clock.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*
  2. * arch/arm/mach-spear3xx/clock.c
  3. *
  4. * SPEAr3xx machines clock framework source file
  5. *
  6. * Copyright (C) 2009 ST Microelectronics
  7. * Viresh Kumar<viresh.kumar@st.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/clkdev.h>
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <linux/kernel.h>
  17. #include <asm/mach-types.h>
  18. #include <plat/clock.h>
  19. #include <mach/misc_regs.h>
  20. /* root clks */
  21. /* 32 KHz oscillator clock */
  22. static struct clk osc_32k_clk = {
  23. .flags = ALWAYS_ENABLED,
  24. .rate = 32000,
  25. };
  26. /* 24 MHz oscillator clock */
  27. static struct clk osc_24m_clk = {
  28. .flags = ALWAYS_ENABLED,
  29. .rate = 24000000,
  30. };
  31. /* clock derived from 32 KHz osc clk */
  32. /* rtc clock */
  33. static struct clk rtc_clk = {
  34. .pclk = &osc_32k_clk,
  35. .en_reg = PERIP1_CLK_ENB,
  36. .en_reg_bit = RTC_CLK_ENB,
  37. .recalc = &follow_parent,
  38. };
  39. /* clock derived from 24 MHz osc clk */
  40. /* pll masks structure */
  41. static struct pll_clk_masks pll1_masks = {
  42. .mode_mask = PLL_MODE_MASK,
  43. .mode_shift = PLL_MODE_SHIFT,
  44. .norm_fdbk_m_mask = PLL_NORM_FDBK_M_MASK,
  45. .norm_fdbk_m_shift = PLL_NORM_FDBK_M_SHIFT,
  46. .dith_fdbk_m_mask = PLL_DITH_FDBK_M_MASK,
  47. .dith_fdbk_m_shift = PLL_DITH_FDBK_M_SHIFT,
  48. .div_p_mask = PLL_DIV_P_MASK,
  49. .div_p_shift = PLL_DIV_P_SHIFT,
  50. .div_n_mask = PLL_DIV_N_MASK,
  51. .div_n_shift = PLL_DIV_N_SHIFT,
  52. };
  53. /* pll1 configuration structure */
  54. static struct pll_clk_config pll1_config = {
  55. .mode_reg = PLL1_CTR,
  56. .cfg_reg = PLL1_FRQ,
  57. .masks = &pll1_masks,
  58. };
  59. /* pll rate configuration table, in ascending order of rates */
  60. struct pll_rate_tbl pll_rtbl[] = {
  61. {.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* 266 MHz */
  62. {.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* 332 MHz */
  63. };
  64. /* PLL1 clock */
  65. static struct clk pll1_clk = {
  66. .flags = ENABLED_ON_INIT,
  67. .pclk = &osc_24m_clk,
  68. .en_reg = PLL1_CTR,
  69. .en_reg_bit = PLL_ENABLE,
  70. .calc_rate = &pll_calc_rate,
  71. .recalc = &pll_clk_recalc,
  72. .set_rate = &pll_clk_set_rate,
  73. .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1},
  74. .private_data = &pll1_config,
  75. };
  76. /* PLL3 48 MHz clock */
  77. static struct clk pll3_48m_clk = {
  78. .flags = ALWAYS_ENABLED,
  79. .pclk = &osc_24m_clk,
  80. .rate = 48000000,
  81. };
  82. /* watch dog timer clock */
  83. static struct clk wdt_clk = {
  84. .flags = ALWAYS_ENABLED,
  85. .pclk = &osc_24m_clk,
  86. .recalc = &follow_parent,
  87. };
  88. /* clock derived from pll1 clk */
  89. /* cpu clock */
  90. static struct clk cpu_clk = {
  91. .flags = ALWAYS_ENABLED,
  92. .pclk = &pll1_clk,
  93. .recalc = &follow_parent,
  94. };
  95. /* ahb masks structure */
  96. static struct bus_clk_masks ahb_masks = {
  97. .mask = PLL_HCLK_RATIO_MASK,
  98. .shift = PLL_HCLK_RATIO_SHIFT,
  99. };
  100. /* ahb configuration structure */
  101. static struct bus_clk_config ahb_config = {
  102. .reg = CORE_CLK_CFG,
  103. .masks = &ahb_masks,
  104. };
  105. /* ahb rate configuration table, in ascending order of rates */
  106. struct bus_rate_tbl bus_rtbl[] = {
  107. {.div = 3}, /* == parent divided by 4 */
  108. {.div = 2}, /* == parent divided by 3 */
  109. {.div = 1}, /* == parent divided by 2 */
  110. {.div = 0}, /* == parent divided by 1 */
  111. };
  112. /* ahb clock */
  113. static struct clk ahb_clk = {
  114. .flags = ALWAYS_ENABLED,
  115. .pclk = &pll1_clk,
  116. .calc_rate = &bus_calc_rate,
  117. .recalc = &bus_clk_recalc,
  118. .set_rate = &bus_clk_set_rate,
  119. .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2},
  120. .private_data = &ahb_config,
  121. };
  122. /* auxiliary synthesizers masks */
  123. static struct aux_clk_masks aux_masks = {
  124. .eq_sel_mask = AUX_EQ_SEL_MASK,
  125. .eq_sel_shift = AUX_EQ_SEL_SHIFT,
  126. .eq1_mask = AUX_EQ1_SEL,
  127. .eq2_mask = AUX_EQ2_SEL,
  128. .xscale_sel_mask = AUX_XSCALE_MASK,
  129. .xscale_sel_shift = AUX_XSCALE_SHIFT,
  130. .yscale_sel_mask = AUX_YSCALE_MASK,
  131. .yscale_sel_shift = AUX_YSCALE_SHIFT,
  132. };
  133. /* uart synth configurations */
  134. static struct aux_clk_config uart_synth_config = {
  135. .synth_reg = UART_CLK_SYNT,
  136. .masks = &aux_masks,
  137. };
  138. /* aux rate configuration table, in ascending order of rates */
  139. struct aux_rate_tbl aux_rtbl[] = {
  140. /* For PLL1 = 332 MHz */
  141. {.xscale = 1, .yscale = 8, .eq = 1}, /* 41.5 MHz */
  142. {.xscale = 1, .yscale = 4, .eq = 1}, /* 83 MHz */
  143. {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */
  144. };
  145. /* uart synth clock */
  146. static struct clk uart_synth_clk = {
  147. .en_reg = UART_CLK_SYNT,
  148. .en_reg_bit = AUX_SYNT_ENB,
  149. .pclk = &pll1_clk,
  150. .calc_rate = &aux_calc_rate,
  151. .recalc = &aux_clk_recalc,
  152. .set_rate = &aux_clk_set_rate,
  153. .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 1},
  154. .private_data = &uart_synth_config,
  155. };
  156. /* uart parents */
  157. static struct pclk_info uart_pclk_info[] = {
  158. {
  159. .pclk = &uart_synth_clk,
  160. .pclk_val = AUX_CLK_PLL1_VAL,
  161. }, {
  162. .pclk = &pll3_48m_clk,
  163. .pclk_val = AUX_CLK_PLL3_VAL,
  164. },
  165. };
  166. /* uart parent select structure */
  167. static struct pclk_sel uart_pclk_sel = {
  168. .pclk_info = uart_pclk_info,
  169. .pclk_count = ARRAY_SIZE(uart_pclk_info),
  170. .pclk_sel_reg = PERIP_CLK_CFG,
  171. .pclk_sel_mask = UART_CLK_MASK,
  172. };
  173. /* uart clock */
  174. static struct clk uart_clk = {
  175. .en_reg = PERIP1_CLK_ENB,
  176. .en_reg_bit = UART_CLK_ENB,
  177. .pclk_sel = &uart_pclk_sel,
  178. .pclk_sel_shift = UART_CLK_SHIFT,
  179. .recalc = &follow_parent,
  180. };
  181. /* firda configurations */
  182. static struct aux_clk_config firda_synth_config = {
  183. .synth_reg = FIRDA_CLK_SYNT,
  184. .masks = &aux_masks,
  185. };
  186. /* firda synth clock */
  187. static struct clk firda_synth_clk = {
  188. .en_reg = FIRDA_CLK_SYNT,
  189. .en_reg_bit = AUX_SYNT_ENB,
  190. .pclk = &pll1_clk,
  191. .calc_rate = &aux_calc_rate,
  192. .recalc = &aux_clk_recalc,
  193. .set_rate = &aux_clk_set_rate,
  194. .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 1},
  195. .private_data = &firda_synth_config,
  196. };
  197. /* firda parents */
  198. static struct pclk_info firda_pclk_info[] = {
  199. {
  200. .pclk = &firda_synth_clk,
  201. .pclk_val = AUX_CLK_PLL1_VAL,
  202. }, {
  203. .pclk = &pll3_48m_clk,
  204. .pclk_val = AUX_CLK_PLL3_VAL,
  205. },
  206. };
  207. /* firda parent select structure */
  208. static struct pclk_sel firda_pclk_sel = {
  209. .pclk_info = firda_pclk_info,
  210. .pclk_count = ARRAY_SIZE(firda_pclk_info),
  211. .pclk_sel_reg = PERIP_CLK_CFG,
  212. .pclk_sel_mask = FIRDA_CLK_MASK,
  213. };
  214. /* firda clock */
  215. static struct clk firda_clk = {
  216. .en_reg = PERIP1_CLK_ENB,
  217. .en_reg_bit = FIRDA_CLK_ENB,
  218. .pclk_sel = &firda_pclk_sel,
  219. .pclk_sel_shift = FIRDA_CLK_SHIFT,
  220. .recalc = &follow_parent,
  221. };
  222. /* gpt synthesizer masks */
  223. static struct gpt_clk_masks gpt_masks = {
  224. .mscale_sel_mask = GPT_MSCALE_MASK,
  225. .mscale_sel_shift = GPT_MSCALE_SHIFT,
  226. .nscale_sel_mask = GPT_NSCALE_MASK,
  227. .nscale_sel_shift = GPT_NSCALE_SHIFT,
  228. };
  229. /* gpt rate configuration table, in ascending order of rates */
  230. struct gpt_rate_tbl gpt_rtbl[] = {
  231. /* For pll1 = 332 MHz */
  232. {.mscale = 4, .nscale = 0}, /* 41.5 MHz */
  233. {.mscale = 2, .nscale = 0}, /* 55.3 MHz */
  234. {.mscale = 1, .nscale = 0}, /* 83 MHz */
  235. };
  236. /* gpt0 synth clk config*/
  237. static struct gpt_clk_config gpt0_synth_config = {
  238. .synth_reg = PRSC1_CLK_CFG,
  239. .masks = &gpt_masks,
  240. };
  241. /* gpt synth clock */
  242. static struct clk gpt0_synth_clk = {
  243. .flags = ALWAYS_ENABLED,
  244. .pclk = &pll1_clk,
  245. .calc_rate = &gpt_calc_rate,
  246. .recalc = &gpt_clk_recalc,
  247. .set_rate = &gpt_clk_set_rate,
  248. .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2},
  249. .private_data = &gpt0_synth_config,
  250. };
  251. /* gpt parents */
  252. static struct pclk_info gpt0_pclk_info[] = {
  253. {
  254. .pclk = &gpt0_synth_clk,
  255. .pclk_val = AUX_CLK_PLL1_VAL,
  256. }, {
  257. .pclk = &pll3_48m_clk,
  258. .pclk_val = AUX_CLK_PLL3_VAL,
  259. },
  260. };
  261. /* gpt parent select structure */
  262. static struct pclk_sel gpt0_pclk_sel = {
  263. .pclk_info = gpt0_pclk_info,
  264. .pclk_count = ARRAY_SIZE(gpt0_pclk_info),
  265. .pclk_sel_reg = PERIP_CLK_CFG,
  266. .pclk_sel_mask = GPT_CLK_MASK,
  267. };
  268. /* gpt0 timer clock */
  269. static struct clk gpt0_clk = {
  270. .flags = ALWAYS_ENABLED,
  271. .pclk_sel = &gpt0_pclk_sel,
  272. .pclk_sel_shift = GPT0_CLK_SHIFT,
  273. .recalc = &follow_parent,
  274. };
  275. /* gpt1 synth clk configurations */
  276. static struct gpt_clk_config gpt1_synth_config = {
  277. .synth_reg = PRSC2_CLK_CFG,
  278. .masks = &gpt_masks,
  279. };
  280. /* gpt1 synth clock */
  281. static struct clk gpt1_synth_clk = {
  282. .flags = ALWAYS_ENABLED,
  283. .pclk = &pll1_clk,
  284. .calc_rate = &gpt_calc_rate,
  285. .recalc = &gpt_clk_recalc,
  286. .set_rate = &gpt_clk_set_rate,
  287. .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2},
  288. .private_data = &gpt1_synth_config,
  289. };
  290. static struct pclk_info gpt1_pclk_info[] = {
  291. {
  292. .pclk = &gpt1_synth_clk,
  293. .pclk_val = AUX_CLK_PLL1_VAL,
  294. }, {
  295. .pclk = &pll3_48m_clk,
  296. .pclk_val = AUX_CLK_PLL3_VAL,
  297. },
  298. };
  299. /* gpt parent select structure */
  300. static struct pclk_sel gpt1_pclk_sel = {
  301. .pclk_info = gpt1_pclk_info,
  302. .pclk_count = ARRAY_SIZE(gpt1_pclk_info),
  303. .pclk_sel_reg = PERIP_CLK_CFG,
  304. .pclk_sel_mask = GPT_CLK_MASK,
  305. };
  306. /* gpt1 timer clock */
  307. static struct clk gpt1_clk = {
  308. .en_reg = PERIP1_CLK_ENB,
  309. .en_reg_bit = GPT1_CLK_ENB,
  310. .pclk_sel = &gpt1_pclk_sel,
  311. .pclk_sel_shift = GPT1_CLK_SHIFT,
  312. .recalc = &follow_parent,
  313. };
  314. /* gpt2 synth clk configurations */
  315. static struct gpt_clk_config gpt2_synth_config = {
  316. .synth_reg = PRSC3_CLK_CFG,
  317. .masks = &gpt_masks,
  318. };
  319. /* gpt1 synth clock */
  320. static struct clk gpt2_synth_clk = {
  321. .flags = ALWAYS_ENABLED,
  322. .pclk = &pll1_clk,
  323. .calc_rate = &gpt_calc_rate,
  324. .recalc = &gpt_clk_recalc,
  325. .set_rate = &gpt_clk_set_rate,
  326. .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2},
  327. .private_data = &gpt2_synth_config,
  328. };
  329. static struct pclk_info gpt2_pclk_info[] = {
  330. {
  331. .pclk = &gpt2_synth_clk,
  332. .pclk_val = AUX_CLK_PLL1_VAL,
  333. }, {
  334. .pclk = &pll3_48m_clk,
  335. .pclk_val = AUX_CLK_PLL3_VAL,
  336. },
  337. };
  338. /* gpt parent select structure */
  339. static struct pclk_sel gpt2_pclk_sel = {
  340. .pclk_info = gpt2_pclk_info,
  341. .pclk_count = ARRAY_SIZE(gpt2_pclk_info),
  342. .pclk_sel_reg = PERIP_CLK_CFG,
  343. .pclk_sel_mask = GPT_CLK_MASK,
  344. };
  345. /* gpt2 timer clock */
  346. static struct clk gpt2_clk = {
  347. .en_reg = PERIP1_CLK_ENB,
  348. .en_reg_bit = GPT2_CLK_ENB,
  349. .pclk_sel = &gpt2_pclk_sel,
  350. .pclk_sel_shift = GPT2_CLK_SHIFT,
  351. .recalc = &follow_parent,
  352. };
  353. /* clock derived from pll3 clk */
  354. /* usbh clock */
  355. static struct clk usbh_clk = {
  356. .pclk = &pll3_48m_clk,
  357. .en_reg = PERIP1_CLK_ENB,
  358. .en_reg_bit = USBH_CLK_ENB,
  359. .recalc = &follow_parent,
  360. };
  361. /* usbd clock */
  362. static struct clk usbd_clk = {
  363. .pclk = &pll3_48m_clk,
  364. .en_reg = PERIP1_CLK_ENB,
  365. .en_reg_bit = USBD_CLK_ENB,
  366. .recalc = &follow_parent,
  367. };
  368. /* clock derived from ahb clk */
  369. /* apb masks structure */
  370. static struct bus_clk_masks apb_masks = {
  371. .mask = HCLK_PCLK_RATIO_MASK,
  372. .shift = HCLK_PCLK_RATIO_SHIFT,
  373. };
  374. /* apb configuration structure */
  375. static struct bus_clk_config apb_config = {
  376. .reg = CORE_CLK_CFG,
  377. .masks = &apb_masks,
  378. };
  379. /* apb clock */
  380. static struct clk apb_clk = {
  381. .flags = ALWAYS_ENABLED,
  382. .pclk = &ahb_clk,
  383. .calc_rate = &bus_calc_rate,
  384. .recalc = &bus_clk_recalc,
  385. .set_rate = &bus_clk_set_rate,
  386. .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2},
  387. .private_data = &apb_config,
  388. };
  389. /* i2c clock */
  390. static struct clk i2c_clk = {
  391. .pclk = &ahb_clk,
  392. .en_reg = PERIP1_CLK_ENB,
  393. .en_reg_bit = I2C_CLK_ENB,
  394. .recalc = &follow_parent,
  395. };
  396. /* dma clock */
  397. static struct clk dma_clk = {
  398. .pclk = &ahb_clk,
  399. .en_reg = PERIP1_CLK_ENB,
  400. .en_reg_bit = DMA_CLK_ENB,
  401. .recalc = &follow_parent,
  402. };
  403. /* jpeg clock */
  404. static struct clk jpeg_clk = {
  405. .pclk = &ahb_clk,
  406. .en_reg = PERIP1_CLK_ENB,
  407. .en_reg_bit = JPEG_CLK_ENB,
  408. .recalc = &follow_parent,
  409. };
  410. /* gmac clock */
  411. static struct clk gmac_clk = {
  412. .pclk = &ahb_clk,
  413. .en_reg = PERIP1_CLK_ENB,
  414. .en_reg_bit = GMAC_CLK_ENB,
  415. .recalc = &follow_parent,
  416. };
  417. /* smi clock */
  418. static struct clk smi_clk = {
  419. .pclk = &ahb_clk,
  420. .en_reg = PERIP1_CLK_ENB,
  421. .en_reg_bit = SMI_CLK_ENB,
  422. .recalc = &follow_parent,
  423. };
  424. /* c3 clock */
  425. static struct clk c3_clk = {
  426. .pclk = &ahb_clk,
  427. .en_reg = PERIP1_CLK_ENB,
  428. .en_reg_bit = C3_CLK_ENB,
  429. .recalc = &follow_parent,
  430. };
  431. /* clock derived from apb clk */
  432. /* adc clock */
  433. static struct clk adc_clk = {
  434. .pclk = &apb_clk,
  435. .en_reg = PERIP1_CLK_ENB,
  436. .en_reg_bit = ADC_CLK_ENB,
  437. .recalc = &follow_parent,
  438. };
  439. #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
  440. /* emi clock */
  441. static struct clk emi_clk = {
  442. .flags = ALWAYS_ENABLED,
  443. .pclk = &ahb_clk,
  444. .recalc = &follow_parent,
  445. };
  446. #endif
  447. /* ssp clock */
  448. static struct clk ssp0_clk = {
  449. .pclk = &apb_clk,
  450. .en_reg = PERIP1_CLK_ENB,
  451. .en_reg_bit = SSP_CLK_ENB,
  452. .recalc = &follow_parent,
  453. };
  454. /* gpio clock */
  455. static struct clk gpio_clk = {
  456. .pclk = &apb_clk,
  457. .en_reg = PERIP1_CLK_ENB,
  458. .en_reg_bit = GPIO_CLK_ENB,
  459. .recalc = &follow_parent,
  460. };
  461. static struct clk dummy_apb_pclk;
  462. #if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR310) || \
  463. defined(CONFIG_MACH_SPEAR320)
  464. /* fsmc clock */
  465. static struct clk fsmc_clk = {
  466. .flags = ALWAYS_ENABLED,
  467. .pclk = &ahb_clk,
  468. .recalc = &follow_parent,
  469. };
  470. #endif
  471. /* common clocks to spear310 and spear320 */
  472. #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
  473. /* uart1 clock */
  474. static struct clk uart1_clk = {
  475. .flags = ALWAYS_ENABLED,
  476. .pclk = &apb_clk,
  477. .recalc = &follow_parent,
  478. };
  479. /* uart2 clock */
  480. static struct clk uart2_clk = {
  481. .flags = ALWAYS_ENABLED,
  482. .pclk = &apb_clk,
  483. .recalc = &follow_parent,
  484. };
  485. #endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */
  486. /* common clocks to spear300 and spear320 */
  487. #if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR320)
  488. /* clcd clock */
  489. static struct clk clcd_clk = {
  490. .flags = ALWAYS_ENABLED,
  491. .pclk = &pll3_48m_clk,
  492. .recalc = &follow_parent,
  493. };
  494. /* sdhci clock */
  495. static struct clk sdhci_clk = {
  496. .flags = ALWAYS_ENABLED,
  497. .pclk = &ahb_clk,
  498. .recalc = &follow_parent,
  499. };
  500. #endif /* CONFIG_MACH_SPEAR300 || CONFIG_MACH_SPEAR320 */
  501. /* spear300 machine specific clock structures */
  502. #ifdef CONFIG_MACH_SPEAR300
  503. /* gpio1 clock */
  504. static struct clk gpio1_clk = {
  505. .flags = ALWAYS_ENABLED,
  506. .pclk = &apb_clk,
  507. .recalc = &follow_parent,
  508. };
  509. /* keyboard clock */
  510. static struct clk kbd_clk = {
  511. .flags = ALWAYS_ENABLED,
  512. .pclk = &apb_clk,
  513. .recalc = &follow_parent,
  514. };
  515. #endif
  516. /* spear310 machine specific clock structures */
  517. #ifdef CONFIG_MACH_SPEAR310
  518. /* uart3 clock */
  519. static struct clk uart3_clk = {
  520. .flags = ALWAYS_ENABLED,
  521. .pclk = &apb_clk,
  522. .recalc = &follow_parent,
  523. };
  524. /* uart4 clock */
  525. static struct clk uart4_clk = {
  526. .flags = ALWAYS_ENABLED,
  527. .pclk = &apb_clk,
  528. .recalc = &follow_parent,
  529. };
  530. /* uart5 clock */
  531. static struct clk uart5_clk = {
  532. .flags = ALWAYS_ENABLED,
  533. .pclk = &apb_clk,
  534. .recalc = &follow_parent,
  535. };
  536. #endif
  537. /* spear320 machine specific clock structures */
  538. #ifdef CONFIG_MACH_SPEAR320
  539. /* can0 clock */
  540. static struct clk can0_clk = {
  541. .flags = ALWAYS_ENABLED,
  542. .pclk = &apb_clk,
  543. .recalc = &follow_parent,
  544. };
  545. /* can1 clock */
  546. static struct clk can1_clk = {
  547. .flags = ALWAYS_ENABLED,
  548. .pclk = &apb_clk,
  549. .recalc = &follow_parent,
  550. };
  551. /* i2c1 clock */
  552. static struct clk i2c1_clk = {
  553. .flags = ALWAYS_ENABLED,
  554. .pclk = &ahb_clk,
  555. .recalc = &follow_parent,
  556. };
  557. /* ssp1 clock */
  558. static struct clk ssp1_clk = {
  559. .flags = ALWAYS_ENABLED,
  560. .pclk = &apb_clk,
  561. .recalc = &follow_parent,
  562. };
  563. /* ssp2 clock */
  564. static struct clk ssp2_clk = {
  565. .flags = ALWAYS_ENABLED,
  566. .pclk = &apb_clk,
  567. .recalc = &follow_parent,
  568. };
  569. /* pwm clock */
  570. static struct clk pwm_clk = {
  571. .flags = ALWAYS_ENABLED,
  572. .pclk = &apb_clk,
  573. .recalc = &follow_parent,
  574. };
  575. #endif
  576. /* array of all spear 3xx clock lookups */
  577. static struct clk_lookup spear_clk_lookups[] = {
  578. CLKDEV_INIT(NULL, "apb_pclk", &dummy_apb_pclk),
  579. /* root clks */
  580. CLKDEV_INIT(NULL, "osc_32k_clk", &osc_32k_clk),
  581. CLKDEV_INIT(NULL, "osc_24m_clk", &osc_24m_clk),
  582. /* clock derived from 32 KHz osc clk */
  583. CLKDEV_INIT("rtc-spear", NULL, &rtc_clk),
  584. /* clock derived from 24 MHz osc clk */
  585. CLKDEV_INIT(NULL, "pll1_clk", &pll1_clk),
  586. CLKDEV_INIT(NULL, "pll3_48m_clk", &pll3_48m_clk),
  587. CLKDEV_INIT("wdt", NULL, &wdt_clk),
  588. /* clock derived from pll1 clk */
  589. CLKDEV_INIT(NULL, "cpu_clk", &cpu_clk),
  590. CLKDEV_INIT(NULL, "ahb_clk", &ahb_clk),
  591. CLKDEV_INIT(NULL, "uart_synth_clk", &uart_synth_clk),
  592. CLKDEV_INIT(NULL, "firda_synth_clk", &firda_synth_clk),
  593. CLKDEV_INIT(NULL, "gpt0_synth_clk", &gpt0_synth_clk),
  594. CLKDEV_INIT(NULL, "gpt1_synth_clk", &gpt1_synth_clk),
  595. CLKDEV_INIT(NULL, "gpt2_synth_clk", &gpt2_synth_clk),
  596. CLKDEV_INIT("uart", NULL, &uart_clk),
  597. CLKDEV_INIT("firda", NULL, &firda_clk),
  598. CLKDEV_INIT("gpt0", NULL, &gpt0_clk),
  599. CLKDEV_INIT("gpt1", NULL, &gpt1_clk),
  600. CLKDEV_INIT("gpt2", NULL, &gpt2_clk),
  601. /* clock derived from pll3 clk */
  602. CLKDEV_INIT("designware_udc", NULL, &usbd_clk),
  603. CLKDEV_INIT(NULL, "usbh_clk", &usbh_clk),
  604. /* clock derived from ahb clk */
  605. CLKDEV_INIT(NULL, "apb_clk", &apb_clk),
  606. CLKDEV_INIT("i2c_designware.0", NULL, &i2c_clk),
  607. CLKDEV_INIT("dma", NULL, &dma_clk),
  608. CLKDEV_INIT("jpeg", NULL, &jpeg_clk),
  609. CLKDEV_INIT("gmac", NULL, &gmac_clk),
  610. CLKDEV_INIT("smi", NULL, &smi_clk),
  611. CLKDEV_INIT("c3", NULL, &c3_clk),
  612. /* clock derived from apb clk */
  613. CLKDEV_INIT("adc", NULL, &adc_clk),
  614. CLKDEV_INIT("ssp-pl022.0", NULL, &ssp0_clk),
  615. CLKDEV_INIT("gpio", NULL, &gpio_clk),
  616. };
  617. /* array of all spear 300 clock lookups */
  618. #ifdef CONFIG_MACH_SPEAR300
  619. static struct clk_lookup spear300_clk_lookups[] = {
  620. CLKDEV_INIT("clcd", NULL, &clcd_clk),
  621. CLKDEV_INIT("fsmc", NULL, &fsmc_clk),
  622. CLKDEV_INIT("gpio1", NULL, &gpio1_clk),
  623. CLKDEV_INIT("keyboard", NULL, &kbd_clk),
  624. CLKDEV_INIT("sdhci", NULL, &sdhci_clk),
  625. };
  626. #endif
  627. /* array of all spear 310 clock lookups */
  628. #ifdef CONFIG_MACH_SPEAR310
  629. static struct clk_lookup spear310_clk_lookups[] = {
  630. CLKDEV_INIT("fsmc", NULL, &fsmc_clk),
  631. CLKDEV_INIT(NULL, "emi", &emi_clk),
  632. CLKDEV_INIT("uart1", NULL, &uart1_clk),
  633. CLKDEV_INIT("uart2", NULL, &uart2_clk),
  634. CLKDEV_INIT("uart3", NULL, &uart3_clk),
  635. CLKDEV_INIT("uart4", NULL, &uart4_clk),
  636. CLKDEV_INIT("uart5", NULL, &uart5_clk),
  637. };
  638. #endif
  639. /* array of all spear 320 clock lookups */
  640. #ifdef CONFIG_MACH_SPEAR320
  641. static struct clk_lookup spear320_clk_lookups[] = {
  642. CLKDEV_INIT("clcd", NULL, &clcd_clk),
  643. CLKDEV_INIT("fsmc", NULL, &fsmc_clk),
  644. CLKDEV_INIT("i2c_designware.1", NULL, &i2c1_clk),
  645. CLKDEV_INIT(NULL, "emi", &emi_clk),
  646. CLKDEV_INIT("pwm", NULL, &pwm_clk),
  647. CLKDEV_INIT("sdhci", NULL, &sdhci_clk),
  648. CLKDEV_INIT("c_can_platform.0", NULL, &can0_clk),
  649. CLKDEV_INIT("c_can_platform.1", NULL, &can1_clk),
  650. CLKDEV_INIT("ssp-pl022.1", NULL, &ssp1_clk),
  651. CLKDEV_INIT("ssp-pl022.2", NULL, &ssp2_clk),
  652. CLKDEV_INIT("uart1", NULL, &uart1_clk),
  653. CLKDEV_INIT("uart2", NULL, &uart2_clk),
  654. };
  655. #endif
  656. void __init spear3xx_clk_init(void)
  657. {
  658. int i, cnt;
  659. struct clk_lookup *lookups;
  660. if (machine_is_spear300()) {
  661. cnt = ARRAY_SIZE(spear300_clk_lookups);
  662. lookups = spear300_clk_lookups;
  663. } else if (machine_is_spear310()) {
  664. cnt = ARRAY_SIZE(spear310_clk_lookups);
  665. lookups = spear310_clk_lookups;
  666. } else {
  667. cnt = ARRAY_SIZE(spear320_clk_lookups);
  668. lookups = spear320_clk_lookups;
  669. }
  670. for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++)
  671. clk_register(&spear_clk_lookups[i]);
  672. for (i = 0; i < cnt; i++)
  673. clk_register(&lookups[i]);
  674. clk_init();
  675. }