clk-3xxx.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /*
  2. * OMAP3 Clock init
  3. *
  4. * Copyright (C) 2013 Texas Instruments, Inc
  5. * Tero Kristo (t-kristo@ti.com)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation version 2.
  10. *
  11. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  12. * kind, whether express or implied; without even the implied warranty
  13. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/list.h>
  18. #include <linux/clk.h>
  19. #include <linux/clk-provider.h>
  20. #include <linux/clk/ti.h>
  21. #include "clock.h"
  22. #define OMAP3430ES2_ST_DSS_IDLE_SHIFT 1
  23. #define OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT 5
  24. #define OMAP3430ES2_ST_SSI_IDLE_SHIFT 8
  25. #define OMAP34XX_CM_IDLEST_VAL 1
  26. /*
  27. * In AM35xx IPSS, the {ICK,FCK} enable bits for modules are exported
  28. * in the same register at a bit offset of 0x8. The EN_ACK for ICK is
  29. * at an offset of 4 from ICK enable bit.
  30. */
  31. #define AM35XX_IPSS_ICK_MASK 0xF
  32. #define AM35XX_IPSS_ICK_EN_ACK_OFFSET 0x4
  33. #define AM35XX_IPSS_ICK_FCK_OFFSET 0x8
  34. #define AM35XX_IPSS_CLK_IDLEST_VAL 0
  35. #define AM35XX_ST_IPSS_SHIFT 5
  36. /**
  37. * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI
  38. * @clk: struct clk * being enabled
  39. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  40. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  41. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  42. *
  43. * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift
  44. * from the CM_{I,F}CLKEN bit. Pass back the correct info via
  45. * @idlest_reg and @idlest_bit. No return value.
  46. */
  47. static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *clk,
  48. void __iomem **idlest_reg,
  49. u8 *idlest_bit,
  50. u8 *idlest_val)
  51. {
  52. u32 r;
  53. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  54. *idlest_reg = (__force void __iomem *)r;
  55. *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT;
  56. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  57. }
  58. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = {
  59. .allow_idle = omap2_clkt_iclk_allow_idle,
  60. .deny_idle = omap2_clkt_iclk_deny_idle,
  61. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  62. .find_companion = omap2_clk_dflt_find_companion,
  63. };
  64. /**
  65. * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST
  66. * @clk: struct clk * being enabled
  67. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  68. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  69. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  70. *
  71. * Some OMAP modules on OMAP3 ES2+ chips have both initiator and
  72. * target IDLEST bits. For our purposes, we are concerned with the
  73. * target IDLEST bits, which exist at a different bit position than
  74. * the *CLKEN bit position for these modules (DSS and USBHOST) (The
  75. * default find_idlest code assumes that they are at the same
  76. * position.) No return value.
  77. */
  78. static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk,
  79. void __iomem **idlest_reg,
  80. u8 *idlest_bit,
  81. u8 *idlest_val)
  82. {
  83. u32 r;
  84. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  85. *idlest_reg = (__force void __iomem *)r;
  86. /* USBHOST_IDLE has same shift */
  87. *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
  88. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  89. }
  90. const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait = {
  91. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  92. .find_companion = omap2_clk_dflt_find_companion,
  93. };
  94. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = {
  95. .allow_idle = omap2_clkt_iclk_allow_idle,
  96. .deny_idle = omap2_clkt_iclk_deny_idle,
  97. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  98. .find_companion = omap2_clk_dflt_find_companion,
  99. };
  100. /**
  101. * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB
  102. * @clk: struct clk * being enabled
  103. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  104. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  105. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  106. *
  107. * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different
  108. * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
  109. * @idlest_reg and @idlest_bit. No return value.
  110. */
  111. static void omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk,
  112. void __iomem **idlest_reg,
  113. u8 *idlest_bit,
  114. u8 *idlest_val)
  115. {
  116. u32 r;
  117. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  118. *idlest_reg = (__force void __iomem *)r;
  119. *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
  120. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  121. }
  122. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = {
  123. .allow_idle = omap2_clkt_iclk_allow_idle,
  124. .deny_idle = omap2_clkt_iclk_deny_idle,
  125. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  126. .find_companion = omap2_clk_dflt_find_companion,
  127. };
  128. /**
  129. * am35xx_clk_find_idlest - return clock ACK info for AM35XX IPSS
  130. * @clk: struct clk * being enabled
  131. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  132. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  133. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  134. *
  135. * The interface clocks on AM35xx IPSS reflects the clock idle status
  136. * in the enable register itsel at a bit offset of 4 from the enable
  137. * bit. A value of 1 indicates that clock is enabled.
  138. */
  139. static void am35xx_clk_find_idlest(struct clk_hw_omap *clk,
  140. void __iomem **idlest_reg,
  141. u8 *idlest_bit,
  142. u8 *idlest_val)
  143. {
  144. *idlest_reg = (__force void __iomem *)(clk->enable_reg);
  145. *idlest_bit = clk->enable_bit + AM35XX_IPSS_ICK_EN_ACK_OFFSET;
  146. *idlest_val = AM35XX_IPSS_CLK_IDLEST_VAL;
  147. }
  148. /**
  149. * am35xx_clk_find_companion - find companion clock to @clk
  150. * @clk: struct clk * to find the companion clock of
  151. * @other_reg: void __iomem ** to return the companion clock CM_*CLKEN va in
  152. * @other_bit: u8 ** to return the companion clock bit shift in
  153. *
  154. * Some clocks don't have companion clocks. For example, modules with
  155. * only an interface clock (such as HECC) don't have a companion
  156. * clock. Right now, this code relies on the hardware exporting a bit
  157. * in the correct companion register that indicates that the
  158. * nonexistent 'companion clock' is active. Future patches will
  159. * associate this type of code with per-module data structures to
  160. * avoid this issue, and remove the casts. No return value.
  161. */
  162. static void am35xx_clk_find_companion(struct clk_hw_omap *clk,
  163. void __iomem **other_reg,
  164. u8 *other_bit)
  165. {
  166. *other_reg = (__force void __iomem *)(clk->enable_reg);
  167. if (clk->enable_bit & AM35XX_IPSS_ICK_MASK)
  168. *other_bit = clk->enable_bit + AM35XX_IPSS_ICK_FCK_OFFSET;
  169. else
  170. *other_bit = clk->enable_bit - AM35XX_IPSS_ICK_FCK_OFFSET;
  171. }
  172. const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait = {
  173. .find_idlest = am35xx_clk_find_idlest,
  174. .find_companion = am35xx_clk_find_companion,
  175. };
  176. /**
  177. * am35xx_clk_ipss_find_idlest - return CM_IDLEST info for IPSS
  178. * @clk: struct clk * being enabled
  179. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  180. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  181. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  182. *
  183. * The IPSS target CM_IDLEST bit is at a different shift from the
  184. * CM_{I,F}CLKEN bit. Pass back the correct info via @idlest_reg
  185. * and @idlest_bit. No return value.
  186. */
  187. static void am35xx_clk_ipss_find_idlest(struct clk_hw_omap *clk,
  188. void __iomem **idlest_reg,
  189. u8 *idlest_bit,
  190. u8 *idlest_val)
  191. {
  192. u32 r;
  193. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  194. *idlest_reg = (__force void __iomem *)r;
  195. *idlest_bit = AM35XX_ST_IPSS_SHIFT;
  196. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  197. }
  198. const struct clk_hw_omap_ops clkhwops_am35xx_ipss_wait = {
  199. .allow_idle = omap2_clkt_iclk_allow_idle,
  200. .deny_idle = omap2_clkt_iclk_deny_idle,
  201. .find_idlest = am35xx_clk_ipss_find_idlest,
  202. .find_companion = omap2_clk_dflt_find_companion,
  203. };
  204. static struct ti_dt_clk omap3xxx_clks[] = {
  205. DT_CLK(NULL, "apb_pclk", "dummy_apb_pclk"),
  206. DT_CLK(NULL, "omap_32k_fck", "omap_32k_fck"),
  207. DT_CLK(NULL, "virt_12m_ck", "virt_12m_ck"),
  208. DT_CLK(NULL, "virt_13m_ck", "virt_13m_ck"),
  209. DT_CLK(NULL, "virt_19200000_ck", "virt_19200000_ck"),
  210. DT_CLK(NULL, "virt_26000000_ck", "virt_26000000_ck"),
  211. DT_CLK(NULL, "virt_38_4m_ck", "virt_38_4m_ck"),
  212. DT_CLK(NULL, "osc_sys_ck", "osc_sys_ck"),
  213. DT_CLK("twl", "fck", "osc_sys_ck"),
  214. DT_CLK(NULL, "sys_ck", "sys_ck"),
  215. DT_CLK(NULL, "omap_96m_alwon_fck", "omap_96m_alwon_fck"),
  216. DT_CLK("etb", "emu_core_alwon_ck", "emu_core_alwon_ck"),
  217. DT_CLK(NULL, "sys_altclk", "sys_altclk"),
  218. DT_CLK(NULL, "sys_clkout1", "sys_clkout1"),
  219. DT_CLK(NULL, "dpll1_ck", "dpll1_ck"),
  220. DT_CLK(NULL, "dpll1_x2_ck", "dpll1_x2_ck"),
  221. DT_CLK(NULL, "dpll1_x2m2_ck", "dpll1_x2m2_ck"),
  222. DT_CLK(NULL, "dpll3_ck", "dpll3_ck"),
  223. DT_CLK(NULL, "core_ck", "core_ck"),
  224. DT_CLK(NULL, "dpll3_x2_ck", "dpll3_x2_ck"),
  225. DT_CLK(NULL, "dpll3_m2_ck", "dpll3_m2_ck"),
  226. DT_CLK(NULL, "dpll3_m2x2_ck", "dpll3_m2x2_ck"),
  227. DT_CLK(NULL, "dpll3_m3_ck", "dpll3_m3_ck"),
  228. DT_CLK(NULL, "dpll3_m3x2_ck", "dpll3_m3x2_ck"),
  229. DT_CLK(NULL, "dpll4_ck", "dpll4_ck"),
  230. DT_CLK(NULL, "dpll4_x2_ck", "dpll4_x2_ck"),
  231. DT_CLK(NULL, "omap_96m_fck", "omap_96m_fck"),
  232. DT_CLK(NULL, "cm_96m_fck", "cm_96m_fck"),
  233. DT_CLK(NULL, "omap_54m_fck", "omap_54m_fck"),
  234. DT_CLK(NULL, "omap_48m_fck", "omap_48m_fck"),
  235. DT_CLK(NULL, "omap_12m_fck", "omap_12m_fck"),
  236. DT_CLK(NULL, "dpll4_m2_ck", "dpll4_m2_ck"),
  237. DT_CLK(NULL, "dpll4_m2x2_ck", "dpll4_m2x2_ck"),
  238. DT_CLK(NULL, "dpll4_m3_ck", "dpll4_m3_ck"),
  239. DT_CLK(NULL, "dpll4_m3x2_ck", "dpll4_m3x2_ck"),
  240. DT_CLK(NULL, "dpll4_m4_ck", "dpll4_m4_ck"),
  241. DT_CLK(NULL, "dpll4_m4x2_ck", "dpll4_m4x2_ck"),
  242. DT_CLK(NULL, "dpll4_m5_ck", "dpll4_m5_ck"),
  243. DT_CLK(NULL, "dpll4_m5x2_ck", "dpll4_m5x2_ck"),
  244. DT_CLK(NULL, "dpll4_m6_ck", "dpll4_m6_ck"),
  245. DT_CLK(NULL, "dpll4_m6x2_ck", "dpll4_m6x2_ck"),
  246. DT_CLK("etb", "emu_per_alwon_ck", "emu_per_alwon_ck"),
  247. DT_CLK(NULL, "clkout2_src_ck", "clkout2_src_ck"),
  248. DT_CLK(NULL, "sys_clkout2", "sys_clkout2"),
  249. DT_CLK(NULL, "corex2_fck", "corex2_fck"),
  250. DT_CLK(NULL, "dpll1_fck", "dpll1_fck"),
  251. DT_CLK(NULL, "mpu_ck", "mpu_ck"),
  252. DT_CLK(NULL, "arm_fck", "arm_fck"),
  253. DT_CLK("etb", "emu_mpu_alwon_ck", "emu_mpu_alwon_ck"),
  254. DT_CLK(NULL, "l3_ick", "l3_ick"),
  255. DT_CLK(NULL, "l4_ick", "l4_ick"),
  256. DT_CLK(NULL, "rm_ick", "rm_ick"),
  257. DT_CLK(NULL, "gpt10_fck", "gpt10_fck"),
  258. DT_CLK(NULL, "gpt11_fck", "gpt11_fck"),
  259. DT_CLK(NULL, "core_96m_fck", "core_96m_fck"),
  260. DT_CLK(NULL, "mmchs2_fck", "mmchs2_fck"),
  261. DT_CLK(NULL, "mmchs1_fck", "mmchs1_fck"),
  262. DT_CLK(NULL, "i2c3_fck", "i2c3_fck"),
  263. DT_CLK(NULL, "i2c2_fck", "i2c2_fck"),
  264. DT_CLK(NULL, "i2c1_fck", "i2c1_fck"),
  265. DT_CLK(NULL, "core_48m_fck", "core_48m_fck"),
  266. DT_CLK(NULL, "mcspi4_fck", "mcspi4_fck"),
  267. DT_CLK(NULL, "mcspi3_fck", "mcspi3_fck"),
  268. DT_CLK(NULL, "mcspi2_fck", "mcspi2_fck"),
  269. DT_CLK(NULL, "mcspi1_fck", "mcspi1_fck"),
  270. DT_CLK(NULL, "uart2_fck", "uart2_fck"),
  271. DT_CLK(NULL, "uart1_fck", "uart1_fck"),
  272. DT_CLK(NULL, "core_12m_fck", "core_12m_fck"),
  273. DT_CLK("omap_hdq.0", "fck", "hdq_fck"),
  274. DT_CLK(NULL, "hdq_fck", "hdq_fck"),
  275. DT_CLK(NULL, "core_l3_ick", "core_l3_ick"),
  276. DT_CLK(NULL, "sdrc_ick", "sdrc_ick"),
  277. DT_CLK(NULL, "gpmc_fck", "gpmc_fck"),
  278. DT_CLK(NULL, "core_l4_ick", "core_l4_ick"),
  279. DT_CLK("omap_hsmmc.1", "ick", "mmchs2_ick"),
  280. DT_CLK("omap_hsmmc.0", "ick", "mmchs1_ick"),
  281. DT_CLK(NULL, "mmchs2_ick", "mmchs2_ick"),
  282. DT_CLK(NULL, "mmchs1_ick", "mmchs1_ick"),
  283. DT_CLK("omap_hdq.0", "ick", "hdq_ick"),
  284. DT_CLK(NULL, "hdq_ick", "hdq_ick"),
  285. DT_CLK("omap2_mcspi.4", "ick", "mcspi4_ick"),
  286. DT_CLK("omap2_mcspi.3", "ick", "mcspi3_ick"),
  287. DT_CLK("omap2_mcspi.2", "ick", "mcspi2_ick"),
  288. DT_CLK("omap2_mcspi.1", "ick", "mcspi1_ick"),
  289. DT_CLK(NULL, "mcspi4_ick", "mcspi4_ick"),
  290. DT_CLK(NULL, "mcspi3_ick", "mcspi3_ick"),
  291. DT_CLK(NULL, "mcspi2_ick", "mcspi2_ick"),
  292. DT_CLK(NULL, "mcspi1_ick", "mcspi1_ick"),
  293. DT_CLK("omap_i2c.3", "ick", "i2c3_ick"),
  294. DT_CLK("omap_i2c.2", "ick", "i2c2_ick"),
  295. DT_CLK("omap_i2c.1", "ick", "i2c1_ick"),
  296. DT_CLK(NULL, "i2c3_ick", "i2c3_ick"),
  297. DT_CLK(NULL, "i2c2_ick", "i2c2_ick"),
  298. DT_CLK(NULL, "i2c1_ick", "i2c1_ick"),
  299. DT_CLK(NULL, "uart2_ick", "uart2_ick"),
  300. DT_CLK(NULL, "uart1_ick", "uart1_ick"),
  301. DT_CLK(NULL, "gpt11_ick", "gpt11_ick"),
  302. DT_CLK(NULL, "gpt10_ick", "gpt10_ick"),
  303. DT_CLK(NULL, "omapctrl_ick", "omapctrl_ick"),
  304. DT_CLK(NULL, "dss_tv_fck", "dss_tv_fck"),
  305. DT_CLK(NULL, "dss_96m_fck", "dss_96m_fck"),
  306. DT_CLK(NULL, "dss2_alwon_fck", "dss2_alwon_fck"),
  307. DT_CLK(NULL, "init_60m_fclk", "dummy_ck"),
  308. DT_CLK(NULL, "gpt1_fck", "gpt1_fck"),
  309. DT_CLK(NULL, "aes2_ick", "aes2_ick"),
  310. DT_CLK(NULL, "wkup_32k_fck", "wkup_32k_fck"),
  311. DT_CLK(NULL, "gpio1_dbck", "gpio1_dbck"),
  312. DT_CLK(NULL, "sha12_ick", "sha12_ick"),
  313. DT_CLK(NULL, "wdt2_fck", "wdt2_fck"),
  314. DT_CLK("omap_wdt", "ick", "wdt2_ick"),
  315. DT_CLK(NULL, "wdt2_ick", "wdt2_ick"),
  316. DT_CLK(NULL, "wdt1_ick", "wdt1_ick"),
  317. DT_CLK(NULL, "gpio1_ick", "gpio1_ick"),
  318. DT_CLK(NULL, "omap_32ksync_ick", "omap_32ksync_ick"),
  319. DT_CLK(NULL, "gpt12_ick", "gpt12_ick"),
  320. DT_CLK(NULL, "gpt1_ick", "gpt1_ick"),
  321. DT_CLK(NULL, "per_96m_fck", "per_96m_fck"),
  322. DT_CLK(NULL, "per_48m_fck", "per_48m_fck"),
  323. DT_CLK(NULL, "uart3_fck", "uart3_fck"),
  324. DT_CLK(NULL, "gpt2_fck", "gpt2_fck"),
  325. DT_CLK(NULL, "gpt3_fck", "gpt3_fck"),
  326. DT_CLK(NULL, "gpt4_fck", "gpt4_fck"),
  327. DT_CLK(NULL, "gpt5_fck", "gpt5_fck"),
  328. DT_CLK(NULL, "gpt6_fck", "gpt6_fck"),
  329. DT_CLK(NULL, "gpt7_fck", "gpt7_fck"),
  330. DT_CLK(NULL, "gpt8_fck", "gpt8_fck"),
  331. DT_CLK(NULL, "gpt9_fck", "gpt9_fck"),
  332. DT_CLK(NULL, "per_32k_alwon_fck", "per_32k_alwon_fck"),
  333. DT_CLK(NULL, "gpio6_dbck", "gpio6_dbck"),
  334. DT_CLK(NULL, "gpio5_dbck", "gpio5_dbck"),
  335. DT_CLK(NULL, "gpio4_dbck", "gpio4_dbck"),
  336. DT_CLK(NULL, "gpio3_dbck", "gpio3_dbck"),
  337. DT_CLK(NULL, "gpio2_dbck", "gpio2_dbck"),
  338. DT_CLK(NULL, "wdt3_fck", "wdt3_fck"),
  339. DT_CLK(NULL, "per_l4_ick", "per_l4_ick"),
  340. DT_CLK(NULL, "gpio6_ick", "gpio6_ick"),
  341. DT_CLK(NULL, "gpio5_ick", "gpio5_ick"),
  342. DT_CLK(NULL, "gpio4_ick", "gpio4_ick"),
  343. DT_CLK(NULL, "gpio3_ick", "gpio3_ick"),
  344. DT_CLK(NULL, "gpio2_ick", "gpio2_ick"),
  345. DT_CLK(NULL, "wdt3_ick", "wdt3_ick"),
  346. DT_CLK(NULL, "uart3_ick", "uart3_ick"),
  347. DT_CLK(NULL, "gpt9_ick", "gpt9_ick"),
  348. DT_CLK(NULL, "gpt8_ick", "gpt8_ick"),
  349. DT_CLK(NULL, "gpt7_ick", "gpt7_ick"),
  350. DT_CLK(NULL, "gpt6_ick", "gpt6_ick"),
  351. DT_CLK(NULL, "gpt5_ick", "gpt5_ick"),
  352. DT_CLK(NULL, "gpt4_ick", "gpt4_ick"),
  353. DT_CLK(NULL, "gpt3_ick", "gpt3_ick"),
  354. DT_CLK(NULL, "gpt2_ick", "gpt2_ick"),
  355. DT_CLK(NULL, "mcbsp_clks", "mcbsp_clks"),
  356. DT_CLK(NULL, "mcbsp1_ick", "mcbsp1_ick"),
  357. DT_CLK(NULL, "mcbsp2_ick", "mcbsp2_ick"),
  358. DT_CLK(NULL, "mcbsp3_ick", "mcbsp3_ick"),
  359. DT_CLK(NULL, "mcbsp4_ick", "mcbsp4_ick"),
  360. DT_CLK(NULL, "mcbsp5_ick", "mcbsp5_ick"),
  361. DT_CLK(NULL, "mcbsp1_fck", "mcbsp1_fck"),
  362. DT_CLK(NULL, "mcbsp2_fck", "mcbsp2_fck"),
  363. DT_CLK(NULL, "mcbsp3_fck", "mcbsp3_fck"),
  364. DT_CLK(NULL, "mcbsp4_fck", "mcbsp4_fck"),
  365. DT_CLK(NULL, "mcbsp5_fck", "mcbsp5_fck"),
  366. DT_CLK("etb", "emu_src_ck", "emu_src_ck"),
  367. DT_CLK(NULL, "emu_src_ck", "emu_src_ck"),
  368. DT_CLK(NULL, "pclk_fck", "pclk_fck"),
  369. DT_CLK(NULL, "pclkx2_fck", "pclkx2_fck"),
  370. DT_CLK(NULL, "atclk_fck", "atclk_fck"),
  371. DT_CLK(NULL, "traceclk_src_fck", "traceclk_src_fck"),
  372. DT_CLK(NULL, "traceclk_fck", "traceclk_fck"),
  373. DT_CLK(NULL, "secure_32k_fck", "secure_32k_fck"),
  374. DT_CLK(NULL, "gpt12_fck", "gpt12_fck"),
  375. DT_CLK(NULL, "wdt1_fck", "wdt1_fck"),
  376. DT_CLK(NULL, "timer_32k_ck", "omap_32k_fck"),
  377. DT_CLK(NULL, "timer_sys_ck", "sys_ck"),
  378. DT_CLK(NULL, "cpufreq_ck", "dpll1_ck"),
  379. { .node_name = NULL },
  380. };
  381. static struct ti_dt_clk omap34xx_omap36xx_clks[] = {
  382. DT_CLK(NULL, "aes1_ick", "aes1_ick"),
  383. DT_CLK("omap_rng", "ick", "rng_ick"),
  384. DT_CLK("omap3-rom-rng", "ick", "rng_ick"),
  385. DT_CLK(NULL, "sha11_ick", "sha11_ick"),
  386. DT_CLK(NULL, "des1_ick", "des1_ick"),
  387. DT_CLK(NULL, "cam_mclk", "cam_mclk"),
  388. DT_CLK(NULL, "cam_ick", "cam_ick"),
  389. DT_CLK(NULL, "csi2_96m_fck", "csi2_96m_fck"),
  390. DT_CLK(NULL, "security_l3_ick", "security_l3_ick"),
  391. DT_CLK(NULL, "pka_ick", "pka_ick"),
  392. DT_CLK(NULL, "icr_ick", "icr_ick"),
  393. DT_CLK("omap-aes", "ick", "aes2_ick"),
  394. DT_CLK("omap-sham", "ick", "sha12_ick"),
  395. DT_CLK(NULL, "des2_ick", "des2_ick"),
  396. DT_CLK(NULL, "mspro_ick", "mspro_ick"),
  397. DT_CLK(NULL, "mailboxes_ick", "mailboxes_ick"),
  398. DT_CLK(NULL, "ssi_l4_ick", "ssi_l4_ick"),
  399. DT_CLK(NULL, "sr1_fck", "sr1_fck"),
  400. DT_CLK(NULL, "sr2_fck", "sr2_fck"),
  401. DT_CLK(NULL, "sr_l4_ick", "sr_l4_ick"),
  402. DT_CLK(NULL, "security_l4_ick2", "security_l4_ick2"),
  403. DT_CLK(NULL, "wkup_l4_ick", "wkup_l4_ick"),
  404. DT_CLK(NULL, "dpll2_fck", "dpll2_fck"),
  405. DT_CLK(NULL, "iva2_ck", "iva2_ck"),
  406. DT_CLK(NULL, "modem_fck", "modem_fck"),
  407. DT_CLK(NULL, "sad2d_ick", "sad2d_ick"),
  408. DT_CLK(NULL, "mad2d_ick", "mad2d_ick"),
  409. DT_CLK(NULL, "mspro_fck", "mspro_fck"),
  410. DT_CLK(NULL, "dpll2_ck", "dpll2_ck"),
  411. DT_CLK(NULL, "dpll2_m2_ck", "dpll2_m2_ck"),
  412. { .node_name = NULL },
  413. };
  414. static struct ti_dt_clk omap36xx_omap3430es2plus_clks[] = {
  415. DT_CLK(NULL, "ssi_ssr_fck", "ssi_ssr_fck_3430es2"),
  416. DT_CLK(NULL, "ssi_sst_fck", "ssi_sst_fck_3430es2"),
  417. DT_CLK("musb-omap2430", "ick", "hsotgusb_ick_3430es2"),
  418. DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_3430es2"),
  419. DT_CLK(NULL, "ssi_ick", "ssi_ick_3430es2"),
  420. DT_CLK(NULL, "usim_fck", "usim_fck"),
  421. DT_CLK(NULL, "usim_ick", "usim_ick"),
  422. { .node_name = NULL },
  423. };
  424. static struct ti_dt_clk omap3430es1_clks[] = {
  425. DT_CLK(NULL, "gfx_l3_ck", "gfx_l3_ck"),
  426. DT_CLK(NULL, "gfx_l3_fck", "gfx_l3_fck"),
  427. DT_CLK(NULL, "gfx_l3_ick", "gfx_l3_ick"),
  428. DT_CLK(NULL, "gfx_cg1_ck", "gfx_cg1_ck"),
  429. DT_CLK(NULL, "gfx_cg2_ck", "gfx_cg2_ck"),
  430. DT_CLK(NULL, "d2d_26m_fck", "d2d_26m_fck"),
  431. DT_CLK(NULL, "fshostusb_fck", "fshostusb_fck"),
  432. DT_CLK(NULL, "ssi_ssr_fck", "ssi_ssr_fck_3430es1"),
  433. DT_CLK(NULL, "ssi_sst_fck", "ssi_sst_fck_3430es1"),
  434. DT_CLK("musb-omap2430", "ick", "hsotgusb_ick_3430es1"),
  435. DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_3430es1"),
  436. DT_CLK(NULL, "fac_ick", "fac_ick"),
  437. DT_CLK(NULL, "ssi_ick", "ssi_ick_3430es1"),
  438. DT_CLK(NULL, "usb_l4_ick", "usb_l4_ick"),
  439. DT_CLK(NULL, "dss1_alwon_fck", "dss1_alwon_fck_3430es1"),
  440. DT_CLK("omapdss_dss", "ick", "dss_ick_3430es1"),
  441. DT_CLK(NULL, "dss_ick", "dss_ick_3430es1"),
  442. { .node_name = NULL },
  443. };
  444. static struct ti_dt_clk omap36xx_am35xx_omap3430es2plus_clks[] = {
  445. DT_CLK(NULL, "virt_16_8m_ck", "virt_16_8m_ck"),
  446. DT_CLK(NULL, "dpll5_ck", "dpll5_ck"),
  447. DT_CLK(NULL, "dpll5_m2_ck", "dpll5_m2_ck"),
  448. DT_CLK(NULL, "sgx_fck", "sgx_fck"),
  449. DT_CLK(NULL, "sgx_ick", "sgx_ick"),
  450. DT_CLK(NULL, "cpefuse_fck", "cpefuse_fck"),
  451. DT_CLK(NULL, "ts_fck", "ts_fck"),
  452. DT_CLK(NULL, "usbtll_fck", "usbtll_fck"),
  453. DT_CLK(NULL, "usbtll_ick", "usbtll_ick"),
  454. DT_CLK("omap_hsmmc.2", "ick", "mmchs3_ick"),
  455. DT_CLK(NULL, "mmchs3_ick", "mmchs3_ick"),
  456. DT_CLK(NULL, "mmchs3_fck", "mmchs3_fck"),
  457. DT_CLK(NULL, "dss1_alwon_fck", "dss1_alwon_fck_3430es2"),
  458. DT_CLK("omapdss_dss", "ick", "dss_ick_3430es2"),
  459. DT_CLK(NULL, "dss_ick", "dss_ick_3430es2"),
  460. DT_CLK(NULL, "usbhost_120m_fck", "usbhost_120m_fck"),
  461. DT_CLK(NULL, "usbhost_48m_fck", "usbhost_48m_fck"),
  462. DT_CLK(NULL, "usbhost_ick", "usbhost_ick"),
  463. { .node_name = NULL },
  464. };
  465. static struct ti_dt_clk am35xx_clks[] = {
  466. DT_CLK(NULL, "ipss_ick", "ipss_ick"),
  467. DT_CLK(NULL, "rmii_ck", "rmii_ck"),
  468. DT_CLK(NULL, "pclk_ck", "pclk_ck"),
  469. DT_CLK(NULL, "emac_ick", "emac_ick"),
  470. DT_CLK(NULL, "emac_fck", "emac_fck"),
  471. DT_CLK("davinci_emac.0", NULL, "emac_ick"),
  472. DT_CLK("davinci_mdio.0", NULL, "emac_fck"),
  473. DT_CLK("vpfe-capture", "master", "vpfe_ick"),
  474. DT_CLK("vpfe-capture", "slave", "vpfe_fck"),
  475. DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_am35xx"),
  476. DT_CLK(NULL, "hsotgusb_fck", "hsotgusb_fck_am35xx"),
  477. DT_CLK(NULL, "hecc_ck", "hecc_ck"),
  478. DT_CLK(NULL, "uart4_ick", "uart4_ick_am35xx"),
  479. DT_CLK(NULL, "uart4_fck", "uart4_fck_am35xx"),
  480. { .node_name = NULL },
  481. };
  482. static struct ti_dt_clk omap36xx_clks[] = {
  483. DT_CLK(NULL, "omap_192m_alwon_fck", "omap_192m_alwon_fck"),
  484. DT_CLK(NULL, "uart4_fck", "uart4_fck"),
  485. DT_CLK(NULL, "uart4_ick", "uart4_ick"),
  486. { .node_name = NULL },
  487. };
  488. static const char *enable_init_clks[] = {
  489. "sdrc_ick",
  490. "gpmc_fck",
  491. "omapctrl_ick",
  492. };
  493. enum {
  494. OMAP3_SOC_AM35XX,
  495. OMAP3_SOC_OMAP3430_ES1,
  496. OMAP3_SOC_OMAP3430_ES2_PLUS,
  497. OMAP3_SOC_OMAP3630,
  498. };
  499. /**
  500. * omap3_clk_lock_dpll5 - locks DPLL5
  501. *
  502. * Locks DPLL5 to a pre-defined frequency. This is required for proper
  503. * operation of USB.
  504. */
  505. void __init omap3_clk_lock_dpll5(void)
  506. {
  507. struct clk *dpll5_clk;
  508. struct clk *dpll5_m2_clk;
  509. /*
  510. * Errata sprz319f advisory 2.1 documents a USB host clock drift issue
  511. * that can be worked around using specially crafted dpll5 settings
  512. * with a dpll5_m2 divider set to 8. Set the dpll5 rate to 8x the USB
  513. * host clock rate, its .set_rate handler() will detect that frequency
  514. * and use the errata settings.
  515. */
  516. dpll5_clk = clk_get(NULL, "dpll5_ck");
  517. clk_set_rate(dpll5_clk, OMAP3_DPLL5_FREQ_FOR_USBHOST * 8);
  518. clk_prepare_enable(dpll5_clk);
  519. /* Program dpll5_m2_clk divider */
  520. dpll5_m2_clk = clk_get(NULL, "dpll5_m2_ck");
  521. clk_prepare_enable(dpll5_m2_clk);
  522. clk_set_rate(dpll5_m2_clk, OMAP3_DPLL5_FREQ_FOR_USBHOST);
  523. clk_disable_unprepare(dpll5_m2_clk);
  524. clk_disable_unprepare(dpll5_clk);
  525. }
  526. static int __init omap3xxx_dt_clk_init(int soc_type)
  527. {
  528. if (soc_type == OMAP3_SOC_AM35XX || soc_type == OMAP3_SOC_OMAP3630 ||
  529. soc_type == OMAP3_SOC_OMAP3430_ES1 ||
  530. soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS)
  531. ti_dt_clocks_register(omap3xxx_clks);
  532. if (soc_type == OMAP3_SOC_AM35XX)
  533. ti_dt_clocks_register(am35xx_clks);
  534. if (soc_type == OMAP3_SOC_OMAP3630 || soc_type == OMAP3_SOC_AM35XX ||
  535. soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS)
  536. ti_dt_clocks_register(omap36xx_am35xx_omap3430es2plus_clks);
  537. if (soc_type == OMAP3_SOC_OMAP3430_ES1)
  538. ti_dt_clocks_register(omap3430es1_clks);
  539. if (soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS ||
  540. soc_type == OMAP3_SOC_OMAP3630)
  541. ti_dt_clocks_register(omap36xx_omap3430es2plus_clks);
  542. if (soc_type == OMAP3_SOC_OMAP3430_ES1 ||
  543. soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS ||
  544. soc_type == OMAP3_SOC_OMAP3630)
  545. ti_dt_clocks_register(omap34xx_omap36xx_clks);
  546. if (soc_type == OMAP3_SOC_OMAP3630)
  547. ti_dt_clocks_register(omap36xx_clks);
  548. omap2_clk_disable_autoidle_all();
  549. omap2_clk_enable_init_clocks(enable_init_clks,
  550. ARRAY_SIZE(enable_init_clks));
  551. pr_info("Clocking rate (Crystal/Core/MPU): %ld.%01ld/%ld/%ld MHz\n",
  552. (clk_get_rate(clk_get_sys(NULL, "osc_sys_ck")) / 1000000),
  553. (clk_get_rate(clk_get_sys(NULL, "osc_sys_ck")) / 100000) % 10,
  554. (clk_get_rate(clk_get_sys(NULL, "core_ck")) / 1000000),
  555. (clk_get_rate(clk_get_sys(NULL, "arm_fck")) / 1000000));
  556. if (soc_type != OMAP3_SOC_OMAP3430_ES1)
  557. omap3_clk_lock_dpll5();
  558. return 0;
  559. }
  560. int __init omap3430_dt_clk_init(void)
  561. {
  562. return omap3xxx_dt_clk_init(OMAP3_SOC_OMAP3430_ES2_PLUS);
  563. }
  564. int __init omap3630_dt_clk_init(void)
  565. {
  566. return omap3xxx_dt_clk_init(OMAP3_SOC_OMAP3630);
  567. }
  568. int __init am35xx_dt_clk_init(void)
  569. {
  570. return omap3xxx_dt_clk_init(OMAP3_SOC_AM35XX);
  571. }