ccu-sun8i-h3.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  1. /*
  2. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/clk-provider.h>
  14. #include <linux/of_address.h>
  15. #include "ccu_common.h"
  16. #include "ccu_reset.h"
  17. #include "ccu_div.h"
  18. #include "ccu_gate.h"
  19. #include "ccu_mp.h"
  20. #include "ccu_mult.h"
  21. #include "ccu_nk.h"
  22. #include "ccu_nkm.h"
  23. #include "ccu_nkmp.h"
  24. #include "ccu_nm.h"
  25. #include "ccu_phase.h"
  26. #include "ccu_sdm.h"
  27. #include "ccu-sun8i-h3.h"
  28. static SUNXI_CCU_NKMP_WITH_GATE_LOCK(pll_cpux_clk, "pll-cpux",
  29. "osc24M", 0x000,
  30. 8, 5, /* N */
  31. 4, 2, /* K */
  32. 0, 2, /* M */
  33. 16, 2, /* P */
  34. BIT(31), /* gate */
  35. BIT(28), /* lock */
  36. CLK_SET_RATE_UNGATE);
  37. /*
  38. * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
  39. * the base (2x, 4x and 8x), and one variable divider (the one true
  40. * pll audio).
  41. *
  42. * With sigma-delta modulation for fractional-N on the audio PLL,
  43. * we have to use specific dividers. This means the variable divider
  44. * can no longer be used, as the audio codec requests the exact clock
  45. * rates we support through this mechanism. So we now hard code the
  46. * variable divider to 1. This means the clock rates will no longer
  47. * match the clock names.
  48. */
  49. #define SUN8I_H3_PLL_AUDIO_REG 0x008
  50. static struct ccu_sdm_setting pll_audio_sdm_table[] = {
  51. { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
  52. { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
  53. };
  54. static SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
  55. "osc24M", 0x008,
  56. 8, 7, /* N */
  57. 0, 5, /* M */
  58. pll_audio_sdm_table, BIT(24),
  59. 0x284, BIT(31),
  60. BIT(31), /* gate */
  61. BIT(28), /* lock */
  62. CLK_SET_RATE_UNGATE);
  63. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN(pll_video_clk, "pll-video",
  64. "osc24M", 0x0010,
  65. 192000000, /* Minimum rate */
  66. 8, 7, /* N */
  67. 0, 4, /* M */
  68. BIT(24), /* frac enable */
  69. BIT(25), /* frac select */
  70. 270000000, /* frac rate 0 */
  71. 297000000, /* frac rate 1 */
  72. BIT(31), /* gate */
  73. BIT(28), /* lock */
  74. CLK_SET_RATE_UNGATE);
  75. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
  76. "osc24M", 0x0018,
  77. 8, 7, /* N */
  78. 0, 4, /* M */
  79. BIT(24), /* frac enable */
  80. BIT(25), /* frac select */
  81. 270000000, /* frac rate 0 */
  82. 297000000, /* frac rate 1 */
  83. BIT(31), /* gate */
  84. BIT(28), /* lock */
  85. CLK_SET_RATE_UNGATE);
  86. static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr_clk, "pll-ddr",
  87. "osc24M", 0x020,
  88. 8, 5, /* N */
  89. 4, 2, /* K */
  90. 0, 2, /* M */
  91. BIT(31), /* gate */
  92. BIT(28), /* lock */
  93. CLK_SET_RATE_UNGATE);
  94. static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph0_clk, "pll-periph0",
  95. "osc24M", 0x028,
  96. 8, 5, /* N */
  97. 4, 2, /* K */
  98. BIT(31), /* gate */
  99. BIT(28), /* lock */
  100. 2, /* post-div */
  101. CLK_SET_RATE_UNGATE);
  102. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
  103. "osc24M", 0x0038,
  104. 8, 7, /* N */
  105. 0, 4, /* M */
  106. BIT(24), /* frac enable */
  107. BIT(25), /* frac select */
  108. 270000000, /* frac rate 0 */
  109. 297000000, /* frac rate 1 */
  110. BIT(31), /* gate */
  111. BIT(28), /* lock */
  112. CLK_SET_RATE_UNGATE);
  113. static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk, "pll-periph1",
  114. "osc24M", 0x044,
  115. 8, 5, /* N */
  116. 4, 2, /* K */
  117. BIT(31), /* gate */
  118. BIT(28), /* lock */
  119. 2, /* post-div */
  120. CLK_SET_RATE_UNGATE);
  121. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
  122. "osc24M", 0x0048,
  123. 8, 7, /* N */
  124. 0, 4, /* M */
  125. BIT(24), /* frac enable */
  126. BIT(25), /* frac select */
  127. 270000000, /* frac rate 0 */
  128. 297000000, /* frac rate 1 */
  129. BIT(31), /* gate */
  130. BIT(28), /* lock */
  131. CLK_SET_RATE_UNGATE);
  132. static const char * const cpux_parents[] = { "osc32k", "osc24M",
  133. "pll-cpux" , "pll-cpux" };
  134. static SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
  135. 0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
  136. static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
  137. static const char * const ahb1_parents[] = { "osc32k", "osc24M",
  138. "axi" , "pll-periph0" };
  139. static const struct ccu_mux_var_prediv ahb1_predivs[] = {
  140. { .index = 3, .shift = 6, .width = 2 },
  141. };
  142. static struct ccu_div ahb1_clk = {
  143. .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
  144. .mux = {
  145. .shift = 12,
  146. .width = 2,
  147. .var_predivs = ahb1_predivs,
  148. .n_var_predivs = ARRAY_SIZE(ahb1_predivs),
  149. },
  150. .common = {
  151. .reg = 0x054,
  152. .features = CCU_FEATURE_VARIABLE_PREDIV,
  153. .hw.init = CLK_HW_INIT_PARENTS("ahb1",
  154. ahb1_parents,
  155. &ccu_div_ops,
  156. 0),
  157. },
  158. };
  159. static struct clk_div_table apb1_div_table[] = {
  160. { .val = 0, .div = 2 },
  161. { .val = 1, .div = 2 },
  162. { .val = 2, .div = 4 },
  163. { .val = 3, .div = 8 },
  164. { /* Sentinel */ },
  165. };
  166. static SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
  167. 0x054, 8, 2, apb1_div_table, 0);
  168. static const char * const apb2_parents[] = { "osc32k", "osc24M",
  169. "pll-periph0" , "pll-periph0" };
  170. static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
  171. 0, 5, /* M */
  172. 16, 2, /* P */
  173. 24, 2, /* mux */
  174. 0);
  175. static const char * const ahb2_parents[] = { "ahb1" , "pll-periph0" };
  176. static const struct ccu_mux_fixed_prediv ahb2_fixed_predivs[] = {
  177. { .index = 1, .div = 2 },
  178. };
  179. static struct ccu_mux ahb2_clk = {
  180. .mux = {
  181. .shift = 0,
  182. .width = 1,
  183. .fixed_predivs = ahb2_fixed_predivs,
  184. .n_predivs = ARRAY_SIZE(ahb2_fixed_predivs),
  185. },
  186. .common = {
  187. .reg = 0x05c,
  188. .features = CCU_FEATURE_FIXED_PREDIV,
  189. .hw.init = CLK_HW_INIT_PARENTS("ahb2",
  190. ahb2_parents,
  191. &ccu_mux_ops,
  192. 0),
  193. },
  194. };
  195. static SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "ahb1",
  196. 0x060, BIT(5), 0);
  197. static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1",
  198. 0x060, BIT(6), 0);
  199. static SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1",
  200. 0x060, BIT(8), 0);
  201. static SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1",
  202. 0x060, BIT(9), 0);
  203. static SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1",
  204. 0x060, BIT(10), 0);
  205. static SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb1",
  206. 0x060, BIT(13), 0);
  207. static SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1",
  208. 0x060, BIT(14), 0);
  209. static SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb2",
  210. 0x060, BIT(17), 0);
  211. static SUNXI_CCU_GATE(bus_ts_clk, "bus-ts", "ahb1",
  212. 0x060, BIT(18), 0);
  213. static SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1",
  214. 0x060, BIT(19), 0);
  215. static SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1",
  216. 0x060, BIT(20), 0);
  217. static SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb1",
  218. 0x060, BIT(21), 0);
  219. static SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1",
  220. 0x060, BIT(23), 0);
  221. static SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb1",
  222. 0x060, BIT(24), 0);
  223. static SUNXI_CCU_GATE(bus_ehci1_clk, "bus-ehci1", "ahb2",
  224. 0x060, BIT(25), 0);
  225. static SUNXI_CCU_GATE(bus_ehci2_clk, "bus-ehci2", "ahb2",
  226. 0x060, BIT(26), 0);
  227. static SUNXI_CCU_GATE(bus_ehci3_clk, "bus-ehci3", "ahb2",
  228. 0x060, BIT(27), 0);
  229. static SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb1",
  230. 0x060, BIT(28), 0);
  231. static SUNXI_CCU_GATE(bus_ohci1_clk, "bus-ohci1", "ahb2",
  232. 0x060, BIT(29), 0);
  233. static SUNXI_CCU_GATE(bus_ohci2_clk, "bus-ohci2", "ahb2",
  234. 0x060, BIT(30), 0);
  235. static SUNXI_CCU_GATE(bus_ohci3_clk, "bus-ohci3", "ahb2",
  236. 0x060, BIT(31), 0);
  237. static SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1",
  238. 0x064, BIT(0), 0);
  239. static SUNXI_CCU_GATE(bus_tcon0_clk, "bus-tcon0", "ahb1",
  240. 0x064, BIT(3), 0);
  241. static SUNXI_CCU_GATE(bus_tcon1_clk, "bus-tcon1", "ahb1",
  242. 0x064, BIT(4), 0);
  243. static SUNXI_CCU_GATE(bus_deinterlace_clk, "bus-deinterlace", "ahb1",
  244. 0x064, BIT(5), 0);
  245. static SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb1",
  246. 0x064, BIT(8), 0);
  247. static SUNXI_CCU_GATE(bus_tve_clk, "bus-tve", "ahb1",
  248. 0x064, BIT(9), 0);
  249. static SUNXI_CCU_GATE(bus_hdmi_clk, "bus-hdmi", "ahb1",
  250. 0x064, BIT(11), 0);
  251. static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1",
  252. 0x064, BIT(12), 0);
  253. static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1",
  254. 0x064, BIT(20), 0);
  255. static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1",
  256. 0x064, BIT(21), 0);
  257. static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1",
  258. 0x064, BIT(22), 0);
  259. static SUNXI_CCU_GATE(bus_codec_clk, "bus-codec", "apb1",
  260. 0x068, BIT(0), 0);
  261. static SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb1",
  262. 0x068, BIT(1), 0);
  263. static SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1",
  264. 0x068, BIT(5), 0);
  265. static SUNXI_CCU_GATE(bus_ths_clk, "bus-ths", "apb1",
  266. 0x068, BIT(8), 0);
  267. static SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1",
  268. 0x068, BIT(12), 0);
  269. static SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1",
  270. 0x068, BIT(13), 0);
  271. static SUNXI_CCU_GATE(bus_i2s2_clk, "bus-i2s2", "apb1",
  272. 0x068, BIT(14), 0);
  273. static SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2",
  274. 0x06c, BIT(0), 0);
  275. static SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2",
  276. 0x06c, BIT(1), 0);
  277. static SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2",
  278. 0x06c, BIT(2), 0);
  279. static SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2",
  280. 0x06c, BIT(16), 0);
  281. static SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2",
  282. 0x06c, BIT(17), 0);
  283. static SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2",
  284. 0x06c, BIT(18), 0);
  285. static SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2",
  286. 0x06c, BIT(19), 0);
  287. static SUNXI_CCU_GATE(bus_scr0_clk, "bus-scr0", "apb2",
  288. 0x06c, BIT(20), 0);
  289. static SUNXI_CCU_GATE(bus_scr1_clk, "bus-scr1", "apb2",
  290. 0x06c, BIT(21), 0);
  291. static SUNXI_CCU_GATE(bus_ephy_clk, "bus-ephy", "ahb1",
  292. 0x070, BIT(0), 0);
  293. static SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "ahb1",
  294. 0x070, BIT(7), 0);
  295. static struct clk_div_table ths_div_table[] = {
  296. { .val = 0, .div = 1 },
  297. { .val = 1, .div = 2 },
  298. { .val = 2, .div = 4 },
  299. { .val = 3, .div = 6 },
  300. { /* Sentinel */ },
  301. };
  302. static SUNXI_CCU_DIV_TABLE_WITH_GATE(ths_clk, "ths", "osc24M",
  303. 0x074, 0, 2, ths_div_table, BIT(31), 0);
  304. static const char * const mod0_default_parents[] = { "osc24M", "pll-periph0",
  305. "pll-periph1" };
  306. static SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
  307. 0, 4, /* M */
  308. 16, 2, /* P */
  309. 24, 2, /* mux */
  310. BIT(31), /* gate */
  311. 0);
  312. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
  313. 0, 4, /* M */
  314. 16, 2, /* P */
  315. 24, 2, /* mux */
  316. BIT(31), /* gate */
  317. 0);
  318. static SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0",
  319. 0x088, 20, 3, 0);
  320. static SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0",
  321. 0x088, 8, 3, 0);
  322. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
  323. 0, 4, /* M */
  324. 16, 2, /* P */
  325. 24, 2, /* mux */
  326. BIT(31), /* gate */
  327. 0);
  328. static SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1",
  329. 0x08c, 20, 3, 0);
  330. static SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1",
  331. 0x08c, 8, 3, 0);
  332. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
  333. 0, 4, /* M */
  334. 16, 2, /* P */
  335. 24, 2, /* mux */
  336. BIT(31), /* gate */
  337. 0);
  338. static SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2_sample", "mmc2",
  339. 0x090, 20, 3, 0);
  340. static SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2_output", "mmc2",
  341. 0x090, 8, 3, 0);
  342. static const char * const ts_parents[] = { "osc24M", "pll-periph0", };
  343. static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098,
  344. 0, 4, /* M */
  345. 16, 2, /* P */
  346. 24, 2, /* mux */
  347. BIT(31), /* gate */
  348. 0);
  349. static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", mod0_default_parents, 0x09c,
  350. 0, 4, /* M */
  351. 16, 2, /* P */
  352. 24, 2, /* mux */
  353. BIT(31), /* gate */
  354. 0);
  355. static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
  356. 0, 4, /* M */
  357. 16, 2, /* P */
  358. 24, 2, /* mux */
  359. BIT(31), /* gate */
  360. 0);
  361. static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
  362. 0, 4, /* M */
  363. 16, 2, /* P */
  364. 24, 2, /* mux */
  365. BIT(31), /* gate */
  366. 0);
  367. static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
  368. "pll-audio-2x", "pll-audio" };
  369. static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
  370. 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  371. static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
  372. 0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  373. static SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents,
  374. 0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  375. static SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio",
  376. 0x0c0, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  377. static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M",
  378. 0x0cc, BIT(8), 0);
  379. static SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "osc24M",
  380. 0x0cc, BIT(9), 0);
  381. static SUNXI_CCU_GATE(usb_phy2_clk, "usb-phy2", "osc24M",
  382. 0x0cc, BIT(10), 0);
  383. static SUNXI_CCU_GATE(usb_phy3_clk, "usb-phy3", "osc24M",
  384. 0x0cc, BIT(11), 0);
  385. static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc24M",
  386. 0x0cc, BIT(16), 0);
  387. static SUNXI_CCU_GATE(usb_ohci1_clk, "usb-ohci1", "osc24M",
  388. 0x0cc, BIT(17), 0);
  389. static SUNXI_CCU_GATE(usb_ohci2_clk, "usb-ohci2", "osc24M",
  390. 0x0cc, BIT(18), 0);
  391. static SUNXI_CCU_GATE(usb_ohci3_clk, "usb-ohci3", "osc24M",
  392. 0x0cc, BIT(19), 0);
  393. static const char * const dram_parents[] = { "pll-ddr", "pll-periph0-2x" };
  394. static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
  395. 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL);
  396. static SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram",
  397. 0x100, BIT(0), 0);
  398. static SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "dram",
  399. 0x100, BIT(1), 0);
  400. static SUNXI_CCU_GATE(dram_deinterlace_clk, "dram-deinterlace", "dram",
  401. 0x100, BIT(2), 0);
  402. static SUNXI_CCU_GATE(dram_ts_clk, "dram-ts", "dram",
  403. 0x100, BIT(3), 0);
  404. static const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
  405. static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
  406. 0x104, 0, 4, 24, 3, BIT(31),
  407. CLK_SET_RATE_PARENT);
  408. static const char * const tcon_parents[] = { "pll-video" };
  409. static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents,
  410. 0x118, 0, 4, 24, 3, BIT(31),
  411. CLK_SET_RATE_PARENT);
  412. static const char * const tve_parents[] = { "pll-de", "pll-periph1" };
  413. static SUNXI_CCU_M_WITH_MUX_GATE(tve_clk, "tve", tve_parents,
  414. 0x120, 0, 4, 24, 3, BIT(31), 0);
  415. static const char * const deinterlace_parents[] = { "pll-periph0", "pll-periph1" };
  416. static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace", deinterlace_parents,
  417. 0x124, 0, 4, 24, 3, BIT(31), 0);
  418. static SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M",
  419. 0x130, BIT(31), 0);
  420. static const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
  421. static SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
  422. 0x134, 16, 4, 24, 3, BIT(31), 0);
  423. static const char * const csi_mclk_parents[] = { "osc24M", "pll-video", "pll-periph1" };
  424. static SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk, "csi-mclk", csi_mclk_parents,
  425. 0x134, 0, 5, 8, 3, BIT(15), 0);
  426. static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
  427. 0x13c, 16, 3, BIT(31), 0);
  428. static SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio",
  429. 0x140, BIT(31), CLK_SET_RATE_PARENT);
  430. static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M",
  431. 0x144, BIT(31), 0);
  432. static const char * const hdmi_parents[] = { "pll-video" };
  433. static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
  434. 0x150, 0, 4, 24, 2, BIT(31),
  435. CLK_SET_RATE_PARENT);
  436. static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M",
  437. 0x154, BIT(31), 0);
  438. static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", "pll-ddr" };
  439. static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
  440. 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);
  441. static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
  442. 0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);
  443. static struct ccu_common *sun8i_h3_ccu_clks[] = {
  444. &pll_cpux_clk.common,
  445. &pll_audio_base_clk.common,
  446. &pll_video_clk.common,
  447. &pll_ve_clk.common,
  448. &pll_ddr_clk.common,
  449. &pll_periph0_clk.common,
  450. &pll_gpu_clk.common,
  451. &pll_periph1_clk.common,
  452. &pll_de_clk.common,
  453. &cpux_clk.common,
  454. &axi_clk.common,
  455. &ahb1_clk.common,
  456. &apb1_clk.common,
  457. &apb2_clk.common,
  458. &ahb2_clk.common,
  459. &bus_ce_clk.common,
  460. &bus_dma_clk.common,
  461. &bus_mmc0_clk.common,
  462. &bus_mmc1_clk.common,
  463. &bus_mmc2_clk.common,
  464. &bus_nand_clk.common,
  465. &bus_dram_clk.common,
  466. &bus_emac_clk.common,
  467. &bus_ts_clk.common,
  468. &bus_hstimer_clk.common,
  469. &bus_spi0_clk.common,
  470. &bus_spi1_clk.common,
  471. &bus_otg_clk.common,
  472. &bus_ehci0_clk.common,
  473. &bus_ehci1_clk.common,
  474. &bus_ehci2_clk.common,
  475. &bus_ehci3_clk.common,
  476. &bus_ohci0_clk.common,
  477. &bus_ohci1_clk.common,
  478. &bus_ohci2_clk.common,
  479. &bus_ohci3_clk.common,
  480. &bus_ve_clk.common,
  481. &bus_tcon0_clk.common,
  482. &bus_tcon1_clk.common,
  483. &bus_deinterlace_clk.common,
  484. &bus_csi_clk.common,
  485. &bus_tve_clk.common,
  486. &bus_hdmi_clk.common,
  487. &bus_de_clk.common,
  488. &bus_gpu_clk.common,
  489. &bus_msgbox_clk.common,
  490. &bus_spinlock_clk.common,
  491. &bus_codec_clk.common,
  492. &bus_spdif_clk.common,
  493. &bus_pio_clk.common,
  494. &bus_ths_clk.common,
  495. &bus_i2s0_clk.common,
  496. &bus_i2s1_clk.common,
  497. &bus_i2s2_clk.common,
  498. &bus_i2c0_clk.common,
  499. &bus_i2c1_clk.common,
  500. &bus_i2c2_clk.common,
  501. &bus_uart0_clk.common,
  502. &bus_uart1_clk.common,
  503. &bus_uart2_clk.common,
  504. &bus_uart3_clk.common,
  505. &bus_scr0_clk.common,
  506. &bus_ephy_clk.common,
  507. &bus_dbg_clk.common,
  508. &ths_clk.common,
  509. &nand_clk.common,
  510. &mmc0_clk.common,
  511. &mmc0_sample_clk.common,
  512. &mmc0_output_clk.common,
  513. &mmc1_clk.common,
  514. &mmc1_sample_clk.common,
  515. &mmc1_output_clk.common,
  516. &mmc2_clk.common,
  517. &mmc2_sample_clk.common,
  518. &mmc2_output_clk.common,
  519. &ts_clk.common,
  520. &ce_clk.common,
  521. &spi0_clk.common,
  522. &spi1_clk.common,
  523. &i2s0_clk.common,
  524. &i2s1_clk.common,
  525. &i2s2_clk.common,
  526. &spdif_clk.common,
  527. &usb_phy0_clk.common,
  528. &usb_phy1_clk.common,
  529. &usb_phy2_clk.common,
  530. &usb_phy3_clk.common,
  531. &usb_ohci0_clk.common,
  532. &usb_ohci1_clk.common,
  533. &usb_ohci2_clk.common,
  534. &usb_ohci3_clk.common,
  535. &dram_clk.common,
  536. &dram_ve_clk.common,
  537. &dram_csi_clk.common,
  538. &dram_deinterlace_clk.common,
  539. &dram_ts_clk.common,
  540. &de_clk.common,
  541. &tcon_clk.common,
  542. &tve_clk.common,
  543. &deinterlace_clk.common,
  544. &csi_misc_clk.common,
  545. &csi_sclk_clk.common,
  546. &csi_mclk_clk.common,
  547. &ve_clk.common,
  548. &ac_dig_clk.common,
  549. &avs_clk.common,
  550. &hdmi_clk.common,
  551. &hdmi_ddc_clk.common,
  552. &mbus_clk.common,
  553. &gpu_clk.common,
  554. };
  555. static struct ccu_common *sun50i_h5_ccu_clks[] = {
  556. &pll_cpux_clk.common,
  557. &pll_audio_base_clk.common,
  558. &pll_video_clk.common,
  559. &pll_ve_clk.common,
  560. &pll_ddr_clk.common,
  561. &pll_periph0_clk.common,
  562. &pll_gpu_clk.common,
  563. &pll_periph1_clk.common,
  564. &pll_de_clk.common,
  565. &cpux_clk.common,
  566. &axi_clk.common,
  567. &ahb1_clk.common,
  568. &apb1_clk.common,
  569. &apb2_clk.common,
  570. &ahb2_clk.common,
  571. &bus_ce_clk.common,
  572. &bus_dma_clk.common,
  573. &bus_mmc0_clk.common,
  574. &bus_mmc1_clk.common,
  575. &bus_mmc2_clk.common,
  576. &bus_nand_clk.common,
  577. &bus_dram_clk.common,
  578. &bus_emac_clk.common,
  579. &bus_ts_clk.common,
  580. &bus_hstimer_clk.common,
  581. &bus_spi0_clk.common,
  582. &bus_spi1_clk.common,
  583. &bus_otg_clk.common,
  584. &bus_ehci0_clk.common,
  585. &bus_ehci1_clk.common,
  586. &bus_ehci2_clk.common,
  587. &bus_ehci3_clk.common,
  588. &bus_ohci0_clk.common,
  589. &bus_ohci1_clk.common,
  590. &bus_ohci2_clk.common,
  591. &bus_ohci3_clk.common,
  592. &bus_ve_clk.common,
  593. &bus_tcon0_clk.common,
  594. &bus_tcon1_clk.common,
  595. &bus_deinterlace_clk.common,
  596. &bus_csi_clk.common,
  597. &bus_tve_clk.common,
  598. &bus_hdmi_clk.common,
  599. &bus_de_clk.common,
  600. &bus_gpu_clk.common,
  601. &bus_msgbox_clk.common,
  602. &bus_spinlock_clk.common,
  603. &bus_codec_clk.common,
  604. &bus_spdif_clk.common,
  605. &bus_pio_clk.common,
  606. &bus_ths_clk.common,
  607. &bus_i2s0_clk.common,
  608. &bus_i2s1_clk.common,
  609. &bus_i2s2_clk.common,
  610. &bus_i2c0_clk.common,
  611. &bus_i2c1_clk.common,
  612. &bus_i2c2_clk.common,
  613. &bus_uart0_clk.common,
  614. &bus_uart1_clk.common,
  615. &bus_uart2_clk.common,
  616. &bus_uart3_clk.common,
  617. &bus_scr0_clk.common,
  618. &bus_scr1_clk.common,
  619. &bus_ephy_clk.common,
  620. &bus_dbg_clk.common,
  621. &ths_clk.common,
  622. &nand_clk.common,
  623. &mmc0_clk.common,
  624. &mmc1_clk.common,
  625. &mmc2_clk.common,
  626. &ts_clk.common,
  627. &ce_clk.common,
  628. &spi0_clk.common,
  629. &spi1_clk.common,
  630. &i2s0_clk.common,
  631. &i2s1_clk.common,
  632. &i2s2_clk.common,
  633. &spdif_clk.common,
  634. &usb_phy0_clk.common,
  635. &usb_phy1_clk.common,
  636. &usb_phy2_clk.common,
  637. &usb_phy3_clk.common,
  638. &usb_ohci0_clk.common,
  639. &usb_ohci1_clk.common,
  640. &usb_ohci2_clk.common,
  641. &usb_ohci3_clk.common,
  642. &dram_clk.common,
  643. &dram_ve_clk.common,
  644. &dram_csi_clk.common,
  645. &dram_deinterlace_clk.common,
  646. &dram_ts_clk.common,
  647. &de_clk.common,
  648. &tcon_clk.common,
  649. &tve_clk.common,
  650. &deinterlace_clk.common,
  651. &csi_misc_clk.common,
  652. &csi_sclk_clk.common,
  653. &csi_mclk_clk.common,
  654. &ve_clk.common,
  655. &ac_dig_clk.common,
  656. &avs_clk.common,
  657. &hdmi_clk.common,
  658. &hdmi_ddc_clk.common,
  659. &mbus_clk.common,
  660. &gpu_clk.common,
  661. };
  662. /* We hardcode the divider to 1 for now */
  663. static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",
  664. "pll-audio-base", 1, 1, CLK_SET_RATE_PARENT);
  665. static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x",
  666. "pll-audio-base", 2, 1, CLK_SET_RATE_PARENT);
  667. static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x",
  668. "pll-audio-base", 1, 1, CLK_SET_RATE_PARENT);
  669. static CLK_FIXED_FACTOR(pll_audio_8x_clk, "pll-audio-8x",
  670. "pll-audio-base", 1, 2, CLK_SET_RATE_PARENT);
  671. static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x",
  672. "pll-periph0", 1, 2, 0);
  673. static struct clk_hw_onecell_data sun8i_h3_hw_clks = {
  674. .hws = {
  675. [CLK_PLL_CPUX] = &pll_cpux_clk.common.hw,
  676. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  677. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  678. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  679. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  680. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  681. [CLK_PLL_VIDEO] = &pll_video_clk.common.hw,
  682. [CLK_PLL_VE] = &pll_ve_clk.common.hw,
  683. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  684. [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw,
  685. [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw,
  686. [CLK_PLL_GPU] = &pll_gpu_clk.common.hw,
  687. [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw,
  688. [CLK_PLL_DE] = &pll_de_clk.common.hw,
  689. [CLK_CPUX] = &cpux_clk.common.hw,
  690. [CLK_AXI] = &axi_clk.common.hw,
  691. [CLK_AHB1] = &ahb1_clk.common.hw,
  692. [CLK_APB1] = &apb1_clk.common.hw,
  693. [CLK_APB2] = &apb2_clk.common.hw,
  694. [CLK_AHB2] = &ahb2_clk.common.hw,
  695. [CLK_BUS_CE] = &bus_ce_clk.common.hw,
  696. [CLK_BUS_DMA] = &bus_dma_clk.common.hw,
  697. [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw,
  698. [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw,
  699. [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw,
  700. [CLK_BUS_NAND] = &bus_nand_clk.common.hw,
  701. [CLK_BUS_DRAM] = &bus_dram_clk.common.hw,
  702. [CLK_BUS_EMAC] = &bus_emac_clk.common.hw,
  703. [CLK_BUS_TS] = &bus_ts_clk.common.hw,
  704. [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw,
  705. [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw,
  706. [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw,
  707. [CLK_BUS_OTG] = &bus_otg_clk.common.hw,
  708. [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw,
  709. [CLK_BUS_EHCI1] = &bus_ehci1_clk.common.hw,
  710. [CLK_BUS_EHCI2] = &bus_ehci2_clk.common.hw,
  711. [CLK_BUS_EHCI3] = &bus_ehci3_clk.common.hw,
  712. [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw,
  713. [CLK_BUS_OHCI1] = &bus_ohci1_clk.common.hw,
  714. [CLK_BUS_OHCI2] = &bus_ohci2_clk.common.hw,
  715. [CLK_BUS_OHCI3] = &bus_ohci3_clk.common.hw,
  716. [CLK_BUS_VE] = &bus_ve_clk.common.hw,
  717. [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw,
  718. [CLK_BUS_TCON1] = &bus_tcon1_clk.common.hw,
  719. [CLK_BUS_DEINTERLACE] = &bus_deinterlace_clk.common.hw,
  720. [CLK_BUS_CSI] = &bus_csi_clk.common.hw,
  721. [CLK_BUS_TVE] = &bus_tve_clk.common.hw,
  722. [CLK_BUS_HDMI] = &bus_hdmi_clk.common.hw,
  723. [CLK_BUS_DE] = &bus_de_clk.common.hw,
  724. [CLK_BUS_GPU] = &bus_gpu_clk.common.hw,
  725. [CLK_BUS_MSGBOX] = &bus_msgbox_clk.common.hw,
  726. [CLK_BUS_SPINLOCK] = &bus_spinlock_clk.common.hw,
  727. [CLK_BUS_CODEC] = &bus_codec_clk.common.hw,
  728. [CLK_BUS_SPDIF] = &bus_spdif_clk.common.hw,
  729. [CLK_BUS_PIO] = &bus_pio_clk.common.hw,
  730. [CLK_BUS_THS] = &bus_ths_clk.common.hw,
  731. [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw,
  732. [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw,
  733. [CLK_BUS_I2S2] = &bus_i2s2_clk.common.hw,
  734. [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw,
  735. [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw,
  736. [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw,
  737. [CLK_BUS_UART0] = &bus_uart0_clk.common.hw,
  738. [CLK_BUS_UART1] = &bus_uart1_clk.common.hw,
  739. [CLK_BUS_UART2] = &bus_uart2_clk.common.hw,
  740. [CLK_BUS_UART3] = &bus_uart3_clk.common.hw,
  741. [CLK_BUS_SCR0] = &bus_scr0_clk.common.hw,
  742. [CLK_BUS_EPHY] = &bus_ephy_clk.common.hw,
  743. [CLK_BUS_DBG] = &bus_dbg_clk.common.hw,
  744. [CLK_THS] = &ths_clk.common.hw,
  745. [CLK_NAND] = &nand_clk.common.hw,
  746. [CLK_MMC0] = &mmc0_clk.common.hw,
  747. [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw,
  748. [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw,
  749. [CLK_MMC1] = &mmc1_clk.common.hw,
  750. [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw,
  751. [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw,
  752. [CLK_MMC2] = &mmc2_clk.common.hw,
  753. [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw,
  754. [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw,
  755. [CLK_TS] = &ts_clk.common.hw,
  756. [CLK_CE] = &ce_clk.common.hw,
  757. [CLK_SPI0] = &spi0_clk.common.hw,
  758. [CLK_SPI1] = &spi1_clk.common.hw,
  759. [CLK_I2S0] = &i2s0_clk.common.hw,
  760. [CLK_I2S1] = &i2s1_clk.common.hw,
  761. [CLK_I2S2] = &i2s2_clk.common.hw,
  762. [CLK_SPDIF] = &spdif_clk.common.hw,
  763. [CLK_USB_PHY0] = &usb_phy0_clk.common.hw,
  764. [CLK_USB_PHY1] = &usb_phy1_clk.common.hw,
  765. [CLK_USB_PHY2] = &usb_phy2_clk.common.hw,
  766. [CLK_USB_PHY3] = &usb_phy3_clk.common.hw,
  767. [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw,
  768. [CLK_USB_OHCI1] = &usb_ohci1_clk.common.hw,
  769. [CLK_USB_OHCI2] = &usb_ohci2_clk.common.hw,
  770. [CLK_USB_OHCI3] = &usb_ohci3_clk.common.hw,
  771. [CLK_DRAM] = &dram_clk.common.hw,
  772. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  773. [CLK_DRAM_CSI] = &dram_csi_clk.common.hw,
  774. [CLK_DRAM_DEINTERLACE] = &dram_deinterlace_clk.common.hw,
  775. [CLK_DRAM_TS] = &dram_ts_clk.common.hw,
  776. [CLK_DE] = &de_clk.common.hw,
  777. [CLK_TCON0] = &tcon_clk.common.hw,
  778. [CLK_TVE] = &tve_clk.common.hw,
  779. [CLK_DEINTERLACE] = &deinterlace_clk.common.hw,
  780. [CLK_CSI_MISC] = &csi_misc_clk.common.hw,
  781. [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw,
  782. [CLK_CSI_MCLK] = &csi_mclk_clk.common.hw,
  783. [CLK_VE] = &ve_clk.common.hw,
  784. [CLK_AC_DIG] = &ac_dig_clk.common.hw,
  785. [CLK_AVS] = &avs_clk.common.hw,
  786. [CLK_HDMI] = &hdmi_clk.common.hw,
  787. [CLK_HDMI_DDC] = &hdmi_ddc_clk.common.hw,
  788. [CLK_MBUS] = &mbus_clk.common.hw,
  789. [CLK_GPU] = &gpu_clk.common.hw,
  790. },
  791. .num = CLK_NUMBER_H3,
  792. };
  793. static struct clk_hw_onecell_data sun50i_h5_hw_clks = {
  794. .hws = {
  795. [CLK_PLL_CPUX] = &pll_cpux_clk.common.hw,
  796. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  797. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  798. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  799. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  800. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  801. [CLK_PLL_VIDEO] = &pll_video_clk.common.hw,
  802. [CLK_PLL_VE] = &pll_ve_clk.common.hw,
  803. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  804. [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw,
  805. [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw,
  806. [CLK_PLL_GPU] = &pll_gpu_clk.common.hw,
  807. [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw,
  808. [CLK_PLL_DE] = &pll_de_clk.common.hw,
  809. [CLK_CPUX] = &cpux_clk.common.hw,
  810. [CLK_AXI] = &axi_clk.common.hw,
  811. [CLK_AHB1] = &ahb1_clk.common.hw,
  812. [CLK_APB1] = &apb1_clk.common.hw,
  813. [CLK_APB2] = &apb2_clk.common.hw,
  814. [CLK_AHB2] = &ahb2_clk.common.hw,
  815. [CLK_BUS_CE] = &bus_ce_clk.common.hw,
  816. [CLK_BUS_DMA] = &bus_dma_clk.common.hw,
  817. [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw,
  818. [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw,
  819. [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw,
  820. [CLK_BUS_NAND] = &bus_nand_clk.common.hw,
  821. [CLK_BUS_DRAM] = &bus_dram_clk.common.hw,
  822. [CLK_BUS_EMAC] = &bus_emac_clk.common.hw,
  823. [CLK_BUS_TS] = &bus_ts_clk.common.hw,
  824. [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw,
  825. [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw,
  826. [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw,
  827. [CLK_BUS_OTG] = &bus_otg_clk.common.hw,
  828. [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw,
  829. [CLK_BUS_EHCI1] = &bus_ehci1_clk.common.hw,
  830. [CLK_BUS_EHCI2] = &bus_ehci2_clk.common.hw,
  831. [CLK_BUS_EHCI3] = &bus_ehci3_clk.common.hw,
  832. [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw,
  833. [CLK_BUS_OHCI1] = &bus_ohci1_clk.common.hw,
  834. [CLK_BUS_OHCI2] = &bus_ohci2_clk.common.hw,
  835. [CLK_BUS_OHCI3] = &bus_ohci3_clk.common.hw,
  836. [CLK_BUS_VE] = &bus_ve_clk.common.hw,
  837. [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw,
  838. [CLK_BUS_TCON1] = &bus_tcon1_clk.common.hw,
  839. [CLK_BUS_DEINTERLACE] = &bus_deinterlace_clk.common.hw,
  840. [CLK_BUS_CSI] = &bus_csi_clk.common.hw,
  841. [CLK_BUS_TVE] = &bus_tve_clk.common.hw,
  842. [CLK_BUS_HDMI] = &bus_hdmi_clk.common.hw,
  843. [CLK_BUS_DE] = &bus_de_clk.common.hw,
  844. [CLK_BUS_GPU] = &bus_gpu_clk.common.hw,
  845. [CLK_BUS_MSGBOX] = &bus_msgbox_clk.common.hw,
  846. [CLK_BUS_SPINLOCK] = &bus_spinlock_clk.common.hw,
  847. [CLK_BUS_CODEC] = &bus_codec_clk.common.hw,
  848. [CLK_BUS_SPDIF] = &bus_spdif_clk.common.hw,
  849. [CLK_BUS_PIO] = &bus_pio_clk.common.hw,
  850. [CLK_BUS_THS] = &bus_ths_clk.common.hw,
  851. [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw,
  852. [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw,
  853. [CLK_BUS_I2S2] = &bus_i2s2_clk.common.hw,
  854. [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw,
  855. [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw,
  856. [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw,
  857. [CLK_BUS_UART0] = &bus_uart0_clk.common.hw,
  858. [CLK_BUS_UART1] = &bus_uart1_clk.common.hw,
  859. [CLK_BUS_UART2] = &bus_uart2_clk.common.hw,
  860. [CLK_BUS_UART3] = &bus_uart3_clk.common.hw,
  861. [CLK_BUS_SCR0] = &bus_scr0_clk.common.hw,
  862. [CLK_BUS_SCR1] = &bus_scr1_clk.common.hw,
  863. [CLK_BUS_EPHY] = &bus_ephy_clk.common.hw,
  864. [CLK_BUS_DBG] = &bus_dbg_clk.common.hw,
  865. [CLK_THS] = &ths_clk.common.hw,
  866. [CLK_NAND] = &nand_clk.common.hw,
  867. [CLK_MMC0] = &mmc0_clk.common.hw,
  868. [CLK_MMC1] = &mmc1_clk.common.hw,
  869. [CLK_MMC2] = &mmc2_clk.common.hw,
  870. [CLK_TS] = &ts_clk.common.hw,
  871. [CLK_CE] = &ce_clk.common.hw,
  872. [CLK_SPI0] = &spi0_clk.common.hw,
  873. [CLK_SPI1] = &spi1_clk.common.hw,
  874. [CLK_I2S0] = &i2s0_clk.common.hw,
  875. [CLK_I2S1] = &i2s1_clk.common.hw,
  876. [CLK_I2S2] = &i2s2_clk.common.hw,
  877. [CLK_SPDIF] = &spdif_clk.common.hw,
  878. [CLK_USB_PHY0] = &usb_phy0_clk.common.hw,
  879. [CLK_USB_PHY1] = &usb_phy1_clk.common.hw,
  880. [CLK_USB_PHY2] = &usb_phy2_clk.common.hw,
  881. [CLK_USB_PHY3] = &usb_phy3_clk.common.hw,
  882. [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw,
  883. [CLK_USB_OHCI1] = &usb_ohci1_clk.common.hw,
  884. [CLK_USB_OHCI2] = &usb_ohci2_clk.common.hw,
  885. [CLK_USB_OHCI3] = &usb_ohci3_clk.common.hw,
  886. [CLK_DRAM] = &dram_clk.common.hw,
  887. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  888. [CLK_DRAM_CSI] = &dram_csi_clk.common.hw,
  889. [CLK_DRAM_DEINTERLACE] = &dram_deinterlace_clk.common.hw,
  890. [CLK_DRAM_TS] = &dram_ts_clk.common.hw,
  891. [CLK_DE] = &de_clk.common.hw,
  892. [CLK_TCON0] = &tcon_clk.common.hw,
  893. [CLK_TVE] = &tve_clk.common.hw,
  894. [CLK_DEINTERLACE] = &deinterlace_clk.common.hw,
  895. [CLK_CSI_MISC] = &csi_misc_clk.common.hw,
  896. [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw,
  897. [CLK_CSI_MCLK] = &csi_mclk_clk.common.hw,
  898. [CLK_VE] = &ve_clk.common.hw,
  899. [CLK_AC_DIG] = &ac_dig_clk.common.hw,
  900. [CLK_AVS] = &avs_clk.common.hw,
  901. [CLK_HDMI] = &hdmi_clk.common.hw,
  902. [CLK_HDMI_DDC] = &hdmi_ddc_clk.common.hw,
  903. [CLK_MBUS] = &mbus_clk.common.hw,
  904. [CLK_GPU] = &gpu_clk.common.hw,
  905. },
  906. .num = CLK_NUMBER_H5,
  907. };
  908. static struct ccu_reset_map sun8i_h3_ccu_resets[] = {
  909. [RST_USB_PHY0] = { 0x0cc, BIT(0) },
  910. [RST_USB_PHY1] = { 0x0cc, BIT(1) },
  911. [RST_USB_PHY2] = { 0x0cc, BIT(2) },
  912. [RST_USB_PHY3] = { 0x0cc, BIT(3) },
  913. [RST_MBUS] = { 0x0fc, BIT(31) },
  914. [RST_BUS_CE] = { 0x2c0, BIT(5) },
  915. [RST_BUS_DMA] = { 0x2c0, BIT(6) },
  916. [RST_BUS_MMC0] = { 0x2c0, BIT(8) },
  917. [RST_BUS_MMC1] = { 0x2c0, BIT(9) },
  918. [RST_BUS_MMC2] = { 0x2c0, BIT(10) },
  919. [RST_BUS_NAND] = { 0x2c0, BIT(13) },
  920. [RST_BUS_DRAM] = { 0x2c0, BIT(14) },
  921. [RST_BUS_EMAC] = { 0x2c0, BIT(17) },
  922. [RST_BUS_TS] = { 0x2c0, BIT(18) },
  923. [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) },
  924. [RST_BUS_SPI0] = { 0x2c0, BIT(20) },
  925. [RST_BUS_SPI1] = { 0x2c0, BIT(21) },
  926. [RST_BUS_OTG] = { 0x2c0, BIT(23) },
  927. [RST_BUS_EHCI0] = { 0x2c0, BIT(24) },
  928. [RST_BUS_EHCI1] = { 0x2c0, BIT(25) },
  929. [RST_BUS_EHCI2] = { 0x2c0, BIT(26) },
  930. [RST_BUS_EHCI3] = { 0x2c0, BIT(27) },
  931. [RST_BUS_OHCI0] = { 0x2c0, BIT(28) },
  932. [RST_BUS_OHCI1] = { 0x2c0, BIT(29) },
  933. [RST_BUS_OHCI2] = { 0x2c0, BIT(30) },
  934. [RST_BUS_OHCI3] = { 0x2c0, BIT(31) },
  935. [RST_BUS_VE] = { 0x2c4, BIT(0) },
  936. [RST_BUS_TCON0] = { 0x2c4, BIT(3) },
  937. [RST_BUS_TCON1] = { 0x2c4, BIT(4) },
  938. [RST_BUS_DEINTERLACE] = { 0x2c4, BIT(5) },
  939. [RST_BUS_CSI] = { 0x2c4, BIT(8) },
  940. [RST_BUS_TVE] = { 0x2c4, BIT(9) },
  941. [RST_BUS_HDMI0] = { 0x2c4, BIT(10) },
  942. [RST_BUS_HDMI1] = { 0x2c4, BIT(11) },
  943. [RST_BUS_DE] = { 0x2c4, BIT(12) },
  944. [RST_BUS_GPU] = { 0x2c4, BIT(20) },
  945. [RST_BUS_MSGBOX] = { 0x2c4, BIT(21) },
  946. [RST_BUS_SPINLOCK] = { 0x2c4, BIT(22) },
  947. [RST_BUS_DBG] = { 0x2c4, BIT(31) },
  948. [RST_BUS_EPHY] = { 0x2c8, BIT(2) },
  949. [RST_BUS_CODEC] = { 0x2d0, BIT(0) },
  950. [RST_BUS_SPDIF] = { 0x2d0, BIT(1) },
  951. [RST_BUS_THS] = { 0x2d0, BIT(8) },
  952. [RST_BUS_I2S0] = { 0x2d0, BIT(12) },
  953. [RST_BUS_I2S1] = { 0x2d0, BIT(13) },
  954. [RST_BUS_I2S2] = { 0x2d0, BIT(14) },
  955. [RST_BUS_I2C0] = { 0x2d8, BIT(0) },
  956. [RST_BUS_I2C1] = { 0x2d8, BIT(1) },
  957. [RST_BUS_I2C2] = { 0x2d8, BIT(2) },
  958. [RST_BUS_UART0] = { 0x2d8, BIT(16) },
  959. [RST_BUS_UART1] = { 0x2d8, BIT(17) },
  960. [RST_BUS_UART2] = { 0x2d8, BIT(18) },
  961. [RST_BUS_UART3] = { 0x2d8, BIT(19) },
  962. [RST_BUS_SCR0] = { 0x2d8, BIT(20) },
  963. };
  964. static struct ccu_reset_map sun50i_h5_ccu_resets[] = {
  965. [RST_USB_PHY0] = { 0x0cc, BIT(0) },
  966. [RST_USB_PHY1] = { 0x0cc, BIT(1) },
  967. [RST_USB_PHY2] = { 0x0cc, BIT(2) },
  968. [RST_USB_PHY3] = { 0x0cc, BIT(3) },
  969. [RST_MBUS] = { 0x0fc, BIT(31) },
  970. [RST_BUS_CE] = { 0x2c0, BIT(5) },
  971. [RST_BUS_DMA] = { 0x2c0, BIT(6) },
  972. [RST_BUS_MMC0] = { 0x2c0, BIT(8) },
  973. [RST_BUS_MMC1] = { 0x2c0, BIT(9) },
  974. [RST_BUS_MMC2] = { 0x2c0, BIT(10) },
  975. [RST_BUS_NAND] = { 0x2c0, BIT(13) },
  976. [RST_BUS_DRAM] = { 0x2c0, BIT(14) },
  977. [RST_BUS_EMAC] = { 0x2c0, BIT(17) },
  978. [RST_BUS_TS] = { 0x2c0, BIT(18) },
  979. [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) },
  980. [RST_BUS_SPI0] = { 0x2c0, BIT(20) },
  981. [RST_BUS_SPI1] = { 0x2c0, BIT(21) },
  982. [RST_BUS_OTG] = { 0x2c0, BIT(23) },
  983. [RST_BUS_EHCI0] = { 0x2c0, BIT(24) },
  984. [RST_BUS_EHCI1] = { 0x2c0, BIT(25) },
  985. [RST_BUS_EHCI2] = { 0x2c0, BIT(26) },
  986. [RST_BUS_EHCI3] = { 0x2c0, BIT(27) },
  987. [RST_BUS_OHCI0] = { 0x2c0, BIT(28) },
  988. [RST_BUS_OHCI1] = { 0x2c0, BIT(29) },
  989. [RST_BUS_OHCI2] = { 0x2c0, BIT(30) },
  990. [RST_BUS_OHCI3] = { 0x2c0, BIT(31) },
  991. [RST_BUS_VE] = { 0x2c4, BIT(0) },
  992. [RST_BUS_TCON0] = { 0x2c4, BIT(3) },
  993. [RST_BUS_TCON1] = { 0x2c4, BIT(4) },
  994. [RST_BUS_DEINTERLACE] = { 0x2c4, BIT(5) },
  995. [RST_BUS_CSI] = { 0x2c4, BIT(8) },
  996. [RST_BUS_TVE] = { 0x2c4, BIT(9) },
  997. [RST_BUS_HDMI0] = { 0x2c4, BIT(10) },
  998. [RST_BUS_HDMI1] = { 0x2c4, BIT(11) },
  999. [RST_BUS_DE] = { 0x2c4, BIT(12) },
  1000. [RST_BUS_GPU] = { 0x2c4, BIT(20) },
  1001. [RST_BUS_MSGBOX] = { 0x2c4, BIT(21) },
  1002. [RST_BUS_SPINLOCK] = { 0x2c4, BIT(22) },
  1003. [RST_BUS_DBG] = { 0x2c4, BIT(31) },
  1004. [RST_BUS_EPHY] = { 0x2c8, BIT(2) },
  1005. [RST_BUS_CODEC] = { 0x2d0, BIT(0) },
  1006. [RST_BUS_SPDIF] = { 0x2d0, BIT(1) },
  1007. [RST_BUS_THS] = { 0x2d0, BIT(8) },
  1008. [RST_BUS_I2S0] = { 0x2d0, BIT(12) },
  1009. [RST_BUS_I2S1] = { 0x2d0, BIT(13) },
  1010. [RST_BUS_I2S2] = { 0x2d0, BIT(14) },
  1011. [RST_BUS_I2C0] = { 0x2d8, BIT(0) },
  1012. [RST_BUS_I2C1] = { 0x2d8, BIT(1) },
  1013. [RST_BUS_I2C2] = { 0x2d8, BIT(2) },
  1014. [RST_BUS_UART0] = { 0x2d8, BIT(16) },
  1015. [RST_BUS_UART1] = { 0x2d8, BIT(17) },
  1016. [RST_BUS_UART2] = { 0x2d8, BIT(18) },
  1017. [RST_BUS_UART3] = { 0x2d8, BIT(19) },
  1018. [RST_BUS_SCR0] = { 0x2d8, BIT(20) },
  1019. [RST_BUS_SCR1] = { 0x2d8, BIT(20) },
  1020. };
  1021. static const struct sunxi_ccu_desc sun8i_h3_ccu_desc = {
  1022. .ccu_clks = sun8i_h3_ccu_clks,
  1023. .num_ccu_clks = ARRAY_SIZE(sun8i_h3_ccu_clks),
  1024. .hw_clks = &sun8i_h3_hw_clks,
  1025. .resets = sun8i_h3_ccu_resets,
  1026. .num_resets = ARRAY_SIZE(sun8i_h3_ccu_resets),
  1027. };
  1028. static const struct sunxi_ccu_desc sun50i_h5_ccu_desc = {
  1029. .ccu_clks = sun50i_h5_ccu_clks,
  1030. .num_ccu_clks = ARRAY_SIZE(sun50i_h5_ccu_clks),
  1031. .hw_clks = &sun50i_h5_hw_clks,
  1032. .resets = sun50i_h5_ccu_resets,
  1033. .num_resets = ARRAY_SIZE(sun50i_h5_ccu_resets),
  1034. };
  1035. static struct ccu_pll_nb sun8i_h3_pll_cpu_nb = {
  1036. .common = &pll_cpux_clk.common,
  1037. /* copy from pll_cpux_clk */
  1038. .enable = BIT(31),
  1039. .lock = BIT(28),
  1040. };
  1041. static struct ccu_mux_nb sun8i_h3_cpu_nb = {
  1042. .common = &cpux_clk.common,
  1043. .cm = &cpux_clk.mux,
  1044. .delay_us = 1, /* > 8 clock cycles at 24 MHz */
  1045. .bypass_index = 1, /* index of 24 MHz oscillator */
  1046. };
  1047. static void __init sunxi_h3_h5_ccu_init(struct device_node *node,
  1048. const struct sunxi_ccu_desc *desc)
  1049. {
  1050. void __iomem *reg;
  1051. u32 val;
  1052. reg = of_io_request_and_map(node, 0, of_node_full_name(node));
  1053. if (IS_ERR(reg)) {
  1054. pr_err("%pOF: Could not map the clock registers\n", node);
  1055. return;
  1056. }
  1057. /* Force the PLL-Audio-1x divider to 1 */
  1058. val = readl(reg + SUN8I_H3_PLL_AUDIO_REG);
  1059. val &= ~GENMASK(19, 16);
  1060. writel(val | (0 << 16), reg + SUN8I_H3_PLL_AUDIO_REG);
  1061. sunxi_ccu_probe(node, reg, desc);
  1062. /* Gate then ungate PLL CPU after any rate changes */
  1063. ccu_pll_notifier_register(&sun8i_h3_pll_cpu_nb);
  1064. /* Reparent CPU during PLL CPU rate changes */
  1065. ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
  1066. &sun8i_h3_cpu_nb);
  1067. }
  1068. static void __init sun8i_h3_ccu_setup(struct device_node *node)
  1069. {
  1070. sunxi_h3_h5_ccu_init(node, &sun8i_h3_ccu_desc);
  1071. }
  1072. CLK_OF_DECLARE(sun8i_h3_ccu, "allwinner,sun8i-h3-ccu",
  1073. sun8i_h3_ccu_setup);
  1074. static void __init sun50i_h5_ccu_setup(struct device_node *node)
  1075. {
  1076. sunxi_h3_h5_ccu_init(node, &sun50i_h5_ccu_desc);
  1077. }
  1078. CLK_OF_DECLARE(sun50i_h5_ccu, "allwinner,sun50i-h5-ccu",
  1079. sun50i_h5_ccu_setup);