linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH|RESEND 0/4] clock-imx35: fixes
@ 2010-08-16 13:54 Michael Grzeschik
  2010-08-16 13:54 ` [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per Michael Grzeschik
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Michael Grzeschik @ 2010-08-16 13:54 UTC (permalink / raw)
  To: linux-arm-kernel

The following clock specific patchseries with fixes for the mx35
are tested and checked againsted the following Datasheet:

"i.MX35 (MCIMX35) Multimedia Applications Processor Reference Manual,
Rev. 2"

Juergen Beisert (1):
  clock-imx35: Calculate the base clock rate for the IPU unit

Marc Kleine-Budde (3):
  clock-imx35: use get_3_3_div helper for get_rate_ipg_per
  clock-imx35: fix divider if ahb is source for ipg_per
  clock-imx35: correct arm and ahb clock calculation

 arch/arm/mach-mx3/clock-imx35.c |   41 +++++++++++++++++++++++++++++++-------
 1 files changed, 33 insertions(+), 8 deletions(-)

--
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 |

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

* [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per
  2010-08-16 13:54 [PATCH|RESEND 0/4] clock-imx35: fixes Michael Grzeschik
@ 2010-08-16 13:54 ` Michael Grzeschik
  2010-08-16 15:25   ` Michael Grzeschik
  2010-08-17  7:06   ` Sascha Hauer
  2010-08-16 13:54 ` [PATCH|RESEND 2/4] clock-imx35: fix divider if ahb is source for ipg_per Michael Grzeschik
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 8+ messages in thread
From: Michael Grzeschik @ 2010-08-16 13:54 UTC (permalink / raw)
  To: linux-arm-kernel

From: Marc Kleine-Budde <mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 arch/arm/mach-mx3/clock-imx35.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index d3af0fd..4b10f46 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -290,12 +290,10 @@ static unsigned long get_rate_ipg_per(struct clk *clk)
 {
 	unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
 	unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
-	unsigned long div1, div2;
+	unsigned long div1;
 
 	if (pdr0 & (1 << 26)) {
-		div1 = (pdr4 >> 19) & 0x7;
-		div2 = (pdr4 >> 16) & 0x7;
-		return get_rate_arm() / ((div1 + 1) * (div2 + 1));
+		return get_rate_arm() / get_3_3_div(pdr4 >> 16);
 	} else {
 		div1 = (pdr0 >> 12) & 0x7;
 		return get_rate_ahb(NULL) / div1;
-- 
1.7.1

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

* [PATCH|RESEND 2/4] clock-imx35: fix divider if ahb is source for ipg_per
  2010-08-16 13:54 [PATCH|RESEND 0/4] clock-imx35: fixes Michael Grzeschik
  2010-08-16 13:54 ` [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per Michael Grzeschik
@ 2010-08-16 13:54 ` Michael Grzeschik
  2010-08-16 13:54 ` [PATCH|RESEND 3/4] clock-imx35: correct arm and ahb clock calculation Michael Grzeschik
  2010-08-16 13:54 ` [PATCH|RESEND 4/4] clock-imx35: Calculate the base clock rate for the IPU unit Michael Grzeschik
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Grzeschik @ 2010-08-16 13:54 UTC (permalink / raw)
  To: linux-arm-kernel

From: Marc Kleine-Budde <mkl@pengutronix.de>

According to the Datasheet:
"i.MX35 (MCIMX35) Multimedia Applications Processor Reference Manual,
Rev. 2" "Table 14-6. PDR0 Field Descriptions" the divider is
CCM_PER_AHB[3:0] + 1.

This patch adds the missing + 1.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 arch/arm/mach-mx3/clock-imx35.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index 4b10f46..f54a82c 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -296,7 +296,7 @@ static unsigned long get_rate_ipg_per(struct clk *clk)
 		return get_rate_arm() / get_3_3_div(pdr4 >> 16);
 	} else {
 		div1 = (pdr0 >> 12) & 0x7;
-		return get_rate_ahb(NULL) / div1;
+		return get_rate_ahb(NULL) / (div1 + 1);
 	}
 }
 
-- 
1.7.1

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

* [PATCH|RESEND 3/4] clock-imx35: correct arm and ahb clock calculation
  2010-08-16 13:54 [PATCH|RESEND 0/4] clock-imx35: fixes Michael Grzeschik
  2010-08-16 13:54 ` [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per Michael Grzeschik
  2010-08-16 13:54 ` [PATCH|RESEND 2/4] clock-imx35: fix divider if ahb is source for ipg_per Michael Grzeschik
@ 2010-08-16 13:54 ` Michael Grzeschik
  2010-08-16 15:32   ` Michael Grzeschik
  2010-08-16 13:54 ` [PATCH|RESEND 4/4] clock-imx35: Calculate the base clock rate for the IPU unit Michael Grzeschik
  3 siblings, 1 reply; 8+ messages in thread
From: Michael Grzeschik @ 2010-08-16 13:54 UTC (permalink / raw)
  To: linux-arm-kernel

From: Marc Kleine-Budde <mkl@pengutronix.de>

According to the Datasheet:
"i.MX35 (MCIMX35) Multimedia Applications Processor Reference Manual,
Rev. 2" "Figure 14-24. Clock Control And Gating"
change the result of get_rate_ahb based on the frequency returned
by get_rate_arm to calculate the proper rate.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 arch/arm/mach-mx3/clock-imx35.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index f54a82c..009156d 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -155,7 +155,7 @@ static unsigned long get_rate_arm(void)
 
 	aad = &clk_consumer[(pdr0 >> 16) & 0xf];
 	if (aad->sel)
-		fref = fref * 2 / 3;
+		fref = fref * 3 / 4;
 
 	return fref / aad->arm;
 }
@@ -164,7 +164,7 @@ static unsigned long get_rate_ahb(struct clk *clk)
 {
 	unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
 	struct arm_ahb_div *aad;
-	unsigned long fref = get_rate_mpll();
+	unsigned long fref = get_rate_arm();
 
 	aad = &clk_consumer[(pdr0 >> 16) & 0xf];
 
-- 
1.7.1

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

* [PATCH|RESEND 4/4] clock-imx35: Calculate the base clock rate for the IPU unit
  2010-08-16 13:54 [PATCH|RESEND 0/4] clock-imx35: fixes Michael Grzeschik
                   ` (2 preceding siblings ...)
  2010-08-16 13:54 ` [PATCH|RESEND 3/4] clock-imx35: correct arm and ahb clock calculation Michael Grzeschik
@ 2010-08-16 13:54 ` Michael Grzeschik
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Grzeschik @ 2010-08-16 13:54 UTC (permalink / raw)
  To: linux-arm-kernel

From: Juergen Beisert <jbe@pengutronix.de>

The mx3fb driver needs the clock the IPU runs in order to calculate
the divider for the LCD clock. This patch adds the clock rate calculation
routine for the i.MX35 CPU.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 arch/arm/mach-mx3/clock-imx35.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index 009156d..9b7dbcc 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -300,6 +300,33 @@ static unsigned long get_rate_ipg_per(struct clk *clk)
 	}
 }
 
+static unsigned long get_rate_hsp(struct clk *clk)
+{
+	unsigned long hsp_podf = (__raw_readl(CCM_BASE + CCM_PDR0) >> 20) & 0x03;
+	unsigned long fref = get_rate_mpll();
+
+	if (fref > 400 * 1000 * 1000) {
+		switch (hsp_podf) {
+		case 0:
+			return fref >> 2;
+		case 1:
+			return fref >> 3;
+		case 2:
+			return fref / 3;
+		}
+	} else {
+		switch (hsp_podf) {
+		case 0:
+		case 2:
+			return fref / 3;
+		case 1:
+			return fref / 6;
+		}
+	}
+
+	return 0;
+}
+
 static int clk_cgr_enable(struct clk *clk)
 {
 	u32 reg;
@@ -357,7 +384,7 @@ DEFINE_CLOCK(i2c1_clk,   0, CCM_CGR1, 10, get_rate_ipg_per, NULL);
 DEFINE_CLOCK(i2c2_clk,   1, CCM_CGR1, 12, get_rate_ipg_per, NULL);
 DEFINE_CLOCK(i2c3_clk,   2, CCM_CGR1, 14, get_rate_ipg_per, NULL);
 DEFINE_CLOCK(iomuxc_clk, 0, CCM_CGR1, 16, NULL, NULL);
-DEFINE_CLOCK(ipu_clk,    0, CCM_CGR1, 18, get_rate_ahb, NULL);
+DEFINE_CLOCK(ipu_clk,    0, CCM_CGR1, 18, get_rate_hsp, NULL);
 DEFINE_CLOCK(kpp_clk,    0, CCM_CGR1, 20, get_rate_ipg, NULL);
 DEFINE_CLOCK(mlb_clk,    0, CCM_CGR1, 22, get_rate_ahb, NULL);
 DEFINE_CLOCK(mshc_clk,   0, CCM_CGR1, 24, get_rate_mshc, NULL);
-- 
1.7.1

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

* [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per
  2010-08-16 13:54 ` [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per Michael Grzeschik
@ 2010-08-16 15:25   ` Michael Grzeschik
  2010-08-17  7:06   ` Sascha Hauer
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Grzeschik @ 2010-08-16 15:25 UTC (permalink / raw)
  To: linux-arm-kernel


On Mon, Aug 16, 2010 at 03:54:04PM +0200, Michael Grzeschik wrote:
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  arch/arm/mach-mx3/clock-imx35.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
> index d3af0fd..4b10f46 100644
> --- a/arch/arm/mach-mx3/clock-imx35.c
> +++ b/arch/arm/mach-mx3/clock-imx35.c
> @@ -290,12 +290,10 @@ static unsigned long get_rate_ipg_per(struct clk *clk)
>  {
>  	unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
>  	unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
> -	unsigned long div1, div2;
> +	unsigned long div1;
>  
>  	if (pdr0 & (1 << 26)) {
> -		div1 = (pdr4 >> 19) & 0x7;
> -		div2 = (pdr4 >> 16) & 0x7;
> -		return get_rate_arm() / ((div1 + 1) * (div2 + 1));
> +		return get_rate_arm() / get_3_3_div(pdr4 >> 16);
>  	} else {
>  		div1 = (pdr0 >> 12) & 0x7;
>  		return get_rate_ahb(NULL) / div1;
> -- 
> 1.7.1
> 

This one is probably not necessary/possible anymore
when we look into this tree [1] in branch imx-for-2.6.36
for following patch:

5e05cb09aede7e3571673b142143f68575590136 i.MX35: remove get_3_3_div helper function

[1] git://git.pengutronix.de/git/imx/linux-2.6.git

Michael

-- 
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 |

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

* [PATCH|RESEND 3/4] clock-imx35: correct arm and ahb clock calculation
  2010-08-16 13:54 ` [PATCH|RESEND 3/4] clock-imx35: correct arm and ahb clock calculation Michael Grzeschik
@ 2010-08-16 15:32   ` Michael Grzeschik
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Grzeschik @ 2010-08-16 15:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 16, 2010 at 03:54:06PM +0200, Michael Grzeschik wrote:
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> According to the Datasheet:
> "i.MX35 (MCIMX35) Multimedia Applications Processor Reference Manual,
> Rev. 2" "Figure 14-24. Clock Control And Gating"
> change the result of get_rate_ahb based on the frequency returned
> by get_rate_arm to calculate the proper rate.
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  arch/arm/mach-mx3/clock-imx35.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
> index f54a82c..009156d 100644
> --- a/arch/arm/mach-mx3/clock-imx35.c
> +++ b/arch/arm/mach-mx3/clock-imx35.c
> @@ -155,7 +155,7 @@ static unsigned long get_rate_arm(void)
>  
>  	aad = &clk_consumer[(pdr0 >> 16) & 0xf];
>  	if (aad->sel)
> -		fref = fref * 2 / 3;
> +		fref = fref * 3 / 4;
>  
>  	return fref / aad->arm;
>  }
> @@ -164,7 +164,7 @@ static unsigned long get_rate_ahb(struct clk *clk)
>  {
>  	unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
>  	struct arm_ahb_div *aad;
> -	unsigned long fref = get_rate_mpll();
> +	unsigned long fref = get_rate_arm();
>  
>  	aad = &clk_consumer[(pdr0 >> 16) & 0xf];
>  
> -- 
> 1.7.1

This one is probably not needed anymore and conflicts with
the following patch in this tree [1] in branch imx-for-2.6.36:

a4104f4c3e6e24961e4d29f96c0488a7bce8da8d i.MX35: Fix arm/ahb clock calculation

[1] git://git.pengutronix.de/git/imx/linux-2.6.git

Michael

-- 
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 |

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

* [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per
  2010-08-16 13:54 ` [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per Michael Grzeschik
  2010-08-16 15:25   ` Michael Grzeschik
@ 2010-08-17  7:06   ` Sascha Hauer
  1 sibling, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2010-08-17  7:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 16, 2010 at 03:54:04PM +0200, Michael Grzeschik wrote:
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  arch/arm/mach-mx3/clock-imx35.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
> index d3af0fd..4b10f46 100644
> --- a/arch/arm/mach-mx3/clock-imx35.c
> +++ b/arch/arm/mach-mx3/clock-imx35.c
> @@ -290,12 +290,10 @@ static unsigned long get_rate_ipg_per(struct clk *clk)
>  {
>  	unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0);
>  	unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
> -	unsigned long div1, div2;
> +	unsigned long div1;
>  
>  	if (pdr0 & (1 << 26)) {
> -		div1 = (pdr4 >> 19) & 0x7;
> -		div2 = (pdr4 >> 16) & 0x7;
> -		return get_rate_arm() / ((div1 + 1) * (div2 + 1));
> +		return get_rate_arm() / get_3_3_div(pdr4 >> 16);

This is wrong. According to newer Datasheets this field contains a plain
6bit divider not to cascaded 3bit dividers.

Sascha


-- 
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 |

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

end of thread, other threads:[~2010-08-17  7:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16 13:54 [PATCH|RESEND 0/4] clock-imx35: fixes Michael Grzeschik
2010-08-16 13:54 ` [PATCH|RESEND 1/4] clock-imx35: use get_3_3_div helper for get_rate_ipg_per Michael Grzeschik
2010-08-16 15:25   ` Michael Grzeschik
2010-08-17  7:06   ` Sascha Hauer
2010-08-16 13:54 ` [PATCH|RESEND 2/4] clock-imx35: fix divider if ahb is source for ipg_per Michael Grzeschik
2010-08-16 13:54 ` [PATCH|RESEND 3/4] clock-imx35: correct arm and ahb clock calculation Michael Grzeschik
2010-08-16 15:32   ` Michael Grzeschik
2010-08-16 13:54 ` [PATCH|RESEND 4/4] clock-imx35: Calculate the base clock rate for the IPU unit Michael Grzeschik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).