blob: bfb1917ad0da3b4c41a8c2866151fd312aca0b64 [file] [log] [blame]
Kukjin Kim3109e552010-09-01 15:35:30 +09001/* linux/arch/arm/mach-s5p64x0/clock-s5p6440.c
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P6440 - Clock 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 version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/list.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/sysdev.h>
21#include <linux/io.h>
22
23#include <mach/hardware.h>
24#include <mach/map.h>
25#include <mach/regs-clock.h>
26#include <mach/s5p64x0-clock.h>
27
28#include <plat/cpu-freq.h>
29#include <plat/clock.h>
30#include <plat/cpu.h>
31#include <plat/pll.h>
32#include <plat/s5p-clock.h>
33#include <plat/clock-clksrc.h>
34#include <plat/s5p6440.h>
35
36static u32 epll_div[][5] = {
37 { 36000000, 0, 48, 1, 4 },
38 { 48000000, 0, 32, 1, 3 },
39 { 60000000, 0, 40, 1, 3 },
40 { 72000000, 0, 48, 1, 3 },
41 { 84000000, 0, 28, 1, 2 },
42 { 96000000, 0, 32, 1, 2 },
43 { 32768000, 45264, 43, 1, 4 },
44 { 45158000, 6903, 30, 1, 3 },
45 { 49152000, 50332, 32, 1, 3 },
46 { 67738000, 10398, 45, 1, 3 },
47 { 73728000, 9961, 49, 1, 3 }
48};
49
50static int s5p6440_epll_set_rate(struct clk *clk, unsigned long rate)
51{
52 unsigned int epll_con, epll_con_k;
53 unsigned int i;
54
55 if (clk->rate == rate) /* Return if nothing changed */
56 return 0;
57
58 epll_con = __raw_readl(S5P64X0_EPLL_CON);
59 epll_con_k = __raw_readl(S5P64X0_EPLL_CON_K);
60
61 epll_con_k &= ~(PLL90XX_KDIV_MASK);
62 epll_con &= ~(PLL90XX_MDIV_MASK | PLL90XX_PDIV_MASK | PLL90XX_SDIV_MASK);
63
64 for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
65 if (epll_div[i][0] == rate) {
66 epll_con_k |= (epll_div[i][1] << PLL90XX_KDIV_SHIFT);
67 epll_con |= (epll_div[i][2] << PLL90XX_MDIV_SHIFT) |
68 (epll_div[i][3] << PLL90XX_PDIV_SHIFT) |
69 (epll_div[i][4] << PLL90XX_SDIV_SHIFT);
70 break;
71 }
72 }
73
74 if (i == ARRAY_SIZE(epll_div)) {
75 printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n", __func__);
76 return -EINVAL;
77 }
78
79 __raw_writel(epll_con, S5P64X0_EPLL_CON);
80 __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K);
81
Seungwhan Youn96166742010-10-14 10:39:33 +090082 printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
83 clk->rate, rate);
84
Kukjin Kim3109e552010-09-01 15:35:30 +090085 clk->rate = rate;
86
87 return 0;
88}
89
90static struct clk_ops s5p6440_epll_ops = {
Seungwhan Yound4b34c62010-10-14 10:39:08 +090091 .get_rate = s5p_epll_get_rate,
Kukjin Kim3109e552010-09-01 15:35:30 +090092 .set_rate = s5p6440_epll_set_rate,
93};
94
95static struct clksrc_clk clk_hclk = {
96 .clk = {
97 .name = "clk_hclk",
Kukjin Kim3109e552010-09-01 15:35:30 +090098 .parent = &clk_armclk.clk,
99 },
100 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 8, .size = 4 },
101};
102
103static struct clksrc_clk clk_pclk = {
104 .clk = {
105 .name = "clk_pclk",
Kukjin Kim3109e552010-09-01 15:35:30 +0900106 .parent = &clk_hclk.clk,
107 },
108 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 12, .size = 4 },
109};
110static struct clksrc_clk clk_hclk_low = {
111 .clk = {
112 .name = "clk_hclk_low",
Kukjin Kim3109e552010-09-01 15:35:30 +0900113 },
114 .sources = &clkset_hclk_low,
115 .reg_src = { .reg = S5P64X0_SYS_OTHERS, .shift = 6, .size = 1 },
116 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 8, .size = 4 },
117};
118
119static struct clksrc_clk clk_pclk_low = {
120 .clk = {
121 .name = "clk_pclk_low",
Kukjin Kim3109e552010-09-01 15:35:30 +0900122 .parent = &clk_hclk_low.clk,
123 },
124 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 12, .size = 4 },
125};
126
127/*
128 * The following clocks will be disabled during clock initialization. It is
129 * recommended to keep the following clocks disabled until the driver requests
130 * for enabling the clock.
131 */
Kukjin Kim9f6bb3f2011-01-04 18:12:57 +0900132static struct clk init_clocks_off[] = {
Kukjin Kim3109e552010-09-01 15:35:30 +0900133 {
134 .name = "nand",
Kukjin Kim3109e552010-09-01 15:35:30 +0900135 .parent = &clk_hclk.clk,
136 .enable = s5p64x0_mem_ctrl,
137 .ctrlbit = (1 << 2),
138 }, {
139 .name = "post",
Kukjin Kim3109e552010-09-01 15:35:30 +0900140 .parent = &clk_hclk_low.clk,
141 .enable = s5p64x0_hclk0_ctrl,
142 .ctrlbit = (1 << 5)
143 }, {
144 .name = "2d",
Kukjin Kim3109e552010-09-01 15:35:30 +0900145 .parent = &clk_hclk.clk,
146 .enable = s5p64x0_hclk0_ctrl,
147 .ctrlbit = (1 << 8),
148 }, {
Boojin Kim3091e612011-09-02 09:44:39 +0900149 .name = "dma",
Boojin Kim2213d0c2011-08-18 19:24:55 +0900150 .devname = "dma-pl330",
Seungwhan Younb05d8532010-10-19 18:13:11 +0900151 .parent = &clk_hclk_low.clk,
152 .enable = s5p64x0_hclk0_ctrl,
153 .ctrlbit = (1 << 12),
154 }, {
Kukjin Kim3109e552010-09-01 15:35:30 +0900155 .name = "hsmmc",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900156 .devname = "s3c-sdhci.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900157 .parent = &clk_hclk_low.clk,
158 .enable = s5p64x0_hclk0_ctrl,
159 .ctrlbit = (1 << 17),
160 }, {
161 .name = "hsmmc",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900162 .devname = "s3c-sdhci.1",
Kukjin Kim3109e552010-09-01 15:35:30 +0900163 .parent = &clk_hclk_low.clk,
164 .enable = s5p64x0_hclk0_ctrl,
165 .ctrlbit = (1 << 18),
166 }, {
167 .name = "hsmmc",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900168 .devname = "s3c-sdhci.2",
Kukjin Kim3109e552010-09-01 15:35:30 +0900169 .parent = &clk_hclk_low.clk,
170 .enable = s5p64x0_hclk0_ctrl,
171 .ctrlbit = (1 << 19),
172 }, {
173 .name = "otg",
Kukjin Kim3109e552010-09-01 15:35:30 +0900174 .parent = &clk_hclk_low.clk,
175 .enable = s5p64x0_hclk0_ctrl,
176 .ctrlbit = (1 << 20)
177 }, {
178 .name = "irom",
Kukjin Kim3109e552010-09-01 15:35:30 +0900179 .parent = &clk_hclk.clk,
180 .enable = s5p64x0_hclk0_ctrl,
181 .ctrlbit = (1 << 25),
182 }, {
183 .name = "lcd",
Kukjin Kim3109e552010-09-01 15:35:30 +0900184 .parent = &clk_hclk_low.clk,
185 .enable = s5p64x0_hclk1_ctrl,
186 .ctrlbit = (1 << 1),
187 }, {
188 .name = "hclk_fimgvg",
Kukjin Kim3109e552010-09-01 15:35:30 +0900189 .parent = &clk_hclk.clk,
190 .enable = s5p64x0_hclk1_ctrl,
191 .ctrlbit = (1 << 2),
192 }, {
193 .name = "tsi",
Kukjin Kim3109e552010-09-01 15:35:30 +0900194 .parent = &clk_hclk_low.clk,
195 .enable = s5p64x0_hclk1_ctrl,
196 .ctrlbit = (1 << 0),
197 }, {
198 .name = "watchdog",
Kukjin Kim3109e552010-09-01 15:35:30 +0900199 .parent = &clk_pclk_low.clk,
200 .enable = s5p64x0_pclk_ctrl,
201 .ctrlbit = (1 << 5),
202 }, {
203 .name = "rtc",
Kukjin Kim3109e552010-09-01 15:35:30 +0900204 .parent = &clk_pclk_low.clk,
205 .enable = s5p64x0_pclk_ctrl,
206 .ctrlbit = (1 << 6),
207 }, {
208 .name = "timers",
Kukjin Kim3109e552010-09-01 15:35:30 +0900209 .parent = &clk_pclk_low.clk,
210 .enable = s5p64x0_pclk_ctrl,
211 .ctrlbit = (1 << 7),
212 }, {
213 .name = "pcm",
Kukjin Kim3109e552010-09-01 15:35:30 +0900214 .parent = &clk_pclk_low.clk,
215 .enable = s5p64x0_pclk_ctrl,
216 .ctrlbit = (1 << 8),
217 }, {
218 .name = "adc",
Kukjin Kim3109e552010-09-01 15:35:30 +0900219 .parent = &clk_pclk_low.clk,
220 .enable = s5p64x0_pclk_ctrl,
221 .ctrlbit = (1 << 12),
222 }, {
223 .name = "i2c",
Kukjin Kim3109e552010-09-01 15:35:30 +0900224 .parent = &clk_pclk_low.clk,
225 .enable = s5p64x0_pclk_ctrl,
226 .ctrlbit = (1 << 17),
227 }, {
228 .name = "spi",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900229 .devname = "s3c64xx-spi.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900230 .parent = &clk_pclk_low.clk,
231 .enable = s5p64x0_pclk_ctrl,
232 .ctrlbit = (1 << 21),
233 }, {
234 .name = "spi",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900235 .devname = "s3c64xx-spi.1",
Kukjin Kim3109e552010-09-01 15:35:30 +0900236 .parent = &clk_pclk_low.clk,
237 .enable = s5p64x0_pclk_ctrl,
238 .ctrlbit = (1 << 22),
239 }, {
240 .name = "gps",
Kukjin Kim3109e552010-09-01 15:35:30 +0900241 .parent = &clk_pclk_low.clk,
242 .enable = s5p64x0_pclk_ctrl,
243 .ctrlbit = (1 << 25),
244 }, {
Jassi Brard9a93c32010-11-19 08:49:44 +0900245 .name = "iis",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900246 .devname = "samsung-i2s.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900247 .parent = &clk_pclk_low.clk,
248 .enable = s5p64x0_pclk_ctrl,
249 .ctrlbit = (1 << 26),
250 }, {
251 .name = "dsim",
Kukjin Kim3109e552010-09-01 15:35:30 +0900252 .parent = &clk_pclk_low.clk,
253 .enable = s5p64x0_pclk_ctrl,
254 .ctrlbit = (1 << 28),
255 }, {
256 .name = "etm",
Kukjin Kim3109e552010-09-01 15:35:30 +0900257 .parent = &clk_pclk.clk,
258 .enable = s5p64x0_pclk_ctrl,
259 .ctrlbit = (1 << 29),
260 }, {
261 .name = "dmc0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900262 .parent = &clk_pclk.clk,
263 .enable = s5p64x0_pclk_ctrl,
264 .ctrlbit = (1 << 30),
265 }, {
266 .name = "pclk_fimgvg",
Kukjin Kim3109e552010-09-01 15:35:30 +0900267 .parent = &clk_pclk.clk,
268 .enable = s5p64x0_pclk_ctrl,
269 .ctrlbit = (1 << 31),
270 }, {
271 .name = "sclk_spi_48",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900272 .devname = "s3c64xx-spi.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900273 .parent = &clk_48m,
274 .enable = s5p64x0_sclk_ctrl,
275 .ctrlbit = (1 << 22),
276 }, {
277 .name = "sclk_spi_48",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900278 .devname = "s3c64xx-spi.1",
Kukjin Kim3109e552010-09-01 15:35:30 +0900279 .parent = &clk_48m,
280 .enable = s5p64x0_sclk_ctrl,
281 .ctrlbit = (1 << 23),
282 }, {
283 .name = "mmc_48m",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900284 .devname = "s3c-sdhci.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900285 .parent = &clk_48m,
286 .enable = s5p64x0_sclk_ctrl,
287 .ctrlbit = (1 << 27),
288 }, {
289 .name = "mmc_48m",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900290 .devname = "s3c-sdhci.1",
Kukjin Kim3109e552010-09-01 15:35:30 +0900291 .parent = &clk_48m,
292 .enable = s5p64x0_sclk_ctrl,
293 .ctrlbit = (1 << 28),
294 }, {
295 .name = "mmc_48m",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900296 .devname = "s3c-sdhci.2",
Kukjin Kim3109e552010-09-01 15:35:30 +0900297 .parent = &clk_48m,
298 .enable = s5p64x0_sclk_ctrl,
299 .ctrlbit = (1 << 29),
300 },
301};
302
303/*
304 * The following clocks will be enabled during clock initialization.
305 */
306static struct clk init_clocks[] = {
307 {
308 .name = "intc",
Kukjin Kim3109e552010-09-01 15:35:30 +0900309 .parent = &clk_hclk.clk,
310 .enable = s5p64x0_hclk0_ctrl,
311 .ctrlbit = (1 << 1),
312 }, {
313 .name = "mem",
Kukjin Kim3109e552010-09-01 15:35:30 +0900314 .parent = &clk_hclk.clk,
315 .enable = s5p64x0_hclk0_ctrl,
316 .ctrlbit = (1 << 21),
317 }, {
Kukjin Kim3109e552010-09-01 15:35:30 +0900318 .name = "uart",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900319 .devname = "s3c6400-uart.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900320 .parent = &clk_pclk_low.clk,
321 .enable = s5p64x0_pclk_ctrl,
322 .ctrlbit = (1 << 1),
323 }, {
324 .name = "uart",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900325 .devname = "s3c6400-uart.1",
Kukjin Kim3109e552010-09-01 15:35:30 +0900326 .parent = &clk_pclk_low.clk,
327 .enable = s5p64x0_pclk_ctrl,
328 .ctrlbit = (1 << 2),
329 }, {
330 .name = "uart",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900331 .devname = "s3c6400-uart.2",
Kukjin Kim3109e552010-09-01 15:35:30 +0900332 .parent = &clk_pclk_low.clk,
333 .enable = s5p64x0_pclk_ctrl,
334 .ctrlbit = (1 << 3),
335 }, {
336 .name = "uart",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900337 .devname = "s3c6400-uart.3",
Kukjin Kim3109e552010-09-01 15:35:30 +0900338 .parent = &clk_pclk_low.clk,
339 .enable = s5p64x0_pclk_ctrl,
340 .ctrlbit = (1 << 4),
341 }, {
342 .name = "gpio",
Kukjin Kim3109e552010-09-01 15:35:30 +0900343 .parent = &clk_pclk_low.clk,
344 .enable = s5p64x0_pclk_ctrl,
345 .ctrlbit = (1 << 18),
346 },
347};
348
349static struct clk clk_iis_cd_v40 = {
350 .name = "iis_cdclk_v40",
Kukjin Kim3109e552010-09-01 15:35:30 +0900351};
352
353static struct clk clk_pcm_cd = {
354 .name = "pcm_cdclk",
Kukjin Kim3109e552010-09-01 15:35:30 +0900355};
356
357static struct clk *clkset_group1_list[] = {
358 &clk_mout_epll.clk,
359 &clk_dout_mpll.clk,
360 &clk_fin_epll,
361};
362
363static struct clksrc_sources clkset_group1 = {
364 .sources = clkset_group1_list,
365 .nr_sources = ARRAY_SIZE(clkset_group1_list),
366};
367
368static struct clk *clkset_uart_list[] = {
369 &clk_mout_epll.clk,
370 &clk_dout_mpll.clk,
371};
372
373static struct clksrc_sources clkset_uart = {
374 .sources = clkset_uart_list,
375 .nr_sources = ARRAY_SIZE(clkset_uart_list),
376};
377
378static struct clk *clkset_audio_list[] = {
379 &clk_mout_epll.clk,
380 &clk_dout_mpll.clk,
381 &clk_fin_epll,
382 &clk_iis_cd_v40,
383 &clk_pcm_cd,
384};
385
386static struct clksrc_sources clkset_audio = {
387 .sources = clkset_audio_list,
388 .nr_sources = ARRAY_SIZE(clkset_audio_list),
389};
390
391static struct clksrc_clk clksrcs[] = {
392 {
393 .clk = {
Abhilash Kesavan9af7d942010-12-22 13:31:49 +0900394 .name = "sclk_mmc",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900395 .devname = "s3c-sdhci.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900396 .ctrlbit = (1 << 24),
397 .enable = s5p64x0_sclk_ctrl,
398 },
399 .sources = &clkset_group1,
400 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 18, .size = 2 },
401 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 0, .size = 4 },
402 }, {
403 .clk = {
Abhilash Kesavan9af7d942010-12-22 13:31:49 +0900404 .name = "sclk_mmc",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900405 .devname = "s3c-sdhci.1",
Kukjin Kim3109e552010-09-01 15:35:30 +0900406 .ctrlbit = (1 << 25),
407 .enable = s5p64x0_sclk_ctrl,
408 },
409 .sources = &clkset_group1,
410 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 20, .size = 2 },
411 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 4, .size = 4 },
412 }, {
413 .clk = {
Abhilash Kesavan9af7d942010-12-22 13:31:49 +0900414 .name = "sclk_mmc",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900415 .devname = "s3c-sdhci.2",
Kukjin Kim3109e552010-09-01 15:35:30 +0900416 .ctrlbit = (1 << 26),
417 .enable = s5p64x0_sclk_ctrl,
418 },
419 .sources = &clkset_group1,
420 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 22, .size = 2 },
421 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 8, .size = 4 },
422 }, {
423 .clk = {
Kukjin Kim3109e552010-09-01 15:35:30 +0900424 .name = "sclk_spi",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900425 .devname = "s3c64xx-spi.0",
Kukjin Kim3109e552010-09-01 15:35:30 +0900426 .ctrlbit = (1 << 20),
427 .enable = s5p64x0_sclk_ctrl,
428 },
429 .sources = &clkset_group1,
430 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 14, .size = 2 },
431 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 0, .size = 4 },
432 }, {
433 .clk = {
434 .name = "sclk_spi",
Thomas Abrahamd8b22d22011-06-14 19:12:27 +0900435 .devname = "s3c64xx-spi.1",
Kukjin Kim3109e552010-09-01 15:35:30 +0900436 .ctrlbit = (1 << 21),
437 .enable = s5p64x0_sclk_ctrl,
438 },
439 .sources = &clkset_group1,
440 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 16, .size = 2 },
441 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 4, .size = 4 },
442 }, {
443 .clk = {
444 .name = "sclk_post",
Kukjin Kim3109e552010-09-01 15:35:30 +0900445 .ctrlbit = (1 << 10),
446 .enable = s5p64x0_sclk_ctrl,
447 },
448 .sources = &clkset_group1,
449 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 26, .size = 2 },
450 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 12, .size = 4 },
451 }, {
452 .clk = {
453 .name = "sclk_dispcon",
Kukjin Kim3109e552010-09-01 15:35:30 +0900454 .ctrlbit = (1 << 1),
455 .enable = s5p64x0_sclk1_ctrl,
456 },
457 .sources = &clkset_group1,
458 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 4, .size = 2 },
459 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 0, .size = 4 },
460 }, {
461 .clk = {
462 .name = "sclk_fimgvg",
Kukjin Kim3109e552010-09-01 15:35:30 +0900463 .ctrlbit = (1 << 2),
464 .enable = s5p64x0_sclk1_ctrl,
465 },
466 .sources = &clkset_group1,
467 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 8, .size = 2 },
468 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 4, .size = 4 },
469 }, {
470 .clk = {
471 .name = "sclk_audio2",
Kukjin Kim3109e552010-09-01 15:35:30 +0900472 .ctrlbit = (1 << 11),
473 .enable = s5p64x0_sclk_ctrl,
474 },
475 .sources = &clkset_audio,
476 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 0, .size = 3 },
477 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 24, .size = 4 },
478 },
479};
480
Thomas Abraham0cfb26e2011-10-24 12:08:42 +0200481static struct clksrc_clk clk_sclk_uclk = {
482 .clk = {
483 .name = "uclk1",
484 .ctrlbit = (1 << 5),
485 .enable = s5p64x0_sclk_ctrl,
486 },
487 .sources = &clkset_uart,
488 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 13, .size = 1 },
489 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 16, .size = 4 },
490};
491
Kukjin Kim3109e552010-09-01 15:35:30 +0900492/* Clock initialization code */
493static struct clksrc_clk *sysclks[] = {
494 &clk_mout_apll,
495 &clk_mout_epll,
496 &clk_mout_mpll,
497 &clk_dout_mpll,
498 &clk_armclk,
499 &clk_hclk,
500 &clk_pclk,
501 &clk_hclk_low,
502 &clk_pclk_low,
503};
504
Boojin Kim3091e612011-09-02 09:44:39 +0900505static struct clk dummy_apb_pclk = {
506 .name = "apb_pclk",
507 .id = -1,
508};
509
Thomas Abraham0cfb26e2011-10-24 12:08:42 +0200510static struct clksrc_clk *clksrc_cdev[] = {
511 &clk_sclk_uclk,
512};
513
514static struct clk_lookup s5p6440_clk_lookup[] = {
515 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_pclk_low.clk),
516 CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_sclk_uclk.clk),
517};
518
Kukjin Kim3109e552010-09-01 15:35:30 +0900519void __init_or_cpufreq s5p6440_setup_clocks(void)
520{
521 struct clk *xtal_clk;
522
523 unsigned long xtal;
524 unsigned long fclk;
525 unsigned long hclk;
526 unsigned long hclk_low;
527 unsigned long pclk;
528 unsigned long pclk_low;
529
530 unsigned long apll;
531 unsigned long mpll;
532 unsigned long epll;
533 unsigned int ptr;
534
535 /* Set S5P6440 functions for clk_fout_epll */
536
Seungwhan Yound4b34c62010-10-14 10:39:08 +0900537 clk_fout_epll.enable = s5p_epll_enable;
Kukjin Kim3109e552010-09-01 15:35:30 +0900538 clk_fout_epll.ops = &s5p6440_epll_ops;
539
540 clk_48m.enable = s5p64x0_clk48m_ctrl;
541
542 xtal_clk = clk_get(NULL, "ext_xtal");
543 BUG_ON(IS_ERR(xtal_clk));
544
545 xtal = clk_get_rate(xtal_clk);
546 clk_put(xtal_clk);
547
548 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_APLL_CON), pll_4502);
549 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_MPLL_CON), pll_4502);
550 epll = s5p_get_pll90xx(xtal, __raw_readl(S5P64X0_EPLL_CON),
551 __raw_readl(S5P64X0_EPLL_CON_K));
552
553 clk_fout_apll.rate = apll;
554 clk_fout_mpll.rate = mpll;
555 clk_fout_epll.rate = epll;
556
557 printk(KERN_INFO "S5P6440: PLL settings, A=%ld.%ldMHz, M=%ld.%ldMHz," \
558 " E=%ld.%ldMHz\n",
559 print_mhz(apll), print_mhz(mpll), print_mhz(epll));
560
561 fclk = clk_get_rate(&clk_armclk.clk);
562 hclk = clk_get_rate(&clk_hclk.clk);
563 pclk = clk_get_rate(&clk_pclk.clk);
564 hclk_low = clk_get_rate(&clk_hclk_low.clk);
565 pclk_low = clk_get_rate(&clk_pclk_low.clk);
566
567 printk(KERN_INFO "S5P6440: HCLK=%ld.%ldMHz, HCLK_LOW=%ld.%ldMHz," \
568 " PCLK=%ld.%ldMHz, PCLK_LOW=%ld.%ldMHz\n",
569 print_mhz(hclk), print_mhz(hclk_low),
570 print_mhz(pclk), print_mhz(pclk_low));
571
572 clk_f.rate = fclk;
573 clk_h.rate = hclk;
574 clk_p.rate = pclk;
575
576 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
577 s3c_set_clksrc(&clksrcs[ptr], true);
578}
579
580static struct clk *clks[] __initdata = {
581 &clk_ext,
582 &clk_iis_cd_v40,
583 &clk_pcm_cd,
584};
585
586void __init s5p6440_register_clocks(void)
587{
Kukjin Kim3109e552010-09-01 15:35:30 +0900588 int ptr;
589
590 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
591
592 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
593 s3c_register_clksrc(sysclks[ptr], 1);
594
595 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
596 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
Thomas Abraham0cfb26e2011-10-24 12:08:42 +0200597 for (ptr = 0; ptr < ARRAY_SIZE(clksrc_cdev); ptr++)
598 s3c_register_clksrc(clksrc_cdev[ptr], 1);
Kukjin Kim3109e552010-09-01 15:35:30 +0900599
Kukjin Kim9f6bb3f2011-01-04 18:12:57 +0900600 s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
601 s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
Thomas Abraham0cfb26e2011-10-24 12:08:42 +0200602 clkdev_add_table(s5p6440_clk_lookup, ARRAY_SIZE(s5p6440_clk_lookup));
Kukjin Kim3109e552010-09-01 15:35:30 +0900603
Boojin Kim3091e612011-09-02 09:44:39 +0900604 s3c24xx_register_clock(&dummy_apb_pclk);
605
Kukjin Kim3109e552010-09-01 15:35:30 +0900606 s3c_pwmclk_init();
607}