aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2013-11-10 04:34:49 -0500
committerShawn Guo <shawn.guo@linaro.org>2013-12-30 20:36:29 -0500
commita594790368a89165b92d7146aac2223b5a37637e (patch)
tree30abe1a53da130da596673ee924aa61c1def0332
parent630a212501653d046b61015a4d0f9e3db65382cc (diff)
ARM: imx: pllv1: Fix PLL calculation for i.MX27
MFN bit 9 on i.MX27 has a different meaning than in other SOCs. This is a just sign bit. This patch makes different calculation for i.MX27. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
-rw-r--r--arch/arm/mach-imx/clk-pllv1.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/arch/arm/mach-imx/clk-pllv1.c b/arch/arm/mach-imx/clk-pllv1.c
index c1eaee346954..d21d14ca46c1 100644
--- a/arch/arm/mach-imx/clk-pllv1.c
+++ b/arch/arm/mach-imx/clk-pllv1.c
@@ -18,6 +18,11 @@
18 * 18 *
19 * PLL clock version 1, found on i.MX1/21/25/27/31/35 19 * PLL clock version 1, found on i.MX1/21/25/27/31/35
20 */ 20 */
21
22#define MFN_BITS (10)
23#define MFN_SIGN (BIT(MFN_BITS - 1))
24#define MFN_MASK (MFN_SIGN - 1)
25
21struct clk_pllv1 { 26struct clk_pllv1 {
22 struct clk_hw hw; 27 struct clk_hw hw;
23 void __iomem *base; 28 void __iomem *base;
@@ -25,6 +30,11 @@ struct clk_pllv1 {
25 30
26#define to_clk_pllv1(clk) (container_of(clk, struct clk_pllv1, clk)) 31#define to_clk_pllv1(clk) (container_of(clk, struct clk_pllv1, clk))
27 32
33static inline bool mfn_is_negative(unsigned int mfn)
34{
35 return !cpu_is_mx1() && !cpu_is_mx21() && (mfn & MFN_SIGN);
36}
37
28static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw, 38static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw,
29 unsigned long parent_rate) 39 unsigned long parent_rate)
30{ 40{
@@ -58,10 +68,15 @@ static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw,
58 68
59 /* 69 /*
60 * On all i.MXs except i.MX1 and i.MX21 mfn is a 10bit 70 * On all i.MXs except i.MX1 and i.MX21 mfn is a 10bit
61 * 2's complements number 71 * 2's complements number.
72 * On i.MX27 the bit 9 is the sign bit.
62 */ 73 */
63 if (!cpu_is_mx1() && !cpu_is_mx21() && mfn >= 0x200) 74 if (mfn_is_negative(mfn)) {
64 mfn_abs = 0x400 - mfn; 75 if (cpu_is_mx27())
76 mfn_abs = mfn & MFN_MASK;
77 else
78 mfn_abs = BIT(MFN_BITS) - mfn;
79 }
65 80
66 rate = parent_rate * 2; 81 rate = parent_rate * 2;
67 rate /= pd + 1; 82 rate /= pd + 1;
@@ -70,7 +85,7 @@ static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw,
70 85
71 do_div(ll, mfd + 1); 86 do_div(ll, mfd + 1);
72 87
73 if (!cpu_is_mx1() && !cpu_is_mx21() && mfn >= 0x200) 88 if (mfn_is_negative(mfn))
74 ll = -ll; 89 ll = -ll;
75 90
76 ll = (rate * mfi) + ll; 91 ll = (rate * mfi) + ll;