Skip to contentSkip to conversation

mx6: clock: Fix the calculation of PLL_ENET frequency

PATCH Superseded Fabio Estevam 2 participants 3 messages Dec 3, 2013 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mx6: clock: Fix the calculation of PLL_ENET frequency

From: Fabio Estevam <[email protected]>

According to the mx6 quad reference manual, the DIV_SELECT field of register CCM_ANALOG_PLL_ENETn has the following meaning:

"Controls the frequency of the ethernet reference clock.
- 00 - 25MHz
- 01 - 50MHz
- 10 - 100MHz
- 11 - 125MHz"

Current logic does not handle the 25MHz case correctly, so fix it.

---
 arch/arm/cpu/armv7/mx6/clock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx6/clock.c +4 -1
index 873d9d0..eab8596 100644
@@ -94,7 +94,10 @@ static u32 decode_pll(enum pll_clocks pll, u32 infreq)
 		div = __raw_readl(&imx_ccm->analog_pll_enet);
 		div &= BM_ANADIG_PLL_ENET_DIV_SELECT;
 
-		return (div == 3 ? 125000000 : 25000000 * (div << 1));
+		if (div == 0)
+			return 25000000;
+		else
+			return (div == 3 ? 125000000 : 25000000 * (div << 1));
 	default:
 		return 0;
 	}
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 mx6: clock: Fix the calculation of PLL_ENET frequency

Quoted 25 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

According to the mx6 quad reference manual, the DIV_SELECT field of register CCM_ANALOG_PLL_ENETn has the following meaning:

"Controls the frequency of the ethernet reference clock.
- 00 - 25MHz
- 01 - 50MHz
- 10 - 100MHz
- 11 - 125MHz"

Current logic does not handle the 25MHz case correctly, so fix it.

---
  arch/arm/cpu/armv7/mx6/clock.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx6/clock.c +0 -0
index 873d9d0..eab8596 100644
@@ -94,7 +94,10 @@ static u32 decode_pll(enum pll_clocks pll, u32 infreq)
  		div = __raw_readl(&imx_ccm->analog_pll_enet);

arch/arm/cpu/armv7/mx6/clock.c static u32 decode_pll(enum pll_clocks pll, u32 infreq) · line 103

Quoted 10 lines
arch/arm/cpu/armv7/mx6/clock.c +4 -1
  		div &= BM_ANADIG_PLL_ENET_DIV_SELECT;
 
-		return (div == 3 ? 125000000 : 25000000 * (div << 1));
+		if (div == 0)
+			return 25000000;
+		else
+			return (div == 3 ? 125000000 : 25000000 * (div << 1));
  	default:
  		return 0;
  	}

How about just

     return 25000000 * (div + (div >> 1) + 1);
#2 lore raw

PATCH 1/1 mx6: clock: Fix the calculation of PLL_ENET frequency

Hi Troy,

Quoted 3 lines · Troy Kisky

How about just

    return 25000000 * (div + (div >> 1) + 1);

That looks much better, thanks!