Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c2443/clock.c |
| 2 | * |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 3 | * Copyright (c) 2007, 2010 Simtec Electronics |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 4 | * Ben Dooks <ben@simtec.co.uk> |
| 5 | * |
| 6 | * S3C2443 Clock control support |
| 7 | * |
| 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. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <linux/init.h> |
Ben Dooks | af337f3 | 2010-04-28 18:03:57 +0900 | [diff] [blame] | 24 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 25 | #include <linux/module.h> |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/list.h> |
| 28 | #include <linux/errno.h> |
| 29 | #include <linux/err.h> |
| 30 | #include <linux/sysdev.h> |
| 31 | #include <linux/clk.h> |
| 32 | #include <linux/mutex.h> |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 33 | #include <linux/serial_core.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 34 | #include <linux/io.h> |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 35 | |
| 36 | #include <asm/mach/map.h> |
| 37 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 38 | #include <mach/hardware.h> |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 39 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 40 | #include <mach/regs-s3c2443-clock.h> |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 41 | |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 42 | #include <plat/cpu-freq.h> |
| 43 | |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 44 | #include <plat/s3c2443.h> |
Ben Dooks | d5120ae | 2008-10-07 23:09:51 +0100 | [diff] [blame] | 45 | #include <plat/clock.h> |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 46 | #include <plat/clock-clksrc.h> |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 47 | #include <plat/cpu.h> |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 48 | |
| 49 | /* We currently have to assume that the system is running |
| 50 | * from the XTPll input, and that all ***REFCLKs are being |
| 51 | * fed from it, as we cannot read the state of OM[4] from |
| 52 | * software. |
| 53 | * |
| 54 | * It would be possible for each board initialisation to |
| 55 | * set the correct muxing at initialisation |
| 56 | */ |
| 57 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 58 | /* clock selections */ |
| 59 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 60 | static struct clk clk_i2s_ext = { |
| 61 | .name = "i2s-ext", |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
Ben Dooks | ba7622a | 2008-07-07 18:12:39 +0100 | [diff] [blame] | 64 | /* armdiv |
| 65 | * |
| 66 | * this clock is sourced from msysclk and can have a number of |
| 67 | * divider values applied to it to then be fed into armclk. |
| 68 | */ |
| 69 | |
Ben Dooks | 41f23a0 | 2010-01-30 11:14:14 +0200 | [diff] [blame] | 70 | /* armdiv divisor table */ |
| 71 | |
| 72 | static unsigned int armdiv[16] = { |
| 73 | [S3C2443_CLKDIV0_ARMDIV_1 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 1, |
| 74 | [S3C2443_CLKDIV0_ARMDIV_2 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 2, |
| 75 | [S3C2443_CLKDIV0_ARMDIV_3 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 3, |
| 76 | [S3C2443_CLKDIV0_ARMDIV_4 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 4, |
| 77 | [S3C2443_CLKDIV0_ARMDIV_6 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 6, |
| 78 | [S3C2443_CLKDIV0_ARMDIV_8 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 8, |
| 79 | [S3C2443_CLKDIV0_ARMDIV_12 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 12, |
| 80 | [S3C2443_CLKDIV0_ARMDIV_16 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 16, |
| 81 | }; |
| 82 | |
| 83 | static inline unsigned int s3c2443_fclk_div(unsigned long clkcon0) |
| 84 | { |
| 85 | clkcon0 &= S3C2443_CLKDIV0_ARMDIV_MASK; |
| 86 | |
| 87 | return armdiv[clkcon0 >> S3C2443_CLKDIV0_ARMDIV_SHIFT]; |
| 88 | } |
| 89 | |
| 90 | static unsigned long s3c2443_armclk_roundrate(struct clk *clk, |
| 91 | unsigned long rate) |
| 92 | { |
| 93 | unsigned long parent = clk_get_rate(clk->parent); |
| 94 | unsigned long calc; |
| 95 | unsigned best = 256; /* bigger than any value */ |
| 96 | unsigned div; |
| 97 | int ptr; |
| 98 | |
| 99 | for (ptr = 0; ptr < ARRAY_SIZE(armdiv); ptr++) { |
| 100 | div = armdiv[ptr]; |
| 101 | calc = parent / div; |
| 102 | if (calc <= rate && div < best) |
| 103 | best = div; |
| 104 | } |
| 105 | |
| 106 | return parent / best; |
| 107 | } |
| 108 | |
| 109 | static int s3c2443_armclk_setrate(struct clk *clk, unsigned long rate) |
| 110 | { |
| 111 | unsigned long parent = clk_get_rate(clk->parent); |
| 112 | unsigned long calc; |
| 113 | unsigned div; |
| 114 | unsigned best = 256; /* bigger than any value */ |
| 115 | int ptr; |
| 116 | int val = -1; |
| 117 | |
| 118 | for (ptr = 0; ptr < ARRAY_SIZE(armdiv); ptr++) { |
| 119 | div = armdiv[ptr]; |
| 120 | calc = parent / div; |
| 121 | if (calc <= rate && div < best) { |
| 122 | best = div; |
| 123 | val = ptr; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | if (val >= 0) { |
| 128 | unsigned long clkcon0; |
| 129 | |
| 130 | clkcon0 = __raw_readl(S3C2443_CLKDIV0); |
| 131 | clkcon0 &= S3C2443_CLKDIV0_ARMDIV_MASK; |
| 132 | clkcon0 |= val << S3C2443_CLKDIV0_ARMDIV_SHIFT; |
| 133 | __raw_writel(clkcon0, S3C2443_CLKDIV0); |
| 134 | } |
| 135 | |
| 136 | return (val == -1) ? -EINVAL : 0; |
| 137 | } |
| 138 | |
Ben Dooks | ba7622a | 2008-07-07 18:12:39 +0100 | [diff] [blame] | 139 | static struct clk clk_armdiv = { |
| 140 | .name = "armdiv", |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 141 | .parent = &clk_msysclk.clk, |
Ben Dooks | 41f23a0 | 2010-01-30 11:14:14 +0200 | [diff] [blame] | 142 | .ops = &(struct clk_ops) { |
| 143 | .round_rate = s3c2443_armclk_roundrate, |
| 144 | .set_rate = s3c2443_armclk_setrate, |
| 145 | }, |
Ben Dooks | ba7622a | 2008-07-07 18:12:39 +0100 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | /* armclk |
| 149 | * |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 150 | * this is the clock fed into the ARM core itself, from armdiv or from hclk. |
Ben Dooks | ba7622a | 2008-07-07 18:12:39 +0100 | [diff] [blame] | 151 | */ |
| 152 | |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 153 | static struct clk *clk_arm_sources[] = { |
| 154 | [0] = &clk_armdiv, |
| 155 | [1] = &clk_h, |
| 156 | }; |
Ben Dooks | ba7622a | 2008-07-07 18:12:39 +0100 | [diff] [blame] | 157 | |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 158 | static struct clksrc_clk clk_arm = { |
| 159 | .clk = { |
| 160 | .name = "armclk", |
Ben Dooks | b3bf41b | 2009-12-01 01:24:37 +0000 | [diff] [blame] | 161 | }, |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 162 | .sources = &(struct clksrc_sources) { |
| 163 | .sources = clk_arm_sources, |
| 164 | .nr_sources = ARRAY_SIZE(clk_arm_sources), |
| 165 | }, |
| 166 | .reg_src = { .reg = S3C2443_CLKDIV0, .size = 1, .shift = 13 }, |
Ben Dooks | ba7622a | 2008-07-07 18:12:39 +0100 | [diff] [blame] | 167 | }; |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 168 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 169 | /* hsspi |
| 170 | * |
| 171 | * high-speed spi clock, sourced from esysclk |
| 172 | */ |
| 173 | |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 174 | static struct clksrc_clk clk_hsspi = { |
| 175 | .clk = { |
| 176 | .name = "hsspi", |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 177 | .parent = &clk_esysclk.clk, |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 178 | .ctrlbit = S3C2443_SCLKCON_HSSPICLK, |
| 179 | .enable = s3c2443_clkcon_enable_s, |
Ben Dooks | b3bf41b | 2009-12-01 01:24:37 +0000 | [diff] [blame] | 180 | }, |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 181 | .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 4 }, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 182 | }; |
| 183 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 184 | |
| 185 | /* clk_hsmcc_div |
| 186 | * |
| 187 | * this clock is sourced from epll, and is fed through a divider, |
| 188 | * to a mux controlled by sclkcon where either it or a extclk can |
| 189 | * be fed to the hsmmc block |
| 190 | */ |
| 191 | |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 192 | static struct clksrc_clk clk_hsmmc_div = { |
| 193 | .clk = { |
| 194 | .name = "hsmmc-div", |
Thomas Abraham | e83626f | 2011-06-14 19:12:26 +0900 | [diff] [blame] | 195 | .devname = "s3c-sdhci.1", |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 196 | .parent = &clk_esysclk.clk, |
Ben Dooks | b3bf41b | 2009-12-01 01:24:37 +0000 | [diff] [blame] | 197 | }, |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 198 | .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 6 }, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 199 | }; |
| 200 | |
| 201 | static int s3c2443_setparent_hsmmc(struct clk *clk, struct clk *parent) |
| 202 | { |
| 203 | unsigned long clksrc = __raw_readl(S3C2443_SCLKCON); |
| 204 | |
| 205 | clksrc &= ~(S3C2443_SCLKCON_HSMMCCLK_EXT | |
| 206 | S3C2443_SCLKCON_HSMMCCLK_EPLL); |
| 207 | |
| 208 | if (parent == &clk_epll) |
| 209 | clksrc |= S3C2443_SCLKCON_HSMMCCLK_EPLL; |
| 210 | else if (parent == &clk_ext) |
| 211 | clksrc |= S3C2443_SCLKCON_HSMMCCLK_EXT; |
| 212 | else |
| 213 | return -EINVAL; |
| 214 | |
| 215 | if (clk->usage > 0) { |
| 216 | __raw_writel(clksrc, S3C2443_SCLKCON); |
| 217 | } |
| 218 | |
| 219 | clk->parent = parent; |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | static int s3c2443_enable_hsmmc(struct clk *clk, int enable) |
| 224 | { |
| 225 | return s3c2443_setparent_hsmmc(clk, clk->parent); |
| 226 | } |
| 227 | |
| 228 | static struct clk clk_hsmmc = { |
| 229 | .name = "hsmmc-if", |
Thomas Abraham | e83626f | 2011-06-14 19:12:26 +0900 | [diff] [blame] | 230 | .devname = "s3c-sdhci.1", |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 231 | .parent = &clk_hsmmc_div.clk, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 232 | .enable = s3c2443_enable_hsmmc, |
Ben Dooks | b3bf41b | 2009-12-01 01:24:37 +0000 | [diff] [blame] | 233 | .ops = &(struct clk_ops) { |
| 234 | .set_parent = s3c2443_setparent_hsmmc, |
| 235 | }, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | /* i2s_eplldiv |
| 239 | * |
Anand Gadiyar | a8cd456 | 2010-05-10 14:51:19 +0530 | [diff] [blame] | 240 | * This clock is the output from the I2S divisor of ESYSCLK, and is separate |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 241 | * from the mux that comes after it (cannot merge into one single clock) |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 242 | */ |
| 243 | |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 244 | static struct clksrc_clk clk_i2s_eplldiv = { |
| 245 | .clk = { |
| 246 | .name = "i2s-eplldiv", |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 247 | .parent = &clk_esysclk.clk, |
Ben Dooks | b3bf41b | 2009-12-01 01:24:37 +0000 | [diff] [blame] | 248 | }, |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 249 | .reg_div = { .reg = S3C2443_CLKDIV1, .size = 4, .shift = 12, }, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 250 | }; |
| 251 | |
| 252 | /* i2s-ref |
| 253 | * |
| 254 | * i2s bus reference clock, selectable from external, esysclk or epllref |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 255 | * |
| 256 | * Note, this used to be two clocks, but was compressed into one. |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 257 | */ |
| 258 | |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 259 | struct clk *clk_i2s_srclist[] = { |
| 260 | [0] = &clk_i2s_eplldiv.clk, |
| 261 | [1] = &clk_i2s_ext, |
| 262 | [2] = &clk_epllref.clk, |
| 263 | [3] = &clk_epllref.clk, |
| 264 | }; |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 265 | |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 266 | static struct clksrc_clk clk_i2s = { |
| 267 | .clk = { |
| 268 | .name = "i2s-if", |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 269 | .ctrlbit = S3C2443_SCLKCON_I2SCLK, |
| 270 | .enable = s3c2443_clkcon_enable_s, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 271 | |
Ben Dooks | b3bf41b | 2009-12-01 01:24:37 +0000 | [diff] [blame] | 272 | }, |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 273 | .sources = &(struct clksrc_sources) { |
| 274 | .sources = clk_i2s_srclist, |
| 275 | .nr_sources = ARRAY_SIZE(clk_i2s_srclist), |
| 276 | }, |
| 277 | .reg_src = { .reg = S3C2443_CLKSRC, .size = 2, .shift = 14 }, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 278 | }; |
| 279 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 280 | /* standard clock definitions */ |
| 281 | |
Ben Dooks | 4e04691 | 2010-04-28 12:58:13 +0900 | [diff] [blame] | 282 | static struct clk init_clocks_off[] = { |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 283 | { |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 284 | .name = "sdi", |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 285 | .parent = &clk_p, |
| 286 | .enable = s3c2443_clkcon_enable_p, |
| 287 | .ctrlbit = S3C2443_PCLKCON_SDI, |
| 288 | }, { |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 289 | .name = "iis", |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 290 | .parent = &clk_p, |
| 291 | .enable = s3c2443_clkcon_enable_p, |
| 292 | .ctrlbit = S3C2443_PCLKCON_IIS, |
| 293 | }, { |
| 294 | .name = "spi", |
Thomas Abraham | e83626f | 2011-06-14 19:12:26 +0900 | [diff] [blame] | 295 | .devname = "s3c2410-spi.0", |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 296 | .parent = &clk_p, |
| 297 | .enable = s3c2443_clkcon_enable_p, |
| 298 | .ctrlbit = S3C2443_PCLKCON_SPI0, |
| 299 | }, { |
| 300 | .name = "spi", |
Thomas Abraham | e83626f | 2011-06-14 19:12:26 +0900 | [diff] [blame] | 301 | .devname = "s3c2410-spi.1", |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 302 | .parent = &clk_p, |
| 303 | .enable = s3c2443_clkcon_enable_p, |
| 304 | .ctrlbit = S3C2443_PCLKCON_SPI1, |
| 305 | } |
| 306 | }; |
| 307 | |
| 308 | static struct clk init_clocks[] = { |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 309 | }; |
| 310 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 311 | /* clocks to add straight away */ |
| 312 | |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 313 | static struct clksrc_clk *clksrcs[] __initdata = { |
Ben Dooks | 4bed36b | 2010-01-30 10:25:49 +0200 | [diff] [blame] | 314 | &clk_arm, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 315 | &clk_i2s_eplldiv, |
| 316 | &clk_i2s, |
| 317 | &clk_hsspi, |
| 318 | &clk_hsmmc_div, |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 319 | }; |
| 320 | |
| 321 | static struct clk *clks[] __initdata = { |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 322 | &clk_hsmmc, |
Ben Dooks | ba7622a | 2008-07-07 18:12:39 +0100 | [diff] [blame] | 323 | &clk_armdiv, |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 324 | }; |
| 325 | |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 326 | void __init_or_cpufreq s3c2443_setup_clocks(void) |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 327 | { |
Ben Dooks | af337f3 | 2010-04-28 18:03:57 +0900 | [diff] [blame] | 328 | s3c2443_common_setup_clocks(s3c2443_get_mpll, s3c2443_fclk_div); |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | void __init s3c2443_init_clocks(int xtal) |
| 332 | { |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 333 | unsigned long epllcon = __raw_readl(S3C2443_EPLLCON); |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 334 | int ptr; |
| 335 | |
Ben Dooks | af337f3 | 2010-04-28 18:03:57 +0900 | [diff] [blame] | 336 | clk_epll.rate = s3c2443_get_epll(epllcon, xtal); |
| 337 | clk_epll.parent = &clk_epllref.clk; |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 338 | |
Ben Dooks | af337f3 | 2010-04-28 18:03:57 +0900 | [diff] [blame] | 339 | s3c2443_common_init_clocks(xtal, s3c2443_get_mpll, s3c2443_fclk_div); |
| 340 | |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 341 | s3c2443_setup_clocks(); |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 342 | |
Ben Dooks | 4e04691 | 2010-04-28 12:58:13 +0900 | [diff] [blame] | 343 | s3c24xx_register_clocks(clks, ARRAY_SIZE(clks)); |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 344 | |
Ben Dooks | 9aa753c | 2010-01-30 09:19:59 +0200 | [diff] [blame] | 345 | for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) |
| 346 | s3c_register_clksrc(clksrcs[ptr], 1); |
| 347 | |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 348 | /* register clocks from clock array */ |
| 349 | |
Ben Dooks | 1d9f13c | 2010-01-06 01:21:38 +0900 | [diff] [blame] | 350 | s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks)); |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 351 | |
| 352 | /* We must be careful disabling the clocks we are not intending to |
Robert P. J. Day | 3a4fa0a | 2007-10-19 23:10:43 +0200 | [diff] [blame] | 353 | * be using at boot time, as subsystems such as the LCD which do |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 354 | * their own DMA requests to the bus can cause the system to lockup |
| 355 | * if they where in the middle of requesting bus access. |
| 356 | * |
| 357 | * Disabling the LCD clock if the LCD is active is very dangerous, |
| 358 | * and therefore the bootloader should be careful to not enable |
| 359 | * the LCD clock if it is not needed. |
| 360 | */ |
| 361 | |
| 362 | /* install (and disable) the clocks we do not need immediately */ |
| 363 | |
Ben Dooks | 4e04691 | 2010-04-28 12:58:13 +0900 | [diff] [blame] | 364 | s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off)); |
| 365 | s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off)); |
Ben Dooks | 9d325f2 | 2008-11-21 10:36:05 +0000 | [diff] [blame] | 366 | |
| 367 | s3c_pwmclk_init(); |
Ben Dooks | e4d06e3 | 2007-02-16 12:12:31 +0100 | [diff] [blame] | 368 | } |