clk-px30.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. /*
  2. * Copyright (c) 2018 Rockchip Electronics Co. Ltd.
  3. * Author: Elaine Zhang<zhangqing@rock-chips.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/clk-provider.h>
  16. #include <linux/of.h>
  17. #include <linux/of_address.h>
  18. #include <linux/syscore_ops.h>
  19. #include <dt-bindings/clock/px30-cru.h>
  20. #include "clk.h"
  21. #define PX30_GRF_SOC_STATUS0 0x480
  22. enum px30_plls {
  23. apll, dpll, cpll, npll, apll_b_h, apll_b_l,
  24. };
  25. enum px30_pmu_plls {
  26. gpll,
  27. };
  28. static struct rockchip_pll_rate_table px30_pll_rates[] = {
  29. /* _mhz, _refdiv, _fbdiv, _postdiv1, _postdiv2, _dsmpd, _frac */
  30. RK3036_PLL_RATE(1608000000, 1, 67, 1, 1, 1, 0),
  31. RK3036_PLL_RATE(1584000000, 1, 66, 1, 1, 1, 0),
  32. RK3036_PLL_RATE(1560000000, 1, 65, 1, 1, 1, 0),
  33. RK3036_PLL_RATE(1536000000, 1, 64, 1, 1, 1, 0),
  34. RK3036_PLL_RATE(1512000000, 1, 63, 1, 1, 1, 0),
  35. RK3036_PLL_RATE(1488000000, 1, 62, 1, 1, 1, 0),
  36. RK3036_PLL_RATE(1464000000, 1, 61, 1, 1, 1, 0),
  37. RK3036_PLL_RATE(1440000000, 1, 60, 1, 1, 1, 0),
  38. RK3036_PLL_RATE(1416000000, 1, 59, 1, 1, 1, 0),
  39. RK3036_PLL_RATE(1392000000, 1, 58, 1, 1, 1, 0),
  40. RK3036_PLL_RATE(1368000000, 1, 57, 1, 1, 1, 0),
  41. RK3036_PLL_RATE(1344000000, 1, 56, 1, 1, 1, 0),
  42. RK3036_PLL_RATE(1320000000, 1, 55, 1, 1, 1, 0),
  43. RK3036_PLL_RATE(1296000000, 1, 54, 1, 1, 1, 0),
  44. RK3036_PLL_RATE(1272000000, 1, 53, 1, 1, 1, 0),
  45. RK3036_PLL_RATE(1248000000, 1, 52, 1, 1, 1, 0),
  46. RK3036_PLL_RATE(1200000000, 1, 50, 1, 1, 1, 0),
  47. RK3036_PLL_RATE(1188000000, 2, 99, 1, 1, 1, 0),
  48. RK3036_PLL_RATE(1104000000, 1, 46, 1, 1, 1, 0),
  49. RK3036_PLL_RATE(1100000000, 12, 550, 1, 1, 1, 0),
  50. RK3036_PLL_RATE(1008000000, 1, 84, 2, 1, 1, 0),
  51. RK3036_PLL_RATE(1000000000, 6, 500, 2, 1, 1, 0),
  52. RK3036_PLL_RATE(984000000, 1, 82, 2, 1, 1, 0),
  53. RK3036_PLL_RATE(960000000, 1, 80, 2, 1, 1, 0),
  54. RK3036_PLL_RATE(936000000, 1, 78, 2, 1, 1, 0),
  55. RK3036_PLL_RATE(912000000, 1, 76, 2, 1, 1, 0),
  56. RK3036_PLL_RATE(900000000, 4, 300, 2, 1, 1, 0),
  57. RK3036_PLL_RATE(888000000, 1, 74, 2, 1, 1, 0),
  58. RK3036_PLL_RATE(864000000, 1, 72, 2, 1, 1, 0),
  59. RK3036_PLL_RATE(840000000, 1, 70, 2, 1, 1, 0),
  60. RK3036_PLL_RATE(816000000, 1, 68, 2, 1, 1, 0),
  61. RK3036_PLL_RATE(800000000, 6, 400, 2, 1, 1, 0),
  62. RK3036_PLL_RATE(700000000, 6, 350, 2, 1, 1, 0),
  63. RK3036_PLL_RATE(696000000, 1, 58, 2, 1, 1, 0),
  64. RK3036_PLL_RATE(624000000, 1, 52, 2, 1, 1, 0),
  65. RK3036_PLL_RATE(600000000, 1, 75, 3, 1, 1, 0),
  66. RK3036_PLL_RATE(594000000, 2, 99, 2, 1, 1, 0),
  67. RK3036_PLL_RATE(504000000, 1, 63, 3, 1, 1, 0),
  68. RK3036_PLL_RATE(500000000, 6, 250, 2, 1, 1, 0),
  69. RK3036_PLL_RATE(408000000, 1, 68, 2, 2, 1, 0),
  70. RK3036_PLL_RATE(312000000, 1, 52, 2, 2, 1, 0),
  71. RK3036_PLL_RATE(216000000, 1, 72, 4, 2, 1, 0),
  72. RK3036_PLL_RATE(96000000, 1, 64, 4, 4, 1, 0),
  73. { /* sentinel */ },
  74. };
  75. #define PX30_DIV_ACLKM_MASK 0x7
  76. #define PX30_DIV_ACLKM_SHIFT 12
  77. #define PX30_DIV_PCLK_DBG_MASK 0xf
  78. #define PX30_DIV_PCLK_DBG_SHIFT 8
  79. #define PX30_CLKSEL0(_aclk_core, _pclk_dbg) \
  80. { \
  81. .reg = PX30_CLKSEL_CON(0), \
  82. .val = HIWORD_UPDATE(_aclk_core, PX30_DIV_ACLKM_MASK, \
  83. PX30_DIV_ACLKM_SHIFT) | \
  84. HIWORD_UPDATE(_pclk_dbg, PX30_DIV_PCLK_DBG_MASK, \
  85. PX30_DIV_PCLK_DBG_SHIFT), \
  86. }
  87. #define PX30_CPUCLK_RATE(_prate, _aclk_core, _pclk_dbg) \
  88. { \
  89. .prate = _prate, \
  90. .divs = { \
  91. PX30_CLKSEL0(_aclk_core, _pclk_dbg), \
  92. }, \
  93. }
  94. static struct rockchip_cpuclk_rate_table px30_cpuclk_rates[] __initdata = {
  95. PX30_CPUCLK_RATE(1608000000, 1, 7),
  96. PX30_CPUCLK_RATE(1584000000, 1, 7),
  97. PX30_CPUCLK_RATE(1560000000, 1, 7),
  98. PX30_CPUCLK_RATE(1536000000, 1, 7),
  99. PX30_CPUCLK_RATE(1512000000, 1, 7),
  100. PX30_CPUCLK_RATE(1488000000, 1, 5),
  101. PX30_CPUCLK_RATE(1464000000, 1, 5),
  102. PX30_CPUCLK_RATE(1440000000, 1, 5),
  103. PX30_CPUCLK_RATE(1416000000, 1, 5),
  104. PX30_CPUCLK_RATE(1392000000, 1, 5),
  105. PX30_CPUCLK_RATE(1368000000, 1, 5),
  106. PX30_CPUCLK_RATE(1344000000, 1, 5),
  107. PX30_CPUCLK_RATE(1320000000, 1, 5),
  108. PX30_CPUCLK_RATE(1296000000, 1, 5),
  109. PX30_CPUCLK_RATE(1272000000, 1, 5),
  110. PX30_CPUCLK_RATE(1248000000, 1, 5),
  111. PX30_CPUCLK_RATE(1224000000, 1, 5),
  112. PX30_CPUCLK_RATE(1200000000, 1, 5),
  113. PX30_CPUCLK_RATE(1104000000, 1, 5),
  114. PX30_CPUCLK_RATE(1008000000, 1, 5),
  115. PX30_CPUCLK_RATE(912000000, 1, 5),
  116. PX30_CPUCLK_RATE(816000000, 1, 3),
  117. PX30_CPUCLK_RATE(696000000, 1, 3),
  118. PX30_CPUCLK_RATE(600000000, 1, 3),
  119. PX30_CPUCLK_RATE(408000000, 1, 1),
  120. PX30_CPUCLK_RATE(312000000, 1, 1),
  121. PX30_CPUCLK_RATE(216000000, 1, 1),
  122. PX30_CPUCLK_RATE(96000000, 1, 1),
  123. };
  124. static const struct rockchip_cpuclk_reg_data px30_cpuclk_data = {
  125. .core_reg = PX30_CLKSEL_CON(0),
  126. .div_core_shift = 0,
  127. .div_core_mask = 0xf,
  128. .mux_core_alt = 1,
  129. .mux_core_main = 0,
  130. .mux_core_shift = 7,
  131. .mux_core_mask = 0x1,
  132. };
  133. PNAME(mux_pll_p) = { "xin24m"};
  134. PNAME(mux_usb480m_p) = { "xin24m", "usb480m_phy", "clk_rtc32k_pmu" };
  135. PNAME(mux_armclk_p) = { "apll_core", "gpll_core" };
  136. PNAME(mux_ddrphy_p) = { "dpll_ddr", "gpll_ddr" };
  137. PNAME(mux_ddrstdby_p) = { "clk_ddrphy1x", "clk_stdby_2wrap" };
  138. PNAME(mux_4plls_p) = { "gpll", "dummy_cpll", "usb480m", "npll" };
  139. PNAME(mux_cpll_npll_p) = { "cpll", "npll" };
  140. PNAME(mux_npll_cpll_p) = { "npll", "cpll" };
  141. PNAME(mux_gpll_cpll_p) = { "gpll", "dummy_cpll" };
  142. PNAME(mux_gpll_npll_p) = { "gpll", "npll" };
  143. PNAME(mux_gpll_xin24m_p) = { "gpll", "xin24m"};
  144. PNAME(mux_gpll_cpll_npll_p) = { "gpll", "dummy_cpll", "npll" };
  145. PNAME(mux_gpll_cpll_npll_xin24m_p) = { "gpll", "dummy_cpll", "npll", "xin24m" };
  146. PNAME(mux_gpll_xin24m_npll_p) = { "gpll", "xin24m", "npll"};
  147. PNAME(mux_pdm_p) = { "clk_pdm_src", "clk_pdm_frac" };
  148. PNAME(mux_i2s0_tx_p) = { "clk_i2s0_tx_src", "clk_i2s0_tx_frac", "mclk_i2s0_tx_in", "xin12m"};
  149. PNAME(mux_i2s0_rx_p) = { "clk_i2s0_rx_src", "clk_i2s0_rx_frac", "mclk_i2s0_rx_in", "xin12m"};
  150. PNAME(mux_i2s1_p) = { "clk_i2s1_src", "clk_i2s1_frac", "i2s1_clkin", "xin12m"};
  151. PNAME(mux_i2s2_p) = { "clk_i2s2_src", "clk_i2s2_frac", "i2s2_clkin", "xin12m"};
  152. PNAME(mux_i2s0_tx_out_p) = { "clk_i2s0_tx", "xin12m", "clk_i2s0_rx"};
  153. PNAME(mux_i2s0_rx_out_p) = { "clk_i2s0_rx", "xin12m", "clk_i2s0_tx"};
  154. PNAME(mux_i2s1_out_p) = { "clk_i2s1", "xin12m"};
  155. PNAME(mux_i2s2_out_p) = { "clk_i2s2", "xin12m"};
  156. PNAME(mux_i2s0_tx_rx_p) = { "clk_i2s0_tx_mux", "clk_i2s0_rx_mux"};
  157. PNAME(mux_i2s0_rx_tx_p) = { "clk_i2s0_rx_mux", "clk_i2s0_tx_mux"};
  158. PNAME(mux_uart_src_p) = { "gpll", "xin24m", "usb480m", "npll" };
  159. PNAME(mux_uart1_p) = { "clk_uart1_src", "clk_uart1_np5", "clk_uart1_frac" };
  160. PNAME(mux_uart2_p) = { "clk_uart2_src", "clk_uart2_np5", "clk_uart2_frac" };
  161. PNAME(mux_uart3_p) = { "clk_uart3_src", "clk_uart3_np5", "clk_uart3_frac" };
  162. PNAME(mux_uart4_p) = { "clk_uart4_src", "clk_uart4_np5", "clk_uart4_frac" };
  163. PNAME(mux_uart5_p) = { "clk_uart5_src", "clk_uart5_np5", "clk_uart5_frac" };
  164. PNAME(mux_cif_out_p) = { "xin24m", "dummy_cpll", "npll", "usb480m" };
  165. PNAME(mux_dclk_vopb_p) = { "dclk_vopb_src", "dclk_vopb_frac", "xin24m" };
  166. PNAME(mux_dclk_vopl_p) = { "dclk_vopl_src", "dclk_vopl_frac", "xin24m" };
  167. PNAME(mux_gmac_p) = { "clk_gmac_src", "gmac_clkin" };
  168. PNAME(mux_gmac_rmii_sel_p) = { "clk_gmac_rx_tx_div20", "clk_gmac_rx_tx_div2" };
  169. PNAME(mux_rtc32k_pmu_p) = { "xin32k", "pmu_pvtm_32k", "clk_rtc32k_frac", };
  170. PNAME(mux_wifi_pmu_p) = { "xin24m", "clk_wifi_pmu_src" };
  171. PNAME(mux_uart0_pmu_p) = { "clk_uart0_pmu_src", "clk_uart0_np5", "clk_uart0_frac" };
  172. PNAME(mux_usbphy_ref_p) = { "xin24m", "clk_ref24m_pmu" };
  173. PNAME(mux_mipidsiphy_ref_p) = { "xin24m", "clk_ref24m_pmu" };
  174. PNAME(mux_gpu_p) = { "clk_gpu_div", "clk_gpu_np5" };
  175. static struct rockchip_pll_clock px30_pll_clks[] __initdata = {
  176. [apll] = PLL(pll_rk3328, PLL_APLL, "apll", mux_pll_p,
  177. 0, PX30_PLL_CON(0),
  178. PX30_MODE_CON, 0, 0, 0, px30_pll_rates),
  179. [dpll] = PLL(pll_rk3328, PLL_DPLL, "dpll", mux_pll_p,
  180. 0, PX30_PLL_CON(8),
  181. PX30_MODE_CON, 4, 1, 0, NULL),
  182. [cpll] = PLL(pll_rk3328, PLL_CPLL, "cpll", mux_pll_p,
  183. 0, PX30_PLL_CON(16),
  184. PX30_MODE_CON, 2, 2, 0, px30_pll_rates),
  185. [npll] = PLL(pll_rk3328, PLL_NPLL, "npll", mux_pll_p,
  186. 0, PX30_PLL_CON(24),
  187. PX30_MODE_CON, 6, 4, 0, px30_pll_rates),
  188. };
  189. static struct rockchip_pll_clock px30_pmu_pll_clks[] __initdata = {
  190. [gpll] = PLL(pll_rk3328, PLL_GPLL, "gpll", mux_pll_p, 0, PX30_PMU_PLL_CON(0),
  191. PX30_PMU_MODE, 0, 3, 0, px30_pll_rates),
  192. };
  193. #define MFLAGS CLK_MUX_HIWORD_MASK
  194. #define DFLAGS CLK_DIVIDER_HIWORD_MASK
  195. #define GFLAGS (CLK_GATE_HIWORD_MASK | CLK_GATE_SET_TO_DISABLE)
  196. static struct rockchip_clk_branch px30_pdm_fracmux __initdata =
  197. MUX(0, "clk_pdm_mux", mux_pdm_p, CLK_SET_RATE_PARENT,
  198. PX30_CLKSEL_CON(26), 15, 1, MFLAGS);
  199. static struct rockchip_clk_branch px30_i2s0_tx_fracmux __initdata =
  200. MUX(0, "clk_i2s0_tx_mux", mux_i2s0_tx_p, CLK_SET_RATE_PARENT,
  201. PX30_CLKSEL_CON(28), 10, 2, MFLAGS);
  202. static struct rockchip_clk_branch px30_i2s0_rx_fracmux __initdata =
  203. MUX(0, "clk_i2s0_rx_mux", mux_i2s0_rx_p, CLK_SET_RATE_PARENT,
  204. PX30_CLKSEL_CON(58), 10, 2, MFLAGS);
  205. static struct rockchip_clk_branch px30_i2s1_fracmux __initdata =
  206. MUX(0, "clk_i2s1_mux", mux_i2s1_p, CLK_SET_RATE_PARENT,
  207. PX30_CLKSEL_CON(30), 10, 2, MFLAGS);
  208. static struct rockchip_clk_branch px30_i2s2_fracmux __initdata =
  209. MUX(0, "clk_i2s2_mux", mux_i2s2_p, CLK_SET_RATE_PARENT,
  210. PX30_CLKSEL_CON(32), 10, 2, MFLAGS);
  211. static struct rockchip_clk_branch px30_uart1_fracmux __initdata =
  212. MUX(0, "clk_uart1_mux", mux_uart1_p, CLK_SET_RATE_PARENT,
  213. PX30_CLKSEL_CON(35), 14, 2, MFLAGS);
  214. static struct rockchip_clk_branch px30_uart2_fracmux __initdata =
  215. MUX(0, "clk_uart2_mux", mux_uart2_p, CLK_SET_RATE_PARENT,
  216. PX30_CLKSEL_CON(38), 14, 2, MFLAGS);
  217. static struct rockchip_clk_branch px30_uart3_fracmux __initdata =
  218. MUX(0, "clk_uart3_mux", mux_uart3_p, CLK_SET_RATE_PARENT,
  219. PX30_CLKSEL_CON(41), 14, 2, MFLAGS);
  220. static struct rockchip_clk_branch px30_uart4_fracmux __initdata =
  221. MUX(0, "clk_uart4_mux", mux_uart4_p, CLK_SET_RATE_PARENT,
  222. PX30_CLKSEL_CON(44), 14, 2, MFLAGS);
  223. static struct rockchip_clk_branch px30_uart5_fracmux __initdata =
  224. MUX(0, "clk_uart5_mux", mux_uart5_p, CLK_SET_RATE_PARENT,
  225. PX30_CLKSEL_CON(47), 14, 2, MFLAGS);
  226. static struct rockchip_clk_branch px30_dclk_vopb_fracmux __initdata =
  227. MUX(0, "dclk_vopb_mux", mux_dclk_vopb_p, CLK_SET_RATE_PARENT,
  228. PX30_CLKSEL_CON(5), 14, 2, MFLAGS);
  229. static struct rockchip_clk_branch px30_dclk_vopl_fracmux __initdata =
  230. MUX(0, "dclk_vopl_mux", mux_dclk_vopl_p, CLK_SET_RATE_PARENT,
  231. PX30_CLKSEL_CON(8), 14, 2, MFLAGS);
  232. static struct rockchip_clk_branch px30_rtc32k_pmu_fracmux __initdata =
  233. MUX(SCLK_RTC32K_PMU, "clk_rtc32k_pmu", mux_rtc32k_pmu_p, CLK_SET_RATE_PARENT,
  234. PX30_PMU_CLKSEL_CON(0), 14, 2, MFLAGS);
  235. static struct rockchip_clk_branch px30_uart0_pmu_fracmux __initdata =
  236. MUX(0, "clk_uart0_pmu_mux", mux_uart0_pmu_p, CLK_SET_RATE_PARENT,
  237. PX30_PMU_CLKSEL_CON(4), 14, 2, MFLAGS);
  238. static struct rockchip_clk_branch px30_clk_branches[] __initdata = {
  239. /*
  240. * Clock-Architecture Diagram 1
  241. */
  242. MUX(USB480M, "usb480m", mux_usb480m_p, CLK_SET_RATE_PARENT,
  243. PX30_MODE_CON, 8, 2, MFLAGS),
  244. FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
  245. /*
  246. * Clock-Architecture Diagram 3
  247. */
  248. /* PD_CORE */
  249. GATE(0, "apll_core", "apll", CLK_IGNORE_UNUSED,
  250. PX30_CLKGATE_CON(0), 0, GFLAGS),
  251. GATE(0, "gpll_core", "gpll", CLK_IGNORE_UNUSED,
  252. PX30_CLKGATE_CON(0), 0, GFLAGS),
  253. COMPOSITE_NOMUX(0, "pclk_dbg", "armclk", CLK_IGNORE_UNUSED,
  254. PX30_CLKSEL_CON(0), 8, 4, DFLAGS | CLK_DIVIDER_READ_ONLY,
  255. PX30_CLKGATE_CON(0), 2, GFLAGS),
  256. COMPOSITE_NOMUX(0, "aclk_core", "armclk", CLK_IGNORE_UNUSED,
  257. PX30_CLKSEL_CON(0), 12, 3, DFLAGS | CLK_DIVIDER_READ_ONLY,
  258. PX30_CLKGATE_CON(0), 1, GFLAGS),
  259. GATE(0, "aclk_core_niu", "aclk_core", CLK_IGNORE_UNUSED,
  260. PX30_CLKGATE_CON(0), 4, GFLAGS),
  261. GATE(0, "aclk_core_prf", "aclk_core", CLK_IGNORE_UNUSED,
  262. PX30_CLKGATE_CON(17), 5, GFLAGS),
  263. GATE(0, "pclk_dbg_niu", "pclk_dbg", CLK_IGNORE_UNUSED,
  264. PX30_CLKGATE_CON(0), 5, GFLAGS),
  265. GATE(0, "pclk_core_dbg", "pclk_dbg", CLK_IGNORE_UNUSED,
  266. PX30_CLKGATE_CON(0), 6, GFLAGS),
  267. GATE(0, "pclk_core_grf", "pclk_dbg", CLK_IGNORE_UNUSED,
  268. PX30_CLKGATE_CON(17), 6, GFLAGS),
  269. GATE(0, "clk_jtag", "jtag_clkin", CLK_IGNORE_UNUSED,
  270. PX30_CLKGATE_CON(0), 3, GFLAGS),
  271. GATE(SCLK_PVTM, "clk_pvtm", "xin24m", 0,
  272. PX30_CLKGATE_CON(17), 4, GFLAGS),
  273. /* PD_GPU */
  274. COMPOSITE_NODIV(0, "clk_gpu_src", mux_4plls_p, 0,
  275. PX30_CLKSEL_CON(1), 6, 2, MFLAGS,
  276. PX30_CLKGATE_CON(0), 8, GFLAGS),
  277. COMPOSITE_NOMUX(0, "clk_gpu_div", "clk_gpu_src", 0,
  278. PX30_CLKSEL_CON(1), 0, 4, DFLAGS,
  279. PX30_CLKGATE_CON(0), 12, GFLAGS),
  280. COMPOSITE_NOMUX_HALFDIV(0, "clk_gpu_np5", "clk_gpu_src", 0,
  281. PX30_CLKSEL_CON(1), 8, 4, DFLAGS,
  282. PX30_CLKGATE_CON(0), 9, GFLAGS),
  283. COMPOSITE_NODIV(SCLK_GPU, "clk_gpu", mux_gpu_p, CLK_SET_RATE_PARENT,
  284. PX30_CLKSEL_CON(1), 15, 1, MFLAGS,
  285. PX30_CLKGATE_CON(0), 10, GFLAGS),
  286. COMPOSITE_NOMUX(0, "aclk_gpu", "clk_gpu", CLK_IGNORE_UNUSED,
  287. PX30_CLKSEL_CON(1), 13, 2, DFLAGS,
  288. PX30_CLKGATE_CON(17), 10, GFLAGS),
  289. GATE(0, "aclk_gpu_niu", "aclk_gpu", CLK_IGNORE_UNUSED,
  290. PX30_CLKGATE_CON(0), 11, GFLAGS),
  291. GATE(0, "aclk_gpu_prf", "aclk_gpu", CLK_IGNORE_UNUSED,
  292. PX30_CLKGATE_CON(17), 8, GFLAGS),
  293. GATE(0, "pclk_gpu_grf", "aclk_gpu", CLK_IGNORE_UNUSED,
  294. PX30_CLKGATE_CON(17), 9, GFLAGS),
  295. /*
  296. * Clock-Architecture Diagram 4
  297. */
  298. /* PD_DDR */
  299. GATE(0, "dpll_ddr", "dpll", CLK_IGNORE_UNUSED,
  300. PX30_CLKGATE_CON(0), 7, GFLAGS),
  301. GATE(0, "gpll_ddr", "gpll", CLK_IGNORE_UNUSED,
  302. PX30_CLKGATE_CON(0), 13, GFLAGS),
  303. COMPOSITE_NOGATE(SCLK_DDRCLK, "sclk_ddrc", mux_ddrphy_p, CLK_IGNORE_UNUSED,
  304. PX30_CLKSEL_CON(2), 7, 1, MFLAGS, 0, 3, DFLAGS | CLK_DIVIDER_POWER_OF_TWO),
  305. COMPOSITE_NOGATE(0, "clk_ddrphy4x", mux_ddrphy_p, CLK_IGNORE_UNUSED,
  306. PX30_CLKSEL_CON(2), 7, 1, MFLAGS, 0, 3, DFLAGS),
  307. FACTOR_GATE(0, "clk_ddrphy1x", "clk_ddrphy4x", CLK_IGNORE_UNUSED, 1, 4,
  308. PX30_CLKGATE_CON(0), 14, GFLAGS),
  309. FACTOR_GATE(0, "clk_stdby_2wrap", "clk_ddrphy4x", CLK_IGNORE_UNUSED, 1, 4,
  310. PX30_CLKGATE_CON(1), 0, GFLAGS),
  311. COMPOSITE_NODIV(0, "clk_ddrstdby", mux_ddrstdby_p, CLK_IGNORE_UNUSED,
  312. PX30_CLKSEL_CON(2), 4, 1, MFLAGS,
  313. PX30_CLKGATE_CON(1), 13, GFLAGS),
  314. GATE(0, "aclk_split", "clk_ddrphy1x", CLK_IGNORE_UNUSED,
  315. PX30_CLKGATE_CON(1), 15, GFLAGS),
  316. GATE(0, "clk_msch", "clk_ddrphy1x", CLK_IGNORE_UNUSED,
  317. PX30_CLKGATE_CON(1), 8, GFLAGS),
  318. GATE(0, "aclk_ddrc", "clk_ddrphy1x", CLK_IGNORE_UNUSED,
  319. PX30_CLKGATE_CON(1), 5, GFLAGS),
  320. GATE(0, "clk_core_ddrc", "clk_ddrphy1x", CLK_IGNORE_UNUSED,
  321. PX30_CLKGATE_CON(1), 6, GFLAGS),
  322. GATE(0, "aclk_cmd_buff", "clk_ddrphy1x", CLK_IGNORE_UNUSED,
  323. PX30_CLKGATE_CON(1), 6, GFLAGS),
  324. GATE(0, "clk_ddrmon", "clk_ddrphy1x", CLK_IGNORE_UNUSED,
  325. PX30_CLKGATE_CON(1), 11, GFLAGS),
  326. GATE(0, "clk_ddrmon_timer", "xin24m", CLK_IGNORE_UNUSED,
  327. PX30_CLKGATE_CON(0), 15, GFLAGS),
  328. COMPOSITE_NOMUX(PCLK_DDR, "pclk_ddr", "gpll", CLK_IGNORE_UNUSED,
  329. PX30_CLKSEL_CON(2), 8, 5, DFLAGS,
  330. PX30_CLKGATE_CON(1), 1, GFLAGS),
  331. GATE(0, "pclk_ddrmon", "pclk_ddr", CLK_IGNORE_UNUSED,
  332. PX30_CLKGATE_CON(1), 10, GFLAGS),
  333. GATE(0, "pclk_ddrc", "pclk_ddr", CLK_IGNORE_UNUSED,
  334. PX30_CLKGATE_CON(1), 7, GFLAGS),
  335. GATE(0, "pclk_msch", "pclk_ddr", CLK_IGNORE_UNUSED,
  336. PX30_CLKGATE_CON(1), 9, GFLAGS),
  337. GATE(0, "pclk_stdby", "pclk_ddr", CLK_IGNORE_UNUSED,
  338. PX30_CLKGATE_CON(1), 12, GFLAGS),
  339. GATE(0, "pclk_ddr_grf", "pclk_ddr", CLK_IGNORE_UNUSED,
  340. PX30_CLKGATE_CON(1), 14, GFLAGS),
  341. GATE(0, "pclk_cmdbuff", "pclk_ddr", CLK_IGNORE_UNUSED,
  342. PX30_CLKGATE_CON(1), 3, GFLAGS),
  343. /*
  344. * Clock-Architecture Diagram 5
  345. */
  346. /* PD_VI */
  347. COMPOSITE(ACLK_VI_PRE, "aclk_vi_pre", mux_gpll_cpll_npll_p, 0,
  348. PX30_CLKSEL_CON(11), 6, 2, MFLAGS, 0, 5, DFLAGS,
  349. PX30_CLKGATE_CON(4), 8, GFLAGS),
  350. COMPOSITE_NOMUX(HCLK_VI_PRE, "hclk_vi_pre", "aclk_vi_pre", 0,
  351. PX30_CLKSEL_CON(11), 8, 4, DFLAGS,
  352. PX30_CLKGATE_CON(4), 12, GFLAGS),
  353. COMPOSITE(SCLK_ISP, "clk_isp", mux_gpll_cpll_npll_p, 0,
  354. PX30_CLKSEL_CON(12), 6, 2, MFLAGS, 0, 5, DFLAGS,
  355. PX30_CLKGATE_CON(4), 9, GFLAGS),
  356. COMPOSITE(SCLK_CIF_OUT, "clk_cif_out", mux_cif_out_p, 0,
  357. PX30_CLKSEL_CON(13), 6, 2, MFLAGS, 0, 6, DFLAGS,
  358. PX30_CLKGATE_CON(4), 11, GFLAGS),
  359. GATE(PCLK_ISP, "pclkin_isp", "ext_pclkin", 0,
  360. PX30_CLKGATE_CON(4), 13, GFLAGS),
  361. GATE(PCLK_CIF, "pclkin_cif", "ext_pclkin", 0,
  362. PX30_CLKGATE_CON(4), 14, GFLAGS),
  363. /*
  364. * Clock-Architecture Diagram 6
  365. */
  366. /* PD_VO */
  367. COMPOSITE(ACLK_VO_PRE, "aclk_vo_pre", mux_gpll_cpll_npll_p, 0,
  368. PX30_CLKSEL_CON(3), 6, 2, MFLAGS, 0, 5, DFLAGS,
  369. PX30_CLKGATE_CON(2), 0, GFLAGS),
  370. COMPOSITE_NOMUX(HCLK_VO_PRE, "hclk_vo_pre", "aclk_vo_pre", 0,
  371. PX30_CLKSEL_CON(3), 8, 4, DFLAGS,
  372. PX30_CLKGATE_CON(2), 12, GFLAGS),
  373. COMPOSITE_NOMUX(PCLK_VO_PRE, "pclk_vo_pre", "aclk_vo_pre", 0,
  374. PX30_CLKSEL_CON(3), 12, 4, DFLAGS,
  375. PX30_CLKGATE_CON(2), 13, GFLAGS),
  376. COMPOSITE(SCLK_RGA_CORE, "clk_rga_core", mux_gpll_cpll_npll_p, 0,
  377. PX30_CLKSEL_CON(4), 6, 2, MFLAGS, 0, 5, DFLAGS,
  378. PX30_CLKGATE_CON(2), 1, GFLAGS),
  379. COMPOSITE(SCLK_VOPB_PWM, "clk_vopb_pwm", mux_gpll_xin24m_p, 0,
  380. PX30_CLKSEL_CON(7), 7, 1, MFLAGS, 0, 7, DFLAGS,
  381. PX30_CLKGATE_CON(2), 5, GFLAGS),
  382. COMPOSITE(0, "dclk_vopb_src", mux_cpll_npll_p, CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
  383. PX30_CLKSEL_CON(5), 11, 1, MFLAGS, 0, 8, DFLAGS,
  384. PX30_CLKGATE_CON(2), 2, GFLAGS),
  385. COMPOSITE_FRACMUX(0, "dclk_vopb_frac", "dclk_vopb_src", CLK_SET_RATE_PARENT,
  386. PX30_CLKSEL_CON(6), 0,
  387. PX30_CLKGATE_CON(2), 3, GFLAGS,
  388. &px30_dclk_vopb_fracmux),
  389. GATE(DCLK_VOPB, "dclk_vopb", "dclk_vopb_mux", CLK_SET_RATE_PARENT,
  390. PX30_CLKGATE_CON(2), 4, GFLAGS),
  391. COMPOSITE(0, "dclk_vopl_src", mux_npll_cpll_p, 0,
  392. PX30_CLKSEL_CON(8), 11, 1, MFLAGS, 0, 8, DFLAGS,
  393. PX30_CLKGATE_CON(2), 6, GFLAGS),
  394. COMPOSITE_FRACMUX(0, "dclk_vopl_frac", "dclk_vopl_src", CLK_SET_RATE_PARENT,
  395. PX30_CLKSEL_CON(9), 0,
  396. PX30_CLKGATE_CON(2), 7, GFLAGS,
  397. &px30_dclk_vopl_fracmux),
  398. GATE(DCLK_VOPL, "dclk_vopl", "dclk_vopl_mux", CLK_SET_RATE_PARENT,
  399. PX30_CLKGATE_CON(2), 8, GFLAGS),
  400. /* PD_VPU */
  401. COMPOSITE(0, "aclk_vpu_pre", mux_gpll_cpll_npll_p, 0,
  402. PX30_CLKSEL_CON(10), 6, 2, MFLAGS, 0, 5, DFLAGS,
  403. PX30_CLKGATE_CON(4), 0, GFLAGS),
  404. COMPOSITE_NOMUX(0, "hclk_vpu_pre", "aclk_vpu_pre", 0,
  405. PX30_CLKSEL_CON(10), 8, 4, DFLAGS,
  406. PX30_CLKGATE_CON(4), 2, GFLAGS),
  407. COMPOSITE(SCLK_CORE_VPU, "sclk_core_vpu", mux_gpll_cpll_npll_p, 0,
  408. PX30_CLKSEL_CON(13), 14, 2, MFLAGS, 8, 5, DFLAGS,
  409. PX30_CLKGATE_CON(4), 1, GFLAGS),
  410. /*
  411. * Clock-Architecture Diagram 7
  412. */
  413. COMPOSITE_NODIV(ACLK_PERI_SRC, "aclk_peri_src", mux_gpll_cpll_p, 0,
  414. PX30_CLKSEL_CON(14), 15, 1, MFLAGS,
  415. PX30_CLKGATE_CON(5), 7, GFLAGS),
  416. COMPOSITE_NOMUX(ACLK_PERI_PRE, "aclk_peri_pre", "aclk_peri_src", CLK_IGNORE_UNUSED,
  417. PX30_CLKSEL_CON(14), 0, 5, DFLAGS,
  418. PX30_CLKGATE_CON(5), 8, GFLAGS),
  419. DIV(HCLK_PERI_PRE, "hclk_peri_pre", "aclk_peri_src", CLK_IGNORE_UNUSED,
  420. PX30_CLKSEL_CON(14), 8, 5, DFLAGS),
  421. /* PD_MMC_NAND */
  422. GATE(HCLK_MMC_NAND, "hclk_mmc_nand", "hclk_peri_pre", 0,
  423. PX30_CLKGATE_CON(6), 0, GFLAGS),
  424. COMPOSITE(SCLK_NANDC, "clk_nandc", mux_gpll_cpll_npll_p, 0,
  425. PX30_CLKSEL_CON(15), 6, 2, MFLAGS, 0, 5, DFLAGS,
  426. PX30_CLKGATE_CON(5), 13, GFLAGS),
  427. COMPOSITE(SCLK_SDIO, "clk_sdio", mux_gpll_cpll_npll_xin24m_p, 0,
  428. PX30_CLKSEL_CON(18), 14, 2, MFLAGS, 0, 8, DFLAGS,
  429. PX30_CLKGATE_CON(6), 3, GFLAGS),
  430. COMPOSITE(SCLK_EMMC, "clk_emmc", mux_gpll_cpll_npll_xin24m_p, 0,
  431. PX30_CLKSEL_CON(20), 14, 2, MFLAGS, 0, 8, DFLAGS,
  432. PX30_CLKGATE_CON(6), 6, GFLAGS),
  433. COMPOSITE(SCLK_SFC, "clk_sfc", mux_gpll_cpll_p, 0,
  434. PX30_CLKSEL_CON(22), 7, 1, MFLAGS, 0, 7, DFLAGS,
  435. PX30_CLKGATE_CON(6), 7, GFLAGS),
  436. MMC(SCLK_SDMMC_DRV, "sdmmc_drv", "clk_sdmmc",
  437. PX30_SDMMC_CON0, 1),
  438. MMC(SCLK_SDMMC_SAMPLE, "sdmmc_sample", "clk_sdmmc",
  439. PX30_SDMMC_CON1, 1),
  440. MMC(SCLK_SDIO_DRV, "sdio_drv", "clk_sdio",
  441. PX30_SDIO_CON0, 1),
  442. MMC(SCLK_SDIO_SAMPLE, "sdio_sample", "clk_sdio",
  443. PX30_SDIO_CON1, 1),
  444. MMC(SCLK_EMMC_DRV, "emmc_drv", "clk_emmc",
  445. PX30_EMMC_CON0, 1),
  446. MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "clk_emmc",
  447. PX30_EMMC_CON1, 1),
  448. /* PD_SDCARD */
  449. GATE(0, "hclk_sdmmc_pre", "hclk_peri_pre", 0,
  450. PX30_CLKGATE_CON(6), 12, GFLAGS),
  451. COMPOSITE(SCLK_SDMMC, "clk_sdmmc", mux_gpll_cpll_npll_xin24m_p, 0,
  452. PX30_CLKSEL_CON(16), 14, 2, MFLAGS, 0, 8, DFLAGS,
  453. PX30_CLKGATE_CON(6), 15, GFLAGS),
  454. /* PD_USB */
  455. GATE(HCLK_USB, "hclk_usb", "hclk_peri_pre", 0,
  456. PX30_CLKGATE_CON(7), 2, GFLAGS),
  457. GATE(SCLK_OTG_ADP, "clk_otg_adp", "clk_rtc32k_pmu", 0,
  458. PX30_CLKGATE_CON(7), 3, GFLAGS),
  459. /* PD_GMAC */
  460. COMPOSITE(SCLK_GMAC_SRC, "clk_gmac_src", mux_gpll_cpll_npll_p, 0,
  461. PX30_CLKSEL_CON(22), 14, 2, MFLAGS, 8, 5, DFLAGS,
  462. PX30_CLKGATE_CON(7), 11, GFLAGS),
  463. MUX(SCLK_GMAC, "clk_gmac", mux_gmac_p, CLK_SET_RATE_PARENT,
  464. PX30_CLKSEL_CON(23), 6, 1, MFLAGS),
  465. GATE(SCLK_MAC_REF, "clk_mac_ref", "clk_gmac", 0,
  466. PX30_CLKGATE_CON(7), 15, GFLAGS),
  467. GATE(SCLK_GMAC_RX_TX, "clk_gmac_rx_tx", "clk_gmac", 0,
  468. PX30_CLKGATE_CON(7), 13, GFLAGS),
  469. FACTOR(0, "clk_gmac_rx_tx_div2", "clk_gmac_rx_tx", 0, 1, 2),
  470. FACTOR(0, "clk_gmac_rx_tx_div20", "clk_gmac_rx_tx", 0, 1, 20),
  471. MUX(SCLK_GMAC_RMII, "clk_gmac_rmii_sel", mux_gmac_rmii_sel_p, CLK_SET_RATE_PARENT,
  472. PX30_CLKSEL_CON(23), 7, 1, MFLAGS),
  473. GATE(0, "aclk_gmac_pre", "aclk_peri_pre", 0,
  474. PX30_CLKGATE_CON(7), 10, GFLAGS),
  475. COMPOSITE_NOMUX(0, "pclk_gmac_pre", "aclk_gmac_pre", 0,
  476. PX30_CLKSEL_CON(23), 0, 4, DFLAGS,
  477. PX30_CLKGATE_CON(7), 12, GFLAGS),
  478. COMPOSITE(SCLK_MAC_OUT, "clk_mac_out", mux_gpll_cpll_npll_p, 0,
  479. PX30_CLKSEL_CON(12), 14, 2, MFLAGS, 8, 5, DFLAGS,
  480. PX30_CLKGATE_CON(8), 5, GFLAGS),
  481. /*
  482. * Clock-Architecture Diagram 8
  483. */
  484. /* PD_BUS */
  485. COMPOSITE_NODIV(ACLK_BUS_SRC, "aclk_bus_src", mux_gpll_cpll_p, CLK_IGNORE_UNUSED,
  486. PX30_CLKSEL_CON(23), 15, 1, MFLAGS,
  487. PX30_CLKGATE_CON(8), 6, GFLAGS),
  488. COMPOSITE_NOMUX(HCLK_BUS_PRE, "hclk_bus_pre", "aclk_bus_src", CLK_IGNORE_UNUSED,
  489. PX30_CLKSEL_CON(24), 0, 5, DFLAGS,
  490. PX30_CLKGATE_CON(8), 8, GFLAGS),
  491. COMPOSITE_NOMUX(ACLK_BUS_PRE, "aclk_bus_pre", "aclk_bus_src", CLK_IGNORE_UNUSED,
  492. PX30_CLKSEL_CON(23), 8, 5, DFLAGS,
  493. PX30_CLKGATE_CON(8), 7, GFLAGS),
  494. COMPOSITE_NOMUX(PCLK_BUS_PRE, "pclk_bus_pre", "aclk_bus_pre", CLK_IGNORE_UNUSED,
  495. PX30_CLKSEL_CON(24), 8, 2, DFLAGS,
  496. PX30_CLKGATE_CON(8), 9, GFLAGS),
  497. GATE(0, "pclk_top_pre", "pclk_bus_pre", CLK_IGNORE_UNUSED,
  498. PX30_CLKGATE_CON(8), 10, GFLAGS),
  499. COMPOSITE(0, "clk_pdm_src", mux_gpll_xin24m_npll_p, 0,
  500. PX30_CLKSEL_CON(26), 8, 2, MFLAGS, 0, 7, DFLAGS,
  501. PX30_CLKGATE_CON(9), 9, GFLAGS),
  502. COMPOSITE_FRACMUX(0, "clk_pdm_frac", "clk_pdm_src", CLK_SET_RATE_PARENT,
  503. PX30_CLKSEL_CON(27), 0,
  504. PX30_CLKGATE_CON(9), 10, GFLAGS,
  505. &px30_pdm_fracmux),
  506. GATE(SCLK_PDM, "clk_pdm", "clk_pdm_mux", CLK_SET_RATE_PARENT,
  507. PX30_CLKGATE_CON(9), 11, GFLAGS),
  508. COMPOSITE(0, "clk_i2s0_tx_src", mux_gpll_npll_p, 0,
  509. PX30_CLKSEL_CON(28), 8, 1, MFLAGS, 0, 7, DFLAGS,
  510. PX30_CLKGATE_CON(9), 12, GFLAGS),
  511. COMPOSITE_FRACMUX(0, "clk_i2s0_tx_frac", "clk_i2s0_tx_src", CLK_SET_RATE_PARENT,
  512. PX30_CLKSEL_CON(29), 0,
  513. PX30_CLKGATE_CON(9), 13, GFLAGS,
  514. &px30_i2s0_tx_fracmux),
  515. COMPOSITE_NODIV(SCLK_I2S0_TX, "clk_i2s0_tx", mux_i2s0_tx_rx_p, CLK_SET_RATE_PARENT,
  516. PX30_CLKSEL_CON(28), 12, 1, MFLAGS,
  517. PX30_CLKGATE_CON(9), 14, GFLAGS),
  518. COMPOSITE_NODIV(0, "clk_i2s0_tx_out_pre", mux_i2s0_tx_out_p, 0,
  519. PX30_CLKSEL_CON(28), 14, 2, MFLAGS,
  520. PX30_CLKGATE_CON(9), 15, GFLAGS),
  521. GATE(SCLK_I2S0_TX_OUT, "clk_i2s0_tx_out", "clk_i2s0_tx_out_pre", CLK_SET_RATE_PARENT,
  522. PX30_CLKGATE_CON(10), 8, CLK_GATE_HIWORD_MASK),
  523. COMPOSITE(0, "clk_i2s0_rx_src", mux_gpll_npll_p, 0,
  524. PX30_CLKSEL_CON(58), 8, 1, MFLAGS, 0, 7, DFLAGS,
  525. PX30_CLKGATE_CON(17), 0, GFLAGS),
  526. COMPOSITE_FRACMUX(0, "clk_i2s0_rx_frac", "clk_i2s0_rx_src", CLK_SET_RATE_PARENT,
  527. PX30_CLKSEL_CON(59), 0,
  528. PX30_CLKGATE_CON(17), 1, GFLAGS,
  529. &px30_i2s0_rx_fracmux),
  530. COMPOSITE_NODIV(SCLK_I2S0_RX, "clk_i2s0_rx", mux_i2s0_rx_tx_p, CLK_SET_RATE_PARENT,
  531. PX30_CLKSEL_CON(58), 12, 1, MFLAGS,
  532. PX30_CLKGATE_CON(17), 2, GFLAGS),
  533. COMPOSITE_NODIV(0, "clk_i2s0_rx_out_pre", mux_i2s0_rx_out_p, 0,
  534. PX30_CLKSEL_CON(58), 14, 2, MFLAGS,
  535. PX30_CLKGATE_CON(17), 3, GFLAGS),
  536. GATE(SCLK_I2S0_RX_OUT, "clk_i2s0_rx_out", "clk_i2s0_rx_out_pre", CLK_SET_RATE_PARENT,
  537. PX30_CLKGATE_CON(10), 11, CLK_GATE_HIWORD_MASK),
  538. COMPOSITE(0, "clk_i2s1_src", mux_gpll_npll_p, 0,
  539. PX30_CLKSEL_CON(30), 8, 1, MFLAGS, 0, 7, DFLAGS,
  540. PX30_CLKGATE_CON(10), 0, GFLAGS),
  541. COMPOSITE_FRACMUX(0, "clk_i2s1_frac", "clk_i2s1_src", CLK_SET_RATE_PARENT,
  542. PX30_CLKSEL_CON(31), 0,
  543. PX30_CLKGATE_CON(10), 1, GFLAGS,
  544. &px30_i2s1_fracmux),
  545. GATE(SCLK_I2S1, "clk_i2s1", "clk_i2s1_mux", CLK_SET_RATE_PARENT,
  546. PX30_CLKGATE_CON(10), 2, GFLAGS),
  547. COMPOSITE_NODIV(0, "clk_i2s1_out_pre", mux_i2s1_out_p, 0,
  548. PX30_CLKSEL_CON(30), 15, 1, MFLAGS,
  549. PX30_CLKGATE_CON(10), 3, GFLAGS),
  550. GATE(SCLK_I2S1_OUT, "clk_i2s1_out", "clk_i2s1_out_pre", CLK_SET_RATE_PARENT,
  551. PX30_CLKGATE_CON(10), 9, CLK_GATE_HIWORD_MASK),
  552. COMPOSITE(0, "clk_i2s2_src", mux_gpll_npll_p, 0,
  553. PX30_CLKSEL_CON(32), 8, 1, MFLAGS, 0, 7, DFLAGS,
  554. PX30_CLKGATE_CON(10), 4, GFLAGS),
  555. COMPOSITE_FRACMUX(0, "clk_i2s2_frac", "clk_i2s2_src", CLK_SET_RATE_PARENT,
  556. PX30_CLKSEL_CON(33), 0,
  557. PX30_CLKGATE_CON(10), 5, GFLAGS,
  558. &px30_i2s2_fracmux),
  559. GATE(SCLK_I2S2, "clk_i2s2", "clk_i2s2_mux", CLK_SET_RATE_PARENT,
  560. PX30_CLKGATE_CON(10), 6, GFLAGS),
  561. COMPOSITE_NODIV(0, "clk_i2s2_out_pre", mux_i2s2_out_p, 0,
  562. PX30_CLKSEL_CON(32), 15, 1, MFLAGS,
  563. PX30_CLKGATE_CON(10), 7, GFLAGS),
  564. GATE(SCLK_I2S2_OUT, "clk_i2s2_out", "clk_i2s2_out_pre", CLK_SET_RATE_PARENT,
  565. PX30_CLKGATE_CON(10), 10, CLK_GATE_HIWORD_MASK),
  566. COMPOSITE(SCLK_UART1_SRC, "clk_uart1_src", mux_uart_src_p, CLK_SET_RATE_NO_REPARENT,
  567. PX30_CLKSEL_CON(34), 14, 2, MFLAGS, 0, 5, DFLAGS,
  568. PX30_CLKGATE_CON(10), 12, GFLAGS),
  569. COMPOSITE_NOMUX_HALFDIV(0, "clk_uart1_np5", "clk_uart1_src", 0,
  570. PX30_CLKSEL_CON(35), 0, 5, DFLAGS,
  571. PX30_CLKGATE_CON(10), 13, GFLAGS),
  572. COMPOSITE_FRACMUX(0, "clk_uart1_frac", "clk_uart1_src", CLK_SET_RATE_PARENT,
  573. PX30_CLKSEL_CON(36), 0,
  574. PX30_CLKGATE_CON(10), 14, GFLAGS,
  575. &px30_uart1_fracmux),
  576. GATE(SCLK_UART1, "clk_uart1", "clk_uart1_mux", CLK_SET_RATE_PARENT,
  577. PX30_CLKGATE_CON(10), 15, GFLAGS),
  578. COMPOSITE(SCLK_UART2_SRC, "clk_uart2_src", mux_uart_src_p, 0,
  579. PX30_CLKSEL_CON(37), 14, 2, MFLAGS, 0, 5, DFLAGS,
  580. PX30_CLKGATE_CON(11), 0, GFLAGS),
  581. COMPOSITE_NOMUX_HALFDIV(0, "clk_uart2_np5", "clk_uart2_src", 0,
  582. PX30_CLKSEL_CON(38), 0, 5, DFLAGS,
  583. PX30_CLKGATE_CON(11), 1, GFLAGS),
  584. COMPOSITE_FRACMUX(0, "clk_uart2_frac", "clk_uart2_src", CLK_SET_RATE_PARENT,
  585. PX30_CLKSEL_CON(39), 0,
  586. PX30_CLKGATE_CON(11), 2, GFLAGS,
  587. &px30_uart2_fracmux),
  588. GATE(SCLK_UART2, "clk_uart2", "clk_uart2_mux", CLK_SET_RATE_PARENT,
  589. PX30_CLKGATE_CON(11), 3, GFLAGS),
  590. COMPOSITE(0, "clk_uart3_src", mux_uart_src_p, 0,
  591. PX30_CLKSEL_CON(40), 14, 2, MFLAGS, 0, 5, DFLAGS,
  592. PX30_CLKGATE_CON(11), 4, GFLAGS),
  593. COMPOSITE_NOMUX_HALFDIV(0, "clk_uart3_np5", "clk_uart3_src", 0,
  594. PX30_CLKSEL_CON(41), 0, 5, DFLAGS,
  595. PX30_CLKGATE_CON(11), 5, GFLAGS),
  596. COMPOSITE_FRACMUX(0, "clk_uart3_frac", "clk_uart3_src", CLK_SET_RATE_PARENT,
  597. PX30_CLKSEL_CON(42), 0,
  598. PX30_CLKGATE_CON(11), 6, GFLAGS,
  599. &px30_uart3_fracmux),
  600. GATE(SCLK_UART3, "clk_uart3", "clk_uart3_mux", CLK_SET_RATE_PARENT,
  601. PX30_CLKGATE_CON(11), 7, GFLAGS),
  602. COMPOSITE(0, "clk_uart4_src", mux_uart_src_p, 0,
  603. PX30_CLKSEL_CON(43), 14, 2, MFLAGS, 0, 5, DFLAGS,
  604. PX30_CLKGATE_CON(11), 8, GFLAGS),
  605. COMPOSITE_NOMUX_HALFDIV(0, "clk_uart4_np5", "clk_uart4_src", 0,
  606. PX30_CLKSEL_CON(44), 0, 5, DFLAGS,
  607. PX30_CLKGATE_CON(11), 9, GFLAGS),
  608. COMPOSITE_FRACMUX(0, "clk_uart4_frac", "clk_uart4_src", CLK_SET_RATE_PARENT,
  609. PX30_CLKSEL_CON(45), 0,
  610. PX30_CLKGATE_CON(11), 10, GFLAGS,
  611. &px30_uart4_fracmux),
  612. GATE(SCLK_UART4, "clk_uart4", "clk_uart4_mux", CLK_SET_RATE_PARENT,
  613. PX30_CLKGATE_CON(11), 11, GFLAGS),
  614. COMPOSITE(0, "clk_uart5_src", mux_uart_src_p, 0,
  615. PX30_CLKSEL_CON(46), 14, 2, MFLAGS, 0, 5, DFLAGS,
  616. PX30_CLKGATE_CON(11), 12, GFLAGS),
  617. COMPOSITE_NOMUX_HALFDIV(0, "clk_uart5_np5", "clk_uart5_src", 0,
  618. PX30_CLKSEL_CON(47), 0, 5, DFLAGS,
  619. PX30_CLKGATE_CON(11), 13, GFLAGS),
  620. COMPOSITE_FRACMUX(0, "clk_uart5_frac", "clk_uart5_src", CLK_SET_RATE_PARENT,
  621. PX30_CLKSEL_CON(48), 0,
  622. PX30_CLKGATE_CON(11), 14, GFLAGS,
  623. &px30_uart5_fracmux),
  624. GATE(SCLK_UART5, "clk_uart5", "clk_uart5_mux", CLK_SET_RATE_PARENT,
  625. PX30_CLKGATE_CON(11), 15, GFLAGS),
  626. COMPOSITE(SCLK_I2C0, "clk_i2c0", mux_gpll_xin24m_p, 0,
  627. PX30_CLKSEL_CON(49), 7, 1, MFLAGS, 0, 7, DFLAGS,
  628. PX30_CLKGATE_CON(12), 0, GFLAGS),
  629. COMPOSITE(SCLK_I2C1, "clk_i2c1", mux_gpll_xin24m_p, 0,
  630. PX30_CLKSEL_CON(49), 15, 1, MFLAGS, 8, 7, DFLAGS,
  631. PX30_CLKGATE_CON(12), 1, GFLAGS),
  632. COMPOSITE(SCLK_I2C2, "clk_i2c2", mux_gpll_xin24m_p, 0,
  633. PX30_CLKSEL_CON(50), 7, 1, MFLAGS, 0, 7, DFLAGS,
  634. PX30_CLKGATE_CON(12), 2, GFLAGS),
  635. COMPOSITE(SCLK_I2C3, "clk_i2c3", mux_gpll_xin24m_p, 0,
  636. PX30_CLKSEL_CON(50), 15, 1, MFLAGS, 8, 7, DFLAGS,
  637. PX30_CLKGATE_CON(12), 3, GFLAGS),
  638. COMPOSITE(SCLK_PWM0, "clk_pwm0", mux_gpll_xin24m_p, 0,
  639. PX30_CLKSEL_CON(52), 7, 1, MFLAGS, 0, 7, DFLAGS,
  640. PX30_CLKGATE_CON(12), 5, GFLAGS),
  641. COMPOSITE(SCLK_PWM1, "clk_pwm1", mux_gpll_xin24m_p, 0,
  642. PX30_CLKSEL_CON(52), 15, 1, MFLAGS, 8, 7, DFLAGS,
  643. PX30_CLKGATE_CON(12), 6, GFLAGS),
  644. COMPOSITE(SCLK_SPI0, "clk_spi0", mux_gpll_xin24m_p, 0,
  645. PX30_CLKSEL_CON(53), 7, 1, MFLAGS, 0, 7, DFLAGS,
  646. PX30_CLKGATE_CON(12), 7, GFLAGS),
  647. COMPOSITE(SCLK_SPI1, "clk_spi1", mux_gpll_xin24m_p, 0,
  648. PX30_CLKSEL_CON(53), 15, 1, MFLAGS, 8, 7, DFLAGS,
  649. PX30_CLKGATE_CON(12), 8, GFLAGS),
  650. GATE(SCLK_TIMER0, "sclk_timer0", "xin24m", 0,
  651. PX30_CLKGATE_CON(13), 0, GFLAGS),
  652. GATE(SCLK_TIMER1, "sclk_timer1", "xin24m", 0,
  653. PX30_CLKGATE_CON(13), 1, GFLAGS),
  654. GATE(SCLK_TIMER2, "sclk_timer2", "xin24m", 0,
  655. PX30_CLKGATE_CON(13), 2, GFLAGS),
  656. GATE(SCLK_TIMER3, "sclk_timer3", "xin24m", 0,
  657. PX30_CLKGATE_CON(13), 3, GFLAGS),
  658. GATE(SCLK_TIMER4, "sclk_timer4", "xin24m", 0,
  659. PX30_CLKGATE_CON(13), 4, GFLAGS),
  660. GATE(SCLK_TIMER5, "sclk_timer5", "xin24m", 0,
  661. PX30_CLKGATE_CON(13), 5, GFLAGS),
  662. COMPOSITE_NOMUX(SCLK_TSADC, "clk_tsadc", "xin24m", 0,
  663. PX30_CLKSEL_CON(54), 0, 11, DFLAGS,
  664. PX30_CLKGATE_CON(12), 9, GFLAGS),
  665. COMPOSITE_NOMUX(SCLK_SARADC, "clk_saradc", "xin24m", 0,
  666. PX30_CLKSEL_CON(55), 0, 11, DFLAGS,
  667. PX30_CLKGATE_CON(12), 10, GFLAGS),
  668. COMPOSITE_NOMUX(SCLK_OTP, "clk_otp", "xin24m", 0,
  669. PX30_CLKSEL_CON(56), 0, 3, DFLAGS,
  670. PX30_CLKGATE_CON(12), 11, GFLAGS),
  671. COMPOSITE_NOMUX(SCLK_OTP_USR, "clk_otp_usr", "clk_otp", 0,
  672. PX30_CLKSEL_CON(56), 4, 2, DFLAGS,
  673. PX30_CLKGATE_CON(13), 6, GFLAGS),
  674. GATE(0, "clk_cpu_boost", "xin24m", CLK_IGNORE_UNUSED,
  675. PX30_CLKGATE_CON(12), 12, GFLAGS),
  676. /* PD_CRYPTO */
  677. GATE(0, "aclk_crypto_pre", "aclk_bus_pre", 0,
  678. PX30_CLKGATE_CON(8), 12, GFLAGS),
  679. GATE(0, "hclk_crypto_pre", "hclk_bus_pre", 0,
  680. PX30_CLKGATE_CON(8), 13, GFLAGS),
  681. COMPOSITE(SCLK_CRYPTO, "clk_crypto", mux_gpll_cpll_npll_p, 0,
  682. PX30_CLKSEL_CON(25), 6, 2, MFLAGS, 0, 5, DFLAGS,
  683. PX30_CLKGATE_CON(8), 14, GFLAGS),
  684. COMPOSITE(SCLK_CRYPTO_APK, "clk_crypto_apk", mux_gpll_cpll_npll_p, 0,
  685. PX30_CLKSEL_CON(25), 14, 2, MFLAGS, 8, 5, DFLAGS,
  686. PX30_CLKGATE_CON(8), 15, GFLAGS),
  687. /*
  688. * Clock-Architecture Diagram 9
  689. */
  690. /* PD_BUS_TOP */
  691. GATE(0, "pclk_top_niu", "pclk_top_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(16), 0, GFLAGS),
  692. GATE(0, "pclk_top_cru", "pclk_top_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(16), 1, GFLAGS),
  693. GATE(PCLK_OTP_PHY, "pclk_otp_phy", "pclk_top_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(16), 2, GFLAGS),
  694. GATE(0, "pclk_ddrphy", "pclk_top_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(16), 3, GFLAGS),
  695. GATE(PCLK_MIPIDSIPHY, "pclk_mipidsiphy", "pclk_top_pre", 0, PX30_CLKGATE_CON(16), 4, GFLAGS),
  696. GATE(PCLK_MIPICSIPHY, "pclk_mipicsiphy", "pclk_top_pre", 0, PX30_CLKGATE_CON(16), 5, GFLAGS),
  697. GATE(PCLK_USB_GRF, "pclk_usb_grf", "pclk_top_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(16), 6, GFLAGS),
  698. GATE(0, "pclk_cpu_hoost", "pclk_top_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(16), 7, GFLAGS),
  699. /* PD_VI */
  700. GATE(0, "aclk_vi_niu", "aclk_vi_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(4), 15, GFLAGS),
  701. GATE(ACLK_CIF, "aclk_cif", "aclk_vi_pre", 0, PX30_CLKGATE_CON(5), 1, GFLAGS),
  702. GATE(ACLK_ISP, "aclk_isp", "aclk_vi_pre", 0, PX30_CLKGATE_CON(5), 3, GFLAGS),
  703. GATE(0, "hclk_vi_niu", "hclk_vi_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(5), 0, GFLAGS),
  704. GATE(HCLK_CIF, "hclk_cif", "hclk_vi_pre", 0, PX30_CLKGATE_CON(5), 2, GFLAGS),
  705. GATE(HCLK_ISP, "hclk_isp", "hclk_vi_pre", 0, PX30_CLKGATE_CON(5), 4, GFLAGS),
  706. /* PD_VO */
  707. GATE(0, "aclk_vo_niu", "aclk_vo_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(3), 0, GFLAGS),
  708. GATE(ACLK_VOPB, "aclk_vopb", "aclk_vo_pre", 0, PX30_CLKGATE_CON(3), 3, GFLAGS),
  709. GATE(ACLK_RGA, "aclk_rga", "aclk_vo_pre", 0, PX30_CLKGATE_CON(3), 7, GFLAGS),
  710. GATE(ACLK_VOPL, "aclk_vopl", "aclk_vo_pre", 0, PX30_CLKGATE_CON(3), 5, GFLAGS),
  711. GATE(0, "hclk_vo_niu", "hclk_vo_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(3), 1, GFLAGS),
  712. GATE(HCLK_VOPB, "hclk_vopb", "hclk_vo_pre", 0, PX30_CLKGATE_CON(3), 4, GFLAGS),
  713. GATE(HCLK_RGA, "hclk_rga", "hclk_vo_pre", 0, PX30_CLKGATE_CON(3), 8, GFLAGS),
  714. GATE(HCLK_VOPL, "hclk_vopl", "hclk_vo_pre", 0, PX30_CLKGATE_CON(3), 6, GFLAGS),
  715. GATE(0, "pclk_vo_niu", "pclk_vo_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(3), 2, GFLAGS),
  716. GATE(PCLK_MIPI_DSI, "pclk_mipi_dsi", "pclk_vo_pre", 0, PX30_CLKGATE_CON(3), 9, GFLAGS),
  717. /* PD_BUS */
  718. GATE(0, "aclk_bus_niu", "aclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(13), 8, GFLAGS),
  719. GATE(0, "aclk_intmem", "aclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(13), 11, GFLAGS),
  720. GATE(ACLK_GIC, "aclk_gic", "aclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(13), 12, GFLAGS),
  721. GATE(ACLK_DCF, "aclk_dcf", "aclk_bus_pre", 0, PX30_CLKGATE_CON(13), 15, GFLAGS),
  722. GATE(0, "hclk_bus_niu", "hclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(13), 9, GFLAGS),
  723. GATE(0, "hclk_rom", "hclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(13), 14, GFLAGS),
  724. GATE(HCLK_PDM, "hclk_pdm", "hclk_bus_pre", 0, PX30_CLKGATE_CON(14), 1, GFLAGS),
  725. GATE(HCLK_I2S0, "hclk_i2s0", "hclk_bus_pre", 0, PX30_CLKGATE_CON(14), 2, GFLAGS),
  726. GATE(HCLK_I2S1, "hclk_i2s1", "hclk_bus_pre", 0, PX30_CLKGATE_CON(14), 3, GFLAGS),
  727. GATE(HCLK_I2S2, "hclk_i2s2", "hclk_bus_pre", 0, PX30_CLKGATE_CON(14), 4, GFLAGS),
  728. GATE(0, "pclk_bus_niu", "pclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(13), 10, GFLAGS),
  729. GATE(PCLK_DCF, "pclk_dcf", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 0, GFLAGS),
  730. GATE(PCLK_UART1, "pclk_uart1", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 5, GFLAGS),
  731. GATE(PCLK_UART2, "pclk_uart2", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 6, GFLAGS),
  732. GATE(PCLK_UART3, "pclk_uart3", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 7, GFLAGS),
  733. GATE(PCLK_UART4, "pclk_uart4", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 8, GFLAGS),
  734. GATE(PCLK_UART5, "pclk_uart5", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 9, GFLAGS),
  735. GATE(PCLK_I2C0, "pclk_i2c0", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 10, GFLAGS),
  736. GATE(PCLK_I2C1, "pclk_i2c1", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 11, GFLAGS),
  737. GATE(PCLK_I2C2, "pclk_i2c2", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 12, GFLAGS),
  738. GATE(PCLK_I2C3, "pclk_i2c3", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 13, GFLAGS),
  739. GATE(PCLK_I2C4, "pclk_i2c4", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 14, GFLAGS),
  740. GATE(PCLK_PWM0, "pclk_pwm0", "pclk_bus_pre", 0, PX30_CLKGATE_CON(14), 15, GFLAGS),
  741. GATE(PCLK_PWM1, "pclk_pwm1", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 0, GFLAGS),
  742. GATE(PCLK_SPI0, "pclk_spi0", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 1, GFLAGS),
  743. GATE(PCLK_SPI1, "pclk_spi1", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 2, GFLAGS),
  744. GATE(PCLK_SARADC, "pclk_saradc", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 3, GFLAGS),
  745. GATE(PCLK_TSADC, "pclk_tsadc", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 4, GFLAGS),
  746. GATE(PCLK_TIMER, "pclk_timer", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 5, GFLAGS),
  747. GATE(PCLK_OTP_NS, "pclk_otp_ns", "pclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(15), 6, GFLAGS),
  748. GATE(PCLK_WDT_NS, "pclk_wdt_ns", "pclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(15), 7, GFLAGS),
  749. GATE(PCLK_GPIO1, "pclk_gpio1", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 8, GFLAGS),
  750. GATE(PCLK_GPIO2, "pclk_gpio2", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 9, GFLAGS),
  751. GATE(PCLK_GPIO3, "pclk_gpio3", "pclk_bus_pre", 0, PX30_CLKGATE_CON(15), 10, GFLAGS),
  752. GATE(0, "pclk_grf", "pclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(15), 11, GFLAGS),
  753. GATE(0, "pclk_sgrf", "pclk_bus_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(15), 12, GFLAGS),
  754. /* PD_VPU */
  755. GATE(0, "hclk_vpu_niu", "hclk_vpu_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(4), 7, GFLAGS),
  756. GATE(HCLK_VPU, "hclk_vpu", "hclk_vpu_pre", 0, PX30_CLKGATE_CON(4), 6, GFLAGS),
  757. GATE(0, "aclk_vpu_niu", "aclk_vpu_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(4), 5, GFLAGS),
  758. GATE(ACLK_VPU, "aclk_vpu", "aclk_vpu_pre", 0, PX30_CLKGATE_CON(4), 4, GFLAGS),
  759. /* PD_CRYPTO */
  760. GATE(0, "hclk_crypto_niu", "hclk_crypto_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(9), 3, GFLAGS),
  761. GATE(HCLK_CRYPTO, "hclk_crypto", "hclk_crypto_pre", 0, PX30_CLKGATE_CON(9), 5, GFLAGS),
  762. GATE(0, "aclk_crypto_niu", "aclk_crypto_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(9), 2, GFLAGS),
  763. GATE(ACLK_CRYPTO, "aclk_crypto", "aclk_crypto_pre", 0, PX30_CLKGATE_CON(9), 4, GFLAGS),
  764. /* PD_SDCARD */
  765. GATE(0, "hclk_sdmmc_niu", "hclk_sdmmc_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(7), 0, GFLAGS),
  766. GATE(HCLK_SDMMC, "hclk_sdmmc", "hclk_sdmmc_pre", 0, PX30_CLKGATE_CON(7), 1, GFLAGS),
  767. /* PD_PERI */
  768. GATE(0, "aclk_peri_niu", "aclk_peri_pre", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(5), 9, GFLAGS),
  769. /* PD_MMC_NAND */
  770. GATE(HCLK_NANDC, "hclk_nandc", "hclk_mmc_nand", 0, PX30_CLKGATE_CON(5), 15, GFLAGS),
  771. GATE(0, "hclk_mmc_nand_niu", "hclk_mmc_nand", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(6), 8, GFLAGS),
  772. GATE(HCLK_SDIO, "hclk_sdio", "hclk_mmc_nand", 0, PX30_CLKGATE_CON(6), 9, GFLAGS),
  773. GATE(HCLK_EMMC, "hclk_emmc", "hclk_mmc_nand", 0, PX30_CLKGATE_CON(6), 10, GFLAGS),
  774. GATE(HCLK_SFC, "hclk_sfc", "hclk_mmc_nand", 0, PX30_CLKGATE_CON(6), 11, GFLAGS),
  775. /* PD_USB */
  776. GATE(0, "hclk_usb_niu", "hclk_usb", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(7), 4, GFLAGS),
  777. GATE(HCLK_OTG, "hclk_otg", "hclk_usb", 0, PX30_CLKGATE_CON(7), 5, GFLAGS),
  778. GATE(HCLK_HOST, "hclk_host", "hclk_usb", 0, PX30_CLKGATE_CON(7), 6, GFLAGS),
  779. GATE(HCLK_HOST_ARB, "hclk_host_arb", "hclk_usb", CLK_IGNORE_UNUSED, PX30_CLKGATE_CON(7), 8, GFLAGS),
  780. /* PD_GMAC */
  781. GATE(0, "aclk_gmac_niu", "aclk_gmac_pre", CLK_IGNORE_UNUSED,
  782. PX30_CLKGATE_CON(8), 0, GFLAGS),
  783. GATE(ACLK_GMAC, "aclk_gmac", "aclk_gmac_pre", 0,
  784. PX30_CLKGATE_CON(8), 2, GFLAGS),
  785. GATE(0, "pclk_gmac_niu", "pclk_gmac_pre", CLK_IGNORE_UNUSED,
  786. PX30_CLKGATE_CON(8), 1, GFLAGS),
  787. GATE(PCLK_GMAC, "pclk_gmac", "pclk_gmac_pre", 0,
  788. PX30_CLKGATE_CON(8), 3, GFLAGS),
  789. };
  790. static struct rockchip_clk_branch px30_clk_pmu_branches[] __initdata = {
  791. /*
  792. * Clock-Architecture Diagram 2
  793. */
  794. COMPOSITE_FRACMUX(0, "clk_rtc32k_frac", "xin24m", CLK_IGNORE_UNUSED,
  795. PX30_PMU_CLKSEL_CON(1), 0,
  796. PX30_PMU_CLKGATE_CON(0), 13, GFLAGS,
  797. &px30_rtc32k_pmu_fracmux),
  798. COMPOSITE_NOMUX(XIN24M_DIV, "xin24m_div", "xin24m", CLK_IGNORE_UNUSED,
  799. PX30_PMU_CLKSEL_CON(0), 8, 5, DFLAGS,
  800. PX30_PMU_CLKGATE_CON(0), 12, GFLAGS),
  801. COMPOSITE_NOMUX(0, "clk_wifi_pmu_src", "gpll", 0,
  802. PX30_PMU_CLKSEL_CON(2), 8, 6, DFLAGS,
  803. PX30_PMU_CLKGATE_CON(0), 14, GFLAGS),
  804. COMPOSITE_NODIV(SCLK_WIFI_PMU, "clk_wifi_pmu", mux_wifi_pmu_p, CLK_SET_RATE_PARENT,
  805. PX30_PMU_CLKSEL_CON(2), 15, 1, MFLAGS,
  806. PX30_PMU_CLKGATE_CON(0), 15, GFLAGS),
  807. COMPOSITE(0, "clk_uart0_pmu_src", mux_uart_src_p, 0,
  808. PX30_PMU_CLKSEL_CON(3), 14, 2, MFLAGS, 0, 5, DFLAGS,
  809. PX30_PMU_CLKGATE_CON(1), 0, GFLAGS),
  810. COMPOSITE_NOMUX_HALFDIV(0, "clk_uart0_np5", "clk_uart0_pmu_src", 0,
  811. PX30_PMU_CLKSEL_CON(4), 0, 5, DFLAGS,
  812. PX30_PMU_CLKGATE_CON(1), 1, GFLAGS),
  813. COMPOSITE_FRACMUX(0, "clk_uart0_frac", "clk_uart0_pmu_src", CLK_SET_RATE_PARENT,
  814. PX30_PMU_CLKSEL_CON(5), 0,
  815. PX30_PMU_CLKGATE_CON(1), 2, GFLAGS,
  816. &px30_uart0_pmu_fracmux),
  817. GATE(SCLK_UART0_PMU, "clk_uart0_pmu", "clk_uart0_pmu_mux", CLK_SET_RATE_PARENT,
  818. PX30_PMU_CLKGATE_CON(1), 3, GFLAGS),
  819. GATE(SCLK_PVTM_PMU, "clk_pvtm_pmu", "xin24m", 0,
  820. PX30_PMU_CLKGATE_CON(1), 4, GFLAGS),
  821. COMPOSITE_NOMUX(PCLK_PMU_PRE, "pclk_pmu_pre", "gpll", 0,
  822. PX30_PMU_CLKSEL_CON(0), 0, 5, DFLAGS,
  823. PX30_PMU_CLKGATE_CON(0), 0, GFLAGS),
  824. COMPOSITE_NOMUX(SCLK_REF24M_PMU, "clk_ref24m_pmu", "gpll", 0,
  825. PX30_PMU_CLKSEL_CON(2), 0, 6, DFLAGS,
  826. PX30_PMU_CLKGATE_CON(1), 8, GFLAGS),
  827. COMPOSITE_NODIV(SCLK_USBPHY_REF, "clk_usbphy_ref", mux_usbphy_ref_p, CLK_SET_RATE_PARENT,
  828. PX30_PMU_CLKSEL_CON(2), 6, 1, MFLAGS,
  829. PX30_PMU_CLKGATE_CON(1), 9, GFLAGS),
  830. COMPOSITE_NODIV(SCLK_MIPIDSIPHY_REF, "clk_mipidsiphy_ref", mux_mipidsiphy_ref_p, CLK_SET_RATE_PARENT,
  831. PX30_PMU_CLKSEL_CON(2), 7, 1, MFLAGS,
  832. PX30_PMU_CLKGATE_CON(1), 10, GFLAGS),
  833. /*
  834. * Clock-Architecture Diagram 9
  835. */
  836. /* PD_PMU */
  837. GATE(0, "pclk_pmu_niu", "pclk_pmu_pre", CLK_IGNORE_UNUSED, PX30_PMU_CLKGATE_CON(0), 1, GFLAGS),
  838. GATE(0, "pclk_pmu_sgrf", "pclk_pmu_pre", CLK_IGNORE_UNUSED, PX30_PMU_CLKGATE_CON(0), 2, GFLAGS),
  839. GATE(0, "pclk_pmu_grf", "pclk_pmu_pre", CLK_IGNORE_UNUSED, PX30_PMU_CLKGATE_CON(0), 3, GFLAGS),
  840. GATE(0, "pclk_pmu", "pclk_pmu_pre", CLK_IGNORE_UNUSED, PX30_PMU_CLKGATE_CON(0), 4, GFLAGS),
  841. GATE(0, "pclk_pmu_mem", "pclk_pmu_pre", CLK_IGNORE_UNUSED, PX30_PMU_CLKGATE_CON(0), 5, GFLAGS),
  842. GATE(PCLK_GPIO0_PMU, "pclk_gpio0_pmu", "pclk_pmu_pre", 0, PX30_PMU_CLKGATE_CON(0), 6, GFLAGS),
  843. GATE(PCLK_UART0_PMU, "pclk_uart0_pmu", "pclk_pmu_pre", 0, PX30_PMU_CLKGATE_CON(0), 7, GFLAGS),
  844. GATE(0, "pclk_cru_pmu", "pclk_pmu_pre", CLK_IGNORE_UNUSED, PX30_PMU_CLKGATE_CON(0), 8, GFLAGS),
  845. };
  846. static const char *const px30_pmucru_critical_clocks[] __initconst = {
  847. "aclk_bus_pre",
  848. "pclk_bus_pre",
  849. "hclk_bus_pre",
  850. "aclk_peri_pre",
  851. "hclk_peri_pre",
  852. "aclk_gpu_niu",
  853. "pclk_top_pre",
  854. "pclk_pmu_pre",
  855. "hclk_usb_niu",
  856. "pll_npll",
  857. "usb480m",
  858. "clk_uart2",
  859. "pclk_uart2",
  860. };
  861. static void __init px30_clk_init(struct device_node *np)
  862. {
  863. struct rockchip_clk_provider *ctx;
  864. void __iomem *reg_base;
  865. struct clk *clk;
  866. reg_base = of_iomap(np, 0);
  867. if (!reg_base) {
  868. pr_err("%s: could not map cru region\n", __func__);
  869. return;
  870. }
  871. ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
  872. if (IS_ERR(ctx)) {
  873. pr_err("%s: rockchip clk init failed\n", __func__);
  874. iounmap(reg_base);
  875. return;
  876. }
  877. /* aclk_dmac is controlled by sgrf_soc_con1[11]. */
  878. clk = clk_register_fixed_factor(NULL, "aclk_dmac", "aclk_bus_pre", 0, 1, 1);
  879. if (IS_ERR(clk))
  880. pr_warn("%s: could not register clock aclk_dmac: %ld\n",
  881. __func__, PTR_ERR(clk));
  882. else
  883. rockchip_clk_add_lookup(ctx, clk, ACLK_DMAC);
  884. rockchip_clk_register_plls(ctx, px30_pll_clks,
  885. ARRAY_SIZE(px30_pll_clks),
  886. PX30_GRF_SOC_STATUS0);
  887. rockchip_clk_register_branches(ctx, px30_clk_branches,
  888. ARRAY_SIZE(px30_clk_branches));
  889. rockchip_clk_register_armclk(ctx, ARMCLK, "armclk",
  890. mux_armclk_p, ARRAY_SIZE(mux_armclk_p),
  891. &px30_cpuclk_data, px30_cpuclk_rates,
  892. ARRAY_SIZE(px30_cpuclk_rates));
  893. rockchip_register_softrst(np, 12, reg_base + PX30_SOFTRST_CON(0),
  894. ROCKCHIP_SOFTRST_HIWORD_MASK);
  895. rockchip_register_restart_notifier(ctx, PX30_GLB_SRST_FST, NULL);
  896. rockchip_clk_of_add_provider(np, ctx);
  897. }
  898. CLK_OF_DECLARE(px30_cru, "rockchip,px30-cru", px30_clk_init);
  899. static void __init px30_pmu_clk_init(struct device_node *np)
  900. {
  901. struct rockchip_clk_provider *ctx;
  902. void __iomem *reg_base;
  903. reg_base = of_iomap(np, 0);
  904. if (!reg_base) {
  905. pr_err("%s: could not map cru pmu region\n", __func__);
  906. return;
  907. }
  908. ctx = rockchip_clk_init(np, reg_base, CLKPMU_NR_CLKS);
  909. if (IS_ERR(ctx)) {
  910. pr_err("%s: rockchip pmu clk init failed\n", __func__);
  911. return;
  912. }
  913. rockchip_clk_register_plls(ctx, px30_pmu_pll_clks,
  914. ARRAY_SIZE(px30_pmu_pll_clks), PX30_GRF_SOC_STATUS0);
  915. rockchip_clk_register_branches(ctx, px30_clk_pmu_branches,
  916. ARRAY_SIZE(px30_clk_pmu_branches));
  917. rockchip_clk_protect_critical(px30_pmucru_critical_clocks,
  918. ARRAY_SIZE(px30_pmucru_critical_clocks));
  919. rockchip_clk_of_add_provider(np, ctx);
  920. }
  921. CLK_OF_DECLARE(px30_cru_pmu, "rockchip,px30-pmucru", px30_pmu_clk_init);