1 /* linux/arch/arm/mach-s3c2416/clock.c
3 * Copyright (c) 2010 Simtec Electronics
4 * Copyright (c) 2010 Ben Dooks <ben-linux@fluff.org>
6 * S3C2416 Clock control 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 as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/init.h>
15 #include <linux/clk.h>
17 #include <plat/clock.h>
18 #include <plat/clock-clksrc.h>
21 #include <plat/cpu-freq.h>
24 #include <asm/mach/map.h>
26 #include <mach/regs-clock.h>
27 #include <mach/regs-s3c2443-clock.h>
31 * this clock is sourced from msysclk and can have a number of
32 * divider values applied to it to then be fed into armclk.
33 * The real clock definition is done in s3c2443-clock.c,
34 * only the armdiv divisor table must be defined here.
37 static unsigned int armdiv
[8] = {
46 static struct clksrc_clk hsspi_eplldiv
= {
48 .name
= "hsspi-eplldiv",
49 .parent
= &clk_esysclk
.clk
,
51 .enable
= s3c2443_clkcon_enable_s
,
53 .reg_div
= { .reg
= S3C2443_CLKDIV1
, .size
= 2, .shift
= 24 },
56 static struct clk
*hsspi_sources
[] = {
57 [0] = &hsspi_eplldiv
.clk
,
58 [1] = NULL
, /* to fix */
61 static struct clksrc_clk hsspi_mux
= {
65 .sources
= &(struct clksrc_sources
) {
66 .sources
= hsspi_sources
,
67 .nr_sources
= ARRAY_SIZE(hsspi_sources
),
69 .reg_src
= { .reg
= S3C2443_CLKSRC
, .size
= 1, .shift
= 18 },
72 static struct clksrc_clk hsmmc_div
[] = {
76 .devname
= "s3c-sdhci.0",
77 .parent
= &clk_esysclk
.clk
,
79 .reg_div
= { .reg
= S3C2416_CLKDIV2
, .size
= 2, .shift
= 6 },
84 .devname
= "s3c-sdhci.1",
85 .parent
= &clk_esysclk
.clk
,
87 .reg_div
= { .reg
= S3C2443_CLKDIV1
, .size
= 2, .shift
= 6 },
91 static struct clksrc_clk hsmmc_mux0
= {
94 .devname
= "s3c-sdhci.0",
96 .enable
= s3c2443_clkcon_enable_s
,
98 .sources
= &(struct clksrc_sources
) {
100 .sources
= (struct clk
* []) {
101 [0] = &hsmmc_div
[0].clk
,
102 [1] = NULL
, /* to fix */
105 .reg_src
= { .reg
= S3C2443_CLKSRC
, .size
= 1, .shift
= 16 },
108 static struct clksrc_clk hsmmc_mux1
= {
111 .devname
= "s3c-sdhci.1",
112 .ctrlbit
= (1 << 12),
113 .enable
= s3c2443_clkcon_enable_s
,
115 .sources
= &(struct clksrc_sources
) {
117 .sources
= (struct clk
* []) {
118 [0] = &hsmmc_div
[1].clk
,
119 [1] = NULL
, /* to fix */
122 .reg_src
= { .reg
= S3C2443_CLKSRC
, .size
= 1, .shift
= 17 },
125 static struct clk hsmmc0_clk
= {
127 .devname
= "s3c-sdhci.0",
129 .enable
= s3c2443_clkcon_enable_h
,
130 .ctrlbit
= S3C2416_HCLKCON_HSMMC0
,
133 static struct clksrc_clk
*clksrcs
[] __initdata
= {
142 static struct clk_lookup s3c2416_clk_lookup
[] = {
143 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &hsmmc0_clk
),
144 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &hsmmc_mux0
.clk
),
145 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &hsmmc_mux1
.clk
),
146 /* s3c2443-spi.0 is used on s3c2416 and s3c2450 as well */
147 CLKDEV_INIT("s3c2443-spi.0", "spi_busclk2", &hsspi_mux
.clk
),
150 void __init
s3c2416_init_clocks(int xtal
)
152 u32 epllcon
= __raw_readl(S3C2443_EPLLCON
);
153 u32 epllcon1
= __raw_readl(S3C2443_EPLLCON
+4);
156 /* s3c2416 EPLL compatible with s3c64xx */
157 clk_epll
.rate
= s3c_get_pll6553x(xtal
, epllcon
, epllcon1
);
159 clk_epll
.parent
= &clk_epllref
.clk
;
161 s3c2443_common_init_clocks(xtal
, s3c2416_get_pll
,
162 armdiv
, ARRAY_SIZE(armdiv
),
163 S3C2416_CLKDIV0_ARMDIV_MASK
);
165 for (ptr
= 0; ptr
< ARRAY_SIZE(clksrcs
); ptr
++)
166 s3c_register_clksrc(clksrcs
[ptr
], 1);
168 s3c24xx_register_clock(&hsmmc0_clk
);
169 clkdev_add_table(s3c2416_clk_lookup
, ARRAY_SIZE(s3c2416_clk_lookup
));