blob: ac70e0d88fef8a7a7616573788c9fdb727c252c4 [file] [log] [blame]
viresh kumar8c0236f2010-04-01 12:30:46 +01001/*
2 * arch/arm/mach-spear6xx/clock.c
3 *
4 * SPEAr6xx machines clock framework source file
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Viresh Kumar<viresh.kumar@st.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#include <linux/init.h>
15#include <linux/kernel.h>
viresh kumar8c0236f2010-04-01 12:30:46 +010016#include <plat/clock.h>
viresh kumar410782b2011-03-07 05:57:01 +010017#include <mach/misc_regs.h>
viresh kumar8c0236f2010-04-01 12:30:46 +010018
19/* root clks */
20/* 32 KHz oscillator clock */
21static struct clk osc_32k_clk = {
22 .flags = ALWAYS_ENABLED,
23 .rate = 32000,
24};
25
26/* 30 MHz oscillator clock */
27static struct clk osc_30m_clk = {
28 .flags = ALWAYS_ENABLED,
29 .rate = 30000000,
30};
31
32/* clock derived from 32 KHz osc clk */
33/* rtc clock */
34static struct clk rtc_clk = {
35 .pclk = &osc_32k_clk,
36 .en_reg = PERIP1_CLK_ENB,
37 .en_reg_bit = RTC_CLK_ENB,
38 .recalc = &follow_parent,
39};
40
41/* clock derived from 30 MHz osc clk */
viresh kumarcf285432011-02-16 07:40:31 +010042/* pll masks structure */
43static 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
viresh kumar8c0236f2010-04-01 12:30:46 +010056/* pll1 configuration structure */
57static struct pll_clk_config pll1_config = {
58 .mode_reg = PLL1_CTR,
59 .cfg_reg = PLL1_FRQ,
viresh kumarcf285432011-02-16 07:40:31 +010060 .masks = &pll1_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +010061};
62
viresh kumaraf89fd82011-02-16 07:40:39 +010063/* pll rate configuration table, in ascending order of rates */
64struct 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 */
67};
68
viresh kumar8c0236f2010-04-01 12:30:46 +010069/* PLL1 clock */
70static struct clk pll1_clk = {
viresh kumaraf89fd82011-02-16 07:40:39 +010071 .flags = ENABLED_ON_INIT,
viresh kumar8c0236f2010-04-01 12:30:46 +010072 .pclk = &osc_30m_clk,
73 .en_reg = PLL1_CTR,
74 .en_reg_bit = PLL_ENABLE,
viresh kumaraf89fd82011-02-16 07:40:39 +010075 .calc_rate = &pll_calc_rate,
viresh kumarcf285432011-02-16 07:40:31 +010076 .recalc = &pll_clk_recalc,
viresh kumaraf89fd82011-02-16 07:40:39 +010077 .set_rate = &pll_clk_set_rate,
78 .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1},
viresh kumar8c0236f2010-04-01 12:30:46 +010079 .private_data = &pll1_config,
80};
81
82/* PLL3 48 MHz clock */
83static struct clk pll3_48m_clk = {
84 .flags = ALWAYS_ENABLED,
85 .pclk = &osc_30m_clk,
86 .rate = 48000000,
87};
88
89/* watch dog timer clock */
90static struct clk wdt_clk = {
91 .flags = ALWAYS_ENABLED,
92 .pclk = &osc_30m_clk,
93 .recalc = &follow_parent,
94};
95
96/* clock derived from pll1 clk */
97/* cpu clock */
98static struct clk cpu_clk = {
99 .flags = ALWAYS_ENABLED,
100 .pclk = &pll1_clk,
101 .recalc = &follow_parent,
102};
103
viresh kumarcf285432011-02-16 07:40:31 +0100104/* ahb masks structure */
105static struct bus_clk_masks ahb_masks = {
106 .mask = PLL_HCLK_RATIO_MASK,
107 .shift = PLL_HCLK_RATIO_SHIFT,
108};
109
viresh kumar8c0236f2010-04-01 12:30:46 +0100110/* ahb configuration structure */
111static struct bus_clk_config ahb_config = {
112 .reg = CORE_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100113 .masks = &ahb_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100114};
115
viresh kumaraf89fd82011-02-16 07:40:39 +0100116/* ahb rate configuration table, in ascending order of rates */
117struct 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 */
122};
123
viresh kumar8c0236f2010-04-01 12:30:46 +0100124/* ahb clock */
125static struct clk ahb_clk = {
126 .flags = ALWAYS_ENABLED,
127 .pclk = &pll1_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100128 .calc_rate = &bus_calc_rate,
viresh kumar8c0236f2010-04-01 12:30:46 +0100129 .recalc = &bus_clk_recalc,
viresh kumaraf89fd82011-02-16 07:40:39 +0100130 .set_rate = &bus_clk_set_rate,
131 .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2},
viresh kumar8c0236f2010-04-01 12:30:46 +0100132 .private_data = &ahb_config,
133};
134
viresh kumarcf285432011-02-16 07:40:31 +0100135/* auxiliary synthesizers masks */
136static 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
viresh kumar8c0236f2010-04-01 12:30:46 +0100147/* uart configurations */
viresh kumaraf89fd82011-02-16 07:40:39 +0100148static struct aux_clk_config uart_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100149 .synth_reg = UART_CLK_SYNT,
viresh kumarcf285432011-02-16 07:40:31 +0100150 .masks = &aux_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100151};
152
viresh kumaraf89fd82011-02-16 07:40:39 +0100153/* aux rate configuration table, in ascending order of rates */
154struct 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 */
162static 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
173/* uart parents */
174static struct pclk_info uart_pclk_info[] = {
175 {
176 .pclk = &uart_synth_clk,
177 .pclk_val = AUX_CLK_PLL1_VAL,
178 }, {
179 .pclk = &pll3_48m_clk,
180 .pclk_val = AUX_CLK_PLL3_VAL,
181 },
182};
183
184/* uart parent select structure */
185static struct pclk_sel uart_pclk_sel = {
186 .pclk_info = uart_pclk_info,
187 .pclk_count = ARRAY_SIZE(uart_pclk_info),
188 .pclk_sel_reg = PERIP_CLK_CFG,
189 .pclk_sel_mask = UART_CLK_MASK,
190};
191
viresh kumar8c0236f2010-04-01 12:30:46 +0100192/* uart0 clock */
193static struct clk uart0_clk = {
194 .en_reg = PERIP1_CLK_ENB,
195 .en_reg_bit = UART0_CLK_ENB,
196 .pclk_sel = &uart_pclk_sel,
197 .pclk_sel_shift = UART_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100198 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100199};
200
201/* uart1 clock */
202static struct clk uart1_clk = {
203 .en_reg = PERIP1_CLK_ENB,
204 .en_reg_bit = UART1_CLK_ENB,
205 .pclk_sel = &uart_pclk_sel,
206 .pclk_sel_shift = UART_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100207 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100208};
209
210/* firda configurations */
viresh kumaraf89fd82011-02-16 07:40:39 +0100211static struct aux_clk_config firda_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100212 .synth_reg = FIRDA_CLK_SYNT,
viresh kumarcf285432011-02-16 07:40:31 +0100213 .masks = &aux_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100214};
215
viresh kumaraf89fd82011-02-16 07:40:39 +0100216/* firda synth clock */
217static 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,
226};
227
viresh kumar8c0236f2010-04-01 12:30:46 +0100228/* firda parents */
229static struct pclk_info firda_pclk_info[] = {
230 {
viresh kumaraf89fd82011-02-16 07:40:39 +0100231 .pclk = &firda_synth_clk,
232 .pclk_val = AUX_CLK_PLL1_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100233 }, {
234 .pclk = &pll3_48m_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100235 .pclk_val = AUX_CLK_PLL3_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100236 },
237};
238
239/* firda parent select structure */
240static struct pclk_sel firda_pclk_sel = {
241 .pclk_info = firda_pclk_info,
242 .pclk_count = ARRAY_SIZE(firda_pclk_info),
243 .pclk_sel_reg = PERIP_CLK_CFG,
244 .pclk_sel_mask = FIRDA_CLK_MASK,
245};
246
247/* firda clock */
248static struct clk firda_clk = {
249 .en_reg = PERIP1_CLK_ENB,
250 .en_reg_bit = FIRDA_CLK_ENB,
251 .pclk_sel = &firda_pclk_sel,
252 .pclk_sel_shift = FIRDA_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100253 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100254};
255
256/* clcd configurations */
viresh kumaraf89fd82011-02-16 07:40:39 +0100257static struct aux_clk_config clcd_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100258 .synth_reg = CLCD_CLK_SYNT,
viresh kumarcf285432011-02-16 07:40:31 +0100259 .masks = &aux_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100260};
261
viresh kumaraf89fd82011-02-16 07:40:39 +0100262/* firda synth clock */
263static 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,
272};
273
viresh kumar8c0236f2010-04-01 12:30:46 +0100274/* clcd parents */
275static struct pclk_info clcd_pclk_info[] = {
276 {
viresh kumaraf89fd82011-02-16 07:40:39 +0100277 .pclk = &clcd_synth_clk,
278 .pclk_val = AUX_CLK_PLL1_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100279 }, {
280 .pclk = &pll3_48m_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100281 .pclk_val = AUX_CLK_PLL3_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100282 },
283};
284
285/* clcd parent select structure */
286static struct pclk_sel clcd_pclk_sel = {
287 .pclk_info = clcd_pclk_info,
288 .pclk_count = ARRAY_SIZE(clcd_pclk_info),
289 .pclk_sel_reg = PERIP_CLK_CFG,
290 .pclk_sel_mask = CLCD_CLK_MASK,
291};
292
293/* clcd clock */
294static struct clk clcd_clk = {
295 .en_reg = PERIP1_CLK_ENB,
296 .en_reg_bit = CLCD_CLK_ENB,
297 .pclk_sel = &clcd_pclk_sel,
298 .pclk_sel_shift = CLCD_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100299 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100300};
301
viresh kumarcf285432011-02-16 07:40:31 +0100302/* gpt synthesizer masks */
303static 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
viresh kumaraf89fd82011-02-16 07:40:39 +0100310/* gpt rate configuration table, in ascending order of rates */
311struct 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*/
319static struct gpt_clk_config gpt0_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100320 .synth_reg = PRSC1_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100321 .masks = &gpt_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100322};
323
viresh kumaraf89fd82011-02-16 07:40:39 +0100324/* gpt synth clock */
325static 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,
333};
334
335/* gpt parents */
336static struct pclk_info gpt0_pclk_info[] = {
337 {
338 .pclk = &gpt0_synth_clk,
339 .pclk_val = AUX_CLK_PLL1_VAL,
340 }, {
341 .pclk = &pll3_48m_clk,
342 .pclk_val = AUX_CLK_PLL3_VAL,
343 },
344};
345
346/* gpt parent select structure */
347static struct pclk_sel gpt0_pclk_sel = {
348 .pclk_info = gpt0_pclk_info,
349 .pclk_count = ARRAY_SIZE(gpt0_pclk_info),
350 .pclk_sel_reg = PERIP_CLK_CFG,
351 .pclk_sel_mask = GPT_CLK_MASK,
352};
353
viresh kumar8c0236f2010-04-01 12:30:46 +0100354/* gpt0 ARM1 subsystem timer clock */
355static struct clk gpt0_clk = {
356 .flags = ALWAYS_ENABLED,
viresh kumaraf89fd82011-02-16 07:40:39 +0100357 .pclk_sel = &gpt0_pclk_sel,
viresh kumar8c0236f2010-04-01 12:30:46 +0100358 .pclk_sel_shift = GPT0_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100359 .recalc = &follow_parent,
360};
361
362
363/* Note: gpt0 and gpt1 share same parent clocks */
364/* gpt parent select structure */
365static 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,
viresh kumar8c0236f2010-04-01 12:30:46 +0100370};
371
372/* gpt1 timer clock */
373static struct clk gpt1_clk = {
374 .flags = ALWAYS_ENABLED,
viresh kumaraf89fd82011-02-16 07:40:39 +0100375 .pclk_sel = &gpt1_pclk_sel,
viresh kumar8c0236f2010-04-01 12:30:46 +0100376 .pclk_sel_shift = GPT1_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100377 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100378};
379
viresh kumaraf89fd82011-02-16 07:40:39 +0100380/* gpt2 synth clk config*/
381static struct gpt_clk_config gpt2_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100382 .synth_reg = PRSC2_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100383 .masks = &gpt_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100384};
385
viresh kumaraf89fd82011-02-16 07:40:39 +0100386/* gpt synth clock */
387static struct clk gpt2_synth_clk = {
388 .flags = ALWAYS_ENABLED,
389 .pclk = &pll1_clk,
390 .calc_rate = &gpt_calc_rate,
viresh kumar8c0236f2010-04-01 12:30:46 +0100391 .recalc = &gpt_clk_recalc,
viresh kumaraf89fd82011-02-16 07:40:39 +0100392 .set_rate = &gpt_clk_set_rate,
393 .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2},
394 .private_data = &gpt2_synth_config,
viresh kumar8c0236f2010-04-01 12:30:46 +0100395};
396
viresh kumaraf89fd82011-02-16 07:40:39 +0100397/* gpt parents */
398static 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 */
409static 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,
414};
415
416/* gpt2 timer clock */
417static struct clk gpt2_clk = {
418 .flags = ALWAYS_ENABLED,
419 .pclk_sel = &gpt2_pclk_sel,
420 .pclk_sel_shift = GPT2_CLK_SHIFT,
421 .recalc = &follow_parent,
422};
423
424/* gpt3 synth clk config*/
425static struct gpt_clk_config gpt3_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100426 .synth_reg = PRSC3_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100427 .masks = &gpt_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100428};
429
viresh kumaraf89fd82011-02-16 07:40:39 +0100430/* gpt synth clock */
431static 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 */
442static 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 */
453static 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,
458};
459
viresh kumar8c0236f2010-04-01 12:30:46 +0100460/* gpt3 timer clock */
461static struct clk gpt3_clk = {
viresh kumaraf89fd82011-02-16 07:40:39 +0100462 .flags = ALWAYS_ENABLED,
463 .pclk_sel = &gpt3_pclk_sel,
viresh kumar8c0236f2010-04-01 12:30:46 +0100464 .pclk_sel_shift = GPT3_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100465 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100466};
467
468/* clock derived from pll3 clk */
469/* usbh0 clock */
470static struct clk usbh0_clk = {
471 .pclk = &pll3_48m_clk,
472 .en_reg = PERIP1_CLK_ENB,
473 .en_reg_bit = USBH0_CLK_ENB,
474 .recalc = &follow_parent,
475};
476
477/* usbh1 clock */
478static struct clk usbh1_clk = {
479 .pclk = &pll3_48m_clk,
480 .en_reg = PERIP1_CLK_ENB,
481 .en_reg_bit = USBH1_CLK_ENB,
482 .recalc = &follow_parent,
483};
484
485/* usbd clock */
486static struct clk usbd_clk = {
487 .pclk = &pll3_48m_clk,
488 .en_reg = PERIP1_CLK_ENB,
489 .en_reg_bit = USBD_CLK_ENB,
490 .recalc = &follow_parent,
491};
492
493/* clock derived from ahb clk */
viresh kumarcf285432011-02-16 07:40:31 +0100494/* apb masks structure */
495static struct bus_clk_masks apb_masks = {
496 .mask = HCLK_PCLK_RATIO_MASK,
497 .shift = HCLK_PCLK_RATIO_SHIFT,
498};
499
viresh kumar8c0236f2010-04-01 12:30:46 +0100500/* apb configuration structure */
501static struct bus_clk_config apb_config = {
502 .reg = CORE_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100503 .masks = &apb_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100504};
505
506/* apb clock */
507static struct clk apb_clk = {
508 .flags = ALWAYS_ENABLED,
509 .pclk = &ahb_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100510 .calc_rate = &bus_calc_rate,
viresh kumar8c0236f2010-04-01 12:30:46 +0100511 .recalc = &bus_clk_recalc,
viresh kumaraf89fd82011-02-16 07:40:39 +0100512 .set_rate = &bus_clk_set_rate,
513 .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2},
viresh kumar8c0236f2010-04-01 12:30:46 +0100514 .private_data = &apb_config,
515};
516
517/* i2c clock */
518static struct clk i2c_clk = {
519 .pclk = &ahb_clk,
520 .en_reg = PERIP1_CLK_ENB,
521 .en_reg_bit = I2C_CLK_ENB,
522 .recalc = &follow_parent,
523};
524
525/* dma clock */
526static struct clk dma_clk = {
527 .pclk = &ahb_clk,
528 .en_reg = PERIP1_CLK_ENB,
529 .en_reg_bit = DMA_CLK_ENB,
530 .recalc = &follow_parent,
531};
532
533/* jpeg clock */
534static struct clk jpeg_clk = {
535 .pclk = &ahb_clk,
536 .en_reg = PERIP1_CLK_ENB,
537 .en_reg_bit = JPEG_CLK_ENB,
538 .recalc = &follow_parent,
539};
540
541/* gmac clock */
542static struct clk gmac_clk = {
543 .pclk = &ahb_clk,
544 .en_reg = PERIP1_CLK_ENB,
545 .en_reg_bit = GMAC_CLK_ENB,
546 .recalc = &follow_parent,
547};
548
549/* smi clock */
550static struct clk smi_clk = {
551 .pclk = &ahb_clk,
552 .en_reg = PERIP1_CLK_ENB,
553 .en_reg_bit = SMI_CLK_ENB,
554 .recalc = &follow_parent,
555};
556
557/* fsmc clock */
558static struct clk fsmc_clk = {
559 .pclk = &ahb_clk,
560 .en_reg = PERIP1_CLK_ENB,
561 .en_reg_bit = FSMC_CLK_ENB,
562 .recalc = &follow_parent,
563};
564
565/* clock derived from apb clk */
566/* adc clock */
567static struct clk adc_clk = {
568 .pclk = &apb_clk,
569 .en_reg = PERIP1_CLK_ENB,
570 .en_reg_bit = ADC_CLK_ENB,
571 .recalc = &follow_parent,
572};
573
574/* ssp0 clock */
575static struct clk ssp0_clk = {
576 .pclk = &apb_clk,
577 .en_reg = PERIP1_CLK_ENB,
578 .en_reg_bit = SSP0_CLK_ENB,
579 .recalc = &follow_parent,
580};
581
582/* ssp1 clock */
583static struct clk ssp1_clk = {
584 .pclk = &apb_clk,
585 .en_reg = PERIP1_CLK_ENB,
586 .en_reg_bit = SSP1_CLK_ENB,
587 .recalc = &follow_parent,
588};
589
590/* ssp2 clock */
591static struct clk ssp2_clk = {
592 .pclk = &apb_clk,
593 .en_reg = PERIP1_CLK_ENB,
594 .en_reg_bit = SSP2_CLK_ENB,
595 .recalc = &follow_parent,
596};
597
598/* gpio0 ARM subsystem clock */
599static struct clk gpio0_clk = {
600 .flags = ALWAYS_ENABLED,
601 .pclk = &apb_clk,
602 .recalc = &follow_parent,
603};
604
605/* gpio1 clock */
606static struct clk gpio1_clk = {
607 .pclk = &apb_clk,
608 .en_reg = PERIP1_CLK_ENB,
609 .en_reg_bit = GPIO1_CLK_ENB,
610 .recalc = &follow_parent,
611};
612
613/* gpio2 clock */
614static struct clk gpio2_clk = {
615 .pclk = &apb_clk,
616 .en_reg = PERIP1_CLK_ENB,
617 .en_reg_bit = GPIO2_CLK_ENB,
618 .recalc = &follow_parent,
619};
620
Russell King3126c7b2010-07-15 11:01:17 +0100621static struct clk dummy_apb_pclk;
622
viresh kumar8c0236f2010-04-01 12:30:46 +0100623/* array of all spear 6xx clock lookups */
624static struct clk_lookup spear_clk_lookups[] = {
viresh kumarb5761372011-03-07 05:57:04 +0100625 { .con_id = "apb_pclk", .clk = &dummy_apb_pclk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100626 /* root clks */
627 { .con_id = "osc_32k_clk", .clk = &osc_32k_clk},
628 { .con_id = "osc_30m_clk", .clk = &osc_30m_clk},
629 /* clock derived from 32 KHz os clk */
viresh kumaraf89fd82011-02-16 07:40:39 +0100630 { .dev_id = "rtc-spear", .clk = &rtc_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100631 /* clock derived from 30 MHz os clk */
632 { .con_id = "pll1_clk", .clk = &pll1_clk},
633 { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk},
634 { .dev_id = "wdt", .clk = &wdt_clk},
635 /* clock derived from pll1 clk */
636 { .con_id = "cpu_clk", .clk = &cpu_clk},
637 { .con_id = "ahb_clk", .clk = &ahb_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100638 { .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},
viresh kumar8c0236f2010-04-01 12:30:46 +0100644 { .dev_id = "uart0", .clk = &uart0_clk},
645 { .dev_id = "uart1", .clk = &uart1_clk},
646 { .dev_id = "firda", .clk = &firda_clk},
647 { .dev_id = "clcd", .clk = &clcd_clk},
648 { .dev_id = "gpt0", .clk = &gpt0_clk},
649 { .dev_id = "gpt1", .clk = &gpt1_clk},
650 { .dev_id = "gpt2", .clk = &gpt2_clk},
651 { .dev_id = "gpt3", .clk = &gpt3_clk},
652 /* clock derived from pll3 clk */
viresh kumarb5761372011-03-07 05:57:04 +0100653 { .dev_id = "designware_udc", .clk = &usbd_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100654 { .con_id = "usbh.0_clk", .clk = &usbh0_clk},
655 { .con_id = "usbh.1_clk", .clk = &usbh1_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100656 /* clock derived from ahb clk */
657 { .con_id = "apb_clk", .clk = &apb_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100658 { .dev_id = "i2c_designware.0", .clk = &i2c_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100659 { .dev_id = "dma", .clk = &dma_clk},
660 { .dev_id = "jpeg", .clk = &jpeg_clk},
661 { .dev_id = "gmac", .clk = &gmac_clk},
662 { .dev_id = "smi", .clk = &smi_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100663 { .con_id = "fsmc", .clk = &fsmc_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100664 /* clock derived from apb clk */
665 { .dev_id = "adc", .clk = &adc_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100666 { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk},
667 { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk},
668 { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100669 { .dev_id = "gpio0", .clk = &gpio0_clk},
670 { .dev_id = "gpio1", .clk = &gpio1_clk},
671 { .dev_id = "gpio2", .clk = &gpio2_clk},
672};
673
viresh kumarb997f6e2011-05-20 08:34:18 +0100674void __init spear6xx_clk_init(void)
viresh kumar8c0236f2010-04-01 12:30:46 +0100675{
676 int i;
677
678 for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++)
679 clk_register(&spear_clk_lookups[i]);
680
viresh kumarb997f6e2011-05-20 08:34:18 +0100681 clk_init();
viresh kumar8c0236f2010-04-01 12:30:46 +0100682}