clock-s5p6450.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. /* linux/arch/arm/mach-s5p64x0/clock-s5p6450.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * S5P6450 - 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. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/list.h>
  16. #include <linux/errno.h>
  17. #include <linux/err.h>
  18. #include <linux/clk.h>
  19. #include <linux/device.h>
  20. #include <linux/io.h>
  21. #include <mach/hardware.h>
  22. #include <mach/map.h>
  23. #include <mach/regs-clock.h>
  24. #include <mach/s5p64x0-clock.h>
  25. #include <plat/cpu-freq.h>
  26. #include <plat/clock.h>
  27. #include <plat/cpu.h>
  28. #include <plat/pll.h>
  29. #include <plat/s5p-clock.h>
  30. #include <plat/clock-clksrc.h>
  31. #include "common.h"
  32. static struct clksrc_clk clk_mout_dpll = {
  33. .clk = {
  34. .name = "mout_dpll",
  35. },
  36. .sources = &clk_src_dpll,
  37. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 5, .size = 1 },
  38. };
  39. static u32 epll_div[][5] = {
  40. { 133000000, 27307, 55, 2, 2 },
  41. { 100000000, 43691, 41, 2, 2 },
  42. { 480000000, 0, 80, 2, 0 },
  43. };
  44. static int s5p6450_epll_set_rate(struct clk *clk, unsigned long rate)
  45. {
  46. unsigned int epll_con, epll_con_k;
  47. unsigned int i;
  48. if (clk->rate == rate) /* Return if nothing changed */
  49. return 0;
  50. epll_con = __raw_readl(S5P64X0_EPLL_CON);
  51. epll_con_k = __raw_readl(S5P64X0_EPLL_CON_K);
  52. epll_con_k &= ~(PLL90XX_KDIV_MASK);
  53. epll_con &= ~(PLL90XX_MDIV_MASK | PLL90XX_PDIV_MASK | PLL90XX_SDIV_MASK);
  54. for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
  55. if (epll_div[i][0] == rate) {
  56. epll_con_k |= (epll_div[i][1] << PLL90XX_KDIV_SHIFT);
  57. epll_con |= (epll_div[i][2] << PLL90XX_MDIV_SHIFT) |
  58. (epll_div[i][3] << PLL90XX_PDIV_SHIFT) |
  59. (epll_div[i][4] << PLL90XX_SDIV_SHIFT);
  60. break;
  61. }
  62. }
  63. if (i == ARRAY_SIZE(epll_div)) {
  64. printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n", __func__);
  65. return -EINVAL;
  66. }
  67. __raw_writel(epll_con, S5P64X0_EPLL_CON);
  68. __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K);
  69. printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
  70. clk->rate, rate);
  71. clk->rate = rate;
  72. return 0;
  73. }
  74. static struct clk_ops s5p6450_epll_ops = {
  75. .get_rate = s5p_epll_get_rate,
  76. .set_rate = s5p6450_epll_set_rate,
  77. };
  78. static struct clksrc_clk clk_dout_epll = {
  79. .clk = {
  80. .name = "dout_epll",
  81. .parent = &clk_mout_epll.clk,
  82. },
  83. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 24, .size = 4 },
  84. };
  85. static struct clksrc_clk clk_mout_hclk_sel = {
  86. .clk = {
  87. .name = "mout_hclk_sel",
  88. },
  89. .sources = &clkset_hclk_low,
  90. .reg_src = { .reg = S5P64X0_OTHERS, .shift = 15, .size = 1 },
  91. };
  92. static struct clk *clkset_hclk_list[] = {
  93. &clk_mout_hclk_sel.clk,
  94. &clk_armclk.clk,
  95. };
  96. static struct clksrc_sources clkset_hclk = {
  97. .sources = clkset_hclk_list,
  98. .nr_sources = ARRAY_SIZE(clkset_hclk_list),
  99. };
  100. static struct clksrc_clk clk_hclk = {
  101. .clk = {
  102. .name = "clk_hclk",
  103. },
  104. .sources = &clkset_hclk,
  105. .reg_src = { .reg = S5P64X0_OTHERS, .shift = 14, .size = 1 },
  106. .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 8, .size = 4 },
  107. };
  108. static struct clksrc_clk clk_pclk = {
  109. .clk = {
  110. .name = "clk_pclk",
  111. .parent = &clk_hclk.clk,
  112. },
  113. .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 12, .size = 4 },
  114. };
  115. static struct clksrc_clk clk_dout_pwm_ratio0 = {
  116. .clk = {
  117. .name = "clk_dout_pwm_ratio0",
  118. .parent = &clk_mout_hclk_sel.clk,
  119. },
  120. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 16, .size = 4 },
  121. };
  122. static struct clksrc_clk clk_pclk_to_wdt_pwm = {
  123. .clk = {
  124. .name = "clk_pclk_to_wdt_pwm",
  125. .parent = &clk_dout_pwm_ratio0.clk,
  126. },
  127. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 20, .size = 4 },
  128. };
  129. static struct clksrc_clk clk_hclk_low = {
  130. .clk = {
  131. .name = "clk_hclk_low",
  132. },
  133. .sources = &clkset_hclk_low,
  134. .reg_src = { .reg = S5P64X0_OTHERS, .shift = 6, .size = 1 },
  135. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 8, .size = 4 },
  136. };
  137. static struct clksrc_clk clk_pclk_low = {
  138. .clk = {
  139. .name = "clk_pclk_low",
  140. .parent = &clk_hclk_low.clk,
  141. },
  142. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 12, .size = 4 },
  143. };
  144. /*
  145. * The following clocks will be disabled during clock initialization. It is
  146. * recommended to keep the following clocks disabled until the driver requests
  147. * for enabling the clock.
  148. */
  149. static struct clk init_clocks_off[] = {
  150. {
  151. .name = "usbhost",
  152. .parent = &clk_hclk_low.clk,
  153. .enable = s5p64x0_hclk0_ctrl,
  154. .ctrlbit = (1 << 3),
  155. }, {
  156. .name = "dma",
  157. .devname = "dma-pl330",
  158. .parent = &clk_hclk_low.clk,
  159. .enable = s5p64x0_hclk0_ctrl,
  160. .ctrlbit = (1 << 12),
  161. }, {
  162. .name = "hsmmc",
  163. .devname = "s3c-sdhci.0",
  164. .parent = &clk_hclk_low.clk,
  165. .enable = s5p64x0_hclk0_ctrl,
  166. .ctrlbit = (1 << 17),
  167. }, {
  168. .name = "hsmmc",
  169. .devname = "s3c-sdhci.1",
  170. .parent = &clk_hclk_low.clk,
  171. .enable = s5p64x0_hclk0_ctrl,
  172. .ctrlbit = (1 << 18),
  173. }, {
  174. .name = "hsmmc",
  175. .devname = "s3c-sdhci.2",
  176. .parent = &clk_hclk_low.clk,
  177. .enable = s5p64x0_hclk0_ctrl,
  178. .ctrlbit = (1 << 19),
  179. }, {
  180. .name = "usbotg",
  181. .parent = &clk_hclk_low.clk,
  182. .enable = s5p64x0_hclk0_ctrl,
  183. .ctrlbit = (1 << 20),
  184. }, {
  185. .name = "lcd",
  186. .parent = &clk_h,
  187. .enable = s5p64x0_hclk1_ctrl,
  188. .ctrlbit = (1 << 1),
  189. }, {
  190. .name = "watchdog",
  191. .parent = &clk_pclk_low.clk,
  192. .enable = s5p64x0_pclk_ctrl,
  193. .ctrlbit = (1 << 5),
  194. }, {
  195. .name = "rtc",
  196. .parent = &clk_pclk_low.clk,
  197. .enable = s5p64x0_pclk_ctrl,
  198. .ctrlbit = (1 << 6),
  199. }, {
  200. .name = "adc",
  201. .parent = &clk_pclk_low.clk,
  202. .enable = s5p64x0_pclk_ctrl,
  203. .ctrlbit = (1 << 12),
  204. }, {
  205. .name = "i2c",
  206. .devname = "s3c2440-i2c.0",
  207. .parent = &clk_pclk_low.clk,
  208. .enable = s5p64x0_pclk_ctrl,
  209. .ctrlbit = (1 << 17),
  210. }, {
  211. .name = "spi",
  212. .devname = "s3c64xx-spi.0",
  213. .parent = &clk_pclk_low.clk,
  214. .enable = s5p64x0_pclk_ctrl,
  215. .ctrlbit = (1 << 21),
  216. }, {
  217. .name = "spi",
  218. .devname = "s3c64xx-spi.1",
  219. .parent = &clk_pclk_low.clk,
  220. .enable = s5p64x0_pclk_ctrl,
  221. .ctrlbit = (1 << 22),
  222. }, {
  223. .name = "iis",
  224. .devname = "samsung-i2s.0",
  225. .parent = &clk_pclk_low.clk,
  226. .enable = s5p64x0_pclk_ctrl,
  227. .ctrlbit = (1 << 26),
  228. }, {
  229. .name = "iis",
  230. .devname = "samsung-i2s.1",
  231. .parent = &clk_pclk_low.clk,
  232. .enable = s5p64x0_pclk_ctrl,
  233. .ctrlbit = (1 << 15),
  234. }, {
  235. .name = "iis",
  236. .devname = "samsung-i2s.2",
  237. .parent = &clk_pclk_low.clk,
  238. .enable = s5p64x0_pclk_ctrl,
  239. .ctrlbit = (1 << 16),
  240. }, {
  241. .name = "i2c",
  242. .devname = "s3c2440-i2c.1",
  243. .parent = &clk_pclk_low.clk,
  244. .enable = s5p64x0_pclk_ctrl,
  245. .ctrlbit = (1 << 27),
  246. }, {
  247. .name = "dmc0",
  248. .parent = &clk_pclk.clk,
  249. .enable = s5p64x0_pclk_ctrl,
  250. .ctrlbit = (1 << 30),
  251. }
  252. };
  253. /*
  254. * The following clocks will be enabled during clock initialization.
  255. */
  256. static struct clk init_clocks[] = {
  257. {
  258. .name = "intc",
  259. .parent = &clk_hclk.clk,
  260. .enable = s5p64x0_hclk0_ctrl,
  261. .ctrlbit = (1 << 1),
  262. }, {
  263. .name = "mem",
  264. .parent = &clk_hclk.clk,
  265. .enable = s5p64x0_hclk0_ctrl,
  266. .ctrlbit = (1 << 21),
  267. }, {
  268. .name = "uart",
  269. .devname = "s3c6400-uart.0",
  270. .parent = &clk_pclk_low.clk,
  271. .enable = s5p64x0_pclk_ctrl,
  272. .ctrlbit = (1 << 1),
  273. }, {
  274. .name = "uart",
  275. .devname = "s3c6400-uart.1",
  276. .parent = &clk_pclk_low.clk,
  277. .enable = s5p64x0_pclk_ctrl,
  278. .ctrlbit = (1 << 2),
  279. }, {
  280. .name = "uart",
  281. .devname = "s3c6400-uart.2",
  282. .parent = &clk_pclk_low.clk,
  283. .enable = s5p64x0_pclk_ctrl,
  284. .ctrlbit = (1 << 3),
  285. }, {
  286. .name = "uart",
  287. .devname = "s3c6400-uart.3",
  288. .parent = &clk_pclk_low.clk,
  289. .enable = s5p64x0_pclk_ctrl,
  290. .ctrlbit = (1 << 4),
  291. }, {
  292. .name = "timers",
  293. .parent = &clk_pclk_to_wdt_pwm.clk,
  294. .enable = s5p64x0_pclk_ctrl,
  295. .ctrlbit = (1 << 7),
  296. }, {
  297. .name = "gpio",
  298. .parent = &clk_pclk_low.clk,
  299. .enable = s5p64x0_pclk_ctrl,
  300. .ctrlbit = (1 << 18),
  301. },
  302. };
  303. static struct clk *clkset_uart_list[] = {
  304. &clk_dout_epll.clk,
  305. &clk_dout_mpll.clk,
  306. };
  307. static struct clksrc_sources clkset_uart = {
  308. .sources = clkset_uart_list,
  309. .nr_sources = ARRAY_SIZE(clkset_uart_list),
  310. };
  311. static struct clk *clkset_mali_list[] = {
  312. &clk_mout_epll.clk,
  313. &clk_mout_apll.clk,
  314. &clk_mout_mpll.clk,
  315. };
  316. static struct clksrc_sources clkset_mali = {
  317. .sources = clkset_mali_list,
  318. .nr_sources = ARRAY_SIZE(clkset_mali_list),
  319. };
  320. static struct clk *clkset_group2_list[] = {
  321. &clk_dout_epll.clk,
  322. &clk_dout_mpll.clk,
  323. &clk_ext_xtal_mux,
  324. };
  325. static struct clksrc_sources clkset_group2 = {
  326. .sources = clkset_group2_list,
  327. .nr_sources = ARRAY_SIZE(clkset_group2_list),
  328. };
  329. static struct clk *clkset_dispcon_list[] = {
  330. &clk_dout_epll.clk,
  331. &clk_dout_mpll.clk,
  332. &clk_ext_xtal_mux,
  333. &clk_mout_dpll.clk,
  334. };
  335. static struct clksrc_sources clkset_dispcon = {
  336. .sources = clkset_dispcon_list,
  337. .nr_sources = ARRAY_SIZE(clkset_dispcon_list),
  338. };
  339. static struct clk *clkset_hsmmc44_list[] = {
  340. &clk_dout_epll.clk,
  341. &clk_dout_mpll.clk,
  342. &clk_ext_xtal_mux,
  343. &s5p_clk_27m,
  344. &clk_48m,
  345. };
  346. static struct clksrc_sources clkset_hsmmc44 = {
  347. .sources = clkset_hsmmc44_list,
  348. .nr_sources = ARRAY_SIZE(clkset_hsmmc44_list),
  349. };
  350. static struct clk *clkset_sclk_audio0_list[] = {
  351. [0] = &clk_dout_epll.clk,
  352. [1] = &clk_dout_mpll.clk,
  353. [2] = &clk_ext_xtal_mux,
  354. [3] = NULL,
  355. [4] = NULL,
  356. };
  357. static struct clksrc_sources clkset_sclk_audio0 = {
  358. .sources = clkset_sclk_audio0_list,
  359. .nr_sources = ARRAY_SIZE(clkset_sclk_audio0_list),
  360. };
  361. static struct clksrc_clk clk_sclk_audio0 = {
  362. .clk = {
  363. .name = "audio-bus",
  364. .enable = s5p64x0_sclk_ctrl,
  365. .ctrlbit = (1 << 8),
  366. .parent = &clk_dout_epll.clk,
  367. },
  368. .sources = &clkset_sclk_audio0,
  369. .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 10, .size = 3 },
  370. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 8, .size = 4 },
  371. };
  372. static struct clksrc_clk clksrcs[] = {
  373. {
  374. .clk = {
  375. .name = "sclk_fimc",
  376. .ctrlbit = (1 << 10),
  377. .enable = s5p64x0_sclk_ctrl,
  378. },
  379. .sources = &clkset_group2,
  380. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 26, .size = 2 },
  381. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 12, .size = 4 },
  382. }, {
  383. .clk = {
  384. .name = "aclk_mali",
  385. .ctrlbit = (1 << 2),
  386. .enable = s5p64x0_sclk1_ctrl,
  387. },
  388. .sources = &clkset_mali,
  389. .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 8, .size = 2 },
  390. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 4, .size = 4 },
  391. }, {
  392. .clk = {
  393. .name = "sclk_2d",
  394. .ctrlbit = (1 << 12),
  395. .enable = s5p64x0_sclk_ctrl,
  396. },
  397. .sources = &clkset_mali,
  398. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 30, .size = 2 },
  399. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 20, .size = 4 },
  400. }, {
  401. .clk = {
  402. .name = "sclk_usi",
  403. .ctrlbit = (1 << 7),
  404. .enable = s5p64x0_sclk_ctrl,
  405. },
  406. .sources = &clkset_group2,
  407. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 10, .size = 2 },
  408. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 16, .size = 4 },
  409. }, {
  410. .clk = {
  411. .name = "sclk_camif",
  412. .ctrlbit = (1 << 6),
  413. .enable = s5p64x0_sclk_ctrl,
  414. },
  415. .sources = &clkset_group2,
  416. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 28, .size = 2 },
  417. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 20, .size = 4 },
  418. }, {
  419. .clk = {
  420. .name = "sclk_dispcon",
  421. .ctrlbit = (1 << 1),
  422. .enable = s5p64x0_sclk1_ctrl,
  423. },
  424. .sources = &clkset_dispcon,
  425. .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 4, .size = 2 },
  426. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 0, .size = 4 },
  427. }, {
  428. .clk = {
  429. .name = "sclk_hsmmc44",
  430. .ctrlbit = (1 << 30),
  431. .enable = s5p64x0_sclk_ctrl,
  432. },
  433. .sources = &clkset_hsmmc44,
  434. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 6, .size = 3 },
  435. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 28, .size = 4 },
  436. },
  437. };
  438. static struct clksrc_clk clk_sclk_mmc0 = {
  439. .clk = {
  440. .name = "sclk_mmc",
  441. .devname = "s3c-sdhci.0",
  442. .ctrlbit = (1 << 24),
  443. .enable = s5p64x0_sclk_ctrl,
  444. },
  445. .sources = &clkset_group2,
  446. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 18, .size = 2 },
  447. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 0, .size = 4 },
  448. };
  449. static struct clksrc_clk clk_sclk_mmc1 = {
  450. .clk = {
  451. .name = "sclk_mmc",
  452. .devname = "s3c-sdhci.1",
  453. .ctrlbit = (1 << 25),
  454. .enable = s5p64x0_sclk_ctrl,
  455. },
  456. .sources = &clkset_group2,
  457. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 20, .size = 2 },
  458. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 4, .size = 4 },
  459. };
  460. static struct clksrc_clk clk_sclk_mmc2 = {
  461. .clk = {
  462. .name = "sclk_mmc",
  463. .devname = "s3c-sdhci.2",
  464. .ctrlbit = (1 << 26),
  465. .enable = s5p64x0_sclk_ctrl,
  466. },
  467. .sources = &clkset_group2,
  468. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 22, .size = 2 },
  469. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 8, .size = 4 },
  470. };
  471. static struct clksrc_clk clk_sclk_uclk = {
  472. .clk = {
  473. .name = "uclk1",
  474. .ctrlbit = (1 << 5),
  475. .enable = s5p64x0_sclk_ctrl,
  476. },
  477. .sources = &clkset_uart,
  478. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 13, .size = 1 },
  479. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 16, .size = 4 },
  480. };
  481. static struct clksrc_clk clk_sclk_spi0 = {
  482. .clk = {
  483. .name = "sclk_spi",
  484. .devname = "s3c64xx-spi.0",
  485. .ctrlbit = (1 << 20),
  486. .enable = s5p64x0_sclk_ctrl,
  487. },
  488. .sources = &clkset_group2,
  489. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 14, .size = 2 },
  490. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 0, .size = 4 },
  491. };
  492. static struct clksrc_clk clk_sclk_spi1 = {
  493. .clk = {
  494. .name = "sclk_spi",
  495. .devname = "s3c64xx-spi.1",
  496. .ctrlbit = (1 << 21),
  497. .enable = s5p64x0_sclk_ctrl,
  498. },
  499. .sources = &clkset_group2,
  500. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 16, .size = 2 },
  501. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 4, .size = 4 },
  502. };
  503. static struct clksrc_clk *clksrc_cdev[] = {
  504. &clk_sclk_uclk,
  505. &clk_sclk_spi0,
  506. &clk_sclk_spi1,
  507. &clk_sclk_mmc0,
  508. &clk_sclk_mmc1,
  509. &clk_sclk_mmc2,
  510. };
  511. static struct clk_lookup s5p6450_clk_lookup[] = {
  512. CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_pclk_low.clk),
  513. CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_sclk_uclk.clk),
  514. CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
  515. CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk1", &clk_sclk_spi0.clk),
  516. CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk1", &clk_sclk_spi1.clk),
  517. CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
  518. CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
  519. CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
  520. };
  521. /* Clock initialization code */
  522. static struct clksrc_clk *sysclks[] = {
  523. &clk_mout_apll,
  524. &clk_mout_epll,
  525. &clk_dout_epll,
  526. &clk_mout_mpll,
  527. &clk_dout_mpll,
  528. &clk_armclk,
  529. &clk_mout_hclk_sel,
  530. &clk_dout_pwm_ratio0,
  531. &clk_pclk_to_wdt_pwm,
  532. &clk_hclk,
  533. &clk_pclk,
  534. &clk_hclk_low,
  535. &clk_pclk_low,
  536. &clk_sclk_audio0,
  537. };
  538. static struct clk dummy_apb_pclk = {
  539. .name = "apb_pclk",
  540. .id = -1,
  541. };
  542. void __init_or_cpufreq s5p6450_setup_clocks(void)
  543. {
  544. struct clk *xtal_clk;
  545. unsigned long xtal;
  546. unsigned long fclk;
  547. unsigned long hclk;
  548. unsigned long hclk_low;
  549. unsigned long pclk;
  550. unsigned long pclk_low;
  551. unsigned long apll;
  552. unsigned long mpll;
  553. unsigned long epll;
  554. unsigned long dpll;
  555. unsigned int ptr;
  556. /* Set S5P6450 functions for clk_fout_epll */
  557. clk_fout_epll.enable = s5p_epll_enable;
  558. clk_fout_epll.ops = &s5p6450_epll_ops;
  559. clk_48m.enable = s5p64x0_clk48m_ctrl;
  560. xtal_clk = clk_get(NULL, "ext_xtal");
  561. BUG_ON(IS_ERR(xtal_clk));
  562. xtal = clk_get_rate(xtal_clk);
  563. clk_put(xtal_clk);
  564. apll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_APLL_CON), pll_4502);
  565. mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_MPLL_CON), pll_4502);
  566. epll = s5p_get_pll90xx(xtal, __raw_readl(S5P64X0_EPLL_CON),
  567. __raw_readl(S5P64X0_EPLL_CON_K));
  568. dpll = s5p_get_pll46xx(xtal, __raw_readl(S5P6450_DPLL_CON),
  569. __raw_readl(S5P6450_DPLL_CON_K), pll_4650c);
  570. clk_fout_apll.rate = apll;
  571. clk_fout_mpll.rate = mpll;
  572. clk_fout_epll.rate = epll;
  573. clk_fout_dpll.rate = dpll;
  574. printk(KERN_INFO "S5P6450: PLL settings, A=%ld.%ldMHz, M=%ld.%ldMHz," \
  575. " E=%ld.%ldMHz, D=%ld.%ldMHz\n",
  576. print_mhz(apll), print_mhz(mpll), print_mhz(epll),
  577. print_mhz(dpll));
  578. fclk = clk_get_rate(&clk_armclk.clk);
  579. hclk = clk_get_rate(&clk_hclk.clk);
  580. pclk = clk_get_rate(&clk_pclk.clk);
  581. hclk_low = clk_get_rate(&clk_hclk_low.clk);
  582. pclk_low = clk_get_rate(&clk_pclk_low.clk);
  583. printk(KERN_INFO "S5P6450: HCLK=%ld.%ldMHz, HCLK_LOW=%ld.%ldMHz," \
  584. " PCLK=%ld.%ldMHz, PCLK_LOW=%ld.%ldMHz\n",
  585. print_mhz(hclk), print_mhz(hclk_low),
  586. print_mhz(pclk), print_mhz(pclk_low));
  587. clk_f.rate = fclk;
  588. clk_h.rate = hclk;
  589. clk_p.rate = pclk;
  590. for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
  591. s3c_set_clksrc(&clksrcs[ptr], true);
  592. }
  593. void __init s5p6450_register_clocks(void)
  594. {
  595. int ptr;
  596. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  597. s3c_register_clksrc(sysclks[ptr], 1);
  598. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  599. s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
  600. for (ptr = 0; ptr < ARRAY_SIZE(clksrc_cdev); ptr++)
  601. s3c_register_clksrc(clksrc_cdev[ptr], 1);
  602. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  603. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  604. clkdev_add_table(s5p6450_clk_lookup, ARRAY_SIZE(s5p6450_clk_lookup));
  605. s3c24xx_register_clock(&dummy_apb_pclk);
  606. s3c_pwmclk_init();
  607. }