clk-bcm21664.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * Copyright (C) 2014 Broadcom Corporation
  3. * Copyright 2014 Linaro Limited
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation version 2.
  8. *
  9. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  10. * kind, whether express or implied; without even the implied warranty
  11. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include "clk-kona.h"
  15. #include "dt-bindings/clock/bcm21664.h"
  16. #define BCM21664_CCU_COMMON(_name, _capname) \
  17. KONA_CCU_COMMON(BCM21664, _name, _capname)
  18. /* Root CCU */
  19. static struct peri_clk_data frac_1m_data = {
  20. .gate = HW_SW_GATE(0x214, 16, 0, 1),
  21. .clocks = CLOCKS("ref_crystal"),
  22. };
  23. static struct ccu_data root_ccu_data = {
  24. BCM21664_CCU_COMMON(root, ROOT),
  25. /* no policy control */
  26. .kona_clks = {
  27. [BCM21664_ROOT_CCU_FRAC_1M] =
  28. KONA_CLK(root, frac_1m, peri),
  29. [BCM21664_ROOT_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  30. },
  31. };
  32. /* AON CCU */
  33. static struct peri_clk_data hub_timer_data = {
  34. .gate = HW_SW_GATE(0x0414, 16, 0, 1),
  35. .hyst = HYST(0x0414, 8, 9),
  36. .clocks = CLOCKS("bbl_32k",
  37. "frac_1m",
  38. "dft_19_5m"),
  39. .sel = SELECTOR(0x0a10, 0, 2),
  40. .trig = TRIGGER(0x0a40, 4),
  41. };
  42. static struct ccu_data aon_ccu_data = {
  43. BCM21664_CCU_COMMON(aon, AON),
  44. .policy = {
  45. .enable = CCU_LVM_EN(0x0034, 0),
  46. .control = CCU_POLICY_CTL(0x000c, 0, 1, 2),
  47. },
  48. .kona_clks = {
  49. [BCM21664_AON_CCU_HUB_TIMER] =
  50. KONA_CLK(aon, hub_timer, peri),
  51. [BCM21664_AON_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  52. },
  53. };
  54. /* Master CCU */
  55. static struct peri_clk_data sdio1_data = {
  56. .gate = HW_SW_GATE(0x0358, 18, 2, 3),
  57. .clocks = CLOCKS("ref_crystal",
  58. "var_52m",
  59. "ref_52m",
  60. "var_96m",
  61. "ref_96m"),
  62. .sel = SELECTOR(0x0a28, 0, 3),
  63. .div = DIVIDER(0x0a28, 4, 14),
  64. .trig = TRIGGER(0x0afc, 9),
  65. };
  66. static struct peri_clk_data sdio2_data = {
  67. .gate = HW_SW_GATE(0x035c, 18, 2, 3),
  68. .clocks = CLOCKS("ref_crystal",
  69. "var_52m",
  70. "ref_52m",
  71. "var_96m",
  72. "ref_96m"),
  73. .sel = SELECTOR(0x0a2c, 0, 3),
  74. .div = DIVIDER(0x0a2c, 4, 14),
  75. .trig = TRIGGER(0x0afc, 10),
  76. };
  77. static struct peri_clk_data sdio3_data = {
  78. .gate = HW_SW_GATE(0x0364, 18, 2, 3),
  79. .clocks = CLOCKS("ref_crystal",
  80. "var_52m",
  81. "ref_52m",
  82. "var_96m",
  83. "ref_96m"),
  84. .sel = SELECTOR(0x0a34, 0, 3),
  85. .div = DIVIDER(0x0a34, 4, 14),
  86. .trig = TRIGGER(0x0afc, 12),
  87. };
  88. static struct peri_clk_data sdio4_data = {
  89. .gate = HW_SW_GATE(0x0360, 18, 2, 3),
  90. .clocks = CLOCKS("ref_crystal",
  91. "var_52m",
  92. "ref_52m",
  93. "var_96m",
  94. "ref_96m"),
  95. .sel = SELECTOR(0x0a30, 0, 3),
  96. .div = DIVIDER(0x0a30, 4, 14),
  97. .trig = TRIGGER(0x0afc, 11),
  98. };
  99. static struct peri_clk_data sdio1_sleep_data = {
  100. .clocks = CLOCKS("ref_32k"), /* Verify */
  101. .gate = HW_SW_GATE(0x0358, 18, 2, 3),
  102. };
  103. static struct peri_clk_data sdio2_sleep_data = {
  104. .clocks = CLOCKS("ref_32k"), /* Verify */
  105. .gate = HW_SW_GATE(0x035c, 18, 2, 3),
  106. };
  107. static struct peri_clk_data sdio3_sleep_data = {
  108. .clocks = CLOCKS("ref_32k"), /* Verify */
  109. .gate = HW_SW_GATE(0x0364, 18, 2, 3),
  110. };
  111. static struct peri_clk_data sdio4_sleep_data = {
  112. .clocks = CLOCKS("ref_32k"), /* Verify */
  113. .gate = HW_SW_GATE(0x0360, 18, 2, 3),
  114. };
  115. static struct ccu_data master_ccu_data = {
  116. BCM21664_CCU_COMMON(master, MASTER),
  117. .policy = {
  118. .enable = CCU_LVM_EN(0x0034, 0),
  119. .control = CCU_POLICY_CTL(0x000c, 0, 1, 2),
  120. },
  121. .kona_clks = {
  122. [BCM21664_MASTER_CCU_SDIO1] =
  123. KONA_CLK(master, sdio1, peri),
  124. [BCM21664_MASTER_CCU_SDIO2] =
  125. KONA_CLK(master, sdio2, peri),
  126. [BCM21664_MASTER_CCU_SDIO3] =
  127. KONA_CLK(master, sdio3, peri),
  128. [BCM21664_MASTER_CCU_SDIO4] =
  129. KONA_CLK(master, sdio4, peri),
  130. [BCM21664_MASTER_CCU_SDIO1_SLEEP] =
  131. KONA_CLK(master, sdio1_sleep, peri),
  132. [BCM21664_MASTER_CCU_SDIO2_SLEEP] =
  133. KONA_CLK(master, sdio2_sleep, peri),
  134. [BCM21664_MASTER_CCU_SDIO3_SLEEP] =
  135. KONA_CLK(master, sdio3_sleep, peri),
  136. [BCM21664_MASTER_CCU_SDIO4_SLEEP] =
  137. KONA_CLK(master, sdio4_sleep, peri),
  138. [BCM21664_MASTER_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  139. },
  140. };
  141. /* Slave CCU */
  142. static struct peri_clk_data uartb_data = {
  143. .gate = HW_SW_GATE(0x0400, 18, 2, 3),
  144. .clocks = CLOCKS("ref_crystal",
  145. "var_156m",
  146. "ref_156m"),
  147. .sel = SELECTOR(0x0a10, 0, 2),
  148. .div = FRAC_DIVIDER(0x0a10, 4, 12, 8),
  149. .trig = TRIGGER(0x0afc, 2),
  150. };
  151. static struct peri_clk_data uartb2_data = {
  152. .gate = HW_SW_GATE(0x0404, 18, 2, 3),
  153. .clocks = CLOCKS("ref_crystal",
  154. "var_156m",
  155. "ref_156m"),
  156. .sel = SELECTOR(0x0a14, 0, 2),
  157. .div = FRAC_DIVIDER(0x0a14, 4, 12, 8),
  158. .trig = TRIGGER(0x0afc, 3),
  159. };
  160. static struct peri_clk_data uartb3_data = {
  161. .gate = HW_SW_GATE(0x0408, 18, 2, 3),
  162. .clocks = CLOCKS("ref_crystal",
  163. "var_156m",
  164. "ref_156m"),
  165. .sel = SELECTOR(0x0a18, 0, 2),
  166. .div = FRAC_DIVIDER(0x0a18, 4, 12, 8),
  167. .trig = TRIGGER(0x0afc, 4),
  168. };
  169. static struct peri_clk_data bsc1_data = {
  170. .gate = HW_SW_GATE(0x0458, 18, 2, 3),
  171. .clocks = CLOCKS("ref_crystal",
  172. "var_104m",
  173. "ref_104m",
  174. "var_13m",
  175. "ref_13m"),
  176. .sel = SELECTOR(0x0a64, 0, 3),
  177. .trig = TRIGGER(0x0afc, 23),
  178. };
  179. static struct peri_clk_data bsc2_data = {
  180. .gate = HW_SW_GATE(0x045c, 18, 2, 3),
  181. .clocks = CLOCKS("ref_crystal",
  182. "var_104m",
  183. "ref_104m",
  184. "var_13m",
  185. "ref_13m"),
  186. .sel = SELECTOR(0x0a68, 0, 3),
  187. .trig = TRIGGER(0x0afc, 24),
  188. };
  189. static struct peri_clk_data bsc3_data = {
  190. .gate = HW_SW_GATE(0x0470, 18, 2, 3),
  191. .clocks = CLOCKS("ref_crystal",
  192. "var_104m",
  193. "ref_104m",
  194. "var_13m",
  195. "ref_13m"),
  196. .sel = SELECTOR(0x0a7c, 0, 3),
  197. .trig = TRIGGER(0x0afc, 18),
  198. };
  199. static struct peri_clk_data bsc4_data = {
  200. .gate = HW_SW_GATE(0x0474, 18, 2, 3),
  201. .clocks = CLOCKS("ref_crystal",
  202. "var_104m",
  203. "ref_104m",
  204. "var_13m",
  205. "ref_13m"),
  206. .sel = SELECTOR(0x0a80, 0, 3),
  207. .trig = TRIGGER(0x0afc, 19),
  208. };
  209. static struct ccu_data slave_ccu_data = {
  210. BCM21664_CCU_COMMON(slave, SLAVE),
  211. .policy = {
  212. .enable = CCU_LVM_EN(0x0034, 0),
  213. .control = CCU_POLICY_CTL(0x000c, 0, 1, 2),
  214. },
  215. .kona_clks = {
  216. [BCM21664_SLAVE_CCU_UARTB] =
  217. KONA_CLK(slave, uartb, peri),
  218. [BCM21664_SLAVE_CCU_UARTB2] =
  219. KONA_CLK(slave, uartb2, peri),
  220. [BCM21664_SLAVE_CCU_UARTB3] =
  221. KONA_CLK(slave, uartb3, peri),
  222. [BCM21664_SLAVE_CCU_BSC1] =
  223. KONA_CLK(slave, bsc1, peri),
  224. [BCM21664_SLAVE_CCU_BSC2] =
  225. KONA_CLK(slave, bsc2, peri),
  226. [BCM21664_SLAVE_CCU_BSC3] =
  227. KONA_CLK(slave, bsc3, peri),
  228. [BCM21664_SLAVE_CCU_BSC4] =
  229. KONA_CLK(slave, bsc4, peri),
  230. [BCM21664_SLAVE_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  231. },
  232. };
  233. /* Device tree match table callback functions */
  234. static void __init kona_dt_root_ccu_setup(struct device_node *node)
  235. {
  236. kona_dt_ccu_setup(&root_ccu_data, node);
  237. }
  238. static void __init kona_dt_aon_ccu_setup(struct device_node *node)
  239. {
  240. kona_dt_ccu_setup(&aon_ccu_data, node);
  241. }
  242. static void __init kona_dt_master_ccu_setup(struct device_node *node)
  243. {
  244. kona_dt_ccu_setup(&master_ccu_data, node);
  245. }
  246. static void __init kona_dt_slave_ccu_setup(struct device_node *node)
  247. {
  248. kona_dt_ccu_setup(&slave_ccu_data, node);
  249. }
  250. CLK_OF_DECLARE(bcm21664_root_ccu, BCM21664_DT_ROOT_CCU_COMPAT,
  251. kona_dt_root_ccu_setup);
  252. CLK_OF_DECLARE(bcm21664_aon_ccu, BCM21664_DT_AON_CCU_COMPAT,
  253. kona_dt_aon_ccu_setup);
  254. CLK_OF_DECLARE(bcm21664_master_ccu, BCM21664_DT_MASTER_CCU_COMPAT,
  255. kona_dt_master_ccu_setup);
  256. CLK_OF_DECLARE(bcm21664_slave_ccu, BCM21664_DT_SLAVE_CCU_COMPAT,
  257. kona_dt_slave_ccu_setup);