1 /* linux/arch/arm/mach-s5pv210/clock.c
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
6 * S5PV210 - Clock support
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/init.h>
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/list.h>
17 #include <linux/errno.h>
18 #include <linux/err.h>
19 #include <linux/clk.h>
20 #include <linux/sysdev.h>
25 #include <plat/cpu-freq.h>
26 #include <mach/regs-clock.h>
27 #include <plat/clock.h>
30 #include <plat/s5p-clock.h>
31 #include <plat/clock-clksrc.h>
32 #include <plat/s5pv210.h>
34 static struct clksrc_clk clk_mout_apll = {
39 .sources = &clk_src_apll,
40 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 0, .size = 1 },
43 static struct clksrc_clk clk_mout_epll = {
48 .sources = &clk_src_epll,
49 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 8, .size = 1 },
52 static struct clksrc_clk clk_mout_mpll = {
57 .sources = &clk_src_mpll,
58 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 4, .size = 1 },
61 static struct clk *clkset_armclk_list[] = {
62 [0] = &clk_mout_apll.clk,
63 [1] = &clk_mout_mpll.clk,
66 static struct clksrc_sources clkset_armclk = {
67 .sources = clkset_armclk_list,
68 .nr_sources = ARRAY_SIZE(clkset_armclk_list),
71 static struct clksrc_clk clk_armclk = {
76 .sources = &clkset_armclk,
77 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 16, .size = 1 },
78 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 0, .size = 3 },
81 static struct clksrc_clk clk_hclk_msys = {
85 .parent = &clk_armclk.clk,
87 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 8, .size = 3 },
90 static struct clksrc_clk clk_pclk_msys = {
94 .parent = &clk_hclk_msys.clk,
96 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 12, .size = 3 },
99 static struct clksrc_clk clk_sclk_a2m = {
103 .parent = &clk_mout_apll.clk,
105 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 4, .size = 3 },
108 static struct clk *clkset_hclk_sys_list[] = {
109 [0] = &clk_mout_mpll.clk,
110 [1] = &clk_sclk_a2m.clk,
113 static struct clksrc_sources clkset_hclk_sys = {
114 .sources = clkset_hclk_sys_list,
115 .nr_sources = ARRAY_SIZE(clkset_hclk_sys_list),
118 static struct clksrc_clk clk_hclk_dsys = {
123 .sources = &clkset_hclk_sys,
124 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 20, .size = 1 },
125 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 16, .size = 4 },
128 static struct clksrc_clk clk_pclk_dsys = {
132 .parent = &clk_hclk_dsys.clk,
134 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 20, .size = 3 },
137 static struct clksrc_clk clk_hclk_psys = {
142 .sources = &clkset_hclk_sys,
143 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 24, .size = 1 },
144 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 24, .size = 4 },
147 static struct clksrc_clk clk_pclk_psys = {
151 .parent = &clk_hclk_psys.clk,
153 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 28, .size = 3 },
156 static int s5pv210_clk_ip0_ctrl(struct clk *clk, int enable)
158 return s5p_gatectrl(S5P_CLKGATE_IP0, clk, enable);
161 static int s5pv210_clk_ip1_ctrl(struct clk *clk, int enable)
163 return s5p_gatectrl(S5P_CLKGATE_IP1, clk, enable);
166 static int s5pv210_clk_ip2_ctrl(struct clk *clk, int enable)
168 return s5p_gatectrl(S5P_CLKGATE_IP2, clk, enable);
171 static int s5pv210_clk_ip3_ctrl(struct clk *clk, int enable)
173 return s5p_gatectrl(S5P_CLKGATE_IP3, clk, enable);
176 static int s5pv210_clk_ip4_ctrl(struct clk *clk, int enable)
178 return s5p_gatectrl(S5P_CLKGATE_IP4, clk, enable);
181 static int s5pv210_clk_mask0_ctrl(struct clk *clk, int enable)
183 return s5p_gatectrl(S5P_CLK_SRC_MASK0, clk, enable);
186 static struct clk clk_sclk_hdmi27m = {
187 .name = "sclk_hdmi27m",
192 static struct clk clk_sclk_hdmiphy = {
193 .name = "sclk_hdmiphy",
197 static struct clk clk_sclk_usbphy0 = {
198 .name = "sclk_usbphy0",
202 static struct clk clk_sclk_usbphy1 = {
203 .name = "sclk_usbphy1",
207 static struct clk clk_pcmcdclk0 = {
212 static struct clk clk_pcmcdclk1 = {
217 static struct clk clk_pcmcdclk2 = {
222 static struct clk *clkset_vpllsrc_list[] = {
224 [1] = &clk_sclk_hdmi27m,
227 static struct clksrc_sources clkset_vpllsrc = {
228 .sources = clkset_vpllsrc_list,
229 .nr_sources = ARRAY_SIZE(clkset_vpllsrc_list),
232 static struct clksrc_clk clk_vpllsrc = {
236 .enable = s5pv210_clk_mask0_ctrl,
239 .sources = &clkset_vpllsrc,
240 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 28, .size = 1 },
243 static struct clk *clkset_sclk_vpll_list[] = {
244 [0] = &clk_vpllsrc.clk,
245 [1] = &clk_fout_vpll,
248 static struct clksrc_sources clkset_sclk_vpll = {
249 .sources = clkset_sclk_vpll_list,
250 .nr_sources = ARRAY_SIZE(clkset_sclk_vpll_list),
253 static struct clksrc_clk clk_sclk_vpll = {
258 .sources = &clkset_sclk_vpll,
259 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 12, .size = 1 },
262 static unsigned long s5pv210_clk_imem_get_rate(struct clk *clk)
264 return clk_get_rate(clk->parent) / 2;
267 static struct clk_ops clk_hclk_imem_ops = {
268 .get_rate = s5pv210_clk_imem_get_rate,
271 static struct clk init_clocks_disable[] = {
275 .parent = &clk_hclk_dsys.clk,
276 .enable = s5pv210_clk_ip0_ctrl,
281 .parent = &clk_hclk_psys.clk,
282 .enable = s5pv210_clk_ip1_ctrl,
287 .parent = &clk_hclk_psys.clk,
288 .enable = s5pv210_clk_ip1_ctrl,
293 .parent = &clk_hclk_dsys.clk,
294 .enable = s5pv210_clk_ip1_ctrl,
299 .parent = &clk_hclk_psys.clk,
300 .enable = s5pv210_clk_ip1_ctrl,
305 .parent = &clk_hclk_psys.clk,
306 .enable = s5pv210_clk_ip2_ctrl,
311 .parent = &clk_hclk_psys.clk,
312 .enable = s5pv210_clk_ip2_ctrl,
317 .parent = &clk_hclk_psys.clk,
318 .enable = s5pv210_clk_ip2_ctrl,
323 .parent = &clk_hclk_psys.clk,
324 .enable = s5pv210_clk_ip2_ctrl,
329 .parent = &clk_pclk_psys.clk,
330 .enable = s5pv210_clk_ip3_ctrl,
335 .parent = &clk_pclk_psys.clk,
336 .enable = s5pv210_clk_ip3_ctrl,
341 .parent = &clk_pclk_psys.clk,
342 .enable = s5pv210_clk_ip3_ctrl,
347 .parent = &clk_pclk_psys.clk,
348 .enable = s5pv210_clk_ip3_ctrl,
353 .parent = &clk_pclk_psys.clk,
354 .enable = s5pv210_clk_ip3_ctrl,
359 .parent = &clk_pclk_psys.clk,
360 .enable = s5pv210_clk_ip3_ctrl,
365 .parent = &clk_pclk_psys.clk,
366 .enable = s5pv210_clk_ip3_ctrl,
371 .parent = &clk_pclk_psys.clk,
372 .enable = s5pv210_clk_ip3_ctrl,
377 .parent = &clk_pclk_psys.clk,
378 .enable = s5pv210_clk_ip3_ctrl,
383 .parent = &clk_pclk_psys.clk,
384 .enable = s5pv210_clk_ip3_ctrl,
389 .parent = &clk_pclk_psys.clk,
390 .enable = s5pv210_clk_ip3_ctrl,
395 .parent = &clk_pclk_psys.clk,
396 .enable = s5pv210_clk_ip3_ctrl,
402 .enable = s5pv210_clk_ip3_ctrl,
408 .enable = s5pv210_clk_ip3_ctrl,
414 .enable = s5pv210_clk_ip3_ctrl,
419 static struct clk init_clocks[] = {
423 .parent = &clk_hclk_msys.clk,
425 .enable = s5pv210_clk_ip0_ctrl,
426 .ops = &clk_hclk_imem_ops,
430 .parent = &clk_pclk_psys.clk,
431 .enable = s5pv210_clk_ip3_ctrl,
436 .parent = &clk_pclk_psys.clk,
437 .enable = s5pv210_clk_ip3_ctrl,
442 .parent = &clk_pclk_psys.clk,
443 .enable = s5pv210_clk_ip3_ctrl,
448 .parent = &clk_pclk_psys.clk,
449 .enable = s5pv210_clk_ip3_ctrl,
454 static struct clk *clkset_uart_list[] = {
455 [6] = &clk_mout_mpll.clk,
456 [7] = &clk_mout_epll.clk,
459 static struct clksrc_sources clkset_uart = {
460 .sources = clkset_uart_list,
461 .nr_sources = ARRAY_SIZE(clkset_uart_list),
464 static struct clk *clkset_group1_list[] = {
465 [0] = &clk_sclk_a2m.clk,
466 [1] = &clk_mout_mpll.clk,
467 [2] = &clk_mout_epll.clk,
468 [3] = &clk_sclk_vpll.clk,
471 static struct clksrc_sources clkset_group1 = {
472 .sources = clkset_group1_list,
473 .nr_sources = ARRAY_SIZE(clkset_group1_list),
476 static struct clk *clkset_sclk_onenand_list[] = {
477 [0] = &clk_hclk_psys.clk,
478 [1] = &clk_hclk_dsys.clk,
481 static struct clksrc_sources clkset_sclk_onenand = {
482 .sources = clkset_sclk_onenand_list,
483 .nr_sources = ARRAY_SIZE(clkset_sclk_onenand_list),
486 static struct clk *clkset_sclk_dac_list[] = {
487 [0] = &clk_sclk_vpll.clk,
488 [1] = &clk_sclk_hdmiphy,
491 static struct clksrc_sources clkset_sclk_dac = {
492 .sources = clkset_sclk_dac_list,
493 .nr_sources = ARRAY_SIZE(clkset_sclk_dac_list),
496 static struct clksrc_clk clk_sclk_dac = {
500 .ctrlbit = (1 << 10),
501 .enable = s5pv210_clk_ip1_ctrl,
503 .sources = &clkset_sclk_dac,
504 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 8, .size = 1 },
507 static struct clksrc_clk clk_sclk_pixel = {
509 .name = "sclk_pixel",
511 .parent = &clk_sclk_vpll.clk,
513 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 0, .size = 4},
516 static struct clk *clkset_sclk_hdmi_list[] = {
517 [0] = &clk_sclk_pixel.clk,
518 [1] = &clk_sclk_hdmiphy,
521 static struct clksrc_sources clkset_sclk_hdmi = {
522 .sources = clkset_sclk_hdmi_list,
523 .nr_sources = ARRAY_SIZE(clkset_sclk_hdmi_list),
526 static struct clksrc_clk clk_sclk_hdmi = {
530 .enable = s5pv210_clk_ip1_ctrl,
531 .ctrlbit = (1 << 11),
533 .sources = &clkset_sclk_hdmi,
534 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 0, .size = 1 },
537 static struct clk *clkset_sclk_mixer_list[] = {
538 [0] = &clk_sclk_dac.clk,
539 [1] = &clk_sclk_hdmi.clk,
542 static struct clksrc_sources clkset_sclk_mixer = {
543 .sources = clkset_sclk_mixer_list,
544 .nr_sources = ARRAY_SIZE(clkset_sclk_mixer_list),
547 static struct clk *clkset_sclk_audio0_list[] = {
548 [0] = &clk_ext_xtal_mux,
549 [1] = &clk_pcmcdclk0,
550 [2] = &clk_sclk_hdmi27m,
551 [3] = &clk_sclk_usbphy0,
552 [4] = &clk_sclk_usbphy1,
553 [5] = &clk_sclk_hdmiphy,
554 [6] = &clk_mout_mpll.clk,
555 [7] = &clk_mout_epll.clk,
556 [8] = &clk_sclk_vpll.clk,
559 static struct clksrc_sources clkset_sclk_audio0 = {
560 .sources = clkset_sclk_audio0_list,
561 .nr_sources = ARRAY_SIZE(clkset_sclk_audio0_list),
564 static struct clksrc_clk clk_sclk_audio0 = {
566 .name = "sclk_audio",
568 .enable = s5pv210_clk_ip3_ctrl,
571 .sources = &clkset_sclk_audio0,
572 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 0, .size = 4 },
573 .reg_div = { .reg = S5P_CLK_DIV6, .shift = 0, .size = 4 },
576 static struct clk *clkset_sclk_audio1_list[] = {
577 [0] = &clk_ext_xtal_mux,
578 [1] = &clk_pcmcdclk1,
579 [2] = &clk_sclk_hdmi27m,
580 [3] = &clk_sclk_usbphy0,
581 [4] = &clk_sclk_usbphy1,
582 [5] = &clk_sclk_hdmiphy,
583 [6] = &clk_mout_mpll.clk,
584 [7] = &clk_mout_epll.clk,
585 [8] = &clk_sclk_vpll.clk,
588 static struct clksrc_sources clkset_sclk_audio1 = {
589 .sources = clkset_sclk_audio1_list,
590 .nr_sources = ARRAY_SIZE(clkset_sclk_audio1_list),
593 static struct clksrc_clk clk_sclk_audio1 = {
595 .name = "sclk_audio",
597 .enable = s5pv210_clk_ip3_ctrl,
600 .sources = &clkset_sclk_audio1,
601 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 4, .size = 4 },
602 .reg_div = { .reg = S5P_CLK_DIV6, .shift = 4, .size = 4 },
605 static struct clk *clkset_sclk_audio2_list[] = {
606 [0] = &clk_ext_xtal_mux,
607 [1] = &clk_pcmcdclk0,
608 [2] = &clk_sclk_hdmi27m,
609 [3] = &clk_sclk_usbphy0,
610 [4] = &clk_sclk_usbphy1,
611 [5] = &clk_sclk_hdmiphy,
612 [6] = &clk_mout_mpll.clk,
613 [7] = &clk_mout_epll.clk,
614 [8] = &clk_sclk_vpll.clk,
617 static struct clksrc_sources clkset_sclk_audio2 = {
618 .sources = clkset_sclk_audio2_list,
619 .nr_sources = ARRAY_SIZE(clkset_sclk_audio2_list),
622 static struct clksrc_clk clk_sclk_audio2 = {
624 .name = "sclk_audio",
626 .enable = s5pv210_clk_ip3_ctrl,
629 .sources = &clkset_sclk_audio2,
630 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 8, .size = 4 },
631 .reg_div = { .reg = S5P_CLK_DIV6, .shift = 8, .size = 4 },
634 static struct clk *clkset_sclk_spdif_list[] = {
635 [0] = &clk_sclk_audio0.clk,
636 [1] = &clk_sclk_audio1.clk,
637 [2] = &clk_sclk_audio2.clk,
640 static struct clksrc_sources clkset_sclk_spdif = {
641 .sources = clkset_sclk_spdif_list,
642 .nr_sources = ARRAY_SIZE(clkset_sclk_spdif_list),
645 static struct clk *clkset_group2_list[] = {
646 [0] = &clk_ext_xtal_mux,
648 [2] = &clk_sclk_hdmi27m,
649 [3] = &clk_sclk_usbphy0,
650 [4] = &clk_sclk_usbphy1,
651 [5] = &clk_sclk_hdmiphy,
652 [6] = &clk_mout_mpll.clk,
653 [7] = &clk_mout_epll.clk,
654 [8] = &clk_sclk_vpll.clk,
657 static struct clksrc_sources clkset_group2 = {
658 .sources = clkset_group2_list,
659 .nr_sources = ARRAY_SIZE(clkset_group2_list),
662 static struct clksrc_clk clksrcs[] = {
668 .sources = &clkset_group1,
669 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 24, .size = 2 },
670 .reg_div = { .reg = S5P_CLK_DIV6, .shift = 28, .size = 4 },
673 .name = "sclk_onenand",
676 .sources = &clkset_sclk_onenand,
677 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 28, .size = 1 },
678 .reg_div = { .reg = S5P_CLK_DIV6, .shift = 12, .size = 3 },
684 .enable = s5pv210_clk_ip3_ctrl,
686 .sources = &clkset_uart,
687 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 16, .size = 4 },
688 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 16, .size = 4 },
693 .enable = s5pv210_clk_ip3_ctrl,
694 .ctrlbit = (1 << 18),
696 .sources = &clkset_uart,
697 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 20, .size = 4 },
698 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 20, .size = 4 },
703 .enable = s5pv210_clk_ip3_ctrl,
704 .ctrlbit = (1 << 19),
706 .sources = &clkset_uart,
707 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 24, .size = 4 },
708 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 24, .size = 4 },
713 .enable = s5pv210_clk_ip3_ctrl,
714 .ctrlbit = (1 << 20),
716 .sources = &clkset_uart,
717 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 28, .size = 4 },
718 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 28, .size = 4 },
721 .name = "sclk_mixer",
723 .enable = s5pv210_clk_ip1_ctrl,
726 .sources = &clkset_sclk_mixer,
727 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 4, .size = 1 },
730 .name = "sclk_spdif",
732 .enable = s5pv210_clk_mask0_ctrl,
733 .ctrlbit = (1 << 27),
735 .sources = &clkset_sclk_spdif,
736 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 12, .size = 2 },
741 .enable = s5pv210_clk_ip0_ctrl,
742 .ctrlbit = (1 << 24),
744 .sources = &clkset_group2,
745 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 12, .size = 4 },
746 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 12, .size = 4 },
751 .enable = s5pv210_clk_ip0_ctrl,
752 .ctrlbit = (1 << 25),
754 .sources = &clkset_group2,
755 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 16, .size = 4 },
756 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 16, .size = 4 },
761 .enable = s5pv210_clk_ip0_ctrl,
762 .ctrlbit = (1 << 26),
764 .sources = &clkset_group2,
765 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 20, .size = 4 },
766 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 20, .size = 4 },
772 .sources = &clkset_group2,
773 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 12, .size = 4 },
774 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 12, .size = 4 },
780 .sources = &clkset_group2,
781 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 16, .size = 4 },
782 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 16, .size = 4 },
787 .enable = s5pv210_clk_ip1_ctrl,
790 .sources = &clkset_group2,
791 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 20, .size = 4 },
792 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 20, .size = 4 },
797 .enable = s5pv210_clk_ip2_ctrl,
798 .ctrlbit = (1 << 16),
800 .sources = &clkset_group2,
801 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 0, .size = 4 },
802 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 0, .size = 4 },
807 .enable = s5pv210_clk_ip2_ctrl,
808 .ctrlbit = (1 << 17),
810 .sources = &clkset_group2,
811 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 4, .size = 4 },
812 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 4, .size = 4 },
817 .enable = s5pv210_clk_ip2_ctrl,
818 .ctrlbit = (1 << 18),
820 .sources = &clkset_group2,
821 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 8, .size = 4 },
822 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 8, .size = 4 },
827 .enable = s5pv210_clk_ip2_ctrl,
828 .ctrlbit = (1 << 19),
830 .sources = &clkset_group2,
831 .reg_src = { .reg = S5P_CLK_SRC4, .shift = 12, .size = 4 },
832 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 12, .size = 4 },
837 .enable = s5pv210_clk_ip0_ctrl,
838 .ctrlbit = (1 << 16),
840 .sources = &clkset_group1,
841 .reg_src = { .reg = S5P_CLK_SRC2, .shift = 4, .size = 2 },
842 .reg_div = { .reg = S5P_CLK_DIV2, .shift = 4, .size = 4 },
847 .enable = s5pv210_clk_ip0_ctrl,
848 .ctrlbit = (1 << 12),
850 .sources = &clkset_group1,
851 .reg_src = { .reg = S5P_CLK_SRC2, .shift = 8, .size = 2 },
852 .reg_div = { .reg = S5P_CLK_DIV2, .shift = 8, .size = 4 },
857 .enable = s5pv210_clk_ip0_ctrl,
860 .sources = &clkset_group1,
861 .reg_src = { .reg = S5P_CLK_SRC2, .shift = 0, .size = 2 },
862 .reg_div = { .reg = S5P_CLK_DIV2, .shift = 0, .size = 4 },
867 .enable = s5pv210_clk_ip0_ctrl,
868 .ctrlbit = (1 << 31),
870 .sources = &clkset_group2,
871 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 24, .size = 4 },
872 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 28, .size = 4 },
877 .enable = s5pv210_clk_ip3_ctrl,
878 .ctrlbit = (1 << 12),
880 .sources = &clkset_group2,
881 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 0, .size = 4 },
882 .reg_div = { .reg = S5P_CLK_DIV5, .shift = 0, .size = 4 },
887 .enable = s5pv210_clk_ip3_ctrl,
888 .ctrlbit = (1 << 13),
890 .sources = &clkset_group2,
891 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 4, .size = 4 },
892 .reg_div = { .reg = S5P_CLK_DIV5, .shift = 4, .size = 4 },
897 .enable = &s5pv210_clk_ip4_ctrl,
900 .sources = &clkset_group2,
901 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 20, .size = 4 },
902 .reg_div = { .reg = S5P_CLK_DIV6, .shift = 24, .size = 4 },
907 .enable = s5pv210_clk_ip3_ctrl,
908 .ctrlbit = (1 << 23),
910 .sources = &clkset_group2,
911 .reg_src = { .reg = S5P_CLK_SRC5, .shift = 12, .size = 4 },
912 .reg_div = { .reg = S5P_CLK_DIV5, .shift = 12, .size = 4 },
916 /* Clock initialisation code */
917 static struct clksrc_clk *sysclks[] = {
936 void __init_or_cpufreq s5pv210_setup_clocks(void)
938 struct clk *xtal_clk;
940 unsigned long vpllsrc;
941 unsigned long armclk;
942 unsigned long hclk_msys;
943 unsigned long hclk_dsys;
944 unsigned long hclk_psys;
945 unsigned long pclk_msys;
946 unsigned long pclk_dsys;
947 unsigned long pclk_psys;
953 u32 clkdiv0, clkdiv1;
955 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
957 clkdiv0 = __raw_readl(S5P_CLK_DIV0);
958 clkdiv1 = __raw_readl(S5P_CLK_DIV1);
960 printk(KERN_DEBUG "%s: clkdiv0 = %08x, clkdiv1 = %08x\n",
961 __func__, clkdiv0, clkdiv1);
963 xtal_clk = clk_get(NULL, "xtal");
964 BUG_ON(IS_ERR(xtal_clk));
966 xtal = clk_get_rate(xtal_clk);
969 printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
971 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508);
972 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502);
973 epll = s5p_get_pll45xx(xtal, __raw_readl(S5P_EPLL_CON), pll_4500);
974 vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
975 vpll = s5p_get_pll45xx(vpllsrc, __raw_readl(S5P_VPLL_CON), pll_4502);
977 clk_fout_apll.rate = apll;
978 clk_fout_mpll.rate = mpll;
979 clk_fout_epll.rate = epll;
980 clk_fout_vpll.rate = vpll;
982 printk(KERN_INFO "S5PV210: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
983 apll, mpll, epll, vpll);
985 armclk = clk_get_rate(&clk_armclk.clk);
986 hclk_msys = clk_get_rate(&clk_hclk_msys.clk);
987 hclk_dsys = clk_get_rate(&clk_hclk_dsys.clk);
988 hclk_psys = clk_get_rate(&clk_hclk_psys.clk);
989 pclk_msys = clk_get_rate(&clk_pclk_msys.clk);
990 pclk_dsys = clk_get_rate(&clk_pclk_dsys.clk);
991 pclk_psys = clk_get_rate(&clk_pclk_psys.clk);
993 printk(KERN_INFO "S5PV210: ARMCLK=%ld, HCLKM=%ld, HCLKD=%ld\n"
994 "HCLKP=%ld, PCLKM=%ld, PCLKD=%ld, PCLKP=%ld\n",
995 armclk, hclk_msys, hclk_dsys, hclk_psys,
996 pclk_msys, pclk_dsys, pclk_psys);
999 clk_h.rate = hclk_psys;
1000 clk_p.rate = pclk_psys;
1002 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
1003 s3c_set_clksrc(&clksrcs[ptr], true);
1006 static struct clk *clks[] __initdata = {
1016 void __init s5pv210_register_clocks(void)
1022 ret = s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
1024 printk(KERN_ERR "Failed to register %u clocks\n", ret);
1026 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
1027 s3c_register_clksrc(sysclks[ptr], 1);
1029 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
1030 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
1032 clkp = init_clocks_disable;
1033 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) {
1034 ret = s3c24xx_register_clock(clkp);
1036 printk(KERN_ERR "Failed to register clock %s (%d)\n",
1039 (clkp->enable)(clkp, 0);