Skip to contentSkip to conversation

clock-imx35: fixes

PATCH New Michael Grzeschik 3 participants 8 messages Aug 16, 2010 – Aug 17, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover clock-imx35: fixes

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 |
#1 lore raw

PATCH 1/4 clock-imx35: use get_3_3_div helper for get_rate_ipg_per

From: Marc Kleine-Budde <[email protected]>

---
 arch/arm/mach-mx3/clock-imx35.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +2 -4
index d3af0fd..4b10f46 100644
@@ -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;
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/4 clock-imx35: use get_3_3_div helper for get_rate_ipg_per

Quoted 30 lines · Michael Grzeschik

From: Marc Kleine-Budde <[email protected]>

---
 arch/arm/mach-mx3/clock-imx35.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +2 -4
index d3af0fd..4b10f46 100644
@@ -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;
Signature · 1 line
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

Signature · 4 lines
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 |
maintainer
#3 lore raw

PATCH 1/4 clock-imx35: use get_3_3_div helper for get_rate_ipg_per

In reply to Michael Grzeschik
Quoted 14 lines · Michael Grzeschik

From: Marc Kleine-Budde <[email protected]>

---
 arch/arm/mach-mx3/clock-imx35.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +0 -0
index d3af0fd..4b10f46 100644
@@ -290,12 +290,10 @@ static unsigned long get_rate_ipg_per(struct clk *clk)
 {

arch/arm/mach-mx3/clock-imx35.c static unsigned long get_rate_ipg_per(struct clk *clk) · line 296

Quoted 10 lines
arch/arm/mach-mx3/clock-imx35.c +2 -4
 	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

Signature · 4 lines
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 |
#4 lore raw

PATCH 2/4 clock-imx35: fix divider if ahb is source for ipg_per

In reply to Michael Grzeschik

From: Marc Kleine-Budde <[email protected]>

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.

---
 arch/arm/mach-mx3/clock-imx35.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +1 -1
index 4b10f46..f54a82c 100644
@@ -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);
 	}
 }
 
Signature · 1 line
1.7.1
#5 lore raw

PATCH 3/4 clock-imx35: correct arm and ahb clock calculation

In reply to Michael Grzeschik

From: Marc Kleine-Budde <[email protected]>

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.

---
 arch/arm/mach-mx3/clock-imx35.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +2 -2
index f54a82c..009156d 100644
@@ -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];
 
Signature · 1 line
1.7.1
#6 lore raw

PATCH 3/4 clock-imx35: correct arm and ahb clock calculation

Quoted 38 lines · Michael Grzeschik

From: Marc Kleine-Budde <[email protected]>

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.

---
 arch/arm/mach-mx3/clock-imx35.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +2 -2
index f54a82c..009156d 100644
@@ -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];
 
Signature · 1 line
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

Signature · 4 lines
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 |
#7 lore raw

PATCH 4/4 clock-imx35: Calculate the base clock rate for the IPU unit

In reply to Michael Grzeschik

From: Juergen Beisert <[email protected]>

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.

---
 arch/arm/mach-mx3/clock-imx35.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +28 -1
index 009156d..9b7dbcc 100644
@@ -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);
Signature · 1 line
1.7.1