clock.c 18 KB

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