diff options
author | Magnus Damm <damm@igel.co.jp> | 2009-05-25 04:10:19 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-05-26 04:08:36 -0400 |
commit | c9904dd15922f349b5f06839e34b1723d4a75940 (patch) | |
tree | 7d141fd2b4a106e6a139e341051b8677e9797099 /arch/sh | |
parent | 36aa1e32f451b664adaf3fc9a77d8279b7a833b2 (diff) |
sh: add pll_clk to sh7785
This patch converts the sh7785 pll implementation from the
all-in-one code in frqmr_recalc() and frqmr_build_rate_table()
to a separate struct clk. This allows us to remove the processor
specific multiplier and use generic rate table functions.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/clock-sh7785.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c index cf042b53b3ae..7021ab0bfb88 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c | |||
@@ -56,12 +56,7 @@ static unsigned long frqmr_recalc(struct clk *clk) | |||
56 | 56 | ||
57 | idx = (__raw_readl(FRQMR1) >> data->shift) & 0x000f; | 57 | idx = (__raw_readl(FRQMR1) >> data->shift) & 0x000f; |
58 | 58 | ||
59 | /* | 59 | return clk->parent->rate / div2[idx]; |
60 | * XXX: PLL1 multiplier is locked for the default clock mode, | ||
61 | * when mode pin detection and configuration support is added, | ||
62 | * select the multiplier dynamically. | ||
63 | */ | ||
64 | return clk->parent->rate * 36 / div2[idx]; | ||
65 | } | 60 | } |
66 | 61 | ||
67 | static void frqmr_build_rate_table(struct clk *clk) | 62 | static void frqmr_build_rate_table(struct clk *clk) |
@@ -75,7 +70,7 @@ static void frqmr_build_rate_table(struct clk *clk) | |||
75 | 70 | ||
76 | data->freq_table[entry].index = entry; | 71 | data->freq_table[entry].index = entry; |
77 | data->freq_table[entry].frequency = | 72 | data->freq_table[entry].frequency = |
78 | clk->parent->rate * 36 / div2[i]; | 73 | clk->parent->rate / div2[i]; |
79 | 74 | ||
80 | entry++; | 75 | entry++; |
81 | } | 76 | } |
@@ -136,6 +131,20 @@ static struct clk_ops frqmr_clk_ops = { | |||
136 | .round_rate = frqmr_round_rate, | 131 | .round_rate = frqmr_round_rate, |
137 | }; | 132 | }; |
138 | 133 | ||
134 | static unsigned long pll_recalc(struct clk *clk) | ||
135 | { | ||
136 | /* | ||
137 | * XXX: PLL1 multiplier is locked for the default clock mode, | ||
138 | * when mode pin detection and configuration support is added, | ||
139 | * select the multiplier dynamically. | ||
140 | */ | ||
141 | return clk->parent->rate * 36; | ||
142 | } | ||
143 | |||
144 | static struct clk_ops pll_clk_ops = { | ||
145 | .recalc = pll_recalc, | ||
146 | }; | ||
147 | |||
139 | /* | 148 | /* |
140 | * Default rate for the root input clock, reset this with clk_set_rate() | 149 | * Default rate for the root input clock, reset this with clk_set_rate() |
141 | * from the platform code. | 150 | * from the platform code. |
@@ -146,11 +155,19 @@ static struct clk extal_clk = { | |||
146 | .rate = 33333333, | 155 | .rate = 33333333, |
147 | }; | 156 | }; |
148 | 157 | ||
158 | static struct clk pll_clk = { | ||
159 | .name = "pll_clk", | ||
160 | .id = -1, | ||
161 | .ops = &pll_clk_ops, | ||
162 | .parent = &extal_clk, | ||
163 | .flags = CLK_ENABLE_ON_INIT, | ||
164 | }; | ||
165 | |||
149 | static struct clk cpu_clk = { | 166 | static struct clk cpu_clk = { |
150 | .name = "cpu_clk", /* Ick */ | 167 | .name = "cpu_clk", /* Ick */ |
151 | .id = -1, | 168 | .id = -1, |
152 | .ops = &frqmr_clk_ops, | 169 | .ops = &frqmr_clk_ops, |
153 | .parent = &extal_clk, | 170 | .parent = &pll_clk, |
154 | .flags = CLK_ENABLE_ON_INIT, | 171 | .flags = CLK_ENABLE_ON_INIT, |
155 | .priv = &ifc_data, | 172 | .priv = &ifc_data, |
156 | }; | 173 | }; |
@@ -159,7 +176,7 @@ static struct clk shyway_clk = { | |||
159 | .name = "shyway_clk", /* SHck */ | 176 | .name = "shyway_clk", /* SHck */ |
160 | .id = -1, | 177 | .id = -1, |
161 | .ops = &frqmr_clk_ops, | 178 | .ops = &frqmr_clk_ops, |
162 | .parent = &extal_clk, | 179 | .parent = &pll_clk, |
163 | .flags = CLK_ENABLE_ON_INIT, | 180 | .flags = CLK_ENABLE_ON_INIT, |
164 | .priv = &sfc_data, | 181 | .priv = &sfc_data, |
165 | }; | 182 | }; |
@@ -168,7 +185,7 @@ static struct clk peripheral_clk = { | |||
168 | .name = "peripheral_clk", /* Pck */ | 185 | .name = "peripheral_clk", /* Pck */ |
169 | .id = -1, | 186 | .id = -1, |
170 | .ops = &frqmr_clk_ops, | 187 | .ops = &frqmr_clk_ops, |
171 | .parent = &extal_clk, | 188 | .parent = &pll_clk, |
172 | .flags = CLK_ENABLE_ON_INIT, | 189 | .flags = CLK_ENABLE_ON_INIT, |
173 | .priv = &pfc_data, | 190 | .priv = &pfc_data, |
174 | }; | 191 | }; |
@@ -177,7 +194,7 @@ static struct clk ddr_clk = { | |||
177 | .name = "ddr_clk", /* DDRck */ | 194 | .name = "ddr_clk", /* DDRck */ |
178 | .id = -1, | 195 | .id = -1, |
179 | .ops = &frqmr_clk_ops, | 196 | .ops = &frqmr_clk_ops, |
180 | .parent = &extal_clk, | 197 | .parent = &pll_clk, |
181 | .flags = CLK_ENABLE_ON_INIT, | 198 | .flags = CLK_ENABLE_ON_INIT, |
182 | .priv = &mfc_data, | 199 | .priv = &mfc_data, |
183 | }; | 200 | }; |
@@ -186,7 +203,7 @@ static struct clk bus_clk = { | |||
186 | .name = "bus_clk", /* Bck */ | 203 | .name = "bus_clk", /* Bck */ |
187 | .id = -1, | 204 | .id = -1, |
188 | .ops = &frqmr_clk_ops, | 205 | .ops = &frqmr_clk_ops, |
189 | .parent = &extal_clk, | 206 | .parent = &pll_clk, |
190 | .flags = CLK_ENABLE_ON_INIT, | 207 | .flags = CLK_ENABLE_ON_INIT, |
191 | .priv = &bfc_data, | 208 | .priv = &bfc_data, |
192 | }; | 209 | }; |
@@ -195,7 +212,7 @@ static struct clk ga_clk = { | |||
195 | .name = "ga_clk", /* GAck */ | 212 | .name = "ga_clk", /* GAck */ |
196 | .id = -1, | 213 | .id = -1, |
197 | .ops = &frqmr_clk_ops, | 214 | .ops = &frqmr_clk_ops, |
198 | .parent = &extal_clk, | 215 | .parent = &pll_clk, |
199 | .priv = &s2fc_data, | 216 | .priv = &s2fc_data, |
200 | }; | 217 | }; |
201 | 218 | ||
@@ -203,7 +220,7 @@ static struct clk du_clk = { | |||
203 | .name = "du_clk", /* DUck */ | 220 | .name = "du_clk", /* DUck */ |
204 | .id = -1, | 221 | .id = -1, |
205 | .ops = &frqmr_clk_ops, | 222 | .ops = &frqmr_clk_ops, |
206 | .parent = &extal_clk, | 223 | .parent = &pll_clk, |
207 | .priv = &s3fc_data, | 224 | .priv = &s3fc_data, |
208 | }; | 225 | }; |
209 | 226 | ||
@@ -211,13 +228,14 @@ static struct clk umem_clk = { | |||
211 | .name = "umem_clk", /* uck */ | 228 | .name = "umem_clk", /* uck */ |
212 | .id = -1, | 229 | .id = -1, |
213 | .ops = &frqmr_clk_ops, | 230 | .ops = &frqmr_clk_ops, |
214 | .parent = &extal_clk, | 231 | .parent = &pll_clk, |
215 | .flags = CLK_ENABLE_ON_INIT, | 232 | .flags = CLK_ENABLE_ON_INIT, |
216 | .priv = &ufc_data, | 233 | .priv = &ufc_data, |
217 | }; | 234 | }; |
218 | 235 | ||
219 | static struct clk *clks[] = { | 236 | static struct clk *clks[] = { |
220 | &extal_clk, | 237 | &extal_clk, |
238 | &pll_clk, | ||
221 | &cpu_clk, | 239 | &cpu_clk, |
222 | ­way_clk, | 240 | ­way_clk, |
223 | &peripheral_clk, | 241 | &peripheral_clk, |