blob: 31f97f1bb36359d65d663b49757d32ef5c562847 [file] [log] [blame]
Ben Dooksaf337f32010-04-28 18:03:57 +09001/* linux/arch/arm/plat-s3c24xx/s3c2443-clock.c
2 *
3 * Copyright (c) 2007, 2010 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2443 Clock control suport - common code
7 */
8
9#include <linux/init.h>
10#include <linux/clk.h>
11#include <linux/io.h>
12
13#include <mach/regs-s3c2443-clock.h>
14
15#include <plat/s3c2443.h>
16#include <plat/clock.h>
17#include <plat/clock-clksrc.h>
18#include <plat/cpu.h>
19
20#include <plat/cpu-freq.h>
21
22
23static int s3c2443_gate(void __iomem *reg, struct clk *clk, int enable)
24{
25 u32 ctrlbit = clk->ctrlbit;
26 u32 con = __raw_readl(reg);
27
28 if (enable)
29 con |= ctrlbit;
30 else
31 con &= ~ctrlbit;
32
33 __raw_writel(con, reg);
34 return 0;
35}
36
37int s3c2443_clkcon_enable_h(struct clk *clk, int enable)
38{
39 return s3c2443_gate(S3C2443_HCLKCON, clk, enable);
40}
41
42int s3c2443_clkcon_enable_p(struct clk *clk, int enable)
43{
44 return s3c2443_gate(S3C2443_PCLKCON, clk, enable);
45}
46
47int s3c2443_clkcon_enable_s(struct clk *clk, int enable)
48{
49 return s3c2443_gate(S3C2443_SCLKCON, clk, enable);
50}
51
52/* mpllref is a direct descendant of clk_xtal by default, but it is not
53 * elided as the EPLL can be either sourced by the XTAL or EXTCLK and as
54 * such directly equating the two source clocks is impossible.
55 */
56struct clk clk_mpllref = {
57 .name = "mpllref",
58 .parent = &clk_xtal,
Ben Dooksaf337f32010-04-28 18:03:57 +090059};
60
61static struct clk *clk_epllref_sources[] = {
62 [0] = &clk_mpllref,
63 [1] = &clk_mpllref,
64 [2] = &clk_xtal,
65 [3] = &clk_ext,
66};
67
68struct clksrc_clk clk_epllref = {
69 .clk = {
70 .name = "epllref",
Ben Dooksaf337f32010-04-28 18:03:57 +090071 },
72 .sources = &(struct clksrc_sources) {
73 .sources = clk_epllref_sources,
74 .nr_sources = ARRAY_SIZE(clk_epllref_sources),
75 },
76 .reg_src = { .reg = S3C2443_CLKSRC, .size = 2, .shift = 7 },
77};
78
79/* esysclk
80 *
81 * this is sourced from either the EPLL or the EPLLref clock
82*/
83
84static struct clk *clk_sysclk_sources[] = {
85 [0] = &clk_epllref.clk,
86 [1] = &clk_epll,
87};
88
89struct clksrc_clk clk_esysclk = {
90 .clk = {
91 .name = "esysclk",
92 .parent = &clk_epll,
Ben Dooksaf337f32010-04-28 18:03:57 +090093 },
94 .sources = &(struct clksrc_sources) {
95 .sources = clk_sysclk_sources,
96 .nr_sources = ARRAY_SIZE(clk_sysclk_sources),
97 },
98 .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 6 },
99};
100
101static unsigned long s3c2443_getrate_mdivclk(struct clk *clk)
102{
103 unsigned long parent_rate = clk_get_rate(clk->parent);
104 unsigned long div = __raw_readl(S3C2443_CLKDIV0);
105
106 div &= S3C2443_CLKDIV0_EXTDIV_MASK;
107 div >>= (S3C2443_CLKDIV0_EXTDIV_SHIFT-1); /* x2 */
108
109 return parent_rate / (div + 1);
110}
111
112static struct clk clk_mdivclk = {
113 .name = "mdivclk",
114 .parent = &clk_mpllref,
Ben Dooksaf337f32010-04-28 18:03:57 +0900115 .ops = &(struct clk_ops) {
116 .get_rate = s3c2443_getrate_mdivclk,
117 },
118};
119
120static struct clk *clk_msysclk_sources[] = {
121 [0] = &clk_mpllref,
122 [1] = &clk_mpll,
123 [2] = &clk_mdivclk,
124 [3] = &clk_mpllref,
125};
126
127struct clksrc_clk clk_msysclk = {
128 .clk = {
129 .name = "msysclk",
130 .parent = &clk_xtal,
Ben Dooksaf337f32010-04-28 18:03:57 +0900131 },
132 .sources = &(struct clksrc_sources) {
133 .sources = clk_msysclk_sources,
134 .nr_sources = ARRAY_SIZE(clk_msysclk_sources),
135 },
136 .reg_src = { .reg = S3C2443_CLKSRC, .size = 2, .shift = 3 },
137};
138
139/* prediv
140 *
141 * this divides the msysclk down to pass to h/p/etc.
142 */
143
144static unsigned long s3c2443_prediv_getrate(struct clk *clk)
145{
146 unsigned long rate = clk_get_rate(clk->parent);
147 unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
148
149 clkdiv0 &= S3C2443_CLKDIV0_PREDIV_MASK;
150 clkdiv0 >>= S3C2443_CLKDIV0_PREDIV_SHIFT;
151
152 return rate / (clkdiv0 + 1);
153}
154
155static struct clk clk_prediv = {
156 .name = "prediv",
Ben Dooksaf337f32010-04-28 18:03:57 +0900157 .parent = &clk_msysclk.clk,
158 .ops = &(struct clk_ops) {
159 .get_rate = s3c2443_prediv_getrate,
160 },
161};
162
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900163/* armdiv
164 *
165 * this clock is sourced from msysclk and can have a number of
166 * divider values applied to it to then be fed into armclk.
167*/
168
Heiko Stuebnerd9a3bfb2011-10-14 15:08:56 +0900169static unsigned int *armdiv;
170static int nr_armdiv;
171static int armdivmask;
172
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900173static unsigned long s3c2443_armclk_roundrate(struct clk *clk,
174 unsigned long rate)
175{
176 unsigned long parent = clk_get_rate(clk->parent);
177 unsigned long calc;
178 unsigned best = 256; /* bigger than any value */
179 unsigned div;
180 int ptr;
181
Heiko Stuebnerf9f7c752011-10-14 15:08:56 +0900182 if (!nr_armdiv)
183 return -EINVAL;
184
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900185 for (ptr = 0; ptr < nr_armdiv; ptr++) {
186 div = armdiv[ptr];
Heiko Stuebnerf9f7c752011-10-14 15:08:56 +0900187 if (div) {
188 calc = parent / div;
189 if (calc <= rate && div < best)
190 best = div;
191 }
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900192 }
193
194 return parent / best;
195}
196
Heiko Stuebner5f33bd72011-10-14 15:08:56 +0900197static unsigned long s3c2443_armclk_getrate(struct clk *clk)
198{
199 unsigned long rate = clk_get_rate(clk->parent);
200 unsigned long clkcon0;
201 int val;
202
Heiko Stuebnerf9f7c752011-10-14 15:08:56 +0900203 if (!nr_armdiv || !armdivmask)
204 return -EINVAL;
205
Heiko Stuebner5f33bd72011-10-14 15:08:56 +0900206 clkcon0 = __raw_readl(S3C2443_CLKDIV0);
207 clkcon0 &= armdivmask;
208 val = clkcon0 >> S3C2443_CLKDIV0_ARMDIV_SHIFT;
209
210 return rate / armdiv[val];
211}
212
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900213static int s3c2443_armclk_setrate(struct clk *clk, unsigned long rate)
214{
215 unsigned long parent = clk_get_rate(clk->parent);
216 unsigned long calc;
217 unsigned div;
218 unsigned best = 256; /* bigger than any value */
219 int ptr;
220 int val = -1;
221
Heiko Stuebnerf9f7c752011-10-14 15:08:56 +0900222 if (!nr_armdiv || !armdivmask)
223 return -EINVAL;
224
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900225 for (ptr = 0; ptr < nr_armdiv; ptr++) {
226 div = armdiv[ptr];
Heiko Stuebnerf9f7c752011-10-14 15:08:56 +0900227 if (div) {
228 calc = parent / div;
229 if (calc <= rate && div < best) {
230 best = div;
231 val = ptr;
232 }
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900233 }
234 }
235
236 if (val >= 0) {
237 unsigned long clkcon0;
238
239 clkcon0 = __raw_readl(S3C2443_CLKDIV0);
240 clkcon0 &= ~armdivmask;
241 clkcon0 |= val << S3C2443_CLKDIV0_ARMDIV_SHIFT;
242 __raw_writel(clkcon0, S3C2443_CLKDIV0);
243 }
244
245 return (val == -1) ? -EINVAL : 0;
246}
247
248static struct clk clk_armdiv = {
249 .name = "armdiv",
250 .parent = &clk_msysclk.clk,
251 .ops = &(struct clk_ops) {
252 .round_rate = s3c2443_armclk_roundrate,
Heiko Stuebner5f33bd72011-10-14 15:08:56 +0900253 .get_rate = s3c2443_armclk_getrate,
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900254 .set_rate = s3c2443_armclk_setrate,
255 },
256};
257
258/* armclk
259 *
260 * this is the clock fed into the ARM core itself, from armdiv or from hclk.
261 */
262
263static struct clk *clk_arm_sources[] = {
264 [0] = &clk_armdiv,
265 [1] = &clk_h,
266};
267
268static struct clksrc_clk clk_arm = {
269 .clk = {
270 .name = "armclk",
271 },
272 .sources = &(struct clksrc_sources) {
273 .sources = clk_arm_sources,
274 .nr_sources = ARRAY_SIZE(clk_arm_sources),
275 },
276 .reg_src = { .reg = S3C2443_CLKDIV0, .size = 1, .shift = 13 },
277};
278
Ben Dooksaf337f32010-04-28 18:03:57 +0900279/* usbhost
280 *
281 * usb host bus-clock, usually 48MHz to provide USB bus clock timing
282*/
283
284static struct clksrc_clk clk_usb_bus_host = {
285 .clk = {
286 .name = "usb-bus-host-parent",
Ben Dooksaf337f32010-04-28 18:03:57 +0900287 .parent = &clk_esysclk.clk,
288 .ctrlbit = S3C2443_SCLKCON_USBHOST,
289 .enable = s3c2443_clkcon_enable_s,
290 },
291 .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 4 },
292};
293
294/* common clksrc clocks */
295
296static struct clksrc_clk clksrc_clks[] = {
297 {
298 /* ART baud-rate clock sourced from esysclk via a divisor */
299 .clk = {
300 .name = "uartclk",
Ben Dooksaf337f32010-04-28 18:03:57 +0900301 .parent = &clk_esysclk.clk,
302 },
303 .reg_div = { .reg = S3C2443_CLKDIV1, .size = 4, .shift = 8 },
304 }, {
305 /* camera interface bus-clock, divided down from esysclk */
306 .clk = {
307 .name = "camif-upll", /* same as 2440 name */
Ben Dooksaf337f32010-04-28 18:03:57 +0900308 .parent = &clk_esysclk.clk,
309 .ctrlbit = S3C2443_SCLKCON_CAMCLK,
310 .enable = s3c2443_clkcon_enable_s,
311 },
312 .reg_div = { .reg = S3C2443_CLKDIV1, .size = 4, .shift = 26 },
313 }, {
314 .clk = {
315 .name = "display-if",
Ben Dooksaf337f32010-04-28 18:03:57 +0900316 .parent = &clk_esysclk.clk,
317 .ctrlbit = S3C2443_SCLKCON_DISPCLK,
318 .enable = s3c2443_clkcon_enable_s,
319 },
320 .reg_div = { .reg = S3C2443_CLKDIV1, .size = 8, .shift = 16 },
321 },
322};
323
Heiko Stuebnere3b454f2011-09-27 08:44:37 +0900324static struct clk clk_i2s_ext = {
325 .name = "i2s-ext",
326};
327
328/* i2s_eplldiv
329 *
330 * This clock is the output from the I2S divisor of ESYSCLK, and is separate
331 * from the mux that comes after it (cannot merge into one single clock)
332*/
333
334static struct clksrc_clk clk_i2s_eplldiv = {
335 .clk = {
336 .name = "i2s-eplldiv",
337 .parent = &clk_esysclk.clk,
338 },
339 .reg_div = { .reg = S3C2443_CLKDIV1, .size = 4, .shift = 12, },
340};
341
342/* i2s-ref
343 *
344 * i2s bus reference clock, selectable from external, esysclk or epllref
345 *
346 * Note, this used to be two clocks, but was compressed into one.
347*/
348
349static struct clk *clk_i2s_srclist[] = {
350 [0] = &clk_i2s_eplldiv.clk,
351 [1] = &clk_i2s_ext,
352 [2] = &clk_epllref.clk,
353 [3] = &clk_epllref.clk,
354};
355
356static struct clksrc_clk clk_i2s = {
357 .clk = {
358 .name = "i2s-if",
359 .ctrlbit = S3C2443_SCLKCON_I2SCLK,
360 .enable = s3c2443_clkcon_enable_s,
361
362 },
363 .sources = &(struct clksrc_sources) {
364 .sources = clk_i2s_srclist,
365 .nr_sources = ARRAY_SIZE(clk_i2s_srclist),
366 },
367 .reg_src = { .reg = S3C2443_CLKSRC, .size = 2, .shift = 14 },
368};
Ben Dooksaf337f32010-04-28 18:03:57 +0900369
370static struct clk init_clocks_off[] = {
371 {
Heiko Stuebnere3b454f2011-09-27 08:44:37 +0900372 .name = "iis",
373 .parent = &clk_p,
374 .enable = s3c2443_clkcon_enable_p,
375 .ctrlbit = S3C2443_PCLKCON_IIS,
376 }, {
Heiko Stuebner8b069b72011-09-27 08:45:23 +0900377 .name = "hsspi",
378 .parent = &clk_p,
379 .enable = s3c2443_clkcon_enable_p,
380 .ctrlbit = S3C2443_PCLKCON_HSSPI,
381 }, {
Ben Dooksaf337f32010-04-28 18:03:57 +0900382 .name = "adc",
Ben Dooksaf337f32010-04-28 18:03:57 +0900383 .parent = &clk_p,
384 .enable = s3c2443_clkcon_enable_p,
385 .ctrlbit = S3C2443_PCLKCON_ADC,
386 }, {
387 .name = "i2c",
Ben Dooksaf337f32010-04-28 18:03:57 +0900388 .parent = &clk_p,
389 .enable = s3c2443_clkcon_enable_p,
390 .ctrlbit = S3C2443_PCLKCON_IIC,
391 }
392};
393
394static struct clk init_clocks[] = {
395 {
396 .name = "dma",
Ben Dooksaf337f32010-04-28 18:03:57 +0900397 .parent = &clk_h,
398 .enable = s3c2443_clkcon_enable_h,
399 .ctrlbit = S3C2443_HCLKCON_DMA0,
400 }, {
401 .name = "dma",
Ben Dooksaf337f32010-04-28 18:03:57 +0900402 .parent = &clk_h,
403 .enable = s3c2443_clkcon_enable_h,
404 .ctrlbit = S3C2443_HCLKCON_DMA1,
405 }, {
406 .name = "dma",
Ben Dooksaf337f32010-04-28 18:03:57 +0900407 .parent = &clk_h,
408 .enable = s3c2443_clkcon_enable_h,
409 .ctrlbit = S3C2443_HCLKCON_DMA2,
410 }, {
411 .name = "dma",
Ben Dooksaf337f32010-04-28 18:03:57 +0900412 .parent = &clk_h,
413 .enable = s3c2443_clkcon_enable_h,
414 .ctrlbit = S3C2443_HCLKCON_DMA3,
415 }, {
416 .name = "dma",
Ben Dooksaf337f32010-04-28 18:03:57 +0900417 .parent = &clk_h,
418 .enable = s3c2443_clkcon_enable_h,
419 .ctrlbit = S3C2443_HCLKCON_DMA4,
420 }, {
421 .name = "dma",
Ben Dooksaf337f32010-04-28 18:03:57 +0900422 .parent = &clk_h,
423 .enable = s3c2443_clkcon_enable_h,
424 .ctrlbit = S3C2443_HCLKCON_DMA5,
425 }, {
426 .name = "hsmmc",
Ben Dooksaf337f32010-04-28 18:03:57 +0900427 .parent = &clk_h,
428 .enable = s3c2443_clkcon_enable_h,
429 .ctrlbit = S3C2443_HCLKCON_HSMMC,
430 }, {
431 .name = "gpio",
Ben Dooksaf337f32010-04-28 18:03:57 +0900432 .parent = &clk_p,
433 .enable = s3c2443_clkcon_enable_p,
434 .ctrlbit = S3C2443_PCLKCON_GPIO,
435 }, {
436 .name = "usb-host",
Ben Dooksaf337f32010-04-28 18:03:57 +0900437 .parent = &clk_h,
438 .enable = s3c2443_clkcon_enable_h,
439 .ctrlbit = S3C2443_HCLKCON_USBH,
440 }, {
441 .name = "usb-device",
Ben Dooksaf337f32010-04-28 18:03:57 +0900442 .parent = &clk_h,
443 .enable = s3c2443_clkcon_enable_h,
444 .ctrlbit = S3C2443_HCLKCON_USBD,
445 }, {
446 .name = "lcd",
Ben Dooksaf337f32010-04-28 18:03:57 +0900447 .parent = &clk_h,
448 .enable = s3c2443_clkcon_enable_h,
449 .ctrlbit = S3C2443_HCLKCON_LCDC,
450
451 }, {
452 .name = "timers",
Ben Dooksaf337f32010-04-28 18:03:57 +0900453 .parent = &clk_p,
454 .enable = s3c2443_clkcon_enable_p,
455 .ctrlbit = S3C2443_PCLKCON_PWMT,
456 }, {
457 .name = "cfc",
Ben Dooksaf337f32010-04-28 18:03:57 +0900458 .parent = &clk_h,
459 .enable = s3c2443_clkcon_enable_h,
460 .ctrlbit = S3C2443_HCLKCON_CFC,
461 }, {
462 .name = "ssmc",
Ben Dooksaf337f32010-04-28 18:03:57 +0900463 .parent = &clk_h,
464 .enable = s3c2443_clkcon_enable_h,
465 .ctrlbit = S3C2443_HCLKCON_SSMC,
466 }, {
467 .name = "uart",
Thomas Abrahame83626f2011-06-14 19:12:26 +0900468 .devname = "s3c2440-uart.0",
Ben Dooksaf337f32010-04-28 18:03:57 +0900469 .parent = &clk_p,
470 .enable = s3c2443_clkcon_enable_p,
471 .ctrlbit = S3C2443_PCLKCON_UART0,
472 }, {
473 .name = "uart",
Thomas Abrahame83626f2011-06-14 19:12:26 +0900474 .devname = "s3c2440-uart.1",
Ben Dooksaf337f32010-04-28 18:03:57 +0900475 .parent = &clk_p,
476 .enable = s3c2443_clkcon_enable_p,
477 .ctrlbit = S3C2443_PCLKCON_UART1,
478 }, {
479 .name = "uart",
Thomas Abrahame83626f2011-06-14 19:12:26 +0900480 .devname = "s3c2440-uart.2",
Ben Dooksaf337f32010-04-28 18:03:57 +0900481 .parent = &clk_p,
482 .enable = s3c2443_clkcon_enable_p,
483 .ctrlbit = S3C2443_PCLKCON_UART2,
484 }, {
485 .name = "uart",
Thomas Abrahame83626f2011-06-14 19:12:26 +0900486 .devname = "s3c2440-uart.3",
Ben Dooksaf337f32010-04-28 18:03:57 +0900487 .parent = &clk_p,
488 .enable = s3c2443_clkcon_enable_p,
489 .ctrlbit = S3C2443_PCLKCON_UART3,
490 }, {
491 .name = "rtc",
Ben Dooksaf337f32010-04-28 18:03:57 +0900492 .parent = &clk_p,
493 .enable = s3c2443_clkcon_enable_p,
494 .ctrlbit = S3C2443_PCLKCON_RTC,
495 }, {
496 .name = "watchdog",
Ben Dooksaf337f32010-04-28 18:03:57 +0900497 .parent = &clk_p,
498 .ctrlbit = S3C2443_PCLKCON_WDT,
499 }, {
500 .name = "ac97",
Ben Dooksaf337f32010-04-28 18:03:57 +0900501 .parent = &clk_p,
502 .ctrlbit = S3C2443_PCLKCON_AC97,
503 }, {
504 .name = "nand",
Ben Dooksaf337f32010-04-28 18:03:57 +0900505 .parent = &clk_h,
506 }, {
507 .name = "usb-bus-host",
Ben Dooksaf337f32010-04-28 18:03:57 +0900508 .parent = &clk_usb_bus_host.clk,
509 }
510};
511
512static inline unsigned long s3c2443_get_hdiv(unsigned long clkcon0)
513{
514 clkcon0 &= S3C2443_CLKDIV0_HCLKDIV_MASK;
515
516 return clkcon0 + 1;
517}
518
519/* EPLLCON compatible enough to get on/off information */
520
521void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll,
522 fdiv_fn get_fdiv)
523{
524 unsigned long epllcon = __raw_readl(S3C2443_EPLLCON);
525 unsigned long mpllcon = __raw_readl(S3C2443_MPLLCON);
526 unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
527 struct clk *xtal_clk;
528 unsigned long xtal;
529 unsigned long pll;
530 unsigned long fclk;
531 unsigned long hclk;
532 unsigned long pclk;
533 int ptr;
534
535 xtal_clk = clk_get(NULL, "xtal");
536 xtal = clk_get_rate(xtal_clk);
537 clk_put(xtal_clk);
538
539 pll = get_mpll(mpllcon, xtal);
540 clk_msysclk.clk.rate = pll;
541
542 fclk = pll / get_fdiv(clkdiv0);
543 hclk = s3c2443_prediv_getrate(&clk_prediv);
544 hclk /= s3c2443_get_hdiv(clkdiv0);
545 pclk = hclk / ((clkdiv0 & S3C2443_CLKDIV0_HALF_PCLK) ? 2 : 1);
546
547 s3c24xx_setup_clocks(fclk, hclk, pclk);
548
549 printk("CPU: MPLL %s %ld.%03ld MHz, cpu %ld.%03ld MHz, mem %ld.%03ld MHz, pclk %ld.%03ld MHz\n",
550 (mpllcon & S3C2443_PLLCON_OFF) ? "off":"on",
551 print_mhz(pll), print_mhz(fclk),
552 print_mhz(hclk), print_mhz(pclk));
553
554 for (ptr = 0; ptr < ARRAY_SIZE(clksrc_clks); ptr++)
555 s3c_set_clksrc(&clksrc_clks[ptr], true);
556
557 /* ensure usb bus clock is within correct rate of 48MHz */
558
559 if (clk_get_rate(&clk_usb_bus_host.clk) != (48 * 1000 * 1000)) {
560 printk(KERN_INFO "Warning: USB host bus not at 48MHz\n");
561 clk_set_rate(&clk_usb_bus_host.clk, 48*1000*1000);
562 }
563
564 printk("CPU: EPLL %s %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n",
565 (epllcon & S3C2443_PLLCON_OFF) ? "off":"on",
566 print_mhz(clk_get_rate(&clk_epll)),
567 print_mhz(clk_get_rate(&clk_usb_bus)));
568}
569
570static struct clk *clks[] __initdata = {
571 &clk_prediv,
572 &clk_mpllref,
573 &clk_mdivclk,
574 &clk_ext,
575 &clk_epll,
576 &clk_usb_bus,
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900577 &clk_armdiv,
Ben Dooksaf337f32010-04-28 18:03:57 +0900578};
579
580static struct clksrc_clk *clksrcs[] __initdata = {
Heiko Stuebnere3b454f2011-09-27 08:44:37 +0900581 &clk_i2s_eplldiv,
582 &clk_i2s,
Ben Dooksaf337f32010-04-28 18:03:57 +0900583 &clk_usb_bus_host,
584 &clk_epllref,
585 &clk_esysclk,
586 &clk_msysclk,
Heiko St?bneraab08ee2011-10-14 15:08:56 +0900587 &clk_arm,
Ben Dooksaf337f32010-04-28 18:03:57 +0900588};
589
590void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
Heiko Stuebnerd9a3bfb2011-10-14 15:08:56 +0900591 fdiv_fn get_fdiv,
592 unsigned int *divs, int nr_divs,
593 int divmask)
Ben Dooksaf337f32010-04-28 18:03:57 +0900594{
595 int ptr;
596
Heiko Stuebnerd9a3bfb2011-10-14 15:08:56 +0900597 armdiv = divs;
598 nr_armdiv = nr_divs;
599 armdivmask = divmask;
600
Ben Dooksaf337f32010-04-28 18:03:57 +0900601 /* s3c2443 parents h and p clocks from prediv */
602 clk_h.parent = &clk_prediv;
603 clk_p.parent = &clk_prediv;
604
605 clk_usb_bus.parent = &clk_usb_bus_host.clk;
606 clk_epll.parent = &clk_epllref.clk;
607
608 s3c24xx_register_baseclocks(xtal);
609 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
610
611 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
612 s3c_register_clksrc(clksrcs[ptr], 1);
613
614 s3c_register_clksrc(clksrc_clks, ARRAY_SIZE(clksrc_clks));
615 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
616
617 /* See s3c2443/etc notes on disabling clocks at init time */
618 s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
619 s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
620
621 s3c2443_common_setup_clocks(get_mpll, get_fdiv);
622}