clock.c 19 KB

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