diff options
Diffstat (limited to 'arch/arm/mach-spear6xx/clock.c')
-rw-r--r-- | arch/arm/mach-spear6xx/clock.c | 356 |
1 files changed, 276 insertions, 80 deletions
diff --git a/arch/arm/mach-spear6xx/clock.c b/arch/arm/mach-spear6xx/clock.c index 36ff056b7321..88b748b5be80 100644 --- a/arch/arm/mach-spear6xx/clock.c +++ b/arch/arm/mach-spear6xx/clock.c | |||
@@ -13,8 +13,8 @@ | |||
13 | 13 | ||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <mach/misc_regs.h> | ||
17 | #include <plat/clock.h> | 16 | #include <plat/clock.h> |
17 | #include <mach/misc_regs.h> | ||
18 | 18 | ||
19 | /* root clks */ | 19 | /* root clks */ |
20 | /* 32 KHz oscillator clock */ | 20 | /* 32 KHz oscillator clock */ |
@@ -39,18 +39,43 @@ static struct clk rtc_clk = { | |||
39 | }; | 39 | }; |
40 | 40 | ||
41 | /* clock derived from 30 MHz osc clk */ | 41 | /* clock derived from 30 MHz osc clk */ |
42 | /* pll masks structure */ | ||
43 | static struct pll_clk_masks pll1_masks = { | ||
44 | .mode_mask = PLL_MODE_MASK, | ||
45 | .mode_shift = PLL_MODE_SHIFT, | ||
46 | .norm_fdbk_m_mask = PLL_NORM_FDBK_M_MASK, | ||
47 | .norm_fdbk_m_shift = PLL_NORM_FDBK_M_SHIFT, | ||
48 | .dith_fdbk_m_mask = PLL_DITH_FDBK_M_MASK, | ||
49 | .dith_fdbk_m_shift = PLL_DITH_FDBK_M_SHIFT, | ||
50 | .div_p_mask = PLL_DIV_P_MASK, | ||
51 | .div_p_shift = PLL_DIV_P_SHIFT, | ||
52 | .div_n_mask = PLL_DIV_N_MASK, | ||
53 | .div_n_shift = PLL_DIV_N_SHIFT, | ||
54 | }; | ||
55 | |||
42 | /* pll1 configuration structure */ | 56 | /* pll1 configuration structure */ |
43 | static struct pll_clk_config pll1_config = { | 57 | static struct pll_clk_config pll1_config = { |
44 | .mode_reg = PLL1_CTR, | 58 | .mode_reg = PLL1_CTR, |
45 | .cfg_reg = PLL1_FRQ, | 59 | .cfg_reg = PLL1_FRQ, |
60 | .masks = &pll1_masks, | ||
61 | }; | ||
62 | |||
63 | /* pll rate configuration table, in ascending order of rates */ | ||
64 | struct pll_rate_tbl pll_rtbl[] = { | ||
65 | {.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* 266 MHz */ | ||
66 | {.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* 332 MHz */ | ||
46 | }; | 67 | }; |
47 | 68 | ||
48 | /* PLL1 clock */ | 69 | /* PLL1 clock */ |
49 | static struct clk pll1_clk = { | 70 | static struct clk pll1_clk = { |
71 | .flags = ENABLED_ON_INIT, | ||
50 | .pclk = &osc_30m_clk, | 72 | .pclk = &osc_30m_clk, |
51 | .en_reg = PLL1_CTR, | 73 | .en_reg = PLL1_CTR, |
52 | .en_reg_bit = PLL_ENABLE, | 74 | .en_reg_bit = PLL_ENABLE, |
53 | .recalc = &pll1_clk_recalc, | 75 | .calc_rate = &pll_calc_rate, |
76 | .recalc = &pll_clk_recalc, | ||
77 | .set_rate = &pll_clk_set_rate, | ||
78 | .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, | ||
54 | .private_data = &pll1_config, | 79 | .private_data = &pll1_config, |
55 | }; | 80 | }; |
56 | 81 | ||
@@ -76,31 +101,83 @@ static struct clk cpu_clk = { | |||
76 | .recalc = &follow_parent, | 101 | .recalc = &follow_parent, |
77 | }; | 102 | }; |
78 | 103 | ||
104 | /* ahb masks structure */ | ||
105 | static struct bus_clk_masks ahb_masks = { | ||
106 | .mask = PLL_HCLK_RATIO_MASK, | ||
107 | .shift = PLL_HCLK_RATIO_SHIFT, | ||
108 | }; | ||
109 | |||
79 | /* ahb configuration structure */ | 110 | /* ahb configuration structure */ |
80 | static struct bus_clk_config ahb_config = { | 111 | static struct bus_clk_config ahb_config = { |
81 | .reg = CORE_CLK_CFG, | 112 | .reg = CORE_CLK_CFG, |
82 | .mask = PLL_HCLK_RATIO_MASK, | 113 | .masks = &ahb_masks, |
83 | .shift = PLL_HCLK_RATIO_SHIFT, | 114 | }; |
115 | |||
116 | /* ahb rate configuration table, in ascending order of rates */ | ||
117 | struct bus_rate_tbl bus_rtbl[] = { | ||
118 | {.div = 3}, /* == parent divided by 4 */ | ||
119 | {.div = 2}, /* == parent divided by 3 */ | ||
120 | {.div = 1}, /* == parent divided by 2 */ | ||
121 | {.div = 0}, /* == parent divided by 1 */ | ||
84 | }; | 122 | }; |
85 | 123 | ||
86 | /* ahb clock */ | 124 | /* ahb clock */ |
87 | static struct clk ahb_clk = { | 125 | static struct clk ahb_clk = { |
88 | .flags = ALWAYS_ENABLED, | 126 | .flags = ALWAYS_ENABLED, |
89 | .pclk = &pll1_clk, | 127 | .pclk = &pll1_clk, |
128 | .calc_rate = &bus_calc_rate, | ||
90 | .recalc = &bus_clk_recalc, | 129 | .recalc = &bus_clk_recalc, |
130 | .set_rate = &bus_clk_set_rate, | ||
131 | .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, | ||
91 | .private_data = &ahb_config, | 132 | .private_data = &ahb_config, |
92 | }; | 133 | }; |
93 | 134 | ||
135 | /* auxiliary synthesizers masks */ | ||
136 | static struct aux_clk_masks aux_masks = { | ||
137 | .eq_sel_mask = AUX_EQ_SEL_MASK, | ||
138 | .eq_sel_shift = AUX_EQ_SEL_SHIFT, | ||
139 | .eq1_mask = AUX_EQ1_SEL, | ||
140 | .eq2_mask = AUX_EQ2_SEL, | ||
141 | .xscale_sel_mask = AUX_XSCALE_MASK, | ||
142 | .xscale_sel_shift = AUX_XSCALE_SHIFT, | ||
143 | .yscale_sel_mask = AUX_YSCALE_MASK, | ||
144 | .yscale_sel_shift = AUX_YSCALE_SHIFT, | ||
145 | }; | ||
146 | |||
147 | /* uart configurations */ | ||
148 | static struct aux_clk_config uart_synth_config = { | ||
149 | .synth_reg = UART_CLK_SYNT, | ||
150 | .masks = &aux_masks, | ||
151 | }; | ||
152 | |||
153 | /* aux rate configuration table, in ascending order of rates */ | ||
154 | struct aux_rate_tbl aux_rtbl[] = { | ||
155 | /* For PLL1 = 332 MHz */ | ||
156 | {.xscale = 1, .yscale = 8, .eq = 1}, /* 41.5 MHz */ | ||
157 | {.xscale = 1, .yscale = 4, .eq = 1}, /* 83 MHz */ | ||
158 | {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */ | ||
159 | }; | ||
160 | |||
161 | /* uart synth clock */ | ||
162 | static struct clk uart_synth_clk = { | ||
163 | .en_reg = UART_CLK_SYNT, | ||
164 | .en_reg_bit = AUX_SYNT_ENB, | ||
165 | .pclk = &pll1_clk, | ||
166 | .calc_rate = &aux_calc_rate, | ||
167 | .recalc = &aux_clk_recalc, | ||
168 | .set_rate = &aux_clk_set_rate, | ||
169 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, | ||
170 | .private_data = &uart_synth_config, | ||
171 | }; | ||
172 | |||
94 | /* uart parents */ | 173 | /* uart parents */ |
95 | static struct pclk_info uart_pclk_info[] = { | 174 | static struct pclk_info uart_pclk_info[] = { |
96 | { | 175 | { |
97 | .pclk = &pll1_clk, | 176 | .pclk = &uart_synth_clk, |
98 | .pclk_mask = AUX_CLK_PLL1_MASK, | 177 | .pclk_val = AUX_CLK_PLL1_VAL, |
99 | .scalable = 1, | ||
100 | }, { | 178 | }, { |
101 | .pclk = &pll3_48m_clk, | 179 | .pclk = &pll3_48m_clk, |
102 | .pclk_mask = AUX_CLK_PLL3_MASK, | 180 | .pclk_val = AUX_CLK_PLL3_VAL, |
103 | .scalable = 0, | ||
104 | }, | 181 | }, |
105 | }; | 182 | }; |
106 | 183 | ||
@@ -112,19 +189,13 @@ static struct pclk_sel uart_pclk_sel = { | |||
112 | .pclk_sel_mask = UART_CLK_MASK, | 189 | .pclk_sel_mask = UART_CLK_MASK, |
113 | }; | 190 | }; |
114 | 191 | ||
115 | /* uart configurations */ | ||
116 | static struct aux_clk_config uart_config = { | ||
117 | .synth_reg = UART_CLK_SYNT, | ||
118 | }; | ||
119 | |||
120 | /* uart0 clock */ | 192 | /* uart0 clock */ |
121 | static struct clk uart0_clk = { | 193 | static struct clk uart0_clk = { |
122 | .en_reg = PERIP1_CLK_ENB, | 194 | .en_reg = PERIP1_CLK_ENB, |
123 | .en_reg_bit = UART0_CLK_ENB, | 195 | .en_reg_bit = UART0_CLK_ENB, |
124 | .pclk_sel = &uart_pclk_sel, | 196 | .pclk_sel = &uart_pclk_sel, |
125 | .pclk_sel_shift = UART_CLK_SHIFT, | 197 | .pclk_sel_shift = UART_CLK_SHIFT, |
126 | .recalc = &aux_clk_recalc, | 198 | .recalc = &follow_parent, |
127 | .private_data = &uart_config, | ||
128 | }; | 199 | }; |
129 | 200 | ||
130 | /* uart1 clock */ | 201 | /* uart1 clock */ |
@@ -133,25 +204,35 @@ static struct clk uart1_clk = { | |||
133 | .en_reg_bit = UART1_CLK_ENB, | 204 | .en_reg_bit = UART1_CLK_ENB, |
134 | .pclk_sel = &uart_pclk_sel, | 205 | .pclk_sel = &uart_pclk_sel, |
135 | .pclk_sel_shift = UART_CLK_SHIFT, | 206 | .pclk_sel_shift = UART_CLK_SHIFT, |
136 | .recalc = &aux_clk_recalc, | 207 | .recalc = &follow_parent, |
137 | .private_data = &uart_config, | ||
138 | }; | 208 | }; |
139 | 209 | ||
140 | /* firda configurations */ | 210 | /* firda configurations */ |
141 | static struct aux_clk_config firda_config = { | 211 | static struct aux_clk_config firda_synth_config = { |
142 | .synth_reg = FIRDA_CLK_SYNT, | 212 | .synth_reg = FIRDA_CLK_SYNT, |
213 | .masks = &aux_masks, | ||
214 | }; | ||
215 | |||
216 | /* firda synth clock */ | ||
217 | static struct clk firda_synth_clk = { | ||
218 | .en_reg = FIRDA_CLK_SYNT, | ||
219 | .en_reg_bit = AUX_SYNT_ENB, | ||
220 | .pclk = &pll1_clk, | ||
221 | .calc_rate = &aux_calc_rate, | ||
222 | .recalc = &aux_clk_recalc, | ||
223 | .set_rate = &aux_clk_set_rate, | ||
224 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, | ||
225 | .private_data = &firda_synth_config, | ||
143 | }; | 226 | }; |
144 | 227 | ||
145 | /* firda parents */ | 228 | /* firda parents */ |
146 | static struct pclk_info firda_pclk_info[] = { | 229 | static struct pclk_info firda_pclk_info[] = { |
147 | { | 230 | { |
148 | .pclk = &pll1_clk, | 231 | .pclk = &firda_synth_clk, |
149 | .pclk_mask = AUX_CLK_PLL1_MASK, | 232 | .pclk_val = AUX_CLK_PLL1_VAL, |
150 | .scalable = 1, | ||
151 | }, { | 233 | }, { |
152 | .pclk = &pll3_48m_clk, | 234 | .pclk = &pll3_48m_clk, |
153 | .pclk_mask = AUX_CLK_PLL3_MASK, | 235 | .pclk_val = AUX_CLK_PLL3_VAL, |
154 | .scalable = 0, | ||
155 | }, | 236 | }, |
156 | }; | 237 | }; |
157 | 238 | ||
@@ -169,25 +250,35 @@ static struct clk firda_clk = { | |||
169 | .en_reg_bit = FIRDA_CLK_ENB, | 250 | .en_reg_bit = FIRDA_CLK_ENB, |
170 | .pclk_sel = &firda_pclk_sel, | 251 | .pclk_sel = &firda_pclk_sel, |
171 | .pclk_sel_shift = FIRDA_CLK_SHIFT, | 252 | .pclk_sel_shift = FIRDA_CLK_SHIFT, |
172 | .recalc = &aux_clk_recalc, | 253 | .recalc = &follow_parent, |
173 | .private_data = &firda_config, | ||
174 | }; | 254 | }; |
175 | 255 | ||
176 | /* clcd configurations */ | 256 | /* clcd configurations */ |
177 | static struct aux_clk_config clcd_config = { | 257 | static struct aux_clk_config clcd_synth_config = { |
178 | .synth_reg = CLCD_CLK_SYNT, | 258 | .synth_reg = CLCD_CLK_SYNT, |
259 | .masks = &aux_masks, | ||
260 | }; | ||
261 | |||
262 | /* firda synth clock */ | ||
263 | static struct clk clcd_synth_clk = { | ||
264 | .en_reg = CLCD_CLK_SYNT, | ||
265 | .en_reg_bit = AUX_SYNT_ENB, | ||
266 | .pclk = &pll1_clk, | ||
267 | .calc_rate = &aux_calc_rate, | ||
268 | .recalc = &aux_clk_recalc, | ||
269 | .set_rate = &aux_clk_set_rate, | ||
270 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, | ||
271 | .private_data = &clcd_synth_config, | ||
179 | }; | 272 | }; |
180 | 273 | ||
181 | /* clcd parents */ | 274 | /* clcd parents */ |
182 | static struct pclk_info clcd_pclk_info[] = { | 275 | static struct pclk_info clcd_pclk_info[] = { |
183 | { | 276 | { |
184 | .pclk = &pll1_clk, | 277 | .pclk = &clcd_synth_clk, |
185 | .pclk_mask = AUX_CLK_PLL1_MASK, | 278 | .pclk_val = AUX_CLK_PLL1_VAL, |
186 | .scalable = 1, | ||
187 | }, { | 279 | }, { |
188 | .pclk = &pll3_48m_clk, | 280 | .pclk = &pll3_48m_clk, |
189 | .pclk_mask = AUX_CLK_PLL3_MASK, | 281 | .pclk_val = AUX_CLK_PLL3_VAL, |
190 | .scalable = 0, | ||
191 | }, | 282 | }, |
192 | }; | 283 | }; |
193 | 284 | ||
@@ -205,82 +296,173 @@ static struct clk clcd_clk = { | |||
205 | .en_reg_bit = CLCD_CLK_ENB, | 296 | .en_reg_bit = CLCD_CLK_ENB, |
206 | .pclk_sel = &clcd_pclk_sel, | 297 | .pclk_sel = &clcd_pclk_sel, |
207 | .pclk_sel_shift = CLCD_CLK_SHIFT, | 298 | .pclk_sel_shift = CLCD_CLK_SHIFT, |
208 | .recalc = &aux_clk_recalc, | 299 | .recalc = &follow_parent, |
209 | .private_data = &clcd_config, | 300 | }; |
301 | |||
302 | /* gpt synthesizer masks */ | ||
303 | static struct gpt_clk_masks gpt_masks = { | ||
304 | .mscale_sel_mask = GPT_MSCALE_MASK, | ||
305 | .mscale_sel_shift = GPT_MSCALE_SHIFT, | ||
306 | .nscale_sel_mask = GPT_NSCALE_MASK, | ||
307 | .nscale_sel_shift = GPT_NSCALE_SHIFT, | ||
308 | }; | ||
309 | |||
310 | /* gpt rate configuration table, in ascending order of rates */ | ||
311 | struct gpt_rate_tbl gpt_rtbl[] = { | ||
312 | /* For pll1 = 332 MHz */ | ||
313 | {.mscale = 4, .nscale = 0}, /* 41.5 MHz */ | ||
314 | {.mscale = 2, .nscale = 0}, /* 55.3 MHz */ | ||
315 | {.mscale = 1, .nscale = 0}, /* 83 MHz */ | ||
316 | }; | ||
317 | |||
318 | /* gpt0 synth clk config*/ | ||
319 | static struct gpt_clk_config gpt0_synth_config = { | ||
320 | .synth_reg = PRSC1_CLK_CFG, | ||
321 | .masks = &gpt_masks, | ||
322 | }; | ||
323 | |||
324 | /* gpt synth clock */ | ||
325 | static struct clk gpt0_synth_clk = { | ||
326 | .flags = ALWAYS_ENABLED, | ||
327 | .pclk = &pll1_clk, | ||
328 | .calc_rate = &gpt_calc_rate, | ||
329 | .recalc = &gpt_clk_recalc, | ||
330 | .set_rate = &gpt_clk_set_rate, | ||
331 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
332 | .private_data = &gpt0_synth_config, | ||
210 | }; | 333 | }; |
211 | 334 | ||
212 | /* gpt parents */ | 335 | /* gpt parents */ |
213 | static struct pclk_info gpt_pclk_info[] = { | 336 | static struct pclk_info gpt0_pclk_info[] = { |
214 | { | 337 | { |
215 | .pclk = &pll1_clk, | 338 | .pclk = &gpt0_synth_clk, |
216 | .pclk_mask = AUX_CLK_PLL1_MASK, | 339 | .pclk_val = AUX_CLK_PLL1_VAL, |
217 | .scalable = 1, | ||
218 | }, { | 340 | }, { |
219 | .pclk = &pll3_48m_clk, | 341 | .pclk = &pll3_48m_clk, |
220 | .pclk_mask = AUX_CLK_PLL3_MASK, | 342 | .pclk_val = AUX_CLK_PLL3_VAL, |
221 | .scalable = 0, | ||
222 | }, | 343 | }, |
223 | }; | 344 | }; |
224 | 345 | ||
225 | /* gpt parent select structure */ | 346 | /* gpt parent select structure */ |
226 | static struct pclk_sel gpt_pclk_sel = { | 347 | static struct pclk_sel gpt0_pclk_sel = { |
227 | .pclk_info = gpt_pclk_info, | 348 | .pclk_info = gpt0_pclk_info, |
228 | .pclk_count = ARRAY_SIZE(gpt_pclk_info), | 349 | .pclk_count = ARRAY_SIZE(gpt0_pclk_info), |
229 | .pclk_sel_reg = PERIP_CLK_CFG, | 350 | .pclk_sel_reg = PERIP_CLK_CFG, |
230 | .pclk_sel_mask = GPT_CLK_MASK, | 351 | .pclk_sel_mask = GPT_CLK_MASK, |
231 | }; | 352 | }; |
232 | 353 | ||
233 | /* gpt0_1 configurations */ | ||
234 | static struct aux_clk_config gpt0_1_config = { | ||
235 | .synth_reg = PRSC1_CLK_CFG, | ||
236 | }; | ||
237 | |||
238 | /* gpt0 ARM1 subsystem timer clock */ | 354 | /* gpt0 ARM1 subsystem timer clock */ |
239 | static struct clk gpt0_clk = { | 355 | static struct clk gpt0_clk = { |
240 | .flags = ALWAYS_ENABLED, | 356 | .flags = ALWAYS_ENABLED, |
241 | .pclk_sel = &gpt_pclk_sel, | 357 | .pclk_sel = &gpt0_pclk_sel, |
242 | .pclk_sel_shift = GPT0_CLK_SHIFT, | 358 | .pclk_sel_shift = GPT0_CLK_SHIFT, |
243 | .recalc = &gpt_clk_recalc, | 359 | .recalc = &follow_parent, |
244 | .private_data = &gpt0_1_config, | 360 | }; |
361 | |||
362 | |||
363 | /* Note: gpt0 and gpt1 share same parent clocks */ | ||
364 | /* gpt parent select structure */ | ||
365 | static struct pclk_sel gpt1_pclk_sel = { | ||
366 | .pclk_info = gpt0_pclk_info, | ||
367 | .pclk_count = ARRAY_SIZE(gpt0_pclk_info), | ||
368 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
369 | .pclk_sel_mask = GPT_CLK_MASK, | ||
245 | }; | 370 | }; |
246 | 371 | ||
247 | /* gpt1 timer clock */ | 372 | /* gpt1 timer clock */ |
248 | static struct clk gpt1_clk = { | 373 | static struct clk gpt1_clk = { |
249 | .flags = ALWAYS_ENABLED, | 374 | .flags = ALWAYS_ENABLED, |
250 | .pclk_sel = &gpt_pclk_sel, | 375 | .pclk_sel = &gpt1_pclk_sel, |
251 | .pclk_sel_shift = GPT1_CLK_SHIFT, | 376 | .pclk_sel_shift = GPT1_CLK_SHIFT, |
252 | .recalc = &gpt_clk_recalc, | 377 | .recalc = &follow_parent, |
253 | .private_data = &gpt0_1_config, | ||
254 | }; | 378 | }; |
255 | 379 | ||
256 | /* gpt2 configurations */ | 380 | /* gpt2 synth clk config*/ |
257 | static struct aux_clk_config gpt2_config = { | 381 | static struct gpt_clk_config gpt2_synth_config = { |
258 | .synth_reg = PRSC2_CLK_CFG, | 382 | .synth_reg = PRSC2_CLK_CFG, |
383 | .masks = &gpt_masks, | ||
384 | }; | ||
385 | |||
386 | /* gpt synth clock */ | ||
387 | static struct clk gpt2_synth_clk = { | ||
388 | .flags = ALWAYS_ENABLED, | ||
389 | .pclk = &pll1_clk, | ||
390 | .calc_rate = &gpt_calc_rate, | ||
391 | .recalc = &gpt_clk_recalc, | ||
392 | .set_rate = &gpt_clk_set_rate, | ||
393 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
394 | .private_data = &gpt2_synth_config, | ||
395 | }; | ||
396 | |||
397 | /* gpt parents */ | ||
398 | static struct pclk_info gpt2_pclk_info[] = { | ||
399 | { | ||
400 | .pclk = &gpt2_synth_clk, | ||
401 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
402 | }, { | ||
403 | .pclk = &pll3_48m_clk, | ||
404 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
405 | }, | ||
406 | }; | ||
407 | |||
408 | /* gpt parent select structure */ | ||
409 | static struct pclk_sel gpt2_pclk_sel = { | ||
410 | .pclk_info = gpt2_pclk_info, | ||
411 | .pclk_count = ARRAY_SIZE(gpt2_pclk_info), | ||
412 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
413 | .pclk_sel_mask = GPT_CLK_MASK, | ||
259 | }; | 414 | }; |
260 | 415 | ||
261 | /* gpt2 timer clock */ | 416 | /* gpt2 timer clock */ |
262 | static struct clk gpt2_clk = { | 417 | static struct clk gpt2_clk = { |
263 | .en_reg = PERIP1_CLK_ENB, | 418 | .flags = ALWAYS_ENABLED, |
264 | .en_reg_bit = GPT2_CLK_ENB, | 419 | .pclk_sel = &gpt2_pclk_sel, |
265 | .pclk_sel = &gpt_pclk_sel, | ||
266 | .pclk_sel_shift = GPT2_CLK_SHIFT, | 420 | .pclk_sel_shift = GPT2_CLK_SHIFT, |
267 | .recalc = &gpt_clk_recalc, | 421 | .recalc = &follow_parent, |
268 | .private_data = &gpt2_config, | ||
269 | }; | 422 | }; |
270 | 423 | ||
271 | /* gpt3 configurations */ | 424 | /* gpt3 synth clk config*/ |
272 | static struct aux_clk_config gpt3_config = { | 425 | static struct gpt_clk_config gpt3_synth_config = { |
273 | .synth_reg = PRSC3_CLK_CFG, | 426 | .synth_reg = PRSC3_CLK_CFG, |
427 | .masks = &gpt_masks, | ||
428 | }; | ||
429 | |||
430 | /* gpt synth clock */ | ||
431 | static struct clk gpt3_synth_clk = { | ||
432 | .flags = ALWAYS_ENABLED, | ||
433 | .pclk = &pll1_clk, | ||
434 | .calc_rate = &gpt_calc_rate, | ||
435 | .recalc = &gpt_clk_recalc, | ||
436 | .set_rate = &gpt_clk_set_rate, | ||
437 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
438 | .private_data = &gpt3_synth_config, | ||
439 | }; | ||
440 | |||
441 | /* gpt parents */ | ||
442 | static struct pclk_info gpt3_pclk_info[] = { | ||
443 | { | ||
444 | .pclk = &gpt3_synth_clk, | ||
445 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
446 | }, { | ||
447 | .pclk = &pll3_48m_clk, | ||
448 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
449 | }, | ||
450 | }; | ||
451 | |||
452 | /* gpt parent select structure */ | ||
453 | static struct pclk_sel gpt3_pclk_sel = { | ||
454 | .pclk_info = gpt3_pclk_info, | ||
455 | .pclk_count = ARRAY_SIZE(gpt3_pclk_info), | ||
456 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
457 | .pclk_sel_mask = GPT_CLK_MASK, | ||
274 | }; | 458 | }; |
275 | 459 | ||
276 | /* gpt3 timer clock */ | 460 | /* gpt3 timer clock */ |
277 | static struct clk gpt3_clk = { | 461 | static struct clk gpt3_clk = { |
278 | .en_reg = PERIP1_CLK_ENB, | 462 | .flags = ALWAYS_ENABLED, |
279 | .en_reg_bit = GPT3_CLK_ENB, | 463 | .pclk_sel = &gpt3_pclk_sel, |
280 | .pclk_sel = &gpt_pclk_sel, | ||
281 | .pclk_sel_shift = GPT3_CLK_SHIFT, | 464 | .pclk_sel_shift = GPT3_CLK_SHIFT, |
282 | .recalc = &gpt_clk_recalc, | 465 | .recalc = &follow_parent, |
283 | .private_data = &gpt3_config, | ||
284 | }; | 466 | }; |
285 | 467 | ||
286 | /* clock derived from pll3 clk */ | 468 | /* clock derived from pll3 clk */ |
@@ -309,18 +491,26 @@ static struct clk usbd_clk = { | |||
309 | }; | 491 | }; |
310 | 492 | ||
311 | /* clock derived from ahb clk */ | 493 | /* clock derived from ahb clk */ |
494 | /* apb masks structure */ | ||
495 | static struct bus_clk_masks apb_masks = { | ||
496 | .mask = HCLK_PCLK_RATIO_MASK, | ||
497 | .shift = HCLK_PCLK_RATIO_SHIFT, | ||
498 | }; | ||
499 | |||
312 | /* apb configuration structure */ | 500 | /* apb configuration structure */ |
313 | static struct bus_clk_config apb_config = { | 501 | static struct bus_clk_config apb_config = { |
314 | .reg = CORE_CLK_CFG, | 502 | .reg = CORE_CLK_CFG, |
315 | .mask = HCLK_PCLK_RATIO_MASK, | 503 | .masks = &apb_masks, |
316 | .shift = HCLK_PCLK_RATIO_SHIFT, | ||
317 | }; | 504 | }; |
318 | 505 | ||
319 | /* apb clock */ | 506 | /* apb clock */ |
320 | static struct clk apb_clk = { | 507 | static struct clk apb_clk = { |
321 | .flags = ALWAYS_ENABLED, | 508 | .flags = ALWAYS_ENABLED, |
322 | .pclk = &ahb_clk, | 509 | .pclk = &ahb_clk, |
510 | .calc_rate = &bus_calc_rate, | ||
323 | .recalc = &bus_clk_recalc, | 511 | .recalc = &bus_clk_recalc, |
512 | .set_rate = &bus_clk_set_rate, | ||
513 | .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, | ||
324 | .private_data = &apb_config, | 514 | .private_data = &apb_config, |
325 | }; | 515 | }; |
326 | 516 | ||
@@ -432,12 +622,12 @@ static struct clk dummy_apb_pclk; | |||
432 | 622 | ||
433 | /* array of all spear 6xx clock lookups */ | 623 | /* array of all spear 6xx clock lookups */ |
434 | static struct clk_lookup spear_clk_lookups[] = { | 624 | static struct clk_lookup spear_clk_lookups[] = { |
435 | { .con_id = "apb_pclk", .clk = &dummy_apb_pclk}, | 625 | { .con_id = "apb_pclk", .clk = &dummy_apb_pclk}, |
436 | /* root clks */ | 626 | /* root clks */ |
437 | { .con_id = "osc_32k_clk", .clk = &osc_32k_clk}, | 627 | { .con_id = "osc_32k_clk", .clk = &osc_32k_clk}, |
438 | { .con_id = "osc_30m_clk", .clk = &osc_30m_clk}, | 628 | { .con_id = "osc_30m_clk", .clk = &osc_30m_clk}, |
439 | /* clock derived from 32 KHz os clk */ | 629 | /* clock derived from 32 KHz os clk */ |
440 | { .dev_id = "rtc", .clk = &rtc_clk}, | 630 | { .dev_id = "rtc-spear", .clk = &rtc_clk}, |
441 | /* clock derived from 30 MHz os clk */ | 631 | /* clock derived from 30 MHz os clk */ |
442 | { .con_id = "pll1_clk", .clk = &pll1_clk}, | 632 | { .con_id = "pll1_clk", .clk = &pll1_clk}, |
443 | { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk}, | 633 | { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk}, |
@@ -445,6 +635,12 @@ static struct clk_lookup spear_clk_lookups[] = { | |||
445 | /* clock derived from pll1 clk */ | 635 | /* clock derived from pll1 clk */ |
446 | { .con_id = "cpu_clk", .clk = &cpu_clk}, | 636 | { .con_id = "cpu_clk", .clk = &cpu_clk}, |
447 | { .con_id = "ahb_clk", .clk = &ahb_clk}, | 637 | { .con_id = "ahb_clk", .clk = &ahb_clk}, |
638 | { .con_id = "uart_synth_clk", .clk = &uart_synth_clk}, | ||
639 | { .con_id = "firda_synth_clk", .clk = &firda_synth_clk}, | ||
640 | { .con_id = "clcd_synth_clk", .clk = &clcd_synth_clk}, | ||
641 | { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk}, | ||
642 | { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk}, | ||
643 | { .con_id = "gpt3_synth_clk", .clk = &gpt3_synth_clk}, | ||
448 | { .dev_id = "uart0", .clk = &uart0_clk}, | 644 | { .dev_id = "uart0", .clk = &uart0_clk}, |
449 | { .dev_id = "uart1", .clk = &uart1_clk}, | 645 | { .dev_id = "uart1", .clk = &uart1_clk}, |
450 | { .dev_id = "firda", .clk = &firda_clk}, | 646 | { .dev_id = "firda", .clk = &firda_clk}, |
@@ -454,22 +650,22 @@ static struct clk_lookup spear_clk_lookups[] = { | |||
454 | { .dev_id = "gpt2", .clk = &gpt2_clk}, | 650 | { .dev_id = "gpt2", .clk = &gpt2_clk}, |
455 | { .dev_id = "gpt3", .clk = &gpt3_clk}, | 651 | { .dev_id = "gpt3", .clk = &gpt3_clk}, |
456 | /* clock derived from pll3 clk */ | 652 | /* clock derived from pll3 clk */ |
457 | { .dev_id = "usbh0", .clk = &usbh0_clk}, | 653 | { .dev_id = "designware_udc", .clk = &usbd_clk}, |
458 | { .dev_id = "usbh1", .clk = &usbh1_clk}, | 654 | { .con_id = "usbh.0_clk", .clk = &usbh0_clk}, |
459 | { .dev_id = "usbd", .clk = &usbd_clk}, | 655 | { .con_id = "usbh.1_clk", .clk = &usbh1_clk}, |
460 | /* clock derived from ahb clk */ | 656 | /* clock derived from ahb clk */ |
461 | { .con_id = "apb_clk", .clk = &apb_clk}, | 657 | { .con_id = "apb_clk", .clk = &apb_clk}, |
462 | { .dev_id = "i2c", .clk = &i2c_clk}, | 658 | { .dev_id = "i2c_designware.0", .clk = &i2c_clk}, |
463 | { .dev_id = "dma", .clk = &dma_clk}, | 659 | { .dev_id = "dma", .clk = &dma_clk}, |
464 | { .dev_id = "jpeg", .clk = &jpeg_clk}, | 660 | { .dev_id = "jpeg", .clk = &jpeg_clk}, |
465 | { .dev_id = "gmac", .clk = &gmac_clk}, | 661 | { .dev_id = "gmac", .clk = &gmac_clk}, |
466 | { .dev_id = "smi", .clk = &smi_clk}, | 662 | { .dev_id = "smi", .clk = &smi_clk}, |
467 | { .dev_id = "fsmc", .clk = &fsmc_clk}, | 663 | { .con_id = "fsmc", .clk = &fsmc_clk}, |
468 | /* clock derived from apb clk */ | 664 | /* clock derived from apb clk */ |
469 | { .dev_id = "adc", .clk = &adc_clk}, | 665 | { .dev_id = "adc", .clk = &adc_clk}, |
470 | { .dev_id = "ssp0", .clk = &ssp0_clk}, | 666 | { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk}, |
471 | { .dev_id = "ssp1", .clk = &ssp1_clk}, | 667 | { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk}, |
472 | { .dev_id = "ssp2", .clk = &ssp2_clk}, | 668 | { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk}, |
473 | { .dev_id = "gpio0", .clk = &gpio0_clk}, | 669 | { .dev_id = "gpio0", .clk = &gpio0_clk}, |
474 | { .dev_id = "gpio1", .clk = &gpio1_clk}, | 670 | { .dev_id = "gpio1", .clk = &gpio1_clk}, |
475 | { .dev_id = "gpio2", .clk = &gpio2_clk}, | 671 | { .dev_id = "gpio2", .clk = &gpio2_clk}, |