24 #include <plat/clock.h>
64 static struct clk clk_mpllref = {
69 static struct clk *clk_epllref_sources[] = {
81 .sources = clk_epllref_sources,
92 static struct clk *clk_sysclk_sources[] = {
93 [0] = &clk_epllref.
clk,
103 .sources = clk_sysclk_sources,
109 static unsigned long s3c2443_getrate_mdivclk(
struct clk *clk)
117 return parent_rate / (div + 1);
120 static struct clk clk_mdivclk = {
122 .parent = &clk_mpllref,
124 .get_rate = s3c2443_getrate_mdivclk,
128 static struct clk *clk_msysclk_sources[] = {
141 .sources = clk_msysclk_sources,
142 .nr_sources =
ARRAY_SIZE(clk_msysclk_sources),
152 static unsigned long s3c2443_prediv_getrate(
struct clk *clk)
160 return rate / (clkdiv0 + 1);
163 static struct clk clk_prediv = {
165 .parent = &clk_msysclk.
clk,
167 .get_rate = s3c2443_prediv_getrate,
176 static unsigned long s3c2443_hclkdiv_getrate(
struct clk *clk)
183 return rate / (clkdiv0 + 1);
186 static struct clk_ops clk_h_ops = {
187 .get_rate = s3c2443_hclkdiv_getrate,
195 static unsigned long s3c2443_pclkdiv_getrate(
struct clk *clk)
202 return rate / (clkdiv0 + 1);
205 static struct clk_ops clk_p_ops = {
206 .get_rate = s3c2443_pclkdiv_getrate,
215 static unsigned int *armdiv;
216 static int nr_armdiv;
217 static int armdivmask;
219 static unsigned long s3c2443_armclk_roundrate(
struct clk *clk,
231 for (ptr = 0; ptr < nr_armdiv; ptr++) {
235 calc = (parent / div / 1000) * 1000;
236 if (calc <= rate && div < best)
241 return parent / best;
244 static unsigned long s3c2443_armclk_getrate(
struct clk *clk)
247 unsigned long clkcon0;
250 if (!nr_armdiv || !armdivmask)
254 clkcon0 &= armdivmask;
257 return rate / armdiv[
val];
260 static int s3c2443_armclk_setrate(
struct clk *clk,
unsigned long rate)
269 if (!nr_armdiv || !armdivmask)
272 for (ptr = 0; ptr < nr_armdiv; ptr++) {
276 calc = (parent / div / 1000) * 1000;
277 if (calc <= rate && div < best) {
285 unsigned long clkcon0;
288 clkcon0 &= ~armdivmask;
293 return (val == -1) ? -
EINVAL : 0;
296 static struct clk clk_armdiv = {
298 .parent = &clk_msysclk.
clk,
300 .round_rate = s3c2443_armclk_roundrate,
301 .get_rate = s3c2443_armclk_getrate,
302 .set_rate = s3c2443_armclk_setrate,
311 static struct clk *clk_arm_sources[] = {
321 .sources = clk_arm_sources,
334 .name =
"usb-bus-host-parent",
335 .parent = &clk_esysclk.
clk,
348 .name =
"camif-upll",
349 .parent = &clk_esysclk.
clk,
356 .name =
"display-if",
357 .parent = &clk_esysclk.
clk,
369 .parent = &clk_esysclk.
clk,
374 static struct clk clk_i2s_ext = {
386 .name =
"i2s-eplldiv",
387 .parent = &clk_esysclk.
clk,
399 static struct clk *clk_i2s_srclist[] = {
400 [0] = &clk_i2s_eplldiv.
clk,
402 [2] = &clk_epllref.
clk,
403 [3] = &clk_epllref.
clk,
414 .sources = clk_i2s_srclist,
420 static struct clk init_clocks_off[] = {
439 static struct clk init_clocks[] = {
481 .name =
"usb-device",
508 .devname =
"s3c2440-uart.0",
514 .devname =
"s3c2440-uart.1",
520 .devname =
"s3c2440-uart.2",
526 .devname =
"s3c2440-uart.3",
547 .name =
"usb-bus-host",
548 .parent = &clk_usb_bus_host.
clk,
552 static struct clk hsmmc1_clk = {
554 .devname =
"s3c-sdhci.1",
560 static struct clk hsspi_clk = {
562 .devname =
"s3c2443-spi.0",
574 struct clk *xtal_clk;
583 pll = get_mpll(mpllcon, xtal);
584 clk_msysclk.
clk.rate =
pll;
587 printk(
"CPU: MPLL %s %ld.%03ld MHz, cpu %ld.%03ld MHz, mem %ld.%03ld MHz, pclk %ld.%03ld MHz\n",
593 for (ptr = 0; ptr <
ARRAY_SIZE(clksrc_clks); ptr++)
603 printk(
"CPU: EPLL %s %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n",
604 (epllcon & S3C2443_PLLCON_OFF) ?
"off" :
"on",
621 static struct clksrc_clk *clksrcs[] __initdata = {
631 static struct clk_lookup s3c2443_clk_lookup[] = {
635 CLKDEV_INIT(
"s3c-sdhci.1",
"mmc_busclk.0", &hsmmc1_clk),
636 CLKDEV_INIT(
"s3c2443-spi.0",
"spi_busclk0", &hsspi_clk),
640 unsigned int *divs,
int nr_divs,
647 armdivmask = divmask;
650 clk_h.parent = &clk_prediv;
651 clk_h.ops = &clk_h_ops;
655 clk_p.ops = &clk_p_ops;
663 for (ptr = 0; ptr <
ARRAY_SIZE(clksrcs); ptr++)