clock-s5p6450.c 15 KB

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