diff options
author | Stefan Wahren <stefan.wahren@i2se.com> | 2015-02-12 15:30:07 -0500 |
---|---|---|
committer | Michael Turquette <mturquette@linaro.org> | 2015-02-18 13:13:26 -0500 |
commit | a92614879128b8f797f0b3119ef42a129be5eded (patch) | |
tree | 555741cea26ee80bf4bcbd7e462ceaeb0f5e763b /drivers/clk | |
parent | a513b72cc3606f49addca31bf2322bb26e374010 (diff) |
Revert "clk: mxs: Fix invalid 32-bit access to frac registers"
Revert commit 039e59707507 (clk: mxs: Fix invalid 32-bit access to frac
registers), because it leads to a faulty spi communication on mx28evk.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reported-by: Fabio Estevam <fabio.estevam@freescale.com>
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/mxs/clk-imx23.c | 11 | ||||
-rw-r--r-- | drivers/clk/mxs/clk-imx28.c | 19 | ||||
-rw-r--r-- | drivers/clk/mxs/clk-ref.c | 19 |
3 files changed, 18 insertions, 31 deletions
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c index a084566cf7e2..9fc9359f5133 100644 --- a/drivers/clk/mxs/clk-imx23.c +++ b/drivers/clk/mxs/clk-imx23.c | |||
@@ -46,13 +46,11 @@ static void __iomem *digctrl; | |||
46 | #define BP_CLKSEQ_BYPASS_SAIF 0 | 46 | #define BP_CLKSEQ_BYPASS_SAIF 0 |
47 | #define BP_CLKSEQ_BYPASS_SSP 5 | 47 | #define BP_CLKSEQ_BYPASS_SSP 5 |
48 | #define BP_SAIF_DIV_FRAC_EN 16 | 48 | #define BP_SAIF_DIV_FRAC_EN 16 |
49 | 49 | #define BP_FRAC_IOFRAC 24 | |
50 | #define FRAC_IO 3 | ||
51 | 50 | ||
52 | static void __init clk_misc_init(void) | 51 | static void __init clk_misc_init(void) |
53 | { | 52 | { |
54 | u32 val; | 53 | u32 val; |
55 | u8 frac; | ||
56 | 54 | ||
57 | /* Gate off cpu clock in WFI for power saving */ | 55 | /* Gate off cpu clock in WFI for power saving */ |
58 | writel_relaxed(1 << BP_CPU_INTERRUPT_WAIT, CPU + SET); | 56 | writel_relaxed(1 << BP_CPU_INTERRUPT_WAIT, CPU + SET); |
@@ -74,12 +72,9 @@ static void __init clk_misc_init(void) | |||
74 | /* | 72 | /* |
75 | * 480 MHz seems too high to be ssp clock source directly, | 73 | * 480 MHz seems too high to be ssp clock source directly, |
76 | * so set frac to get a 288 MHz ref_io. | 74 | * so set frac to get a 288 MHz ref_io. |
77 | * According to reference manual we must access frac bytewise. | ||
78 | */ | 75 | */ |
79 | frac = readb_relaxed(FRAC + FRAC_IO); | 76 | writel_relaxed(0x3f << BP_FRAC_IOFRAC, FRAC + CLR); |
80 | frac &= ~0x3f; | 77 | writel_relaxed(30 << BP_FRAC_IOFRAC, FRAC + SET); |
81 | frac |= 30; | ||
82 | writeb_relaxed(frac, FRAC + FRAC_IO); | ||
83 | } | 78 | } |
84 | 79 | ||
85 | static const char *sel_pll[] __initconst = { "pll", "ref_xtal", }; | 80 | static const char *sel_pll[] __initconst = { "pll", "ref_xtal", }; |
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c index c541377838a8..a6c35010e4e5 100644 --- a/drivers/clk/mxs/clk-imx28.c +++ b/drivers/clk/mxs/clk-imx28.c | |||
@@ -53,9 +53,8 @@ static void __iomem *clkctrl; | |||
53 | #define BP_ENET_SLEEP 31 | 53 | #define BP_ENET_SLEEP 31 |
54 | #define BP_CLKSEQ_BYPASS_SAIF0 0 | 54 | #define BP_CLKSEQ_BYPASS_SAIF0 0 |
55 | #define BP_CLKSEQ_BYPASS_SSP0 3 | 55 | #define BP_CLKSEQ_BYPASS_SSP0 3 |
56 | 56 | #define BP_FRAC0_IO1FRAC 16 | |
57 | #define FRAC0_IO1 2 | 57 | #define BP_FRAC0_IO0FRAC 24 |
58 | #define FRAC0_IO0 3 | ||
59 | 58 | ||
60 | static void __iomem *digctrl; | 59 | static void __iomem *digctrl; |
61 | #define DIGCTRL digctrl | 60 | #define DIGCTRL digctrl |
@@ -86,7 +85,6 @@ int mxs_saif_clkmux_select(unsigned int clkmux) | |||
86 | static void __init clk_misc_init(void) | 85 | static void __init clk_misc_init(void) |
87 | { | 86 | { |
88 | u32 val; | 87 | u32 val; |
89 | u8 frac; | ||
90 | 88 | ||
91 | /* Gate off cpu clock in WFI for power saving */ | 89 | /* Gate off cpu clock in WFI for power saving */ |
92 | writel_relaxed(1 << BP_CPU_INTERRUPT_WAIT, CPU + SET); | 90 | writel_relaxed(1 << BP_CPU_INTERRUPT_WAIT, CPU + SET); |
@@ -120,16 +118,11 @@ static void __init clk_misc_init(void) | |||
120 | /* | 118 | /* |
121 | * 480 MHz seems too high to be ssp clock source directly, | 119 | * 480 MHz seems too high to be ssp clock source directly, |
122 | * so set frac0 to get a 288 MHz ref_io0 and ref_io1. | 120 | * so set frac0 to get a 288 MHz ref_io0 and ref_io1. |
123 | * According to reference manual we must access frac0 bytewise. | ||
124 | */ | 121 | */ |
125 | frac = readb_relaxed(FRAC0 + FRAC0_IO0); | 122 | val = readl_relaxed(FRAC0); |
126 | frac &= ~0x3f; | 123 | val &= ~((0x3f << BP_FRAC0_IO0FRAC) | (0x3f << BP_FRAC0_IO1FRAC)); |
127 | frac |= 30; | 124 | val |= (30 << BP_FRAC0_IO0FRAC) | (30 << BP_FRAC0_IO1FRAC); |
128 | writeb_relaxed(frac, FRAC0 + FRAC0_IO0); | 125 | writel_relaxed(val, FRAC0); |
129 | frac = readb_relaxed(FRAC0 + FRAC0_IO1); | ||
130 | frac &= ~0x3f; | ||
131 | frac |= 30; | ||
132 | writeb_relaxed(frac, FRAC0 + FRAC0_IO1); | ||
133 | } | 126 | } |
134 | 127 | ||
135 | static const char *sel_cpu[] __initconst = { "ref_cpu", "ref_xtal", }; | 128 | static const char *sel_cpu[] __initconst = { "ref_cpu", "ref_xtal", }; |
diff --git a/drivers/clk/mxs/clk-ref.c b/drivers/clk/mxs/clk-ref.c index ad3851c93c90..4adeed6c2f94 100644 --- a/drivers/clk/mxs/clk-ref.c +++ b/drivers/clk/mxs/clk-ref.c | |||
@@ -16,8 +16,6 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include "clk.h" | 17 | #include "clk.h" |
18 | 18 | ||
19 | #define BF_CLKGATE BIT(7) | ||
20 | |||
21 | /** | 19 | /** |
22 | * struct clk_ref - mxs reference clock | 20 | * struct clk_ref - mxs reference clock |
23 | * @hw: clk_hw for the reference clock | 21 | * @hw: clk_hw for the reference clock |
@@ -41,7 +39,7 @@ static int clk_ref_enable(struct clk_hw *hw) | |||
41 | { | 39 | { |
42 | struct clk_ref *ref = to_clk_ref(hw); | 40 | struct clk_ref *ref = to_clk_ref(hw); |
43 | 41 | ||
44 | writeb_relaxed(BF_CLKGATE, ref->reg + ref->idx + CLR); | 42 | writel_relaxed(1 << ((ref->idx + 1) * 8 - 1), ref->reg + CLR); |
45 | 43 | ||
46 | return 0; | 44 | return 0; |
47 | } | 45 | } |
@@ -50,7 +48,7 @@ static void clk_ref_disable(struct clk_hw *hw) | |||
50 | { | 48 | { |
51 | struct clk_ref *ref = to_clk_ref(hw); | 49 | struct clk_ref *ref = to_clk_ref(hw); |
52 | 50 | ||
53 | writeb_relaxed(BF_CLKGATE, ref->reg + ref->idx + SET); | 51 | writel_relaxed(1 << ((ref->idx + 1) * 8 - 1), ref->reg + SET); |
54 | } | 52 | } |
55 | 53 | ||
56 | static unsigned long clk_ref_recalc_rate(struct clk_hw *hw, | 54 | static unsigned long clk_ref_recalc_rate(struct clk_hw *hw, |
@@ -58,7 +56,7 @@ static unsigned long clk_ref_recalc_rate(struct clk_hw *hw, | |||
58 | { | 56 | { |
59 | struct clk_ref *ref = to_clk_ref(hw); | 57 | struct clk_ref *ref = to_clk_ref(hw); |
60 | u64 tmp = parent_rate; | 58 | u64 tmp = parent_rate; |
61 | u8 frac = readb_relaxed(ref->reg + ref->idx) & 0x3f; | 59 | u8 frac = (readl_relaxed(ref->reg) >> (ref->idx * 8)) & 0x3f; |
62 | 60 | ||
63 | tmp *= 18; | 61 | tmp *= 18; |
64 | do_div(tmp, frac); | 62 | do_div(tmp, frac); |
@@ -95,7 +93,8 @@ static int clk_ref_set_rate(struct clk_hw *hw, unsigned long rate, | |||
95 | struct clk_ref *ref = to_clk_ref(hw); | 93 | struct clk_ref *ref = to_clk_ref(hw); |
96 | unsigned long flags; | 94 | unsigned long flags; |
97 | u64 tmp = parent_rate; | 95 | u64 tmp = parent_rate; |
98 | u8 frac, val; | 96 | u32 val; |
97 | u8 frac, shift = ref->idx * 8; | ||
99 | 98 | ||
100 | tmp = tmp * 18 + rate / 2; | 99 | tmp = tmp * 18 + rate / 2; |
101 | do_div(tmp, rate); | 100 | do_div(tmp, rate); |
@@ -108,10 +107,10 @@ static int clk_ref_set_rate(struct clk_hw *hw, unsigned long rate, | |||
108 | 107 | ||
109 | spin_lock_irqsave(&mxs_lock, flags); | 108 | spin_lock_irqsave(&mxs_lock, flags); |
110 | 109 | ||
111 | val = readb_relaxed(ref->reg + ref->idx); | 110 | val = readl_relaxed(ref->reg); |
112 | val &= ~0x3f; | 111 | val &= ~(0x3f << shift); |
113 | val |= frac; | 112 | val |= frac << shift; |
114 | writeb_relaxed(val, ref->reg + ref->idx); | 113 | writel_relaxed(val, ref->reg); |
115 | 114 | ||
116 | spin_unlock_irqrestore(&mxs_lock, flags); | 115 | spin_unlock_irqrestore(&mxs_lock, flags); |
117 | 116 | ||