clock-s5p6450.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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_off[] = {
  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 = "rtc",
  209. .id = -1,
  210. .parent = &clk_pclk_low.clk,
  211. .enable = s5p64x0_pclk_ctrl,
  212. .ctrlbit = (1 << 6),
  213. }, {
  214. .name = "adc",
  215. .id = -1,
  216. .parent = &clk_pclk_low.clk,
  217. .enable = s5p64x0_pclk_ctrl,
  218. .ctrlbit = (1 << 12),
  219. }, {
  220. .name = "i2c",
  221. .id = 0,
  222. .parent = &clk_pclk_low.clk,
  223. .enable = s5p64x0_pclk_ctrl,
  224. .ctrlbit = (1 << 17),
  225. }, {
  226. .name = "spi",
  227. .id = 0,
  228. .parent = &clk_pclk_low.clk,
  229. .enable = s5p64x0_pclk_ctrl,
  230. .ctrlbit = (1 << 21),
  231. }, {
  232. .name = "spi",
  233. .id = 1,
  234. .parent = &clk_pclk_low.clk,
  235. .enable = s5p64x0_pclk_ctrl,
  236. .ctrlbit = (1 << 22),
  237. }, {
  238. .name = "iis",
  239. .id = 0,
  240. .parent = &clk_pclk_low.clk,
  241. .enable = s5p64x0_pclk_ctrl,
  242. .ctrlbit = (1 << 26),
  243. }, {
  244. .name = "iis",
  245. .id = 1,
  246. .parent = &clk_pclk_low.clk,
  247. .enable = s5p64x0_pclk_ctrl,
  248. .ctrlbit = (1 << 15),
  249. }, {
  250. .name = "iis",
  251. .id = 2,
  252. .parent = &clk_pclk_low.clk,
  253. .enable = s5p64x0_pclk_ctrl,
  254. .ctrlbit = (1 << 16),
  255. }, {
  256. .name = "i2c",
  257. .id = 1,
  258. .parent = &clk_pclk_low.clk,
  259. .enable = s5p64x0_pclk_ctrl,
  260. .ctrlbit = (1 << 27),
  261. }, {
  262. .name = "dmc0",
  263. .id = -1,
  264. .parent = &clk_pclk.clk,
  265. .enable = s5p64x0_pclk_ctrl,
  266. .ctrlbit = (1 << 30),
  267. }
  268. };
  269. /*
  270. * The following clocks will be enabled during clock initialization.
  271. */
  272. static struct clk init_clocks[] = {
  273. {
  274. .name = "intc",
  275. .id = -1,
  276. .parent = &clk_hclk.clk,
  277. .enable = s5p64x0_hclk0_ctrl,
  278. .ctrlbit = (1 << 1),
  279. }, {
  280. .name = "mem",
  281. .id = -1,
  282. .parent = &clk_hclk.clk,
  283. .enable = s5p64x0_hclk0_ctrl,
  284. .ctrlbit = (1 << 21),
  285. }, {
  286. .name = "uart",
  287. .id = 0,
  288. .parent = &clk_pclk_low.clk,
  289. .enable = s5p64x0_pclk_ctrl,
  290. .ctrlbit = (1 << 1),
  291. }, {
  292. .name = "uart",
  293. .id = 1,
  294. .parent = &clk_pclk_low.clk,
  295. .enable = s5p64x0_pclk_ctrl,
  296. .ctrlbit = (1 << 2),
  297. }, {
  298. .name = "uart",
  299. .id = 2,
  300. .parent = &clk_pclk_low.clk,
  301. .enable = s5p64x0_pclk_ctrl,
  302. .ctrlbit = (1 << 3),
  303. }, {
  304. .name = "uart",
  305. .id = 3,
  306. .parent = &clk_pclk_low.clk,
  307. .enable = s5p64x0_pclk_ctrl,
  308. .ctrlbit = (1 << 4),
  309. }, {
  310. .name = "timers",
  311. .id = -1,
  312. .parent = &clk_pclk_to_wdt_pwm.clk,
  313. .enable = s5p64x0_pclk_ctrl,
  314. .ctrlbit = (1 << 7),
  315. }, {
  316. .name = "gpio",
  317. .id = -1,
  318. .parent = &clk_pclk_low.clk,
  319. .enable = s5p64x0_pclk_ctrl,
  320. .ctrlbit = (1 << 18),
  321. },
  322. };
  323. static struct clk *clkset_uart_list[] = {
  324. &clk_dout_epll.clk,
  325. &clk_dout_mpll.clk,
  326. };
  327. static struct clksrc_sources clkset_uart = {
  328. .sources = clkset_uart_list,
  329. .nr_sources = ARRAY_SIZE(clkset_uart_list),
  330. };
  331. static struct clk *clkset_mali_list[] = {
  332. &clk_mout_epll.clk,
  333. &clk_mout_apll.clk,
  334. &clk_mout_mpll.clk,
  335. };
  336. static struct clksrc_sources clkset_mali = {
  337. .sources = clkset_mali_list,
  338. .nr_sources = ARRAY_SIZE(clkset_mali_list),
  339. };
  340. static struct clk *clkset_group2_list[] = {
  341. &clk_dout_epll.clk,
  342. &clk_dout_mpll.clk,
  343. &clk_ext_xtal_mux,
  344. };
  345. static struct clksrc_sources clkset_group2 = {
  346. .sources = clkset_group2_list,
  347. .nr_sources = ARRAY_SIZE(clkset_group2_list),
  348. };
  349. static struct clk *clkset_dispcon_list[] = {
  350. &clk_dout_epll.clk,
  351. &clk_dout_mpll.clk,
  352. &clk_ext_xtal_mux,
  353. &clk_mout_dpll.clk,
  354. };
  355. static struct clksrc_sources clkset_dispcon = {
  356. .sources = clkset_dispcon_list,
  357. .nr_sources = ARRAY_SIZE(clkset_dispcon_list),
  358. };
  359. static struct clk *clkset_hsmmc44_list[] = {
  360. &clk_dout_epll.clk,
  361. &clk_dout_mpll.clk,
  362. &clk_ext_xtal_mux,
  363. &s5p_clk_27m,
  364. &clk_48m,
  365. };
  366. static struct clksrc_sources clkset_hsmmc44 = {
  367. .sources = clkset_hsmmc44_list,
  368. .nr_sources = ARRAY_SIZE(clkset_hsmmc44_list),
  369. };
  370. static struct clk *clkset_sclk_audio0_list[] = {
  371. [0] = &clk_dout_epll.clk,
  372. [1] = &clk_dout_mpll.clk,
  373. [2] = &clk_ext_xtal_mux,
  374. [3] = NULL,
  375. [4] = NULL,
  376. };
  377. static struct clksrc_sources clkset_sclk_audio0 = {
  378. .sources = clkset_sclk_audio0_list,
  379. .nr_sources = ARRAY_SIZE(clkset_sclk_audio0_list),
  380. };
  381. static struct clksrc_clk clk_sclk_audio0 = {
  382. .clk = {
  383. .name = "audio-bus",
  384. .id = -1,
  385. .enable = s5p64x0_sclk_ctrl,
  386. .ctrlbit = (1 << 8),
  387. .parent = &clk_dout_epll.clk,
  388. },
  389. .sources = &clkset_sclk_audio0,
  390. .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 10, .size = 3 },
  391. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 8, .size = 4 },
  392. };
  393. static struct clksrc_clk clksrcs[] = {
  394. {
  395. .clk = {
  396. .name = "sclk_mmc",
  397. .id = 0,
  398. .ctrlbit = (1 << 24),
  399. .enable = s5p64x0_sclk_ctrl,
  400. },
  401. .sources = &clkset_group2,
  402. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 18, .size = 2 },
  403. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 0, .size = 4 },
  404. }, {
  405. .clk = {
  406. .name = "sclk_mmc",
  407. .id = 1,
  408. .ctrlbit = (1 << 25),
  409. .enable = s5p64x0_sclk_ctrl,
  410. },
  411. .sources = &clkset_group2,
  412. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 20, .size = 2 },
  413. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 4, .size = 4 },
  414. }, {
  415. .clk = {
  416. .name = "sclk_mmc",
  417. .id = 2,
  418. .ctrlbit = (1 << 26),
  419. .enable = s5p64x0_sclk_ctrl,
  420. },
  421. .sources = &clkset_group2,
  422. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 22, .size = 2 },
  423. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 8, .size = 4 },
  424. }, {
  425. .clk = {
  426. .name = "uclk1",
  427. .id = -1,
  428. .ctrlbit = (1 << 5),
  429. .enable = s5p64x0_sclk_ctrl,
  430. },
  431. .sources = &clkset_uart,
  432. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 13, .size = 1 },
  433. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 16, .size = 4 },
  434. }, {
  435. .clk = {
  436. .name = "sclk_spi",
  437. .id = 0,
  438. .ctrlbit = (1 << 20),
  439. .enable = s5p64x0_sclk_ctrl,
  440. },
  441. .sources = &clkset_group2,
  442. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 14, .size = 2 },
  443. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 0, .size = 4 },
  444. }, {
  445. .clk = {
  446. .name = "sclk_spi",
  447. .id = 1,
  448. .ctrlbit = (1 << 21),
  449. .enable = s5p64x0_sclk_ctrl,
  450. },
  451. .sources = &clkset_group2,
  452. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 16, .size = 2 },
  453. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 4, .size = 4 },
  454. }, {
  455. .clk = {
  456. .name = "sclk_fimc",
  457. .id = -1,
  458. .ctrlbit = (1 << 10),
  459. .enable = s5p64x0_sclk_ctrl,
  460. },
  461. .sources = &clkset_group2,
  462. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 26, .size = 2 },
  463. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 12, .size = 4 },
  464. }, {
  465. .clk = {
  466. .name = "aclk_mali",
  467. .id = -1,
  468. .ctrlbit = (1 << 2),
  469. .enable = s5p64x0_sclk1_ctrl,
  470. },
  471. .sources = &clkset_mali,
  472. .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 8, .size = 2 },
  473. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 4, .size = 4 },
  474. }, {
  475. .clk = {
  476. .name = "sclk_2d",
  477. .id = -1,
  478. .ctrlbit = (1 << 12),
  479. .enable = s5p64x0_sclk_ctrl,
  480. },
  481. .sources = &clkset_mali,
  482. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 30, .size = 2 },
  483. .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 20, .size = 4 },
  484. }, {
  485. .clk = {
  486. .name = "sclk_usi",
  487. .id = -1,
  488. .ctrlbit = (1 << 7),
  489. .enable = s5p64x0_sclk_ctrl,
  490. },
  491. .sources = &clkset_group2,
  492. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 10, .size = 2 },
  493. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 16, .size = 4 },
  494. }, {
  495. .clk = {
  496. .name = "sclk_camif",
  497. .id = -1,
  498. .ctrlbit = (1 << 6),
  499. .enable = s5p64x0_sclk_ctrl,
  500. },
  501. .sources = &clkset_group2,
  502. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 28, .size = 2 },
  503. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 20, .size = 4 },
  504. }, {
  505. .clk = {
  506. .name = "sclk_dispcon",
  507. .id = -1,
  508. .ctrlbit = (1 << 1),
  509. .enable = s5p64x0_sclk1_ctrl,
  510. },
  511. .sources = &clkset_dispcon,
  512. .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 4, .size = 2 },
  513. .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 0, .size = 4 },
  514. }, {
  515. .clk = {
  516. .name = "sclk_hsmmc44",
  517. .id = -1,
  518. .ctrlbit = (1 << 30),
  519. .enable = s5p64x0_sclk_ctrl,
  520. },
  521. .sources = &clkset_hsmmc44,
  522. .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 6, .size = 3 },
  523. .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 28, .size = 4 },
  524. },
  525. };
  526. /* Clock initialization code */
  527. static struct clksrc_clk *sysclks[] = {
  528. &clk_mout_apll,
  529. &clk_mout_epll,
  530. &clk_dout_epll,
  531. &clk_mout_mpll,
  532. &clk_dout_mpll,
  533. &clk_armclk,
  534. &clk_mout_hclk_sel,
  535. &clk_dout_pwm_ratio0,
  536. &clk_pclk_to_wdt_pwm,
  537. &clk_hclk,
  538. &clk_pclk,
  539. &clk_hclk_low,
  540. &clk_pclk_low,
  541. &clk_sclk_audio0,
  542. };
  543. void __init_or_cpufreq s5p6450_setup_clocks(void)
  544. {
  545. struct clk *xtal_clk;
  546. unsigned long xtal;
  547. unsigned long fclk;
  548. unsigned long hclk;
  549. unsigned long hclk_low;
  550. unsigned long pclk;
  551. unsigned long pclk_low;
  552. unsigned long apll;
  553. unsigned long mpll;
  554. unsigned long epll;
  555. unsigned long dpll;
  556. unsigned int ptr;
  557. /* Set S5P6450 functions for clk_fout_epll */
  558. clk_fout_epll.enable = s5p_epll_enable;
  559. clk_fout_epll.ops = &s5p6450_epll_ops;
  560. clk_48m.enable = s5p64x0_clk48m_ctrl;
  561. xtal_clk = clk_get(NULL, "ext_xtal");
  562. BUG_ON(IS_ERR(xtal_clk));
  563. xtal = clk_get_rate(xtal_clk);
  564. clk_put(xtal_clk);
  565. apll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_APLL_CON), pll_4502);
  566. mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_MPLL_CON), pll_4502);
  567. epll = s5p_get_pll90xx(xtal, __raw_readl(S5P64X0_EPLL_CON),
  568. __raw_readl(S5P64X0_EPLL_CON_K));
  569. dpll = s5p_get_pll46xx(xtal, __raw_readl(S5P6450_DPLL_CON),
  570. __raw_readl(S5P6450_DPLL_CON_K), pll_4650c);
  571. clk_fout_apll.rate = apll;
  572. clk_fout_mpll.rate = mpll;
  573. clk_fout_epll.rate = epll;
  574. clk_fout_dpll.rate = dpll;
  575. printk(KERN_INFO "S5P6450: PLL settings, A=%ld.%ldMHz, M=%ld.%ldMHz," \
  576. " E=%ld.%ldMHz, D=%ld.%ldMHz\n",
  577. print_mhz(apll), print_mhz(mpll), print_mhz(epll),
  578. print_mhz(dpll));
  579. fclk = clk_get_rate(&clk_armclk.clk);
  580. hclk = clk_get_rate(&clk_hclk.clk);
  581. pclk = clk_get_rate(&clk_pclk.clk);
  582. hclk_low = clk_get_rate(&clk_hclk_low.clk);
  583. pclk_low = clk_get_rate(&clk_pclk_low.clk);
  584. printk(KERN_INFO "S5P6450: HCLK=%ld.%ldMHz, HCLK_LOW=%ld.%ldMHz," \
  585. " PCLK=%ld.%ldMHz, PCLK_LOW=%ld.%ldMHz\n",
  586. print_mhz(hclk), print_mhz(hclk_low),
  587. print_mhz(pclk), print_mhz(pclk_low));
  588. clk_f.rate = fclk;
  589. clk_h.rate = hclk;
  590. clk_p.rate = pclk;
  591. for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
  592. s3c_set_clksrc(&clksrcs[ptr], true);
  593. }
  594. void __init s5p6450_register_clocks(void)
  595. {
  596. int ptr;
  597. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  598. s3c_register_clksrc(sysclks[ptr], 1);
  599. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  600. s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
  601. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  602. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  603. s3c_pwmclk_init();
  604. }