ccu-sun5i.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/io.h>
  7. #include <linux/of_address.h>
  8. #include "ccu_common.h"
  9. #include "ccu_reset.h"
  10. #include "ccu_div.h"
  11. #include "ccu_gate.h"
  12. #include "ccu_mp.h"
  13. #include "ccu_mult.h"
  14. #include "ccu_nk.h"
  15. #include "ccu_nkm.h"
  16. #include "ccu_nkmp.h"
  17. #include "ccu_nm.h"
  18. #include "ccu_phase.h"
  19. #include "ccu_sdm.h"
  20. #include "ccu-sun5i.h"
  21. static struct ccu_nkmp pll_core_clk = {
  22. .enable = BIT(31),
  23. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  24. .k = _SUNXI_CCU_MULT(4, 2),
  25. .m = _SUNXI_CCU_DIV(0, 2),
  26. .p = _SUNXI_CCU_DIV(16, 2),
  27. .common = {
  28. .reg = 0x000,
  29. .hw.init = CLK_HW_INIT("pll-core",
  30. "hosc",
  31. &ccu_nkmp_ops,
  32. 0),
  33. },
  34. };
  35. /*
  36. * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
  37. * the base (2x, 4x and 8x), and one variable divider (the one true
  38. * pll audio).
  39. *
  40. * With sigma-delta modulation for fractional-N on the audio PLL,
  41. * we have to use specific dividers. This means the variable divider
  42. * can no longer be used, as the audio codec requests the exact clock
  43. * rates we support through this mechanism. So we now hard code the
  44. * variable divider to 1. This means the clock rates will no longer
  45. * match the clock names.
  46. */
  47. #define SUN5I_PLL_AUDIO_REG 0x008
  48. static struct ccu_sdm_setting pll_audio_sdm_table[] = {
  49. { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
  50. { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
  51. };
  52. static struct ccu_nm pll_audio_base_clk = {
  53. .enable = BIT(31),
  54. .n = _SUNXI_CCU_MULT_OFFSET(8, 7, 0),
  55. /*
  56. * The datasheet is wrong here, this doesn't have any
  57. * offset
  58. */
  59. .m = _SUNXI_CCU_DIV_OFFSET(0, 5, 0),
  60. .sdm = _SUNXI_CCU_SDM(pll_audio_sdm_table, 0,
  61. 0x00c, BIT(31)),
  62. .common = {
  63. .reg = 0x008,
  64. .features = CCU_FEATURE_SIGMA_DELTA_MOD,
  65. .hw.init = CLK_HW_INIT("pll-audio-base",
  66. "hosc",
  67. &ccu_nm_ops,
  68. 0),
  69. },
  70. };
  71. static struct ccu_mult pll_video0_clk = {
  72. .enable = BIT(31),
  73. .mult = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(0, 7, 0, 9, 127),
  74. .frac = _SUNXI_CCU_FRAC(BIT(15), BIT(14),
  75. 270000000, 297000000),
  76. .common = {
  77. .reg = 0x010,
  78. .features = (CCU_FEATURE_FRACTIONAL |
  79. CCU_FEATURE_ALL_PREDIV),
  80. .prediv = 8,
  81. .hw.init = CLK_HW_INIT("pll-video0",
  82. "hosc",
  83. &ccu_mult_ops,
  84. 0),
  85. },
  86. };
  87. static struct ccu_nkmp pll_ve_clk = {
  88. .enable = BIT(31),
  89. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  90. .k = _SUNXI_CCU_MULT(4, 2),
  91. .m = _SUNXI_CCU_DIV(0, 2),
  92. .p = _SUNXI_CCU_DIV(16, 2),
  93. .common = {
  94. .reg = 0x018,
  95. .hw.init = CLK_HW_INIT("pll-ve",
  96. "hosc",
  97. &ccu_nkmp_ops,
  98. 0),
  99. },
  100. };
  101. static struct ccu_nk pll_ddr_base_clk = {
  102. .enable = BIT(31),
  103. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  104. .k = _SUNXI_CCU_MULT(4, 2),
  105. .common = {
  106. .reg = 0x020,
  107. .hw.init = CLK_HW_INIT("pll-ddr-base",
  108. "hosc",
  109. &ccu_nk_ops,
  110. 0),
  111. },
  112. };
  113. static SUNXI_CCU_M(pll_ddr_clk, "pll-ddr", "pll-ddr-base", 0x020, 0, 2,
  114. CLK_IS_CRITICAL);
  115. static struct ccu_div pll_ddr_other_clk = {
  116. .div = _SUNXI_CCU_DIV_FLAGS(16, 2, CLK_DIVIDER_POWER_OF_TWO),
  117. .common = {
  118. .reg = 0x020,
  119. .hw.init = CLK_HW_INIT("pll-ddr-other", "pll-ddr-base",
  120. &ccu_div_ops,
  121. 0),
  122. },
  123. };
  124. static struct ccu_nk pll_periph_clk = {
  125. .enable = BIT(31),
  126. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  127. .k = _SUNXI_CCU_MULT(4, 2),
  128. .fixed_post_div = 2,
  129. .common = {
  130. .reg = 0x028,
  131. .features = CCU_FEATURE_FIXED_POSTDIV,
  132. .hw.init = CLK_HW_INIT("pll-periph",
  133. "hosc",
  134. &ccu_nk_ops,
  135. 0),
  136. },
  137. };
  138. static struct ccu_mult pll_video1_clk = {
  139. .enable = BIT(31),
  140. .mult = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(0, 7, 0, 9, 127),
  141. .frac = _SUNXI_CCU_FRAC(BIT(15), BIT(14),
  142. 270000000, 297000000),
  143. .common = {
  144. .reg = 0x030,
  145. .features = (CCU_FEATURE_FRACTIONAL |
  146. CCU_FEATURE_ALL_PREDIV),
  147. .prediv = 8,
  148. .hw.init = CLK_HW_INIT("pll-video1",
  149. "hosc",
  150. &ccu_mult_ops,
  151. 0),
  152. },
  153. };
  154. static SUNXI_CCU_GATE(hosc_clk, "hosc", "osc24M", 0x050, BIT(0), 0);
  155. #define SUN5I_AHB_REG 0x054
  156. static const char * const cpu_parents[] = { "osc32k", "hosc",
  157. "pll-core" , "pll-periph" };
  158. static const struct ccu_mux_fixed_prediv cpu_predivs[] = {
  159. { .index = 3, .div = 3, },
  160. };
  161. static struct ccu_mux cpu_clk = {
  162. .mux = {
  163. .shift = 16,
  164. .width = 2,
  165. .fixed_predivs = cpu_predivs,
  166. .n_predivs = ARRAY_SIZE(cpu_predivs),
  167. },
  168. .common = {
  169. .reg = 0x054,
  170. .features = CCU_FEATURE_FIXED_PREDIV,
  171. .hw.init = CLK_HW_INIT_PARENTS("cpu",
  172. cpu_parents,
  173. &ccu_mux_ops,
  174. CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
  175. }
  176. };
  177. static SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x054, 0, 2, 0);
  178. static const char * const ahb_parents[] = { "axi" , "cpu", "pll-periph" };
  179. static const struct ccu_mux_fixed_prediv ahb_predivs[] = {
  180. { .index = 2, .div = 2, },
  181. };
  182. static struct ccu_div ahb_clk = {
  183. .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
  184. .mux = {
  185. .shift = 6,
  186. .width = 2,
  187. .fixed_predivs = ahb_predivs,
  188. .n_predivs = ARRAY_SIZE(ahb_predivs),
  189. },
  190. .common = {
  191. .reg = 0x054,
  192. .hw.init = CLK_HW_INIT_PARENTS("ahb",
  193. ahb_parents,
  194. &ccu_div_ops,
  195. 0),
  196. },
  197. };
  198. static struct clk_div_table apb0_div_table[] = {
  199. { .val = 0, .div = 2 },
  200. { .val = 1, .div = 2 },
  201. { .val = 2, .div = 4 },
  202. { .val = 3, .div = 8 },
  203. { /* Sentinel */ },
  204. };
  205. static SUNXI_CCU_DIV_TABLE(apb0_clk, "apb0", "ahb",
  206. 0x054, 8, 2, apb0_div_table, 0);
  207. static const char * const apb1_parents[] = { "hosc", "pll-periph", "osc32k" };
  208. static SUNXI_CCU_MP_WITH_MUX(apb1_clk, "apb1", apb1_parents, 0x058,
  209. 0, 5, /* M */
  210. 16, 2, /* P */
  211. 24, 2, /* mux */
  212. 0);
  213. static SUNXI_CCU_GATE(axi_dram_clk, "axi-dram", "axi",
  214. 0x05c, BIT(0), 0);
  215. static SUNXI_CCU_GATE(ahb_otg_clk, "ahb-otg", "ahb",
  216. 0x060, BIT(0), 0);
  217. static SUNXI_CCU_GATE(ahb_ehci_clk, "ahb-ehci", "ahb",
  218. 0x060, BIT(1), 0);
  219. static SUNXI_CCU_GATE(ahb_ohci_clk, "ahb-ohci", "ahb",
  220. 0x060, BIT(2), 0);
  221. static SUNXI_CCU_GATE(ahb_ss_clk, "ahb-ss", "ahb",
  222. 0x060, BIT(5), 0);
  223. static SUNXI_CCU_GATE(ahb_dma_clk, "ahb-dma", "ahb",
  224. 0x060, BIT(6), 0);
  225. static SUNXI_CCU_GATE(ahb_bist_clk, "ahb-bist", "ahb",
  226. 0x060, BIT(7), 0);
  227. static SUNXI_CCU_GATE(ahb_mmc0_clk, "ahb-mmc0", "ahb",
  228. 0x060, BIT(8), 0);
  229. static SUNXI_CCU_GATE(ahb_mmc1_clk, "ahb-mmc1", "ahb",
  230. 0x060, BIT(9), 0);
  231. static SUNXI_CCU_GATE(ahb_mmc2_clk, "ahb-mmc2", "ahb",
  232. 0x060, BIT(10), 0);
  233. static SUNXI_CCU_GATE(ahb_nand_clk, "ahb-nand", "ahb",
  234. 0x060, BIT(13), 0);
  235. static SUNXI_CCU_GATE(ahb_sdram_clk, "ahb-sdram", "ahb",
  236. 0x060, BIT(14), CLK_IS_CRITICAL);
  237. static SUNXI_CCU_GATE(ahb_emac_clk, "ahb-emac", "ahb",
  238. 0x060, BIT(17), 0);
  239. static SUNXI_CCU_GATE(ahb_ts_clk, "ahb-ts", "ahb",
  240. 0x060, BIT(18), 0);
  241. static SUNXI_CCU_GATE(ahb_spi0_clk, "ahb-spi0", "ahb",
  242. 0x060, BIT(20), 0);
  243. static SUNXI_CCU_GATE(ahb_spi1_clk, "ahb-spi1", "ahb",
  244. 0x060, BIT(21), 0);
  245. static SUNXI_CCU_GATE(ahb_spi2_clk, "ahb-spi2", "ahb",
  246. 0x060, BIT(22), 0);
  247. static SUNXI_CCU_GATE(ahb_gps_clk, "ahb-gps", "ahb",
  248. 0x060, BIT(26), 0);
  249. static SUNXI_CCU_GATE(ahb_hstimer_clk, "ahb-hstimer", "ahb",
  250. 0x060, BIT(28), 0);
  251. static SUNXI_CCU_GATE(ahb_ve_clk, "ahb-ve", "ahb",
  252. 0x064, BIT(0), 0);
  253. static SUNXI_CCU_GATE(ahb_tve_clk, "ahb-tve", "ahb",
  254. 0x064, BIT(2), 0);
  255. static SUNXI_CCU_GATE(ahb_lcd_clk, "ahb-lcd", "ahb",
  256. 0x064, BIT(4), 0);
  257. static SUNXI_CCU_GATE(ahb_csi_clk, "ahb-csi", "ahb",
  258. 0x064, BIT(8), 0);
  259. static SUNXI_CCU_GATE(ahb_hdmi_clk, "ahb-hdmi", "ahb",
  260. 0x064, BIT(11), 0);
  261. static SUNXI_CCU_GATE(ahb_de_be_clk, "ahb-de-be", "ahb",
  262. 0x064, BIT(12), 0);
  263. static SUNXI_CCU_GATE(ahb_de_fe_clk, "ahb-de-fe", "ahb",
  264. 0x064, BIT(14), 0);
  265. static SUNXI_CCU_GATE(ahb_iep_clk, "ahb-iep", "ahb",
  266. 0x064, BIT(19), 0);
  267. static SUNXI_CCU_GATE(ahb_gpu_clk, "ahb-gpu", "ahb",
  268. 0x064, BIT(20), 0);
  269. static SUNXI_CCU_GATE(apb0_codec_clk, "apb0-codec", "apb0",
  270. 0x068, BIT(0), 0);
  271. static SUNXI_CCU_GATE(apb0_spdif_clk, "apb0-spdif", "apb0",
  272. 0x068, BIT(1), 0);
  273. static SUNXI_CCU_GATE(apb0_i2s_clk, "apb0-i2s", "apb0",
  274. 0x068, BIT(3), 0);
  275. static SUNXI_CCU_GATE(apb0_pio_clk, "apb0-pio", "apb0",
  276. 0x068, BIT(5), 0);
  277. static SUNXI_CCU_GATE(apb0_ir_clk, "apb0-ir", "apb0",
  278. 0x068, BIT(6), 0);
  279. static SUNXI_CCU_GATE(apb0_keypad_clk, "apb0-keypad", "apb0",
  280. 0x068, BIT(10), 0);
  281. static SUNXI_CCU_GATE(apb1_i2c0_clk, "apb1-i2c0", "apb1",
  282. 0x06c, BIT(0), 0);
  283. static SUNXI_CCU_GATE(apb1_i2c1_clk, "apb1-i2c1", "apb1",
  284. 0x06c, BIT(1), 0);
  285. static SUNXI_CCU_GATE(apb1_i2c2_clk, "apb1-i2c2", "apb1",
  286. 0x06c, BIT(2), 0);
  287. static SUNXI_CCU_GATE(apb1_uart0_clk, "apb1-uart0", "apb1",
  288. 0x06c, BIT(16), 0);
  289. static SUNXI_CCU_GATE(apb1_uart1_clk, "apb1-uart1", "apb1",
  290. 0x06c, BIT(17), 0);
  291. static SUNXI_CCU_GATE(apb1_uart2_clk, "apb1-uart2", "apb1",
  292. 0x06c, BIT(18), 0);
  293. static SUNXI_CCU_GATE(apb1_uart3_clk, "apb1-uart3", "apb1",
  294. 0x06c, BIT(19), 0);
  295. static const char * const mod0_default_parents[] = { "hosc", "pll-periph",
  296. "pll-ddr-other" };
  297. static SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
  298. 0, 4, /* M */
  299. 16, 2, /* P */
  300. 24, 2, /* mux */
  301. BIT(31), /* gate */
  302. 0);
  303. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
  304. 0, 4, /* M */
  305. 16, 2, /* P */
  306. 24, 2, /* mux */
  307. BIT(31), /* gate */
  308. 0);
  309. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
  310. 0, 4, /* M */
  311. 16, 2, /* P */
  312. 24, 2, /* mux */
  313. BIT(31), /* gate */
  314. 0);
  315. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
  316. 0, 4, /* M */
  317. 16, 2, /* P */
  318. 24, 2, /* mux */
  319. BIT(31), /* gate */
  320. 0);
  321. static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", mod0_default_parents, 0x098,
  322. 0, 4, /* M */
  323. 16, 2, /* P */
  324. 24, 2, /* mux */
  325. BIT(31), /* gate */
  326. 0);
  327. static SUNXI_CCU_MP_WITH_MUX_GATE(ss_clk, "ss", mod0_default_parents, 0x09c,
  328. 0, 4, /* M */
  329. 16, 2, /* P */
  330. 24, 2, /* mux */
  331. BIT(31), /* gate */
  332. 0);
  333. static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
  334. 0, 4, /* M */
  335. 16, 2, /* P */
  336. 24, 2, /* mux */
  337. BIT(31), /* gate */
  338. 0);
  339. static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
  340. 0, 4, /* M */
  341. 16, 2, /* P */
  342. 24, 2, /* mux */
  343. BIT(31), /* gate */
  344. 0);
  345. static SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", mod0_default_parents, 0x0a8,
  346. 0, 4, /* M */
  347. 16, 2, /* P */
  348. 24, 2, /* mux */
  349. BIT(31), /* gate */
  350. 0);
  351. static SUNXI_CCU_MP_WITH_MUX_GATE(ir_clk, "ir", mod0_default_parents, 0x0b0,
  352. 0, 4, /* M */
  353. 16, 2, /* P */
  354. 24, 2, /* mux */
  355. BIT(31), /* gate */
  356. 0);
  357. static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
  358. "pll-audio-2x", "pll-audio" };
  359. static SUNXI_CCU_MUX_WITH_GATE(i2s_clk, "i2s", i2s_parents,
  360. 0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  361. static const char * const spdif_parents[] = { "pll-audio-8x", "pll-audio-4x",
  362. "pll-audio-2x", "pll-audio" };
  363. static SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", spdif_parents,
  364. 0x0c0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  365. static const char * const keypad_parents[] = { "hosc", "losc"};
  366. static const u8 keypad_table[] = { 0, 2 };
  367. static struct ccu_mp keypad_clk = {
  368. .enable = BIT(31),
  369. .m = _SUNXI_CCU_DIV(8, 5),
  370. .p = _SUNXI_CCU_DIV(20, 2),
  371. .mux = _SUNXI_CCU_MUX_TABLE(24, 2, keypad_table),
  372. .common = {
  373. .reg = 0x0c4,
  374. .hw.init = CLK_HW_INIT_PARENTS("keypad",
  375. keypad_parents,
  376. &ccu_mp_ops,
  377. 0),
  378. },
  379. };
  380. static SUNXI_CCU_GATE(usb_ohci_clk, "usb-ohci", "pll-periph",
  381. 0x0cc, BIT(6), 0);
  382. static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "pll-periph",
  383. 0x0cc, BIT(8), 0);
  384. static SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "pll-periph",
  385. 0x0cc, BIT(9), 0);
  386. static const char * const gps_parents[] = { "hosc", "pll-periph",
  387. "pll-video1", "pll-ve" };
  388. static SUNXI_CCU_M_WITH_MUX_GATE(gps_clk, "gps", gps_parents,
  389. 0x0d0, 0, 3, 24, 2, BIT(31), 0);
  390. static SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "pll-ddr",
  391. 0x100, BIT(0), 0);
  392. static SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "pll-ddr",
  393. 0x100, BIT(1), 0);
  394. static SUNXI_CCU_GATE(dram_ts_clk, "dram-ts", "pll-ddr",
  395. 0x100, BIT(3), 0);
  396. static SUNXI_CCU_GATE(dram_tve_clk, "dram-tve", "pll-ddr",
  397. 0x100, BIT(5), 0);
  398. static SUNXI_CCU_GATE(dram_de_fe_clk, "dram-de-fe", "pll-ddr",
  399. 0x100, BIT(25), 0);
  400. static SUNXI_CCU_GATE(dram_de_be_clk, "dram-de-be", "pll-ddr",
  401. 0x100, BIT(26), 0);
  402. static SUNXI_CCU_GATE(dram_ace_clk, "dram-ace", "pll-ddr",
  403. 0x100, BIT(29), 0);
  404. static SUNXI_CCU_GATE(dram_iep_clk, "dram-iep", "pll-ddr",
  405. 0x100, BIT(31), 0);
  406. static const char * const de_parents[] = { "pll-video0", "pll-video1",
  407. "pll-ddr-other" };
  408. static SUNXI_CCU_M_WITH_MUX_GATE(de_be_clk, "de-be", de_parents,
  409. 0x104, 0, 4, 24, 2, BIT(31), 0);
  410. static SUNXI_CCU_M_WITH_MUX_GATE(de_fe_clk, "de-fe", de_parents,
  411. 0x10c, 0, 4, 24, 2, BIT(31), 0);
  412. static const char * const tcon_parents[] = { "pll-video0", "pll-video1",
  413. "pll-video0-2x", "pll-video1-2x" };
  414. static SUNXI_CCU_MUX_WITH_GATE(tcon_ch0_clk, "tcon-ch0-sclk", tcon_parents,
  415. 0x118, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
  416. static SUNXI_CCU_M_WITH_MUX_GATE(tcon_ch1_sclk2_clk, "tcon-ch1-sclk2",
  417. tcon_parents,
  418. 0x12c, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
  419. static SUNXI_CCU_M_WITH_GATE(tcon_ch1_sclk1_clk, "tcon-ch1-sclk1", "tcon-ch1-sclk2",
  420. 0x12c, 11, 1, BIT(15), CLK_SET_RATE_PARENT);
  421. static const char * const csi_parents[] = { "hosc", "pll-video0", "pll-video1",
  422. "pll-video0-2x", "pll-video1-2x" };
  423. static const u8 csi_table[] = { 0, 1, 2, 5, 6 };
  424. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_clk, "csi",
  425. csi_parents, csi_table,
  426. 0x134, 0, 5, 24, 3, BIT(31), 0);
  427. static SUNXI_CCU_GATE(ve_clk, "ve", "pll-ve",
  428. 0x13c, BIT(31), CLK_SET_RATE_PARENT);
  429. static SUNXI_CCU_GATE(codec_clk, "codec", "pll-audio",
  430. 0x140, BIT(31), CLK_SET_RATE_PARENT);
  431. static SUNXI_CCU_GATE(avs_clk, "avs", "hosc",
  432. 0x144, BIT(31), 0);
  433. static const char * const hdmi_parents[] = { "pll-video0", "pll-video0-2x" };
  434. static const u8 hdmi_table[] = { 0, 2 };
  435. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(hdmi_clk, "hdmi",
  436. hdmi_parents, hdmi_table,
  437. 0x150, 0, 4, 24, 2, BIT(31),
  438. CLK_SET_RATE_PARENT);
  439. static const char * const gpu_parents[] = { "pll-video0", "pll-ve",
  440. "pll-ddr-other", "pll-video1",
  441. "pll-video1-2x" };
  442. static SUNXI_CCU_M_WITH_MUX_GATE(gpu_clk, "gpu", gpu_parents,
  443. 0x154, 0, 4, 24, 3, BIT(31), 0);
  444. static const char * const mbus_parents[] = { "hosc", "pll-periph", "pll-ddr" };
  445. static SUNXI_CCU_MP_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
  446. 0x15c, 0, 4, 16, 2, 24, 2, BIT(31), CLK_IS_CRITICAL);
  447. static SUNXI_CCU_GATE(iep_clk, "iep", "de-be",
  448. 0x160, BIT(31), 0);
  449. static struct ccu_common *sun5i_a10s_ccu_clks[] = {
  450. &hosc_clk.common,
  451. &pll_core_clk.common,
  452. &pll_audio_base_clk.common,
  453. &pll_video0_clk.common,
  454. &pll_ve_clk.common,
  455. &pll_ddr_base_clk.common,
  456. &pll_ddr_clk.common,
  457. &pll_ddr_other_clk.common,
  458. &pll_periph_clk.common,
  459. &pll_video1_clk.common,
  460. &cpu_clk.common,
  461. &axi_clk.common,
  462. &ahb_clk.common,
  463. &apb0_clk.common,
  464. &apb1_clk.common,
  465. &axi_dram_clk.common,
  466. &ahb_otg_clk.common,
  467. &ahb_ehci_clk.common,
  468. &ahb_ohci_clk.common,
  469. &ahb_ss_clk.common,
  470. &ahb_dma_clk.common,
  471. &ahb_bist_clk.common,
  472. &ahb_mmc0_clk.common,
  473. &ahb_mmc1_clk.common,
  474. &ahb_mmc2_clk.common,
  475. &ahb_nand_clk.common,
  476. &ahb_sdram_clk.common,
  477. &ahb_emac_clk.common,
  478. &ahb_ts_clk.common,
  479. &ahb_spi0_clk.common,
  480. &ahb_spi1_clk.common,
  481. &ahb_spi2_clk.common,
  482. &ahb_gps_clk.common,
  483. &ahb_hstimer_clk.common,
  484. &ahb_ve_clk.common,
  485. &ahb_tve_clk.common,
  486. &ahb_lcd_clk.common,
  487. &ahb_csi_clk.common,
  488. &ahb_hdmi_clk.common,
  489. &ahb_de_be_clk.common,
  490. &ahb_de_fe_clk.common,
  491. &ahb_iep_clk.common,
  492. &ahb_gpu_clk.common,
  493. &apb0_codec_clk.common,
  494. &apb0_spdif_clk.common,
  495. &apb0_i2s_clk.common,
  496. &apb0_pio_clk.common,
  497. &apb0_ir_clk.common,
  498. &apb0_keypad_clk.common,
  499. &apb1_i2c0_clk.common,
  500. &apb1_i2c1_clk.common,
  501. &apb1_i2c2_clk.common,
  502. &apb1_uart0_clk.common,
  503. &apb1_uart1_clk.common,
  504. &apb1_uart2_clk.common,
  505. &apb1_uart3_clk.common,
  506. &nand_clk.common,
  507. &mmc0_clk.common,
  508. &mmc1_clk.common,
  509. &mmc2_clk.common,
  510. &ts_clk.common,
  511. &ss_clk.common,
  512. &spi0_clk.common,
  513. &spi1_clk.common,
  514. &spi2_clk.common,
  515. &ir_clk.common,
  516. &i2s_clk.common,
  517. &spdif_clk.common,
  518. &keypad_clk.common,
  519. &usb_ohci_clk.common,
  520. &usb_phy0_clk.common,
  521. &usb_phy1_clk.common,
  522. &gps_clk.common,
  523. &dram_ve_clk.common,
  524. &dram_csi_clk.common,
  525. &dram_ts_clk.common,
  526. &dram_tve_clk.common,
  527. &dram_de_fe_clk.common,
  528. &dram_de_be_clk.common,
  529. &dram_ace_clk.common,
  530. &dram_iep_clk.common,
  531. &de_be_clk.common,
  532. &de_fe_clk.common,
  533. &tcon_ch0_clk.common,
  534. &tcon_ch1_sclk2_clk.common,
  535. &tcon_ch1_sclk1_clk.common,
  536. &csi_clk.common,
  537. &ve_clk.common,
  538. &codec_clk.common,
  539. &avs_clk.common,
  540. &hdmi_clk.common,
  541. &gpu_clk.common,
  542. &mbus_clk.common,
  543. &iep_clk.common,
  544. };
  545. static const struct clk_hw *clk_parent_pll_audio[] = {
  546. &pll_audio_base_clk.common.hw
  547. };
  548. /* We hardcode the divider to 1 for now */
  549. static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
  550. clk_parent_pll_audio,
  551. 1, 1, CLK_SET_RATE_PARENT);
  552. static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
  553. clk_parent_pll_audio,
  554. 2, 1, CLK_SET_RATE_PARENT);
  555. static CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x",
  556. clk_parent_pll_audio,
  557. 1, 1, CLK_SET_RATE_PARENT);
  558. static CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x",
  559. clk_parent_pll_audio,
  560. 1, 2, CLK_SET_RATE_PARENT);
  561. static CLK_FIXED_FACTOR_HW(pll_video0_2x_clk, "pll-video0-2x",
  562. &pll_video0_clk.common.hw,
  563. 1, 2, CLK_SET_RATE_PARENT);
  564. static CLK_FIXED_FACTOR_HW(pll_video1_2x_clk, "pll-video1-2x",
  565. &pll_video1_clk.common.hw,
  566. 1, 2, CLK_SET_RATE_PARENT);
  567. static struct clk_hw_onecell_data sun5i_a10s_hw_clks = {
  568. .hws = {
  569. [CLK_HOSC] = &hosc_clk.common.hw,
  570. [CLK_PLL_CORE] = &pll_core_clk.common.hw,
  571. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  572. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  573. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  574. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  575. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  576. [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw,
  577. [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw,
  578. [CLK_PLL_VE] = &pll_ve_clk.common.hw,
  579. [CLK_PLL_DDR_BASE] = &pll_ddr_base_clk.common.hw,
  580. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  581. [CLK_PLL_DDR_OTHER] = &pll_ddr_other_clk.common.hw,
  582. [CLK_PLL_PERIPH] = &pll_periph_clk.common.hw,
  583. [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw,
  584. [CLK_PLL_VIDEO1_2X] = &pll_video1_2x_clk.hw,
  585. [CLK_CPU] = &cpu_clk.common.hw,
  586. [CLK_AXI] = &axi_clk.common.hw,
  587. [CLK_AHB] = &ahb_clk.common.hw,
  588. [CLK_APB0] = &apb0_clk.common.hw,
  589. [CLK_APB1] = &apb1_clk.common.hw,
  590. [CLK_DRAM_AXI] = &axi_dram_clk.common.hw,
  591. [CLK_AHB_OTG] = &ahb_otg_clk.common.hw,
  592. [CLK_AHB_EHCI] = &ahb_ehci_clk.common.hw,
  593. [CLK_AHB_OHCI] = &ahb_ohci_clk.common.hw,
  594. [CLK_AHB_SS] = &ahb_ss_clk.common.hw,
  595. [CLK_AHB_DMA] = &ahb_dma_clk.common.hw,
  596. [CLK_AHB_BIST] = &ahb_bist_clk.common.hw,
  597. [CLK_AHB_MMC0] = &ahb_mmc0_clk.common.hw,
  598. [CLK_AHB_MMC1] = &ahb_mmc1_clk.common.hw,
  599. [CLK_AHB_MMC2] = &ahb_mmc2_clk.common.hw,
  600. [CLK_AHB_NAND] = &ahb_nand_clk.common.hw,
  601. [CLK_AHB_SDRAM] = &ahb_sdram_clk.common.hw,
  602. [CLK_AHB_EMAC] = &ahb_emac_clk.common.hw,
  603. [CLK_AHB_TS] = &ahb_ts_clk.common.hw,
  604. [CLK_AHB_SPI0] = &ahb_spi0_clk.common.hw,
  605. [CLK_AHB_SPI1] = &ahb_spi1_clk.common.hw,
  606. [CLK_AHB_SPI2] = &ahb_spi2_clk.common.hw,
  607. [CLK_AHB_GPS] = &ahb_gps_clk.common.hw,
  608. [CLK_AHB_HSTIMER] = &ahb_hstimer_clk.common.hw,
  609. [CLK_AHB_VE] = &ahb_ve_clk.common.hw,
  610. [CLK_AHB_TVE] = &ahb_tve_clk.common.hw,
  611. [CLK_AHB_LCD] = &ahb_lcd_clk.common.hw,
  612. [CLK_AHB_CSI] = &ahb_csi_clk.common.hw,
  613. [CLK_AHB_HDMI] = &ahb_hdmi_clk.common.hw,
  614. [CLK_AHB_DE_BE] = &ahb_de_be_clk.common.hw,
  615. [CLK_AHB_DE_FE] = &ahb_de_fe_clk.common.hw,
  616. [CLK_AHB_IEP] = &ahb_iep_clk.common.hw,
  617. [CLK_AHB_GPU] = &ahb_gpu_clk.common.hw,
  618. [CLK_APB0_CODEC] = &apb0_codec_clk.common.hw,
  619. [CLK_APB0_I2S] = &apb0_i2s_clk.common.hw,
  620. [CLK_APB0_PIO] = &apb0_pio_clk.common.hw,
  621. [CLK_APB0_IR] = &apb0_ir_clk.common.hw,
  622. [CLK_APB0_KEYPAD] = &apb0_keypad_clk.common.hw,
  623. [CLK_APB1_I2C0] = &apb1_i2c0_clk.common.hw,
  624. [CLK_APB1_I2C1] = &apb1_i2c1_clk.common.hw,
  625. [CLK_APB1_I2C2] = &apb1_i2c2_clk.common.hw,
  626. [CLK_APB1_UART0] = &apb1_uart0_clk.common.hw,
  627. [CLK_APB1_UART1] = &apb1_uart1_clk.common.hw,
  628. [CLK_APB1_UART2] = &apb1_uart2_clk.common.hw,
  629. [CLK_APB1_UART3] = &apb1_uart3_clk.common.hw,
  630. [CLK_NAND] = &nand_clk.common.hw,
  631. [CLK_MMC0] = &mmc0_clk.common.hw,
  632. [CLK_MMC1] = &mmc1_clk.common.hw,
  633. [CLK_MMC2] = &mmc2_clk.common.hw,
  634. [CLK_TS] = &ts_clk.common.hw,
  635. [CLK_SS] = &ss_clk.common.hw,
  636. [CLK_SPI0] = &spi0_clk.common.hw,
  637. [CLK_SPI1] = &spi1_clk.common.hw,
  638. [CLK_SPI2] = &spi2_clk.common.hw,
  639. [CLK_IR] = &ir_clk.common.hw,
  640. [CLK_I2S] = &i2s_clk.common.hw,
  641. [CLK_KEYPAD] = &keypad_clk.common.hw,
  642. [CLK_USB_OHCI] = &usb_ohci_clk.common.hw,
  643. [CLK_USB_PHY0] = &usb_phy0_clk.common.hw,
  644. [CLK_USB_PHY1] = &usb_phy1_clk.common.hw,
  645. [CLK_GPS] = &gps_clk.common.hw,
  646. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  647. [CLK_DRAM_CSI] = &dram_csi_clk.common.hw,
  648. [CLK_DRAM_TS] = &dram_ts_clk.common.hw,
  649. [CLK_DRAM_TVE] = &dram_tve_clk.common.hw,
  650. [CLK_DRAM_DE_FE] = &dram_de_fe_clk.common.hw,
  651. [CLK_DRAM_DE_BE] = &dram_de_be_clk.common.hw,
  652. [CLK_DRAM_ACE] = &dram_ace_clk.common.hw,
  653. [CLK_DRAM_IEP] = &dram_iep_clk.common.hw,
  654. [CLK_DE_BE] = &de_be_clk.common.hw,
  655. [CLK_DE_FE] = &de_fe_clk.common.hw,
  656. [CLK_TCON_CH0] = &tcon_ch0_clk.common.hw,
  657. [CLK_TCON_CH1_SCLK] = &tcon_ch1_sclk2_clk.common.hw,
  658. [CLK_TCON_CH1] = &tcon_ch1_sclk1_clk.common.hw,
  659. [CLK_CSI] = &csi_clk.common.hw,
  660. [CLK_VE] = &ve_clk.common.hw,
  661. [CLK_CODEC] = &codec_clk.common.hw,
  662. [CLK_AVS] = &avs_clk.common.hw,
  663. [CLK_HDMI] = &hdmi_clk.common.hw,
  664. [CLK_GPU] = &gpu_clk.common.hw,
  665. [CLK_MBUS] = &mbus_clk.common.hw,
  666. [CLK_IEP] = &iep_clk.common.hw,
  667. },
  668. .num = CLK_NUMBER,
  669. };
  670. static struct ccu_reset_map sun5i_a10s_ccu_resets[] = {
  671. [RST_USB_PHY0] = { 0x0cc, BIT(0) },
  672. [RST_USB_PHY1] = { 0x0cc, BIT(1) },
  673. [RST_GPS] = { 0x0d0, BIT(30) },
  674. [RST_DE_BE] = { 0x104, BIT(30) },
  675. [RST_DE_FE] = { 0x10c, BIT(30) },
  676. [RST_TVE] = { 0x118, BIT(29) },
  677. [RST_LCD] = { 0x118, BIT(30) },
  678. [RST_CSI] = { 0x134, BIT(30) },
  679. [RST_VE] = { 0x13c, BIT(0) },
  680. [RST_GPU] = { 0x154, BIT(30) },
  681. [RST_IEP] = { 0x160, BIT(30) },
  682. };
  683. static const struct sunxi_ccu_desc sun5i_a10s_ccu_desc = {
  684. .ccu_clks = sun5i_a10s_ccu_clks,
  685. .num_ccu_clks = ARRAY_SIZE(sun5i_a10s_ccu_clks),
  686. .hw_clks = &sun5i_a10s_hw_clks,
  687. .resets = sun5i_a10s_ccu_resets,
  688. .num_resets = ARRAY_SIZE(sun5i_a10s_ccu_resets),
  689. };
  690. /*
  691. * The A13 is the A10s minus the TS, GPS, HDMI, I2S and the keypad
  692. */
  693. static struct clk_hw_onecell_data sun5i_a13_hw_clks = {
  694. .hws = {
  695. [CLK_HOSC] = &hosc_clk.common.hw,
  696. [CLK_PLL_CORE] = &pll_core_clk.common.hw,
  697. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  698. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  699. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  700. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  701. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  702. [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw,
  703. [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw,
  704. [CLK_PLL_VE] = &pll_ve_clk.common.hw,
  705. [CLK_PLL_DDR_BASE] = &pll_ddr_base_clk.common.hw,
  706. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  707. [CLK_PLL_DDR_OTHER] = &pll_ddr_other_clk.common.hw,
  708. [CLK_PLL_PERIPH] = &pll_periph_clk.common.hw,
  709. [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw,
  710. [CLK_PLL_VIDEO1_2X] = &pll_video1_2x_clk.hw,
  711. [CLK_CPU] = &cpu_clk.common.hw,
  712. [CLK_AXI] = &axi_clk.common.hw,
  713. [CLK_AHB] = &ahb_clk.common.hw,
  714. [CLK_APB0] = &apb0_clk.common.hw,
  715. [CLK_APB1] = &apb1_clk.common.hw,
  716. [CLK_DRAM_AXI] = &axi_dram_clk.common.hw,
  717. [CLK_AHB_OTG] = &ahb_otg_clk.common.hw,
  718. [CLK_AHB_EHCI] = &ahb_ehci_clk.common.hw,
  719. [CLK_AHB_OHCI] = &ahb_ohci_clk.common.hw,
  720. [CLK_AHB_SS] = &ahb_ss_clk.common.hw,
  721. [CLK_AHB_DMA] = &ahb_dma_clk.common.hw,
  722. [CLK_AHB_BIST] = &ahb_bist_clk.common.hw,
  723. [CLK_AHB_MMC0] = &ahb_mmc0_clk.common.hw,
  724. [CLK_AHB_MMC1] = &ahb_mmc1_clk.common.hw,
  725. [CLK_AHB_MMC2] = &ahb_mmc2_clk.common.hw,
  726. [CLK_AHB_NAND] = &ahb_nand_clk.common.hw,
  727. [CLK_AHB_SDRAM] = &ahb_sdram_clk.common.hw,
  728. [CLK_AHB_EMAC] = &ahb_emac_clk.common.hw,
  729. [CLK_AHB_SPI0] = &ahb_spi0_clk.common.hw,
  730. [CLK_AHB_SPI1] = &ahb_spi1_clk.common.hw,
  731. [CLK_AHB_SPI2] = &ahb_spi2_clk.common.hw,
  732. [CLK_AHB_HSTIMER] = &ahb_hstimer_clk.common.hw,
  733. [CLK_AHB_VE] = &ahb_ve_clk.common.hw,
  734. [CLK_AHB_TVE] = &ahb_tve_clk.common.hw,
  735. [CLK_AHB_LCD] = &ahb_lcd_clk.common.hw,
  736. [CLK_AHB_CSI] = &ahb_csi_clk.common.hw,
  737. [CLK_AHB_DE_BE] = &ahb_de_be_clk.common.hw,
  738. [CLK_AHB_DE_FE] = &ahb_de_fe_clk.common.hw,
  739. [CLK_AHB_IEP] = &ahb_iep_clk.common.hw,
  740. [CLK_AHB_GPU] = &ahb_gpu_clk.common.hw,
  741. [CLK_APB0_CODEC] = &apb0_codec_clk.common.hw,
  742. [CLK_APB0_PIO] = &apb0_pio_clk.common.hw,
  743. [CLK_APB0_IR] = &apb0_ir_clk.common.hw,
  744. [CLK_APB1_I2C0] = &apb1_i2c0_clk.common.hw,
  745. [CLK_APB1_I2C1] = &apb1_i2c1_clk.common.hw,
  746. [CLK_APB1_I2C2] = &apb1_i2c2_clk.common.hw,
  747. [CLK_APB1_UART0] = &apb1_uart0_clk.common.hw,
  748. [CLK_APB1_UART1] = &apb1_uart1_clk.common.hw,
  749. [CLK_APB1_UART2] = &apb1_uart2_clk.common.hw,
  750. [CLK_APB1_UART3] = &apb1_uart3_clk.common.hw,
  751. [CLK_NAND] = &nand_clk.common.hw,
  752. [CLK_MMC0] = &mmc0_clk.common.hw,
  753. [CLK_MMC1] = &mmc1_clk.common.hw,
  754. [CLK_MMC2] = &mmc2_clk.common.hw,
  755. [CLK_SS] = &ss_clk.common.hw,
  756. [CLK_SPI0] = &spi0_clk.common.hw,
  757. [CLK_SPI1] = &spi1_clk.common.hw,
  758. [CLK_SPI2] = &spi2_clk.common.hw,
  759. [CLK_IR] = &ir_clk.common.hw,
  760. [CLK_USB_OHCI] = &usb_ohci_clk.common.hw,
  761. [CLK_USB_PHY0] = &usb_phy0_clk.common.hw,
  762. [CLK_USB_PHY1] = &usb_phy1_clk.common.hw,
  763. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  764. [CLK_DRAM_CSI] = &dram_csi_clk.common.hw,
  765. [CLK_DRAM_TVE] = &dram_tve_clk.common.hw,
  766. [CLK_DRAM_DE_FE] = &dram_de_fe_clk.common.hw,
  767. [CLK_DRAM_DE_BE] = &dram_de_be_clk.common.hw,
  768. [CLK_DRAM_ACE] = &dram_ace_clk.common.hw,
  769. [CLK_DRAM_IEP] = &dram_iep_clk.common.hw,
  770. [CLK_DE_BE] = &de_be_clk.common.hw,
  771. [CLK_DE_FE] = &de_fe_clk.common.hw,
  772. [CLK_TCON_CH0] = &tcon_ch0_clk.common.hw,
  773. [CLK_TCON_CH1_SCLK] = &tcon_ch1_sclk2_clk.common.hw,
  774. [CLK_TCON_CH1] = &tcon_ch1_sclk1_clk.common.hw,
  775. [CLK_CSI] = &csi_clk.common.hw,
  776. [CLK_VE] = &ve_clk.common.hw,
  777. [CLK_CODEC] = &codec_clk.common.hw,
  778. [CLK_AVS] = &avs_clk.common.hw,
  779. [CLK_GPU] = &gpu_clk.common.hw,
  780. [CLK_MBUS] = &mbus_clk.common.hw,
  781. [CLK_IEP] = &iep_clk.common.hw,
  782. },
  783. .num = CLK_NUMBER,
  784. };
  785. static const struct sunxi_ccu_desc sun5i_a13_ccu_desc = {
  786. .ccu_clks = sun5i_a10s_ccu_clks,
  787. .num_ccu_clks = ARRAY_SIZE(sun5i_a10s_ccu_clks),
  788. .hw_clks = &sun5i_a13_hw_clks,
  789. .resets = sun5i_a10s_ccu_resets,
  790. .num_resets = ARRAY_SIZE(sun5i_a10s_ccu_resets),
  791. };
  792. /*
  793. * The GR8 is the A10s CCU minus the HDMI and keypad, plus SPDIF
  794. */
  795. static struct clk_hw_onecell_data sun5i_gr8_hw_clks = {
  796. .hws = {
  797. [CLK_HOSC] = &hosc_clk.common.hw,
  798. [CLK_PLL_CORE] = &pll_core_clk.common.hw,
  799. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  800. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  801. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  802. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  803. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  804. [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw,
  805. [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw,
  806. [CLK_PLL_VE] = &pll_ve_clk.common.hw,
  807. [CLK_PLL_DDR_BASE] = &pll_ddr_base_clk.common.hw,
  808. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  809. [CLK_PLL_DDR_OTHER] = &pll_ddr_other_clk.common.hw,
  810. [CLK_PLL_PERIPH] = &pll_periph_clk.common.hw,
  811. [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw,
  812. [CLK_PLL_VIDEO1_2X] = &pll_video1_2x_clk.hw,
  813. [CLK_CPU] = &cpu_clk.common.hw,
  814. [CLK_AXI] = &axi_clk.common.hw,
  815. [CLK_AHB] = &ahb_clk.common.hw,
  816. [CLK_APB0] = &apb0_clk.common.hw,
  817. [CLK_APB1] = &apb1_clk.common.hw,
  818. [CLK_DRAM_AXI] = &axi_dram_clk.common.hw,
  819. [CLK_AHB_OTG] = &ahb_otg_clk.common.hw,
  820. [CLK_AHB_EHCI] = &ahb_ehci_clk.common.hw,
  821. [CLK_AHB_OHCI] = &ahb_ohci_clk.common.hw,
  822. [CLK_AHB_SS] = &ahb_ss_clk.common.hw,
  823. [CLK_AHB_DMA] = &ahb_dma_clk.common.hw,
  824. [CLK_AHB_BIST] = &ahb_bist_clk.common.hw,
  825. [CLK_AHB_MMC0] = &ahb_mmc0_clk.common.hw,
  826. [CLK_AHB_MMC1] = &ahb_mmc1_clk.common.hw,
  827. [CLK_AHB_MMC2] = &ahb_mmc2_clk.common.hw,
  828. [CLK_AHB_NAND] = &ahb_nand_clk.common.hw,
  829. [CLK_AHB_SDRAM] = &ahb_sdram_clk.common.hw,
  830. [CLK_AHB_EMAC] = &ahb_emac_clk.common.hw,
  831. [CLK_AHB_TS] = &ahb_ts_clk.common.hw,
  832. [CLK_AHB_SPI0] = &ahb_spi0_clk.common.hw,
  833. [CLK_AHB_SPI1] = &ahb_spi1_clk.common.hw,
  834. [CLK_AHB_SPI2] = &ahb_spi2_clk.common.hw,
  835. [CLK_AHB_GPS] = &ahb_gps_clk.common.hw,
  836. [CLK_AHB_HSTIMER] = &ahb_hstimer_clk.common.hw,
  837. [CLK_AHB_VE] = &ahb_ve_clk.common.hw,
  838. [CLK_AHB_TVE] = &ahb_tve_clk.common.hw,
  839. [CLK_AHB_LCD] = &ahb_lcd_clk.common.hw,
  840. [CLK_AHB_CSI] = &ahb_csi_clk.common.hw,
  841. [CLK_AHB_DE_BE] = &ahb_de_be_clk.common.hw,
  842. [CLK_AHB_DE_FE] = &ahb_de_fe_clk.common.hw,
  843. [CLK_AHB_IEP] = &ahb_iep_clk.common.hw,
  844. [CLK_AHB_GPU] = &ahb_gpu_clk.common.hw,
  845. [CLK_APB0_CODEC] = &apb0_codec_clk.common.hw,
  846. [CLK_APB0_SPDIF] = &apb0_spdif_clk.common.hw,
  847. [CLK_APB0_I2S] = &apb0_i2s_clk.common.hw,
  848. [CLK_APB0_PIO] = &apb0_pio_clk.common.hw,
  849. [CLK_APB0_IR] = &apb0_ir_clk.common.hw,
  850. [CLK_APB1_I2C0] = &apb1_i2c0_clk.common.hw,
  851. [CLK_APB1_I2C1] = &apb1_i2c1_clk.common.hw,
  852. [CLK_APB1_I2C2] = &apb1_i2c2_clk.common.hw,
  853. [CLK_APB1_UART0] = &apb1_uart0_clk.common.hw,
  854. [CLK_APB1_UART1] = &apb1_uart1_clk.common.hw,
  855. [CLK_APB1_UART2] = &apb1_uart2_clk.common.hw,
  856. [CLK_APB1_UART3] = &apb1_uart3_clk.common.hw,
  857. [CLK_NAND] = &nand_clk.common.hw,
  858. [CLK_MMC0] = &mmc0_clk.common.hw,
  859. [CLK_MMC1] = &mmc1_clk.common.hw,
  860. [CLK_MMC2] = &mmc2_clk.common.hw,
  861. [CLK_TS] = &ts_clk.common.hw,
  862. [CLK_SS] = &ss_clk.common.hw,
  863. [CLK_SPI0] = &spi0_clk.common.hw,
  864. [CLK_SPI1] = &spi1_clk.common.hw,
  865. [CLK_SPI2] = &spi2_clk.common.hw,
  866. [CLK_IR] = &ir_clk.common.hw,
  867. [CLK_I2S] = &i2s_clk.common.hw,
  868. [CLK_SPDIF] = &spdif_clk.common.hw,
  869. [CLK_USB_OHCI] = &usb_ohci_clk.common.hw,
  870. [CLK_USB_PHY0] = &usb_phy0_clk.common.hw,
  871. [CLK_USB_PHY1] = &usb_phy1_clk.common.hw,
  872. [CLK_GPS] = &gps_clk.common.hw,
  873. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  874. [CLK_DRAM_CSI] = &dram_csi_clk.common.hw,
  875. [CLK_DRAM_TS] = &dram_ts_clk.common.hw,
  876. [CLK_DRAM_TVE] = &dram_tve_clk.common.hw,
  877. [CLK_DRAM_DE_FE] = &dram_de_fe_clk.common.hw,
  878. [CLK_DRAM_DE_BE] = &dram_de_be_clk.common.hw,
  879. [CLK_DRAM_ACE] = &dram_ace_clk.common.hw,
  880. [CLK_DRAM_IEP] = &dram_iep_clk.common.hw,
  881. [CLK_DE_BE] = &de_be_clk.common.hw,
  882. [CLK_DE_FE] = &de_fe_clk.common.hw,
  883. [CLK_TCON_CH0] = &tcon_ch0_clk.common.hw,
  884. [CLK_TCON_CH1_SCLK] = &tcon_ch1_sclk2_clk.common.hw,
  885. [CLK_TCON_CH1] = &tcon_ch1_sclk1_clk.common.hw,
  886. [CLK_CSI] = &csi_clk.common.hw,
  887. [CLK_VE] = &ve_clk.common.hw,
  888. [CLK_CODEC] = &codec_clk.common.hw,
  889. [CLK_AVS] = &avs_clk.common.hw,
  890. [CLK_GPU] = &gpu_clk.common.hw,
  891. [CLK_MBUS] = &mbus_clk.common.hw,
  892. [CLK_IEP] = &iep_clk.common.hw,
  893. },
  894. .num = CLK_NUMBER,
  895. };
  896. static const struct sunxi_ccu_desc sun5i_gr8_ccu_desc = {
  897. .ccu_clks = sun5i_a10s_ccu_clks,
  898. .num_ccu_clks = ARRAY_SIZE(sun5i_a10s_ccu_clks),
  899. .hw_clks = &sun5i_gr8_hw_clks,
  900. .resets = sun5i_a10s_ccu_resets,
  901. .num_resets = ARRAY_SIZE(sun5i_a10s_ccu_resets),
  902. };
  903. static void __init sun5i_ccu_init(struct device_node *node,
  904. const struct sunxi_ccu_desc *desc)
  905. {
  906. void __iomem *reg;
  907. u32 val;
  908. reg = of_io_request_and_map(node, 0, of_node_full_name(node));
  909. if (IS_ERR(reg)) {
  910. pr_err("%pOF: Could not map the clock registers\n", node);
  911. return;
  912. }
  913. /* Force the PLL-Audio-1x divider to 1 */
  914. val = readl(reg + SUN5I_PLL_AUDIO_REG);
  915. val &= ~GENMASK(29, 26);
  916. writel(val | (0 << 26), reg + SUN5I_PLL_AUDIO_REG);
  917. /*
  918. * Use the peripheral PLL as the AHB parent, instead of CPU /
  919. * AXI which have rate changes due to cpufreq.
  920. *
  921. * This is especially a big deal for the HS timer whose parent
  922. * clock is AHB.
  923. */
  924. val = readl(reg + SUN5I_AHB_REG);
  925. val &= ~GENMASK(7, 6);
  926. writel(val | (2 << 6), reg + SUN5I_AHB_REG);
  927. of_sunxi_ccu_probe(node, reg, desc);
  928. }
  929. static void __init sun5i_a10s_ccu_setup(struct device_node *node)
  930. {
  931. sun5i_ccu_init(node, &sun5i_a10s_ccu_desc);
  932. }
  933. CLK_OF_DECLARE(sun5i_a10s_ccu, "allwinner,sun5i-a10s-ccu",
  934. sun5i_a10s_ccu_setup);
  935. static void __init sun5i_a13_ccu_setup(struct device_node *node)
  936. {
  937. sun5i_ccu_init(node, &sun5i_a13_ccu_desc);
  938. }
  939. CLK_OF_DECLARE(sun5i_a13_ccu, "allwinner,sun5i-a13-ccu",
  940. sun5i_a13_ccu_setup);
  941. static void __init sun5i_gr8_ccu_setup(struct device_node *node)
  942. {
  943. sun5i_ccu_init(node, &sun5i_gr8_ccu_desc);
  944. }
  945. CLK_OF_DECLARE(sun5i_gr8_ccu, "nextthing,gr8-ccu",
  946. sun5i_gr8_ccu_setup);