s3c6400-clock.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. /* linux/arch/arm/plat-s3c64xx/s3c6400-clock.c
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C6400 based common clock support
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/module.h>
  16. #include <linux/kernel.h>
  17. #include <linux/list.h>
  18. #include <linux/errno.h>
  19. #include <linux/err.h>
  20. #include <linux/clk.h>
  21. #include <linux/sysdev.h>
  22. #include <linux/io.h>
  23. #include <mach/hardware.h>
  24. #include <mach/map.h>
  25. #include <plat/cpu-freq.h>
  26. #include <plat/regs-clock.h>
  27. #include <plat/clock.h>
  28. #include <plat/cpu.h>
  29. #include <plat/pll.h>
  30. /* fin_apll, fin_mpll and fin_epll are all the same clock, which we call
  31. * ext_xtal_mux for want of an actual name from the manual.
  32. */
  33. static struct clk clk_ext_xtal_mux = {
  34. .name = "ext_xtal",
  35. .id = -1,
  36. };
  37. #define clk_fin_apll clk_ext_xtal_mux
  38. #define clk_fin_mpll clk_ext_xtal_mux
  39. #define clk_fin_epll clk_ext_xtal_mux
  40. #define clk_fout_mpll clk_mpll
  41. #define clk_fout_epll clk_epll
  42. struct clk_sources {
  43. unsigned int nr_sources;
  44. struct clk **sources;
  45. };
  46. struct clksrc_clk {
  47. struct clk clk;
  48. unsigned int mask;
  49. unsigned int shift;
  50. struct clk_sources *sources;
  51. unsigned int divider_shift;
  52. void __iomem *reg_divider;
  53. };
  54. static struct clk clk_fout_apll = {
  55. .name = "fout_apll",
  56. .id = -1,
  57. };
  58. static struct clk *clk_src_apll_list[] = {
  59. [0] = &clk_fin_apll,
  60. [1] = &clk_fout_apll,
  61. };
  62. static struct clk_sources clk_src_apll = {
  63. .sources = clk_src_apll_list,
  64. .nr_sources = ARRAY_SIZE(clk_src_apll_list),
  65. };
  66. static struct clksrc_clk clk_mout_apll = {
  67. .clk = {
  68. .name = "mout_apll",
  69. .id = -1,
  70. },
  71. .shift = S3C6400_CLKSRC_APLL_MOUT_SHIFT,
  72. .mask = S3C6400_CLKSRC_APLL_MOUT,
  73. .sources = &clk_src_apll,
  74. };
  75. static struct clk *clk_src_epll_list[] = {
  76. [0] = &clk_fin_epll,
  77. [1] = &clk_fout_epll,
  78. };
  79. static struct clk_sources clk_src_epll = {
  80. .sources = clk_src_epll_list,
  81. .nr_sources = ARRAY_SIZE(clk_src_epll_list),
  82. };
  83. static struct clksrc_clk clk_mout_epll = {
  84. .clk = {
  85. .name = "mout_epll",
  86. .id = -1,
  87. },
  88. .shift = S3C6400_CLKSRC_EPLL_MOUT_SHIFT,
  89. .mask = S3C6400_CLKSRC_EPLL_MOUT,
  90. .sources = &clk_src_epll,
  91. };
  92. static struct clk *clk_src_mpll_list[] = {
  93. [0] = &clk_fin_mpll,
  94. [1] = &clk_fout_mpll,
  95. };
  96. static struct clk_sources clk_src_mpll = {
  97. .sources = clk_src_mpll_list,
  98. .nr_sources = ARRAY_SIZE(clk_src_mpll_list),
  99. };
  100. static struct clksrc_clk clk_mout_mpll = {
  101. .clk = {
  102. .name = "mout_mpll",
  103. .id = -1,
  104. },
  105. .shift = S3C6400_CLKSRC_MPLL_MOUT_SHIFT,
  106. .mask = S3C6400_CLKSRC_MPLL_MOUT,
  107. .sources = &clk_src_mpll,
  108. };
  109. static unsigned int armclk_mask;
  110. static unsigned long s3c64xx_clk_arm_get_rate(struct clk *clk)
  111. {
  112. unsigned long rate = clk_get_rate(clk->parent);
  113. u32 clkdiv;
  114. /* divisor mask starts at bit0, so no need to shift */
  115. clkdiv = __raw_readl(S3C_CLK_DIV0) & armclk_mask;
  116. return rate / (clkdiv + 1);
  117. }
  118. static unsigned long s3c64xx_clk_arm_round_rate(struct clk *clk,
  119. unsigned long rate)
  120. {
  121. unsigned long parent = clk_get_rate(clk->parent);
  122. u32 div;
  123. if (parent < rate)
  124. return parent;
  125. div = (parent / rate) - 1;
  126. if (div > armclk_mask)
  127. div = armclk_mask;
  128. return parent / (div + 1);
  129. }
  130. static int s3c64xx_clk_arm_set_rate(struct clk *clk, unsigned long rate)
  131. {
  132. unsigned long parent = clk_get_rate(clk->parent);
  133. u32 div;
  134. u32 val;
  135. if (rate < parent / (armclk_mask + 1))
  136. return -EINVAL;
  137. rate = clk_round_rate(clk, rate);
  138. div = clk_get_rate(clk->parent) / rate;
  139. val = __raw_readl(S3C_CLK_DIV0);
  140. val &= ~armclk_mask;
  141. val |= (div - 1);
  142. __raw_writel(val, S3C_CLK_DIV0);
  143. return 0;
  144. }
  145. static struct clk clk_arm = {
  146. .name = "armclk",
  147. .id = -1,
  148. .parent = &clk_mout_apll.clk,
  149. .get_rate = s3c64xx_clk_arm_get_rate,
  150. .set_rate = s3c64xx_clk_arm_set_rate,
  151. .round_rate = s3c64xx_clk_arm_round_rate,
  152. };
  153. static unsigned long s3c64xx_clk_doutmpll_get_rate(struct clk *clk)
  154. {
  155. unsigned long rate = clk_get_rate(clk->parent);
  156. printk(KERN_DEBUG "%s: parent is %ld\n", __func__, rate);
  157. if (__raw_readl(S3C_CLK_DIV0) & S3C6400_CLKDIV0_MPLL_MASK)
  158. rate /= 2;
  159. return rate;
  160. }
  161. static struct clk clk_dout_mpll = {
  162. .name = "dout_mpll",
  163. .id = -1,
  164. .parent = &clk_mout_mpll.clk,
  165. .get_rate = s3c64xx_clk_doutmpll_get_rate,
  166. };
  167. static struct clk *clkset_spi_mmc_list[] = {
  168. &clk_mout_epll.clk,
  169. &clk_dout_mpll,
  170. &clk_fin_epll,
  171. &clk_27m,
  172. };
  173. static struct clk_sources clkset_spi_mmc = {
  174. .sources = clkset_spi_mmc_list,
  175. .nr_sources = ARRAY_SIZE(clkset_spi_mmc_list),
  176. };
  177. static struct clk *clkset_irda_list[] = {
  178. &clk_mout_epll.clk,
  179. &clk_dout_mpll,
  180. NULL,
  181. &clk_27m,
  182. };
  183. static struct clk_sources clkset_irda = {
  184. .sources = clkset_irda_list,
  185. .nr_sources = ARRAY_SIZE(clkset_irda_list),
  186. };
  187. static struct clk *clkset_uart_list[] = {
  188. &clk_mout_epll.clk,
  189. &clk_dout_mpll,
  190. NULL,
  191. NULL
  192. };
  193. static struct clk_sources clkset_uart = {
  194. .sources = clkset_uart_list,
  195. .nr_sources = ARRAY_SIZE(clkset_uart_list),
  196. };
  197. static struct clk *clkset_uhost_list[] = {
  198. &clk_48m,
  199. &clk_mout_epll.clk,
  200. &clk_dout_mpll,
  201. &clk_fin_epll,
  202. };
  203. static struct clk_sources clkset_uhost = {
  204. .sources = clkset_uhost_list,
  205. .nr_sources = ARRAY_SIZE(clkset_uhost_list),
  206. };
  207. /* The peripheral clocks are all controlled via clocksource followed
  208. * by an optional divider and gate stage. We currently roll this into
  209. * one clock which hides the intermediate clock from the mux.
  210. *
  211. * Note, the JPEG clock can only be an even divider...
  212. *
  213. * The scaler and LCD clocks depend on the S3C64XX version, and also
  214. * have a common parent divisor so are not included here.
  215. */
  216. static inline struct clksrc_clk *to_clksrc(struct clk *clk)
  217. {
  218. return container_of(clk, struct clksrc_clk, clk);
  219. }
  220. static unsigned long s3c64xx_getrate_clksrc(struct clk *clk)
  221. {
  222. struct clksrc_clk *sclk = to_clksrc(clk);
  223. unsigned long rate = clk_get_rate(clk->parent);
  224. u32 clkdiv = __raw_readl(sclk->reg_divider);
  225. clkdiv >>= sclk->divider_shift;
  226. clkdiv &= 0xf;
  227. clkdiv++;
  228. rate /= clkdiv;
  229. return rate;
  230. }
  231. static int s3c64xx_setrate_clksrc(struct clk *clk, unsigned long rate)
  232. {
  233. struct clksrc_clk *sclk = to_clksrc(clk);
  234. void __iomem *reg = sclk->reg_divider;
  235. unsigned int div;
  236. u32 val;
  237. rate = clk_round_rate(clk, rate);
  238. div = clk_get_rate(clk->parent) / rate;
  239. if (div > 16)
  240. return -EINVAL;
  241. val = __raw_readl(reg);
  242. val &= ~(0xf << sclk->divider_shift);
  243. val |= (div - 1) << sclk->divider_shift;
  244. __raw_writel(val, reg);
  245. return 0;
  246. }
  247. static int s3c64xx_setparent_clksrc(struct clk *clk, struct clk *parent)
  248. {
  249. struct clksrc_clk *sclk = to_clksrc(clk);
  250. struct clk_sources *srcs = sclk->sources;
  251. u32 clksrc = __raw_readl(S3C_CLK_SRC);
  252. int src_nr = -1;
  253. int ptr;
  254. for (ptr = 0; ptr < srcs->nr_sources; ptr++)
  255. if (srcs->sources[ptr] == parent) {
  256. src_nr = ptr;
  257. break;
  258. }
  259. if (src_nr >= 0) {
  260. clksrc &= ~sclk->mask;
  261. clksrc |= src_nr << sclk->shift;
  262. __raw_writel(clksrc, S3C_CLK_SRC);
  263. clk->parent = parent;
  264. return 0;
  265. }
  266. return -EINVAL;
  267. }
  268. static unsigned long s3c64xx_roundrate_clksrc(struct clk *clk,
  269. unsigned long rate)
  270. {
  271. unsigned long parent_rate = clk_get_rate(clk->parent);
  272. int div;
  273. if (rate > parent_rate)
  274. rate = parent_rate;
  275. else {
  276. div = parent_rate / rate;
  277. if (div == 0)
  278. div = 1;
  279. if (div > 16)
  280. div = 16;
  281. rate = parent_rate / div;
  282. }
  283. return rate;
  284. }
  285. /* clocks that feed other parts of the clock source tree */
  286. static struct clk clk_iis_cd0 = {
  287. .name = "iis_cdclk0",
  288. .id = -1,
  289. };
  290. static struct clk clk_iis_cd1 = {
  291. .name = "iis_cdclk1",
  292. .id = -1,
  293. };
  294. static struct clk clk_pcm_cd = {
  295. .name = "pcm_cdclk",
  296. .id = -1,
  297. };
  298. static struct clk *clkset_audio0_list[] = {
  299. [0] = &clk_mout_epll.clk,
  300. [1] = &clk_dout_mpll,
  301. [2] = &clk_fin_epll,
  302. [3] = &clk_iis_cd0,
  303. [4] = &clk_pcm_cd,
  304. };
  305. static struct clk_sources clkset_audio0 = {
  306. .sources = clkset_audio0_list,
  307. .nr_sources = ARRAY_SIZE(clkset_audio0_list),
  308. };
  309. static struct clk *clkset_audio1_list[] = {
  310. [0] = &clk_mout_epll.clk,
  311. [1] = &clk_dout_mpll,
  312. [2] = &clk_fin_epll,
  313. [3] = &clk_iis_cd1,
  314. [4] = &clk_pcm_cd,
  315. };
  316. static struct clk_sources clkset_audio1 = {
  317. .sources = clkset_audio1_list,
  318. .nr_sources = ARRAY_SIZE(clkset_audio1_list),
  319. };
  320. static struct clk *clkset_camif_list[] = {
  321. &clk_h2,
  322. };
  323. static struct clk_sources clkset_camif = {
  324. .sources = clkset_camif_list,
  325. .nr_sources = ARRAY_SIZE(clkset_camif_list),
  326. };
  327. static struct clksrc_clk clksrcs[] = {
  328. {
  329. .clk = {
  330. .name = "mmc_bus",
  331. .id = 0,
  332. .ctrlbit = S3C_CLKCON_SCLK_MMC0,
  333. .enable = s3c64xx_sclk_ctrl,
  334. },
  335. .shift = S3C6400_CLKSRC_MMC0_SHIFT,
  336. .mask = S3C6400_CLKSRC_MMC0_MASK,
  337. .sources = &clkset_spi_mmc,
  338. .divider_shift = S3C6400_CLKDIV1_MMC0_SHIFT,
  339. .reg_divider = S3C_CLK_DIV1,
  340. }, {
  341. .clk = {
  342. .name = "mmc_bus",
  343. .id = 1,
  344. .ctrlbit = S3C_CLKCON_SCLK_MMC1,
  345. .enable = s3c64xx_sclk_ctrl,
  346. },
  347. .shift = S3C6400_CLKSRC_MMC1_SHIFT,
  348. .mask = S3C6400_CLKSRC_MMC1_MASK,
  349. .sources = &clkset_spi_mmc,
  350. .divider_shift = S3C6400_CLKDIV1_MMC1_SHIFT,
  351. .reg_divider = S3C_CLK_DIV1,
  352. }, {
  353. .clk = {
  354. .name = "mmc_bus",
  355. .id = 2,
  356. .ctrlbit = S3C_CLKCON_SCLK_MMC2,
  357. .enable = s3c64xx_sclk_ctrl,
  358. },
  359. .shift = S3C6400_CLKSRC_MMC2_SHIFT,
  360. .mask = S3C6400_CLKSRC_MMC2_MASK,
  361. .sources = &clkset_spi_mmc,
  362. .divider_shift = S3C6400_CLKDIV1_MMC2_SHIFT,
  363. .reg_divider = S3C_CLK_DIV1,
  364. }, {
  365. .clk = {
  366. .name = "usb-bus-host",
  367. .id = -1,
  368. .ctrlbit = S3C_CLKCON_SCLK_UHOST,
  369. .enable = s3c64xx_sclk_ctrl,
  370. },
  371. .shift = S3C6400_CLKSRC_UHOST_SHIFT,
  372. .mask = S3C6400_CLKSRC_UHOST_MASK,
  373. .sources = &clkset_uhost,
  374. .divider_shift = S3C6400_CLKDIV1_UHOST_SHIFT,
  375. .reg_divider = S3C_CLK_DIV1,
  376. }, {
  377. .clk = {
  378. .name = "uclk1",
  379. .id = -1,
  380. .ctrlbit = S3C_CLKCON_SCLK_UART,
  381. .enable = s3c64xx_sclk_ctrl,
  382. },
  383. .shift = S3C6400_CLKSRC_UART_SHIFT,
  384. .mask = S3C6400_CLKSRC_UART_MASK,
  385. .sources = &clkset_uart,
  386. .divider_shift = S3C6400_CLKDIV2_UART_SHIFT,
  387. .reg_divider = S3C_CLK_DIV2,
  388. }, {
  389. /* Where does UCLK0 come from? */
  390. .clk = {
  391. .name = "spi-bus",
  392. .id = 0,
  393. .ctrlbit = S3C_CLKCON_SCLK_SPI0,
  394. .enable = s3c64xx_sclk_ctrl,
  395. },
  396. .shift = S3C6400_CLKSRC_SPI0_SHIFT,
  397. .mask = S3C6400_CLKSRC_SPI0_MASK,
  398. .sources = &clkset_spi_mmc,
  399. .divider_shift = S3C6400_CLKDIV2_SPI0_SHIFT,
  400. .reg_divider = S3C_CLK_DIV2,
  401. }, {
  402. .clk = {
  403. .name = "spi-bus",
  404. .id = 1,
  405. .ctrlbit = S3C_CLKCON_SCLK_SPI1,
  406. .enable = s3c64xx_sclk_ctrl,
  407. },
  408. .shift = S3C6400_CLKSRC_SPI1_SHIFT,
  409. .mask = S3C6400_CLKSRC_SPI1_MASK,
  410. .sources = &clkset_spi_mmc,
  411. .divider_shift = S3C6400_CLKDIV2_SPI1_SHIFT,
  412. .reg_divider = S3C_CLK_DIV2,
  413. }, {
  414. .clk = {
  415. .name = "audio-bus",
  416. .id = 0,
  417. .ctrlbit = S3C_CLKCON_SCLK_AUDIO0,
  418. .enable = s3c64xx_sclk_ctrl,
  419. },
  420. .shift = S3C6400_CLKSRC_AUDIO0_SHIFT,
  421. .mask = S3C6400_CLKSRC_AUDIO0_MASK,
  422. .sources = &clkset_audio0,
  423. .divider_shift = S3C6400_CLKDIV2_AUDIO0_SHIFT,
  424. .reg_divider = S3C_CLK_DIV2,
  425. }, {
  426. .clk = {
  427. .name = "audio-bus",
  428. .id = 1,
  429. .ctrlbit = S3C_CLKCON_SCLK_AUDIO1,
  430. .enable = s3c64xx_sclk_ctrl,
  431. },
  432. .shift = S3C6400_CLKSRC_AUDIO1_SHIFT,
  433. .mask = S3C6400_CLKSRC_AUDIO1_MASK,
  434. .sources = &clkset_audio1,
  435. .divider_shift = S3C6400_CLKDIV2_AUDIO1_SHIFT,
  436. .reg_divider = S3C_CLK_DIV2,
  437. }, {
  438. .clk = {
  439. .name = "irda-bus",
  440. .id = 0,
  441. .ctrlbit = S3C_CLKCON_SCLK_IRDA,
  442. .enable = s3c64xx_sclk_ctrl,
  443. },
  444. .shift = S3C6400_CLKSRC_IRDA_SHIFT,
  445. .mask = S3C6400_CLKSRC_IRDA_MASK,
  446. .sources = &clkset_irda,
  447. .divider_shift = S3C6400_CLKDIV2_IRDA_SHIFT,
  448. .reg_divider = S3C_CLK_DIV2,
  449. }, {
  450. .clk = {
  451. .name = "camera",
  452. .id = -1,
  453. .ctrlbit = S3C_CLKCON_SCLK_CAM,
  454. .enable = s3c64xx_sclk_ctrl,
  455. },
  456. .shift = 0,
  457. .mask = 0,
  458. .sources = &clkset_camif,
  459. .divider_shift = S3C6400_CLKDIV0_CAM_SHIFT,
  460. .reg_divider = S3C_CLK_DIV0,
  461. },
  462. };
  463. /* Clock initialisation code */
  464. static struct clksrc_clk *init_parents[] = {
  465. &clk_mout_apll,
  466. &clk_mout_epll,
  467. &clk_mout_mpll,
  468. };
  469. static void __init_or_cpufreq s3c6400_set_clksrc(struct clksrc_clk *clk)
  470. {
  471. struct clk_sources *srcs = clk->sources;
  472. u32 clksrc = __raw_readl(S3C_CLK_SRC);
  473. clksrc &= clk->mask;
  474. clksrc >>= clk->shift;
  475. if (clksrc > srcs->nr_sources || !srcs->sources[clksrc]) {
  476. printk(KERN_ERR "%s: bad source %d\n",
  477. clk->clk.name, clksrc);
  478. return;
  479. }
  480. clk->clk.parent = srcs->sources[clksrc];
  481. printk(KERN_INFO "%s: source is %s (%d), rate is %ld\n",
  482. clk->clk.name, clk->clk.parent->name, clksrc,
  483. clk_get_rate(&clk->clk));
  484. }
  485. #define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1)
  486. void __init_or_cpufreq s3c6400_setup_clocks(void)
  487. {
  488. struct clk *xtal_clk;
  489. unsigned long xtal;
  490. unsigned long fclk;
  491. unsigned long hclk;
  492. unsigned long hclk2;
  493. unsigned long pclk;
  494. unsigned long epll;
  495. unsigned long apll;
  496. unsigned long mpll;
  497. unsigned int ptr;
  498. u32 clkdiv0;
  499. printk(KERN_DEBUG "%s: registering clocks\n", __func__);
  500. clkdiv0 = __raw_readl(S3C_CLK_DIV0);
  501. printk(KERN_DEBUG "%s: clkdiv0 = %08x\n", __func__, clkdiv0);
  502. xtal_clk = clk_get(NULL, "xtal");
  503. BUG_ON(IS_ERR(xtal_clk));
  504. xtal = clk_get_rate(xtal_clk);
  505. clk_put(xtal_clk);
  506. printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
  507. /* For now assume the mux always selects the crystal */
  508. clk_ext_xtal_mux.parent = xtal_clk;
  509. epll = s3c6400_get_epll(xtal);
  510. mpll = s3c6400_get_pll(xtal, __raw_readl(S3C_MPLL_CON));
  511. apll = s3c6400_get_pll(xtal, __raw_readl(S3C_APLL_CON));
  512. fclk = mpll;
  513. printk(KERN_INFO "S3C64XX: PLL settings, A=%ld, M=%ld, E=%ld\n",
  514. apll, mpll, epll);
  515. hclk2 = mpll / GET_DIV(clkdiv0, S3C6400_CLKDIV0_HCLK2);
  516. hclk = hclk2 / GET_DIV(clkdiv0, S3C6400_CLKDIV0_HCLK);
  517. pclk = hclk2 / GET_DIV(clkdiv0, S3C6400_CLKDIV0_PCLK);
  518. printk(KERN_INFO "S3C64XX: HCLK2=%ld, HCLK=%ld, PCLK=%ld\n",
  519. hclk2, hclk, pclk);
  520. clk_fout_mpll.rate = mpll;
  521. clk_fout_epll.rate = epll;
  522. clk_fout_apll.rate = apll;
  523. clk_h2.rate = hclk2;
  524. clk_h.rate = hclk;
  525. clk_p.rate = pclk;
  526. clk_f.rate = fclk;
  527. for (ptr = 0; ptr < ARRAY_SIZE(init_parents); ptr++)
  528. s3c6400_set_clksrc(init_parents[ptr]);
  529. for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
  530. s3c6400_set_clksrc(&clksrcs[ptr]);
  531. }
  532. static struct clk *clks[] __initdata = {
  533. &clk_ext_xtal_mux,
  534. &clk_iis_cd0,
  535. &clk_iis_cd1,
  536. &clk_pcm_cd,
  537. &clk_mout_epll.clk,
  538. &clk_mout_mpll.clk,
  539. &clk_dout_mpll,
  540. &clk_arm,
  541. };
  542. /**
  543. * s3c6400_register_clocks - register clocks for s3c6400 and above
  544. * @armclk_divlimit: Divisor mask for ARMCLK
  545. *
  546. * Register the clocks for the S3C6400 and above SoC range, such
  547. * as ARMCLK and the clocks which have divider chains attached.
  548. *
  549. * This call does not setup the clocks, which is left to the
  550. * s3c6400_setup_clocks() call which may be needed by the cpufreq
  551. * or resume code to re-set the clocks if the bootloader has changed
  552. * them.
  553. */
  554. void __init s3c6400_register_clocks(unsigned armclk_divlimit)
  555. {
  556. struct clk *clkp;
  557. int ret;
  558. int ptr;
  559. armclk_mask = armclk_divlimit;
  560. for (ptr = 0; ptr < ARRAY_SIZE(clks); ptr++) {
  561. clkp = clks[ptr];
  562. ret = s3c24xx_register_clock(clkp);
  563. if (ret < 0) {
  564. printk(KERN_ERR "Failed to register clock %s (%d)\n",
  565. clkp->name, ret);
  566. }
  567. }
  568. for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) {
  569. clkp = &clksrcs[ptr].clk;
  570. /* all clksrc clocks have these */
  571. clkp->get_rate = s3c64xx_getrate_clksrc;
  572. clkp->set_rate = s3c64xx_setrate_clksrc;
  573. clkp->set_parent = s3c64xx_setparent_clksrc;
  574. clkp->round_rate = s3c64xx_roundrate_clksrc;
  575. ret = s3c24xx_register_clock(clkp);
  576. if (ret < 0) {
  577. printk(KERN_ERR "Failed to register clock %s (%d)\n",
  578. clkp->name, ret);
  579. }
  580. }
  581. }