ccu-sun50i-a64.c 30 KB

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