Skip to contentSkip to conversation

i.MX35 Clock patches

PATCH New Sascha Hauer 2 participants 6 messages Apr 23, 2010

Subsystems (3)
lore
Share & tools
lore

Sascha Hauer

author maintainer
#0 lore raw

Here are some clock fixes for i.MX35.

Sascha

The following changes since commit 2ba3abd8186f24c7fb418927025b4e2120e3a362:
Linus Torvalds (1):

        Merge branch 'pm-fixes' of git://git.kernel.org/.../rafael/suspend-2.6

are available in the git repository at:

git://git.pengutronix.de/git/imx/linux-2.6.git mxc-pu

Sascha Hauer (2):
i.MX35: Fix arm/ahb clock calculation
i.MX35: remove get_3_3_div helper function

 arch/arm/mach-mx3/clock-imx35.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
author maintainer
#1 lore raw

PATCH 1/2 i.MX35: Fix arm/ahb clock calculation

The correct divider for the reference clock if arm_sel is 1 is 3/4 and not 2/3. Also, the ahb clock is also affected by this divider.

---
 arch/arm/mach-mx3/clock-imx35.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +3 -1
index 9f3e943..5c87338 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;
 }
@@ -167,6 +167,8 @@ static unsigned long get_rate_ahb(struct clk *clk)
 	unsigned long fref = get_rate_mpll();
 
 	aad = &clk_consumer[(pdr0 >> 16) & 0xf];
+	if (aad->sel)
+		fref = fref * 3 / 4;
 
 	return fref / aad->ahb;
 }
Signature · 1 line
1.7.0
author maintainer
#2 lore raw

PATCH 2/2 i.MX35: remove get_3_3_div helper function

In reply to Sascha Hauer

In the v2 reference manual there are no dividers combined of two dividers. Instead, all dividers are simple 6bit dividers. I assume the combined dividers only exist in preliminary hardware.

---
 arch/arm/mach-mx3/clock-imx35.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +4 -9
index 5c87338..c6ef64e 100644
@@ -178,16 +178,11 @@ static unsigned long get_rate_ipg(struct clk *clk)
 	return get_rate_ahb(NULL) >> 1;
 }
 
-static unsigned long get_3_3_div(unsigned long in)
-{
-	return (((in >> 3) & 0x7) + 1) * ((in & 0x7) + 1);
-}
-
 static unsigned long get_rate_uart(struct clk *clk)
 {
 	unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3);
 	unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
-	unsigned long div = get_3_3_div(pdr4 >> 10);
+	unsigned long div = ((pdr4 >> 10) & 0x3f) + 1;
 
 	if (pdr3 & (1 << 14))
 		return get_rate_arm() / div;
@@ -218,7 +213,7 @@ static unsigned long get_rate_sdhc(struct clk *clk)
 		break;
 	}
 
-	return rate / get_3_3_div(div);
+	return rate / (div + 1);
 }
 
 static unsigned long get_rate_mshc(struct clk *clk)
@@ -272,7 +267,7 @@ static unsigned long get_rate_csi(struct clk *clk)
 	else
 		rate = get_rate_ppll();
 
-	return rate / get_3_3_div((pdr2 >> 16) & 0x3f);
+	return rate / (((pdr2 >> 16) & 0x3f) + 1);
 }
 
 static unsigned long get_rate_otg(struct clk *clk)
@@ -285,7 +280,7 @@ static unsigned long get_rate_otg(struct clk *clk)
 	else
 		rate = get_rate_ppll();
 
-	return rate / get_3_3_div((pdr4 >> 22) & 0x3f);
+	return rate / (((pdr4 >> 22) & 0x3f) + 1);
 }
 
 static unsigned long get_rate_ipg_per(struct clk *clk)
Signature · 1 line
1.7.0
#3 lore raw

PATCH 2/2 i.MX35: remove get_3_3_div helper function

Hello.

Quoted 32 lines · Sascha Hauer

In the v2 reference manual there are no dividers combined of two dividers. Instead, all dividers are simple 6bit dividers. I assume the combined dividers only exist in preliminary hardware.

---
 arch/arm/mach-mx3/clock-imx35.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)
arch/arm/mach-mx3/clock-imx35.c +1 -6
index 5c87338..c6ef64e 100644
@@ -178,16 +178,11 @@ static unsigned long get_rate_ipg(struct clk *clk)
 	return get_rate_ahb(NULL) >> 1;
 }
 
-static unsigned long get_3_3_div(unsigned long in)
-{
-	return (((in >> 3) & 0x7) + 1) * ((in & 0x7) + 1);
-}
-
 static unsigned long get_rate_uart(struct clk *clk)
 {
 	unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3);
 	unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
-	unsigned long div = get_3_3_div(pdr4 >> 10);
+	unsigned long div = ((pdr4 >> 10) & 0x3f) + 1;
 
 	if (pdr3 & (1 << 14))
 		return get_rate_arm() / div;

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

Quoted 6 lines
arch/arm/mach-mx3/clock-imx35.c +1 -1
@@ -218,7 +213,7 @@ static unsigned long get_rate_sdhc(struct clk *clk)
 		break;
 	}
 
-	return rate / get_3_3_div(div);
+	return rate / (div + 1);
 

You're adding 1 to divisor twice here...

Quoted 13 lines
arch/arm/mach-mx3/clock-imx35.c +0 -0
 }
 

static unsigned long get_rate_mshc(struct clk *clk)

arch/arm/mach-mx3/clock-imx35.c +1 -1
@@ -272,7 +267,7 @@ static unsigned long get_rate_csi(struct clk *clk)
 	else
 		rate = get_rate_ppll();
 
-	return rate / get_3_3_div((pdr2 >> 16) & 0x3f);
+	return rate / (((pdr2 >> 16) & 0x3f) + 1);
 }
 
 static unsigned long get_rate_otg(struct clk *clk)

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

Quoted 6 lines
arch/arm/mach-mx3/clock-imx35.c +1 -1
@@ -285,7 +280,7 @@ static unsigned long get_rate_otg(struct clk *clk)
 	else
 		rate = get_rate_ppll();
 
-	return rate / get_3_3_div((pdr4 >> 22) & 0x3f);
+	return rate / (((pdr4 >> 22) & 0x3f) + 1);
 

... but not here. Is that right?

WBR, Sergei

author maintainer
#4 lore raw

PATCH 2/2 i.MX35: remove get_3_3_div helper function

Quoted 8 lines · Sergei Shtylyov
Quoted 8 lines

static unsigned long get_rate_uart(struct clk *clk) {

arch/arm/mach-mx3/clock-imx35.c +1 -1
 	unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3);
 	unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
-	unsigned long div = get_3_3_div(pdr4 >> 10);
+	unsigned long div = ((pdr4 >> 10) & 0x3f) + 1;
  	if (pdr3 & (1 << 14))
 		return get_rate_arm() / div;
Quoted 8 lines

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

Quoted 6 lines
arch/arm/mach-mx3/clock-imx35.c +1 -0
@@ -218,7 +213,7 @@ static unsigned long get_rate_sdhc(struct clk *clk)
 		break;
 	}
 -	return rate / get_3_3_div(div);
+	return rate / (div + 1);
 

You're adding 1 to divisor twice here...

Look again, these hunks are in two different functions.

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

PATCH 2/2 i.MX35: remove get_3_3_div helper function

Hello.

Quoted 18 lines · Sascha Hauer
Quoted 8 lines
Quoted 8 lines

static unsigned long get_rate_uart(struct clk *clk) {

arch/arm/mach-mx3/clock-imx35.c +1 -1
 	unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3);
 	unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4);
-	unsigned long div = get_3_3_div(pdr4 >> 10);
+	unsigned long div = ((pdr4 >> 10) & 0x3f) + 1;
  	if (pdr3 & (1 << 14))
 		return get_rate_arm() / div;
Quoted 9 lines

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

Quoted 7 lines
arch/arm/mach-mx3/clock-imx35.c +1 -0
@@ -218,7 +213,7 @@ static unsigned long get_rate_sdhc(struct clk *clk)
 		break;
 	}
 -	return rate / get_3_3_div(div);
+	return rate / (div + 1);
 
 

You're adding 1 to divisor twice here...

Quoted 2 lines

Look again, these hunks are in two different functions.

Indeed -- sorry.

Quoted 1 line

Sascha

WBR, Sergei