blob: 6c4841f5522345cb9cdf5c1e5d83cd332adfc644 [file] [log] [blame]
viresh kumar8c0236f2010-04-01 12:30:46 +01001/*
2 * arch/arm/mach-spear3xx/clock.c
3 *
4 * SPEAr3xx 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>
Rob Herring6f6f6a72012-03-10 10:30:31 -060015#include <linux/io.h>
viresh kumar8c0236f2010-04-01 12:30:46 +010016#include <linux/kernel.h>
viresh kumar66b848e2011-05-20 08:34:19 +010017#include <asm/mach-types.h>
viresh kumar8c0236f2010-04-01 12:30:46 +010018#include <plat/clock.h>
viresh kumar410782b2011-03-07 05:57:01 +010019#include <mach/misc_regs.h>
viresh kumar8c0236f2010-04-01 12:30:46 +010020
21/* root clks */
22/* 32 KHz oscillator clock */
23static struct clk osc_32k_clk = {
24 .flags = ALWAYS_ENABLED,
25 .rate = 32000,
26};
27
28/* 24 MHz oscillator clock */
29static struct clk osc_24m_clk = {
30 .flags = ALWAYS_ENABLED,
31 .rate = 24000000,
32};
33
34/* clock derived from 32 KHz osc clk */
35/* rtc clock */
36static struct clk rtc_clk = {
37 .pclk = &osc_32k_clk,
38 .en_reg = PERIP1_CLK_ENB,
39 .en_reg_bit = RTC_CLK_ENB,
40 .recalc = &follow_parent,
41};
42
43/* clock derived from 24 MHz osc clk */
viresh kumarcf285432011-02-16 07:40:31 +010044/* pll masks structure */
45static struct pll_clk_masks pll1_masks = {
46 .mode_mask = PLL_MODE_MASK,
47 .mode_shift = PLL_MODE_SHIFT,
48 .norm_fdbk_m_mask = PLL_NORM_FDBK_M_MASK,
49 .norm_fdbk_m_shift = PLL_NORM_FDBK_M_SHIFT,
50 .dith_fdbk_m_mask = PLL_DITH_FDBK_M_MASK,
51 .dith_fdbk_m_shift = PLL_DITH_FDBK_M_SHIFT,
52 .div_p_mask = PLL_DIV_P_MASK,
53 .div_p_shift = PLL_DIV_P_SHIFT,
54 .div_n_mask = PLL_DIV_N_MASK,
55 .div_n_shift = PLL_DIV_N_SHIFT,
56};
57
viresh kumar8c0236f2010-04-01 12:30:46 +010058/* pll1 configuration structure */
59static struct pll_clk_config pll1_config = {
60 .mode_reg = PLL1_CTR,
61 .cfg_reg = PLL1_FRQ,
viresh kumarcf285432011-02-16 07:40:31 +010062 .masks = &pll1_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +010063};
64
viresh kumaraf89fd82011-02-16 07:40:39 +010065/* pll rate configuration table, in ascending order of rates */
66struct pll_rate_tbl pll_rtbl[] = {
67 {.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* 266 MHz */
68 {.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* 332 MHz */
69};
70
viresh kumar8c0236f2010-04-01 12:30:46 +010071/* PLL1 clock */
72static struct clk pll1_clk = {
viresh kumaraf89fd82011-02-16 07:40:39 +010073 .flags = ENABLED_ON_INIT,
viresh kumar8c0236f2010-04-01 12:30:46 +010074 .pclk = &osc_24m_clk,
75 .en_reg = PLL1_CTR,
76 .en_reg_bit = PLL_ENABLE,
viresh kumaraf89fd82011-02-16 07:40:39 +010077 .calc_rate = &pll_calc_rate,
viresh kumarcf285432011-02-16 07:40:31 +010078 .recalc = &pll_clk_recalc,
viresh kumaraf89fd82011-02-16 07:40:39 +010079 .set_rate = &pll_clk_set_rate,
80 .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1},
viresh kumar8c0236f2010-04-01 12:30:46 +010081 .private_data = &pll1_config,
82};
83
84/* PLL3 48 MHz clock */
85static struct clk pll3_48m_clk = {
86 .flags = ALWAYS_ENABLED,
87 .pclk = &osc_24m_clk,
88 .rate = 48000000,
89};
90
91/* watch dog timer clock */
92static struct clk wdt_clk = {
93 .flags = ALWAYS_ENABLED,
94 .pclk = &osc_24m_clk,
95 .recalc = &follow_parent,
96};
97
98/* clock derived from pll1 clk */
99/* cpu clock */
100static struct clk cpu_clk = {
101 .flags = ALWAYS_ENABLED,
102 .pclk = &pll1_clk,
103 .recalc = &follow_parent,
104};
105
viresh kumarcf285432011-02-16 07:40:31 +0100106/* ahb masks structure */
107static struct bus_clk_masks ahb_masks = {
108 .mask = PLL_HCLK_RATIO_MASK,
109 .shift = PLL_HCLK_RATIO_SHIFT,
110};
111
viresh kumar8c0236f2010-04-01 12:30:46 +0100112/* ahb configuration structure */
113static struct bus_clk_config ahb_config = {
114 .reg = CORE_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100115 .masks = &ahb_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100116};
117
viresh kumaraf89fd82011-02-16 07:40:39 +0100118/* ahb rate configuration table, in ascending order of rates */
119struct bus_rate_tbl bus_rtbl[] = {
120 {.div = 3}, /* == parent divided by 4 */
121 {.div = 2}, /* == parent divided by 3 */
122 {.div = 1}, /* == parent divided by 2 */
123 {.div = 0}, /* == parent divided by 1 */
124};
125
viresh kumar8c0236f2010-04-01 12:30:46 +0100126/* ahb clock */
127static struct clk ahb_clk = {
128 .flags = ALWAYS_ENABLED,
129 .pclk = &pll1_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100130 .calc_rate = &bus_calc_rate,
viresh kumar8c0236f2010-04-01 12:30:46 +0100131 .recalc = &bus_clk_recalc,
viresh kumaraf89fd82011-02-16 07:40:39 +0100132 .set_rate = &bus_clk_set_rate,
133 .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2},
viresh kumar8c0236f2010-04-01 12:30:46 +0100134 .private_data = &ahb_config,
135};
136
viresh kumarcf285432011-02-16 07:40:31 +0100137/* auxiliary synthesizers masks */
138static struct aux_clk_masks aux_masks = {
139 .eq_sel_mask = AUX_EQ_SEL_MASK,
140 .eq_sel_shift = AUX_EQ_SEL_SHIFT,
141 .eq1_mask = AUX_EQ1_SEL,
142 .eq2_mask = AUX_EQ2_SEL,
143 .xscale_sel_mask = AUX_XSCALE_MASK,
144 .xscale_sel_shift = AUX_XSCALE_SHIFT,
145 .yscale_sel_mask = AUX_YSCALE_MASK,
146 .yscale_sel_shift = AUX_YSCALE_SHIFT,
147};
148
viresh kumaraf89fd82011-02-16 07:40:39 +0100149/* uart synth configurations */
150static struct aux_clk_config uart_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100151 .synth_reg = UART_CLK_SYNT,
viresh kumarcf285432011-02-16 07:40:31 +0100152 .masks = &aux_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100153};
154
viresh kumaraf89fd82011-02-16 07:40:39 +0100155/* aux rate configuration table, in ascending order of rates */
156struct aux_rate_tbl aux_rtbl[] = {
157 /* For PLL1 = 332 MHz */
158 {.xscale = 1, .yscale = 8, .eq = 1}, /* 41.5 MHz */
159 {.xscale = 1, .yscale = 4, .eq = 1}, /* 83 MHz */
160 {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */
161};
162
163/* uart synth clock */
164static struct clk uart_synth_clk = {
165 .en_reg = UART_CLK_SYNT,
166 .en_reg_bit = AUX_SYNT_ENB,
167 .pclk = &pll1_clk,
168 .calc_rate = &aux_calc_rate,
169 .recalc = &aux_clk_recalc,
170 .set_rate = &aux_clk_set_rate,
171 .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 1},
172 .private_data = &uart_synth_config,
173};
174
viresh kumar8c0236f2010-04-01 12:30:46 +0100175/* uart parents */
176static struct pclk_info uart_pclk_info[] = {
177 {
viresh kumaraf89fd82011-02-16 07:40:39 +0100178 .pclk = &uart_synth_clk,
179 .pclk_val = AUX_CLK_PLL1_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100180 }, {
181 .pclk = &pll3_48m_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100182 .pclk_val = AUX_CLK_PLL3_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100183 },
184};
185
186/* uart parent select structure */
187static struct pclk_sel uart_pclk_sel = {
188 .pclk_info = uart_pclk_info,
189 .pclk_count = ARRAY_SIZE(uart_pclk_info),
190 .pclk_sel_reg = PERIP_CLK_CFG,
191 .pclk_sel_mask = UART_CLK_MASK,
192};
193
194/* uart clock */
195static struct clk uart_clk = {
196 .en_reg = PERIP1_CLK_ENB,
197 .en_reg_bit = UART_CLK_ENB,
198 .pclk_sel = &uart_pclk_sel,
199 .pclk_sel_shift = UART_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100200 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100201};
202
203/* firda configurations */
viresh kumaraf89fd82011-02-16 07:40:39 +0100204static struct aux_clk_config firda_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100205 .synth_reg = FIRDA_CLK_SYNT,
viresh kumarcf285432011-02-16 07:40:31 +0100206 .masks = &aux_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100207};
208
viresh kumaraf89fd82011-02-16 07:40:39 +0100209/* firda synth clock */
210static struct clk firda_synth_clk = {
211 .en_reg = FIRDA_CLK_SYNT,
212 .en_reg_bit = AUX_SYNT_ENB,
213 .pclk = &pll1_clk,
214 .calc_rate = &aux_calc_rate,
215 .recalc = &aux_clk_recalc,
216 .set_rate = &aux_clk_set_rate,
217 .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 1},
218 .private_data = &firda_synth_config,
219};
220
viresh kumar8c0236f2010-04-01 12:30:46 +0100221/* firda parents */
222static struct pclk_info firda_pclk_info[] = {
223 {
viresh kumaraf89fd82011-02-16 07:40:39 +0100224 .pclk = &firda_synth_clk,
225 .pclk_val = AUX_CLK_PLL1_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100226 }, {
227 .pclk = &pll3_48m_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100228 .pclk_val = AUX_CLK_PLL3_VAL,
viresh kumar8c0236f2010-04-01 12:30:46 +0100229 },
230};
231
232/* firda parent select structure */
233static struct pclk_sel firda_pclk_sel = {
234 .pclk_info = firda_pclk_info,
235 .pclk_count = ARRAY_SIZE(firda_pclk_info),
236 .pclk_sel_reg = PERIP_CLK_CFG,
237 .pclk_sel_mask = FIRDA_CLK_MASK,
238};
239
240/* firda clock */
241static struct clk firda_clk = {
242 .en_reg = PERIP1_CLK_ENB,
243 .en_reg_bit = FIRDA_CLK_ENB,
244 .pclk_sel = &firda_pclk_sel,
245 .pclk_sel_shift = FIRDA_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100246 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100247};
248
viresh kumarcf285432011-02-16 07:40:31 +0100249/* gpt synthesizer masks */
250static struct gpt_clk_masks gpt_masks = {
251 .mscale_sel_mask = GPT_MSCALE_MASK,
252 .mscale_sel_shift = GPT_MSCALE_SHIFT,
253 .nscale_sel_mask = GPT_NSCALE_MASK,
254 .nscale_sel_shift = GPT_NSCALE_SHIFT,
255};
256
viresh kumaraf89fd82011-02-16 07:40:39 +0100257/* gpt rate configuration table, in ascending order of rates */
258struct gpt_rate_tbl gpt_rtbl[] = {
259 /* For pll1 = 332 MHz */
260 {.mscale = 4, .nscale = 0}, /* 41.5 MHz */
261 {.mscale = 2, .nscale = 0}, /* 55.3 MHz */
262 {.mscale = 1, .nscale = 0}, /* 83 MHz */
263};
264
265/* gpt0 synth clk config*/
266static struct gpt_clk_config gpt0_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100267 .synth_reg = PRSC1_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100268 .masks = &gpt_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100269};
270
viresh kumaraf89fd82011-02-16 07:40:39 +0100271/* gpt synth clock */
272static struct clk gpt0_synth_clk = {
273 .flags = ALWAYS_ENABLED,
274 .pclk = &pll1_clk,
275 .calc_rate = &gpt_calc_rate,
276 .recalc = &gpt_clk_recalc,
277 .set_rate = &gpt_clk_set_rate,
278 .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2},
279 .private_data = &gpt0_synth_config,
280};
281
282/* gpt parents */
283static struct pclk_info gpt0_pclk_info[] = {
284 {
285 .pclk = &gpt0_synth_clk,
286 .pclk_val = AUX_CLK_PLL1_VAL,
287 }, {
288 .pclk = &pll3_48m_clk,
289 .pclk_val = AUX_CLK_PLL3_VAL,
290 },
291};
292
293/* gpt parent select structure */
294static struct pclk_sel gpt0_pclk_sel = {
295 .pclk_info = gpt0_pclk_info,
296 .pclk_count = ARRAY_SIZE(gpt0_pclk_info),
297 .pclk_sel_reg = PERIP_CLK_CFG,
298 .pclk_sel_mask = GPT_CLK_MASK,
299};
300
viresh kumar8c0236f2010-04-01 12:30:46 +0100301/* gpt0 timer clock */
302static struct clk gpt0_clk = {
303 .flags = ALWAYS_ENABLED,
viresh kumaraf89fd82011-02-16 07:40:39 +0100304 .pclk_sel = &gpt0_pclk_sel,
viresh kumar8c0236f2010-04-01 12:30:46 +0100305 .pclk_sel_shift = GPT0_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100306 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100307};
308
viresh kumaraf89fd82011-02-16 07:40:39 +0100309/* gpt1 synth clk configurations */
310static struct gpt_clk_config gpt1_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100311 .synth_reg = PRSC2_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100312 .masks = &gpt_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100313};
314
viresh kumaraf89fd82011-02-16 07:40:39 +0100315/* gpt1 synth clock */
316static struct clk gpt1_synth_clk = {
317 .flags = ALWAYS_ENABLED,
318 .pclk = &pll1_clk,
319 .calc_rate = &gpt_calc_rate,
320 .recalc = &gpt_clk_recalc,
321 .set_rate = &gpt_clk_set_rate,
322 .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2},
323 .private_data = &gpt1_synth_config,
324};
325
326static struct pclk_info gpt1_pclk_info[] = {
327 {
328 .pclk = &gpt1_synth_clk,
329 .pclk_val = AUX_CLK_PLL1_VAL,
330 }, {
331 .pclk = &pll3_48m_clk,
332 .pclk_val = AUX_CLK_PLL3_VAL,
333 },
334};
335
336/* gpt parent select structure */
337static struct pclk_sel gpt1_pclk_sel = {
338 .pclk_info = gpt1_pclk_info,
339 .pclk_count = ARRAY_SIZE(gpt1_pclk_info),
340 .pclk_sel_reg = PERIP_CLK_CFG,
341 .pclk_sel_mask = GPT_CLK_MASK,
342};
343
viresh kumar8c0236f2010-04-01 12:30:46 +0100344/* gpt1 timer clock */
345static struct clk gpt1_clk = {
346 .en_reg = PERIP1_CLK_ENB,
347 .en_reg_bit = GPT1_CLK_ENB,
viresh kumaraf89fd82011-02-16 07:40:39 +0100348 .pclk_sel = &gpt1_pclk_sel,
viresh kumar8c0236f2010-04-01 12:30:46 +0100349 .pclk_sel_shift = GPT1_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100350 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100351};
352
viresh kumaraf89fd82011-02-16 07:40:39 +0100353/* gpt2 synth clk configurations */
354static struct gpt_clk_config gpt2_synth_config = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100355 .synth_reg = PRSC3_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100356 .masks = &gpt_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100357};
358
viresh kumaraf89fd82011-02-16 07:40:39 +0100359/* gpt1 synth clock */
360static struct clk gpt2_synth_clk = {
361 .flags = ALWAYS_ENABLED,
362 .pclk = &pll1_clk,
363 .calc_rate = &gpt_calc_rate,
364 .recalc = &gpt_clk_recalc,
365 .set_rate = &gpt_clk_set_rate,
366 .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2},
367 .private_data = &gpt2_synth_config,
368};
369
370static struct pclk_info gpt2_pclk_info[] = {
371 {
372 .pclk = &gpt2_synth_clk,
373 .pclk_val = AUX_CLK_PLL1_VAL,
374 }, {
375 .pclk = &pll3_48m_clk,
376 .pclk_val = AUX_CLK_PLL3_VAL,
377 },
378};
379
380/* gpt parent select structure */
381static struct pclk_sel gpt2_pclk_sel = {
382 .pclk_info = gpt2_pclk_info,
383 .pclk_count = ARRAY_SIZE(gpt2_pclk_info),
384 .pclk_sel_reg = PERIP_CLK_CFG,
385 .pclk_sel_mask = GPT_CLK_MASK,
386};
387
viresh kumar8c0236f2010-04-01 12:30:46 +0100388/* gpt2 timer clock */
389static struct clk gpt2_clk = {
390 .en_reg = PERIP1_CLK_ENB,
391 .en_reg_bit = GPT2_CLK_ENB,
viresh kumaraf89fd82011-02-16 07:40:39 +0100392 .pclk_sel = &gpt2_pclk_sel,
viresh kumar8c0236f2010-04-01 12:30:46 +0100393 .pclk_sel_shift = GPT2_CLK_SHIFT,
viresh kumaraf89fd82011-02-16 07:40:39 +0100394 .recalc = &follow_parent,
viresh kumar8c0236f2010-04-01 12:30:46 +0100395};
396
397/* clock derived from pll3 clk */
398/* usbh clock */
399static struct clk usbh_clk = {
400 .pclk = &pll3_48m_clk,
401 .en_reg = PERIP1_CLK_ENB,
402 .en_reg_bit = USBH_CLK_ENB,
403 .recalc = &follow_parent,
404};
405
406/* usbd clock */
407static struct clk usbd_clk = {
408 .pclk = &pll3_48m_clk,
409 .en_reg = PERIP1_CLK_ENB,
410 .en_reg_bit = USBD_CLK_ENB,
411 .recalc = &follow_parent,
412};
413
viresh kumar8c0236f2010-04-01 12:30:46 +0100414/* clock derived from ahb clk */
viresh kumarcf285432011-02-16 07:40:31 +0100415/* apb masks structure */
416static struct bus_clk_masks apb_masks = {
417 .mask = HCLK_PCLK_RATIO_MASK,
418 .shift = HCLK_PCLK_RATIO_SHIFT,
419};
420
viresh kumar8c0236f2010-04-01 12:30:46 +0100421/* apb configuration structure */
422static struct bus_clk_config apb_config = {
423 .reg = CORE_CLK_CFG,
viresh kumarcf285432011-02-16 07:40:31 +0100424 .masks = &apb_masks,
viresh kumar8c0236f2010-04-01 12:30:46 +0100425};
426
427/* apb clock */
428static struct clk apb_clk = {
429 .flags = ALWAYS_ENABLED,
430 .pclk = &ahb_clk,
viresh kumaraf89fd82011-02-16 07:40:39 +0100431 .calc_rate = &bus_calc_rate,
viresh kumar8c0236f2010-04-01 12:30:46 +0100432 .recalc = &bus_clk_recalc,
viresh kumaraf89fd82011-02-16 07:40:39 +0100433 .set_rate = &bus_clk_set_rate,
434 .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2},
viresh kumar8c0236f2010-04-01 12:30:46 +0100435 .private_data = &apb_config,
436};
437
438/* i2c clock */
439static struct clk i2c_clk = {
440 .pclk = &ahb_clk,
441 .en_reg = PERIP1_CLK_ENB,
442 .en_reg_bit = I2C_CLK_ENB,
443 .recalc = &follow_parent,
444};
445
446/* dma clock */
447static struct clk dma_clk = {
448 .pclk = &ahb_clk,
449 .en_reg = PERIP1_CLK_ENB,
450 .en_reg_bit = DMA_CLK_ENB,
451 .recalc = &follow_parent,
452};
453
454/* jpeg clock */
455static struct clk jpeg_clk = {
456 .pclk = &ahb_clk,
457 .en_reg = PERIP1_CLK_ENB,
458 .en_reg_bit = JPEG_CLK_ENB,
459 .recalc = &follow_parent,
460};
461
462/* gmac clock */
463static struct clk gmac_clk = {
464 .pclk = &ahb_clk,
465 .en_reg = PERIP1_CLK_ENB,
466 .en_reg_bit = GMAC_CLK_ENB,
467 .recalc = &follow_parent,
468};
469
470/* smi clock */
471static struct clk smi_clk = {
472 .pclk = &ahb_clk,
473 .en_reg = PERIP1_CLK_ENB,
474 .en_reg_bit = SMI_CLK_ENB,
475 .recalc = &follow_parent,
476};
477
478/* c3 clock */
479static struct clk c3_clk = {
480 .pclk = &ahb_clk,
481 .en_reg = PERIP1_CLK_ENB,
482 .en_reg_bit = C3_CLK_ENB,
483 .recalc = &follow_parent,
484};
485
486/* clock derived from apb clk */
487/* adc clock */
488static struct clk adc_clk = {
489 .pclk = &apb_clk,
490 .en_reg = PERIP1_CLK_ENB,
491 .en_reg_bit = ADC_CLK_ENB,
492 .recalc = &follow_parent,
493};
494
viresh kumaraf89fd82011-02-16 07:40:39 +0100495#if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
496/* emi clock */
497static struct clk emi_clk = {
498 .flags = ALWAYS_ENABLED,
499 .pclk = &ahb_clk,
500 .recalc = &follow_parent,
501};
502#endif
503
viresh kumar8c0236f2010-04-01 12:30:46 +0100504/* ssp clock */
viresh kumaraf89fd82011-02-16 07:40:39 +0100505static struct clk ssp0_clk = {
viresh kumar8c0236f2010-04-01 12:30:46 +0100506 .pclk = &apb_clk,
507 .en_reg = PERIP1_CLK_ENB,
508 .en_reg_bit = SSP_CLK_ENB,
509 .recalc = &follow_parent,
510};
511
512/* gpio clock */
513static struct clk gpio_clk = {
514 .pclk = &apb_clk,
515 .en_reg = PERIP1_CLK_ENB,
516 .en_reg_bit = GPIO_CLK_ENB,
517 .recalc = &follow_parent,
518};
519
Russell King3126c7b2010-07-15 11:01:17 +0100520static struct clk dummy_apb_pclk;
521
viresh kumaraf89fd82011-02-16 07:40:39 +0100522#if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR310) || \
523 defined(CONFIG_MACH_SPEAR320)
524/* fsmc clock */
525static struct clk fsmc_clk = {
526 .flags = ALWAYS_ENABLED,
527 .pclk = &ahb_clk,
528 .recalc = &follow_parent,
529};
530#endif
531
532/* common clocks to spear310 and spear320 */
533#if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
534/* uart1 clock */
535static struct clk uart1_clk = {
536 .flags = ALWAYS_ENABLED,
537 .pclk = &apb_clk,
538 .recalc = &follow_parent,
539};
540
541/* uart2 clock */
542static struct clk uart2_clk = {
543 .flags = ALWAYS_ENABLED,
544 .pclk = &apb_clk,
545 .recalc = &follow_parent,
546};
547#endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */
548
549/* common clocks to spear300 and spear320 */
550#if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR320)
551/* clcd clock */
552static struct clk clcd_clk = {
553 .flags = ALWAYS_ENABLED,
554 .pclk = &pll3_48m_clk,
555 .recalc = &follow_parent,
556};
557
558/* sdhci clock */
559static struct clk sdhci_clk = {
560 .flags = ALWAYS_ENABLED,
561 .pclk = &ahb_clk,
562 .recalc = &follow_parent,
563};
564#endif /* CONFIG_MACH_SPEAR300 || CONFIG_MACH_SPEAR320 */
565
566/* spear300 machine specific clock structures */
567#ifdef CONFIG_MACH_SPEAR300
568/* gpio1 clock */
569static struct clk gpio1_clk = {
570 .flags = ALWAYS_ENABLED,
571 .pclk = &apb_clk,
572 .recalc = &follow_parent,
573};
574
575/* keyboard clock */
576static struct clk kbd_clk = {
577 .flags = ALWAYS_ENABLED,
578 .pclk = &apb_clk,
579 .recalc = &follow_parent,
580};
581
582#endif
583
584/* spear310 machine specific clock structures */
585#ifdef CONFIG_MACH_SPEAR310
586/* uart3 clock */
587static struct clk uart3_clk = {
588 .flags = ALWAYS_ENABLED,
589 .pclk = &apb_clk,
590 .recalc = &follow_parent,
591};
592
593/* uart4 clock */
594static struct clk uart4_clk = {
595 .flags = ALWAYS_ENABLED,
596 .pclk = &apb_clk,
597 .recalc = &follow_parent,
598};
599
600/* uart5 clock */
601static struct clk uart5_clk = {
602 .flags = ALWAYS_ENABLED,
603 .pclk = &apb_clk,
604 .recalc = &follow_parent,
605};
606#endif
607
608/* spear320 machine specific clock structures */
609#ifdef CONFIG_MACH_SPEAR320
610/* can0 clock */
611static struct clk can0_clk = {
612 .flags = ALWAYS_ENABLED,
613 .pclk = &apb_clk,
614 .recalc = &follow_parent,
615};
616
617/* can1 clock */
618static struct clk can1_clk = {
619 .flags = ALWAYS_ENABLED,
620 .pclk = &apb_clk,
621 .recalc = &follow_parent,
622};
623
624/* i2c1 clock */
625static struct clk i2c1_clk = {
626 .flags = ALWAYS_ENABLED,
627 .pclk = &ahb_clk,
628 .recalc = &follow_parent,
629};
630
631/* ssp1 clock */
632static struct clk ssp1_clk = {
633 .flags = ALWAYS_ENABLED,
634 .pclk = &apb_clk,
635 .recalc = &follow_parent,
636};
637
638/* ssp2 clock */
639static struct clk ssp2_clk = {
640 .flags = ALWAYS_ENABLED,
641 .pclk = &apb_clk,
642 .recalc = &follow_parent,
643};
644
645/* pwm clock */
646static struct clk pwm_clk = {
647 .flags = ALWAYS_ENABLED,
648 .pclk = &apb_clk,
649 .recalc = &follow_parent,
650};
651#endif
652
viresh kumar8c0236f2010-04-01 12:30:46 +0100653/* array of all spear 3xx clock lookups */
654static struct clk_lookup spear_clk_lookups[] = {
viresh kumarb5761372011-03-07 05:57:04 +0100655 { .con_id = "apb_pclk", .clk = &dummy_apb_pclk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100656 /* root clks */
657 { .con_id = "osc_32k_clk", .clk = &osc_32k_clk},
658 { .con_id = "osc_24m_clk", .clk = &osc_24m_clk},
659 /* clock derived from 32 KHz osc clk */
viresh kumaraf89fd82011-02-16 07:40:39 +0100660 { .dev_id = "rtc-spear", .clk = &rtc_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100661 /* clock derived from 24 MHz osc clk */
662 { .con_id = "pll1_clk", .clk = &pll1_clk},
663 { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk},
664 { .dev_id = "wdt", .clk = &wdt_clk},
665 /* clock derived from pll1 clk */
666 { .con_id = "cpu_clk", .clk = &cpu_clk},
667 { .con_id = "ahb_clk", .clk = &ahb_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100668 { .con_id = "uart_synth_clk", .clk = &uart_synth_clk},
669 { .con_id = "firda_synth_clk", .clk = &firda_synth_clk},
670 { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk},
671 { .con_id = "gpt1_synth_clk", .clk = &gpt1_synth_clk},
672 { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100673 { .dev_id = "uart", .clk = &uart_clk},
674 { .dev_id = "firda", .clk = &firda_clk},
675 { .dev_id = "gpt0", .clk = &gpt0_clk},
676 { .dev_id = "gpt1", .clk = &gpt1_clk},
677 { .dev_id = "gpt2", .clk = &gpt2_clk},
678 /* clock derived from pll3 clk */
viresh kumarb5761372011-03-07 05:57:04 +0100679 { .dev_id = "designware_udc", .clk = &usbd_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100680 { .con_id = "usbh_clk", .clk = &usbh_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100681 /* clock derived from ahb clk */
682 { .con_id = "apb_clk", .clk = &apb_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100683 { .dev_id = "i2c_designware.0", .clk = &i2c_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100684 { .dev_id = "dma", .clk = &dma_clk},
685 { .dev_id = "jpeg", .clk = &jpeg_clk},
686 { .dev_id = "gmac", .clk = &gmac_clk},
687 { .dev_id = "smi", .clk = &smi_clk},
688 { .dev_id = "c3", .clk = &c3_clk},
689 /* clock derived from apb clk */
690 { .dev_id = "adc", .clk = &adc_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100691 { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100692 { .dev_id = "gpio", .clk = &gpio_clk},
viresh kumar66b848e2011-05-20 08:34:19 +0100693};
viresh kumaraf89fd82011-02-16 07:40:39 +0100694
viresh kumar66b848e2011-05-20 08:34:19 +0100695/* array of all spear 300 clock lookups */
viresh kumaraf89fd82011-02-16 07:40:39 +0100696#ifdef CONFIG_MACH_SPEAR300
viresh kumar66b848e2011-05-20 08:34:19 +0100697static struct clk_lookup spear300_clk_lookups[] = {
698 { .dev_id = "clcd", .clk = &clcd_clk},
699 { .con_id = "fsmc", .clk = &fsmc_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100700 { .dev_id = "gpio1", .clk = &gpio1_clk},
701 { .dev_id = "keyboard", .clk = &kbd_clk},
viresh kumar66b848e2011-05-20 08:34:19 +0100702 { .dev_id = "sdhci", .clk = &sdhci_clk},
703};
viresh kumaraf89fd82011-02-16 07:40:39 +0100704#endif
705
viresh kumar66b848e2011-05-20 08:34:19 +0100706/* array of all spear 310 clock lookups */
viresh kumaraf89fd82011-02-16 07:40:39 +0100707#ifdef CONFIG_MACH_SPEAR310
viresh kumar66b848e2011-05-20 08:34:19 +0100708static struct clk_lookup spear310_clk_lookups[] = {
709 { .con_id = "fsmc", .clk = &fsmc_clk},
710 { .con_id = "emi", .clk = &emi_clk},
711 { .dev_id = "uart1", .clk = &uart1_clk},
712 { .dev_id = "uart2", .clk = &uart2_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100713 { .dev_id = "uart3", .clk = &uart3_clk},
714 { .dev_id = "uart4", .clk = &uart4_clk},
715 { .dev_id = "uart5", .clk = &uart5_clk},
viresh kumar66b848e2011-05-20 08:34:19 +0100716};
viresh kumaraf89fd82011-02-16 07:40:39 +0100717#endif
viresh kumar66b848e2011-05-20 08:34:19 +0100718
719/* array of all spear 320 clock lookups */
viresh kumaraf89fd82011-02-16 07:40:39 +0100720#ifdef CONFIG_MACH_SPEAR320
viresh kumar66b848e2011-05-20 08:34:19 +0100721static struct clk_lookup spear320_clk_lookups[] = {
722 { .dev_id = "clcd", .clk = &clcd_clk},
723 { .con_id = "fsmc", .clk = &fsmc_clk},
724 { .dev_id = "i2c_designware.1", .clk = &i2c1_clk},
725 { .con_id = "emi", .clk = &emi_clk},
726 { .dev_id = "pwm", .clk = &pwm_clk},
727 { .dev_id = "sdhci", .clk = &sdhci_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100728 { .dev_id = "c_can_platform.0", .clk = &can0_clk},
729 { .dev_id = "c_can_platform.1", .clk = &can1_clk},
viresh kumaraf89fd82011-02-16 07:40:39 +0100730 { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk},
731 { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk},
viresh kumar66b848e2011-05-20 08:34:19 +0100732 { .dev_id = "uart1", .clk = &uart1_clk},
733 { .dev_id = "uart2", .clk = &uart2_clk},
viresh kumar8c0236f2010-04-01 12:30:46 +0100734};
viresh kumar66b848e2011-05-20 08:34:19 +0100735#endif
viresh kumar8c0236f2010-04-01 12:30:46 +0100736
viresh kumarb997f6e2011-05-20 08:34:18 +0100737void __init spear3xx_clk_init(void)
viresh kumar8c0236f2010-04-01 12:30:46 +0100738{
viresh kumar66b848e2011-05-20 08:34:19 +0100739 int i, cnt;
740 struct clk_lookup *lookups;
741
742 if (machine_is_spear300()) {
743 cnt = ARRAY_SIZE(spear300_clk_lookups);
744 lookups = spear300_clk_lookups;
745 } else if (machine_is_spear310()) {
746 cnt = ARRAY_SIZE(spear310_clk_lookups);
747 lookups = spear310_clk_lookups;
748 } else {
749 cnt = ARRAY_SIZE(spear320_clk_lookups);
750 lookups = spear320_clk_lookups;
751 }
viresh kumar8c0236f2010-04-01 12:30:46 +0100752
753 for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++)
754 clk_register(&spear_clk_lookups[i]);
755
viresh kumar66b848e2011-05-20 08:34:19 +0100756 for (i = 0; i < cnt; i++)
757 clk_register(&lookups[i]);
758
viresh kumarb997f6e2011-05-20 08:34:18 +0100759 clk_init();
viresh kumar8c0236f2010-04-01 12:30:46 +0100760}