clk-bcm281xx.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. /*
  2. * Copyright (C) 2013 Broadcom Corporation
  3. * Copyright 2013 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/bcm281xx.h"
  16. #define BCM281XX_CCU_COMMON(_name, _ucase_name) \
  17. KONA_CCU_COMMON(BCM281XX, _name, _ucase_name)
  18. /* Root CCU */
  19. static struct peri_clk_data frac_1m_data = {
  20. .gate = HW_SW_GATE(0x214, 16, 0, 1),
  21. .trig = TRIGGER(0x0e04, 0),
  22. .div = FRAC_DIVIDER(0x0e00, 0, 22, 16),
  23. .clocks = CLOCKS("ref_crystal"),
  24. };
  25. static struct ccu_data root_ccu_data = {
  26. BCM281XX_CCU_COMMON(root, ROOT),
  27. .kona_clks = {
  28. [BCM281XX_ROOT_CCU_FRAC_1M] =
  29. KONA_CLK(root, frac_1m, peri),
  30. [BCM281XX_ROOT_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  31. },
  32. };
  33. /* AON CCU */
  34. static struct peri_clk_data hub_timer_data = {
  35. .gate = HW_SW_GATE(0x0414, 16, 0, 1),
  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 peri_clk_data pmu_bsc_data = {
  43. .gate = HW_SW_GATE(0x0418, 16, 0, 1),
  44. .clocks = CLOCKS("ref_crystal",
  45. "pmu_bsc_var",
  46. "bbl_32k"),
  47. .sel = SELECTOR(0x0a04, 0, 2),
  48. .div = DIVIDER(0x0a04, 3, 4),
  49. .trig = TRIGGER(0x0a40, 0),
  50. };
  51. static struct peri_clk_data pmu_bsc_var_data = {
  52. .clocks = CLOCKS("var_312m",
  53. "ref_312m"),
  54. .sel = SELECTOR(0x0a00, 0, 2),
  55. .div = DIVIDER(0x0a00, 4, 5),
  56. .trig = TRIGGER(0x0a40, 2),
  57. };
  58. static struct ccu_data aon_ccu_data = {
  59. BCM281XX_CCU_COMMON(aon, AON),
  60. .kona_clks = {
  61. [BCM281XX_AON_CCU_HUB_TIMER] =
  62. KONA_CLK(aon, hub_timer, peri),
  63. [BCM281XX_AON_CCU_PMU_BSC] =
  64. KONA_CLK(aon, pmu_bsc, peri),
  65. [BCM281XX_AON_CCU_PMU_BSC_VAR] =
  66. KONA_CLK(aon, pmu_bsc_var, peri),
  67. [BCM281XX_AON_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  68. },
  69. };
  70. /* Hub CCU */
  71. static struct peri_clk_data tmon_1m_data = {
  72. .gate = HW_SW_GATE(0x04a4, 18, 2, 3),
  73. .clocks = CLOCKS("ref_crystal",
  74. "frac_1m"),
  75. .sel = SELECTOR(0x0e74, 0, 2),
  76. .trig = TRIGGER(0x0e84, 1),
  77. };
  78. static struct ccu_data hub_ccu_data = {
  79. BCM281XX_CCU_COMMON(hub, HUB),
  80. .kona_clks = {
  81. [BCM281XX_HUB_CCU_TMON_1M] =
  82. KONA_CLK(hub, tmon_1m, peri),
  83. [BCM281XX_HUB_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  84. },
  85. };
  86. /* Master CCU */
  87. static struct peri_clk_data sdio1_data = {
  88. .gate = HW_SW_GATE(0x0358, 18, 2, 3),
  89. .clocks = CLOCKS("ref_crystal",
  90. "var_52m",
  91. "ref_52m",
  92. "var_96m",
  93. "ref_96m"),
  94. .sel = SELECTOR(0x0a28, 0, 3),
  95. .div = DIVIDER(0x0a28, 4, 14),
  96. .trig = TRIGGER(0x0afc, 9),
  97. };
  98. static struct peri_clk_data sdio2_data = {
  99. .gate = HW_SW_GATE(0x035c, 18, 2, 3),
  100. .clocks = CLOCKS("ref_crystal",
  101. "var_52m",
  102. "ref_52m",
  103. "var_96m",
  104. "ref_96m"),
  105. .sel = SELECTOR(0x0a2c, 0, 3),
  106. .div = DIVIDER(0x0a2c, 4, 14),
  107. .trig = TRIGGER(0x0afc, 10),
  108. };
  109. static struct peri_clk_data sdio3_data = {
  110. .gate = HW_SW_GATE(0x0364, 18, 2, 3),
  111. .clocks = CLOCKS("ref_crystal",
  112. "var_52m",
  113. "ref_52m",
  114. "var_96m",
  115. "ref_96m"),
  116. .sel = SELECTOR(0x0a34, 0, 3),
  117. .div = DIVIDER(0x0a34, 4, 14),
  118. .trig = TRIGGER(0x0afc, 12),
  119. };
  120. static struct peri_clk_data sdio4_data = {
  121. .gate = HW_SW_GATE(0x0360, 18, 2, 3),
  122. .clocks = CLOCKS("ref_crystal",
  123. "var_52m",
  124. "ref_52m",
  125. "var_96m",
  126. "ref_96m"),
  127. .sel = SELECTOR(0x0a30, 0, 3),
  128. .div = DIVIDER(0x0a30, 4, 14),
  129. .trig = TRIGGER(0x0afc, 11),
  130. };
  131. static struct peri_clk_data usb_ic_data = {
  132. .gate = HW_SW_GATE(0x0354, 18, 2, 3),
  133. .clocks = CLOCKS("ref_crystal",
  134. "var_96m",
  135. "ref_96m"),
  136. .div = FIXED_DIVIDER(2),
  137. .sel = SELECTOR(0x0a24, 0, 2),
  138. .trig = TRIGGER(0x0afc, 7),
  139. };
  140. /* also called usbh_48m */
  141. static struct peri_clk_data hsic2_48m_data = {
  142. .gate = HW_SW_GATE(0x0370, 18, 2, 3),
  143. .clocks = CLOCKS("ref_crystal",
  144. "var_96m",
  145. "ref_96m"),
  146. .sel = SELECTOR(0x0a38, 0, 2),
  147. .div = FIXED_DIVIDER(2),
  148. .trig = TRIGGER(0x0afc, 5),
  149. };
  150. /* also called usbh_12m */
  151. static struct peri_clk_data hsic2_12m_data = {
  152. .gate = HW_SW_GATE(0x0370, 20, 4, 5),
  153. .div = DIVIDER(0x0a38, 12, 2),
  154. .clocks = CLOCKS("ref_crystal",
  155. "var_96m",
  156. "ref_96m"),
  157. .pre_div = FIXED_DIVIDER(2),
  158. .sel = SELECTOR(0x0a38, 0, 2),
  159. .trig = TRIGGER(0x0afc, 5),
  160. };
  161. static struct ccu_data master_ccu_data = {
  162. BCM281XX_CCU_COMMON(master, MASTER),
  163. .kona_clks = {
  164. [BCM281XX_MASTER_CCU_SDIO1] =
  165. KONA_CLK(master, sdio1, peri),
  166. [BCM281XX_MASTER_CCU_SDIO2] =
  167. KONA_CLK(master, sdio2, peri),
  168. [BCM281XX_MASTER_CCU_SDIO3] =
  169. KONA_CLK(master, sdio3, peri),
  170. [BCM281XX_MASTER_CCU_SDIO4] =
  171. KONA_CLK(master, sdio4, peri),
  172. [BCM281XX_MASTER_CCU_USB_IC] =
  173. KONA_CLK(master, usb_ic, peri),
  174. [BCM281XX_MASTER_CCU_HSIC2_48M] =
  175. KONA_CLK(master, hsic2_48m, peri),
  176. [BCM281XX_MASTER_CCU_HSIC2_12M] =
  177. KONA_CLK(master, hsic2_12m, peri),
  178. [BCM281XX_MASTER_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  179. },
  180. };
  181. /* Slave CCU */
  182. static struct peri_clk_data uartb_data = {
  183. .gate = HW_SW_GATE(0x0400, 18, 2, 3),
  184. .clocks = CLOCKS("ref_crystal",
  185. "var_156m",
  186. "ref_156m"),
  187. .sel = SELECTOR(0x0a10, 0, 2),
  188. .div = FRAC_DIVIDER(0x0a10, 4, 12, 8),
  189. .trig = TRIGGER(0x0afc, 2),
  190. };
  191. static struct peri_clk_data uartb2_data = {
  192. .gate = HW_SW_GATE(0x0404, 18, 2, 3),
  193. .clocks = CLOCKS("ref_crystal",
  194. "var_156m",
  195. "ref_156m"),
  196. .sel = SELECTOR(0x0a14, 0, 2),
  197. .div = FRAC_DIVIDER(0x0a14, 4, 12, 8),
  198. .trig = TRIGGER(0x0afc, 3),
  199. };
  200. static struct peri_clk_data uartb3_data = {
  201. .gate = HW_SW_GATE(0x0408, 18, 2, 3),
  202. .clocks = CLOCKS("ref_crystal",
  203. "var_156m",
  204. "ref_156m"),
  205. .sel = SELECTOR(0x0a18, 0, 2),
  206. .div = FRAC_DIVIDER(0x0a18, 4, 12, 8),
  207. .trig = TRIGGER(0x0afc, 4),
  208. };
  209. static struct peri_clk_data uartb4_data = {
  210. .gate = HW_SW_GATE(0x0408, 18, 2, 3),
  211. .clocks = CLOCKS("ref_crystal",
  212. "var_156m",
  213. "ref_156m"),
  214. .sel = SELECTOR(0x0a1c, 0, 2),
  215. .div = FRAC_DIVIDER(0x0a1c, 4, 12, 8),
  216. .trig = TRIGGER(0x0afc, 5),
  217. };
  218. static struct peri_clk_data ssp0_data = {
  219. .gate = HW_SW_GATE(0x0410, 18, 2, 3),
  220. .clocks = CLOCKS("ref_crystal",
  221. "var_104m",
  222. "ref_104m",
  223. "var_96m",
  224. "ref_96m"),
  225. .sel = SELECTOR(0x0a20, 0, 3),
  226. .div = DIVIDER(0x0a20, 4, 14),
  227. .trig = TRIGGER(0x0afc, 6),
  228. };
  229. static struct peri_clk_data ssp2_data = {
  230. .gate = HW_SW_GATE(0x0418, 18, 2, 3),
  231. .clocks = CLOCKS("ref_crystal",
  232. "var_104m",
  233. "ref_104m",
  234. "var_96m",
  235. "ref_96m"),
  236. .sel = SELECTOR(0x0a28, 0, 3),
  237. .div = DIVIDER(0x0a28, 4, 14),
  238. .trig = TRIGGER(0x0afc, 8),
  239. };
  240. static struct peri_clk_data bsc1_data = {
  241. .gate = HW_SW_GATE(0x0458, 18, 2, 3),
  242. .clocks = CLOCKS("ref_crystal",
  243. "var_104m",
  244. "ref_104m",
  245. "var_13m",
  246. "ref_13m"),
  247. .sel = SELECTOR(0x0a64, 0, 3),
  248. .trig = TRIGGER(0x0afc, 23),
  249. };
  250. static struct peri_clk_data bsc2_data = {
  251. .gate = HW_SW_GATE(0x045c, 18, 2, 3),
  252. .clocks = CLOCKS("ref_crystal",
  253. "var_104m",
  254. "ref_104m",
  255. "var_13m",
  256. "ref_13m"),
  257. .sel = SELECTOR(0x0a68, 0, 3),
  258. .trig = TRIGGER(0x0afc, 24),
  259. };
  260. static struct peri_clk_data bsc3_data = {
  261. .gate = HW_SW_GATE(0x0484, 18, 2, 3),
  262. .clocks = CLOCKS("ref_crystal",
  263. "var_104m",
  264. "ref_104m",
  265. "var_13m",
  266. "ref_13m"),
  267. .sel = SELECTOR(0x0a84, 0, 3),
  268. .trig = TRIGGER(0x0b00, 2),
  269. };
  270. static struct peri_clk_data pwm_data = {
  271. .gate = HW_SW_GATE(0x0468, 18, 2, 3),
  272. .clocks = CLOCKS("ref_crystal",
  273. "var_104m"),
  274. .sel = SELECTOR(0x0a70, 0, 2),
  275. .div = DIVIDER(0x0a70, 4, 3),
  276. .trig = TRIGGER(0x0afc, 15),
  277. };
  278. static struct ccu_data slave_ccu_data = {
  279. BCM281XX_CCU_COMMON(slave, SLAVE),
  280. .kona_clks = {
  281. [BCM281XX_SLAVE_CCU_UARTB] =
  282. KONA_CLK(slave, uartb, peri),
  283. [BCM281XX_SLAVE_CCU_UARTB2] =
  284. KONA_CLK(slave, uartb2, peri),
  285. [BCM281XX_SLAVE_CCU_UARTB3] =
  286. KONA_CLK(slave, uartb3, peri),
  287. [BCM281XX_SLAVE_CCU_UARTB4] =
  288. KONA_CLK(slave, uartb4, peri),
  289. [BCM281XX_SLAVE_CCU_SSP0] =
  290. KONA_CLK(slave, ssp0, peri),
  291. [BCM281XX_SLAVE_CCU_SSP2] =
  292. KONA_CLK(slave, ssp2, peri),
  293. [BCM281XX_SLAVE_CCU_BSC1] =
  294. KONA_CLK(slave, bsc1, peri),
  295. [BCM281XX_SLAVE_CCU_BSC2] =
  296. KONA_CLK(slave, bsc2, peri),
  297. [BCM281XX_SLAVE_CCU_BSC3] =
  298. KONA_CLK(slave, bsc3, peri),
  299. [BCM281XX_SLAVE_CCU_PWM] =
  300. KONA_CLK(slave, pwm, peri),
  301. [BCM281XX_SLAVE_CCU_CLOCK_COUNT] = LAST_KONA_CLK,
  302. },
  303. };
  304. /* Device tree match table callback functions */
  305. static void __init kona_dt_root_ccu_setup(struct device_node *node)
  306. {
  307. kona_dt_ccu_setup(&root_ccu_data, node);
  308. }
  309. static void __init kona_dt_aon_ccu_setup(struct device_node *node)
  310. {
  311. kona_dt_ccu_setup(&aon_ccu_data, node);
  312. }
  313. static void __init kona_dt_hub_ccu_setup(struct device_node *node)
  314. {
  315. kona_dt_ccu_setup(&hub_ccu_data, node);
  316. }
  317. static void __init kona_dt_master_ccu_setup(struct device_node *node)
  318. {
  319. kona_dt_ccu_setup(&master_ccu_data, node);
  320. }
  321. static void __init kona_dt_slave_ccu_setup(struct device_node *node)
  322. {
  323. kona_dt_ccu_setup(&slave_ccu_data, node);
  324. }
  325. CLK_OF_DECLARE(bcm281xx_root_ccu, BCM281XX_DT_ROOT_CCU_COMPAT,
  326. kona_dt_root_ccu_setup);
  327. CLK_OF_DECLARE(bcm281xx_aon_ccu, BCM281XX_DT_AON_CCU_COMPAT,
  328. kona_dt_aon_ccu_setup);
  329. CLK_OF_DECLARE(bcm281xx_hub_ccu, BCM281XX_DT_HUB_CCU_COMPAT,
  330. kona_dt_hub_ccu_setup);
  331. CLK_OF_DECLARE(bcm281xx_master_ccu, BCM281XX_DT_MASTER_CCU_COMPAT,
  332. kona_dt_master_ccu_setup);
  333. CLK_OF_DECLARE(bcm281xx_slave_ccu, BCM281XX_DT_SLAVE_CCU_COMPAT,
  334. kona_dt_slave_ccu_setup);