clk-rk3399.c 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614
  1. /*
  2. * Copyright (c) 2016 Rockchip Electronics Co. Ltd.
  3. * Author: Xing Zheng <zhengxing@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/platform_device.h>
  19. #include <linux/regmap.h>
  20. #include <dt-bindings/clock/rk3399-cru.h>
  21. #include "clk.h"
  22. enum rk3399_plls {
  23. lpll, bpll, dpll, cpll, gpll, npll, vpll,
  24. };
  25. enum rk3399_pmu_plls {
  26. ppll,
  27. };
  28. static struct rockchip_pll_rate_table rk3399_pll_rates[] = {
  29. /* _mhz, _refdiv, _fbdiv, _postdiv1, _postdiv2, _dsmpd, _frac */
  30. RK3036_PLL_RATE(2208000000, 1, 92, 1, 1, 1, 0),
  31. RK3036_PLL_RATE(2184000000, 1, 91, 1, 1, 1, 0),
  32. RK3036_PLL_RATE(2160000000, 1, 90, 1, 1, 1, 0),
  33. RK3036_PLL_RATE(2136000000, 1, 89, 1, 1, 1, 0),
  34. RK3036_PLL_RATE(2112000000, 1, 88, 1, 1, 1, 0),
  35. RK3036_PLL_RATE(2088000000, 1, 87, 1, 1, 1, 0),
  36. RK3036_PLL_RATE(2064000000, 1, 86, 1, 1, 1, 0),
  37. RK3036_PLL_RATE(2040000000, 1, 85, 1, 1, 1, 0),
  38. RK3036_PLL_RATE(2016000000, 1, 84, 1, 1, 1, 0),
  39. RK3036_PLL_RATE(1992000000, 1, 83, 1, 1, 1, 0),
  40. RK3036_PLL_RATE(1968000000, 1, 82, 1, 1, 1, 0),
  41. RK3036_PLL_RATE(1944000000, 1, 81, 1, 1, 1, 0),
  42. RK3036_PLL_RATE(1920000000, 1, 80, 1, 1, 1, 0),
  43. RK3036_PLL_RATE(1896000000, 1, 79, 1, 1, 1, 0),
  44. RK3036_PLL_RATE(1872000000, 1, 78, 1, 1, 1, 0),
  45. RK3036_PLL_RATE(1848000000, 1, 77, 1, 1, 1, 0),
  46. RK3036_PLL_RATE(1824000000, 1, 76, 1, 1, 1, 0),
  47. RK3036_PLL_RATE(1800000000, 1, 75, 1, 1, 1, 0),
  48. RK3036_PLL_RATE(1776000000, 1, 74, 1, 1, 1, 0),
  49. RK3036_PLL_RATE(1752000000, 1, 73, 1, 1, 1, 0),
  50. RK3036_PLL_RATE(1728000000, 1, 72, 1, 1, 1, 0),
  51. RK3036_PLL_RATE(1704000000, 1, 71, 1, 1, 1, 0),
  52. RK3036_PLL_RATE(1680000000, 1, 70, 1, 1, 1, 0),
  53. RK3036_PLL_RATE(1656000000, 1, 69, 1, 1, 1, 0),
  54. RK3036_PLL_RATE(1632000000, 1, 68, 1, 1, 1, 0),
  55. RK3036_PLL_RATE(1608000000, 1, 67, 1, 1, 1, 0),
  56. RK3036_PLL_RATE(1584000000, 1, 66, 1, 1, 1, 0),
  57. RK3036_PLL_RATE(1560000000, 1, 65, 1, 1, 1, 0),
  58. RK3036_PLL_RATE(1536000000, 1, 64, 1, 1, 1, 0),
  59. RK3036_PLL_RATE(1512000000, 1, 63, 1, 1, 1, 0),
  60. RK3036_PLL_RATE(1488000000, 1, 62, 1, 1, 1, 0),
  61. RK3036_PLL_RATE(1464000000, 1, 61, 1, 1, 1, 0),
  62. RK3036_PLL_RATE(1440000000, 1, 60, 1, 1, 1, 0),
  63. RK3036_PLL_RATE(1416000000, 1, 59, 1, 1, 1, 0),
  64. RK3036_PLL_RATE(1392000000, 1, 58, 1, 1, 1, 0),
  65. RK3036_PLL_RATE(1368000000, 1, 57, 1, 1, 1, 0),
  66. RK3036_PLL_RATE(1344000000, 1, 56, 1, 1, 1, 0),
  67. RK3036_PLL_RATE(1320000000, 1, 55, 1, 1, 1, 0),
  68. RK3036_PLL_RATE(1296000000, 1, 54, 1, 1, 1, 0),
  69. RK3036_PLL_RATE(1272000000, 1, 53, 1, 1, 1, 0),
  70. RK3036_PLL_RATE(1248000000, 1, 52, 1, 1, 1, 0),
  71. RK3036_PLL_RATE(1200000000, 1, 50, 1, 1, 1, 0),
  72. RK3036_PLL_RATE(1188000000, 2, 99, 1, 1, 1, 0),
  73. RK3036_PLL_RATE(1104000000, 1, 46, 1, 1, 1, 0),
  74. RK3036_PLL_RATE(1100000000, 12, 550, 1, 1, 1, 0),
  75. RK3036_PLL_RATE(1008000000, 1, 84, 2, 1, 1, 0),
  76. RK3036_PLL_RATE(1000000000, 6, 500, 2, 1, 1, 0),
  77. RK3036_PLL_RATE( 984000000, 1, 82, 2, 1, 1, 0),
  78. RK3036_PLL_RATE( 960000000, 1, 80, 2, 1, 1, 0),
  79. RK3036_PLL_RATE( 936000000, 1, 78, 2, 1, 1, 0),
  80. RK3036_PLL_RATE( 912000000, 1, 76, 2, 1, 1, 0),
  81. RK3036_PLL_RATE( 900000000, 4, 300, 2, 1, 1, 0),
  82. RK3036_PLL_RATE( 888000000, 1, 74, 2, 1, 1, 0),
  83. RK3036_PLL_RATE( 864000000, 1, 72, 2, 1, 1, 0),
  84. RK3036_PLL_RATE( 840000000, 1, 70, 2, 1, 1, 0),
  85. RK3036_PLL_RATE( 816000000, 1, 68, 2, 1, 1, 0),
  86. RK3036_PLL_RATE( 800000000, 6, 400, 2, 1, 1, 0),
  87. RK3036_PLL_RATE( 700000000, 6, 350, 2, 1, 1, 0),
  88. RK3036_PLL_RATE( 696000000, 1, 58, 2, 1, 1, 0),
  89. RK3036_PLL_RATE( 676000000, 3, 169, 2, 1, 1, 0),
  90. RK3036_PLL_RATE( 600000000, 1, 75, 3, 1, 1, 0),
  91. RK3036_PLL_RATE( 594000000, 1, 99, 4, 1, 1, 0),
  92. RK3036_PLL_RATE( 504000000, 1, 63, 3, 1, 1, 0),
  93. RK3036_PLL_RATE( 500000000, 6, 250, 2, 1, 1, 0),
  94. RK3036_PLL_RATE( 408000000, 1, 68, 2, 2, 1, 0),
  95. RK3036_PLL_RATE( 312000000, 1, 52, 2, 2, 1, 0),
  96. RK3036_PLL_RATE( 297000000, 1, 99, 4, 2, 1, 0),
  97. RK3036_PLL_RATE( 216000000, 1, 72, 4, 2, 1, 0),
  98. RK3036_PLL_RATE( 148500000, 1, 99, 4, 4, 1, 0),
  99. RK3036_PLL_RATE( 106500000, 1, 71, 4, 4, 1, 0),
  100. RK3036_PLL_RATE( 96000000, 1, 64, 4, 4, 1, 0),
  101. RK3036_PLL_RATE( 74250000, 2, 99, 4, 4, 1, 0),
  102. RK3036_PLL_RATE( 65000000, 1, 65, 6, 4, 1, 0),
  103. RK3036_PLL_RATE( 54000000, 1, 54, 6, 4, 1, 0),
  104. RK3036_PLL_RATE( 27000000, 1, 27, 6, 4, 1, 0),
  105. { /* sentinel */ },
  106. };
  107. /* CRU parents */
  108. PNAME(mux_pll_p) = { "xin24m", "xin32k" };
  109. PNAME(mux_armclkl_p) = { "clk_core_l_lpll_src",
  110. "clk_core_l_bpll_src",
  111. "clk_core_l_dpll_src",
  112. "clk_core_l_gpll_src" };
  113. PNAME(mux_armclkb_p) = { "clk_core_b_lpll_src",
  114. "clk_core_b_bpll_src",
  115. "clk_core_b_dpll_src",
  116. "clk_core_b_gpll_src" };
  117. PNAME(mux_ddrclk_p) = { "clk_ddrc_lpll_src",
  118. "clk_ddrc_bpll_src",
  119. "clk_ddrc_dpll_src",
  120. "clk_ddrc_gpll_src" };
  121. PNAME(mux_aclk_cci_p) = { "cpll_aclk_cci_src",
  122. "gpll_aclk_cci_src",
  123. "npll_aclk_cci_src",
  124. "vpll_aclk_cci_src" };
  125. PNAME(mux_cci_trace_p) = { "cpll_cci_trace",
  126. "gpll_cci_trace" };
  127. PNAME(mux_cs_p) = { "cpll_cs", "gpll_cs",
  128. "npll_cs"};
  129. PNAME(mux_aclk_perihp_p) = { "cpll_aclk_perihp_src",
  130. "gpll_aclk_perihp_src" };
  131. PNAME(mux_pll_src_cpll_gpll_p) = { "cpll", "gpll" };
  132. PNAME(mux_pll_src_cpll_gpll_npll_p) = { "cpll", "gpll", "npll" };
  133. PNAME(mux_pll_src_cpll_gpll_ppll_p) = { "cpll", "gpll", "ppll" };
  134. PNAME(mux_pll_src_cpll_gpll_upll_p) = { "cpll", "gpll", "upll" };
  135. PNAME(mux_pll_src_npll_cpll_gpll_p) = { "npll", "cpll", "gpll" };
  136. PNAME(mux_pll_src_cpll_gpll_npll_ppll_p) = { "cpll", "gpll", "npll",
  137. "ppll" };
  138. PNAME(mux_pll_src_cpll_gpll_npll_24m_p) = { "cpll", "gpll", "npll",
  139. "xin24m" };
  140. PNAME(mux_pll_src_cpll_gpll_npll_usbphy480m_p) = { "cpll", "gpll", "npll",
  141. "clk_usbphy_480m" };
  142. PNAME(mux_pll_src_ppll_cpll_gpll_npll_p) = { "ppll", "cpll", "gpll",
  143. "npll", "upll" };
  144. PNAME(mux_pll_src_cpll_gpll_npll_upll_24m_p) = { "cpll", "gpll", "npll",
  145. "upll", "xin24m" };
  146. PNAME(mux_pll_src_cpll_gpll_npll_ppll_upll_24m_p) = { "cpll", "gpll", "npll",
  147. "ppll", "upll", "xin24m" };
  148. PNAME(mux_pll_src_vpll_cpll_gpll_p) = { "vpll", "cpll", "gpll" };
  149. PNAME(mux_pll_src_vpll_cpll_gpll_npll_p) = { "vpll", "cpll", "gpll",
  150. "npll" };
  151. PNAME(mux_pll_src_vpll_cpll_gpll_24m_p) = { "vpll", "cpll", "gpll",
  152. "xin24m" };
  153. PNAME(mux_dclk_vop0_p) = { "dclk_vop0_div",
  154. "dclk_vop0_frac" };
  155. PNAME(mux_dclk_vop1_p) = { "dclk_vop1_div",
  156. "dclk_vop1_frac" };
  157. PNAME(mux_clk_cif_p) = { "clk_cifout_src", "xin24m" };
  158. PNAME(mux_pll_src_24m_usbphy480m_p) = { "xin24m", "clk_usbphy_480m" };
  159. PNAME(mux_pll_src_24m_pciephy_p) = { "xin24m", "clk_pciephy_ref100m" };
  160. PNAME(mux_pll_src_24m_32k_cpll_gpll_p) = { "xin24m", "xin32k",
  161. "cpll", "gpll" };
  162. PNAME(mux_pciecore_cru_phy_p) = { "clk_pcie_core_cru",
  163. "clk_pcie_core_phy" };
  164. PNAME(mux_aclk_emmc_p) = { "cpll_aclk_emmc_src",
  165. "gpll_aclk_emmc_src" };
  166. PNAME(mux_aclk_perilp0_p) = { "cpll_aclk_perilp0_src",
  167. "gpll_aclk_perilp0_src" };
  168. PNAME(mux_fclk_cm0s_p) = { "cpll_fclk_cm0s_src",
  169. "gpll_fclk_cm0s_src" };
  170. PNAME(mux_hclk_perilp1_p) = { "cpll_hclk_perilp1_src",
  171. "gpll_hclk_perilp1_src" };
  172. PNAME(mux_clk_testout1_p) = { "clk_testout1_pll_src", "xin24m" };
  173. PNAME(mux_clk_testout2_p) = { "clk_testout2_pll_src", "xin24m" };
  174. PNAME(mux_usbphy_480m_p) = { "clk_usbphy0_480m_src",
  175. "clk_usbphy1_480m_src" };
  176. PNAME(mux_aclk_gmac_p) = { "cpll_aclk_gmac_src",
  177. "gpll_aclk_gmac_src" };
  178. PNAME(mux_rmii_p) = { "clk_gmac", "clkin_gmac" };
  179. PNAME(mux_spdif_p) = { "clk_spdif_div", "clk_spdif_frac",
  180. "clkin_i2s", "xin12m" };
  181. PNAME(mux_i2s0_p) = { "clk_i2s0_div", "clk_i2s0_frac",
  182. "clkin_i2s", "xin12m" };
  183. PNAME(mux_i2s1_p) = { "clk_i2s1_div", "clk_i2s1_frac",
  184. "clkin_i2s", "xin12m" };
  185. PNAME(mux_i2s2_p) = { "clk_i2s2_div", "clk_i2s2_frac",
  186. "clkin_i2s", "xin12m" };
  187. PNAME(mux_i2sch_p) = { "clk_i2s0", "clk_i2s1",
  188. "clk_i2s2" };
  189. PNAME(mux_i2sout_p) = { "clk_i2sout_src", "xin12m" };
  190. PNAME(mux_uart0_p) = { "clk_uart0_div", "clk_uart0_frac", "xin24m" };
  191. PNAME(mux_uart1_p) = { "clk_uart1_div", "clk_uart1_frac", "xin24m" };
  192. PNAME(mux_uart2_p) = { "clk_uart2_div", "clk_uart2_frac", "xin24m" };
  193. PNAME(mux_uart3_p) = { "clk_uart3_div", "clk_uart3_frac", "xin24m" };
  194. /* PMU CRU parents */
  195. PNAME(mux_ppll_24m_p) = { "ppll", "xin24m" };
  196. PNAME(mux_24m_ppll_p) = { "xin24m", "ppll" };
  197. PNAME(mux_fclk_cm0s_pmu_ppll_p) = { "fclk_cm0s_pmu_ppll_src", "xin24m" };
  198. PNAME(mux_wifi_pmu_p) = { "clk_wifi_div", "clk_wifi_frac" };
  199. PNAME(mux_uart4_pmu_p) = { "clk_uart4_div", "clk_uart4_frac",
  200. "xin24m" };
  201. PNAME(mux_clk_testout2_2io_p) = { "clk_testout2", "clk_32k_suspend_pmu" };
  202. static struct rockchip_pll_clock rk3399_pll_clks[] __initdata = {
  203. [lpll] = PLL(pll_rk3399, PLL_APLLL, "lpll", mux_pll_p, 0, RK3399_PLL_CON(0),
  204. RK3399_PLL_CON(3), 8, 31, 0, rk3399_pll_rates),
  205. [bpll] = PLL(pll_rk3399, PLL_APLLB, "bpll", mux_pll_p, 0, RK3399_PLL_CON(8),
  206. RK3399_PLL_CON(11), 8, 31, 0, rk3399_pll_rates),
  207. [dpll] = PLL(pll_rk3399, PLL_DPLL, "dpll", mux_pll_p, 0, RK3399_PLL_CON(16),
  208. RK3399_PLL_CON(19), 8, 31, 0, NULL),
  209. [cpll] = PLL(pll_rk3399, PLL_CPLL, "cpll", mux_pll_p, 0, RK3399_PLL_CON(24),
  210. RK3399_PLL_CON(27), 8, 31, ROCKCHIP_PLL_SYNC_RATE, rk3399_pll_rates),
  211. [gpll] = PLL(pll_rk3399, PLL_GPLL, "gpll", mux_pll_p, 0, RK3399_PLL_CON(32),
  212. RK3399_PLL_CON(35), 8, 31, ROCKCHIP_PLL_SYNC_RATE, rk3399_pll_rates),
  213. [npll] = PLL(pll_rk3399, PLL_NPLL, "npll", mux_pll_p, 0, RK3399_PLL_CON(40),
  214. RK3399_PLL_CON(43), 8, 31, ROCKCHIP_PLL_SYNC_RATE, rk3399_pll_rates),
  215. [vpll] = PLL(pll_rk3399, PLL_VPLL, "vpll", mux_pll_p, 0, RK3399_PLL_CON(48),
  216. RK3399_PLL_CON(51), 8, 31, ROCKCHIP_PLL_SYNC_RATE, rk3399_pll_rates),
  217. };
  218. static struct rockchip_pll_clock rk3399_pmu_pll_clks[] __initdata = {
  219. [ppll] = PLL(pll_rk3399, PLL_PPLL, "ppll", mux_pll_p, 0, RK3399_PMU_PLL_CON(0),
  220. RK3399_PMU_PLL_CON(3), 8, 31, ROCKCHIP_PLL_SYNC_RATE, rk3399_pll_rates),
  221. };
  222. #define MFLAGS CLK_MUX_HIWORD_MASK
  223. #define DFLAGS CLK_DIVIDER_HIWORD_MASK
  224. #define GFLAGS (CLK_GATE_HIWORD_MASK | CLK_GATE_SET_TO_DISABLE)
  225. #define IFLAGS ROCKCHIP_INVERTER_HIWORD_MASK
  226. static struct rockchip_clk_branch rk3399_spdif_fracmux __initdata =
  227. MUX(0, "clk_spdif_mux", mux_spdif_p, CLK_SET_RATE_PARENT,
  228. RK3399_CLKSEL_CON(32), 13, 2, MFLAGS);
  229. static struct rockchip_clk_branch rk3399_i2s0_fracmux __initdata =
  230. MUX(0, "clk_i2s0_mux", mux_i2s0_p, CLK_SET_RATE_PARENT,
  231. RK3399_CLKSEL_CON(28), 8, 2, MFLAGS);
  232. static struct rockchip_clk_branch rk3399_i2s1_fracmux __initdata =
  233. MUX(0, "clk_i2s1_mux", mux_i2s1_p, CLK_SET_RATE_PARENT,
  234. RK3399_CLKSEL_CON(29), 8, 2, MFLAGS);
  235. static struct rockchip_clk_branch rk3399_i2s2_fracmux __initdata =
  236. MUX(0, "clk_i2s2_mux", mux_i2s2_p, CLK_SET_RATE_PARENT,
  237. RK3399_CLKSEL_CON(30), 8, 2, MFLAGS);
  238. static struct rockchip_clk_branch rk3399_uart0_fracmux __initdata =
  239. MUX(SCLK_UART0, "clk_uart0", mux_uart0_p, CLK_SET_RATE_PARENT,
  240. RK3399_CLKSEL_CON(33), 8, 2, MFLAGS);
  241. static struct rockchip_clk_branch rk3399_uart1_fracmux __initdata =
  242. MUX(SCLK_UART1, "clk_uart1", mux_uart1_p, CLK_SET_RATE_PARENT,
  243. RK3399_CLKSEL_CON(34), 8, 2, MFLAGS);
  244. static struct rockchip_clk_branch rk3399_uart2_fracmux __initdata =
  245. MUX(SCLK_UART2, "clk_uart2", mux_uart2_p, CLK_SET_RATE_PARENT,
  246. RK3399_CLKSEL_CON(35), 8, 2, MFLAGS);
  247. static struct rockchip_clk_branch rk3399_uart3_fracmux __initdata =
  248. MUX(SCLK_UART3, "clk_uart3", mux_uart3_p, CLK_SET_RATE_PARENT,
  249. RK3399_CLKSEL_CON(36), 8, 2, MFLAGS);
  250. static struct rockchip_clk_branch rk3399_uart4_pmu_fracmux __initdata =
  251. MUX(SCLK_UART4_PMU, "clk_uart4_pmu", mux_uart4_pmu_p, CLK_SET_RATE_PARENT,
  252. RK3399_PMU_CLKSEL_CON(5), 8, 2, MFLAGS);
  253. static struct rockchip_clk_branch rk3399_dclk_vop0_fracmux __initdata =
  254. MUX(DCLK_VOP0, "dclk_vop0", mux_dclk_vop0_p, CLK_SET_RATE_PARENT,
  255. RK3399_CLKSEL_CON(49), 11, 1, MFLAGS);
  256. static struct rockchip_clk_branch rk3399_dclk_vop1_fracmux __initdata =
  257. MUX(DCLK_VOP1, "dclk_vop1", mux_dclk_vop1_p, CLK_SET_RATE_PARENT,
  258. RK3399_CLKSEL_CON(50), 11, 1, MFLAGS);
  259. static struct rockchip_clk_branch rk3399_pmuclk_wifi_fracmux __initdata =
  260. MUX(SCLK_WIFI_PMU, "clk_wifi_pmu", mux_wifi_pmu_p, CLK_SET_RATE_PARENT,
  261. RK3399_PMU_CLKSEL_CON(1), 14, 1, MFLAGS);
  262. static const struct rockchip_cpuclk_reg_data rk3399_cpuclkl_data = {
  263. .core_reg = RK3399_CLKSEL_CON(0),
  264. .div_core_shift = 0,
  265. .div_core_mask = 0x1f,
  266. .mux_core_alt = 3,
  267. .mux_core_main = 0,
  268. .mux_core_shift = 6,
  269. .mux_core_mask = 0x3,
  270. };
  271. static const struct rockchip_cpuclk_reg_data rk3399_cpuclkb_data = {
  272. .core_reg = RK3399_CLKSEL_CON(2),
  273. .div_core_shift = 0,
  274. .div_core_mask = 0x1f,
  275. .mux_core_alt = 3,
  276. .mux_core_main = 1,
  277. .mux_core_shift = 6,
  278. .mux_core_mask = 0x3,
  279. };
  280. #define RK3399_DIV_ACLKM_MASK 0x1f
  281. #define RK3399_DIV_ACLKM_SHIFT 8
  282. #define RK3399_DIV_ATCLK_MASK 0x1f
  283. #define RK3399_DIV_ATCLK_SHIFT 0
  284. #define RK3399_DIV_PCLK_DBG_MASK 0x1f
  285. #define RK3399_DIV_PCLK_DBG_SHIFT 8
  286. #define RK3399_CLKSEL0(_offs, _aclkm) \
  287. { \
  288. .reg = RK3399_CLKSEL_CON(0 + _offs), \
  289. .val = HIWORD_UPDATE(_aclkm, RK3399_DIV_ACLKM_MASK, \
  290. RK3399_DIV_ACLKM_SHIFT), \
  291. }
  292. #define RK3399_CLKSEL1(_offs, _atclk, _pdbg) \
  293. { \
  294. .reg = RK3399_CLKSEL_CON(1 + _offs), \
  295. .val = HIWORD_UPDATE(_atclk, RK3399_DIV_ATCLK_MASK, \
  296. RK3399_DIV_ATCLK_SHIFT) | \
  297. HIWORD_UPDATE(_pdbg, RK3399_DIV_PCLK_DBG_MASK, \
  298. RK3399_DIV_PCLK_DBG_SHIFT), \
  299. }
  300. /* cluster_l: aclkm in clksel0, rest in clksel1 */
  301. #define RK3399_CPUCLKL_RATE(_prate, _aclkm, _atclk, _pdbg) \
  302. { \
  303. .prate = _prate##U, \
  304. .divs = { \
  305. RK3399_CLKSEL0(0, _aclkm), \
  306. RK3399_CLKSEL1(0, _atclk, _pdbg), \
  307. }, \
  308. }
  309. /* cluster_b: aclkm in clksel2, rest in clksel3 */
  310. #define RK3399_CPUCLKB_RATE(_prate, _aclkm, _atclk, _pdbg) \
  311. { \
  312. .prate = _prate##U, \
  313. .divs = { \
  314. RK3399_CLKSEL0(2, _aclkm), \
  315. RK3399_CLKSEL1(2, _atclk, _pdbg), \
  316. }, \
  317. }
  318. static struct rockchip_cpuclk_rate_table rk3399_cpuclkl_rates[] __initdata = {
  319. RK3399_CPUCLKL_RATE(1800000000, 1, 8, 8),
  320. RK3399_CPUCLKL_RATE(1704000000, 1, 8, 8),
  321. RK3399_CPUCLKL_RATE(1608000000, 1, 7, 7),
  322. RK3399_CPUCLKL_RATE(1512000000, 1, 7, 7),
  323. RK3399_CPUCLKL_RATE(1488000000, 1, 6, 6),
  324. RK3399_CPUCLKL_RATE(1416000000, 1, 6, 6),
  325. RK3399_CPUCLKL_RATE(1200000000, 1, 5, 5),
  326. RK3399_CPUCLKL_RATE(1008000000, 1, 5, 5),
  327. RK3399_CPUCLKL_RATE( 816000000, 1, 4, 4),
  328. RK3399_CPUCLKL_RATE( 696000000, 1, 3, 3),
  329. RK3399_CPUCLKL_RATE( 600000000, 1, 3, 3),
  330. RK3399_CPUCLKL_RATE( 408000000, 1, 2, 2),
  331. RK3399_CPUCLKL_RATE( 312000000, 1, 1, 1),
  332. RK3399_CPUCLKL_RATE( 216000000, 1, 1, 1),
  333. RK3399_CPUCLKL_RATE( 96000000, 1, 1, 1),
  334. };
  335. static struct rockchip_cpuclk_rate_table rk3399_cpuclkb_rates[] __initdata = {
  336. RK3399_CPUCLKB_RATE(2208000000, 1, 11, 11),
  337. RK3399_CPUCLKB_RATE(2184000000, 1, 11, 11),
  338. RK3399_CPUCLKB_RATE(2088000000, 1, 10, 10),
  339. RK3399_CPUCLKB_RATE(2040000000, 1, 10, 10),
  340. RK3399_CPUCLKB_RATE(2016000000, 1, 9, 9),
  341. RK3399_CPUCLKB_RATE(1992000000, 1, 9, 9),
  342. RK3399_CPUCLKB_RATE(1896000000, 1, 9, 9),
  343. RK3399_CPUCLKB_RATE(1800000000, 1, 8, 8),
  344. RK3399_CPUCLKB_RATE(1704000000, 1, 8, 8),
  345. RK3399_CPUCLKB_RATE(1608000000, 1, 7, 7),
  346. RK3399_CPUCLKB_RATE(1512000000, 1, 7, 7),
  347. RK3399_CPUCLKB_RATE(1488000000, 1, 6, 6),
  348. RK3399_CPUCLKB_RATE(1416000000, 1, 6, 6),
  349. RK3399_CPUCLKB_RATE(1200000000, 1, 5, 5),
  350. RK3399_CPUCLKB_RATE(1008000000, 1, 5, 5),
  351. RK3399_CPUCLKB_RATE( 816000000, 1, 4, 4),
  352. RK3399_CPUCLKB_RATE( 696000000, 1, 3, 3),
  353. RK3399_CPUCLKB_RATE( 600000000, 1, 3, 3),
  354. RK3399_CPUCLKB_RATE( 408000000, 1, 2, 2),
  355. RK3399_CPUCLKB_RATE( 312000000, 1, 1, 1),
  356. RK3399_CPUCLKB_RATE( 216000000, 1, 1, 1),
  357. RK3399_CPUCLKB_RATE( 96000000, 1, 1, 1),
  358. };
  359. static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = {
  360. /*
  361. * CRU Clock-Architecture
  362. */
  363. /* usbphy */
  364. GATE(SCLK_USB2PHY0_REF, "clk_usb2phy0_ref", "xin24m", CLK_IGNORE_UNUSED,
  365. RK3399_CLKGATE_CON(6), 5, GFLAGS),
  366. GATE(SCLK_USB2PHY1_REF, "clk_usb2phy1_ref", "xin24m", CLK_IGNORE_UNUSED,
  367. RK3399_CLKGATE_CON(6), 6, GFLAGS),
  368. GATE(0, "clk_usbphy0_480m_src", "clk_usbphy0_480m", CLK_IGNORE_UNUSED,
  369. RK3399_CLKGATE_CON(13), 12, GFLAGS),
  370. GATE(0, "clk_usbphy1_480m_src", "clk_usbphy1_480m", CLK_IGNORE_UNUSED,
  371. RK3399_CLKGATE_CON(13), 12, GFLAGS),
  372. MUX(0, "clk_usbphy_480m", mux_usbphy_480m_p, CLK_IGNORE_UNUSED,
  373. RK3399_CLKSEL_CON(14), 6, 1, MFLAGS),
  374. MUX(0, "upll", mux_pll_src_24m_usbphy480m_p, 0,
  375. RK3399_CLKSEL_CON(14), 15, 1, MFLAGS),
  376. COMPOSITE_NODIV(SCLK_HSICPHY, "clk_hsicphy", mux_pll_src_cpll_gpll_npll_usbphy480m_p, 0,
  377. RK3399_CLKSEL_CON(19), 0, 2, MFLAGS,
  378. RK3399_CLKGATE_CON(6), 4, GFLAGS),
  379. COMPOSITE(ACLK_USB3, "aclk_usb3", mux_pll_src_cpll_gpll_npll_p, 0,
  380. RK3399_CLKSEL_CON(39), 6, 2, MFLAGS, 0, 5, DFLAGS,
  381. RK3399_CLKGATE_CON(12), 0, GFLAGS),
  382. GATE(ACLK_USB3_NOC, "aclk_usb3_noc", "aclk_usb3", CLK_IGNORE_UNUSED,
  383. RK3399_CLKGATE_CON(30), 0, GFLAGS),
  384. GATE(ACLK_USB3OTG0, "aclk_usb3otg0", "aclk_usb3", 0,
  385. RK3399_CLKGATE_CON(30), 1, GFLAGS),
  386. GATE(ACLK_USB3OTG1, "aclk_usb3otg1", "aclk_usb3", 0,
  387. RK3399_CLKGATE_CON(30), 2, GFLAGS),
  388. GATE(ACLK_USB3_RKSOC_AXI_PERF, "aclk_usb3_rksoc_axi_perf", "aclk_usb3", 0,
  389. RK3399_CLKGATE_CON(30), 3, GFLAGS),
  390. GATE(ACLK_USB3_GRF, "aclk_usb3_grf", "aclk_usb3", 0,
  391. RK3399_CLKGATE_CON(30), 4, GFLAGS),
  392. GATE(SCLK_USB3OTG0_REF, "clk_usb3otg0_ref", "xin24m", 0,
  393. RK3399_CLKGATE_CON(12), 1, GFLAGS),
  394. GATE(SCLK_USB3OTG1_REF, "clk_usb3otg1_ref", "xin24m", 0,
  395. RK3399_CLKGATE_CON(12), 2, GFLAGS),
  396. COMPOSITE(SCLK_USB3OTG0_SUSPEND, "clk_usb3otg0_suspend", mux_pll_p, 0,
  397. RK3399_CLKSEL_CON(40), 15, 1, MFLAGS, 0, 10, DFLAGS,
  398. RK3399_CLKGATE_CON(12), 3, GFLAGS),
  399. COMPOSITE(SCLK_USB3OTG1_SUSPEND, "clk_usb3otg1_suspend", mux_pll_p, 0,
  400. RK3399_CLKSEL_CON(41), 15, 1, MFLAGS, 0, 10, DFLAGS,
  401. RK3399_CLKGATE_CON(12), 4, GFLAGS),
  402. COMPOSITE(SCLK_UPHY0_TCPDPHY_REF, "clk_uphy0_tcpdphy_ref", mux_pll_p, 0,
  403. RK3399_CLKSEL_CON(64), 15, 1, MFLAGS, 8, 5, DFLAGS,
  404. RK3399_CLKGATE_CON(13), 4, GFLAGS),
  405. COMPOSITE(SCLK_UPHY0_TCPDCORE, "clk_uphy0_tcpdcore", mux_pll_src_24m_32k_cpll_gpll_p, 0,
  406. RK3399_CLKSEL_CON(64), 6, 2, MFLAGS, 0, 5, DFLAGS,
  407. RK3399_CLKGATE_CON(13), 5, GFLAGS),
  408. COMPOSITE(SCLK_UPHY1_TCPDPHY_REF, "clk_uphy1_tcpdphy_ref", mux_pll_p, 0,
  409. RK3399_CLKSEL_CON(65), 15, 1, MFLAGS, 8, 5, DFLAGS,
  410. RK3399_CLKGATE_CON(13), 6, GFLAGS),
  411. COMPOSITE(SCLK_UPHY1_TCPDCORE, "clk_uphy1_tcpdcore", mux_pll_src_24m_32k_cpll_gpll_p, 0,
  412. RK3399_CLKSEL_CON(65), 6, 2, MFLAGS, 0, 5, DFLAGS,
  413. RK3399_CLKGATE_CON(13), 7, GFLAGS),
  414. /* little core */
  415. GATE(0, "clk_core_l_lpll_src", "lpll", CLK_IGNORE_UNUSED,
  416. RK3399_CLKGATE_CON(0), 0, GFLAGS),
  417. GATE(0, "clk_core_l_bpll_src", "bpll", CLK_IGNORE_UNUSED,
  418. RK3399_CLKGATE_CON(0), 1, GFLAGS),
  419. GATE(0, "clk_core_l_dpll_src", "dpll", CLK_IGNORE_UNUSED,
  420. RK3399_CLKGATE_CON(0), 2, GFLAGS),
  421. GATE(0, "clk_core_l_gpll_src", "gpll", CLK_IGNORE_UNUSED,
  422. RK3399_CLKGATE_CON(0), 3, GFLAGS),
  423. COMPOSITE_NOMUX(0, "aclkm_core_l", "armclkl", CLK_IGNORE_UNUSED,
  424. RK3399_CLKSEL_CON(0), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
  425. RK3399_CLKGATE_CON(0), 4, GFLAGS),
  426. COMPOSITE_NOMUX(0, "atclk_core_l", "armclkl", CLK_IGNORE_UNUSED,
  427. RK3399_CLKSEL_CON(1), 0, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
  428. RK3399_CLKGATE_CON(0), 5, GFLAGS),
  429. COMPOSITE_NOMUX(0, "pclk_dbg_core_l", "armclkl", CLK_IGNORE_UNUSED,
  430. RK3399_CLKSEL_CON(1), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
  431. RK3399_CLKGATE_CON(0), 6, GFLAGS),
  432. GATE(ACLK_CORE_ADB400_CORE_L_2_CCI500, "aclk_core_adb400_core_l_2_cci500", "aclkm_core_l", CLK_IGNORE_UNUSED,
  433. RK3399_CLKGATE_CON(14), 12, GFLAGS),
  434. GATE(ACLK_PERF_CORE_L, "aclk_perf_core_l", "aclkm_core_l", CLK_IGNORE_UNUSED,
  435. RK3399_CLKGATE_CON(14), 13, GFLAGS),
  436. GATE(0, "clk_dbg_pd_core_l", "armclkl", CLK_IGNORE_UNUSED,
  437. RK3399_CLKGATE_CON(14), 9, GFLAGS),
  438. GATE(ACLK_GIC_ADB400_GIC_2_CORE_L, "aclk_core_adb400_gic_2_core_l", "armclkl", CLK_IGNORE_UNUSED,
  439. RK3399_CLKGATE_CON(14), 10, GFLAGS),
  440. GATE(ACLK_GIC_ADB400_CORE_L_2_GIC, "aclk_core_adb400_core_l_2_gic", "armclkl", CLK_IGNORE_UNUSED,
  441. RK3399_CLKGATE_CON(14), 11, GFLAGS),
  442. GATE(SCLK_PVTM_CORE_L, "clk_pvtm_core_l", "xin24m", CLK_IGNORE_UNUSED,
  443. RK3399_CLKGATE_CON(0), 7, GFLAGS),
  444. /* big core */
  445. GATE(0, "clk_core_b_lpll_src", "lpll", CLK_IGNORE_UNUSED,
  446. RK3399_CLKGATE_CON(1), 0, GFLAGS),
  447. GATE(0, "clk_core_b_bpll_src", "bpll", CLK_IGNORE_UNUSED,
  448. RK3399_CLKGATE_CON(1), 1, GFLAGS),
  449. GATE(0, "clk_core_b_dpll_src", "dpll", CLK_IGNORE_UNUSED,
  450. RK3399_CLKGATE_CON(1), 2, GFLAGS),
  451. GATE(0, "clk_core_b_gpll_src", "gpll", CLK_IGNORE_UNUSED,
  452. RK3399_CLKGATE_CON(1), 3, GFLAGS),
  453. COMPOSITE_NOMUX(0, "aclkm_core_b", "armclkb", CLK_IGNORE_UNUSED,
  454. RK3399_CLKSEL_CON(2), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
  455. RK3399_CLKGATE_CON(1), 4, GFLAGS),
  456. COMPOSITE_NOMUX(0, "atclk_core_b", "armclkb", CLK_IGNORE_UNUSED,
  457. RK3399_CLKSEL_CON(3), 0, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
  458. RK3399_CLKGATE_CON(1), 5, GFLAGS),
  459. COMPOSITE_NOMUX(0, "pclk_dbg_core_b", "armclkb", CLK_IGNORE_UNUSED,
  460. RK3399_CLKSEL_CON(3), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
  461. RK3399_CLKGATE_CON(1), 6, GFLAGS),
  462. GATE(ACLK_CORE_ADB400_CORE_B_2_CCI500, "aclk_core_adb400_core_b_2_cci500", "aclkm_core_b", CLK_IGNORE_UNUSED,
  463. RK3399_CLKGATE_CON(14), 5, GFLAGS),
  464. GATE(ACLK_PERF_CORE_B, "aclk_perf_core_b", "aclkm_core_b", CLK_IGNORE_UNUSED,
  465. RK3399_CLKGATE_CON(14), 6, GFLAGS),
  466. GATE(0, "clk_dbg_pd_core_b", "armclkb", CLK_IGNORE_UNUSED,
  467. RK3399_CLKGATE_CON(14), 1, GFLAGS),
  468. GATE(ACLK_GIC_ADB400_GIC_2_CORE_B, "aclk_core_adb400_gic_2_core_b", "armclkb", CLK_IGNORE_UNUSED,
  469. RK3399_CLKGATE_CON(14), 3, GFLAGS),
  470. GATE(ACLK_GIC_ADB400_CORE_B_2_GIC, "aclk_core_adb400_core_b_2_gic", "armclkb", CLK_IGNORE_UNUSED,
  471. RK3399_CLKGATE_CON(14), 4, GFLAGS),
  472. DIV(0, "pclken_dbg_core_b", "pclk_dbg_core_b", CLK_IGNORE_UNUSED,
  473. RK3399_CLKSEL_CON(3), 13, 2, DFLAGS | CLK_DIVIDER_READ_ONLY),
  474. GATE(0, "pclk_dbg_cxcs_pd_core_b", "pclk_dbg_core_b", CLK_IGNORE_UNUSED,
  475. RK3399_CLKGATE_CON(14), 2, GFLAGS),
  476. GATE(SCLK_PVTM_CORE_B, "clk_pvtm_core_b", "xin24m", CLK_IGNORE_UNUSED,
  477. RK3399_CLKGATE_CON(1), 7, GFLAGS),
  478. /* gmac */
  479. GATE(0, "cpll_aclk_gmac_src", "cpll", CLK_IGNORE_UNUSED,
  480. RK3399_CLKGATE_CON(6), 9, GFLAGS),
  481. GATE(0, "gpll_aclk_gmac_src", "gpll", CLK_IGNORE_UNUSED,
  482. RK3399_CLKGATE_CON(6), 8, GFLAGS),
  483. COMPOSITE(0, "aclk_gmac_pre", mux_aclk_gmac_p, 0,
  484. RK3399_CLKSEL_CON(20), 7, 1, MFLAGS, 0, 5, DFLAGS,
  485. RK3399_CLKGATE_CON(6), 10, GFLAGS),
  486. GATE(ACLK_GMAC, "aclk_gmac", "aclk_gmac_pre", 0,
  487. RK3399_CLKGATE_CON(32), 0, GFLAGS),
  488. GATE(ACLK_GMAC_NOC, "aclk_gmac_noc", "aclk_gmac_pre", CLK_IGNORE_UNUSED,
  489. RK3399_CLKGATE_CON(32), 1, GFLAGS),
  490. GATE(ACLK_PERF_GMAC, "aclk_perf_gmac", "aclk_gmac_pre", 0,
  491. RK3399_CLKGATE_CON(32), 4, GFLAGS),
  492. COMPOSITE_NOMUX(0, "pclk_gmac_pre", "aclk_gmac_pre", 0,
  493. RK3399_CLKSEL_CON(19), 8, 3, DFLAGS,
  494. RK3399_CLKGATE_CON(6), 11, GFLAGS),
  495. GATE(PCLK_GMAC, "pclk_gmac", "pclk_gmac_pre", 0,
  496. RK3399_CLKGATE_CON(32), 2, GFLAGS),
  497. GATE(PCLK_GMAC_NOC, "pclk_gmac_noc", "pclk_gmac_pre", CLK_IGNORE_UNUSED,
  498. RK3399_CLKGATE_CON(32), 3, GFLAGS),
  499. COMPOSITE(SCLK_MAC, "clk_gmac", mux_pll_src_cpll_gpll_npll_p, 0,
  500. RK3399_CLKSEL_CON(20), 14, 2, MFLAGS, 8, 5, DFLAGS,
  501. RK3399_CLKGATE_CON(5), 5, GFLAGS),
  502. MUX(SCLK_RMII_SRC, "clk_rmii_src", mux_rmii_p, CLK_SET_RATE_PARENT,
  503. RK3399_CLKSEL_CON(19), 4, 1, MFLAGS),
  504. GATE(SCLK_MACREF_OUT, "clk_mac_refout", "clk_rmii_src", 0,
  505. RK3399_CLKGATE_CON(5), 6, GFLAGS),
  506. GATE(SCLK_MACREF, "clk_mac_ref", "clk_rmii_src", 0,
  507. RK3399_CLKGATE_CON(5), 7, GFLAGS),
  508. GATE(SCLK_MAC_RX, "clk_rmii_rx", "clk_rmii_src", 0,
  509. RK3399_CLKGATE_CON(5), 8, GFLAGS),
  510. GATE(SCLK_MAC_TX, "clk_rmii_tx", "clk_rmii_src", 0,
  511. RK3399_CLKGATE_CON(5), 9, GFLAGS),
  512. /* spdif */
  513. COMPOSITE(0, "clk_spdif_div", mux_pll_src_cpll_gpll_p, 0,
  514. RK3399_CLKSEL_CON(32), 7, 1, MFLAGS, 0, 7, DFLAGS,
  515. RK3399_CLKGATE_CON(8), 13, GFLAGS),
  516. COMPOSITE_FRACMUX(0, "clk_spdif_frac", "clk_spdif_div", 0,
  517. RK3399_CLKSEL_CON(99), 0,
  518. RK3399_CLKGATE_CON(8), 14, GFLAGS,
  519. &rk3399_spdif_fracmux),
  520. GATE(SCLK_SPDIF_8CH, "clk_spdif", "clk_spdif_mux", CLK_SET_RATE_PARENT,
  521. RK3399_CLKGATE_CON(8), 15, GFLAGS),
  522. COMPOSITE(SCLK_SPDIF_REC_DPTX, "clk_spdif_rec_dptx", mux_pll_src_cpll_gpll_p, 0,
  523. RK3399_CLKSEL_CON(32), 15, 1, MFLAGS, 8, 5, DFLAGS,
  524. RK3399_CLKGATE_CON(10), 6, GFLAGS),
  525. /* i2s */
  526. COMPOSITE(0, "clk_i2s0_div", mux_pll_src_cpll_gpll_p, 0,
  527. RK3399_CLKSEL_CON(28), 7, 1, MFLAGS, 0, 7, DFLAGS,
  528. RK3399_CLKGATE_CON(8), 3, GFLAGS),
  529. COMPOSITE_FRACMUX(0, "clk_i2s0_frac", "clk_i2s0_div", 0,
  530. RK3399_CLKSEL_CON(96), 0,
  531. RK3399_CLKGATE_CON(8), 4, GFLAGS,
  532. &rk3399_i2s0_fracmux),
  533. GATE(SCLK_I2S0_8CH, "clk_i2s0", "clk_i2s0_mux", CLK_SET_RATE_PARENT,
  534. RK3399_CLKGATE_CON(8), 5, GFLAGS),
  535. COMPOSITE(0, "clk_i2s1_div", mux_pll_src_cpll_gpll_p, 0,
  536. RK3399_CLKSEL_CON(29), 7, 1, MFLAGS, 0, 7, DFLAGS,
  537. RK3399_CLKGATE_CON(8), 6, GFLAGS),
  538. COMPOSITE_FRACMUX(0, "clk_i2s1_frac", "clk_i2s1_div", 0,
  539. RK3399_CLKSEL_CON(97), 0,
  540. RK3399_CLKGATE_CON(8), 7, GFLAGS,
  541. &rk3399_i2s1_fracmux),
  542. GATE(SCLK_I2S1_8CH, "clk_i2s1", "clk_i2s1_mux", CLK_SET_RATE_PARENT,
  543. RK3399_CLKGATE_CON(8), 8, GFLAGS),
  544. COMPOSITE(0, "clk_i2s2_div", mux_pll_src_cpll_gpll_p, 0,
  545. RK3399_CLKSEL_CON(30), 7, 1, MFLAGS, 0, 7, DFLAGS,
  546. RK3399_CLKGATE_CON(8), 9, GFLAGS),
  547. COMPOSITE_FRACMUX(0, "clk_i2s2_frac", "clk_i2s2_div", 0,
  548. RK3399_CLKSEL_CON(98), 0,
  549. RK3399_CLKGATE_CON(8), 10, GFLAGS,
  550. &rk3399_i2s2_fracmux),
  551. GATE(SCLK_I2S2_8CH, "clk_i2s2", "clk_i2s2_mux", CLK_SET_RATE_PARENT,
  552. RK3399_CLKGATE_CON(8), 11, GFLAGS),
  553. MUX(0, "clk_i2sout_src", mux_i2sch_p, CLK_SET_RATE_PARENT,
  554. RK3399_CLKSEL_CON(31), 0, 2, MFLAGS),
  555. COMPOSITE_NODIV(SCLK_I2S_8CH_OUT, "clk_i2sout", mux_i2sout_p, CLK_SET_RATE_PARENT,
  556. RK3399_CLKSEL_CON(30), 8, 2, MFLAGS,
  557. RK3399_CLKGATE_CON(8), 12, GFLAGS),
  558. /* uart */
  559. MUX(0, "clk_uart0_src", mux_pll_src_cpll_gpll_upll_p, 0,
  560. RK3399_CLKSEL_CON(33), 12, 2, MFLAGS),
  561. COMPOSITE_NOMUX(0, "clk_uart0_div", "clk_uart0_src", 0,
  562. RK3399_CLKSEL_CON(33), 0, 7, DFLAGS,
  563. RK3399_CLKGATE_CON(9), 0, GFLAGS),
  564. COMPOSITE_FRACMUX(0, "clk_uart0_frac", "clk_uart0_div", 0,
  565. RK3399_CLKSEL_CON(100), 0,
  566. RK3399_CLKGATE_CON(9), 1, GFLAGS,
  567. &rk3399_uart0_fracmux),
  568. MUX(0, "clk_uart_src", mux_pll_src_cpll_gpll_p, 0,
  569. RK3399_CLKSEL_CON(33), 15, 1, MFLAGS),
  570. COMPOSITE_NOMUX(0, "clk_uart1_div", "clk_uart_src", 0,
  571. RK3399_CLKSEL_CON(34), 0, 7, DFLAGS,
  572. RK3399_CLKGATE_CON(9), 2, GFLAGS),
  573. COMPOSITE_FRACMUX(0, "clk_uart1_frac", "clk_uart1_div", 0,
  574. RK3399_CLKSEL_CON(101), 0,
  575. RK3399_CLKGATE_CON(9), 3, GFLAGS,
  576. &rk3399_uart1_fracmux),
  577. COMPOSITE_NOMUX(0, "clk_uart2_div", "clk_uart_src", 0,
  578. RK3399_CLKSEL_CON(35), 0, 7, DFLAGS,
  579. RK3399_CLKGATE_CON(9), 4, GFLAGS),
  580. COMPOSITE_FRACMUX(0, "clk_uart2_frac", "clk_uart2_div", 0,
  581. RK3399_CLKSEL_CON(102), 0,
  582. RK3399_CLKGATE_CON(9), 5, GFLAGS,
  583. &rk3399_uart2_fracmux),
  584. COMPOSITE_NOMUX(0, "clk_uart3_div", "clk_uart_src", 0,
  585. RK3399_CLKSEL_CON(36), 0, 7, DFLAGS,
  586. RK3399_CLKGATE_CON(9), 6, GFLAGS),
  587. COMPOSITE_FRACMUX(0, "clk_uart3_frac", "clk_uart3_div", 0,
  588. RK3399_CLKSEL_CON(103), 0,
  589. RK3399_CLKGATE_CON(9), 7, GFLAGS,
  590. &rk3399_uart3_fracmux),
  591. COMPOSITE(0, "pclk_ddr", mux_pll_src_cpll_gpll_p, CLK_IGNORE_UNUSED,
  592. RK3399_CLKSEL_CON(6), 15, 1, MFLAGS, 8, 5, DFLAGS,
  593. RK3399_CLKGATE_CON(3), 4, GFLAGS),
  594. GATE(PCLK_CENTER_MAIN_NOC, "pclk_center_main_noc", "pclk_ddr", CLK_IGNORE_UNUSED,
  595. RK3399_CLKGATE_CON(18), 10, GFLAGS),
  596. GATE(PCLK_DDR_MON, "pclk_ddr_mon", "pclk_ddr", CLK_IGNORE_UNUSED,
  597. RK3399_CLKGATE_CON(18), 12, GFLAGS),
  598. GATE(PCLK_CIC, "pclk_cic", "pclk_ddr", CLK_IGNORE_UNUSED,
  599. RK3399_CLKGATE_CON(18), 15, GFLAGS),
  600. GATE(PCLK_DDR_SGRF, "pclk_ddr_sgrf", "pclk_ddr", CLK_IGNORE_UNUSED,
  601. RK3399_CLKGATE_CON(19), 2, GFLAGS),
  602. GATE(SCLK_PVTM_DDR, "clk_pvtm_ddr", "xin24m", CLK_IGNORE_UNUSED,
  603. RK3399_CLKGATE_CON(4), 11, GFLAGS),
  604. GATE(SCLK_DFIMON0_TIMER, "clk_dfimon0_timer", "xin24m", CLK_IGNORE_UNUSED,
  605. RK3399_CLKGATE_CON(3), 5, GFLAGS),
  606. GATE(SCLK_DFIMON1_TIMER, "clk_dfimon1_timer", "xin24m", CLK_IGNORE_UNUSED,
  607. RK3399_CLKGATE_CON(3), 6, GFLAGS),
  608. /* cci */
  609. GATE(0, "cpll_aclk_cci_src", "cpll", CLK_IGNORE_UNUSED,
  610. RK3399_CLKGATE_CON(2), 0, GFLAGS),
  611. GATE(0, "gpll_aclk_cci_src", "gpll", CLK_IGNORE_UNUSED,
  612. RK3399_CLKGATE_CON(2), 1, GFLAGS),
  613. GATE(0, "npll_aclk_cci_src", "npll", CLK_IGNORE_UNUSED,
  614. RK3399_CLKGATE_CON(2), 2, GFLAGS),
  615. GATE(0, "vpll_aclk_cci_src", "vpll", CLK_IGNORE_UNUSED,
  616. RK3399_CLKGATE_CON(2), 3, GFLAGS),
  617. COMPOSITE(0, "aclk_cci_pre", mux_aclk_cci_p, CLK_IGNORE_UNUSED,
  618. RK3399_CLKSEL_CON(5), 6, 2, MFLAGS, 0, 5, DFLAGS,
  619. RK3399_CLKGATE_CON(2), 4, GFLAGS),
  620. GATE(ACLK_ADB400M_PD_CORE_L, "aclk_adb400m_pd_core_l", "aclk_cci_pre", CLK_IGNORE_UNUSED,
  621. RK3399_CLKGATE_CON(15), 0, GFLAGS),
  622. GATE(ACLK_ADB400M_PD_CORE_B, "aclk_adb400m_pd_core_b", "aclk_cci_pre", CLK_IGNORE_UNUSED,
  623. RK3399_CLKGATE_CON(15), 1, GFLAGS),
  624. GATE(ACLK_CCI, "aclk_cci", "aclk_cci_pre", CLK_IGNORE_UNUSED,
  625. RK3399_CLKGATE_CON(15), 2, GFLAGS),
  626. GATE(ACLK_CCI_NOC0, "aclk_cci_noc0", "aclk_cci_pre", CLK_IGNORE_UNUSED,
  627. RK3399_CLKGATE_CON(15), 3, GFLAGS),
  628. GATE(ACLK_CCI_NOC1, "aclk_cci_noc1", "aclk_cci_pre", CLK_IGNORE_UNUSED,
  629. RK3399_CLKGATE_CON(15), 4, GFLAGS),
  630. GATE(ACLK_CCI_GRF, "aclk_cci_grf", "aclk_cci_pre", CLK_IGNORE_UNUSED,
  631. RK3399_CLKGATE_CON(15), 7, GFLAGS),
  632. GATE(0, "cpll_cci_trace", "cpll", CLK_IGNORE_UNUSED,
  633. RK3399_CLKGATE_CON(2), 5, GFLAGS),
  634. GATE(0, "gpll_cci_trace", "gpll", CLK_IGNORE_UNUSED,
  635. RK3399_CLKGATE_CON(2), 6, GFLAGS),
  636. COMPOSITE(SCLK_CCI_TRACE, "clk_cci_trace", mux_cci_trace_p, CLK_IGNORE_UNUSED,
  637. RK3399_CLKSEL_CON(5), 15, 2, MFLAGS, 8, 5, DFLAGS,
  638. RK3399_CLKGATE_CON(2), 7, GFLAGS),
  639. GATE(0, "cpll_cs", "cpll", CLK_IGNORE_UNUSED,
  640. RK3399_CLKGATE_CON(2), 8, GFLAGS),
  641. GATE(0, "gpll_cs", "gpll", CLK_IGNORE_UNUSED,
  642. RK3399_CLKGATE_CON(2), 9, GFLAGS),
  643. GATE(0, "npll_cs", "npll", CLK_IGNORE_UNUSED,
  644. RK3399_CLKGATE_CON(2), 10, GFLAGS),
  645. COMPOSITE_NOGATE(0, "clk_cs", mux_cs_p, CLK_IGNORE_UNUSED,
  646. RK3399_CLKSEL_CON(4), 6, 2, MFLAGS, 0, 5, DFLAGS),
  647. GATE(0, "clk_dbg_cxcs", "clk_cs", CLK_IGNORE_UNUSED,
  648. RK3399_CLKGATE_CON(15), 5, GFLAGS),
  649. GATE(0, "clk_dbg_noc", "clk_cs", CLK_IGNORE_UNUSED,
  650. RK3399_CLKGATE_CON(15), 6, GFLAGS),
  651. /* vcodec */
  652. COMPOSITE(0, "aclk_vcodec_pre", mux_pll_src_cpll_gpll_npll_ppll_p, 0,
  653. RK3399_CLKSEL_CON(7), 6, 2, MFLAGS, 0, 5, DFLAGS,
  654. RK3399_CLKGATE_CON(4), 0, GFLAGS),
  655. COMPOSITE_NOMUX(0, "hclk_vcodec_pre", "aclk_vcodec_pre", 0,
  656. RK3399_CLKSEL_CON(7), 8, 5, DFLAGS,
  657. RK3399_CLKGATE_CON(4), 1, GFLAGS),
  658. GATE(HCLK_VCODEC, "hclk_vcodec", "hclk_vcodec_pre", 0,
  659. RK3399_CLKGATE_CON(17), 2, GFLAGS),
  660. GATE(0, "hclk_vcodec_noc", "hclk_vcodec_pre", CLK_IGNORE_UNUSED,
  661. RK3399_CLKGATE_CON(17), 3, GFLAGS),
  662. GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vcodec_pre", 0,
  663. RK3399_CLKGATE_CON(17), 0, GFLAGS),
  664. GATE(0, "aclk_vcodec_noc", "aclk_vcodec_pre", CLK_IGNORE_UNUSED,
  665. RK3399_CLKGATE_CON(17), 1, GFLAGS),
  666. /* vdu */
  667. COMPOSITE(SCLK_VDU_CORE, "clk_vdu_core", mux_pll_src_cpll_gpll_npll_p, 0,
  668. RK3399_CLKSEL_CON(9), 6, 2, MFLAGS, 0, 5, DFLAGS,
  669. RK3399_CLKGATE_CON(4), 4, GFLAGS),
  670. COMPOSITE(SCLK_VDU_CA, "clk_vdu_ca", mux_pll_src_cpll_gpll_npll_p, 0,
  671. RK3399_CLKSEL_CON(9), 14, 2, MFLAGS, 8, 5, DFLAGS,
  672. RK3399_CLKGATE_CON(4), 5, GFLAGS),
  673. COMPOSITE(0, "aclk_vdu_pre", mux_pll_src_cpll_gpll_npll_ppll_p, 0,
  674. RK3399_CLKSEL_CON(8), 6, 2, MFLAGS, 0, 5, DFLAGS,
  675. RK3399_CLKGATE_CON(4), 2, GFLAGS),
  676. COMPOSITE_NOMUX(0, "hclk_vdu_pre", "aclk_vdu_pre", 0,
  677. RK3399_CLKSEL_CON(8), 8, 5, DFLAGS,
  678. RK3399_CLKGATE_CON(4), 3, GFLAGS),
  679. GATE(HCLK_VDU, "hclk_vdu", "hclk_vdu_pre", 0,
  680. RK3399_CLKGATE_CON(17), 10, GFLAGS),
  681. GATE(HCLK_VDU_NOC, "hclk_vdu_noc", "hclk_vdu_pre", CLK_IGNORE_UNUSED,
  682. RK3399_CLKGATE_CON(17), 11, GFLAGS),
  683. GATE(ACLK_VDU, "aclk_vdu", "aclk_vdu_pre", 0,
  684. RK3399_CLKGATE_CON(17), 8, GFLAGS),
  685. GATE(ACLK_VDU_NOC, "aclk_vdu_noc", "aclk_vdu_pre", CLK_IGNORE_UNUSED,
  686. RK3399_CLKGATE_CON(17), 9, GFLAGS),
  687. /* iep */
  688. COMPOSITE(0, "aclk_iep_pre", mux_pll_src_cpll_gpll_npll_ppll_p, 0,
  689. RK3399_CLKSEL_CON(10), 6, 2, MFLAGS, 0, 5, DFLAGS,
  690. RK3399_CLKGATE_CON(4), 6, GFLAGS),
  691. COMPOSITE_NOMUX(0, "hclk_iep_pre", "aclk_iep_pre", 0,
  692. RK3399_CLKSEL_CON(10), 8, 5, DFLAGS,
  693. RK3399_CLKGATE_CON(4), 7, GFLAGS),
  694. GATE(HCLK_IEP, "hclk_iep", "hclk_iep_pre", 0,
  695. RK3399_CLKGATE_CON(16), 2, GFLAGS),
  696. GATE(HCLK_IEP_NOC, "hclk_iep_noc", "hclk_iep_pre", CLK_IGNORE_UNUSED,
  697. RK3399_CLKGATE_CON(16), 3, GFLAGS),
  698. GATE(ACLK_IEP, "aclk_iep", "aclk_iep_pre", 0,
  699. RK3399_CLKGATE_CON(16), 0, GFLAGS),
  700. GATE(ACLK_IEP_NOC, "aclk_iep_noc", "aclk_iep_pre", CLK_IGNORE_UNUSED,
  701. RK3399_CLKGATE_CON(16), 1, GFLAGS),
  702. /* rga */
  703. COMPOSITE(SCLK_RGA_CORE, "clk_rga_core", mux_pll_src_cpll_gpll_npll_ppll_p, 0,
  704. RK3399_CLKSEL_CON(12), 6, 2, MFLAGS, 0, 5, DFLAGS,
  705. RK3399_CLKGATE_CON(4), 10, GFLAGS),
  706. COMPOSITE(0, "aclk_rga_pre", mux_pll_src_cpll_gpll_npll_ppll_p, 0,
  707. RK3399_CLKSEL_CON(11), 6, 2, MFLAGS, 0, 5, DFLAGS,
  708. RK3399_CLKGATE_CON(4), 8, GFLAGS),
  709. COMPOSITE_NOMUX(0, "hclk_rga_pre", "aclk_rga_pre", 0,
  710. RK3399_CLKSEL_CON(11), 8, 5, DFLAGS,
  711. RK3399_CLKGATE_CON(4), 9, GFLAGS),
  712. GATE(HCLK_RGA, "hclk_rga", "hclk_rga_pre", 0,
  713. RK3399_CLKGATE_CON(16), 10, GFLAGS),
  714. GATE(HCLK_RGA_NOC, "hclk_rga_noc", "hclk_rga_pre", CLK_IGNORE_UNUSED,
  715. RK3399_CLKGATE_CON(16), 11, GFLAGS),
  716. GATE(ACLK_RGA, "aclk_rga", "aclk_rga_pre", 0,
  717. RK3399_CLKGATE_CON(16), 8, GFLAGS),
  718. GATE(ACLK_RGA_NOC, "aclk_rga_noc", "aclk_rga_pre", CLK_IGNORE_UNUSED,
  719. RK3399_CLKGATE_CON(16), 9, GFLAGS),
  720. /* center */
  721. COMPOSITE(0, "aclk_center", mux_pll_src_cpll_gpll_npll_p, CLK_IGNORE_UNUSED,
  722. RK3399_CLKSEL_CON(12), 14, 2, MFLAGS, 8, 5, DFLAGS,
  723. RK3399_CLKGATE_CON(3), 7, GFLAGS),
  724. GATE(ACLK_CENTER_MAIN_NOC, "aclk_center_main_noc", "aclk_center", CLK_IGNORE_UNUSED,
  725. RK3399_CLKGATE_CON(19), 0, GFLAGS),
  726. GATE(ACLK_CENTER_PERI_NOC, "aclk_center_peri_noc", "aclk_center", CLK_IGNORE_UNUSED,
  727. RK3399_CLKGATE_CON(19), 1, GFLAGS),
  728. /* gpu */
  729. COMPOSITE(0, "aclk_gpu_pre", mux_pll_src_ppll_cpll_gpll_npll_p, CLK_IGNORE_UNUSED,
  730. RK3399_CLKSEL_CON(13), 5, 3, MFLAGS, 0, 5, DFLAGS,
  731. RK3399_CLKGATE_CON(13), 0, GFLAGS),
  732. GATE(ACLK_GPU, "aclk_gpu", "aclk_gpu_pre", 0,
  733. RK3399_CLKGATE_CON(30), 8, GFLAGS),
  734. GATE(ACLK_PERF_GPU, "aclk_perf_gpu", "aclk_gpu_pre", 0,
  735. RK3399_CLKGATE_CON(30), 10, GFLAGS),
  736. GATE(ACLK_GPU_GRF, "aclk_gpu_grf", "aclk_gpu_pre", 0,
  737. RK3399_CLKGATE_CON(30), 11, GFLAGS),
  738. GATE(SCLK_PVTM_GPU, "aclk_pvtm_gpu", "xin24m", 0,
  739. RK3399_CLKGATE_CON(13), 1, GFLAGS),
  740. /* perihp */
  741. GATE(0, "cpll_aclk_perihp_src", "cpll", CLK_IGNORE_UNUSED,
  742. RK3399_CLKGATE_CON(5), 1, GFLAGS),
  743. GATE(0, "gpll_aclk_perihp_src", "gpll", CLK_IGNORE_UNUSED,
  744. RK3399_CLKGATE_CON(5), 0, GFLAGS),
  745. COMPOSITE(ACLK_PERIHP, "aclk_perihp", mux_aclk_perihp_p, CLK_IGNORE_UNUSED,
  746. RK3399_CLKSEL_CON(14), 7, 1, MFLAGS, 0, 5, DFLAGS,
  747. RK3399_CLKGATE_CON(5), 2, GFLAGS),
  748. COMPOSITE_NOMUX(HCLK_PERIHP, "hclk_perihp", "aclk_perihp", CLK_IGNORE_UNUSED,
  749. RK3399_CLKSEL_CON(14), 8, 2, DFLAGS,
  750. RK3399_CLKGATE_CON(5), 3, GFLAGS),
  751. COMPOSITE_NOMUX(PCLK_PERIHP, "pclk_perihp", "aclk_perihp", CLK_IGNORE_UNUSED,
  752. RK3399_CLKSEL_CON(14), 12, 2, DFLAGS,
  753. RK3399_CLKGATE_CON(5), 4, GFLAGS),
  754. GATE(ACLK_PERF_PCIE, "aclk_perf_pcie", "aclk_perihp", 0,
  755. RK3399_CLKGATE_CON(20), 2, GFLAGS),
  756. GATE(ACLK_PCIE, "aclk_pcie", "aclk_perihp", 0,
  757. RK3399_CLKGATE_CON(20), 10, GFLAGS),
  758. GATE(0, "aclk_perihp_noc", "aclk_perihp", CLK_IGNORE_UNUSED,
  759. RK3399_CLKGATE_CON(20), 12, GFLAGS),
  760. GATE(HCLK_HOST0, "hclk_host0", "hclk_perihp", 0,
  761. RK3399_CLKGATE_CON(20), 5, GFLAGS),
  762. GATE(HCLK_HOST0_ARB, "hclk_host0_arb", "hclk_perihp", 0,
  763. RK3399_CLKGATE_CON(20), 6, GFLAGS),
  764. GATE(HCLK_HOST1, "hclk_host1", "hclk_perihp", 0,
  765. RK3399_CLKGATE_CON(20), 7, GFLAGS),
  766. GATE(HCLK_HOST1_ARB, "hclk_host1_arb", "hclk_perihp", 0,
  767. RK3399_CLKGATE_CON(20), 8, GFLAGS),
  768. GATE(HCLK_HSIC, "hclk_hsic", "hclk_perihp", 0,
  769. RK3399_CLKGATE_CON(20), 9, GFLAGS),
  770. GATE(0, "hclk_perihp_noc", "hclk_perihp", CLK_IGNORE_UNUSED,
  771. RK3399_CLKGATE_CON(20), 13, GFLAGS),
  772. GATE(0, "hclk_ahb1tom", "hclk_perihp", CLK_IGNORE_UNUSED,
  773. RK3399_CLKGATE_CON(20), 15, GFLAGS),
  774. GATE(PCLK_PERIHP_GRF, "pclk_perihp_grf", "pclk_perihp", CLK_IGNORE_UNUSED,
  775. RK3399_CLKGATE_CON(20), 4, GFLAGS),
  776. GATE(PCLK_PCIE, "pclk_pcie", "pclk_perihp", 0,
  777. RK3399_CLKGATE_CON(20), 11, GFLAGS),
  778. GATE(0, "pclk_perihp_noc", "pclk_perihp", CLK_IGNORE_UNUSED,
  779. RK3399_CLKGATE_CON(20), 14, GFLAGS),
  780. GATE(PCLK_HSICPHY, "pclk_hsicphy", "pclk_perihp", 0,
  781. RK3399_CLKGATE_CON(31), 8, GFLAGS),
  782. /* sdio & sdmmc */
  783. COMPOSITE(0, "hclk_sd", mux_pll_src_cpll_gpll_p, 0,
  784. RK3399_CLKSEL_CON(13), 15, 1, MFLAGS, 8, 5, DFLAGS,
  785. RK3399_CLKGATE_CON(12), 13, GFLAGS),
  786. GATE(HCLK_SDMMC, "hclk_sdmmc", "hclk_sd", 0,
  787. RK3399_CLKGATE_CON(33), 8, GFLAGS),
  788. GATE(0, "hclk_sdmmc_noc", "hclk_sd", CLK_IGNORE_UNUSED,
  789. RK3399_CLKGATE_CON(33), 9, GFLAGS),
  790. COMPOSITE(SCLK_SDIO, "clk_sdio", mux_pll_src_cpll_gpll_npll_ppll_upll_24m_p, 0,
  791. RK3399_CLKSEL_CON(15), 8, 3, MFLAGS, 0, 7, DFLAGS,
  792. RK3399_CLKGATE_CON(6), 0, GFLAGS),
  793. COMPOSITE(SCLK_SDMMC, "clk_sdmmc", mux_pll_src_cpll_gpll_npll_ppll_upll_24m_p, 0,
  794. RK3399_CLKSEL_CON(16), 8, 3, MFLAGS, 0, 7, DFLAGS,
  795. RK3399_CLKGATE_CON(6), 1, GFLAGS),
  796. MMC(SCLK_SDMMC_DRV, "sdmmc_drv", "clk_sdmmc", RK3399_SDMMC_CON0, 1),
  797. MMC(SCLK_SDMMC_SAMPLE, "sdmmc_sample", "clk_sdmmc", RK3399_SDMMC_CON1, 1),
  798. MMC(SCLK_SDIO_DRV, "sdio_drv", "clk_sdio", RK3399_SDIO_CON0, 1),
  799. MMC(SCLK_SDIO_SAMPLE, "sdio_sample", "clk_sdio", RK3399_SDIO_CON1, 1),
  800. /* pcie */
  801. COMPOSITE(SCLK_PCIE_PM, "clk_pcie_pm", mux_pll_src_cpll_gpll_npll_24m_p, 0,
  802. RK3399_CLKSEL_CON(17), 8, 3, MFLAGS, 0, 7, DFLAGS,
  803. RK3399_CLKGATE_CON(6), 2, GFLAGS),
  804. COMPOSITE_NOMUX(SCLK_PCIEPHY_REF100M, "clk_pciephy_ref100m", "npll", 0,
  805. RK3399_CLKSEL_CON(18), 11, 5, DFLAGS,
  806. RK3399_CLKGATE_CON(12), 6, GFLAGS),
  807. MUX(SCLK_PCIEPHY_REF, "clk_pciephy_ref", mux_pll_src_24m_pciephy_p, CLK_SET_RATE_PARENT,
  808. RK3399_CLKSEL_CON(18), 10, 1, MFLAGS),
  809. COMPOSITE(0, "clk_pcie_core_cru", mux_pll_src_cpll_gpll_npll_p, 0,
  810. RK3399_CLKSEL_CON(18), 8, 2, MFLAGS, 0, 7, DFLAGS,
  811. RK3399_CLKGATE_CON(6), 3, GFLAGS),
  812. MUX(SCLK_PCIE_CORE, "clk_pcie_core", mux_pciecore_cru_phy_p, CLK_SET_RATE_PARENT,
  813. RK3399_CLKSEL_CON(18), 7, 1, MFLAGS),
  814. /* emmc */
  815. COMPOSITE(SCLK_EMMC, "clk_emmc", mux_pll_src_cpll_gpll_npll_upll_24m_p, 0,
  816. RK3399_CLKSEL_CON(22), 8, 3, MFLAGS, 0, 7, DFLAGS,
  817. RK3399_CLKGATE_CON(6), 14, GFLAGS),
  818. GATE(0, "cpll_aclk_emmc_src", "cpll", CLK_IGNORE_UNUSED,
  819. RK3399_CLKGATE_CON(6), 13, GFLAGS),
  820. GATE(0, "gpll_aclk_emmc_src", "gpll", CLK_IGNORE_UNUSED,
  821. RK3399_CLKGATE_CON(6), 12, GFLAGS),
  822. COMPOSITE_NOGATE(ACLK_EMMC, "aclk_emmc", mux_aclk_emmc_p, CLK_IGNORE_UNUSED,
  823. RK3399_CLKSEL_CON(21), 7, 1, MFLAGS, 0, 5, DFLAGS),
  824. GATE(ACLK_EMMC_CORE, "aclk_emmccore", "aclk_emmc", CLK_IGNORE_UNUSED,
  825. RK3399_CLKGATE_CON(32), 8, GFLAGS),
  826. GATE(ACLK_EMMC_NOC, "aclk_emmc_noc", "aclk_emmc", CLK_IGNORE_UNUSED,
  827. RK3399_CLKGATE_CON(32), 9, GFLAGS),
  828. GATE(ACLK_EMMC_GRF, "aclk_emmcgrf", "aclk_emmc", CLK_IGNORE_UNUSED,
  829. RK3399_CLKGATE_CON(32), 10, GFLAGS),
  830. /* perilp0 */
  831. GATE(0, "cpll_aclk_perilp0_src", "cpll", CLK_IGNORE_UNUSED,
  832. RK3399_CLKGATE_CON(7), 1, GFLAGS),
  833. GATE(0, "gpll_aclk_perilp0_src", "gpll", CLK_IGNORE_UNUSED,
  834. RK3399_CLKGATE_CON(7), 0, GFLAGS),
  835. COMPOSITE(ACLK_PERILP0, "aclk_perilp0", mux_aclk_perilp0_p, CLK_IGNORE_UNUSED,
  836. RK3399_CLKSEL_CON(23), 7, 1, MFLAGS, 0, 5, DFLAGS,
  837. RK3399_CLKGATE_CON(7), 2, GFLAGS),
  838. COMPOSITE_NOMUX(HCLK_PERILP0, "hclk_perilp0", "aclk_perilp0", CLK_IGNORE_UNUSED,
  839. RK3399_CLKSEL_CON(23), 8, 2, DFLAGS,
  840. RK3399_CLKGATE_CON(7), 3, GFLAGS),
  841. COMPOSITE_NOMUX(PCLK_PERILP0, "pclk_perilp0", "aclk_perilp0", 0,
  842. RK3399_CLKSEL_CON(23), 12, 3, DFLAGS,
  843. RK3399_CLKGATE_CON(7), 4, GFLAGS),
  844. /* aclk_perilp0 gates */
  845. GATE(ACLK_INTMEM, "aclk_intmem", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 0, GFLAGS),
  846. GATE(ACLK_TZMA, "aclk_tzma", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 1, GFLAGS),
  847. GATE(SCLK_INTMEM0, "clk_intmem0", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 2, GFLAGS),
  848. GATE(SCLK_INTMEM1, "clk_intmem1", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 3, GFLAGS),
  849. GATE(SCLK_INTMEM2, "clk_intmem2", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 4, GFLAGS),
  850. GATE(SCLK_INTMEM3, "clk_intmem3", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 5, GFLAGS),
  851. GATE(SCLK_INTMEM4, "clk_intmem4", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 6, GFLAGS),
  852. GATE(SCLK_INTMEM5, "clk_intmem5", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 7, GFLAGS),
  853. GATE(ACLK_DCF, "aclk_dcf", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 8, GFLAGS),
  854. GATE(ACLK_DMAC0_PERILP, "aclk_dmac0_perilp", "aclk_perilp0", 0, RK3399_CLKGATE_CON(25), 5, GFLAGS),
  855. GATE(ACLK_DMAC1_PERILP, "aclk_dmac1_perilp", "aclk_perilp0", 0, RK3399_CLKGATE_CON(25), 6, GFLAGS),
  856. GATE(ACLK_PERILP0_NOC, "aclk_perilp0_noc", "aclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(25), 7, GFLAGS),
  857. /* hclk_perilp0 gates */
  858. GATE(HCLK_ROM, "hclk_rom", "hclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(24), 4, GFLAGS),
  859. GATE(HCLK_M_CRYPTO0, "hclk_m_crypto0", "hclk_perilp0", 0, RK3399_CLKGATE_CON(24), 5, GFLAGS),
  860. GATE(HCLK_S_CRYPTO0, "hclk_s_crypto0", "hclk_perilp0", 0, RK3399_CLKGATE_CON(24), 6, GFLAGS),
  861. GATE(HCLK_M_CRYPTO1, "hclk_m_crypto1", "hclk_perilp0", 0, RK3399_CLKGATE_CON(24), 14, GFLAGS),
  862. GATE(HCLK_S_CRYPTO1, "hclk_s_crypto1", "hclk_perilp0", 0, RK3399_CLKGATE_CON(24), 15, GFLAGS),
  863. GATE(HCLK_PERILP0_NOC, "hclk_perilp0_noc", "hclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(25), 8, GFLAGS),
  864. /* pclk_perilp0 gates */
  865. GATE(PCLK_DCF, "pclk_dcf", "pclk_perilp0", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(23), 9, GFLAGS),
  866. /* crypto */
  867. COMPOSITE(SCLK_CRYPTO0, "clk_crypto0", mux_pll_src_cpll_gpll_ppll_p, 0,
  868. RK3399_CLKSEL_CON(24), 6, 2, MFLAGS, 0, 5, DFLAGS,
  869. RK3399_CLKGATE_CON(7), 7, GFLAGS),
  870. COMPOSITE(SCLK_CRYPTO1, "clk_crypto1", mux_pll_src_cpll_gpll_ppll_p, 0,
  871. RK3399_CLKSEL_CON(26), 6, 2, MFLAGS, 0, 5, DFLAGS,
  872. RK3399_CLKGATE_CON(7), 8, GFLAGS),
  873. /* cm0s_perilp */
  874. GATE(0, "cpll_fclk_cm0s_src", "cpll", 0,
  875. RK3399_CLKGATE_CON(7), 6, GFLAGS),
  876. GATE(0, "gpll_fclk_cm0s_src", "gpll", 0,
  877. RK3399_CLKGATE_CON(7), 5, GFLAGS),
  878. COMPOSITE(FCLK_CM0S, "fclk_cm0s", mux_fclk_cm0s_p, 0,
  879. RK3399_CLKSEL_CON(24), 15, 1, MFLAGS, 8, 5, DFLAGS,
  880. RK3399_CLKGATE_CON(7), 9, GFLAGS),
  881. /* fclk_cm0s gates */
  882. GATE(SCLK_M0_PERILP, "sclk_m0_perilp", "fclk_cm0s", 0, RK3399_CLKGATE_CON(24), 8, GFLAGS),
  883. GATE(HCLK_M0_PERILP, "hclk_m0_perilp", "fclk_cm0s", 0, RK3399_CLKGATE_CON(24), 9, GFLAGS),
  884. GATE(DCLK_M0_PERILP, "dclk_m0_perilp", "fclk_cm0s", 0, RK3399_CLKGATE_CON(24), 10, GFLAGS),
  885. GATE(SCLK_M0_PERILP_DEC, "clk_m0_perilp_dec", "fclk_cm0s", 0, RK3399_CLKGATE_CON(24), 11, GFLAGS),
  886. GATE(HCLK_M0_PERILP_NOC, "hclk_m0_perilp_noc", "fclk_cm0s", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(25), 11, GFLAGS),
  887. /* perilp1 */
  888. GATE(0, "cpll_hclk_perilp1_src", "cpll", CLK_IGNORE_UNUSED,
  889. RK3399_CLKGATE_CON(8), 1, GFLAGS),
  890. GATE(0, "gpll_hclk_perilp1_src", "gpll", CLK_IGNORE_UNUSED,
  891. RK3399_CLKGATE_CON(8), 0, GFLAGS),
  892. COMPOSITE_NOGATE(HCLK_PERILP1, "hclk_perilp1", mux_hclk_perilp1_p, CLK_IGNORE_UNUSED,
  893. RK3399_CLKSEL_CON(25), 7, 1, MFLAGS, 0, 5, DFLAGS),
  894. COMPOSITE_NOMUX(PCLK_PERILP1, "pclk_perilp1", "hclk_perilp1", CLK_IGNORE_UNUSED,
  895. RK3399_CLKSEL_CON(25), 8, 3, DFLAGS,
  896. RK3399_CLKGATE_CON(8), 2, GFLAGS),
  897. /* hclk_perilp1 gates */
  898. GATE(0, "hclk_perilp1_noc", "hclk_perilp1", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(25), 9, GFLAGS),
  899. GATE(0, "hclk_sdio_noc", "hclk_perilp1", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(25), 12, GFLAGS),
  900. GATE(HCLK_I2S0_8CH, "hclk_i2s0", "hclk_perilp1", 0, RK3399_CLKGATE_CON(34), 0, GFLAGS),
  901. GATE(HCLK_I2S1_8CH, "hclk_i2s1", "hclk_perilp1", 0, RK3399_CLKGATE_CON(34), 1, GFLAGS),
  902. GATE(HCLK_I2S2_8CH, "hclk_i2s2", "hclk_perilp1", 0, RK3399_CLKGATE_CON(34), 2, GFLAGS),
  903. GATE(HCLK_SPDIF, "hclk_spdif", "hclk_perilp1", 0, RK3399_CLKGATE_CON(34), 3, GFLAGS),
  904. GATE(HCLK_SDIO, "hclk_sdio", "hclk_perilp1", 0, RK3399_CLKGATE_CON(34), 4, GFLAGS),
  905. GATE(PCLK_SPI5, "pclk_spi5", "hclk_perilp1", 0, RK3399_CLKGATE_CON(34), 5, GFLAGS),
  906. GATE(0, "hclk_sdioaudio_noc", "hclk_perilp1", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(34), 6, GFLAGS),
  907. /* pclk_perilp1 gates */
  908. GATE(PCLK_UART0, "pclk_uart0", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 0, GFLAGS),
  909. GATE(PCLK_UART1, "pclk_uart1", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 1, GFLAGS),
  910. GATE(PCLK_UART2, "pclk_uart2", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 2, GFLAGS),
  911. GATE(PCLK_UART3, "pclk_uart3", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 3, GFLAGS),
  912. GATE(PCLK_I2C7, "pclk_rki2c7", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 5, GFLAGS),
  913. GATE(PCLK_I2C1, "pclk_rki2c1", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 6, GFLAGS),
  914. GATE(PCLK_I2C5, "pclk_rki2c5", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 7, GFLAGS),
  915. GATE(PCLK_I2C6, "pclk_rki2c6", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 8, GFLAGS),
  916. GATE(PCLK_I2C2, "pclk_rki2c2", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 9, GFLAGS),
  917. GATE(PCLK_I2C3, "pclk_rki2c3", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 10, GFLAGS),
  918. GATE(PCLK_MAILBOX0, "pclk_mailbox0", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 11, GFLAGS),
  919. GATE(PCLK_SARADC, "pclk_saradc", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 12, GFLAGS),
  920. GATE(PCLK_TSADC, "pclk_tsadc", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 13, GFLAGS),
  921. GATE(PCLK_EFUSE1024NS, "pclk_efuse1024ns", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 14, GFLAGS),
  922. GATE(PCLK_EFUSE1024S, "pclk_efuse1024s", "pclk_perilp1", 0, RK3399_CLKGATE_CON(22), 15, GFLAGS),
  923. GATE(PCLK_SPI0, "pclk_spi0", "pclk_perilp1", 0, RK3399_CLKGATE_CON(23), 10, GFLAGS),
  924. GATE(PCLK_SPI1, "pclk_spi1", "pclk_perilp1", 0, RK3399_CLKGATE_CON(23), 11, GFLAGS),
  925. GATE(PCLK_SPI2, "pclk_spi2", "pclk_perilp1", 0, RK3399_CLKGATE_CON(23), 12, GFLAGS),
  926. GATE(PCLK_SPI4, "pclk_spi4", "pclk_perilp1", 0, RK3399_CLKGATE_CON(23), 13, GFLAGS),
  927. GATE(PCLK_PERIHP_GRF, "pclk_perilp_sgrf", "pclk_perilp1", 0, RK3399_CLKGATE_CON(24), 13, GFLAGS),
  928. GATE(0, "pclk_perilp1_noc", "pclk_perilp1", 0, RK3399_CLKGATE_CON(25), 10, GFLAGS),
  929. /* saradc */
  930. COMPOSITE_NOMUX(SCLK_SARADC, "clk_saradc", "xin24m", 0,
  931. RK3399_CLKSEL_CON(26), 8, 8, DFLAGS,
  932. RK3399_CLKGATE_CON(9), 11, GFLAGS),
  933. /* tsadc */
  934. COMPOSITE(SCLK_TSADC, "clk_tsadc", mux_pll_p, 0,
  935. RK3399_CLKSEL_CON(27), 15, 1, MFLAGS, 0, 10, DFLAGS,
  936. RK3399_CLKGATE_CON(9), 10, GFLAGS),
  937. /* cif_testout */
  938. MUX(0, "clk_testout1_pll_src", mux_pll_src_cpll_gpll_npll_p, 0,
  939. RK3399_CLKSEL_CON(38), 6, 2, MFLAGS),
  940. COMPOSITE(0, "clk_testout1", mux_clk_testout1_p, 0,
  941. RK3399_CLKSEL_CON(38), 5, 1, MFLAGS, 0, 5, DFLAGS,
  942. RK3399_CLKGATE_CON(13), 14, GFLAGS),
  943. MUX(0, "clk_testout2_pll_src", mux_pll_src_cpll_gpll_npll_p, 0,
  944. RK3399_CLKSEL_CON(38), 14, 2, MFLAGS),
  945. COMPOSITE(0, "clk_testout2", mux_clk_testout2_p, 0,
  946. RK3399_CLKSEL_CON(38), 13, 1, MFLAGS, 8, 5, DFLAGS,
  947. RK3399_CLKGATE_CON(13), 15, GFLAGS),
  948. /* vio */
  949. COMPOSITE(ACLK_VIO, "aclk_vio", mux_pll_src_cpll_gpll_ppll_p, CLK_IGNORE_UNUSED,
  950. RK3399_CLKSEL_CON(42), 6, 2, MFLAGS, 0, 5, DFLAGS,
  951. RK3399_CLKGATE_CON(11), 0, GFLAGS),
  952. COMPOSITE_NOMUX(PCLK_VIO, "pclk_vio", "aclk_vio", 0,
  953. RK3399_CLKSEL_CON(43), 0, 5, DFLAGS,
  954. RK3399_CLKGATE_CON(11), 1, GFLAGS),
  955. GATE(ACLK_VIO_NOC, "aclk_vio_noc", "aclk_vio", CLK_IGNORE_UNUSED,
  956. RK3399_CLKGATE_CON(29), 0, GFLAGS),
  957. GATE(PCLK_MIPI_DSI0, "pclk_mipi_dsi0", "pclk_vio", 0,
  958. RK3399_CLKGATE_CON(29), 1, GFLAGS),
  959. GATE(PCLK_MIPI_DSI1, "pclk_mipi_dsi1", "pclk_vio", 0,
  960. RK3399_CLKGATE_CON(29), 2, GFLAGS),
  961. GATE(PCLK_VIO_GRF, "pclk_vio_grf", "pclk_vio", CLK_IGNORE_UNUSED,
  962. RK3399_CLKGATE_CON(29), 12, GFLAGS),
  963. /* hdcp */
  964. COMPOSITE(ACLK_HDCP, "aclk_hdcp", mux_pll_src_cpll_gpll_ppll_p, 0,
  965. RK3399_CLKSEL_CON(42), 14, 2, MFLAGS, 8, 5, DFLAGS,
  966. RK3399_CLKGATE_CON(11), 12, GFLAGS),
  967. COMPOSITE_NOMUX(HCLK_HDCP, "hclk_hdcp", "aclk_hdcp", 0,
  968. RK3399_CLKSEL_CON(43), 5, 5, DFLAGS,
  969. RK3399_CLKGATE_CON(11), 3, GFLAGS),
  970. COMPOSITE_NOMUX(PCLK_HDCP, "pclk_hdcp", "aclk_hdcp", 0,
  971. RK3399_CLKSEL_CON(43), 10, 5, DFLAGS,
  972. RK3399_CLKGATE_CON(11), 10, GFLAGS),
  973. GATE(ACLK_HDCP_NOC, "aclk_hdcp_noc", "aclk_hdcp", CLK_IGNORE_UNUSED,
  974. RK3399_CLKGATE_CON(29), 4, GFLAGS),
  975. GATE(ACLK_HDCP22, "aclk_hdcp22", "aclk_hdcp", 0,
  976. RK3399_CLKGATE_CON(29), 10, GFLAGS),
  977. GATE(HCLK_HDCP_NOC, "hclk_hdcp_noc", "hclk_hdcp", CLK_IGNORE_UNUSED,
  978. RK3399_CLKGATE_CON(29), 5, GFLAGS),
  979. GATE(HCLK_HDCP22, "hclk_hdcp22", "hclk_hdcp", 0,
  980. RK3399_CLKGATE_CON(29), 9, GFLAGS),
  981. GATE(PCLK_HDCP_NOC, "pclk_hdcp_noc", "pclk_hdcp", CLK_IGNORE_UNUSED,
  982. RK3399_CLKGATE_CON(29), 3, GFLAGS),
  983. GATE(PCLK_HDMI_CTRL, "pclk_hdmi_ctrl", "pclk_hdcp", 0,
  984. RK3399_CLKGATE_CON(29), 6, GFLAGS),
  985. GATE(PCLK_DP_CTRL, "pclk_dp_ctrl", "pclk_hdcp", 0,
  986. RK3399_CLKGATE_CON(29), 7, GFLAGS),
  987. GATE(PCLK_HDCP22, "pclk_hdcp22", "pclk_hdcp", 0,
  988. RK3399_CLKGATE_CON(29), 8, GFLAGS),
  989. GATE(PCLK_GASKET, "pclk_gasket", "pclk_hdcp", 0,
  990. RK3399_CLKGATE_CON(29), 11, GFLAGS),
  991. /* edp */
  992. COMPOSITE(SCLK_DP_CORE, "clk_dp_core", mux_pll_src_npll_cpll_gpll_p, 0,
  993. RK3399_CLKSEL_CON(46), 6, 2, MFLAGS, 0, 5, DFLAGS,
  994. RK3399_CLKGATE_CON(11), 8, GFLAGS),
  995. COMPOSITE(PCLK_EDP, "pclk_edp", mux_pll_src_cpll_gpll_p, 0,
  996. RK3399_CLKSEL_CON(44), 15, 1, MFLAGS, 8, 5, DFLAGS,
  997. RK3399_CLKGATE_CON(11), 11, GFLAGS),
  998. GATE(PCLK_EDP_NOC, "pclk_edp_noc", "pclk_edp", CLK_IGNORE_UNUSED,
  999. RK3399_CLKGATE_CON(32), 12, GFLAGS),
  1000. GATE(PCLK_EDP_CTRL, "pclk_edp_ctrl", "pclk_edp", 0,
  1001. RK3399_CLKGATE_CON(32), 13, GFLAGS),
  1002. /* hdmi */
  1003. GATE(SCLK_HDMI_SFR, "clk_hdmi_sfr", "xin24m", 0,
  1004. RK3399_CLKGATE_CON(11), 6, GFLAGS),
  1005. COMPOSITE(SCLK_HDMI_CEC, "clk_hdmi_cec", mux_pll_p, 0,
  1006. RK3399_CLKSEL_CON(45), 15, 1, MFLAGS, 0, 10, DFLAGS,
  1007. RK3399_CLKGATE_CON(11), 7, GFLAGS),
  1008. /* vop0 */
  1009. COMPOSITE(ACLK_VOP0_PRE, "aclk_vop0_pre", mux_pll_src_vpll_cpll_gpll_npll_p, 0,
  1010. RK3399_CLKSEL_CON(47), 6, 2, MFLAGS, 0, 5, DFLAGS,
  1011. RK3399_CLKGATE_CON(10), 8, GFLAGS),
  1012. COMPOSITE_NOMUX(0, "hclk_vop0_pre", "aclk_vop0_pre", 0,
  1013. RK3399_CLKSEL_CON(47), 8, 5, DFLAGS,
  1014. RK3399_CLKGATE_CON(10), 9, GFLAGS),
  1015. GATE(ACLK_VOP0, "aclk_vop0", "aclk_vop0_pre", 0,
  1016. RK3399_CLKGATE_CON(28), 3, GFLAGS),
  1017. GATE(ACLK_VOP0_NOC, "aclk_vop0_noc", "aclk_vop0_pre", CLK_IGNORE_UNUSED,
  1018. RK3399_CLKGATE_CON(28), 1, GFLAGS),
  1019. GATE(HCLK_VOP0, "hclk_vop0", "hclk_vop0_pre", 0,
  1020. RK3399_CLKGATE_CON(28), 2, GFLAGS),
  1021. GATE(HCLK_VOP0_NOC, "hclk_vop0_noc", "hclk_vop0_pre", CLK_IGNORE_UNUSED,
  1022. RK3399_CLKGATE_CON(28), 0, GFLAGS),
  1023. COMPOSITE(DCLK_VOP0_DIV, "dclk_vop0_div", mux_pll_src_vpll_cpll_gpll_p, 0,
  1024. RK3399_CLKSEL_CON(49), 8, 2, MFLAGS, 0, 8, DFLAGS,
  1025. RK3399_CLKGATE_CON(10), 12, GFLAGS),
  1026. COMPOSITE_FRACMUX_NOGATE(DCLK_VOP0_FRAC, "dclk_vop0_frac", "dclk_vop0_div", 0,
  1027. RK3399_CLKSEL_CON(106), 0,
  1028. &rk3399_dclk_vop0_fracmux),
  1029. COMPOSITE(SCLK_VOP0_PWM, "clk_vop0_pwm", mux_pll_src_vpll_cpll_gpll_24m_p, 0,
  1030. RK3399_CLKSEL_CON(51), 6, 2, MFLAGS, 0, 5, DFLAGS,
  1031. RK3399_CLKGATE_CON(10), 14, GFLAGS),
  1032. /* vop1 */
  1033. COMPOSITE(ACLK_VOP1_PRE, "aclk_vop1_pre", mux_pll_src_vpll_cpll_gpll_npll_p, 0,
  1034. RK3399_CLKSEL_CON(48), 6, 2, MFLAGS, 0, 5, DFLAGS,
  1035. RK3399_CLKGATE_CON(10), 10, GFLAGS),
  1036. COMPOSITE_NOMUX(0, "hclk_vop1_pre", "aclk_vop1_pre", 0,
  1037. RK3399_CLKSEL_CON(48), 8, 5, DFLAGS,
  1038. RK3399_CLKGATE_CON(10), 11, GFLAGS),
  1039. GATE(ACLK_VOP1, "aclk_vop1", "aclk_vop1_pre", 0,
  1040. RK3399_CLKGATE_CON(28), 7, GFLAGS),
  1041. GATE(ACLK_VOP1_NOC, "aclk_vop1_noc", "aclk_vop1_pre", CLK_IGNORE_UNUSED,
  1042. RK3399_CLKGATE_CON(28), 5, GFLAGS),
  1043. GATE(HCLK_VOP1, "hclk_vop1", "hclk_vop1_pre", 0,
  1044. RK3399_CLKGATE_CON(28), 6, GFLAGS),
  1045. GATE(HCLK_VOP1_NOC, "hclk_vop1_noc", "hclk_vop1_pre", CLK_IGNORE_UNUSED,
  1046. RK3399_CLKGATE_CON(28), 4, GFLAGS),
  1047. COMPOSITE(DCLK_VOP1_DIV, "dclk_vop1_div", mux_pll_src_vpll_cpll_gpll_p, 0,
  1048. RK3399_CLKSEL_CON(50), 8, 2, MFLAGS, 0, 8, DFLAGS,
  1049. RK3399_CLKGATE_CON(10), 13, GFLAGS),
  1050. COMPOSITE_FRACMUX_NOGATE(DCLK_VOP1_FRAC, "dclk_vop1_frac", "dclk_vop1_div", 0,
  1051. RK3399_CLKSEL_CON(107), 0,
  1052. &rk3399_dclk_vop1_fracmux),
  1053. COMPOSITE(SCLK_VOP1_PWM, "clk_vop1_pwm", mux_pll_src_vpll_cpll_gpll_24m_p, CLK_IGNORE_UNUSED,
  1054. RK3399_CLKSEL_CON(52), 6, 2, MFLAGS, 0, 5, DFLAGS,
  1055. RK3399_CLKGATE_CON(10), 15, GFLAGS),
  1056. /* isp */
  1057. COMPOSITE(ACLK_ISP0, "aclk_isp0", mux_pll_src_cpll_gpll_ppll_p, 0,
  1058. RK3399_CLKSEL_CON(53), 6, 2, MFLAGS, 0, 5, DFLAGS,
  1059. RK3399_CLKGATE_CON(12), 8, GFLAGS),
  1060. COMPOSITE_NOMUX(HCLK_ISP0, "hclk_isp0", "aclk_isp0", 0,
  1061. RK3399_CLKSEL_CON(53), 8, 5, DFLAGS,
  1062. RK3399_CLKGATE_CON(12), 9, GFLAGS),
  1063. GATE(ACLK_ISP0_NOC, "aclk_isp0_noc", "aclk_isp0", CLK_IGNORE_UNUSED,
  1064. RK3399_CLKGATE_CON(27), 1, GFLAGS),
  1065. GATE(ACLK_ISP0_WRAPPER, "aclk_isp0_wrapper", "aclk_isp0", 0,
  1066. RK3399_CLKGATE_CON(27), 5, GFLAGS),
  1067. GATE(HCLK_ISP1_WRAPPER, "hclk_isp1_wrapper", "aclk_isp0", 0,
  1068. RK3399_CLKGATE_CON(27), 7, GFLAGS),
  1069. GATE(HCLK_ISP0_NOC, "hclk_isp0_noc", "hclk_isp0", CLK_IGNORE_UNUSED,
  1070. RK3399_CLKGATE_CON(27), 0, GFLAGS),
  1071. GATE(HCLK_ISP0_WRAPPER, "hclk_isp0_wrapper", "hclk_isp0", 0,
  1072. RK3399_CLKGATE_CON(27), 4, GFLAGS),
  1073. COMPOSITE(SCLK_ISP0, "clk_isp0", mux_pll_src_cpll_gpll_npll_p, 0,
  1074. RK3399_CLKSEL_CON(55), 6, 2, MFLAGS, 0, 5, DFLAGS,
  1075. RK3399_CLKGATE_CON(11), 4, GFLAGS),
  1076. COMPOSITE(ACLK_ISP1, "aclk_isp1", mux_pll_src_cpll_gpll_ppll_p, 0,
  1077. RK3399_CLKSEL_CON(54), 6, 2, MFLAGS, 0, 5, DFLAGS,
  1078. RK3399_CLKGATE_CON(12), 10, GFLAGS),
  1079. COMPOSITE_NOMUX(HCLK_ISP1, "hclk_isp1", "aclk_isp1", 0,
  1080. RK3399_CLKSEL_CON(54), 8, 5, DFLAGS,
  1081. RK3399_CLKGATE_CON(12), 11, GFLAGS),
  1082. GATE(ACLK_ISP1_NOC, "aclk_isp1_noc", "aclk_isp1", CLK_IGNORE_UNUSED,
  1083. RK3399_CLKGATE_CON(27), 3, GFLAGS),
  1084. GATE(HCLK_ISP1_NOC, "hclk_isp1_noc", "hclk_isp1", CLK_IGNORE_UNUSED,
  1085. RK3399_CLKGATE_CON(27), 2, GFLAGS),
  1086. GATE(ACLK_ISP1_WRAPPER, "aclk_isp1_wrapper", "hclk_isp1", 0,
  1087. RK3399_CLKGATE_CON(27), 8, GFLAGS),
  1088. COMPOSITE(SCLK_ISP1, "clk_isp1", mux_pll_src_cpll_gpll_npll_p, 0,
  1089. RK3399_CLKSEL_CON(55), 14, 2, MFLAGS, 8, 5, DFLAGS,
  1090. RK3399_CLKGATE_CON(11), 5, GFLAGS),
  1091. /*
  1092. * We use pclkin_cifinv by default GRF_SOC_CON20[9] (GSC20_9) setting in system,
  1093. * so we ignore the mux and make clocks nodes as following,
  1094. *
  1095. * pclkin_cifinv --|-------\
  1096. * |GSC20_9|-- pclkin_cifmux -- |G27_6| -- pclkin_isp1_wrapper
  1097. * pclkin_cif --|-------/
  1098. */
  1099. GATE(PCLK_ISP1_WRAPPER, "pclkin_isp1_wrapper", "pclkin_cif", 0,
  1100. RK3399_CLKGATE_CON(27), 6, GFLAGS),
  1101. /* cif */
  1102. COMPOSITE_NODIV(0, "clk_cifout_src", mux_pll_src_cpll_gpll_npll_p, 0,
  1103. RK3399_CLKSEL_CON(56), 6, 2, MFLAGS,
  1104. RK3399_CLKGATE_CON(10), 7, GFLAGS),
  1105. COMPOSITE_NOGATE(SCLK_CIF_OUT, "clk_cifout", mux_clk_cif_p, 0,
  1106. RK3399_CLKSEL_CON(56), 5, 1, MFLAGS, 0, 5, DFLAGS),
  1107. /* gic */
  1108. COMPOSITE(ACLK_GIC_PRE, "aclk_gic_pre", mux_pll_src_cpll_gpll_p, CLK_IGNORE_UNUSED,
  1109. RK3399_CLKSEL_CON(56), 15, 1, MFLAGS, 8, 5, DFLAGS,
  1110. RK3399_CLKGATE_CON(12), 12, GFLAGS),
  1111. GATE(ACLK_GIC, "aclk_gic", "aclk_gic_pre", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(33), 0, GFLAGS),
  1112. GATE(ACLK_GIC_NOC, "aclk_gic_noc", "aclk_gic_pre", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(33), 1, GFLAGS),
  1113. GATE(ACLK_GIC_ADB400_CORE_L_2_GIC, "aclk_gic_adb400_core_l_2_gic", "aclk_gic_pre", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(33), 2, GFLAGS),
  1114. GATE(ACLK_GIC_ADB400_CORE_B_2_GIC, "aclk_gic_adb400_core_b_2_gic", "aclk_gic_pre", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(33), 3, GFLAGS),
  1115. GATE(ACLK_GIC_ADB400_GIC_2_CORE_L, "aclk_gic_adb400_gic_2_core_l", "aclk_gic_pre", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(33), 4, GFLAGS),
  1116. GATE(ACLK_GIC_ADB400_GIC_2_CORE_B, "aclk_gic_adb400_gic_2_core_b", "aclk_gic_pre", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(33), 5, GFLAGS),
  1117. /* alive */
  1118. /* pclk_alive_gpll_src is controlled by PMUGRF_SOC_CON0[6] */
  1119. DIV(PCLK_ALIVE, "pclk_alive", "gpll", 0,
  1120. RK3399_CLKSEL_CON(57), 0, 5, DFLAGS),
  1121. GATE(PCLK_USBPHY_MUX_G, "pclk_usbphy_mux_g", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 4, GFLAGS),
  1122. GATE(PCLK_UPHY0_TCPHY_G, "pclk_uphy0_tcphy_g", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 5, GFLAGS),
  1123. GATE(PCLK_UPHY0_TCPD_G, "pclk_uphy0_tcpd_g", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 6, GFLAGS),
  1124. GATE(PCLK_UPHY1_TCPHY_G, "pclk_uphy1_tcphy_g", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 8, GFLAGS),
  1125. GATE(PCLK_UPHY1_TCPD_G, "pclk_uphy1_tcpd_g", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 9, GFLAGS),
  1126. GATE(PCLK_GRF, "pclk_grf", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(31), 1, GFLAGS),
  1127. GATE(PCLK_INTR_ARB, "pclk_intr_arb", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(31), 2, GFLAGS),
  1128. GATE(PCLK_GPIO2, "pclk_gpio2", "pclk_alive", 0, RK3399_CLKGATE_CON(31), 3, GFLAGS),
  1129. GATE(PCLK_GPIO3, "pclk_gpio3", "pclk_alive", 0, RK3399_CLKGATE_CON(31), 4, GFLAGS),
  1130. GATE(PCLK_GPIO4, "pclk_gpio4", "pclk_alive", 0, RK3399_CLKGATE_CON(31), 5, GFLAGS),
  1131. GATE(PCLK_TIMER0, "pclk_timer0", "pclk_alive", 0, RK3399_CLKGATE_CON(31), 6, GFLAGS),
  1132. GATE(PCLK_TIMER1, "pclk_timer1", "pclk_alive", 0, RK3399_CLKGATE_CON(31), 7, GFLAGS),
  1133. GATE(PCLK_PMU_INTR_ARB, "pclk_pmu_intr_arb", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(31), 9, GFLAGS),
  1134. GATE(PCLK_SGRF, "pclk_sgrf", "pclk_alive", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(31), 10, GFLAGS),
  1135. GATE(SCLK_MIPIDPHY_REF, "clk_mipidphy_ref", "xin24m", 0, RK3399_CLKGATE_CON(11), 14, GFLAGS),
  1136. GATE(SCLK_DPHY_PLL, "clk_dphy_pll", "clk_mipidphy_ref", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 0, GFLAGS),
  1137. GATE(SCLK_MIPIDPHY_CFG, "clk_mipidphy_cfg", "xin24m", 0, RK3399_CLKGATE_CON(11), 15, GFLAGS),
  1138. GATE(SCLK_DPHY_TX0_CFG, "clk_dphy_tx0_cfg", "clk_mipidphy_cfg", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 1, GFLAGS),
  1139. GATE(SCLK_DPHY_TX1RX1_CFG, "clk_dphy_tx1rx1_cfg", "clk_mipidphy_cfg", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 2, GFLAGS),
  1140. GATE(SCLK_DPHY_RX0_CFG, "clk_dphy_rx0_cfg", "clk_mipidphy_cfg", CLK_IGNORE_UNUSED, RK3399_CLKGATE_CON(21), 3, GFLAGS),
  1141. /* testout */
  1142. MUX(0, "clk_test_pre", mux_pll_src_cpll_gpll_p, CLK_SET_RATE_PARENT,
  1143. RK3399_CLKSEL_CON(58), 7, 1, MFLAGS),
  1144. COMPOSITE_FRAC(0, "clk_test_frac", "clk_test_pre", 0,
  1145. RK3399_CLKSEL_CON(105), 0,
  1146. RK3399_CLKGATE_CON(13), 9, GFLAGS),
  1147. DIV(0, "clk_test_24m", "xin24m", 0,
  1148. RK3399_CLKSEL_CON(57), 6, 10, DFLAGS),
  1149. /* spi */
  1150. COMPOSITE(SCLK_SPI0, "clk_spi0", mux_pll_src_cpll_gpll_p, 0,
  1151. RK3399_CLKSEL_CON(59), 7, 1, MFLAGS, 0, 7, DFLAGS,
  1152. RK3399_CLKGATE_CON(9), 12, GFLAGS),
  1153. COMPOSITE(SCLK_SPI1, "clk_spi1", mux_pll_src_cpll_gpll_p, 0,
  1154. RK3399_CLKSEL_CON(59), 15, 1, MFLAGS, 8, 7, DFLAGS,
  1155. RK3399_CLKGATE_CON(9), 13, GFLAGS),
  1156. COMPOSITE(SCLK_SPI2, "clk_spi2", mux_pll_src_cpll_gpll_p, 0,
  1157. RK3399_CLKSEL_CON(60), 7, 1, MFLAGS, 0, 7, DFLAGS,
  1158. RK3399_CLKGATE_CON(9), 14, GFLAGS),
  1159. COMPOSITE(SCLK_SPI4, "clk_spi4", mux_pll_src_cpll_gpll_p, 0,
  1160. RK3399_CLKSEL_CON(60), 15, 1, MFLAGS, 8, 7, DFLAGS,
  1161. RK3399_CLKGATE_CON(9), 15, GFLAGS),
  1162. COMPOSITE(SCLK_SPI5, "clk_spi5", mux_pll_src_cpll_gpll_p, 0,
  1163. RK3399_CLKSEL_CON(58), 15, 1, MFLAGS, 8, 7, DFLAGS,
  1164. RK3399_CLKGATE_CON(13), 13, GFLAGS),
  1165. /* i2c */
  1166. COMPOSITE(SCLK_I2C1, "clk_i2c1", mux_pll_src_cpll_gpll_p, 0,
  1167. RK3399_CLKSEL_CON(61), 7, 1, MFLAGS, 0, 7, DFLAGS,
  1168. RK3399_CLKGATE_CON(10), 0, GFLAGS),
  1169. COMPOSITE(SCLK_I2C2, "clk_i2c2", mux_pll_src_cpll_gpll_p, 0,
  1170. RK3399_CLKSEL_CON(62), 7, 1, MFLAGS, 0, 7, DFLAGS,
  1171. RK3399_CLKGATE_CON(10), 2, GFLAGS),
  1172. COMPOSITE(SCLK_I2C3, "clk_i2c3", mux_pll_src_cpll_gpll_p, 0,
  1173. RK3399_CLKSEL_CON(63), 7, 1, MFLAGS, 0, 7, DFLAGS,
  1174. RK3399_CLKGATE_CON(10), 4, GFLAGS),
  1175. COMPOSITE(SCLK_I2C5, "clk_i2c5", mux_pll_src_cpll_gpll_p, 0,
  1176. RK3399_CLKSEL_CON(61), 15, 1, MFLAGS, 8, 7, DFLAGS,
  1177. RK3399_CLKGATE_CON(10), 1, GFLAGS),
  1178. COMPOSITE(SCLK_I2C6, "clk_i2c6", mux_pll_src_cpll_gpll_p, 0,
  1179. RK3399_CLKSEL_CON(62), 15, 1, MFLAGS, 8, 7, DFLAGS,
  1180. RK3399_CLKGATE_CON(10), 3, GFLAGS),
  1181. COMPOSITE(SCLK_I2C7, "clk_i2c7", mux_pll_src_cpll_gpll_p, 0,
  1182. RK3399_CLKSEL_CON(63), 15, 1, MFLAGS, 8, 7, DFLAGS,
  1183. RK3399_CLKGATE_CON(10), 5, GFLAGS),
  1184. /* timer */
  1185. GATE(SCLK_TIMER00, "clk_timer00", "xin24m", 0, RK3399_CLKGATE_CON(26), 0, GFLAGS),
  1186. GATE(SCLK_TIMER01, "clk_timer01", "xin24m", 0, RK3399_CLKGATE_CON(26), 1, GFLAGS),
  1187. GATE(SCLK_TIMER02, "clk_timer02", "xin24m", 0, RK3399_CLKGATE_CON(26), 2, GFLAGS),
  1188. GATE(SCLK_TIMER03, "clk_timer03", "xin24m", 0, RK3399_CLKGATE_CON(26), 3, GFLAGS),
  1189. GATE(SCLK_TIMER04, "clk_timer04", "xin24m", 0, RK3399_CLKGATE_CON(26), 4, GFLAGS),
  1190. GATE(SCLK_TIMER05, "clk_timer05", "xin24m", 0, RK3399_CLKGATE_CON(26), 5, GFLAGS),
  1191. GATE(SCLK_TIMER06, "clk_timer06", "xin24m", 0, RK3399_CLKGATE_CON(26), 6, GFLAGS),
  1192. GATE(SCLK_TIMER07, "clk_timer07", "xin24m", 0, RK3399_CLKGATE_CON(26), 7, GFLAGS),
  1193. GATE(SCLK_TIMER08, "clk_timer08", "xin24m", 0, RK3399_CLKGATE_CON(26), 8, GFLAGS),
  1194. GATE(SCLK_TIMER09, "clk_timer09", "xin24m", 0, RK3399_CLKGATE_CON(26), 9, GFLAGS),
  1195. GATE(SCLK_TIMER10, "clk_timer10", "xin24m", 0, RK3399_CLKGATE_CON(26), 10, GFLAGS),
  1196. GATE(SCLK_TIMER11, "clk_timer11", "xin24m", 0, RK3399_CLKGATE_CON(26), 11, GFLAGS),
  1197. /* clk_test */
  1198. /* clk_test_pre is controlled by CRU_MISC_CON[3] */
  1199. COMPOSITE_NOMUX(0, "clk_test", "clk_test_pre", CLK_IGNORE_UNUSED,
  1200. RK3368_CLKSEL_CON(58), 0, 5, DFLAGS,
  1201. RK3368_CLKGATE_CON(13), 11, GFLAGS),
  1202. /* ddrc */
  1203. GATE(0, "clk_ddrc_lpll_src", "lpll", 0, RK3399_CLKGATE_CON(3),
  1204. 0, GFLAGS),
  1205. GATE(0, "clk_ddrc_bpll_src", "bpll", 0, RK3399_CLKGATE_CON(3),
  1206. 1, GFLAGS),
  1207. GATE(0, "clk_ddrc_dpll_src", "dpll", 0, RK3399_CLKGATE_CON(3),
  1208. 2, GFLAGS),
  1209. GATE(0, "clk_ddrc_gpll_src", "gpll", 0, RK3399_CLKGATE_CON(3),
  1210. 3, GFLAGS),
  1211. COMPOSITE_DDRCLK(SCLK_DDRC, "sclk_ddrc", mux_ddrclk_p, 0,
  1212. RK3399_CLKSEL_CON(6), 4, 2, 0, 0, ROCKCHIP_DDRCLK_SIP),
  1213. };
  1214. static struct rockchip_clk_branch rk3399_clk_pmu_branches[] __initdata = {
  1215. /*
  1216. * PMU CRU Clock-Architecture
  1217. */
  1218. GATE(0, "fclk_cm0s_pmu_ppll_src", "ppll", 0,
  1219. RK3399_PMU_CLKGATE_CON(0), 1, GFLAGS),
  1220. COMPOSITE_NOGATE(FCLK_CM0S_SRC_PMU, "fclk_cm0s_src_pmu", mux_fclk_cm0s_pmu_ppll_p, 0,
  1221. RK3399_PMU_CLKSEL_CON(0), 15, 1, MFLAGS, 8, 5, DFLAGS),
  1222. COMPOSITE(SCLK_SPI3_PMU, "clk_spi3_pmu", mux_24m_ppll_p, 0,
  1223. RK3399_PMU_CLKSEL_CON(1), 7, 1, MFLAGS, 0, 7, DFLAGS,
  1224. RK3399_PMU_CLKGATE_CON(0), 2, GFLAGS),
  1225. COMPOSITE(0, "clk_wifi_div", mux_ppll_24m_p, CLK_IGNORE_UNUSED,
  1226. RK3399_PMU_CLKSEL_CON(1), 13, 1, MFLAGS, 8, 5, DFLAGS,
  1227. RK3399_PMU_CLKGATE_CON(0), 8, GFLAGS),
  1228. COMPOSITE_FRACMUX_NOGATE(0, "clk_wifi_frac", "clk_wifi_div", 0,
  1229. RK3399_PMU_CLKSEL_CON(7), 0,
  1230. &rk3399_pmuclk_wifi_fracmux),
  1231. MUX(0, "clk_timer_src_pmu", mux_pll_p, CLK_IGNORE_UNUSED,
  1232. RK3399_PMU_CLKSEL_CON(1), 15, 1, MFLAGS),
  1233. COMPOSITE_NOMUX(SCLK_I2C0_PMU, "clk_i2c0_pmu", "ppll", 0,
  1234. RK3399_PMU_CLKSEL_CON(2), 0, 7, DFLAGS,
  1235. RK3399_PMU_CLKGATE_CON(0), 9, GFLAGS),
  1236. COMPOSITE_NOMUX(SCLK_I2C4_PMU, "clk_i2c4_pmu", "ppll", 0,
  1237. RK3399_PMU_CLKSEL_CON(3), 0, 7, DFLAGS,
  1238. RK3399_PMU_CLKGATE_CON(0), 10, GFLAGS),
  1239. COMPOSITE_NOMUX(SCLK_I2C8_PMU, "clk_i2c8_pmu", "ppll", 0,
  1240. RK3399_PMU_CLKSEL_CON(2), 8, 7, DFLAGS,
  1241. RK3399_PMU_CLKGATE_CON(0), 11, GFLAGS),
  1242. DIV(0, "clk_32k_suspend_pmu", "xin24m", CLK_IGNORE_UNUSED,
  1243. RK3399_PMU_CLKSEL_CON(4), 0, 10, DFLAGS),
  1244. MUX(0, "clk_testout_2io", mux_clk_testout2_2io_p, CLK_IGNORE_UNUSED,
  1245. RK3399_PMU_CLKSEL_CON(4), 15, 1, MFLAGS),
  1246. COMPOSITE(0, "clk_uart4_div", mux_24m_ppll_p, 0,
  1247. RK3399_PMU_CLKSEL_CON(5), 10, 1, MFLAGS, 0, 7, DFLAGS,
  1248. RK3399_PMU_CLKGATE_CON(0), 5, GFLAGS),
  1249. COMPOSITE_FRACMUX(0, "clk_uart4_frac", "clk_uart4_div", 0,
  1250. RK3399_PMU_CLKSEL_CON(6), 0,
  1251. RK3399_PMU_CLKGATE_CON(0), 6, GFLAGS,
  1252. &rk3399_uart4_pmu_fracmux),
  1253. DIV(PCLK_SRC_PMU, "pclk_pmu_src", "ppll", CLK_IGNORE_UNUSED,
  1254. RK3399_PMU_CLKSEL_CON(0), 0, 5, DFLAGS),
  1255. /* pmu clock gates */
  1256. GATE(SCLK_TIMER12_PMU, "clk_timer0_pmu", "clk_timer_src_pmu", 0, RK3399_PMU_CLKGATE_CON(0), 3, GFLAGS),
  1257. GATE(SCLK_TIMER13_PMU, "clk_timer1_pmu", "clk_timer_src_pmu", 0, RK3399_PMU_CLKGATE_CON(0), 4, GFLAGS),
  1258. GATE(SCLK_PVTM_PMU, "clk_pvtm_pmu", "xin24m", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(0), 7, GFLAGS),
  1259. GATE(PCLK_PMU, "pclk_pmu", "pclk_pmu_src", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(1), 0, GFLAGS),
  1260. GATE(PCLK_PMUGRF_PMU, "pclk_pmugrf_pmu", "pclk_pmu_src", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(1), 1, GFLAGS),
  1261. GATE(PCLK_INTMEM1_PMU, "pclk_intmem1_pmu", "pclk_pmu_src", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(1), 2, GFLAGS),
  1262. GATE(PCLK_GPIO0_PMU, "pclk_gpio0_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 3, GFLAGS),
  1263. GATE(PCLK_GPIO1_PMU, "pclk_gpio1_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 4, GFLAGS),
  1264. GATE(PCLK_SGRF_PMU, "pclk_sgrf_pmu", "pclk_pmu_src", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(1), 5, GFLAGS),
  1265. GATE(PCLK_NOC_PMU, "pclk_noc_pmu", "pclk_pmu_src", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(1), 6, GFLAGS),
  1266. GATE(PCLK_I2C0_PMU, "pclk_i2c0_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 7, GFLAGS),
  1267. GATE(PCLK_I2C4_PMU, "pclk_i2c4_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 8, GFLAGS),
  1268. GATE(PCLK_I2C8_PMU, "pclk_i2c8_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 9, GFLAGS),
  1269. GATE(PCLK_RKPWM_PMU, "pclk_rkpwm_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 10, GFLAGS),
  1270. GATE(PCLK_SPI3_PMU, "pclk_spi3_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 11, GFLAGS),
  1271. GATE(PCLK_TIMER_PMU, "pclk_timer_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 12, GFLAGS),
  1272. GATE(PCLK_MAILBOX_PMU, "pclk_mailbox_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 13, GFLAGS),
  1273. GATE(PCLK_UART4_PMU, "pclk_uart4_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 14, GFLAGS),
  1274. GATE(PCLK_WDT_M0_PMU, "pclk_wdt_m0_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 15, GFLAGS),
  1275. GATE(FCLK_CM0S_PMU, "fclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 0, GFLAGS),
  1276. GATE(SCLK_CM0S_PMU, "sclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 1, GFLAGS),
  1277. GATE(HCLK_CM0S_PMU, "hclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 2, GFLAGS),
  1278. GATE(DCLK_CM0S_PMU, "dclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 3, GFLAGS),
  1279. GATE(HCLK_NOC_PMU, "hclk_noc_pmu", "fclk_cm0s_src_pmu", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(2), 5, GFLAGS),
  1280. };
  1281. static const char *const rk3399_cru_critical_clocks[] __initconst = {
  1282. "aclk_cci_pre",
  1283. "aclk_gic",
  1284. "aclk_gic_noc",
  1285. "aclk_hdcp_noc",
  1286. "hclk_hdcp_noc",
  1287. "pclk_hdcp_noc",
  1288. "pclk_perilp0",
  1289. "pclk_perilp0",
  1290. "hclk_perilp0",
  1291. "hclk_perilp0_noc",
  1292. "pclk_perilp1",
  1293. "pclk_perilp1_noc",
  1294. "pclk_perihp",
  1295. "pclk_perihp_noc",
  1296. "hclk_perihp",
  1297. "aclk_perihp",
  1298. "aclk_perihp_noc",
  1299. "aclk_perilp0",
  1300. "aclk_perilp0_noc",
  1301. "hclk_perilp1",
  1302. "hclk_perilp1_noc",
  1303. "aclk_dmac0_perilp",
  1304. "aclk_emmc_noc",
  1305. "gpll_hclk_perilp1_src",
  1306. "gpll_aclk_perilp0_src",
  1307. "gpll_aclk_perihp_src",
  1308. "aclk_vio_noc",
  1309. /* ddrc */
  1310. "sclk_ddrc"
  1311. };
  1312. static const char *const rk3399_pmucru_critical_clocks[] __initconst = {
  1313. "ppll",
  1314. "pclk_pmu_src",
  1315. "fclk_cm0s_src_pmu",
  1316. "clk_timer_src_pmu",
  1317. };
  1318. static void __init rk3399_clk_init(struct device_node *np)
  1319. {
  1320. struct rockchip_clk_provider *ctx;
  1321. void __iomem *reg_base;
  1322. struct clk *clk;
  1323. reg_base = of_iomap(np, 0);
  1324. if (!reg_base) {
  1325. pr_err("%s: could not map cru region\n", __func__);
  1326. return;
  1327. }
  1328. ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
  1329. if (IS_ERR(ctx)) {
  1330. pr_err("%s: rockchip clk init failed\n", __func__);
  1331. iounmap(reg_base);
  1332. return;
  1333. }
  1334. /* Watchdog pclk is controlled by RK3399 SECURE_GRF_SOC_CON3[8]. */
  1335. clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_alive", 0, 1, 1);
  1336. if (IS_ERR(clk))
  1337. pr_warn("%s: could not register clock pclk_wdt: %ld\n",
  1338. __func__, PTR_ERR(clk));
  1339. else
  1340. rockchip_clk_add_lookup(ctx, clk, PCLK_WDT);
  1341. rockchip_clk_register_plls(ctx, rk3399_pll_clks,
  1342. ARRAY_SIZE(rk3399_pll_clks), -1);
  1343. rockchip_clk_register_branches(ctx, rk3399_clk_branches,
  1344. ARRAY_SIZE(rk3399_clk_branches));
  1345. rockchip_clk_protect_critical(rk3399_cru_critical_clocks,
  1346. ARRAY_SIZE(rk3399_cru_critical_clocks));
  1347. rockchip_clk_register_armclk(ctx, ARMCLKL, "armclkl",
  1348. mux_armclkl_p, ARRAY_SIZE(mux_armclkl_p),
  1349. &rk3399_cpuclkl_data, rk3399_cpuclkl_rates,
  1350. ARRAY_SIZE(rk3399_cpuclkl_rates));
  1351. rockchip_clk_register_armclk(ctx, ARMCLKB, "armclkb",
  1352. mux_armclkb_p, ARRAY_SIZE(mux_armclkb_p),
  1353. &rk3399_cpuclkb_data, rk3399_cpuclkb_rates,
  1354. ARRAY_SIZE(rk3399_cpuclkb_rates));
  1355. rockchip_register_softrst(np, 21, reg_base + RK3399_SOFTRST_CON(0),
  1356. ROCKCHIP_SOFTRST_HIWORD_MASK);
  1357. rockchip_register_restart_notifier(ctx, RK3399_GLB_SRST_FST, NULL);
  1358. rockchip_clk_of_add_provider(np, ctx);
  1359. }
  1360. CLK_OF_DECLARE(rk3399_cru, "rockchip,rk3399-cru", rk3399_clk_init);
  1361. static void __init rk3399_pmu_clk_init(struct device_node *np)
  1362. {
  1363. struct rockchip_clk_provider *ctx;
  1364. void __iomem *reg_base;
  1365. reg_base = of_iomap(np, 0);
  1366. if (!reg_base) {
  1367. pr_err("%s: could not map cru pmu region\n", __func__);
  1368. return;
  1369. }
  1370. ctx = rockchip_clk_init(np, reg_base, CLKPMU_NR_CLKS);
  1371. if (IS_ERR(ctx)) {
  1372. pr_err("%s: rockchip pmu clk init failed\n", __func__);
  1373. iounmap(reg_base);
  1374. return;
  1375. }
  1376. rockchip_clk_register_plls(ctx, rk3399_pmu_pll_clks,
  1377. ARRAY_SIZE(rk3399_pmu_pll_clks), -1);
  1378. rockchip_clk_register_branches(ctx, rk3399_clk_pmu_branches,
  1379. ARRAY_SIZE(rk3399_clk_pmu_branches));
  1380. rockchip_clk_protect_critical(rk3399_pmucru_critical_clocks,
  1381. ARRAY_SIZE(rk3399_pmucru_critical_clocks));
  1382. rockchip_register_softrst(np, 2, reg_base + RK3399_PMU_SOFTRST_CON(0),
  1383. ROCKCHIP_SOFTRST_HIWORD_MASK);
  1384. rockchip_clk_of_add_provider(np, ctx);
  1385. }
  1386. CLK_OF_DECLARE(rk3399_cru_pmu, "rockchip,rk3399-pmucru", rk3399_pmu_clk_init);