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 #ifdef CONFIG_S3C_DEV_I2C1
142 .devname
= "s3c2440-i2c.0",
144 .devname
= "s3c2440-i2c",
147 .enable
= s3c64xx_pclk_ctrl
,
148 .ctrlbit
= S3C_CLKCON_PCLK_IIC
,
151 .devname
= "s3c2440-i2c.1",
153 .enable
= s3c64xx_pclk_ctrl
,
154 .ctrlbit
= S3C6410_CLKCON_PCLK_I2C1
,
157 .devname
= "samsung-i2s.0",
159 .enable
= s3c64xx_pclk_ctrl
,
160 .ctrlbit
= S3C_CLKCON_PCLK_IIS0
,
163 .devname
= "samsung-i2s.1",
165 .enable
= s3c64xx_pclk_ctrl
,
166 .ctrlbit
= S3C_CLKCON_PCLK_IIS1
,
168 #ifdef CONFIG_CPU_S3C6410
171 .enable
= s3c64xx_pclk_ctrl
,
172 .ctrlbit
= S3C6410_CLKCON_PCLK_IIS2
,
177 .enable
= s3c64xx_pclk_ctrl
,
178 .ctrlbit
= S3C_CLKCON_PCLK_KEYPAD
,
181 .devname
= "s3c6410-spi.0",
183 .enable
= s3c64xx_pclk_ctrl
,
184 .ctrlbit
= S3C_CLKCON_PCLK_SPI0
,
187 .devname
= "s3c6410-spi.1",
189 .enable
= s3c64xx_pclk_ctrl
,
190 .ctrlbit
= S3C_CLKCON_PCLK_SPI1
,
193 .devname
= "s3c-sdhci.0",
195 .enable
= s3c64xx_sclk_ctrl
,
196 .ctrlbit
= S3C_CLKCON_SCLK_MMC0_48
,
199 .devname
= "s3c-sdhci.1",
201 .enable
= s3c64xx_sclk_ctrl
,
202 .ctrlbit
= S3C_CLKCON_SCLK_MMC1_48
,
205 .devname
= "s3c-sdhci.2",
207 .enable
= s3c64xx_sclk_ctrl
,
208 .ctrlbit
= S3C_CLKCON_SCLK_MMC2_48
,
212 .ctrlbit
= S3C_CLKCON_PCLK_AC97
,
216 .enable
= s3c64xx_hclk_ctrl
,
217 .ctrlbit
= S3C_CLKCON_HCLK_IHOST
,
221 .enable
= s3c64xx_hclk_ctrl
,
222 .ctrlbit
= S3C_CLKCON_HCLK_DMA0
,
226 .enable
= s3c64xx_hclk_ctrl
,
227 .ctrlbit
= S3C_CLKCON_HCLK_DMA1
,
231 .enable
= s3c64xx_hclk_ctrl
,
232 .ctrlbit
= S3C_CLKCON_HCLK_3DSE
,
234 .name
= "hclk_secur",
236 .enable
= s3c64xx_hclk_ctrl
,
237 .ctrlbit
= S3C_CLKCON_HCLK_SECUR
,
241 .enable
= s3c64xx_hclk_ctrl
,
242 .ctrlbit
= S3C_CLKCON_HCLK_SDMA1
,
246 .enable
= s3c64xx_hclk_ctrl
,
247 .ctrlbit
= S3C_CLKCON_HCLK_SDMA0
,
251 .enable
= s3c64xx_hclk_ctrl
,
252 .ctrlbit
= S3C_CLKCON_HCLK_JPEG
,
256 .enable
= s3c64xx_hclk_ctrl
,
257 .ctrlbit
= S3C_CLKCON_HCLK_CAMIF
,
259 .name
= "hclk_scaler",
261 .enable
= s3c64xx_hclk_ctrl
,
262 .ctrlbit
= S3C_CLKCON_HCLK_SCALER
,
266 .enable
= s3c64xx_hclk_ctrl
,
267 .ctrlbit
= S3C_CLKCON_HCLK_2D
,
271 .enable
= s3c64xx_hclk_ctrl
,
272 .ctrlbit
= S3C_CLKCON_HCLK_TV
,
276 .enable
= s3c64xx_hclk_ctrl
,
277 .ctrlbit
= S3C_CLKCON_HCLK_POST0
,
281 .enable
= s3c64xx_hclk_ctrl
,
282 .ctrlbit
= S3C_CLKCON_HCLK_ROT
,
286 .enable
= s3c64xx_hclk_ctrl
,
287 .ctrlbit
= S3C_CLKCON_HCLK_MFC
,
291 .enable
= s3c64xx_pclk_ctrl
,
292 .ctrlbit
= S3C_CLKCON_PCLK_MFC
,
295 .enable
= s3c64xx_sclk_ctrl
,
296 .ctrlbit
= S3C_CLKCON_SCLK_DAC27
,
299 .enable
= s3c64xx_sclk_ctrl
,
300 .ctrlbit
= S3C_CLKCON_SCLK_TV27
,
303 .enable
= s3c64xx_sclk_ctrl
,
304 .ctrlbit
= S3C_CLKCON_SCLK_SCALER27
,
306 .name
= "sclk_scaler",
307 .enable
= s3c64xx_sclk_ctrl
,
308 .ctrlbit
= S3C_CLKCON_SCLK_SCALER
,
311 .enable
= s3c64xx_sclk_ctrl
,
312 .ctrlbit
= S3C_CLKCON_SCLK_POST0_27
,
315 .enable
= s3c64xx_sclk_ctrl
,
316 .ctrlbit
= S3C_CLKCON_SCLK_SECUR
,
319 .enable
= s3c64xx_sclk_ctrl
,
320 .ctrlbit
= S3C_CLKCON_SCLK_MFC
,
323 .enable
= s3c64xx_sclk_ctrl
,
324 .ctrlbit
= S3C_CLKCON_SCLK_CAM
,
327 .enable
= s3c64xx_sclk_ctrl
,
328 .ctrlbit
= S3C_CLKCON_SCLK_JPEG
,
332 static struct clk clk_48m_spi0
= {
334 .devname
= "s3c6410-spi.0",
336 .enable
= s3c64xx_sclk_ctrl
,
337 .ctrlbit
= S3C_CLKCON_SCLK_SPI0_48
,
340 static struct clk clk_48m_spi1
= {
342 .devname
= "s3c6410-spi.1",
344 .enable
= s3c64xx_sclk_ctrl
,
345 .ctrlbit
= S3C_CLKCON_SCLK_SPI1_48
,
348 static struct clk init_clocks
[] = {
352 .enable
= s3c64xx_hclk_ctrl
,
353 .ctrlbit
= S3C_CLKCON_HCLK_LCD
,
357 .enable
= s3c64xx_pclk_ctrl
,
358 .ctrlbit
= S3C_CLKCON_PCLK_GPIO
,
362 .enable
= s3c64xx_hclk_ctrl
,
363 .ctrlbit
= S3C_CLKCON_HCLK_UHOST
,
367 .enable
= s3c64xx_hclk_ctrl
,
368 .ctrlbit
= S3C_CLKCON_HCLK_USB
,
372 .enable
= s3c64xx_pclk_ctrl
,
373 .ctrlbit
= S3C_CLKCON_PCLK_PWM
,
376 .devname
= "s3c6400-uart.0",
378 .enable
= s3c64xx_pclk_ctrl
,
379 .ctrlbit
= S3C_CLKCON_PCLK_UART0
,
382 .devname
= "s3c6400-uart.1",
384 .enable
= s3c64xx_pclk_ctrl
,
385 .ctrlbit
= S3C_CLKCON_PCLK_UART1
,
388 .devname
= "s3c6400-uart.2",
390 .enable
= s3c64xx_pclk_ctrl
,
391 .ctrlbit
= S3C_CLKCON_PCLK_UART2
,
394 .devname
= "s3c6400-uart.3",
396 .enable
= s3c64xx_pclk_ctrl
,
397 .ctrlbit
= S3C_CLKCON_PCLK_UART3
,
401 .ctrlbit
= S3C_CLKCON_PCLK_WDT
,
405 static struct clk clk_hsmmc0
= {
407 .devname
= "s3c-sdhci.0",
409 .enable
= s3c64xx_hclk_ctrl
,
410 .ctrlbit
= S3C_CLKCON_HCLK_HSMMC0
,
413 static struct clk clk_hsmmc1
= {
415 .devname
= "s3c-sdhci.1",
417 .enable
= s3c64xx_hclk_ctrl
,
418 .ctrlbit
= S3C_CLKCON_HCLK_HSMMC1
,
421 static struct clk clk_hsmmc2
= {
423 .devname
= "s3c-sdhci.2",
425 .enable
= s3c64xx_hclk_ctrl
,
426 .ctrlbit
= S3C_CLKCON_HCLK_HSMMC2
,
429 static struct clk clk_fout_apll
= {
433 static struct clk
*clk_src_apll_list
[] = {
435 [1] = &clk_fout_apll
,
438 static struct clksrc_sources clk_src_apll
= {
439 .sources
= clk_src_apll_list
,
440 .nr_sources
= ARRAY_SIZE(clk_src_apll_list
),
443 static struct clksrc_clk clk_mout_apll
= {
447 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 0, .size
= 1 },
448 .sources
= &clk_src_apll
,
451 static struct clk
*clk_src_epll_list
[] = {
453 [1] = &clk_fout_epll
,
456 static struct clksrc_sources clk_src_epll
= {
457 .sources
= clk_src_epll_list
,
458 .nr_sources
= ARRAY_SIZE(clk_src_epll_list
),
461 static struct clksrc_clk clk_mout_epll
= {
465 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 2, .size
= 1 },
466 .sources
= &clk_src_epll
,
469 static struct clk
*clk_src_mpll_list
[] = {
471 [1] = &clk_fout_mpll
,
474 static struct clksrc_sources clk_src_mpll
= {
475 .sources
= clk_src_mpll_list
,
476 .nr_sources
= ARRAY_SIZE(clk_src_mpll_list
),
479 static struct clksrc_clk clk_mout_mpll
= {
483 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 1, .size
= 1 },
484 .sources
= &clk_src_mpll
,
487 static unsigned int armclk_mask
;
489 static unsigned long s3c64xx_clk_arm_get_rate(struct clk
*clk
)
491 unsigned long rate
= clk_get_rate(clk
->parent
);
494 /* divisor mask starts at bit0, so no need to shift */
495 clkdiv
= __raw_readl(S3C_CLK_DIV0
) & armclk_mask
;
497 return rate
/ (clkdiv
+ 1);
500 static unsigned long s3c64xx_clk_arm_round_rate(struct clk
*clk
,
503 unsigned long parent
= clk_get_rate(clk
->parent
);
509 div
= (parent
/ rate
) - 1;
510 if (div
> armclk_mask
)
513 return parent
/ (div
+ 1);
516 static int s3c64xx_clk_arm_set_rate(struct clk
*clk
, unsigned long rate
)
518 unsigned long parent
= clk_get_rate(clk
->parent
);
522 if (rate
< parent
/ (armclk_mask
+ 1))
525 rate
= clk_round_rate(clk
, rate
);
526 div
= clk_get_rate(clk
->parent
) / rate
;
528 val
= __raw_readl(S3C_CLK_DIV0
);
531 __raw_writel(val
, S3C_CLK_DIV0
);
537 static struct clk clk_arm
= {
539 .parent
= &clk_mout_apll
.clk
,
540 .ops
= &(struct clk_ops
) {
541 .get_rate
= s3c64xx_clk_arm_get_rate
,
542 .set_rate
= s3c64xx_clk_arm_set_rate
,
543 .round_rate
= s3c64xx_clk_arm_round_rate
,
547 static unsigned long s3c64xx_clk_doutmpll_get_rate(struct clk
*clk
)
549 unsigned long rate
= clk_get_rate(clk
->parent
);
551 printk(KERN_DEBUG
"%s: parent is %ld\n", __func__
, rate
);
553 if (__raw_readl(S3C_CLK_DIV0
) & S3C6400_CLKDIV0_MPLL_MASK
)
559 static struct clk_ops clk_dout_ops
= {
560 .get_rate
= s3c64xx_clk_doutmpll_get_rate
,
563 static struct clk clk_dout_mpll
= {
565 .parent
= &clk_mout_mpll
.clk
,
566 .ops
= &clk_dout_ops
,
569 static struct clk
*clkset_spi_mmc_list
[] = {
576 static struct clksrc_sources clkset_spi_mmc
= {
577 .sources
= clkset_spi_mmc_list
,
578 .nr_sources
= ARRAY_SIZE(clkset_spi_mmc_list
),
581 static struct clk
*clkset_irda_list
[] = {
588 static struct clksrc_sources clkset_irda
= {
589 .sources
= clkset_irda_list
,
590 .nr_sources
= ARRAY_SIZE(clkset_irda_list
),
593 static struct clk
*clkset_uart_list
[] = {
600 static struct clksrc_sources clkset_uart
= {
601 .sources
= clkset_uart_list
,
602 .nr_sources
= ARRAY_SIZE(clkset_uart_list
),
605 static struct clk
*clkset_uhost_list
[] = {
612 static struct clksrc_sources clkset_uhost
= {
613 .sources
= clkset_uhost_list
,
614 .nr_sources
= ARRAY_SIZE(clkset_uhost_list
),
617 /* The peripheral clocks are all controlled via clocksource followed
618 * by an optional divider and gate stage. We currently roll this into
619 * one clock which hides the intermediate clock from the mux.
621 * Note, the JPEG clock can only be an even divider...
623 * The scaler and LCD clocks depend on the S3C64XX version, and also
624 * have a common parent divisor so are not included here.
627 /* clocks that feed other parts of the clock source tree */
629 static struct clk clk_iis_cd0
= {
630 .name
= "iis_cdclk0",
633 static struct clk clk_iis_cd1
= {
634 .name
= "iis_cdclk1",
637 static struct clk clk_iisv4_cd
= {
638 .name
= "iis_cdclk_v4",
641 static struct clk clk_pcm_cd
= {
645 static struct clk
*clkset_audio0_list
[] = {
646 [0] = &clk_mout_epll
.clk
,
647 [1] = &clk_dout_mpll
,
653 static struct clksrc_sources clkset_audio0
= {
654 .sources
= clkset_audio0_list
,
655 .nr_sources
= ARRAY_SIZE(clkset_audio0_list
),
658 static struct clk
*clkset_audio1_list
[] = {
659 [0] = &clk_mout_epll
.clk
,
660 [1] = &clk_dout_mpll
,
666 static struct clksrc_sources clkset_audio1
= {
667 .sources
= clkset_audio1_list
,
668 .nr_sources
= ARRAY_SIZE(clkset_audio1_list
),
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
),
684 static struct clk
*clkset_camif_list
[] = {
688 static struct clksrc_sources clkset_camif
= {
689 .sources
= clkset_camif_list
,
690 .nr_sources
= ARRAY_SIZE(clkset_camif_list
),
693 static struct clksrc_clk clksrcs
[] = {
696 .name
= "usb-bus-host",
697 .ctrlbit
= S3C_CLKCON_SCLK_UHOST
,
698 .enable
= s3c64xx_sclk_ctrl
,
700 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 5, .size
= 2 },
701 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 20, .size
= 4 },
702 .sources
= &clkset_uhost
,
706 .devname
= "samsung-i2s.0",
707 .ctrlbit
= S3C_CLKCON_SCLK_AUDIO0
,
708 .enable
= s3c64xx_sclk_ctrl
,
710 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 7, .size
= 3 },
711 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 8, .size
= 4 },
712 .sources
= &clkset_audio0
,
716 .devname
= "samsung-i2s.1",
717 .ctrlbit
= S3C_CLKCON_SCLK_AUDIO1
,
718 .enable
= s3c64xx_sclk_ctrl
,
720 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 10, .size
= 3 },
721 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 12, .size
= 4 },
722 .sources
= &clkset_audio1
,
726 .devname
= "samsung-i2s.2",
727 .ctrlbit
= S3C6410_CLKCON_SCLK_AUDIO2
,
728 .enable
= s3c64xx_sclk_ctrl
,
730 .reg_src
= { .reg
= S3C6410_CLK_SRC2
, .shift
= 0, .size
= 3 },
731 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 24, .size
= 4 },
732 .sources
= &clkset_audio2
,
736 .ctrlbit
= S3C_CLKCON_SCLK_IRDA
,
737 .enable
= s3c64xx_sclk_ctrl
,
739 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 24, .size
= 2 },
740 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 20, .size
= 4 },
741 .sources
= &clkset_irda
,
745 .ctrlbit
= S3C_CLKCON_SCLK_CAM
,
746 .enable
= s3c64xx_sclk_ctrl
,
748 .reg_div
= { .reg
= S3C_CLK_DIV0
, .shift
= 20, .size
= 4 },
749 .reg_src
= { .reg
= NULL
, .shift
= 0, .size
= 0 },
750 .sources
= &clkset_camif
,
754 /* Where does UCLK0 come from? */
755 static struct clksrc_clk clk_sclk_uclk
= {
758 .ctrlbit
= S3C_CLKCON_SCLK_UART
,
759 .enable
= s3c64xx_sclk_ctrl
,
761 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 13, .size
= 1 },
762 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 16, .size
= 4 },
763 .sources
= &clkset_uart
,
766 static struct clksrc_clk clk_sclk_mmc0
= {
769 .devname
= "s3c-sdhci.0",
770 .ctrlbit
= S3C_CLKCON_SCLK_MMC0
,
771 .enable
= s3c64xx_sclk_ctrl
,
773 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 18, .size
= 2 },
774 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 0, .size
= 4 },
775 .sources
= &clkset_spi_mmc
,
778 static struct clksrc_clk clk_sclk_mmc1
= {
781 .devname
= "s3c-sdhci.1",
782 .ctrlbit
= S3C_CLKCON_SCLK_MMC1
,
783 .enable
= s3c64xx_sclk_ctrl
,
785 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 20, .size
= 2 },
786 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 4, .size
= 4 },
787 .sources
= &clkset_spi_mmc
,
790 static struct clksrc_clk clk_sclk_mmc2
= {
793 .devname
= "s3c-sdhci.2",
794 .ctrlbit
= S3C_CLKCON_SCLK_MMC2
,
795 .enable
= s3c64xx_sclk_ctrl
,
797 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 22, .size
= 2 },
798 .reg_div
= { .reg
= S3C_CLK_DIV1
, .shift
= 8, .size
= 4 },
799 .sources
= &clkset_spi_mmc
,
802 static struct clksrc_clk clk_sclk_spi0
= {
805 .devname
= "s3c6410-spi.0",
806 .ctrlbit
= S3C_CLKCON_SCLK_SPI0
,
807 .enable
= s3c64xx_sclk_ctrl
,
809 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 14, .size
= 2 },
810 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 0, .size
= 4 },
811 .sources
= &clkset_spi_mmc
,
814 static struct clksrc_clk clk_sclk_spi1
= {
817 .devname
= "s3c6410-spi.1",
818 .ctrlbit
= S3C_CLKCON_SCLK_SPI1
,
819 .enable
= s3c64xx_sclk_ctrl
,
821 .reg_src
= { .reg
= S3C_CLK_SRC
, .shift
= 16, .size
= 2 },
822 .reg_div
= { .reg
= S3C_CLK_DIV2
, .shift
= 4, .size
= 4 },
823 .sources
= &clkset_spi_mmc
,
826 /* Clock initialisation code */
828 static struct clksrc_clk
*init_parents
[] = {
834 static struct clksrc_clk
*clksrc_cdev
[] = {
843 static struct clk
*clk_cdev
[] = {
851 static struct clk_lookup s3c64xx_clk_lookup
[] = {
852 CLKDEV_INIT(NULL
, "clk_uart_baud2", &clk_p
),
853 CLKDEV_INIT(NULL
, "clk_uart_baud3", &clk_sclk_uclk
.clk
),
854 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &clk_hsmmc0
),
855 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.0", &clk_hsmmc1
),
856 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.0", &clk_hsmmc2
),
857 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0
.clk
),
858 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1
.clk
),
859 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2
.clk
),
860 CLKDEV_INIT(NULL
, "spi_busclk0", &clk_p
),
861 CLKDEV_INIT("s3c6410-spi.0", "spi_busclk1", &clk_sclk_spi0
.clk
),
862 CLKDEV_INIT("s3c6410-spi.0", "spi_busclk2", &clk_48m_spi0
),
863 CLKDEV_INIT("s3c6410-spi.1", "spi_busclk1", &clk_sclk_spi1
.clk
),
864 CLKDEV_INIT("s3c6410-spi.1", "spi_busclk2", &clk_48m_spi1
),
867 #define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1)
869 void __init_or_cpufreq
s3c64xx_setup_clocks(void)
871 struct clk
*xtal_clk
;
883 printk(KERN_DEBUG
"%s: registering clocks\n", __func__
);
885 clkdiv0
= __raw_readl(S3C_CLK_DIV0
);
886 printk(KERN_DEBUG
"%s: clkdiv0 = %08x\n", __func__
, clkdiv0
);
888 xtal_clk
= clk_get(NULL
, "xtal");
889 BUG_ON(IS_ERR(xtal_clk
));
891 xtal
= clk_get_rate(xtal_clk
);
894 printk(KERN_DEBUG
"%s: xtal is %ld\n", __func__
, xtal
);
896 /* For now assume the mux always selects the crystal */
897 clk_ext_xtal_mux
.parent
= xtal_clk
;
899 epll
= s3c_get_pll6553x(xtal
, __raw_readl(S3C_EPLL_CON0
),
900 __raw_readl(S3C_EPLL_CON1
));
901 mpll
= s3c6400_get_pll(xtal
, __raw_readl(S3C_MPLL_CON
));
902 apll
= s3c6400_get_pll(xtal
, __raw_readl(S3C_APLL_CON
));
906 printk(KERN_INFO
"S3C64XX: PLL settings, A=%ld, M=%ld, E=%ld\n",
909 if(__raw_readl(S3C64XX_OTHERS
) & S3C64XX_OTHERS_SYNCMUXSEL
)
910 /* Synchronous mode */
911 hclk2
= apll
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_HCLK2
);
913 /* Asynchronous mode */
914 hclk2
= mpll
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_HCLK2
);
916 hclk
= hclk2
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_HCLK
);
917 pclk
= hclk2
/ GET_DIV(clkdiv0
, S3C6400_CLKDIV0_PCLK
);
919 printk(KERN_INFO
"S3C64XX: HCLK2=%ld, HCLK=%ld, PCLK=%ld\n",
922 clk_fout_mpll
.rate
= mpll
;
923 clk_fout_epll
.rate
= epll
;
924 clk_fout_apll
.rate
= apll
;
931 for (ptr
= 0; ptr
< ARRAY_SIZE(init_parents
); ptr
++)
932 s3c_set_clksrc(init_parents
[ptr
], true);
934 for (ptr
= 0; ptr
< ARRAY_SIZE(clksrcs
); ptr
++)
935 s3c_set_clksrc(&clksrcs
[ptr
], true);
938 static struct clk
*clks1
[] __initdata
= {
950 static struct clk
*clks
[] __initdata
= {
960 * s3c64xx_register_clocks - register clocks for s3c6400 and s3c6410
961 * @xtal: The rate for the clock crystal feeding the PLLs.
962 * @armclk_divlimit: Divisor mask for ARMCLK.
964 * Register the clocks for the S3C6400 and S3C6410 SoC range, such
965 * as ARMCLK as well as the necessary parent clocks.
967 * This call does not setup the clocks, which is left to the
968 * s3c64xx_setup_clocks() call which may be needed by the cpufreq
969 * or resume code to re-set the clocks if the bootloader has changed
972 void __init
s3c64xx_register_clocks(unsigned long xtal
,
973 unsigned armclk_divlimit
)
977 armclk_mask
= armclk_divlimit
;
979 s3c24xx_register_baseclocks(xtal
);
980 s3c24xx_register_clocks(clks
, ARRAY_SIZE(clks
));
982 s3c_register_clocks(init_clocks
, ARRAY_SIZE(init_clocks
));
984 s3c_register_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));
985 s3c_disable_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));
987 s3c24xx_register_clocks(clk_cdev
, ARRAY_SIZE(clk_cdev
));
988 for (cnt
= 0; cnt
< ARRAY_SIZE(clk_cdev
); cnt
++)
989 s3c_disable_clocks(clk_cdev
[cnt
], 1);
991 s3c24xx_register_clocks(clks1
, ARRAY_SIZE(clks1
));
992 s3c_register_clksrc(clksrcs
, ARRAY_SIZE(clksrcs
));
993 for (cnt
= 0; cnt
< ARRAY_SIZE(clksrc_cdev
); cnt
++)
994 s3c_register_clksrc(clksrc_cdev
[cnt
], 1);
995 clkdev_add_table(s3c64xx_clk_lookup
, ARRAY_SIZE(s3c64xx_clk_lookup
));