clock.c 16 KB

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