blob: 32146db1f4516abf53c4fc6cc4f3cc0aaeee4c7a [file] [log] [blame]
Changhwan Younc8bef142010-07-27 17:52:39 +09001/* linux/arch/arm/mach-s5pv310/clock.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5PV310 - 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/kernel.h>
14#include <linux/err.h>
15#include <linux/io.h>
16
17#include <plat/cpu-freq.h>
18#include <plat/clock.h>
19#include <plat/cpu.h>
20#include <plat/pll.h>
21#include <plat/s5p-clock.h>
22#include <plat/clock-clksrc.h>
23
24#include <mach/map.h>
25#include <mach/regs-clock.h>
26
27static struct clk clk_sclk_hdmi27m = {
28 .name = "sclk_hdmi27m",
29 .id = -1,
30 .rate = 27000000,
31};
32
Jongpill Leeb99380e2010-08-18 22:16:45 +090033static struct clk clk_sclk_hdmiphy = {
34 .name = "sclk_hdmiphy",
35 .id = -1,
36};
37
38static struct clk clk_sclk_usbphy0 = {
39 .name = "sclk_usbphy0",
40 .id = -1,
41 .rate = 27000000,
42};
43
44static struct clk clk_sclk_usbphy1 = {
45 .name = "sclk_usbphy1",
46 .id = -1,
47};
48
Jongpill Lee37e01722010-08-18 22:33:43 +090049static int s5pv310_clksrc_mask_top_ctrl(struct clk *clk, int enable)
50{
51 return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
52}
53
Jongpill Lee33f469d2010-08-18 22:54:48 +090054static int s5pv310_clksrc_mask_cam_ctrl(struct clk *clk, int enable)
55{
56 return s5p_gatectrl(S5P_CLKSRC_MASK_CAM, clk, enable);
57}
58
59static int s5pv310_clksrc_mask_lcd0_ctrl(struct clk *clk, int enable)
60{
61 return s5p_gatectrl(S5P_CLKSRC_MASK_LCD0, clk, enable);
62}
63
64static int s5pv310_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable)
65{
66 return s5p_gatectrl(S5P_CLKSRC_MASK_LCD1, clk, enable);
67}
68
Jongpill Lee340ea1e2010-08-18 22:39:26 +090069static int s5pv310_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
70{
71 return s5p_gatectrl(S5P_CLKSRC_MASK_FSYS, clk, enable);
72}
73
Jongpill Lee3297c2e2010-08-27 17:53:26 +090074static int s5pv310_clksrc_mask_peril0_ctrl(struct clk *clk, int enable)
75{
76 return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL0, clk, enable);
77}
78
Jongpill Lee33f469d2010-08-18 22:54:48 +090079static int s5pv310_clksrc_mask_peril1_ctrl(struct clk *clk, int enable)
80{
81 return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL1, clk, enable);
82}
83
Jongpill Lee82260bf2010-08-18 22:49:24 +090084static int s5pv310_clk_ip_cam_ctrl(struct clk *clk, int enable)
85{
86 return s5p_gatectrl(S5P_CLKGATE_IP_CAM, clk, enable);
87}
88
89static int s5pv310_clk_ip_image_ctrl(struct clk *clk, int enable)
90{
91 return s5p_gatectrl(S5P_CLKGATE_IP_IMAGE, clk, enable);
92}
93
94static int s5pv310_clk_ip_lcd0_ctrl(struct clk *clk, int enable)
95{
96 return s5p_gatectrl(S5P_CLKGATE_IP_LCD0, clk, enable);
97}
98
99static int s5pv310_clk_ip_lcd1_ctrl(struct clk *clk, int enable)
100{
101 return s5p_gatectrl(S5P_CLKGATE_IP_LCD1, clk, enable);
102}
103
Jongpill Lee340ea1e2010-08-18 22:39:26 +0900104static int s5pv310_clk_ip_fsys_ctrl(struct clk *clk, int enable)
105{
106 return s5p_gatectrl(S5P_CLKGATE_IP_FSYS, clk, enable);
107}
108
Jongpill Lee5a847b42010-08-27 16:50:47 +0900109static int s5pv310_clk_ip_peril_ctrl(struct clk *clk, int enable)
110{
111 return s5p_gatectrl(S5P_CLKGATE_IP_PERIL, clk, enable);
112}
113
Jongpill Lee82260bf2010-08-18 22:49:24 +0900114static int s5pv310_clk_ip_perir_ctrl(struct clk *clk, int enable)
115{
116 return s5p_gatectrl(S5P_CLKGATE_IP_PERIR, clk, enable);
117}
118
Changhwan Younc8bef142010-07-27 17:52:39 +0900119/* Core list of CMU_CPU side */
120
121static struct clksrc_clk clk_mout_apll = {
122 .clk = {
123 .name = "mout_apll",
124 .id = -1,
125 },
126 .sources = &clk_src_apll,
127 .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 0, .size = 1 },
Jongpill Lee3ff31022010-08-18 22:20:31 +0900128};
129
130static struct clksrc_clk clk_sclk_apll = {
131 .clk = {
132 .name = "sclk_apll",
133 .id = -1,
134 .parent = &clk_mout_apll.clk,
135 },
Changhwan Younc8bef142010-07-27 17:52:39 +0900136 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 24, .size = 3 },
137};
138
139static struct clksrc_clk clk_mout_epll = {
140 .clk = {
141 .name = "mout_epll",
142 .id = -1,
143 },
144 .sources = &clk_src_epll,
145 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 4, .size = 1 },
146};
147
148static struct clksrc_clk clk_mout_mpll = {
149 .clk = {
150 .name = "mout_mpll",
151 .id = -1,
152 },
153 .sources = &clk_src_mpll,
154 .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 8, .size = 1 },
155};
156
157static struct clk *clkset_moutcore_list[] = {
Jaecheol Lee8f3b9cf2010-09-18 10:50:46 +0900158 [0] = &clk_mout_apll.clk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900159 [1] = &clk_mout_mpll.clk,
160};
161
162static struct clksrc_sources clkset_moutcore = {
163 .sources = clkset_moutcore_list,
164 .nr_sources = ARRAY_SIZE(clkset_moutcore_list),
165};
166
167static struct clksrc_clk clk_moutcore = {
168 .clk = {
169 .name = "moutcore",
170 .id = -1,
171 },
172 .sources = &clkset_moutcore,
173 .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 16, .size = 1 },
174};
175
176static struct clksrc_clk clk_coreclk = {
177 .clk = {
178 .name = "core_clk",
179 .id = -1,
180 .parent = &clk_moutcore.clk,
181 },
182 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 0, .size = 3 },
183};
184
185static struct clksrc_clk clk_armclk = {
186 .clk = {
187 .name = "armclk",
188 .id = -1,
189 .parent = &clk_coreclk.clk,
190 },
191};
192
193static struct clksrc_clk clk_aclk_corem0 = {
194 .clk = {
195 .name = "aclk_corem0",
196 .id = -1,
197 .parent = &clk_coreclk.clk,
198 },
199 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 },
200};
201
202static struct clksrc_clk clk_aclk_cores = {
203 .clk = {
204 .name = "aclk_cores",
205 .id = -1,
206 .parent = &clk_coreclk.clk,
207 },
208 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 },
209};
210
211static struct clksrc_clk clk_aclk_corem1 = {
212 .clk = {
213 .name = "aclk_corem1",
214 .id = -1,
215 .parent = &clk_coreclk.clk,
216 },
217 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 8, .size = 3 },
218};
219
220static struct clksrc_clk clk_periphclk = {
221 .clk = {
222 .name = "periphclk",
223 .id = -1,
224 .parent = &clk_coreclk.clk,
225 },
226 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 12, .size = 3 },
227};
228
Changhwan Younc8bef142010-07-27 17:52:39 +0900229/* Core list of CMU_CORE side */
230
231static struct clk *clkset_corebus_list[] = {
232 [0] = &clk_mout_mpll.clk,
Jongpill Lee3ff31022010-08-18 22:20:31 +0900233 [1] = &clk_sclk_apll.clk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900234};
235
236static struct clksrc_sources clkset_mout_corebus = {
237 .sources = clkset_corebus_list,
238 .nr_sources = ARRAY_SIZE(clkset_corebus_list),
239};
240
241static struct clksrc_clk clk_mout_corebus = {
242 .clk = {
243 .name = "mout_corebus",
244 .id = -1,
245 },
246 .sources = &clkset_mout_corebus,
247 .reg_src = { .reg = S5P_CLKSRC_CORE, .shift = 4, .size = 1 },
248};
249
250static struct clksrc_clk clk_sclk_dmc = {
251 .clk = {
252 .name = "sclk_dmc",
253 .id = -1,
254 .parent = &clk_mout_corebus.clk,
255 },
256 .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 12, .size = 3 },
257};
258
259static struct clksrc_clk clk_aclk_cored = {
260 .clk = {
261 .name = "aclk_cored",
262 .id = -1,
263 .parent = &clk_sclk_dmc.clk,
264 },
265 .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 16, .size = 3 },
266};
267
268static struct clksrc_clk clk_aclk_corep = {
269 .clk = {
270 .name = "aclk_corep",
271 .id = -1,
272 .parent = &clk_aclk_cored.clk,
273 },
274 .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 20, .size = 3 },
275};
276
277static struct clksrc_clk clk_aclk_acp = {
278 .clk = {
279 .name = "aclk_acp",
280 .id = -1,
281 .parent = &clk_mout_corebus.clk,
282 },
283 .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 0, .size = 3 },
284};
285
286static struct clksrc_clk clk_pclk_acp = {
287 .clk = {
288 .name = "pclk_acp",
289 .id = -1,
290 .parent = &clk_aclk_acp.clk,
291 },
292 .reg_div = { .reg = S5P_CLKDIV_CORE0, .shift = 4, .size = 3 },
293};
294
295/* Core list of CMU_TOP side */
296
297static struct clk *clkset_aclk_top_list[] = {
298 [0] = &clk_mout_mpll.clk,
Jongpill Lee3ff31022010-08-18 22:20:31 +0900299 [1] = &clk_sclk_apll.clk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900300};
301
Kukjin Kim9e235522010-08-18 22:06:02 +0900302static struct clksrc_sources clkset_aclk = {
Changhwan Younc8bef142010-07-27 17:52:39 +0900303 .sources = clkset_aclk_top_list,
304 .nr_sources = ARRAY_SIZE(clkset_aclk_top_list),
305};
306
307static struct clksrc_clk clk_aclk_200 = {
308 .clk = {
309 .name = "aclk_200",
310 .id = -1,
311 },
Kukjin Kim9e235522010-08-18 22:06:02 +0900312 .sources = &clkset_aclk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900313 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 12, .size = 1 },
314 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 0, .size = 3 },
315};
316
Changhwan Younc8bef142010-07-27 17:52:39 +0900317static struct clksrc_clk clk_aclk_100 = {
318 .clk = {
319 .name = "aclk_100",
320 .id = -1,
321 },
Kukjin Kim9e235522010-08-18 22:06:02 +0900322 .sources = &clkset_aclk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900323 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 16, .size = 1 },
324 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 4, .size = 4 },
325};
326
Changhwan Younc8bef142010-07-27 17:52:39 +0900327static struct clksrc_clk clk_aclk_160 = {
328 .clk = {
329 .name = "aclk_160",
330 .id = -1,
331 },
Kukjin Kim9e235522010-08-18 22:06:02 +0900332 .sources = &clkset_aclk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900333 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 20, .size = 1 },
334 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 8, .size = 3 },
335};
336
Changhwan Younc8bef142010-07-27 17:52:39 +0900337static struct clksrc_clk clk_aclk_133 = {
338 .clk = {
339 .name = "aclk_133",
340 .id = -1,
341 },
Kukjin Kim9e235522010-08-18 22:06:02 +0900342 .sources = &clkset_aclk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900343 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 24, .size = 1 },
344 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 12, .size = 3 },
345};
346
347static struct clk *clkset_vpllsrc_list[] = {
348 [0] = &clk_fin_vpll,
349 [1] = &clk_sclk_hdmi27m,
350};
351
352static struct clksrc_sources clkset_vpllsrc = {
353 .sources = clkset_vpllsrc_list,
354 .nr_sources = ARRAY_SIZE(clkset_vpllsrc_list),
355};
356
357static struct clksrc_clk clk_vpllsrc = {
358 .clk = {
359 .name = "vpll_src",
360 .id = -1,
Jongpill Lee37e01722010-08-18 22:33:43 +0900361 .enable = s5pv310_clksrc_mask_top_ctrl,
362 .ctrlbit = (1 << 0),
Changhwan Younc8bef142010-07-27 17:52:39 +0900363 },
364 .sources = &clkset_vpllsrc,
365 .reg_src = { .reg = S5P_CLKSRC_TOP1, .shift = 0, .size = 1 },
366};
367
368static struct clk *clkset_sclk_vpll_list[] = {
369 [0] = &clk_vpllsrc.clk,
370 [1] = &clk_fout_vpll,
371};
372
373static struct clksrc_sources clkset_sclk_vpll = {
374 .sources = clkset_sclk_vpll_list,
375 .nr_sources = ARRAY_SIZE(clkset_sclk_vpll_list),
376};
377
378static struct clksrc_clk clk_sclk_vpll = {
379 .clk = {
380 .name = "sclk_vpll",
381 .id = -1,
382 },
383 .sources = &clkset_sclk_vpll,
384 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 8, .size = 1 },
385};
386
Changhwan Younc8bef142010-07-27 17:52:39 +0900387static struct clk init_clocks_disable[] = {
388 {
389 .name = "timers",
390 .id = -1,
391 .parent = &clk_aclk_100.clk,
392 .enable = s5pv310_clk_ip_peril_ctrl,
393 .ctrlbit = (1<<24),
Jongpill Lee340ea1e2010-08-18 22:39:26 +0900394 }, {
Jongpill Lee82260bf2010-08-18 22:49:24 +0900395 .name = "csis",
396 .id = 0,
397 .enable = s5pv310_clk_ip_cam_ctrl,
398 .ctrlbit = (1 << 4),
399 }, {
400 .name = "csis",
401 .id = 1,
402 .enable = s5pv310_clk_ip_cam_ctrl,
403 .ctrlbit = (1 << 5),
404 }, {
405 .name = "fimc",
406 .id = 0,
407 .enable = s5pv310_clk_ip_cam_ctrl,
408 .ctrlbit = (1 << 0),
409 }, {
410 .name = "fimc",
411 .id = 1,
412 .enable = s5pv310_clk_ip_cam_ctrl,
413 .ctrlbit = (1 << 1),
414 }, {
415 .name = "fimc",
416 .id = 2,
417 .enable = s5pv310_clk_ip_cam_ctrl,
418 .ctrlbit = (1 << 2),
419 }, {
420 .name = "fimc",
421 .id = 3,
422 .enable = s5pv310_clk_ip_cam_ctrl,
423 .ctrlbit = (1 << 3),
424 }, {
425 .name = "fimd",
426 .id = 0,
427 .enable = s5pv310_clk_ip_lcd0_ctrl,
428 .ctrlbit = (1 << 0),
429 }, {
430 .name = "fimd",
431 .id = 1,
432 .enable = s5pv310_clk_ip_lcd1_ctrl,
433 .ctrlbit = (1 << 0),
434 }, {
Jongpill Lee340ea1e2010-08-18 22:39:26 +0900435 .name = "hsmmc",
436 .id = 0,
437 .parent = &clk_aclk_133.clk,
438 .enable = s5pv310_clk_ip_fsys_ctrl,
439 .ctrlbit = (1 << 5),
440 }, {
441 .name = "hsmmc",
442 .id = 1,
443 .parent = &clk_aclk_133.clk,
444 .enable = s5pv310_clk_ip_fsys_ctrl,
445 .ctrlbit = (1 << 6),
446 }, {
447 .name = "hsmmc",
448 .id = 2,
449 .parent = &clk_aclk_133.clk,
450 .enable = s5pv310_clk_ip_fsys_ctrl,
451 .ctrlbit = (1 << 7),
452 }, {
453 .name = "hsmmc",
454 .id = 3,
455 .parent = &clk_aclk_133.clk,
456 .enable = s5pv310_clk_ip_fsys_ctrl,
457 .ctrlbit = (1 << 8),
458 }, {
459 .name = "hsmmc",
460 .id = 4,
461 .parent = &clk_aclk_133.clk,
462 .enable = s5pv310_clk_ip_fsys_ctrl,
463 .ctrlbit = (1 << 9),
Jongpill Lee82260bf2010-08-18 22:49:24 +0900464 }, {
465 .name = "sata",
466 .id = -1,
467 .enable = s5pv310_clk_ip_fsys_ctrl,
468 .ctrlbit = (1 << 10),
469 }, {
470 .name = "adc",
471 .id = -1,
472 .enable = s5pv310_clk_ip_peril_ctrl,
473 .ctrlbit = (1 << 15),
474 }, {
475 .name = "watchdog",
476 .id = -1,
477 .enable = s5pv310_clk_ip_perir_ctrl,
478 .ctrlbit = (1 << 14),
479 }, {
480 .name = "usbhost",
481 .id = -1,
482 .enable = s5pv310_clk_ip_fsys_ctrl ,
483 .ctrlbit = (1 << 12),
484 }, {
485 .name = "otg",
486 .id = -1,
487 .enable = s5pv310_clk_ip_fsys_ctrl,
488 .ctrlbit = (1 << 13),
489 }, {
490 .name = "spi",
491 .id = 0,
492 .enable = s5pv310_clk_ip_peril_ctrl,
493 .ctrlbit = (1 << 16),
494 }, {
495 .name = "spi",
496 .id = 1,
497 .enable = s5pv310_clk_ip_peril_ctrl,
498 .ctrlbit = (1 << 17),
499 }, {
500 .name = "spi",
501 .id = 2,
502 .enable = s5pv310_clk_ip_peril_ctrl,
503 .ctrlbit = (1 << 18),
504 }, {
505 .name = "fimg2d",
506 .id = -1,
507 .enable = s5pv310_clk_ip_image_ctrl,
508 .ctrlbit = (1 << 0),
509 }, {
510 .name = "i2c",
511 .id = 0,
512 .parent = &clk_aclk_100.clk,
513 .enable = s5pv310_clk_ip_peril_ctrl,
514 .ctrlbit = (1 << 6),
515 }, {
516 .name = "i2c",
517 .id = 1,
518 .parent = &clk_aclk_100.clk,
519 .enable = s5pv310_clk_ip_peril_ctrl,
520 .ctrlbit = (1 << 7),
521 }, {
522 .name = "i2c",
523 .id = 2,
524 .parent = &clk_aclk_100.clk,
525 .enable = s5pv310_clk_ip_peril_ctrl,
526 .ctrlbit = (1 << 8),
527 }, {
528 .name = "i2c",
529 .id = 3,
530 .parent = &clk_aclk_100.clk,
531 .enable = s5pv310_clk_ip_peril_ctrl,
532 .ctrlbit = (1 << 9),
533 }, {
534 .name = "i2c",
535 .id = 4,
536 .parent = &clk_aclk_100.clk,
537 .enable = s5pv310_clk_ip_peril_ctrl,
538 .ctrlbit = (1 << 10),
539 }, {
540 .name = "i2c",
541 .id = 5,
542 .parent = &clk_aclk_100.clk,
543 .enable = s5pv310_clk_ip_peril_ctrl,
544 .ctrlbit = (1 << 11),
545 }, {
546 .name = "i2c",
547 .id = 6,
548 .parent = &clk_aclk_100.clk,
549 .enable = s5pv310_clk_ip_peril_ctrl,
550 .ctrlbit = (1 << 12),
551 }, {
552 .name = "i2c",
553 .id = 7,
554 .parent = &clk_aclk_100.clk,
555 .enable = s5pv310_clk_ip_peril_ctrl,
556 .ctrlbit = (1 << 13),
557 },
Changhwan Younc8bef142010-07-27 17:52:39 +0900558};
559
560static struct clk init_clocks[] = {
Jongpill Lee5a847b42010-08-27 16:50:47 +0900561 {
562 .name = "uart",
563 .id = 0,
564 .enable = s5pv310_clk_ip_peril_ctrl,
565 .ctrlbit = (1 << 0),
566 }, {
567 .name = "uart",
568 .id = 1,
569 .enable = s5pv310_clk_ip_peril_ctrl,
570 .ctrlbit = (1 << 1),
571 }, {
572 .name = "uart",
573 .id = 2,
574 .enable = s5pv310_clk_ip_peril_ctrl,
575 .ctrlbit = (1 << 2),
576 }, {
577 .name = "uart",
578 .id = 3,
579 .enable = s5pv310_clk_ip_peril_ctrl,
580 .ctrlbit = (1 << 3),
581 }, {
582 .name = "uart",
583 .id = 4,
584 .enable = s5pv310_clk_ip_peril_ctrl,
585 .ctrlbit = (1 << 4),
586 }, {
587 .name = "uart",
588 .id = 5,
589 .enable = s5pv310_clk_ip_peril_ctrl,
590 .ctrlbit = (1 << 5),
591 }
Changhwan Younc8bef142010-07-27 17:52:39 +0900592};
593
594static struct clk *clkset_group_list[] = {
595 [0] = &clk_ext_xtal_mux,
596 [1] = &clk_xusbxti,
597 [2] = &clk_sclk_hdmi27m,
Jongpill Leeb99380e2010-08-18 22:16:45 +0900598 [3] = &clk_sclk_usbphy0,
599 [4] = &clk_sclk_usbphy1,
600 [5] = &clk_sclk_hdmiphy,
Changhwan Younc8bef142010-07-27 17:52:39 +0900601 [6] = &clk_mout_mpll.clk,
602 [7] = &clk_mout_epll.clk,
603 [8] = &clk_sclk_vpll.clk,
604};
605
606static struct clksrc_sources clkset_group = {
607 .sources = clkset_group_list,
608 .nr_sources = ARRAY_SIZE(clkset_group_list),
609};
610
Jongpill Lee06cba8d2010-08-18 22:51:23 +0900611static struct clk *clkset_mout_g2d0_list[] = {
612 [0] = &clk_mout_mpll.clk,
613 [1] = &clk_sclk_apll.clk,
614};
615
616static struct clksrc_sources clkset_mout_g2d0 = {
617 .sources = clkset_mout_g2d0_list,
618 .nr_sources = ARRAY_SIZE(clkset_mout_g2d0_list),
619};
620
621static struct clksrc_clk clk_mout_g2d0 = {
622 .clk = {
623 .name = "mout_g2d0",
624 .id = -1,
625 },
626 .sources = &clkset_mout_g2d0,
627 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 0, .size = 1 },
628};
629
630static struct clk *clkset_mout_g2d1_list[] = {
631 [0] = &clk_mout_epll.clk,
632 [1] = &clk_sclk_vpll.clk,
633};
634
635static struct clksrc_sources clkset_mout_g2d1 = {
636 .sources = clkset_mout_g2d1_list,
637 .nr_sources = ARRAY_SIZE(clkset_mout_g2d1_list),
638};
639
640static struct clksrc_clk clk_mout_g2d1 = {
641 .clk = {
642 .name = "mout_g2d1",
643 .id = -1,
644 },
645 .sources = &clkset_mout_g2d1,
646 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 4, .size = 1 },
647};
648
649static struct clk *clkset_mout_g2d_list[] = {
650 [0] = &clk_mout_g2d0.clk,
651 [1] = &clk_mout_g2d1.clk,
652};
653
654static struct clksrc_sources clkset_mout_g2d = {
655 .sources = clkset_mout_g2d_list,
656 .nr_sources = ARRAY_SIZE(clkset_mout_g2d_list),
657};
658
Jongpill Lee340ea1e2010-08-18 22:39:26 +0900659static struct clksrc_clk clk_dout_mmc0 = {
660 .clk = {
661 .name = "dout_mmc0",
662 .id = -1,
663 },
664 .sources = &clkset_group,
665 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 0, .size = 4 },
666 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 0, .size = 4 },
667};
668
669static struct clksrc_clk clk_dout_mmc1 = {
670 .clk = {
671 .name = "dout_mmc1",
672 .id = -1,
673 },
674 .sources = &clkset_group,
675 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 4, .size = 4 },
676 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 16, .size = 4 },
677};
678
679static struct clksrc_clk clk_dout_mmc2 = {
680 .clk = {
681 .name = "dout_mmc2",
682 .id = -1,
683 },
684 .sources = &clkset_group,
685 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 8, .size = 4 },
686 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 0, .size = 4 },
687};
688
689static struct clksrc_clk clk_dout_mmc3 = {
690 .clk = {
691 .name = "dout_mmc3",
692 .id = -1,
693 },
694 .sources = &clkset_group,
695 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 12, .size = 4 },
696 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 16, .size = 4 },
697};
698
699static struct clksrc_clk clk_dout_mmc4 = {
700 .clk = {
701 .name = "dout_mmc4",
702 .id = -1,
703 },
704 .sources = &clkset_group,
705 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 16, .size = 4 },
706 .reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 0, .size = 4 },
707};
708
Changhwan Younc8bef142010-07-27 17:52:39 +0900709static struct clksrc_clk clksrcs[] = {
710 {
711 .clk = {
712 .name = "uclk1",
713 .id = 0,
Jongpill Lee3297c2e2010-08-27 17:53:26 +0900714 .enable = s5pv310_clksrc_mask_peril0_ctrl,
Jongpill Lee5a847b42010-08-27 16:50:47 +0900715 .ctrlbit = (1 << 0),
Changhwan Younc8bef142010-07-27 17:52:39 +0900716 },
717 .sources = &clkset_group,
718 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 0, .size = 4 },
719 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 0, .size = 4 },
720 }, {
721 .clk = {
722 .name = "uclk1",
723 .id = 1,
Jongpill Lee3297c2e2010-08-27 17:53:26 +0900724 .enable = s5pv310_clksrc_mask_peril0_ctrl,
725 .ctrlbit = (1 << 4),
Changhwan Younc8bef142010-07-27 17:52:39 +0900726 },
727 .sources = &clkset_group,
728 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 4, .size = 4 },
729 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 4, .size = 4 },
730 }, {
731 .clk = {
732 .name = "uclk1",
733 .id = 2,
Jongpill Lee3297c2e2010-08-27 17:53:26 +0900734 .enable = s5pv310_clksrc_mask_peril0_ctrl,
735 .ctrlbit = (1 << 8),
Changhwan Younc8bef142010-07-27 17:52:39 +0900736 },
737 .sources = &clkset_group,
738 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 8, .size = 4 },
739 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 8, .size = 4 },
740 }, {
741 .clk = {
742 .name = "uclk1",
743 .id = 3,
Jongpill Lee3297c2e2010-08-27 17:53:26 +0900744 .enable = s5pv310_clksrc_mask_peril0_ctrl,
745 .ctrlbit = (1 << 12),
Changhwan Younc8bef142010-07-27 17:52:39 +0900746 },
747 .sources = &clkset_group,
748 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 12, .size = 4 },
749 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 12, .size = 4 },
750 }, {
751 .clk = {
752 .name = "sclk_pwm",
753 .id = -1,
Jongpill Lee3297c2e2010-08-27 17:53:26 +0900754 .enable = s5pv310_clksrc_mask_peril0_ctrl,
Changhwan Younc8bef142010-07-27 17:52:39 +0900755 .ctrlbit = (1 << 24),
756 },
757 .sources = &clkset_group,
758 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 24, .size = 4 },
759 .reg_div = { .reg = S5P_CLKDIV_PERIL3, .shift = 0, .size = 4 },
Jongpill Lee340ea1e2010-08-18 22:39:26 +0900760 }, {
761 .clk = {
Jongpill Lee33f469d2010-08-18 22:54:48 +0900762 .name = "sclk_csis",
763 .id = 0,
764 .enable = s5pv310_clksrc_mask_cam_ctrl,
765 .ctrlbit = (1 << 24),
766 },
767 .sources = &clkset_group,
768 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 24, .size = 4 },
769 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 24, .size = 4 },
770 }, {
771 .clk = {
772 .name = "sclk_csis",
773 .id = 1,
774 .enable = s5pv310_clksrc_mask_cam_ctrl,
775 .ctrlbit = (1 << 28),
776 },
777 .sources = &clkset_group,
778 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 28, .size = 4 },
779 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 28, .size = 4 },
780 }, {
781 .clk = {
782 .name = "sclk_cam",
783 .id = 0,
784 .enable = s5pv310_clksrc_mask_cam_ctrl,
785 .ctrlbit = (1 << 16),
786 },
787 .sources = &clkset_group,
788 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 16, .size = 4 },
789 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 16, .size = 4 },
790 }, {
791 .clk = {
792 .name = "sclk_cam",
793 .id = 1,
794 .enable = s5pv310_clksrc_mask_cam_ctrl,
795 .ctrlbit = (1 << 20),
796 },
797 .sources = &clkset_group,
798 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 20, .size = 4 },
799 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 20, .size = 4 },
800 }, {
801 .clk = {
802 .name = "sclk_fimc",
803 .id = 0,
804 .enable = s5pv310_clksrc_mask_cam_ctrl,
805 .ctrlbit = (1 << 0),
806 },
807 .sources = &clkset_group,
808 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 0, .size = 4 },
809 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 0, .size = 4 },
810 }, {
811 .clk = {
812 .name = "sclk_fimc",
813 .id = 1,
814 .enable = s5pv310_clksrc_mask_cam_ctrl,
815 .ctrlbit = (1 << 4),
816 },
817 .sources = &clkset_group,
818 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 4, .size = 4 },
819 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 4, .size = 4 },
820 }, {
821 .clk = {
822 .name = "sclk_fimc",
823 .id = 2,
824 .enable = s5pv310_clksrc_mask_cam_ctrl,
825 .ctrlbit = (1 << 8),
826 },
827 .sources = &clkset_group,
828 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 8, .size = 4 },
829 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 8, .size = 4 },
830 }, {
831 .clk = {
832 .name = "sclk_fimc",
833 .id = 3,
834 .enable = s5pv310_clksrc_mask_cam_ctrl,
835 .ctrlbit = (1 << 12),
836 },
837 .sources = &clkset_group,
838 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 12, .size = 4 },
839 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 12, .size = 4 },
840 }, {
841 .clk = {
842 .name = "sclk_fimd",
843 .id = 0,
844 .enable = s5pv310_clksrc_mask_lcd0_ctrl,
845 .ctrlbit = (1 << 0),
846 },
847 .sources = &clkset_group,
848 .reg_src = { .reg = S5P_CLKSRC_LCD0, .shift = 0, .size = 4 },
849 .reg_div = { .reg = S5P_CLKDIV_LCD0, .shift = 0, .size = 4 },
850 }, {
851 .clk = {
852 .name = "sclk_fimd",
853 .id = 1,
854 .enable = s5pv310_clksrc_mask_lcd1_ctrl,
855 .ctrlbit = (1 << 0),
856 },
857 .sources = &clkset_group,
858 .reg_src = { .reg = S5P_CLKSRC_LCD1, .shift = 0, .size = 4 },
859 .reg_div = { .reg = S5P_CLKDIV_LCD1, .shift = 0, .size = 4 },
860 }, {
861 .clk = {
862 .name = "sclk_sata",
863 .id = -1,
864 .enable = s5pv310_clksrc_mask_fsys_ctrl,
865 .ctrlbit = (1 << 24),
866 },
867 .sources = &clkset_mout_corebus,
868 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 24, .size = 1 },
869 .reg_div = { .reg = S5P_CLKDIV_FSYS0, .shift = 20, .size = 4 },
870 }, {
871 .clk = {
872 .name = "sclk_spi",
873 .id = 0,
874 .enable = s5pv310_clksrc_mask_peril1_ctrl,
875 .ctrlbit = (1 << 16),
876 },
877 .sources = &clkset_group,
878 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 16, .size = 4 },
879 .reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 0, .size = 4 },
880 }, {
881 .clk = {
882 .name = "sclk_spi",
883 .id = 1,
884 .enable = s5pv310_clksrc_mask_peril1_ctrl,
885 .ctrlbit = (1 << 20),
886 },
887 .sources = &clkset_group,
888 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 20, .size = 4 },
889 .reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 16, .size = 4 },
890 }, {
891 .clk = {
892 .name = "sclk_spi",
893 .id = 2,
894 .enable = s5pv310_clksrc_mask_peril1_ctrl,
895 .ctrlbit = (1 << 24),
896 },
897 .sources = &clkset_group,
898 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 24, .size = 4 },
899 .reg_div = { .reg = S5P_CLKDIV_PERIL2, .shift = 0, .size = 4 },
900 }, {
901 .clk = {
902 .name = "sclk_fimg2d",
903 .id = -1,
904 },
905 .sources = &clkset_mout_g2d,
906 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 8, .size = 1 },
907 .reg_div = { .reg = S5P_CLKDIV_IMAGE, .shift = 0, .size = 4 },
908 }, {
909 .clk = {
Jongpill Lee340ea1e2010-08-18 22:39:26 +0900910 .name = "sclk_mmc",
911 .id = 0,
912 .parent = &clk_dout_mmc0.clk,
913 .enable = s5pv310_clksrc_mask_fsys_ctrl,
914 .ctrlbit = (1 << 0),
915 },
916 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 8, .size = 8 },
917 }, {
918 .clk = {
919 .name = "sclk_mmc",
920 .id = 1,
921 .parent = &clk_dout_mmc1.clk,
922 .enable = s5pv310_clksrc_mask_fsys_ctrl,
923 .ctrlbit = (1 << 4),
924 },
925 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 24, .size = 8 },
926 }, {
927 .clk = {
928 .name = "sclk_mmc",
929 .id = 2,
930 .parent = &clk_dout_mmc2.clk,
931 .enable = s5pv310_clksrc_mask_fsys_ctrl,
932 .ctrlbit = (1 << 8),
933 },
934 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 8, .size = 8 },
935 }, {
936 .clk = {
937 .name = "sclk_mmc",
938 .id = 3,
939 .parent = &clk_dout_mmc3.clk,
940 .enable = s5pv310_clksrc_mask_fsys_ctrl,
941 .ctrlbit = (1 << 12),
942 },
943 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 24, .size = 8 },
944 }, {
945 .clk = {
946 .name = "sclk_mmc",
947 .id = 4,
948 .parent = &clk_dout_mmc4.clk,
949 .enable = s5pv310_clksrc_mask_fsys_ctrl,
950 .ctrlbit = (1 << 16),
951 },
952 .reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 8, .size = 8 },
953 }
Changhwan Younc8bef142010-07-27 17:52:39 +0900954};
955
956/* Clock initialization code */
957static struct clksrc_clk *sysclks[] = {
958 &clk_mout_apll,
Jongpill Lee3ff31022010-08-18 22:20:31 +0900959 &clk_sclk_apll,
Changhwan Younc8bef142010-07-27 17:52:39 +0900960 &clk_mout_epll,
961 &clk_mout_mpll,
962 &clk_moutcore,
963 &clk_coreclk,
964 &clk_armclk,
965 &clk_aclk_corem0,
966 &clk_aclk_cores,
967 &clk_aclk_corem1,
968 &clk_periphclk,
Changhwan Younc8bef142010-07-27 17:52:39 +0900969 &clk_mout_corebus,
970 &clk_sclk_dmc,
971 &clk_aclk_cored,
972 &clk_aclk_corep,
973 &clk_aclk_acp,
974 &clk_pclk_acp,
975 &clk_vpllsrc,
976 &clk_sclk_vpll,
977 &clk_aclk_200,
978 &clk_aclk_100,
979 &clk_aclk_160,
980 &clk_aclk_133,
Jongpill Lee340ea1e2010-08-18 22:39:26 +0900981 &clk_dout_mmc0,
982 &clk_dout_mmc1,
983 &clk_dout_mmc2,
984 &clk_dout_mmc3,
985 &clk_dout_mmc4,
Changhwan Younc8bef142010-07-27 17:52:39 +0900986};
987
988void __init_or_cpufreq s5pv310_setup_clocks(void)
989{
990 struct clk *xtal_clk;
991 unsigned long apll;
992 unsigned long mpll;
993 unsigned long epll;
994 unsigned long vpll;
995 unsigned long vpllsrc;
996 unsigned long xtal;
997 unsigned long armclk;
Changhwan Younc8bef142010-07-27 17:52:39 +0900998 unsigned long sclk_dmc;
Jongpill Lee228ef982010-08-18 22:24:53 +0900999 unsigned long aclk_200;
1000 unsigned long aclk_100;
1001 unsigned long aclk_160;
1002 unsigned long aclk_133;
Changhwan Younc8bef142010-07-27 17:52:39 +09001003 unsigned int ptr;
1004
1005 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
1006
1007 xtal_clk = clk_get(NULL, "xtal");
1008 BUG_ON(IS_ERR(xtal_clk));
1009
1010 xtal = clk_get_rate(xtal_clk);
1011 clk_put(xtal_clk);
1012
1013 printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
1014
1015 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON0), pll_4508);
1016 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON0), pll_4508);
1017 epll = s5p_get_pll46xx(xtal, __raw_readl(S5P_EPLL_CON0),
Jongpill Lee4d235f792010-08-18 22:13:49 +09001018 __raw_readl(S5P_EPLL_CON1), pll_4600);
Changhwan Younc8bef142010-07-27 17:52:39 +09001019
1020 vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
1021 vpll = s5p_get_pll46xx(vpllsrc, __raw_readl(S5P_VPLL_CON0),
Jongpill Lee4d235f792010-08-18 22:13:49 +09001022 __raw_readl(S5P_VPLL_CON1), pll_4650);
Changhwan Younc8bef142010-07-27 17:52:39 +09001023
1024 clk_fout_apll.rate = apll;
1025 clk_fout_mpll.rate = mpll;
1026 clk_fout_epll.rate = epll;
1027 clk_fout_vpll.rate = vpll;
1028
1029 printk(KERN_INFO "S5PV310: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
1030 apll, mpll, epll, vpll);
1031
1032 armclk = clk_get_rate(&clk_armclk.clk);
Changhwan Younc8bef142010-07-27 17:52:39 +09001033 sclk_dmc = clk_get_rate(&clk_sclk_dmc.clk);
Changhwan Younc8bef142010-07-27 17:52:39 +09001034
Jongpill Lee228ef982010-08-18 22:24:53 +09001035 aclk_200 = clk_get_rate(&clk_aclk_200.clk);
1036 aclk_100 = clk_get_rate(&clk_aclk_100.clk);
1037 aclk_160 = clk_get_rate(&clk_aclk_160.clk);
1038 aclk_133 = clk_get_rate(&clk_aclk_133.clk);
1039
1040 printk(KERN_INFO "S5PV310: ARMCLK=%ld, DMC=%ld, ACLK200=%ld\n"
1041 "ACLK100=%ld, ACLK160=%ld, ACLK133=%ld\n",
1042 armclk, sclk_dmc, aclk_200,
1043 aclk_100, aclk_160, aclk_133);
Changhwan Younc8bef142010-07-27 17:52:39 +09001044
1045 clk_f.rate = armclk;
1046 clk_h.rate = sclk_dmc;
Jongpill Lee228ef982010-08-18 22:24:53 +09001047 clk_p.rate = aclk_100;
Changhwan Younc8bef142010-07-27 17:52:39 +09001048
1049 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
1050 s3c_set_clksrc(&clksrcs[ptr], true);
1051}
1052
1053static struct clk *clks[] __initdata = {
1054 /* Nothing here yet */
1055};
1056
1057void __init s5pv310_register_clocks(void)
1058{
1059 struct clk *clkp;
1060 int ret;
1061 int ptr;
1062
1063 ret = s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
1064 if (ret > 0)
1065 printk(KERN_ERR "Failed to register %u clocks\n", ret);
1066
1067 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
1068 s3c_register_clksrc(sysclks[ptr], 1);
1069
1070 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
1071 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
1072
1073 clkp = init_clocks_disable;
1074 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) {
1075 ret = s3c24xx_register_clock(clkp);
1076 if (ret < 0) {
1077 printk(KERN_ERR "Failed to register clock %s (%d)\n",
1078 clkp->name, ret);
1079 }
1080 (clkp->enable)(clkp, 0);
1081 }
1082
1083 s3c_pwmclk_init();
1084}