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/s3c2416.h>
18 #include <plat/s3c2443.h>
19 #include <plat/clock.h>
20 #include <plat/clock-clksrc.h>
23 #include <plat/cpu-freq.h>
24 #include <plat/pll6553x.h>
27 #include <asm/mach/map.h>
29 #include <mach/regs-clock.h>
30 #include <mach/regs-s3c2443-clock.h>
32 static unsigned int armdiv[8] = {
41 static struct clksrc_clk hsspi_eplldiv = {
43 .name = "hsspi-eplldiv",
44 .parent = &clk_esysclk.clk,
46 .enable = s3c2443_clkcon_enable_s,
48 .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 24 },
51 static struct clk *hsspi_sources[] = {
52 [0] = &hsspi_eplldiv.clk,
53 [1] = NULL, /* to fix */
56 static struct clksrc_clk hsspi_mux = {
60 .sources = &(struct clksrc_sources) {
61 .sources = hsspi_sources,
62 .nr_sources = ARRAY_SIZE(hsspi_sources),
64 .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 18 },
67 static struct clksrc_clk hsmmc_div[] = {
71 .devname = "s3c-sdhci.0",
72 .parent = &clk_esysclk.clk,
74 .reg_div = { .reg = S3C2416_CLKDIV2, .size = 2, .shift = 6 },
79 .devname = "s3c-sdhci.1",
80 .parent = &clk_esysclk.clk,
82 .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 6 },
86 static struct clksrc_clk hsmmc_mux[] = {
90 .devname = "s3c-sdhci.0",
92 .enable = s3c2443_clkcon_enable_s,
94 .sources = &(struct clksrc_sources) {
96 .sources = (struct clk *[]) {
97 [0] = &hsmmc_div[0].clk,
98 [1] = NULL, /* to fix */
101 .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 16 },
106 .devname = "s3c-sdhci.1",
107 .ctrlbit = (1 << 12),
108 .enable = s3c2443_clkcon_enable_s,
110 .sources = &(struct clksrc_sources) {
112 .sources = (struct clk *[]) {
113 [0] = &hsmmc_div[1].clk,
114 [1] = NULL, /* to fix */
117 .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 17 },
121 static struct clk hsmmc0_clk = {
123 .devname = "s3c-sdhci.0",
125 .enable = s3c2443_clkcon_enable_h,
126 .ctrlbit = S3C2416_HCLKCON_HSMMC0,
129 static inline unsigned int s3c2416_fclk_div(unsigned long clkcon0)
131 clkcon0 &= 7 << S3C2443_CLKDIV0_ARMDIV_SHIFT;
133 return armdiv[clkcon0 >> S3C2443_CLKDIV0_ARMDIV_SHIFT];
136 void __init_or_cpufreq s3c2416_setup_clocks(void)
138 s3c2443_common_setup_clocks(s3c2416_get_pll, s3c2416_fclk_div);
142 static struct clksrc_clk *clksrcs[] __initdata = {
151 void __init s3c2416_init_clocks(int xtal)
153 u32 epllcon = __raw_readl(S3C2443_EPLLCON);
154 u32 epllcon1 = __raw_readl(S3C2443_EPLLCON+4);
157 /* s3c2416 EPLL compatible with s3c64xx */
158 clk_epll.rate = s3c_get_pll6553x(xtal, epllcon, epllcon1);
160 clk_epll.parent = &clk_epllref.clk;
162 s3c2443_common_init_clocks(xtal, s3c2416_get_pll, s3c2416_fclk_div);
164 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
165 s3c_register_clksrc(clksrcs[ptr], 1);
167 s3c24xx_register_clock(&hsmmc0_clk);