mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations.
@ 2012-05-30 11:21 Alexander Shiyan
  2012-05-30 11:21 ` [PATCH 2/2] i.MX51 clock: Added USB clock to dump_clocks command Alexander Shiyan
  2012-05-31  7:00 ` [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Shiyan @ 2012-05-30 11:21 UTC (permalink / raw)
  To: barebox


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/speed-imx51.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
index 84f4892..b691d37 100644
--- a/arch/arm/mach-imx/speed-imx51.c
+++ b/arch/arm/mach-imx/speed-imx51.c
@@ -24,6 +24,14 @@ static unsigned long fpm_get_rate(void)
 	return ckil_get_rate() * 512;
 }
 
+static unsigned long lp_apm_get_rate(void)
+{
+	if (ccm_readl(MX5_CCM_CCSR) & MX5_CCM_CCSR_LP_APM_SEL)
+		return fpm_get_rate();
+	else
+		return osc_get_rate();
+}
+
 static unsigned long pll_get_rate(void __iomem *pllbase)
 {
 	long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
@@ -123,7 +131,7 @@ unsigned long imx_get_uartclk(void)
 			pll1_main_get_rate,
 			pll2_sw_get_rate,
 			pll3_sw_get_rate,
-			NULL);
+			lp_apm_get_rate);
 
 	reg = ccm_readl(MX5_CCM_CSCDR1);
 	prediv = ((reg & MX5_CCM_CSCDR1_UART_CLK_PRED_MASK) >>
@@ -180,7 +188,7 @@ unsigned long imx_get_mmcclk(void)
 			pll1_main_get_rate,
 			pll2_sw_get_rate,
 			pll3_sw_get_rate,
-			NULL);
+			lp_apm_get_rate);
 
 	reg = ccm_readl(MX5_CCM_CSCDR1);
 	prediv = ((reg & MX5_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_MASK) >>
@@ -193,11 +201,12 @@ unsigned long imx_get_mmcclk(void)
 
 void imx_dump_clocks(void)
 {
-	printf("pll1: %ld\n", pll1_main_get_rate());
-	printf("pll2: %ld\n", pll2_sw_get_rate());
-	printf("pll3: %ld\n", pll3_sw_get_rate());
-	printf("uart: %ld\n", imx_get_uartclk());
-	printf("ipg:  %ld\n", imx_get_ipgclk());
-	printf("fec:  %ld\n", imx_get_fecclk());
-	printf("gpt:  %ld\n", imx_get_gptclk());
+	printf("pll1:   %ld\n", pll1_main_get_rate());
+	printf("pll2:   %ld\n", pll2_sw_get_rate());
+	printf("pll3:   %ld\n", pll3_sw_get_rate());
+	printf("lp_apm: %ld\n", lp_apm_get_rate());
+	printf("uart:   %ld\n", imx_get_uartclk());
+	printf("ipg:    %ld\n", imx_get_ipgclk());
+	printf("fec:    %ld\n", imx_get_fecclk());
+	printf("gpt:    %ld\n", imx_get_gptclk());
 }
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] i.MX51 clock: Added USB clock to dump_clocks command.
  2012-05-30 11:21 [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations Alexander Shiyan
@ 2012-05-30 11:21 ` Alexander Shiyan
  2012-05-31  7:00 ` [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Shiyan @ 2012-05-30 11:21 UTC (permalink / raw)
  To: barebox


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/speed-imx51.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
index b691d37..a94b392 100644
--- a/arch/arm/mach-imx/speed-imx51.c
+++ b/arch/arm/mach-imx/speed-imx51.c
@@ -199,6 +199,28 @@ unsigned long imx_get_mmcclk(void)
 	return rate / (prediv * podf);
 }
 
+unsigned long imx_get_usbclk(void)
+{
+	u32 reg, prediv, podf, rate;
+
+	reg = ccm_readl(MX5_CCM_CSCMR1);
+	reg &= MX5_CCM_CSCMR1_USBOH3_CLK_SEL_MASK;
+	reg >>= MX5_CCM_CSCMR1_USBOH3_CLK_SEL_OFFSET;
+	rate = get_rate_select(reg,
+			pll1_main_get_rate,
+			pll2_sw_get_rate,
+			pll3_sw_get_rate,
+			lp_apm_get_rate);
+
+	reg = ccm_readl(MX5_CCM_CSCDR1);
+	prediv = ((reg & MX5_CCM_CSCDR1_USBOH3_CLK_PRED_MASK) >>
+			MX5_CCM_CSCDR1_USBOH3_CLK_PRED_OFFSET) + 1;
+	podf = ((reg & MX5_CCM_CSCDR1_USBOH3_CLK_PODF_MASK) >>
+			MX5_CCM_CSCDR1_USBOH3_CLK_PODF_OFFSET) + 1;
+
+	return rate / (prediv * podf);
+}
+
 void imx_dump_clocks(void)
 {
 	printf("pll1:   %ld\n", pll1_main_get_rate());
@@ -209,4 +231,5 @@ void imx_dump_clocks(void)
 	printf("ipg:    %ld\n", imx_get_ipgclk());
 	printf("fec:    %ld\n", imx_get_fecclk());
 	printf("gpt:    %ld\n", imx_get_gptclk());
+	printf("usb:    %ld\n", imx_get_usbclk());
 }
-- 
1.7.3.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations.
  2012-05-30 11:21 [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations Alexander Shiyan
  2012-05-30 11:21 ` [PATCH 2/2] i.MX51 clock: Added USB clock to dump_clocks command Alexander Shiyan
@ 2012-05-31  7:00 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-05-31  7:00 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Wed, May 30, 2012 at 03:21:44PM +0400, Alexander Shiyan wrote:
> 
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>

Applied, thanks

Sascha

> ---
>  arch/arm/mach-imx/speed-imx51.c |   27 ++++++++++++++++++---------
>  1 files changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
> index 84f4892..b691d37 100644
> --- a/arch/arm/mach-imx/speed-imx51.c
> +++ b/arch/arm/mach-imx/speed-imx51.c
> @@ -24,6 +24,14 @@ static unsigned long fpm_get_rate(void)
>  	return ckil_get_rate() * 512;
>  }
>  
> +static unsigned long lp_apm_get_rate(void)
> +{
> +	if (ccm_readl(MX5_CCM_CCSR) & MX5_CCM_CCSR_LP_APM_SEL)
> +		return fpm_get_rate();
> +	else
> +		return osc_get_rate();
> +}
> +
>  static unsigned long pll_get_rate(void __iomem *pllbase)
>  {
>  	long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
> @@ -123,7 +131,7 @@ unsigned long imx_get_uartclk(void)
>  			pll1_main_get_rate,
>  			pll2_sw_get_rate,
>  			pll3_sw_get_rate,
> -			NULL);
> +			lp_apm_get_rate);
>  
>  	reg = ccm_readl(MX5_CCM_CSCDR1);
>  	prediv = ((reg & MX5_CCM_CSCDR1_UART_CLK_PRED_MASK) >>
> @@ -180,7 +188,7 @@ unsigned long imx_get_mmcclk(void)
>  			pll1_main_get_rate,
>  			pll2_sw_get_rate,
>  			pll3_sw_get_rate,
> -			NULL);
> +			lp_apm_get_rate);
>  
>  	reg = ccm_readl(MX5_CCM_CSCDR1);
>  	prediv = ((reg & MX5_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_MASK) >>
> @@ -193,11 +201,12 @@ unsigned long imx_get_mmcclk(void)
>  
>  void imx_dump_clocks(void)
>  {
> -	printf("pll1: %ld\n", pll1_main_get_rate());
> -	printf("pll2: %ld\n", pll2_sw_get_rate());
> -	printf("pll3: %ld\n", pll3_sw_get_rate());
> -	printf("uart: %ld\n", imx_get_uartclk());
> -	printf("ipg:  %ld\n", imx_get_ipgclk());
> -	printf("fec:  %ld\n", imx_get_fecclk());
> -	printf("gpt:  %ld\n", imx_get_gptclk());
> +	printf("pll1:   %ld\n", pll1_main_get_rate());
> +	printf("pll2:   %ld\n", pll2_sw_get_rate());
> +	printf("pll3:   %ld\n", pll3_sw_get_rate());
> +	printf("lp_apm: %ld\n", lp_apm_get_rate());
> +	printf("uart:   %ld\n", imx_get_uartclk());
> +	printf("ipg:    %ld\n", imx_get_ipgclk());
> +	printf("fec:    %ld\n", imx_get_fecclk());
> +	printf("gpt:    %ld\n", imx_get_gptclk());
>  }
> -- 
> 1.7.3.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-31  7:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-30 11:21 [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations Alexander Shiyan
2012-05-30 11:21 ` [PATCH 2/2] i.MX51 clock: Added USB clock to dump_clocks command Alexander Shiyan
2012-05-31  7:00 ` [PATCH 1/2] i.MX51 clock: Added lp_apm clock support for frequency calculations Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox