ccu-sun50i-a64.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  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 <linux/platform_device.h>
  16. #include "ccu_common.h"
  17. #include "ccu_reset.h"
  18. #include "ccu_div.h"
  19. #include "ccu_gate.h"
  20. #include "ccu_mp.h"
  21. #include "ccu_mult.h"
  22. #include "ccu_nk.h"
  23. #include "ccu_nkm.h"
  24. #include "ccu_nkmp.h"
  25. #include "ccu_nm.h"
  26. #include "ccu_phase.h"
  27. #include "ccu-sun50i-a64.h"
  28. static struct ccu_nkmp pll_cpux_clk = {
  29. .enable = BIT(31),
  30. .lock = BIT(28),
  31. .n = _SUNXI_CCU_MULT(8, 5),
  32. .k = _SUNXI_CCU_MULT(4, 2),
  33. .m = _SUNXI_CCU_DIV(0, 2),
  34. .p = _SUNXI_CCU_DIV_MAX(16, 2, 4),
  35. .common = {
  36. .reg = 0x000,
  37. .hw.init = CLK_HW_INIT("pll-cpux",
  38. "osc24M",
  39. &ccu_nkmp_ops,
  40. CLK_SET_RATE_UNGATE),
  41. },
  42. };
  43. /*
  44. * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
  45. * the base (2x, 4x and 8x), and one variable divider (the one true
  46. * pll audio).
  47. *
  48. * We don't have any need for the variable divider for now, so we just
  49. * hardcode it to match with the clock names
  50. */
  51. #define SUN50I_A64_PLL_AUDIO_REG 0x008
  52. static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
  53. "osc24M", 0x008,
  54. 8, 7, /* N */
  55. 0, 5, /* M */
  56. BIT(31), /* gate */
  57. BIT(28), /* lock */
  58. CLK_SET_RATE_UNGATE);
  59. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video0_clk, "pll-video0",
  60. "osc24M", 0x010,
  61. 8, 7, /* N */
  62. 0, 4, /* M */
  63. BIT(24), /* frac enable */
  64. BIT(25), /* frac select */
  65. 270000000, /* frac rate 0 */
  66. 297000000, /* frac rate 1 */
  67. BIT(31), /* gate */
  68. BIT(28), /* lock */
  69. CLK_SET_RATE_UNGATE);
  70. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
  71. "osc24M", 0x018,
  72. 8, 7, /* N */
  73. 0, 4, /* M */
  74. BIT(24), /* frac enable */
  75. BIT(25), /* frac select */
  76. 270000000, /* frac rate 0 */
  77. 297000000, /* frac rate 1 */
  78. BIT(31), /* gate */
  79. BIT(28), /* lock */
  80. CLK_SET_RATE_UNGATE);
  81. static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0",
  82. "osc24M", 0x020,
  83. 8, 5, /* N */
  84. 4, 2, /* K */
  85. 0, 2, /* M */
  86. BIT(31), /* gate */
  87. BIT(28), /* lock */
  88. CLK_SET_RATE_UNGATE);
  89. static struct ccu_nk pll_periph0_clk = {
  90. .enable = BIT(31),
  91. .lock = BIT(28),
  92. .n = _SUNXI_CCU_MULT(8, 5),
  93. .k = _SUNXI_CCU_MULT_MIN(4, 2, 2),
  94. .fixed_post_div = 2,
  95. .common = {
  96. .reg = 0x028,
  97. .features = CCU_FEATURE_FIXED_POSTDIV,
  98. .hw.init = CLK_HW_INIT("pll-periph0", "osc24M",
  99. &ccu_nk_ops, CLK_SET_RATE_UNGATE),
  100. },
  101. };
  102. static struct ccu_nk pll_periph1_clk = {
  103. .enable = BIT(31),
  104. .lock = BIT(28),
  105. .n = _SUNXI_CCU_MULT(8, 5),
  106. .k = _SUNXI_CCU_MULT_MIN(4, 2, 2),
  107. .fixed_post_div = 2,
  108. .common = {
  109. .reg = 0x02c,
  110. .features = CCU_FEATURE_FIXED_POSTDIV,
  111. .hw.init = CLK_HW_INIT("pll-periph1", "osc24M",
  112. &ccu_nk_ops, CLK_SET_RATE_UNGATE),
  113. },
  114. };
  115. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video1_clk, "pll-video1",
  116. "osc24M", 0x030,
  117. 8, 7, /* N */
  118. 0, 4, /* M */
  119. BIT(24), /* frac enable */
  120. BIT(25), /* frac select */
  121. 270000000, /* frac rate 0 */
  122. 297000000, /* frac rate 1 */
  123. BIT(31), /* gate */
  124. BIT(28), /* lock */
  125. CLK_SET_RATE_UNGATE);
  126. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
  127. "osc24M", 0x038,
  128. 8, 7, /* N */
  129. 0, 4, /* M */
  130. BIT(24), /* frac enable */
  131. BIT(25), /* frac select */
  132. 270000000, /* frac rate 0 */
  133. 297000000, /* frac rate 1 */
  134. BIT(31), /* gate */
  135. BIT(28), /* lock */
  136. CLK_SET_RATE_UNGATE);
  137. /*
  138. * The output function can be changed to something more complex that
  139. * we do not handle yet.
  140. *
  141. * Hardcode the mode so that we don't fall in that case.
  142. */
  143. #define SUN50I_A64_PLL_MIPI_REG 0x040
  144. static struct ccu_nkm pll_mipi_clk = {
  145. .enable = BIT(31),
  146. .lock = BIT(28),
  147. .n = _SUNXI_CCU_MULT(8, 4),
  148. .k = _SUNXI_CCU_MULT_MIN(4, 2, 2),
  149. .m = _SUNXI_CCU_DIV(0, 4),
  150. .common = {
  151. .reg = 0x040,
  152. .hw.init = CLK_HW_INIT("pll-mipi", "pll-video0",
  153. &ccu_nkm_ops, CLK_SET_RATE_UNGATE),
  154. },
  155. };
  156. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_hsic_clk, "pll-hsic",
  157. "osc24M", 0x044,
  158. 8, 7, /* N */
  159. 0, 4, /* M */
  160. BIT(24), /* frac enable */
  161. BIT(25), /* frac select */
  162. 270000000, /* frac rate 0 */
  163. 297000000, /* frac rate 1 */
  164. BIT(31), /* gate */
  165. BIT(28), /* lock */
  166. CLK_SET_RATE_UNGATE);
  167. static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
  168. "osc24M", 0x048,
  169. 8, 7, /* N */
  170. 0, 4, /* M */
  171. BIT(24), /* frac enable */
  172. BIT(25), /* frac select */
  173. 270000000, /* frac rate 0 */
  174. 297000000, /* frac rate 1 */
  175. BIT(31), /* gate */
  176. BIT(28), /* lock */
  177. CLK_SET_RATE_UNGATE);
  178. static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1",
  179. "osc24M", 0x04c,
  180. 8, 7, /* N */
  181. 0, 2, /* M */
  182. BIT(31), /* gate */
  183. BIT(28), /* lock */
  184. CLK_SET_RATE_UNGATE);
  185. static const char * const cpux_parents[] = { "osc32k", "osc24M",
  186. "pll-cpux", "pll-cpux" };
  187. static SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
  188. 0x050, 16, 2, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL);
  189. static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
  190. static const char * const ahb1_parents[] = { "osc32k", "osc24M",
  191. "axi", "pll-periph0" };
  192. static struct ccu_div ahb1_clk = {
  193. .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
  194. .mux = {
  195. .shift = 12,
  196. .width = 2,
  197. .variable_prediv = {
  198. .index = 3,
  199. .shift = 6,
  200. .width = 2,
  201. },
  202. },
  203. .common = {
  204. .reg = 0x054,
  205. .features = CCU_FEATURE_VARIABLE_PREDIV,
  206. .hw.init = CLK_HW_INIT_PARENTS("ahb1",
  207. ahb1_parents,
  208. &ccu_div_ops,
  209. 0),
  210. },
  211. };
  212. static struct clk_div_table apb1_div_table[] = {
  213. { .val = 0, .div = 2 },
  214. { .val = 1, .div = 2 },
  215. { .val = 2, .div = 4 },
  216. { .val = 3, .div = 8 },
  217. { /* Sentinel */ },
  218. };
  219. static SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
  220. 0x054, 8, 2, apb1_div_table, 0);
  221. static const char * const apb2_parents[] = { "osc32k", "osc24M",
  222. "pll-periph0-2x",
  223. "pll-periph0-2x" };
  224. static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
  225. 0, 5, /* M */
  226. 16, 2, /* P */
  227. 24, 2, /* mux */
  228. 0);
  229. static const char * const ahb2_parents[] = { "ahb1", "pll-periph0" };
  230. static const struct ccu_mux_fixed_prediv ahb2_fixed_predivs[] = {
  231. { .index = 1, .div = 2 },
  232. };
  233. static struct ccu_mux ahb2_clk = {
  234. .mux = {
  235. .shift = 0,
  236. .width = 1,
  237. .fixed_predivs = ahb2_fixed_predivs,
  238. .n_predivs = ARRAY_SIZE(ahb2_fixed_predivs),
  239. },
  240. .common = {
  241. .reg = 0x05c,
  242. .features = CCU_FEATURE_FIXED_PREDIV,
  243. .hw.init = CLK_HW_INIT_PARENTS("ahb2",
  244. ahb2_parents,
  245. &ccu_mux_ops,
  246. 0),
  247. },
  248. };
  249. static SUNXI_CCU_GATE(bus_mipi_dsi_clk, "bus-mipi-dsi", "ahb1",
  250. 0x060, BIT(1), 0);
  251. static SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "ahb1",
  252. 0x060, BIT(5), 0);
  253. static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1",
  254. 0x060, BIT(6), 0);
  255. static SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1",
  256. 0x060, BIT(8), 0);
  257. static SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1",
  258. 0x060, BIT(9), 0);
  259. static SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1",
  260. 0x060, BIT(10), 0);
  261. static SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb1",
  262. 0x060, BIT(13), 0);
  263. static SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1",
  264. 0x060, BIT(14), 0);
  265. static SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb2",
  266. 0x060, BIT(17), 0);
  267. static SUNXI_CCU_GATE(bus_ts_clk, "bus-ts", "ahb1",
  268. 0x060, BIT(18), 0);
  269. static SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1",
  270. 0x060, BIT(19), 0);
  271. static SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1",
  272. 0x060, BIT(20), 0);
  273. static SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb1",
  274. 0x060, BIT(21), 0);
  275. static SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1",
  276. 0x060, BIT(23), 0);
  277. static SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb1",
  278. 0x060, BIT(24), 0);
  279. static SUNXI_CCU_GATE(bus_ehci1_clk, "bus-ehci1", "ahb2",
  280. 0x060, BIT(25), 0);
  281. static SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb1",
  282. 0x060, BIT(28), 0);
  283. static SUNXI_CCU_GATE(bus_ohci1_clk, "bus-ohci1", "ahb2",
  284. 0x060, BIT(29), 0);
  285. static SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1",
  286. 0x064, BIT(0), 0);
  287. static SUNXI_CCU_GATE(bus_tcon0_clk, "bus-tcon0", "ahb1",
  288. 0x064, BIT(3), 0);
  289. static SUNXI_CCU_GATE(bus_tcon1_clk, "bus-tcon1", "ahb1",
  290. 0x064, BIT(4), 0);
  291. static SUNXI_CCU_GATE(bus_deinterlace_clk, "bus-deinterlace", "ahb1",
  292. 0x064, BIT(5), 0);
  293. static SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb1",
  294. 0x064, BIT(8), 0);
  295. static SUNXI_CCU_GATE(bus_hdmi_clk, "bus-hdmi", "ahb1",
  296. 0x064, BIT(11), 0);
  297. static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1",
  298. 0x064, BIT(12), 0);
  299. static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1",
  300. 0x064, BIT(20), 0);
  301. static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1",
  302. 0x064, BIT(21), 0);
  303. static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1",
  304. 0x064, BIT(22), 0);
  305. static SUNXI_CCU_GATE(bus_codec_clk, "bus-codec", "apb1",
  306. 0x068, BIT(0), 0);
  307. static SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb1",
  308. 0x068, BIT(1), 0);
  309. static SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1",
  310. 0x068, BIT(5), 0);
  311. static SUNXI_CCU_GATE(bus_ths_clk, "bus-ths", "apb1",
  312. 0x068, BIT(8), 0);
  313. static SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1",
  314. 0x068, BIT(12), 0);
  315. static SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1",
  316. 0x068, BIT(13), 0);
  317. static SUNXI_CCU_GATE(bus_i2s2_clk, "bus-i2s2", "apb1",
  318. 0x068, BIT(14), 0);
  319. static SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2",
  320. 0x06c, BIT(0), 0);
  321. static SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2",
  322. 0x06c, BIT(1), 0);
  323. static SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2",
  324. 0x06c, BIT(2), 0);
  325. static SUNXI_CCU_GATE(bus_scr_clk, "bus-scr", "apb2",
  326. 0x06c, BIT(5), 0);
  327. static SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2",
  328. 0x06c, BIT(16), 0);
  329. static SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2",
  330. 0x06c, BIT(17), 0);
  331. static SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2",
  332. 0x06c, BIT(18), 0);
  333. static SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2",
  334. 0x06c, BIT(19), 0);
  335. static SUNXI_CCU_GATE(bus_uart4_clk, "bus-uart4", "apb2",
  336. 0x06c, BIT(20), 0);
  337. static SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "ahb1",
  338. 0x070, BIT(7), 0);
  339. static struct clk_div_table ths_div_table[] = {
  340. { .val = 0, .div = 1 },
  341. { .val = 1, .div = 2 },
  342. { .val = 2, .div = 4 },
  343. { .val = 3, .div = 6 },
  344. };
  345. static const char * const ths_parents[] = { "osc24M" };
  346. static struct ccu_div ths_clk = {
  347. .enable = BIT(31),
  348. .div = _SUNXI_CCU_DIV_TABLE(0, 2, ths_div_table),
  349. .mux = _SUNXI_CCU_MUX(24, 2),
  350. .common = {
  351. .reg = 0x074,
  352. .hw.init = CLK_HW_INIT_PARENTS("ths",
  353. ths_parents,
  354. &ccu_div_ops,
  355. 0),
  356. },
  357. };
  358. static const char * const mod0_default_parents[] = { "osc24M", "pll-periph0",
  359. "pll-periph1" };
  360. static SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
  361. 0, 4, /* M */
  362. 16, 2, /* P */
  363. 24, 2, /* mux */
  364. BIT(31), /* gate */
  365. 0);
  366. static const char * const mmc_default_parents[] = { "osc24M", "pll-periph0-2x",
  367. "pll-periph1-2x" };
  368. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mmc_default_parents, 0x088,
  369. 0, 4, /* M */
  370. 16, 2, /* P */
  371. 24, 2, /* mux */
  372. BIT(31), /* gate */
  373. 0);
  374. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mmc_default_parents, 0x08c,
  375. 0, 4, /* M */
  376. 16, 2, /* P */
  377. 24, 2, /* mux */
  378. BIT(31), /* gate */
  379. 0);
  380. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mmc_default_parents, 0x090,
  381. 0, 4, /* M */
  382. 16, 2, /* P */
  383. 24, 2, /* mux */
  384. BIT(31), /* gate */
  385. 0);
  386. static const char * const ts_parents[] = { "osc24M", "pll-periph0", };
  387. static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098,
  388. 0, 4, /* M */
  389. 16, 2, /* P */
  390. 24, 4, /* mux */
  391. BIT(31), /* gate */
  392. 0);
  393. static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", mmc_default_parents, 0x09c,
  394. 0, 4, /* M */
  395. 16, 2, /* P */
  396. 24, 2, /* mux */
  397. BIT(31), /* gate */
  398. 0);
  399. static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
  400. 0, 4, /* M */
  401. 16, 2, /* P */
  402. 24, 2, /* mux */
  403. BIT(31), /* gate */
  404. 0);
  405. static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
  406. 0, 4, /* M */
  407. 16, 2, /* P */
  408. 24, 2, /* mux */
  409. BIT(31), /* gate */
  410. 0);
  411. static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
  412. "pll-audio-2x", "pll-audio" };
  413. static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
  414. 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  415. static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
  416. 0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  417. static SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents,
  418. 0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  419. static SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio",
  420. 0x0c0, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  421. static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M",
  422. 0x0cc, BIT(8), 0);
  423. static SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "osc24M",
  424. 0x0cc, BIT(9), 0);
  425. static SUNXI_CCU_GATE(usb_hsic_clk, "usb-hsic", "pll-hsic",
  426. 0x0cc, BIT(10), 0);
  427. static SUNXI_CCU_GATE(usb_hsic_12m_clk, "usb-hsic-12M", "osc12M",
  428. 0x0cc, BIT(11), 0);
  429. static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc12M",
  430. 0x0cc, BIT(16), 0);
  431. static SUNXI_CCU_GATE(usb_ohci1_clk, "usb-ohci1", "usb-ohci0",
  432. 0x0cc, BIT(17), 0);
  433. static const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1" };
  434. static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
  435. 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL);
  436. static SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram",
  437. 0x100, BIT(0), 0);
  438. static SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "dram",
  439. 0x100, BIT(1), 0);
  440. static SUNXI_CCU_GATE(dram_deinterlace_clk, "dram-deinterlace", "dram",
  441. 0x100, BIT(2), 0);
  442. static SUNXI_CCU_GATE(dram_ts_clk, "dram-ts", "dram",
  443. 0x100, BIT(3), 0);
  444. static const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
  445. static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
  446. 0x104, 0, 4, 24, 3, BIT(31), 0);
  447. static const char * const tcon0_parents[] = { "pll-mipi", "pll-video0-2x" };
  448. static const u8 tcon0_table[] = { 0, 2, };
  449. static SUNXI_CCU_MUX_TABLE_WITH_GATE(tcon0_clk, "tcon0", tcon0_parents,
  450. tcon0_table, 0x118, 24, 3, BIT(31),
  451. CLK_SET_RATE_PARENT);
  452. static const char * const tcon1_parents[] = { "pll-video0", "pll-video1" };
  453. static const u8 tcon1_table[] = { 0, 2, };
  454. static struct ccu_div tcon1_clk = {
  455. .enable = BIT(31),
  456. .div = _SUNXI_CCU_DIV(0, 4),
  457. .mux = _SUNXI_CCU_MUX_TABLE(24, 2, tcon1_table),
  458. .common = {
  459. .reg = 0x11c,
  460. .hw.init = CLK_HW_INIT_PARENTS("tcon1",
  461. tcon1_parents,
  462. &ccu_div_ops,
  463. CLK_SET_RATE_PARENT),
  464. },
  465. };
  466. static const char * const deinterlace_parents[] = { "pll-periph0", "pll-periph1" };
  467. static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace", deinterlace_parents,
  468. 0x124, 0, 4, 24, 3, BIT(31), 0);
  469. static SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M",
  470. 0x130, BIT(31), 0);
  471. static const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
  472. static SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
  473. 0x134, 16, 4, 24, 3, BIT(31), 0);
  474. static const char * const csi_mclk_parents[] = { "osc24M", "pll-video1", "pll-periph1" };
  475. static SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk, "csi-mclk", csi_mclk_parents,
  476. 0x134, 0, 5, 8, 3, BIT(15), 0);
  477. static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
  478. 0x13c, 16, 3, BIT(31), 0);
  479. static SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio",
  480. 0x140, BIT(31), CLK_SET_RATE_PARENT);
  481. static SUNXI_CCU_GATE(ac_dig_4x_clk, "ac-dig-4x", "pll-audio-4x",
  482. 0x140, BIT(30), CLK_SET_RATE_PARENT);
  483. static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M",
  484. 0x144, BIT(31), 0);
  485. static const char * const hdmi_parents[] = { "pll-video0", "pll-video1" };
  486. static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
  487. 0x150, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
  488. static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M",
  489. 0x154, BIT(31), 0);
  490. static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x",
  491. "pll-ddr0", "pll-ddr1" };
  492. static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
  493. 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);
  494. static const char * const dsi_dphy_parents[] = { "pll-video0", "pll-periph0" };
  495. static const u8 dsi_dphy_table[] = { 0, 2, };
  496. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(dsi_dphy_clk, "dsi-dphy",
  497. dsi_dphy_parents, dsi_dphy_table,
  498. 0x168, 0, 4, 8, 2, BIT(31), CLK_SET_RATE_PARENT);
  499. static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
  500. 0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);
  501. /* Fixed Factor clocks */
  502. static CLK_FIXED_FACTOR(osc12M_clk, "osc12M", "osc24M", 2, 1, 0);
  503. /* We hardcode the divider to 4 for now */
  504. static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",
  505. "pll-audio-base", 4, 1, CLK_SET_RATE_PARENT);
  506. static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x",
  507. "pll-audio-base", 2, 1, CLK_SET_RATE_PARENT);
  508. static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x",
  509. "pll-audio-base", 1, 1, CLK_SET_RATE_PARENT);
  510. static CLK_FIXED_FACTOR(pll_audio_8x_clk, "pll-audio-8x",
  511. "pll-audio-base", 1, 2, CLK_SET_RATE_PARENT);
  512. static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x",
  513. "pll-periph0", 1, 2, 0);
  514. static CLK_FIXED_FACTOR(pll_periph1_2x_clk, "pll-periph1-2x",
  515. "pll-periph1", 1, 2, 0);
  516. static CLK_FIXED_FACTOR(pll_video0_2x_clk, "pll-video0-2x",
  517. "pll-video0", 1, 2, CLK_SET_RATE_PARENT);
  518. static struct ccu_common *sun50i_a64_ccu_clks[] = {
  519. &pll_cpux_clk.common,
  520. &pll_audio_base_clk.common,
  521. &pll_video0_clk.common,
  522. &pll_ve_clk.common,
  523. &pll_ddr0_clk.common,
  524. &pll_periph0_clk.common,
  525. &pll_periph1_clk.common,
  526. &pll_video1_clk.common,
  527. &pll_gpu_clk.common,
  528. &pll_mipi_clk.common,
  529. &pll_hsic_clk.common,
  530. &pll_de_clk.common,
  531. &pll_ddr1_clk.common,
  532. &cpux_clk.common,
  533. &axi_clk.common,
  534. &ahb1_clk.common,
  535. &apb1_clk.common,
  536. &apb2_clk.common,
  537. &ahb2_clk.common,
  538. &bus_mipi_dsi_clk.common,
  539. &bus_ce_clk.common,
  540. &bus_dma_clk.common,
  541. &bus_mmc0_clk.common,
  542. &bus_mmc1_clk.common,
  543. &bus_mmc2_clk.common,
  544. &bus_nand_clk.common,
  545. &bus_dram_clk.common,
  546. &bus_emac_clk.common,
  547. &bus_ts_clk.common,
  548. &bus_hstimer_clk.common,
  549. &bus_spi0_clk.common,
  550. &bus_spi1_clk.common,
  551. &bus_otg_clk.common,
  552. &bus_ehci0_clk.common,
  553. &bus_ehci1_clk.common,
  554. &bus_ohci0_clk.common,
  555. &bus_ohci1_clk.common,
  556. &bus_ve_clk.common,
  557. &bus_tcon0_clk.common,
  558. &bus_tcon1_clk.common,
  559. &bus_deinterlace_clk.common,
  560. &bus_csi_clk.common,
  561. &bus_hdmi_clk.common,
  562. &bus_de_clk.common,
  563. &bus_gpu_clk.common,
  564. &bus_msgbox_clk.common,
  565. &bus_spinlock_clk.common,
  566. &bus_codec_clk.common,
  567. &bus_spdif_clk.common,
  568. &bus_pio_clk.common,
  569. &bus_ths_clk.common,
  570. &bus_i2s0_clk.common,
  571. &bus_i2s1_clk.common,
  572. &bus_i2s2_clk.common,
  573. &bus_i2c0_clk.common,
  574. &bus_i2c1_clk.common,
  575. &bus_i2c2_clk.common,
  576. &bus_scr_clk.common,
  577. &bus_uart0_clk.common,
  578. &bus_uart1_clk.common,
  579. &bus_uart2_clk.common,
  580. &bus_uart3_clk.common,
  581. &bus_uart4_clk.common,
  582. &bus_dbg_clk.common,
  583. &ths_clk.common,
  584. &nand_clk.common,
  585. &mmc0_clk.common,
  586. &mmc1_clk.common,
  587. &mmc2_clk.common,
  588. &ts_clk.common,
  589. &ce_clk.common,
  590. &spi0_clk.common,
  591. &spi1_clk.common,
  592. &i2s0_clk.common,
  593. &i2s1_clk.common,
  594. &i2s2_clk.common,
  595. &spdif_clk.common,
  596. &usb_phy0_clk.common,
  597. &usb_phy1_clk.common,
  598. &usb_hsic_clk.common,
  599. &usb_hsic_12m_clk.common,
  600. &usb_ohci0_clk.common,
  601. &usb_ohci1_clk.common,
  602. &dram_clk.common,
  603. &dram_ve_clk.common,
  604. &dram_csi_clk.common,
  605. &dram_deinterlace_clk.common,
  606. &dram_ts_clk.common,
  607. &de_clk.common,
  608. &tcon0_clk.common,
  609. &tcon1_clk.common,
  610. &deinterlace_clk.common,
  611. &csi_misc_clk.common,
  612. &csi_sclk_clk.common,
  613. &csi_mclk_clk.common,
  614. &ve_clk.common,
  615. &ac_dig_clk.common,
  616. &ac_dig_4x_clk.common,
  617. &avs_clk.common,
  618. &hdmi_clk.common,
  619. &hdmi_ddc_clk.common,
  620. &mbus_clk.common,
  621. &dsi_dphy_clk.common,
  622. &gpu_clk.common,
  623. };
  624. static struct clk_hw_onecell_data sun50i_a64_hw_clks = {
  625. .hws = {
  626. [CLK_OSC_12M] = &osc12M_clk.hw,
  627. [CLK_PLL_CPUX] = &pll_cpux_clk.common.hw,
  628. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  629. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  630. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  631. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  632. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  633. [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw,
  634. [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw,
  635. [CLK_PLL_VE] = &pll_ve_clk.common.hw,
  636. [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw,
  637. [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw,
  638. [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw,
  639. [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw,
  640. [CLK_PLL_PERIPH1_2X] = &pll_periph1_2x_clk.hw,
  641. [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw,
  642. [CLK_PLL_GPU] = &pll_gpu_clk.common.hw,
  643. [CLK_PLL_MIPI] = &pll_mipi_clk.common.hw,
  644. [CLK_PLL_HSIC] = &pll_hsic_clk.common.hw,
  645. [CLK_PLL_DE] = &pll_de_clk.common.hw,
  646. [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw,
  647. [CLK_CPUX] = &cpux_clk.common.hw,
  648. [CLK_AXI] = &axi_clk.common.hw,
  649. [CLK_AHB1] = &ahb1_clk.common.hw,
  650. [CLK_APB1] = &apb1_clk.common.hw,
  651. [CLK_APB2] = &apb2_clk.common.hw,
  652. [CLK_AHB2] = &ahb2_clk.common.hw,
  653. [CLK_BUS_MIPI_DSI] = &bus_mipi_dsi_clk.common.hw,
  654. [CLK_BUS_CE] = &bus_ce_clk.common.hw,
  655. [CLK_BUS_DMA] = &bus_dma_clk.common.hw,
  656. [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw,
  657. [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw,
  658. [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw,
  659. [CLK_BUS_NAND] = &bus_nand_clk.common.hw,
  660. [CLK_BUS_DRAM] = &bus_dram_clk.common.hw,
  661. [CLK_BUS_EMAC] = &bus_emac_clk.common.hw,
  662. [CLK_BUS_TS] = &bus_ts_clk.common.hw,
  663. [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw,
  664. [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw,
  665. [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw,
  666. [CLK_BUS_OTG] = &bus_otg_clk.common.hw,
  667. [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw,
  668. [CLK_BUS_EHCI1] = &bus_ehci1_clk.common.hw,
  669. [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw,
  670. [CLK_BUS_OHCI1] = &bus_ohci1_clk.common.hw,
  671. [CLK_BUS_VE] = &bus_ve_clk.common.hw,
  672. [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw,
  673. [CLK_BUS_TCON1] = &bus_tcon1_clk.common.hw,
  674. [CLK_BUS_DEINTERLACE] = &bus_deinterlace_clk.common.hw,
  675. [CLK_BUS_CSI] = &bus_csi_clk.common.hw,
  676. [CLK_BUS_HDMI] = &bus_hdmi_clk.common.hw,
  677. [CLK_BUS_DE] = &bus_de_clk.common.hw,
  678. [CLK_BUS_GPU] = &bus_gpu_clk.common.hw,
  679. [CLK_BUS_MSGBOX] = &bus_msgbox_clk.common.hw,
  680. [CLK_BUS_SPINLOCK] = &bus_spinlock_clk.common.hw,
  681. [CLK_BUS_CODEC] = &bus_codec_clk.common.hw,
  682. [CLK_BUS_SPDIF] = &bus_spdif_clk.common.hw,
  683. [CLK_BUS_PIO] = &bus_pio_clk.common.hw,
  684. [CLK_BUS_THS] = &bus_ths_clk.common.hw,
  685. [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw,
  686. [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw,
  687. [CLK_BUS_I2S2] = &bus_i2s2_clk.common.hw,
  688. [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw,
  689. [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw,
  690. [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw,
  691. [CLK_BUS_UART0] = &bus_uart0_clk.common.hw,
  692. [CLK_BUS_UART1] = &bus_uart1_clk.common.hw,
  693. [CLK_BUS_UART2] = &bus_uart2_clk.common.hw,
  694. [CLK_BUS_UART3] = &bus_uart3_clk.common.hw,
  695. [CLK_BUS_UART4] = &bus_uart4_clk.common.hw,
  696. [CLK_BUS_SCR] = &bus_scr_clk.common.hw,
  697. [CLK_BUS_DBG] = &bus_dbg_clk.common.hw,
  698. [CLK_THS] = &ths_clk.common.hw,
  699. [CLK_NAND] = &nand_clk.common.hw,
  700. [CLK_MMC0] = &mmc0_clk.common.hw,
  701. [CLK_MMC1] = &mmc1_clk.common.hw,
  702. [CLK_MMC2] = &mmc2_clk.common.hw,
  703. [CLK_TS] = &ts_clk.common.hw,
  704. [CLK_CE] = &ce_clk.common.hw,
  705. [CLK_SPI0] = &spi0_clk.common.hw,
  706. [CLK_SPI1] = &spi1_clk.common.hw,
  707. [CLK_I2S0] = &i2s0_clk.common.hw,
  708. [CLK_I2S1] = &i2s1_clk.common.hw,
  709. [CLK_I2S2] = &i2s2_clk.common.hw,
  710. [CLK_SPDIF] = &spdif_clk.common.hw,
  711. [CLK_USB_PHY0] = &usb_phy0_clk.common.hw,
  712. [CLK_USB_PHY1] = &usb_phy1_clk.common.hw,
  713. [CLK_USB_HSIC] = &usb_hsic_clk.common.hw,
  714. [CLK_USB_HSIC_12M] = &usb_hsic_12m_clk.common.hw,
  715. [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw,
  716. [CLK_USB_OHCI1] = &usb_ohci1_clk.common.hw,
  717. [CLK_DRAM] = &dram_clk.common.hw,
  718. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  719. [CLK_DRAM_CSI] = &dram_csi_clk.common.hw,
  720. [CLK_DRAM_DEINTERLACE] = &dram_deinterlace_clk.common.hw,
  721. [CLK_DRAM_TS] = &dram_ts_clk.common.hw,
  722. [CLK_DE] = &de_clk.common.hw,
  723. [CLK_TCON0] = &tcon0_clk.common.hw,
  724. [CLK_TCON1] = &tcon1_clk.common.hw,
  725. [CLK_DEINTERLACE] = &deinterlace_clk.common.hw,
  726. [CLK_CSI_MISC] = &csi_misc_clk.common.hw,
  727. [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw,
  728. [CLK_CSI_MCLK] = &csi_mclk_clk.common.hw,
  729. [CLK_VE] = &ve_clk.common.hw,
  730. [CLK_AC_DIG] = &ac_dig_clk.common.hw,
  731. [CLK_AC_DIG_4X] = &ac_dig_4x_clk.common.hw,
  732. [CLK_AVS] = &avs_clk.common.hw,
  733. [CLK_HDMI] = &hdmi_clk.common.hw,
  734. [CLK_HDMI_DDC] = &hdmi_ddc_clk.common.hw,
  735. [CLK_MBUS] = &mbus_clk.common.hw,
  736. [CLK_DSI_DPHY] = &dsi_dphy_clk.common.hw,
  737. [CLK_GPU] = &gpu_clk.common.hw,
  738. },
  739. .num = CLK_NUMBER,
  740. };
  741. static struct ccu_reset_map sun50i_a64_ccu_resets[] = {
  742. [RST_USB_PHY0] = { 0x0cc, BIT(0) },
  743. [RST_USB_PHY1] = { 0x0cc, BIT(1) },
  744. [RST_USB_HSIC] = { 0x0cc, BIT(2) },
  745. [RST_DRAM] = { 0x0f4, BIT(31) },
  746. [RST_MBUS] = { 0x0fc, BIT(31) },
  747. [RST_BUS_MIPI_DSI] = { 0x2c0, BIT(1) },
  748. [RST_BUS_CE] = { 0x2c0, BIT(5) },
  749. [RST_BUS_DMA] = { 0x2c0, BIT(6) },
  750. [RST_BUS_MMC0] = { 0x2c0, BIT(8) },
  751. [RST_BUS_MMC1] = { 0x2c0, BIT(9) },
  752. [RST_BUS_MMC2] = { 0x2c0, BIT(10) },
  753. [RST_BUS_NAND] = { 0x2c0, BIT(13) },
  754. [RST_BUS_DRAM] = { 0x2c0, BIT(14) },
  755. [RST_BUS_EMAC] = { 0x2c0, BIT(17) },
  756. [RST_BUS_TS] = { 0x2c0, BIT(18) },
  757. [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) },
  758. [RST_BUS_SPI0] = { 0x2c0, BIT(20) },
  759. [RST_BUS_SPI1] = { 0x2c0, BIT(21) },
  760. [RST_BUS_OTG] = { 0x2c0, BIT(23) },
  761. [RST_BUS_EHCI0] = { 0x2c0, BIT(24) },
  762. [RST_BUS_EHCI1] = { 0x2c0, BIT(25) },
  763. [RST_BUS_OHCI0] = { 0x2c0, BIT(28) },
  764. [RST_BUS_OHCI1] = { 0x2c0, BIT(29) },
  765. [RST_BUS_VE] = { 0x2c4, BIT(0) },
  766. [RST_BUS_TCON0] = { 0x2c4, BIT(3) },
  767. [RST_BUS_TCON1] = { 0x2c4, BIT(4) },
  768. [RST_BUS_DEINTERLACE] = { 0x2c4, BIT(5) },
  769. [RST_BUS_CSI] = { 0x2c4, BIT(8) },
  770. [RST_BUS_HDMI0] = { 0x2c4, BIT(10) },
  771. [RST_BUS_HDMI1] = { 0x2c4, BIT(11) },
  772. [RST_BUS_DE] = { 0x2c4, BIT(12) },
  773. [RST_BUS_GPU] = { 0x2c4, BIT(20) },
  774. [RST_BUS_MSGBOX] = { 0x2c4, BIT(21) },
  775. [RST_BUS_SPINLOCK] = { 0x2c4, BIT(22) },
  776. [RST_BUS_DBG] = { 0x2c4, BIT(31) },
  777. [RST_BUS_LVDS] = { 0x2c8, BIT(0) },
  778. [RST_BUS_CODEC] = { 0x2d0, BIT(0) },
  779. [RST_BUS_SPDIF] = { 0x2d0, BIT(1) },
  780. [RST_BUS_THS] = { 0x2d0, BIT(8) },
  781. [RST_BUS_I2S0] = { 0x2d0, BIT(12) },
  782. [RST_BUS_I2S1] = { 0x2d0, BIT(13) },
  783. [RST_BUS_I2S2] = { 0x2d0, BIT(14) },
  784. [RST_BUS_I2C0] = { 0x2d8, BIT(0) },
  785. [RST_BUS_I2C1] = { 0x2d8, BIT(1) },
  786. [RST_BUS_I2C2] = { 0x2d8, BIT(2) },
  787. [RST_BUS_SCR] = { 0x2d8, BIT(5) },
  788. [RST_BUS_UART0] = { 0x2d8, BIT(16) },
  789. [RST_BUS_UART1] = { 0x2d8, BIT(17) },
  790. [RST_BUS_UART2] = { 0x2d8, BIT(18) },
  791. [RST_BUS_UART3] = { 0x2d8, BIT(19) },
  792. [RST_BUS_UART4] = { 0x2d8, BIT(20) },
  793. };
  794. static const struct sunxi_ccu_desc sun50i_a64_ccu_desc = {
  795. .ccu_clks = sun50i_a64_ccu_clks,
  796. .num_ccu_clks = ARRAY_SIZE(sun50i_a64_ccu_clks),
  797. .hw_clks = &sun50i_a64_hw_clks,
  798. .resets = sun50i_a64_ccu_resets,
  799. .num_resets = ARRAY_SIZE(sun50i_a64_ccu_resets),
  800. };
  801. static int sun50i_a64_ccu_probe(struct platform_device *pdev)
  802. {
  803. struct resource *res;
  804. void __iomem *reg;
  805. u32 val;
  806. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  807. reg = devm_ioremap_resource(&pdev->dev, res);
  808. if (IS_ERR(reg))
  809. return PTR_ERR(reg);
  810. /* Force the PLL-Audio-1x divider to 4 */
  811. val = readl(reg + SUN50I_A64_PLL_AUDIO_REG);
  812. val &= ~GENMASK(19, 16);
  813. writel(val | (3 << 16), reg + SUN50I_A64_PLL_AUDIO_REG);
  814. writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG);
  815. return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc);
  816. }
  817. static const struct of_device_id sun50i_a64_ccu_ids[] = {
  818. { .compatible = "allwinner,sun50i-a64-ccu" },
  819. { }
  820. };
  821. static struct platform_driver sun50i_a64_ccu_driver = {
  822. .probe = sun50i_a64_ccu_probe,
  823. .driver = {
  824. .name = "sun50i-a64-ccu",
  825. .of_match_table = sun50i_a64_ccu_ids,
  826. },
  827. };
  828. builtin_platform_driver(sun50i_a64_ccu_driver);