clock.c 16 KB

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