clock.c 18 KB

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