clock.c 18 KB

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