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 unsigned long xtal
;
36 static struct clksrc_clk clk_mout_apll
= {
41 .sources
= &clk_src_apll
,
42 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 0, .size
= 1 },
45 static struct clksrc_clk clk_mout_epll
= {
50 .sources
= &clk_src_epll
,
51 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 8, .size
= 1 },
54 static struct clksrc_clk clk_mout_mpll
= {
59 .sources
= &clk_src_mpll
,
60 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 4, .size
= 1 },
63 static struct clk
*clkset_armclk_list
[] = {
64 [0] = &clk_mout_apll
.clk
,
65 [1] = &clk_mout_mpll
.clk
,
68 static struct clksrc_sources clkset_armclk
= {
69 .sources
= clkset_armclk_list
,
70 .nr_sources
= ARRAY_SIZE(clkset_armclk_list
),
73 static struct clksrc_clk clk_armclk
= {
78 .sources
= &clkset_armclk
,
79 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 16, .size
= 1 },
80 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 0, .size
= 3 },
83 static struct clksrc_clk clk_hclk_msys
= {
87 .parent
= &clk_armclk
.clk
,
89 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 8, .size
= 3 },
92 static struct clksrc_clk clk_pclk_msys
= {
96 .parent
= &clk_hclk_msys
.clk
,
98 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 12, .size
= 3 },
101 static struct clksrc_clk clk_sclk_a2m
= {
105 .parent
= &clk_mout_apll
.clk
,
107 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 4, .size
= 3 },
110 static struct clk
*clkset_hclk_sys_list
[] = {
111 [0] = &clk_mout_mpll
.clk
,
112 [1] = &clk_sclk_a2m
.clk
,
115 static struct clksrc_sources clkset_hclk_sys
= {
116 .sources
= clkset_hclk_sys_list
,
117 .nr_sources
= ARRAY_SIZE(clkset_hclk_sys_list
),
120 static struct clksrc_clk clk_hclk_dsys
= {
125 .sources
= &clkset_hclk_sys
,
126 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 20, .size
= 1 },
127 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 16, .size
= 4 },
130 static struct clksrc_clk clk_pclk_dsys
= {
134 .parent
= &clk_hclk_dsys
.clk
,
136 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 20, .size
= 3 },
139 static struct clksrc_clk clk_hclk_psys
= {
144 .sources
= &clkset_hclk_sys
,
145 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 24, .size
= 1 },
146 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 24, .size
= 4 },
149 static struct clksrc_clk clk_pclk_psys
= {
153 .parent
= &clk_hclk_psys
.clk
,
155 .reg_div
= { .reg
= S5P_CLK_DIV0
, .shift
= 28, .size
= 3 },
158 static int s5pv210_clk_ip0_ctrl(struct clk
*clk
, int enable
)
160 return s5p_gatectrl(S5P_CLKGATE_IP0
, clk
, enable
);
163 static int s5pv210_clk_ip1_ctrl(struct clk
*clk
, int enable
)
165 return s5p_gatectrl(S5P_CLKGATE_IP1
, clk
, enable
);
168 static int s5pv210_clk_ip2_ctrl(struct clk
*clk
, int enable
)
170 return s5p_gatectrl(S5P_CLKGATE_IP2
, clk
, enable
);
173 static int s5pv210_clk_ip3_ctrl(struct clk
*clk
, int enable
)
175 return s5p_gatectrl(S5P_CLKGATE_IP3
, clk
, enable
);
178 static int s5pv210_clk_mask0_ctrl(struct clk
*clk
, int enable
)
180 return s5p_gatectrl(S5P_CLK_SRC_MASK0
, clk
, enable
);
183 static int s5pv210_clk_mask1_ctrl(struct clk
*clk
, int enable
)
185 return s5p_gatectrl(S5P_CLK_SRC_MASK1
, clk
, enable
);
188 static struct clk clk_sclk_hdmi27m
= {
189 .name
= "sclk_hdmi27m",
194 static struct clk clk_sclk_hdmiphy
= {
195 .name
= "sclk_hdmiphy",
199 static struct clk clk_sclk_usbphy0
= {
200 .name
= "sclk_usbphy0",
204 static struct clk clk_sclk_usbphy1
= {
205 .name
= "sclk_usbphy1",
209 static struct clk clk_pcmcdclk0
= {
214 static struct clk clk_pcmcdclk1
= {
219 static struct clk clk_pcmcdclk2
= {
224 static struct clk
*clkset_vpllsrc_list
[] = {
226 [1] = &clk_sclk_hdmi27m
,
229 static struct clksrc_sources clkset_vpllsrc
= {
230 .sources
= clkset_vpllsrc_list
,
231 .nr_sources
= ARRAY_SIZE(clkset_vpllsrc_list
),
234 static struct clksrc_clk clk_vpllsrc
= {
238 .enable
= s5pv210_clk_mask0_ctrl
,
241 .sources
= &clkset_vpllsrc
,
242 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 28, .size
= 1 },
245 static struct clk
*clkset_sclk_vpll_list
[] = {
246 [0] = &clk_vpllsrc
.clk
,
247 [1] = &clk_fout_vpll
,
250 static struct clksrc_sources clkset_sclk_vpll
= {
251 .sources
= clkset_sclk_vpll_list
,
252 .nr_sources
= ARRAY_SIZE(clkset_sclk_vpll_list
),
255 static struct clksrc_clk clk_sclk_vpll
= {
260 .sources
= &clkset_sclk_vpll
,
261 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 12, .size
= 1 },
264 static struct clk
*clkset_moutdmc0src_list
[] = {
265 [0] = &clk_sclk_a2m
.clk
,
266 [1] = &clk_mout_mpll
.clk
,
271 static struct clksrc_sources clkset_moutdmc0src
= {
272 .sources
= clkset_moutdmc0src_list
,
273 .nr_sources
= ARRAY_SIZE(clkset_moutdmc0src_list
),
276 static struct clksrc_clk clk_mout_dmc0
= {
281 .sources
= &clkset_moutdmc0src
,
282 .reg_src
= { .reg
= S5P_CLK_SRC6
, .shift
= 24, .size
= 2 },
285 static struct clksrc_clk clk_sclk_dmc0
= {
289 .parent
= &clk_mout_dmc0
.clk
,
291 .reg_div
= { .reg
= S5P_CLK_DIV6
, .shift
= 28, .size
= 4 },
294 static unsigned long s5pv210_clk_imem_get_rate(struct clk
*clk
)
296 return clk_get_rate(clk
->parent
) / 2;
299 static struct clk_ops clk_hclk_imem_ops
= {
300 .get_rate
= s5pv210_clk_imem_get_rate
,
303 static unsigned long s5pv210_clk_fout_apll_get_rate(struct clk
*clk
)
305 return s5p_get_pll45xx(xtal
, __raw_readl(S5P_APLL_CON
), pll_4508
);
308 static struct clk_ops clk_fout_apll_ops
= {
309 .get_rate
= s5pv210_clk_fout_apll_get_rate
,
312 static struct clk init_clocks_off
[] = {
316 .parent
= &clk_hclk_psys
.clk
,
317 .enable
= s5pv210_clk_ip0_ctrl
,
322 .parent
= &clk_hclk_psys
.clk
,
323 .enable
= s5pv210_clk_ip0_ctrl
,
328 .parent
= &clk_hclk_dsys
.clk
,
329 .enable
= s5pv210_clk_ip0_ctrl
,
334 .parent
= &clk_hclk_dsys
.clk
,
335 .enable
= s5pv210_clk_ip0_ctrl
,
336 .ctrlbit
= (1 << 24),
340 .parent
= &clk_hclk_dsys
.clk
,
341 .enable
= s5pv210_clk_ip0_ctrl
,
342 .ctrlbit
= (1 << 25),
346 .parent
= &clk_hclk_dsys
.clk
,
347 .enable
= s5pv210_clk_ip0_ctrl
,
348 .ctrlbit
= (1 << 26),
352 .parent
= &clk_hclk_psys
.clk
,
353 .enable
= s5pv210_clk_ip1_ctrl
,
358 .parent
= &clk_hclk_psys
.clk
,
359 .enable
= s5pv210_clk_ip1_ctrl
,
364 .parent
= &clk_hclk_dsys
.clk
,
365 .enable
= s5pv210_clk_ip1_ctrl
,
370 .parent
= &clk_hclk_psys
.clk
,
371 .enable
= s5pv210_clk_ip1_ctrl
,
376 .parent
= &clk_hclk_psys
.clk
,
377 .enable
= s5pv210_clk_ip2_ctrl
,
382 .parent
= &clk_hclk_psys
.clk
,
383 .enable
= s5pv210_clk_ip2_ctrl
,
388 .parent
= &clk_hclk_psys
.clk
,
389 .enable
= s5pv210_clk_ip2_ctrl
,
394 .parent
= &clk_hclk_psys
.clk
,
395 .enable
= s5pv210_clk_ip2_ctrl
,
400 .parent
= &clk_pclk_psys
.clk
,
401 .enable
= s5pv210_clk_ip3_ctrl
,
406 .parent
= &clk_pclk_psys
.clk
,
407 .enable
= s5pv210_clk_ip3_ctrl
,
412 .parent
= &clk_pclk_psys
.clk
,
413 .enable
= s5pv210_clk_ip3_ctrl
,
418 .parent
= &clk_pclk_psys
.clk
,
419 .enable
= s5pv210_clk_ip3_ctrl
,
424 .parent
= &clk_pclk_psys
.clk
,
425 .enable
= s5pv210_clk_ip3_ctrl
,
426 .ctrlbit
= (1 << 10),
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 .parent
= &clk_pclk_psys
.clk
,
455 .enable
= s5pv210_clk_ip3_ctrl
,
460 .parent
= &clk_pclk_psys
.clk
,
461 .enable
= s5pv210_clk_ip3_ctrl
,
466 .parent
= &clk_pclk_psys
.clk
,
467 .enable
= s5pv210_clk_ip3_ctrl
,
473 .enable
= s5pv210_clk_ip3_ctrl
,
479 .enable
= s5pv210_clk_ip3_ctrl
,
485 .enable
= s5pv210_clk_ip3_ctrl
,
491 .enable
= s5pv210_clk_ip3_ctrl
,
496 static struct clk init_clocks
[] = {
500 .parent
= &clk_hclk_msys
.clk
,
502 .enable
= s5pv210_clk_ip0_ctrl
,
503 .ops
= &clk_hclk_imem_ops
,
507 .parent
= &clk_pclk_psys
.clk
,
508 .enable
= s5pv210_clk_ip3_ctrl
,
509 .ctrlbit
= (1 << 17),
513 .parent
= &clk_pclk_psys
.clk
,
514 .enable
= s5pv210_clk_ip3_ctrl
,
515 .ctrlbit
= (1 << 18),
519 .parent
= &clk_pclk_psys
.clk
,
520 .enable
= s5pv210_clk_ip3_ctrl
,
521 .ctrlbit
= (1 << 19),
525 .parent
= &clk_pclk_psys
.clk
,
526 .enable
= s5pv210_clk_ip3_ctrl
,
527 .ctrlbit
= (1 << 20),
531 .parent
= &clk_hclk_psys
.clk
,
532 .enable
= s5pv210_clk_ip1_ctrl
,
533 .ctrlbit
= (1 << 26),
537 static struct clk
*clkset_uart_list
[] = {
538 [6] = &clk_mout_mpll
.clk
,
539 [7] = &clk_mout_epll
.clk
,
542 static struct clksrc_sources clkset_uart
= {
543 .sources
= clkset_uart_list
,
544 .nr_sources
= ARRAY_SIZE(clkset_uart_list
),
547 static struct clk
*clkset_group1_list
[] = {
548 [0] = &clk_sclk_a2m
.clk
,
549 [1] = &clk_mout_mpll
.clk
,
550 [2] = &clk_mout_epll
.clk
,
551 [3] = &clk_sclk_vpll
.clk
,
554 static struct clksrc_sources clkset_group1
= {
555 .sources
= clkset_group1_list
,
556 .nr_sources
= ARRAY_SIZE(clkset_group1_list
),
559 static struct clk
*clkset_sclk_onenand_list
[] = {
560 [0] = &clk_hclk_psys
.clk
,
561 [1] = &clk_hclk_dsys
.clk
,
564 static struct clksrc_sources clkset_sclk_onenand
= {
565 .sources
= clkset_sclk_onenand_list
,
566 .nr_sources
= ARRAY_SIZE(clkset_sclk_onenand_list
),
569 static struct clk
*clkset_sclk_dac_list
[] = {
570 [0] = &clk_sclk_vpll
.clk
,
571 [1] = &clk_sclk_hdmiphy
,
574 static struct clksrc_sources clkset_sclk_dac
= {
575 .sources
= clkset_sclk_dac_list
,
576 .nr_sources
= ARRAY_SIZE(clkset_sclk_dac_list
),
579 static struct clksrc_clk clk_sclk_dac
= {
583 .enable
= s5pv210_clk_mask0_ctrl
,
586 .sources
= &clkset_sclk_dac
,
587 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 8, .size
= 1 },
590 static struct clksrc_clk clk_sclk_pixel
= {
592 .name
= "sclk_pixel",
594 .parent
= &clk_sclk_vpll
.clk
,
596 .reg_div
= { .reg
= S5P_CLK_DIV1
, .shift
= 0, .size
= 4},
599 static struct clk
*clkset_sclk_hdmi_list
[] = {
600 [0] = &clk_sclk_pixel
.clk
,
601 [1] = &clk_sclk_hdmiphy
,
604 static struct clksrc_sources clkset_sclk_hdmi
= {
605 .sources
= clkset_sclk_hdmi_list
,
606 .nr_sources
= ARRAY_SIZE(clkset_sclk_hdmi_list
),
609 static struct clksrc_clk clk_sclk_hdmi
= {
613 .enable
= s5pv210_clk_mask0_ctrl
,
616 .sources
= &clkset_sclk_hdmi
,
617 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 0, .size
= 1 },
620 static struct clk
*clkset_sclk_mixer_list
[] = {
621 [0] = &clk_sclk_dac
.clk
,
622 [1] = &clk_sclk_hdmi
.clk
,
625 static struct clksrc_sources clkset_sclk_mixer
= {
626 .sources
= clkset_sclk_mixer_list
,
627 .nr_sources
= ARRAY_SIZE(clkset_sclk_mixer_list
),
630 static struct clk
*clkset_sclk_audio0_list
[] = {
631 [0] = &clk_ext_xtal_mux
,
632 [1] = &clk_pcmcdclk0
,
633 [2] = &clk_sclk_hdmi27m
,
634 [3] = &clk_sclk_usbphy0
,
635 [4] = &clk_sclk_usbphy1
,
636 [5] = &clk_sclk_hdmiphy
,
637 [6] = &clk_mout_mpll
.clk
,
638 [7] = &clk_mout_epll
.clk
,
639 [8] = &clk_sclk_vpll
.clk
,
642 static struct clksrc_sources clkset_sclk_audio0
= {
643 .sources
= clkset_sclk_audio0_list
,
644 .nr_sources
= ARRAY_SIZE(clkset_sclk_audio0_list
),
647 static struct clksrc_clk clk_sclk_audio0
= {
649 .name
= "sclk_audio",
651 .enable
= s5pv210_clk_mask0_ctrl
,
652 .ctrlbit
= (1 << 24),
654 .sources
= &clkset_sclk_audio0
,
655 .reg_src
= { .reg
= S5P_CLK_SRC6
, .shift
= 0, .size
= 4 },
656 .reg_div
= { .reg
= S5P_CLK_DIV6
, .shift
= 0, .size
= 4 },
659 static struct clk
*clkset_sclk_audio1_list
[] = {
660 [0] = &clk_ext_xtal_mux
,
661 [1] = &clk_pcmcdclk1
,
662 [2] = &clk_sclk_hdmi27m
,
663 [3] = &clk_sclk_usbphy0
,
664 [4] = &clk_sclk_usbphy1
,
665 [5] = &clk_sclk_hdmiphy
,
666 [6] = &clk_mout_mpll
.clk
,
667 [7] = &clk_mout_epll
.clk
,
668 [8] = &clk_sclk_vpll
.clk
,
671 static struct clksrc_sources clkset_sclk_audio1
= {
672 .sources
= clkset_sclk_audio1_list
,
673 .nr_sources
= ARRAY_SIZE(clkset_sclk_audio1_list
),
676 static struct clksrc_clk clk_sclk_audio1
= {
678 .name
= "sclk_audio",
680 .enable
= s5pv210_clk_mask0_ctrl
,
681 .ctrlbit
= (1 << 25),
683 .sources
= &clkset_sclk_audio1
,
684 .reg_src
= { .reg
= S5P_CLK_SRC6
, .shift
= 4, .size
= 4 },
685 .reg_div
= { .reg
= S5P_CLK_DIV6
, .shift
= 4, .size
= 4 },
688 static struct clk
*clkset_sclk_audio2_list
[] = {
689 [0] = &clk_ext_xtal_mux
,
690 [1] = &clk_pcmcdclk0
,
691 [2] = &clk_sclk_hdmi27m
,
692 [3] = &clk_sclk_usbphy0
,
693 [4] = &clk_sclk_usbphy1
,
694 [5] = &clk_sclk_hdmiphy
,
695 [6] = &clk_mout_mpll
.clk
,
696 [7] = &clk_mout_epll
.clk
,
697 [8] = &clk_sclk_vpll
.clk
,
700 static struct clksrc_sources clkset_sclk_audio2
= {
701 .sources
= clkset_sclk_audio2_list
,
702 .nr_sources
= ARRAY_SIZE(clkset_sclk_audio2_list
),
705 static struct clksrc_clk clk_sclk_audio2
= {
707 .name
= "sclk_audio",
709 .enable
= s5pv210_clk_mask0_ctrl
,
710 .ctrlbit
= (1 << 26),
712 .sources
= &clkset_sclk_audio2
,
713 .reg_src
= { .reg
= S5P_CLK_SRC6
, .shift
= 8, .size
= 4 },
714 .reg_div
= { .reg
= S5P_CLK_DIV6
, .shift
= 8, .size
= 4 },
717 static struct clk
*clkset_sclk_spdif_list
[] = {
718 [0] = &clk_sclk_audio0
.clk
,
719 [1] = &clk_sclk_audio1
.clk
,
720 [2] = &clk_sclk_audio2
.clk
,
723 static struct clksrc_sources clkset_sclk_spdif
= {
724 .sources
= clkset_sclk_spdif_list
,
725 .nr_sources
= ARRAY_SIZE(clkset_sclk_spdif_list
),
728 static int s5pv210_spdif_set_rate(struct clk
*clk
, unsigned long rate
)
733 pclk
= clk_get_parent(clk
);
737 ret
= pclk
->ops
->set_rate(pclk
, rate
);
743 static unsigned long s5pv210_spdif_get_rate(struct clk
*clk
)
748 pclk
= clk_get_parent(clk
);
752 rate
= pclk
->ops
->get_rate(clk
);
758 static struct clk_ops s5pv210_sclk_spdif_ops
= {
759 .set_rate
= s5pv210_spdif_set_rate
,
760 .get_rate
= s5pv210_spdif_get_rate
,
763 static struct clksrc_clk clk_sclk_spdif
= {
765 .name
= "sclk_spdif",
767 .enable
= s5pv210_clk_mask0_ctrl
,
768 .ctrlbit
= (1 << 27),
769 .ops
= &s5pv210_sclk_spdif_ops
,
771 .sources
= &clkset_sclk_spdif
,
772 .reg_src
= { .reg
= S5P_CLK_SRC6
, .shift
= 12, .size
= 2 },
775 static struct clk
*clkset_group2_list
[] = {
776 [0] = &clk_ext_xtal_mux
,
778 [2] = &clk_sclk_hdmi27m
,
779 [3] = &clk_sclk_usbphy0
,
780 [4] = &clk_sclk_usbphy1
,
781 [5] = &clk_sclk_hdmiphy
,
782 [6] = &clk_mout_mpll
.clk
,
783 [7] = &clk_mout_epll
.clk
,
784 [8] = &clk_sclk_vpll
.clk
,
787 static struct clksrc_sources clkset_group2
= {
788 .sources
= clkset_group2_list
,
789 .nr_sources
= ARRAY_SIZE(clkset_group2_list
),
792 static struct clksrc_clk clksrcs
[] = {
798 .sources
= &clkset_group1
,
799 .reg_src
= { .reg
= S5P_CLK_SRC6
, .shift
= 24, .size
= 2 },
800 .reg_div
= { .reg
= S5P_CLK_DIV6
, .shift
= 28, .size
= 4 },
803 .name
= "sclk_onenand",
806 .sources
= &clkset_sclk_onenand
,
807 .reg_src
= { .reg
= S5P_CLK_SRC0
, .shift
= 28, .size
= 1 },
808 .reg_div
= { .reg
= S5P_CLK_DIV6
, .shift
= 12, .size
= 3 },
813 .enable
= s5pv210_clk_mask0_ctrl
,
814 .ctrlbit
= (1 << 12),
816 .sources
= &clkset_uart
,
817 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 16, .size
= 4 },
818 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 16, .size
= 4 },
823 .enable
= s5pv210_clk_mask0_ctrl
,
824 .ctrlbit
= (1 << 13),
826 .sources
= &clkset_uart
,
827 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 20, .size
= 4 },
828 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 20, .size
= 4 },
833 .enable
= s5pv210_clk_mask0_ctrl
,
834 .ctrlbit
= (1 << 14),
836 .sources
= &clkset_uart
,
837 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 24, .size
= 4 },
838 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 24, .size
= 4 },
843 .enable
= s5pv210_clk_mask0_ctrl
,
844 .ctrlbit
= (1 << 15),
846 .sources
= &clkset_uart
,
847 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 28, .size
= 4 },
848 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 28, .size
= 4 },
851 .name
= "sclk_mixer",
853 .enable
= s5pv210_clk_mask0_ctrl
,
856 .sources
= &clkset_sclk_mixer
,
857 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 4, .size
= 1 },
862 .enable
= s5pv210_clk_mask1_ctrl
,
865 .sources
= &clkset_group2
,
866 .reg_src
= { .reg
= S5P_CLK_SRC3
, .shift
= 12, .size
= 4 },
867 .reg_div
= { .reg
= S5P_CLK_DIV3
, .shift
= 12, .size
= 4 },
872 .enable
= s5pv210_clk_mask1_ctrl
,
875 .sources
= &clkset_group2
,
876 .reg_src
= { .reg
= S5P_CLK_SRC3
, .shift
= 16, .size
= 4 },
877 .reg_div
= { .reg
= S5P_CLK_DIV3
, .shift
= 16, .size
= 4 },
882 .enable
= s5pv210_clk_mask1_ctrl
,
885 .sources
= &clkset_group2
,
886 .reg_src
= { .reg
= S5P_CLK_SRC3
, .shift
= 20, .size
= 4 },
887 .reg_div
= { .reg
= S5P_CLK_DIV3
, .shift
= 20, .size
= 4 },
892 .enable
= s5pv210_clk_mask0_ctrl
,
895 .sources
= &clkset_group2
,
896 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 12, .size
= 4 },
897 .reg_div
= { .reg
= S5P_CLK_DIV1
, .shift
= 12, .size
= 4 },
902 .enable
= s5pv210_clk_mask0_ctrl
,
905 .sources
= &clkset_group2
,
906 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 16, .size
= 4 },
907 .reg_div
= { .reg
= S5P_CLK_DIV1
, .shift
= 16, .size
= 4 },
912 .enable
= s5pv210_clk_mask0_ctrl
,
915 .sources
= &clkset_group2
,
916 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 20, .size
= 4 },
917 .reg_div
= { .reg
= S5P_CLK_DIV1
, .shift
= 20, .size
= 4 },
922 .enable
= s5pv210_clk_mask0_ctrl
,
925 .sources
= &clkset_group2
,
926 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 0, .size
= 4 },
927 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 0, .size
= 4 },
932 .enable
= s5pv210_clk_mask0_ctrl
,
935 .sources
= &clkset_group2
,
936 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 4, .size
= 4 },
937 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 4, .size
= 4 },
942 .enable
= s5pv210_clk_mask0_ctrl
,
943 .ctrlbit
= (1 << 10),
945 .sources
= &clkset_group2
,
946 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 8, .size
= 4 },
947 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 8, .size
= 4 },
952 .enable
= s5pv210_clk_mask0_ctrl
,
953 .ctrlbit
= (1 << 11),
955 .sources
= &clkset_group2
,
956 .reg_src
= { .reg
= S5P_CLK_SRC4
, .shift
= 12, .size
= 4 },
957 .reg_div
= { .reg
= S5P_CLK_DIV4
, .shift
= 12, .size
= 4 },
962 .enable
= s5pv210_clk_ip0_ctrl
,
963 .ctrlbit
= (1 << 16),
965 .sources
= &clkset_group1
,
966 .reg_src
= { .reg
= S5P_CLK_SRC2
, .shift
= 4, .size
= 2 },
967 .reg_div
= { .reg
= S5P_CLK_DIV2
, .shift
= 4, .size
= 4 },
972 .enable
= s5pv210_clk_ip0_ctrl
,
973 .ctrlbit
= (1 << 12),
975 .sources
= &clkset_group1
,
976 .reg_src
= { .reg
= S5P_CLK_SRC2
, .shift
= 8, .size
= 2 },
977 .reg_div
= { .reg
= S5P_CLK_DIV2
, .shift
= 8, .size
= 4 },
982 .enable
= s5pv210_clk_ip0_ctrl
,
985 .sources
= &clkset_group1
,
986 .reg_src
= { .reg
= S5P_CLK_SRC2
, .shift
= 0, .size
= 2 },
987 .reg_div
= { .reg
= S5P_CLK_DIV2
, .shift
= 0, .size
= 4 },
992 .enable
= s5pv210_clk_mask0_ctrl
,
995 .sources
= &clkset_group2
,
996 .reg_src
= { .reg
= S5P_CLK_SRC1
, .shift
= 24, .size
= 4 },
997 .reg_div
= { .reg
= S5P_CLK_DIV1
, .shift
= 28, .size
= 4 },
1002 .enable
= s5pv210_clk_mask0_ctrl
,
1003 .ctrlbit
= (1 << 16),
1005 .sources
= &clkset_group2
,
1006 .reg_src
= { .reg
= S5P_CLK_SRC5
, .shift
= 0, .size
= 4 },
1007 .reg_div
= { .reg
= S5P_CLK_DIV5
, .shift
= 0, .size
= 4 },
1012 .enable
= s5pv210_clk_mask0_ctrl
,
1013 .ctrlbit
= (1 << 17),
1015 .sources
= &clkset_group2
,
1016 .reg_src
= { .reg
= S5P_CLK_SRC5
, .shift
= 4, .size
= 4 },
1017 .reg_div
= { .reg
= S5P_CLK_DIV5
, .shift
= 4, .size
= 4 },
1022 .enable
= s5pv210_clk_mask0_ctrl
,
1023 .ctrlbit
= (1 << 29),
1025 .sources
= &clkset_group2
,
1026 .reg_src
= { .reg
= S5P_CLK_SRC6
, .shift
= 20, .size
= 4 },
1027 .reg_div
= { .reg
= S5P_CLK_DIV6
, .shift
= 24, .size
= 4 },
1032 .enable
= s5pv210_clk_mask0_ctrl
,
1033 .ctrlbit
= (1 << 19),
1035 .sources
= &clkset_group2
,
1036 .reg_src
= { .reg
= S5P_CLK_SRC5
, .shift
= 12, .size
= 4 },
1037 .reg_div
= { .reg
= S5P_CLK_DIV5
, .shift
= 12, .size
= 4 },
1041 /* Clock initialisation code */
1042 static struct clksrc_clk
*sysclks
[] = {
1067 static u32 epll_div
[][6] = {
1068 { 48000000, 0, 48, 3, 3, 0 },
1069 { 96000000, 0, 48, 3, 2, 0 },
1070 { 144000000, 1, 72, 3, 2, 0 },
1071 { 192000000, 0, 48, 3, 1, 0 },
1072 { 288000000, 1, 72, 3, 1, 0 },
1073 { 32750000, 1, 65, 3, 4, 35127 },
1074 { 32768000, 1, 65, 3, 4, 35127 },
1075 { 45158400, 0, 45, 3, 3, 10355 },
1076 { 45000000, 0, 45, 3, 3, 10355 },
1077 { 45158000, 0, 45, 3, 3, 10355 },
1078 { 49125000, 0, 49, 3, 3, 9961 },
1079 { 49152000, 0, 49, 3, 3, 9961 },
1080 { 67737600, 1, 67, 3, 3, 48366 },
1081 { 67738000, 1, 67, 3, 3, 48366 },
1082 { 73800000, 1, 73, 3, 3, 47710 },
1083 { 73728000, 1, 73, 3, 3, 47710 },
1084 { 36000000, 1, 32, 3, 4, 0 },
1085 { 60000000, 1, 60, 3, 3, 0 },
1086 { 72000000, 1, 72, 3, 3, 0 },
1087 { 80000000, 1, 80, 3, 3, 0 },
1088 { 84000000, 0, 42, 3, 2, 0 },
1089 { 50000000, 0, 50, 3, 3, 0 },
1092 static int s5pv210_epll_set_rate(struct clk
*clk
, unsigned long rate
)
1094 unsigned int epll_con
, epll_con_k
;
1097 /* Return if nothing changed */
1098 if (clk
->rate
== rate
)
1101 epll_con
= __raw_readl(S5P_EPLL_CON
);
1102 epll_con_k
= __raw_readl(S5P_EPLL_CON1
);
1104 epll_con_k
&= ~PLL46XX_KDIV_MASK
;
1105 epll_con
&= ~(1 << 27 |
1106 PLL46XX_MDIV_MASK
<< PLL46XX_MDIV_SHIFT
|
1107 PLL46XX_PDIV_MASK
<< PLL46XX_PDIV_SHIFT
|
1108 PLL46XX_SDIV_MASK
<< PLL46XX_SDIV_SHIFT
);
1110 for (i
= 0; i
< ARRAY_SIZE(epll_div
); i
++) {
1111 if (epll_div
[i
][0] == rate
) {
1112 epll_con_k
|= epll_div
[i
][5] << 0;
1113 epll_con
|= (epll_div
[i
][1] << 27 |
1114 epll_div
[i
][2] << PLL46XX_MDIV_SHIFT
|
1115 epll_div
[i
][3] << PLL46XX_PDIV_SHIFT
|
1116 epll_div
[i
][4] << PLL46XX_SDIV_SHIFT
);
1121 if (i
== ARRAY_SIZE(epll_div
)) {
1122 printk(KERN_ERR
"%s: Invalid Clock EPLL Frequency\n",
1127 __raw_writel(epll_con
, S5P_EPLL_CON
);
1128 __raw_writel(epll_con_k
, S5P_EPLL_CON1
);
1130 printk(KERN_WARNING
"EPLL Rate changes from %lu to %lu\n",
1138 static struct clk_ops s5pv210_epll_ops
= {
1139 .set_rate
= s5pv210_epll_set_rate
,
1140 .get_rate
= s5p_epll_get_rate
,
1143 void __init_or_cpufreq
s5pv210_setup_clocks(void)
1145 struct clk
*xtal_clk
;
1146 unsigned long vpllsrc
;
1147 unsigned long armclk
;
1148 unsigned long hclk_msys
;
1149 unsigned long hclk_dsys
;
1150 unsigned long hclk_psys
;
1151 unsigned long pclk_msys
;
1152 unsigned long pclk_dsys
;
1153 unsigned long pclk_psys
;
1159 u32 clkdiv0
, clkdiv1
;
1161 /* Set functions for clk_fout_epll */
1162 clk_fout_epll
.enable
= s5p_epll_enable
;
1163 clk_fout_epll
.ops
= &s5pv210_epll_ops
;
1165 printk(KERN_DEBUG
"%s: registering clocks\n", __func__
);
1167 clkdiv0
= __raw_readl(S5P_CLK_DIV0
);
1168 clkdiv1
= __raw_readl(S5P_CLK_DIV1
);
1170 printk(KERN_DEBUG
"%s: clkdiv0 = %08x, clkdiv1 = %08x\n",
1171 __func__
, clkdiv0
, clkdiv1
);
1173 xtal_clk
= clk_get(NULL
, "xtal");
1174 BUG_ON(IS_ERR(xtal_clk
));
1176 xtal
= clk_get_rate(xtal_clk
);
1179 printk(KERN_DEBUG
"%s: xtal is %ld\n", __func__
, xtal
);
1181 apll
= s5p_get_pll45xx(xtal
, __raw_readl(S5P_APLL_CON
), pll_4508
);
1182 mpll
= s5p_get_pll45xx(xtal
, __raw_readl(S5P_MPLL_CON
), pll_4502
);
1183 epll
= s5p_get_pll46xx(xtal
, __raw_readl(S5P_EPLL_CON
),
1184 __raw_readl(S5P_EPLL_CON1
), pll_4600
);
1185 vpllsrc
= clk_get_rate(&clk_vpllsrc
.clk
);
1186 vpll
= s5p_get_pll45xx(vpllsrc
, __raw_readl(S5P_VPLL_CON
), pll_4502
);
1188 clk_fout_apll
.ops
= &clk_fout_apll_ops
;
1189 clk_fout_mpll
.rate
= mpll
;
1190 clk_fout_epll
.rate
= epll
;
1191 clk_fout_vpll
.rate
= vpll
;
1193 printk(KERN_INFO
"S5PV210: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
1194 apll
, mpll
, epll
, vpll
);
1196 armclk
= clk_get_rate(&clk_armclk
.clk
);
1197 hclk_msys
= clk_get_rate(&clk_hclk_msys
.clk
);
1198 hclk_dsys
= clk_get_rate(&clk_hclk_dsys
.clk
);
1199 hclk_psys
= clk_get_rate(&clk_hclk_psys
.clk
);
1200 pclk_msys
= clk_get_rate(&clk_pclk_msys
.clk
);
1201 pclk_dsys
= clk_get_rate(&clk_pclk_dsys
.clk
);
1202 pclk_psys
= clk_get_rate(&clk_pclk_psys
.clk
);
1204 printk(KERN_INFO
"S5PV210: ARMCLK=%ld, HCLKM=%ld, HCLKD=%ld\n"
1205 "HCLKP=%ld, PCLKM=%ld, PCLKD=%ld, PCLKP=%ld\n",
1206 armclk
, hclk_msys
, hclk_dsys
, hclk_psys
,
1207 pclk_msys
, pclk_dsys
, pclk_psys
);
1209 clk_f
.rate
= armclk
;
1210 clk_h
.rate
= hclk_psys
;
1211 clk_p
.rate
= pclk_psys
;
1213 for (ptr
= 0; ptr
< ARRAY_SIZE(clksrcs
); ptr
++)
1214 s3c_set_clksrc(&clksrcs
[ptr
], true);
1217 static struct clk
*clks
[] __initdata
= {
1227 void __init
s5pv210_register_clocks(void)
1231 s3c24xx_register_clocks(clks
, ARRAY_SIZE(clks
));
1233 for (ptr
= 0; ptr
< ARRAY_SIZE(sysclks
); ptr
++)
1234 s3c_register_clksrc(sysclks
[ptr
], 1);
1236 s3c_register_clksrc(clksrcs
, ARRAY_SIZE(clksrcs
));
1237 s3c_register_clocks(init_clocks
, ARRAY_SIZE(init_clocks
));
1239 s3c_register_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));
1240 s3c_disable_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));