1 /* linux/arch/arm/plat-s3c64xx/clock.c
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/
8 * S3C64XX Base clock support
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/interrupt.h>
18 #include <linux/ioport.h>
19 #include <linux/clk.h>
20 #include <linux/err.h>
23 #include <mach/hardware.h>
26 #include <mach/regs-sys.h>
27 #include <mach/regs-clock.h>
30 #include <plat/devs.h>
31 #include <plat/cpu-freq.h>
32 #include <plat/clock.h>
33 #include <plat/clock-clksrc.h>
36 /* fin_apll, fin_mpll and fin_epll are all the same clock, which we call
37 * ext_xtal_mux for want of an actual name from the manual.
40 static struct clk clk_ext_xtal_mux
= {
44 #define clk_fin_apll clk_ext_xtal_mux
45 #define clk_fin_mpll clk_ext_xtal_mux
46 #define clk_fin_epll clk_ext_xtal_mux
48 #define clk_fout_mpll clk_mpll
49 #define clk_fout_epll clk_epll
56 struct clk clk_27m
= {
61 static int clk_48m_ctrl(struct clk
*clk
, int enable
)
66 /* can't rely on clock lock, this register has other usages */
67 local_irq_save(flags
);
69 val
= __raw_readl(S3C64XX_OTHERS
);
71 val
|= S3C64XX_OTHERS_USBMASK
;
73 val
&= ~S3C64XX_OTHERS_USBMASK
;
75 __raw_writel(val
, S3C64XX_OTHERS
);
76 local_irq_restore(flags
);
81 struct clk clk_48m
= {
84 .enable
= clk_48m_ctrl
,
87 struct clk clk_xusbxti
= {
92 static int inline s3c64xx_gate(void __iomem
*reg
,
96 unsigned int ctrlbit
= clk
->ctrlbit
;
99 con
= __raw_readl(reg
);
106 __raw_writel(con
, reg
);
110 static int s3c64xx_pclk_ctrl(struct clk
*clk
, int enable
)
112 return s3c64xx_gate(S3C_PCLK_GATE
, clk
, enable
);
115 static int s3c64xx_hclk_ctrl(struct clk
*clk
, int enable
)
117 return s3c64xx_gate(S3C_HCLK_GATE
, clk
, enable
);
120 int s3c64xx_sclk_ctrl(struct clk
*clk
, int enable
)
122 return s3c64xx_gate(S3C_SCLK_GATE
, clk
, enable
);
125 static struct clk init_clocks_off
[] = {
132 .enable
= s3c64xx_pclk_ctrl
,
133 .ctrlbit
= S3C_CLKCON_PCLK_RTC
,
137 .enable
= s3c64xx_pclk_ctrl
,
138 .ctrlbit
= S3C_CLKCON_PCLK_TSADC
,
141 .devname
= "s3c2440-i2c.0",
143 .enable
= s3c64xx_pclk_ctrl
,
144 .ctrlbit
= S3C_CLKCON_PCLK_IIC
,
147 .devname
= "s3c2440-i2c.1",
149 .enable
= s3c64xx_pclk_ctrl
,
150 .ctrlbit
= S3C6410_CLKCON_PCLK_I2C1
,
154 .enable
= s3c64xx_pclk_ctrl
,
155 .ctrlbit
= S3C_CLKCON_PCLK_KEYPAD
,
158 .devname
= "s3c6410-spi.0",
160 .enable
= s3c64xx_pclk_ctrl
,
161 .ctrlbit
= S3C_CLKCON_PCLK_SPI0
,
164 .devname
= "s3c6410-spi.1",
166 .enable
= s3c64xx_pclk_ctrl
,
167 .ctrlbit
= S3C_CLKCON_PCLK_SPI1
,
170 .devname
= "s3c-sdhci.0",
172 .enable
= s3c64xx_sclk_ctrl
,
173 .ctrlbit
= S3C_CLKCON_SCLK_MMC0_48
,
176 .devname
= "s3c-sdhci.1",
178 .enable
= s3c64xx_sclk_ctrl
,
179 .ctrlbit
= S3C_CLKCON_SCLK_MMC1_48
,
182 .devname
= "s3c-sdhci.2",
184 .enable
= s3c64xx_sclk_ctrl
,
185 .ctrlbit
= S3C_CLKCON_SCLK_MMC2_48
,
189 .ctrlbit
= S3C_CLKCON_PCLK_AC97
,
193 .enable
= s3c64xx_hclk_ctrl
,
194 .ctrlbit
= S3C_CLKCON_HCLK_IHOST
,
198 .enable
= s3c64xx_hclk_ctrl
,
199 .ctrlbit
= S3C_CLKCON_HCLK_DMA0
,
203 .enable
= s3c64xx_hclk_ctrl
,
204 .ctrlbit
= S3C_CLKCON_HCLK_DMA1
,
208 .enable
= s3c64xx_hclk_ctrl
,
209 .ctrlbit
= S3C_CLKCON_HCLK_3DSE
,
211 .name
= "hclk_secur",
213 .enable
= s3c64xx_hclk_ctrl
,
214 .ctrlbit
= S3C_CLKCON_HCLK_SECUR
,
218 .enable
= s3c64xx_hclk_ctrl
,
219 .ctrlbit
= S3C_CLKCON_HCLK_SDMA1
,
223 .enable
= s3c64xx_hclk_ctrl
,
224 .ctrlbit
= S3C_CLKCON_HCLK_SDMA0
,
228 .enable
= s3c64xx_hclk_ctrl
,
229 .ctrlbit
= S3C_CLKCON_HCLK_JPEG
,
233 .enable
= s3c64xx_hclk_ctrl
,
234 .ctrlbit
= S3C_CLKCON_HCLK_CAMIF
,
236 .name
= "hclk_scaler",
238 .enable
= s3c64xx_hclk_ctrl
,
239 .ctrlbit
= S3C_CLKCON_HCLK_SCALER
,
243 .enable
= s3c64xx_hclk_ctrl
,
244 .ctrlbit
= S3C_CLKCON_HCLK_2D
,
248 .enable
= s3c64xx_hclk_ctrl
,
249 .ctrlbit
= S3C_CLKCON_HCLK_TV
,
253 .enable
= s3c64xx_hclk_ctrl
,
254 .ctrlbit
= S3C_CLKCON_HCLK_POST0
,
258 .enable
= s3c64xx_hclk_ctrl
,
259 .ctrlbit
= S3C_CLKCON_HCLK_ROT
,
263 .enable
= s3c64xx_hclk_ctrl
,
264 .ctrlbit
= S3C_CLKCON_HCLK_MFC
,
268 .enable
= s3c64xx_pclk_ctrl
,
269 .ctrlbit
= S3C_CLKCON_PCLK_MFC
,
272 .enable
= s3c64xx_sclk_ctrl
,
273 .ctrlbit
= S3C_CLKCON_SCLK_DAC27
,
276 .enable
= s3c64xx_sclk_ctrl
,
277 .ctrlbit
= S3C_CLKCON_SCLK_TV27
,
280 .enable
= s3c64xx_sclk_ctrl
,
281 .ctrlbit
= S3C_CLKCON_SCLK_SCALER27
,
283 .name
= "sclk_scaler",
284 .enable
= s3c64xx_sclk_ctrl
,
285 .ctrlbit
= S3C_CLKCON_SCLK_SCALER
,
288 .enable
= s3c64xx_sclk_ctrl
,
289 .ctrlbit
= S3C_CLKCON_SCLK_POST0_27
,
292 .enable
= s3c64xx_sclk_ctrl
,
293 .ctrlbit
= S3C_CLKCON_SCLK_SECUR
,
296 .enable
= s3c64xx_sclk_ctrl
,
297 .ctrlbit
= S3C_CLKCON_SCLK_MFC
,
300 .enable
= s3c64xx_sclk_ctrl
,
301 .ctrlbit
= S3C_CLKCON_SCLK_JPEG
,
305 static struct clk clk_48m_spi0
= {
307 .devname
= "s3c6410-spi.0",
309 .enable
= s3c64xx_sclk_ctrl
,
310 .ctrlbit
= S3C_CLKCON_SCLK_SPI0_48
,
313 static struct clk clk_48m_spi1
= {
315 .devname
= "s3c6410-spi.1",
317 .enable
= s3c64xx_sclk_ctrl
,
318 .ctrlbit
= S3C_CLKCON_SCLK_SPI1_48
,
321 static struct clk clk_i2s0
= {
323 .devname
= "samsung-i2s.0",
325 .enable
= s3c64xx_pclk_ctrl
,
326 .ctrlbit
= S3C_CLKCON_PCLK_IIS0
,
329 static struct clk clk_i2s1
= {
331 .devname
= "samsung-i2s.1",
333 .enable
= s3c64xx_pclk_ctrl
,
334 .ctrlbit
= S3C_CLKCON_PCLK_IIS1
,
337 #ifdef CONFIG_CPU_S3C6410
338 static struct clk clk_i2s2
= {
340 .devname
= "samsung-i2s.2",
342 .enable
= s3c64xx_pclk_ctrl
,
343 .ctrlbit
= S3C6410_CLKCON_PCLK_IIS2
,
347 static struct clk init_clocks
[] = {
351 .enable
= s3c64xx_hclk_ctrl
,
352 .ctrlbit
= S3C_CLKCON_HCLK_LCD
,
356 .enable
= s3c64xx_pclk_ctrl
,
357 .ctrlbit
= S3C_CLKCON_PCLK_GPIO
,
361 .enable
= s3c64xx_hclk_ctrl
,
362 .ctrlbit
= S3C_CLKCON_HCLK_UHOST
,
366 .enable
= s3c64xx_hclk_ctrl
,
367 .ctrlbit
= S3C_CLKCON_HCLK_USB
,
371 .enable
= s3c64xx_pclk_ctrl
,
372 .ctrlbit
= S3C_CLKCON_PCLK_PWM
,
375 .devname
= "s3c6400-uart.0",
377 .enable
= s3c64xx_pclk_ctrl
,
378 .ctrlbit
= S3C_CLKCON_PCLK_UART0
,
381 .devname
= "s3c6400-uart.1",
383 .enable
= s3c64xx_pclk_ctrl
,
384 .ctrlbit
= S3C_CLKCON_PCLK_UART1
,
387 .devname
= "s3c6400-uart.2",
389 .enable
= s3c64xx_pclk_ctrl
,
390 .ctrlbit
= S3C_CLKCON_PCLK_UART2
,
393 .devname
= "s3c6400-uart.3",
395 .enable
= s3c64xx_pclk_ctrl
,
396 .ctrlbit
= S3C_CLKCON_PCLK_UART3
,
400 .ctrlbit
= S3C_CLKCON_PCLK_WDT
,
404 static struct clk clk_hsmmc0
= {
406 .devname
= "s3c-sdhci.0",
408 .enable
= s3c64xx_hclk_ctrl
,
409 .ctrlbit
= S3C_CLKCON_HCLK_HSMMC0
,
412 static struct clk clk_hsmmc1
= {
414 .devname
= "s3c-sdhci.1",
416 .enable
= s3c64xx_hclk_ctrl
,
417 .ctrlbit
= S3C_CLKCON_HCLK_HSMMC1
,
420 static struct clk clk_hsmmc2
= {
422 .devname
= "s3c-sdhci.2",
424 .enable
= s3c64xx_hclk_ctrl
,
425 .ctrlbit
= S3C_CLKCON_HCLK_HSMMC2
,
428 static struct clk clk_fout_apll
= {
432 static struct clk
*clk_src_apll_list
[] = {
434 [1] = &clk_fout_apll
,
437 static struct clksrc_sources clk_src_apll
= {
438 .sources
= clk_src_apll_list
,
439 .nr_sources
= ARRAY_SIZE(clk_src_apll_list
),
442 static struct clksrc_clk clk_mout_apll
= {
446 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 0, .size
= 1 },
447 .sources
= &clk_src_apll
,
450 static struct clk
*clk_src_epll_list
[] = {
452 [1] = &clk_fout_epll
,
455 static struct clksrc_sources clk_src_epll
= {
456 .sources
= clk_src_epll_list
,
457 .nr_sources
= ARRAY_SIZE(clk_src_epll_list
),
460 static struct clksrc_clk clk_mout_epll
= {
464 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 2, .size
= 1 },
465 .sources
= &clk_src_epll
,
468 static struct clk
*clk_src_mpll_list
[] = {
470 [1] = &clk_fout_mpll
,
473 static struct clksrc_sources clk_src_mpll
= {
474 .sources
= clk_src_mpll_list
,
475 .nr_sources
= ARRAY_SIZE(clk_src_mpll_list
),
478 static struct clksrc_clk clk_mout_mpll
= {
482 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 1, .size
= 1 },
483 .sources
= &clk_src_mpll
,
486 static unsigned int armclk_mask
;
488 static unsigned long s3c64xx_clk_arm_get_rate(struct clk
*clk
)
490 unsigned long rate
= clk_get_rate(clk
->parent
);
493 /* divisor mask starts at bit0, so no need to shift */
494 clkdiv
= __raw_readl(S3C_CLK_DIV0
) & armclk_mask
;
496 return rate
/ (clkdiv
+ 1);
499 static unsigned long s3c64xx_clk_arm_round_rate(struct clk
*clk
,
502 unsigned long parent
= clk_get_rate(clk
->parent
);
508 div
= (parent
/ rate
) - 1;
509 if (div
> armclk_mask
)
512 return parent
/ (div
+ 1);
515 static int s3c64xx_clk_arm_set_rate(struct clk
*clk
, unsigned long rate
)
517 unsigned long parent
= clk_get_rate(clk
->parent
);
521 if (rate
< parent
/ (armclk_mask
+ 1))
524 rate
= clk_round_rate(clk
, rate
);
525 div
= clk_get_rate(clk
->parent
) / rate
;
527 val
= __raw_readl(S3C_CLK_DIV0
);
530 __raw_writel(val
, S3C_CLK_DIV0
);
536 static struct clk clk_arm
= {
538 .parent
= &clk_mout_apll
.clk
,
539 .ops
= &(struct clk_ops
) {
540 .get_rate
= s3c64xx_clk_arm_get_rate
,
541 .set_rate
= s3c64xx_clk_arm_set_rate
,
542 .round_rate
= s3c64xx_clk_arm_round_rate
,
546 static unsigned long s3c64xx_clk_doutmpll_get_rate(struct clk
*clk
)
548 unsigned long rate
= clk_get_rate(clk
->parent
);
550 printk(KERN_DEBUG
"%s: parent is %ld\n", __func__
, rate
);
552 if (__raw_readl(S3C_CLK_DIV0
) & S3C6400_CLKDIV0_MPLL_MASK
)
558 static struct clk_ops clk_dout_ops
= {
559 .get_rate
= s3c64xx_clk_doutmpll_get_rate
,
562 static struct clk clk_dout_mpll
= {
564 .parent
= &clk_mout_mpll
.clk
,
565 .ops
= &clk_dout_ops
,
568 static struct clk
*clkset_spi_mmc_list
[] = {
575 static struct clksrc_sources clkset_spi_mmc
= {
576 .sources
= clkset_spi_mmc_list
,
577 .nr_sources
= ARRAY_SIZE(clkset_spi_mmc_list
),
580 static struct clk
*clkset_irda_list
[] = {
587 static struct clksrc_sources clkset_irda
= {
588 .sources
= clkset_irda_list
,
589 .nr_sources
= ARRAY_SIZE(clkset_irda_list
),
592 static struct clk
*clkset_uart_list
[] = {
599 static struct clksrc_sources clkset_uart
= {
600 .sources
= clkset_uart_list
,
601 .nr_sources
= ARRAY_SIZE(clkset_uart_list
),
604 static struct clk
*clkset_uhost_list
[] = {
611 static struct clksrc_sources clkset_uhost
= {
612 .sources
= clkset_uhost_list
,
613 .nr_sources
= ARRAY_SIZE(clkset_uhost_list
),
616 /* The peripheral clocks are all controlled via clocksource followed
617 * by an optional divider and gate stage. We currently roll this into
618 * one clock which hides the intermediate clock from the mux.
620 * Note, the JPEG clock can only be an even divider...
622 * The scaler and LCD clocks depend on the S3C64XX version, and also
623 * have a common parent divisor so are not included here.
626 /* clocks that feed other parts of the clock source tree */
628 static struct clk clk_iis_cd0
= {
629 .name
= "iis_cdclk0",
632 static struct clk clk_iis_cd1
= {
633 .name
= "iis_cdclk1",
636 static struct clk clk_iisv4_cd
= {
637 .name
= "iis_cdclk_v4",
640 static struct clk clk_pcm_cd
= {
644 static struct clk
*clkset_audio0_list
[] = {
645 [0] = &clk_mout_epll
.clk
,
646 [1] = &clk_dout_mpll
,
652 static struct clksrc_sources clkset_audio0
= {
653 .sources
= clkset_audio0_list
,
654 .nr_sources
= ARRAY_SIZE(clkset_audio0_list
),
657 static struct clk
*clkset_audio1_list
[] = {
658 [0] = &clk_mout_epll
.clk
,
659 [1] = &clk_dout_mpll
,
665 static struct clksrc_sources clkset_audio1
= {
666 .sources
= clkset_audio1_list
,
667 .nr_sources
= ARRAY_SIZE(clkset_audio1_list
),
670 #ifdef CONFIG_CPU_S3C6410
671 static struct clk
*clkset_audio2_list
[] = {
672 [0] = &clk_mout_epll
.clk
,
673 [1] = &clk_dout_mpll
,
679 static struct clksrc_sources clkset_audio2
= {
680 .sources
= clkset_audio2_list
,
681 .nr_sources
= ARRAY_SIZE(clkset_audio2_list
),
685 static struct clksrc_clk clksrcs
[] = {
688 .name
= "usb-bus-host",
689 .ctrlbit
= S3C_CLKCON_SCLK_UHOST
,
690 .enable
= s3c64xx_sclk_ctrl
,
692 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 5, .size
= 2 },
693 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 20, .size
= 4 },
694 .sources
= &clkset_uhost
,
698 .ctrlbit
= S3C_CLKCON_SCLK_IRDA
,
699 .enable
= s3c64xx_sclk_ctrl
,
701 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 24, .size
= 2 },
702 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 20, .size
= 4 },
703 .sources
= &clkset_irda
,
707 .ctrlbit
= S3C_CLKCON_SCLK_CAM
,
708 .enable
= s3c64xx_sclk_ctrl
,
711 .reg_div
= { .reg
= S3C_CLK_DIV0
, .shift
= 20, .size
= 4 },
715 /* Where does UCLK0 come from? */
716 static struct clksrc_clk clk_sclk_uclk
= {
719 .ctrlbit
= S3C_CLKCON_SCLK_UART
,
720 .enable
= s3c64xx_sclk_ctrl
,
722 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 13, .size
= 1 },
723 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 16, .size
= 4 },
724 .sources
= &clkset_uart
,
727 static struct clksrc_clk clk_sclk_mmc0
= {
730 .devname
= "s3c-sdhci.0",
731 .ctrlbit
= S3C_CLKCON_SCLK_MMC0
,
732 .enable
= s3c64xx_sclk_ctrl
,
734 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 18, .size
= 2 },
735 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 0, .size
= 4 },
736 .sources
= &clkset_spi_mmc
,
739 static struct clksrc_clk clk_sclk_mmc1
= {
742 .devname
= "s3c-sdhci.1",
743 .ctrlbit
= S3C_CLKCON_SCLK_MMC1
,
744 .enable
= s3c64xx_sclk_ctrl
,
746 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 20, .size
= 2 },
747 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 4, .size
= 4 },
748 .sources
= &clkset_spi_mmc
,
751 static struct clksrc_clk clk_sclk_mmc2
= {
754 .devname
= "s3c-sdhci.2",
755 .ctrlbit
= S3C_CLKCON_SCLK_MMC2
,
756 .enable
= s3c64xx_sclk_ctrl
,
758 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 22, .size
= 2 },
759 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 8, .size
= 4 },
760 .sources
= &clkset_spi_mmc
,
763 static struct clksrc_clk clk_sclk_spi0
= {
766 .devname
= "s3c6410-spi.0",
767 .ctrlbit
= S3C_CLKCON_SCLK_SPI0
,
768 .enable
= s3c64xx_sclk_ctrl
,
770 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 14, .size
= 2 },
771 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 0, .size
= 4 },
772 .sources
= &clkset_spi_mmc
,
775 static struct clksrc_clk clk_sclk_spi1
= {
778 .devname
= "s3c6410-spi.1",
779 .ctrlbit
= S3C_CLKCON_SCLK_SPI1
,
780 .enable
= s3c64xx_sclk_ctrl
,
782 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 16, .size
= 2 },
783 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 4, .size
= 4 },
784 .sources
= &clkset_spi_mmc
,
787 static struct clksrc_clk clk_audio_bus0
= {
790 .devname
= "samsung-i2s.0",
791 .ctrlbit
= S3C_CLKCON_SCLK_AUDIO0
,
792 .enable
= s3c64xx_sclk_ctrl
,
794 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 7, .size
= 3 },
795 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 8, .size
= 4 },
796 .sources
= &clkset_audio0
,
799 static struct clksrc_clk clk_audio_bus1
= {
802 .devname
= "samsung-i2s.1",
803 .ctrlbit
= S3C_CLKCON_SCLK_AUDIO1
,
804 .enable
= s3c64xx_sclk_ctrl
,
806 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 10, .size
= 3 },
807 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 12, .size
= 4 },
808 .sources
= &clkset_audio1
,
811 #ifdef CONFIG_CPU_S3C6410
812 static struct clksrc_clk clk_audio_bus2
= {
815 .devname
= "samsung-i2s.2",
816 .ctrlbit
= S3C6410_CLKCON_SCLK_AUDIO2
,
817 .enable
= s3c64xx_sclk_ctrl
,
819 .reg_src
= { .reg
= S3C6410_CLK_SRC2
, .shift
= 0, .size
= 3 },
820 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 24, .size
= 4 },
821 .sources
= &clkset_audio2
,
824 /* Clock initialisation code */
826 static struct clksrc_clk
*init_parents
[] = {
832 static struct clksrc_clk
*clksrc_cdev
[] = {
843 static struct clk
*clk_cdev
[] = {
853 static struct clk_lookup s3c64xx_clk_lookup
[] = {
854 CLKDEV_INIT(NULL
, "clk_uart_baud2", &clk_p
),
855 CLKDEV_INIT(NULL
, "clk_uart_baud3", &clk_sclk_uclk
.clk
),
856 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &clk_hsmmc0
),
857 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.0", &clk_hsmmc1
),
858 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.0", &clk_hsmmc2
),
859 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0
.clk
),
860 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1
.clk
),
861 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2
.clk
),
862 CLKDEV_INIT(NULL
, "spi_busclk0", &clk_p
),
863 CLKDEV_INIT("s3c6410-spi.0", "spi_busclk1", &clk_sclk_spi0
.clk
),
864 CLKDEV_INIT("s3c6410-spi.0", "spi_busclk2", &clk_48m_spi0
),
865 CLKDEV_INIT("s3c6410-spi.1", "spi_busclk1", &clk_sclk_spi1
.clk
),
866 CLKDEV_INIT("s3c6410-spi.1", "spi_busclk2", &clk_48m_spi1
),
867 CLKDEV_INIT("samsung-i2s.0", "i2s_opclk0", &clk_i2s0
),
868 CLKDEV_INIT("samsung-i2s.0", "i2s_opclk1", &clk_audio_bus0
.clk
),
869 CLKDEV_INIT("samsung-i2s.1", "i2s_opclk0", &clk_i2s1
),
870 CLKDEV_INIT("samsung-i2s.1", "i2s_opclk1", &clk_audio_bus1
.clk
),
871 #ifdef CONFIG_CPU_S3C6410
872 CLKDEV_INIT("samsung-i2s.2", "i2s_opclk0", &clk_i2s2
),
873 CLKDEV_INIT("samsung-i2s.2", "i2s_opclk1", &clk_audio_bus2
.clk
),
877 #define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1)
879 void __init_or_cpufreq
s3c64xx_setup_clocks(void)
881 struct clk
*xtal_clk
;
893 printk(KERN_DEBUG
"%s: registering clocks\n", __func__
);
895 clkdiv0
= __raw_readl(S3C_CLK_DIV0
);
896 printk(KERN_DEBUG
"%s: clkdiv0 = %08x\n", __func__
, clkdiv0
);
898 xtal_clk
= clk_get(NULL
, "xtal");
899 BUG_ON(IS_ERR(xtal_clk
));
901 xtal
= clk_get_rate(xtal_clk
);
904 printk(KERN_DEBUG
"%s: xtal is %ld\n", __func__
, xtal
);
906 /* For now assume the mux always selects the crystal */
907 clk_ext_xtal_mux
.parent
= xtal_clk
;
909 epll
= s3c_get_pll6553x(xtal
, __raw_readl(S3C_EPLL_CON0
),
910 __raw_readl(S3C_EPLL_CON1
));
911 mpll
= s3c6400_get_pll(xtal
, __raw_readl(S3C_MPLL_CON
));
912 apll
= s3c6400_get_pll(xtal
, __raw_readl(S3C_APLL_CON
));
916 printk(KERN_INFO
"S3C64XX: PLL settings, A=%ld, M=%ld, E=%ld\n",
919 if(__raw_readl(S3C64XX_OTHERS
) & S3C64XX_OTHERS_SYNCMUXSEL
)
920 /* Synchronous mode */
921 hclk2
= apll
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_HCLK2
);
923 /* Asynchronous mode */
924 hclk2
= mpll
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_HCLK2
);
926 hclk
= hclk2
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_HCLK
);
927 pclk
= hclk2
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_PCLK
);
929 printk(KERN_INFO
"S3C64XX: HCLK2=%ld, HCLK=%ld, PCLK=%ld\n",
932 clk_fout_mpll
.rate
= mpll
;
933 clk_fout_epll
.rate
= epll
;
934 clk_fout_apll
.rate
= apll
;
941 for (ptr
= 0; ptr
< ARRAY_SIZE(init_parents
); ptr
++)
942 s3c_set_clksrc(init_parents
[ptr
], true);
944 for (ptr
= 0; ptr
< ARRAY_SIZE(clksrcs
); ptr
++)
945 s3c_set_clksrc(&clksrcs
[ptr
], true);
948 static struct clk
*clks1
[] __initdata
= {
960 static struct clk
*clks
[] __initdata
= {
970 * s3c64xx_register_clocks - register clocks for s3c6400 and s3c6410
971 * @xtal: The rate for the clock crystal feeding the PLLs.
972 * @armclk_divlimit: Divisor mask for ARMCLK.
974 * Register the clocks for the S3C6400 and S3C6410 SoC range, such
975 * as ARMCLK as well as the necessary parent clocks.
977 * This call does not setup the clocks, which is left to the
978 * s3c64xx_setup_clocks() call which may be needed by the cpufreq
979 * or resume code to re-set the clocks if the bootloader has changed
982 void __init
s3c64xx_register_clocks(unsigned long xtal
,
983 unsigned armclk_divlimit
)
987 armclk_mask
= armclk_divlimit
;
989 s3c24xx_register_baseclocks(xtal
);
990 s3c24xx_register_clocks(clks
, ARRAY_SIZE(clks
));
992 s3c_register_clocks(init_clocks
, ARRAY_SIZE(init_clocks
));
994 s3c_register_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));
995 s3c_disable_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));
997 s3c24xx_register_clocks(clk_cdev
, ARRAY_SIZE(clk_cdev
));
998 for (cnt
= 0; cnt
< ARRAY_SIZE(clk_cdev
); cnt
++)
999 s3c_disable_clocks(clk_cdev
[cnt
], 1);
1001 s3c24xx_register_clocks(clks1
, ARRAY_SIZE(clks1
));
1002 s3c_register_clksrc(clksrcs
, ARRAY_SIZE(clksrcs
));
1003 for (cnt
= 0; cnt
< ARRAY_SIZE(clksrc_cdev
); cnt
++)
1004 s3c_register_clksrc(clksrc_cdev
[cnt
], 1);
1005 clkdev_add_table(s3c64xx_clk_lookup
, ARRAY_SIZE(s3c64xx_clk_lookup
));