clock.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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 usbh clk */
  369. /* usbh0 clock */
  370. static struct clk usbh0_clk = {
  371. .flags = ALWAYS_ENABLED,
  372. .pclk = &usbh_clk,
  373. .recalc = &follow_parent,
  374. };
  375. /* usbh1 clock */
  376. static struct clk usbh1_clk = {
  377. .flags = ALWAYS_ENABLED,
  378. .pclk = &usbh_clk,
  379. .recalc = &follow_parent,
  380. };
  381. /* clock derived from ahb clk */
  382. /* apb masks structure */
  383. static struct bus_clk_masks apb_masks = {
  384. .mask = HCLK_PCLK_RATIO_MASK,
  385. .shift = HCLK_PCLK_RATIO_SHIFT,
  386. };
  387. /* apb configuration structure */
  388. static struct bus_clk_config apb_config = {
  389. .reg = CORE_CLK_CFG,
  390. .masks = &apb_masks,
  391. };
  392. /* apb clock */
  393. static struct clk apb_clk = {
  394. .flags = ALWAYS_ENABLED,
  395. .pclk = &ahb_clk,
  396. .calc_rate = &bus_calc_rate,
  397. .recalc = &bus_clk_recalc,
  398. .set_rate = &bus_clk_set_rate,
  399. .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2},
  400. .private_data = &apb_config,
  401. };
  402. /* i2c clock */
  403. static struct clk i2c_clk = {
  404. .pclk = &ahb_clk,
  405. .en_reg = PERIP1_CLK_ENB,
  406. .en_reg_bit = I2C_CLK_ENB,
  407. .recalc = &follow_parent,
  408. };
  409. /* dma clock */
  410. static struct clk dma_clk = {
  411. .pclk = &ahb_clk,
  412. .en_reg = PERIP1_CLK_ENB,
  413. .en_reg_bit = DMA_CLK_ENB,
  414. .recalc = &follow_parent,
  415. };
  416. /* jpeg clock */
  417. static struct clk jpeg_clk = {
  418. .pclk = &ahb_clk,
  419. .en_reg = PERIP1_CLK_ENB,
  420. .en_reg_bit = JPEG_CLK_ENB,
  421. .recalc = &follow_parent,
  422. };
  423. /* gmac clock */
  424. static struct clk gmac_clk = {
  425. .pclk = &ahb_clk,
  426. .en_reg = PERIP1_CLK_ENB,
  427. .en_reg_bit = GMAC_CLK_ENB,
  428. .recalc = &follow_parent,
  429. };
  430. /* smi clock */
  431. static struct clk smi_clk = {
  432. .pclk = &ahb_clk,
  433. .en_reg = PERIP1_CLK_ENB,
  434. .en_reg_bit = SMI_CLK_ENB,
  435. .recalc = &follow_parent,
  436. };
  437. /* c3 clock */
  438. static struct clk c3_clk = {
  439. .pclk = &ahb_clk,
  440. .en_reg = PERIP1_CLK_ENB,
  441. .en_reg_bit = C3_CLK_ENB,
  442. .recalc = &follow_parent,
  443. };
  444. /* clock derived from apb clk */
  445. /* adc clock */
  446. static struct clk adc_clk = {
  447. .pclk = &apb_clk,
  448. .en_reg = PERIP1_CLK_ENB,
  449. .en_reg_bit = ADC_CLK_ENB,
  450. .recalc = &follow_parent,
  451. };
  452. #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
  453. /* emi clock */
  454. static struct clk emi_clk = {
  455. .flags = ALWAYS_ENABLED,
  456. .pclk = &ahb_clk,
  457. .recalc = &follow_parent,
  458. };
  459. #endif
  460. /* ssp clock */
  461. static struct clk ssp0_clk = {
  462. .pclk = &apb_clk,
  463. .en_reg = PERIP1_CLK_ENB,
  464. .en_reg_bit = SSP_CLK_ENB,
  465. .recalc = &follow_parent,
  466. };
  467. /* gpio clock */
  468. static struct clk gpio_clk = {
  469. .pclk = &apb_clk,
  470. .en_reg = PERIP1_CLK_ENB,
  471. .en_reg_bit = GPIO_CLK_ENB,
  472. .recalc = &follow_parent,
  473. };
  474. static struct clk dummy_apb_pclk;
  475. #if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR310) || \
  476. defined(CONFIG_MACH_SPEAR320)
  477. /* fsmc clock */
  478. static struct clk fsmc_clk = {
  479. .flags = ALWAYS_ENABLED,
  480. .pclk = &ahb_clk,
  481. .recalc = &follow_parent,
  482. };
  483. #endif
  484. /* common clocks to spear310 and spear320 */
  485. #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
  486. /* uart1 clock */
  487. static struct clk uart1_clk = {
  488. .flags = ALWAYS_ENABLED,
  489. .pclk = &apb_clk,
  490. .recalc = &follow_parent,
  491. };
  492. /* uart2 clock */
  493. static struct clk uart2_clk = {
  494. .flags = ALWAYS_ENABLED,
  495. .pclk = &apb_clk,
  496. .recalc = &follow_parent,
  497. };
  498. #endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */
  499. /* common clocks to spear300 and spear320 */
  500. #if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR320)
  501. /* clcd clock */
  502. static struct clk clcd_clk = {
  503. .flags = ALWAYS_ENABLED,
  504. .pclk = &pll3_48m_clk,
  505. .recalc = &follow_parent,
  506. };
  507. /* sdhci clock */
  508. static struct clk sdhci_clk = {
  509. .flags = ALWAYS_ENABLED,
  510. .pclk = &ahb_clk,
  511. .recalc = &follow_parent,
  512. };
  513. #endif /* CONFIG_MACH_SPEAR300 || CONFIG_MACH_SPEAR320 */
  514. /* spear300 machine specific clock structures */
  515. #ifdef CONFIG_MACH_SPEAR300
  516. /* gpio1 clock */
  517. static struct clk gpio1_clk = {
  518. .flags = ALWAYS_ENABLED,
  519. .pclk = &apb_clk,
  520. .recalc = &follow_parent,
  521. };
  522. /* keyboard clock */
  523. static struct clk kbd_clk = {
  524. .flags = ALWAYS_ENABLED,
  525. .pclk = &apb_clk,
  526. .recalc = &follow_parent,
  527. };
  528. #endif
  529. /* spear310 machine specific clock structures */
  530. #ifdef CONFIG_MACH_SPEAR310
  531. /* uart3 clock */
  532. static struct clk uart3_clk = {
  533. .flags = ALWAYS_ENABLED,
  534. .pclk = &apb_clk,
  535. .recalc = &follow_parent,
  536. };
  537. /* uart4 clock */
  538. static struct clk uart4_clk = {
  539. .flags = ALWAYS_ENABLED,
  540. .pclk = &apb_clk,
  541. .recalc = &follow_parent,
  542. };
  543. /* uart5 clock */
  544. static struct clk uart5_clk = {
  545. .flags = ALWAYS_ENABLED,
  546. .pclk = &apb_clk,
  547. .recalc = &follow_parent,
  548. };
  549. #endif
  550. /* spear320 machine specific clock structures */
  551. #ifdef CONFIG_MACH_SPEAR320
  552. /* can0 clock */
  553. static struct clk can0_clk = {
  554. .flags = ALWAYS_ENABLED,
  555. .pclk = &apb_clk,
  556. .recalc = &follow_parent,
  557. };
  558. /* can1 clock */
  559. static struct clk can1_clk = {
  560. .flags = ALWAYS_ENABLED,
  561. .pclk = &apb_clk,
  562. .recalc = &follow_parent,
  563. };
  564. /* i2c1 clock */
  565. static struct clk i2c1_clk = {
  566. .flags = ALWAYS_ENABLED,
  567. .pclk = &ahb_clk,
  568. .recalc = &follow_parent,
  569. };
  570. /* ssp1 clock */
  571. static struct clk ssp1_clk = {
  572. .flags = ALWAYS_ENABLED,
  573. .pclk = &apb_clk,
  574. .recalc = &follow_parent,
  575. };
  576. /* ssp2 clock */
  577. static struct clk ssp2_clk = {
  578. .flags = ALWAYS_ENABLED,
  579. .pclk = &apb_clk,
  580. .recalc = &follow_parent,
  581. };
  582. /* pwm clock */
  583. static struct clk pwm_clk = {
  584. .flags = ALWAYS_ENABLED,
  585. .pclk = &apb_clk,
  586. .recalc = &follow_parent,
  587. };
  588. #endif
  589. /* array of all spear 3xx clock lookups */
  590. static struct clk_lookup spear_clk_lookups[] = {
  591. CLKDEV_INIT(NULL, "apb_pclk", &dummy_apb_pclk),
  592. /* root clks */
  593. CLKDEV_INIT(NULL, "osc_32k_clk", &osc_32k_clk),
  594. CLKDEV_INIT(NULL, "osc_24m_clk", &osc_24m_clk),
  595. /* clock derived from 32 KHz osc clk */
  596. CLKDEV_INIT("rtc-spear", NULL, &rtc_clk),
  597. /* clock derived from 24 MHz osc clk */
  598. CLKDEV_INIT(NULL, "pll1_clk", &pll1_clk),
  599. CLKDEV_INIT(NULL, "pll3_48m_clk", &pll3_48m_clk),
  600. CLKDEV_INIT("wdt", NULL, &wdt_clk),
  601. /* clock derived from pll1 clk */
  602. CLKDEV_INIT(NULL, "cpu_clk", &cpu_clk),
  603. CLKDEV_INIT(NULL, "ahb_clk", &ahb_clk),
  604. CLKDEV_INIT(NULL, "uart_synth_clk", &uart_synth_clk),
  605. CLKDEV_INIT(NULL, "firda_synth_clk", &firda_synth_clk),
  606. CLKDEV_INIT(NULL, "gpt0_synth_clk", &gpt0_synth_clk),
  607. CLKDEV_INIT(NULL, "gpt1_synth_clk", &gpt1_synth_clk),
  608. CLKDEV_INIT(NULL, "gpt2_synth_clk", &gpt2_synth_clk),
  609. CLKDEV_INIT("uart", NULL, &uart_clk),
  610. CLKDEV_INIT("firda", NULL, &firda_clk),
  611. CLKDEV_INIT("gpt0", NULL, &gpt0_clk),
  612. CLKDEV_INIT("gpt1", NULL, &gpt1_clk),
  613. CLKDEV_INIT("gpt2", NULL, &gpt2_clk),
  614. /* clock derived from pll3 clk */
  615. CLKDEV_INIT("designware_udc", NULL, &usbd_clk),
  616. CLKDEV_INIT(NULL, "usbh_clk", &usbh_clk),
  617. /* clock derived from usbh clk */
  618. CLKDEV_INIT(NULL, "usbh.0_clk", &usbh0_clk),
  619. CLKDEV_INIT(NULL, "usbh.1_clk", &usbh1_clk),
  620. /* clock derived from ahb clk */
  621. CLKDEV_INIT(NULL, "apb_clk", &apb_clk),
  622. CLKDEV_INIT("i2c_designware.0", NULL, &i2c_clk),
  623. CLKDEV_INIT("dma", NULL, &dma_clk),
  624. CLKDEV_INIT("jpeg", NULL, &jpeg_clk),
  625. CLKDEV_INIT("gmac", NULL, &gmac_clk),
  626. CLKDEV_INIT("smi", NULL, &smi_clk),
  627. CLKDEV_INIT("c3", NULL, &c3_clk),
  628. /* clock derived from apb clk */
  629. CLKDEV_INIT("adc", NULL, &adc_clk),
  630. CLKDEV_INIT("ssp-pl022.0", NULL, &ssp0_clk),
  631. CLKDEV_INIT("gpio", NULL, &gpio_clk),
  632. };
  633. /* array of all spear 300 clock lookups */
  634. #ifdef CONFIG_MACH_SPEAR300
  635. static struct clk_lookup spear300_clk_lookups[] = {
  636. CLKDEV_INIT("clcd", NULL, &clcd_clk),
  637. CLKDEV_INIT("fsmc", NULL, &fsmc_clk),
  638. CLKDEV_INIT("gpio1", NULL, &gpio1_clk),
  639. CLKDEV_INIT("keyboard", NULL, &kbd_clk),
  640. CLKDEV_INIT("sdhci", NULL, &sdhci_clk),
  641. };
  642. #endif
  643. /* array of all spear 310 clock lookups */
  644. #ifdef CONFIG_MACH_SPEAR310
  645. static struct clk_lookup spear310_clk_lookups[] = {
  646. CLKDEV_INIT("fsmc", NULL, &fsmc_clk),
  647. CLKDEV_INIT(NULL, "emi", &emi_clk),
  648. CLKDEV_INIT("uart1", NULL, &uart1_clk),
  649. CLKDEV_INIT("uart2", NULL, &uart2_clk),
  650. CLKDEV_INIT("uart3", NULL, &uart3_clk),
  651. CLKDEV_INIT("uart4", NULL, &uart4_clk),
  652. CLKDEV_INIT("uart5", NULL, &uart5_clk),
  653. };
  654. #endif
  655. /* array of all spear 320 clock lookups */
  656. #ifdef CONFIG_MACH_SPEAR320
  657. static struct clk_lookup spear320_clk_lookups[] = {
  658. CLKDEV_INIT("clcd", NULL, &clcd_clk),
  659. CLKDEV_INIT("fsmc", NULL, &fsmc_clk),
  660. CLKDEV_INIT("i2c_designware.1", NULL, &i2c1_clk),
  661. CLKDEV_INIT(NULL, "emi", &emi_clk),
  662. CLKDEV_INIT("pwm", NULL, &pwm_clk),
  663. CLKDEV_INIT("sdhci", NULL, &sdhci_clk),
  664. CLKDEV_INIT("c_can_platform.0", NULL, &can0_clk),
  665. CLKDEV_INIT("c_can_platform.1", NULL, &can1_clk),
  666. CLKDEV_INIT("ssp-pl022.1", NULL, &ssp1_clk),
  667. CLKDEV_INIT("ssp-pl022.2", NULL, &ssp2_clk),
  668. CLKDEV_INIT("uart1", NULL, &uart1_clk),
  669. CLKDEV_INIT("uart2", NULL, &uart2_clk),
  670. };
  671. #endif
  672. void __init spear3xx_clk_init(void)
  673. {
  674. int i, cnt;
  675. struct clk_lookup *lookups;
  676. if (machine_is_spear300()) {
  677. cnt = ARRAY_SIZE(spear300_clk_lookups);
  678. lookups = spear300_clk_lookups;
  679. } else if (machine_is_spear310()) {
  680. cnt = ARRAY_SIZE(spear310_clk_lookups);
  681. lookups = spear310_clk_lookups;
  682. } else {
  683. cnt = ARRAY_SIZE(spear320_clk_lookups);
  684. lookups = spear320_clk_lookups;
  685. }
  686. for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++)
  687. clk_register(&spear_clk_lookups[i]);
  688. for (i = 0; i < cnt; i++)
  689. clk_register(&lookups[i]);
  690. clk_init();
  691. }