aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mx1/clock.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-01-26 09:41:16 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2009-03-13 05:33:46 -0400
commita2865197a5dad23c619c84f44b7fdf7fdbef3f9c (patch)
treee62afa2bf72a8bad1cbfd400f79b92a13617fac6 /arch/arm/mach-mx1/clock.c
parent5512e88f3a1f1b498fd07181f14596ee117b3471 (diff)
[ARM] MXC: Use a single function for decoding a PLL
We had 3 versions of this function in clock support for MX1/2/3 Use a single one instead. I picked the one from the MX3 as it seems to calculate more accurate as the other ones. Also, on MX27 and MX31 mfn can be negative, this hasn't been handled correctly on MX27 since now. This patch has been tested on MX27 and MX31 and produces the same clock frequencies for me. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx1/clock.c')
-rw-r--r--arch/arm/mach-mx1/clock.c31
1 files changed, 2 insertions, 29 deletions
diff --git a/arch/arm/mach-mx1/clock.c b/arch/arm/mach-mx1/clock.c
index 4bcd1ece55f5..3c464331b870 100644
--- a/arch/arm/mach-mx1/clock.c
+++ b/arch/arm/mach-mx1/clock.c
@@ -87,33 +87,6 @@ static int _clk_parent_set_rate(struct clk *clk, unsigned long rate)
87 return clk->parent->set_rate(clk->parent, rate); 87 return clk->parent->set_rate(clk->parent, rate);
88} 88}
89 89
90/*
91 * get the system pll clock in Hz
92 *
93 * mfi + mfn / (mfd +1)
94 * f = 2 * f_ref * --------------------
95 * pd + 1
96 */
97static unsigned long mx1_decode_pll(unsigned int pll, u32 f_ref)
98{
99 unsigned long long ll;
100 unsigned long quot;
101
102 u32 mfi = (pll >> 10) & 0xf;
103 u32 mfn = pll & 0x3ff;
104 u32 mfd = (pll >> 16) & 0x3ff;
105 u32 pd = (pll >> 26) & 0xf;
106
107 mfi = mfi <= 5 ? 5 : mfi;
108
109 ll = 2 * (unsigned long long)f_ref *
110 ((mfi << 16) + (mfn << 16) / (mfd + 1));
111 quot = (pd + 1) * (1 << 16);
112 ll += quot / 2;
113 do_div(ll, quot);
114 return (unsigned long)ll;
115}
116
117static unsigned long clk16m_get_rate(struct clk *clk) 90static unsigned long clk16m_get_rate(struct clk *clk)
118{ 91{
119 return 16000000; 92 return 16000000;
@@ -188,7 +161,7 @@ static struct clk prem_clk = {
188 161
189static unsigned long system_clk_get_rate(struct clk *clk) 162static unsigned long system_clk_get_rate(struct clk *clk)
190{ 163{
191 return mx1_decode_pll(__raw_readl(CCM_SPCTL0), 164 return mxc_decode_pll(__raw_readl(CCM_SPCTL0),
192 clk_get_rate(clk->parent)); 165 clk_get_rate(clk->parent));
193} 166}
194 167
@@ -200,7 +173,7 @@ static struct clk system_clk = {
200 173
201static unsigned long mcu_clk_get_rate(struct clk *clk) 174static unsigned long mcu_clk_get_rate(struct clk *clk)
202{ 175{
203 return mx1_decode_pll(__raw_readl(CCM_MPCTL0), 176 return mxc_decode_pll(__raw_readl(CCM_MPCTL0),
204 clk_get_rate(clk->parent)); 177 clk_get_rate(clk->parent));
205} 178}
206 179