ccu-sun4i-a10.c 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2017 Priit Laes <[email protected]>.
  4. * Copyright (c) 2017 Maxime Ripard.
  5. * Copyright (c) 2017 Jonathan Liu.
  6. */
  7. #include <linux/clk-provider.h>
  8. #include <linux/io.h>
  9. #include <linux/module.h>
  10. #include <linux/of_device.h>
  11. #include <linux/platform_device.h>
  12. #include "ccu_common.h"
  13. #include "ccu_reset.h"
  14. #include "ccu_div.h"
  15. #include "ccu_gate.h"
  16. #include "ccu_mp.h"
  17. #include "ccu_mult.h"
  18. #include "ccu_nk.h"
  19. #include "ccu_nkm.h"
  20. #include "ccu_nkmp.h"
  21. #include "ccu_nm.h"
  22. #include "ccu_phase.h"
  23. #include "ccu_sdm.h"
  24. #include "ccu-sun4i-a10.h"
  25. static struct ccu_nkmp pll_core_clk = {
  26. .enable = BIT(31),
  27. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  28. .k = _SUNXI_CCU_MULT(4, 2),
  29. .m = _SUNXI_CCU_DIV(0, 2),
  30. .p = _SUNXI_CCU_DIV(16, 2),
  31. .common = {
  32. .reg = 0x000,
  33. .hw.init = CLK_HW_INIT("pll-core",
  34. "hosc",
  35. &ccu_nkmp_ops,
  36. 0),
  37. },
  38. };
  39. /*
  40. * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
  41. * the base (2x, 4x and 8x), and one variable divider (the one true
  42. * pll audio).
  43. *
  44. * With sigma-delta modulation for fractional-N on the audio PLL,
  45. * we have to use specific dividers. This means the variable divider
  46. * can no longer be used, as the audio codec requests the exact clock
  47. * rates we support through this mechanism. So we now hard code the
  48. * variable divider to 1. This means the clock rates will no longer
  49. * match the clock names.
  50. */
  51. #define SUN4I_PLL_AUDIO_REG 0x008
  52. static struct ccu_sdm_setting pll_audio_sdm_table[] = {
  53. { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
  54. { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
  55. };
  56. static struct ccu_nm pll_audio_base_clk = {
  57. .enable = BIT(31),
  58. .n = _SUNXI_CCU_MULT_OFFSET(8, 7, 0),
  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_sun4i_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_ve_sun7i_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 = 0x018,
  107. .hw.init = CLK_HW_INIT("pll-ve",
  108. "hosc",
  109. &ccu_nk_ops,
  110. 0),
  111. },
  112. };
  113. static struct ccu_nk pll_ddr_base_clk = {
  114. .enable = BIT(31),
  115. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  116. .k = _SUNXI_CCU_MULT(4, 2),
  117. .common = {
  118. .reg = 0x020,
  119. .hw.init = CLK_HW_INIT("pll-ddr-base",
  120. "hosc",
  121. &ccu_nk_ops,
  122. 0),
  123. },
  124. };
  125. static SUNXI_CCU_M(pll_ddr_clk, "pll-ddr", "pll-ddr-base", 0x020, 0, 2,
  126. CLK_IS_CRITICAL);
  127. static struct ccu_div pll_ddr_other_clk = {
  128. .div = _SUNXI_CCU_DIV_FLAGS(16, 2, CLK_DIVIDER_POWER_OF_TWO),
  129. .common = {
  130. .reg = 0x020,
  131. .hw.init = CLK_HW_INIT("pll-ddr-other", "pll-ddr-base",
  132. &ccu_div_ops,
  133. 0),
  134. },
  135. };
  136. static struct ccu_nk pll_periph_base_clk = {
  137. .enable = BIT(31),
  138. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  139. .k = _SUNXI_CCU_MULT(4, 2),
  140. .common = {
  141. .reg = 0x028,
  142. .hw.init = CLK_HW_INIT("pll-periph-base",
  143. "hosc",
  144. &ccu_nk_ops,
  145. 0),
  146. },
  147. };
  148. static CLK_FIXED_FACTOR_HW(pll_periph_clk, "pll-periph",
  149. &pll_periph_base_clk.common.hw,
  150. 2, 1, CLK_SET_RATE_PARENT);
  151. /* Not documented on A10 */
  152. static struct ccu_div pll_periph_sata_clk = {
  153. .enable = BIT(14),
  154. .div = _SUNXI_CCU_DIV(0, 2),
  155. .fixed_post_div = 6,
  156. .common = {
  157. .reg = 0x028,
  158. .features = CCU_FEATURE_FIXED_POSTDIV,
  159. .hw.init = CLK_HW_INIT("pll-periph-sata",
  160. "pll-periph-base",
  161. &ccu_div_ops, 0),
  162. },
  163. };
  164. static struct ccu_mult pll_video1_clk = {
  165. .enable = BIT(31),
  166. .mult = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(0, 7, 0, 9, 127),
  167. .frac = _SUNXI_CCU_FRAC(BIT(15), BIT(14),
  168. 270000000, 297000000),
  169. .common = {
  170. .reg = 0x030,
  171. .features = (CCU_FEATURE_FRACTIONAL |
  172. CCU_FEATURE_ALL_PREDIV),
  173. .prediv = 8,
  174. .hw.init = CLK_HW_INIT("pll-video1",
  175. "hosc",
  176. &ccu_mult_ops,
  177. 0),
  178. },
  179. };
  180. /* Not present on A10 */
  181. static struct ccu_nk pll_gpu_clk = {
  182. .enable = BIT(31),
  183. .n = _SUNXI_CCU_MULT_OFFSET(8, 5, 0),
  184. .k = _SUNXI_CCU_MULT(4, 2),
  185. .common = {
  186. .reg = 0x040,
  187. .hw.init = CLK_HW_INIT("pll-gpu",
  188. "hosc",
  189. &ccu_nk_ops,
  190. 0),
  191. },
  192. };
  193. static SUNXI_CCU_GATE(hosc_clk, "hosc", "osc24M", 0x050, BIT(0), 0);
  194. static const char *const cpu_parents[] = { "osc32k", "hosc",
  195. "pll-core", "pll-periph" };
  196. static const struct ccu_mux_fixed_prediv cpu_predivs[] = {
  197. { .index = 3, .div = 3, },
  198. };
  199. #define SUN4I_AHB_REG 0x054
  200. static struct ccu_mux cpu_clk = {
  201. .mux = {
  202. .shift = 16,
  203. .width = 2,
  204. .fixed_predivs = cpu_predivs,
  205. .n_predivs = ARRAY_SIZE(cpu_predivs),
  206. },
  207. .common = {
  208. .reg = 0x054,
  209. .features = CCU_FEATURE_FIXED_PREDIV,
  210. .hw.init = CLK_HW_INIT_PARENTS("cpu",
  211. cpu_parents,
  212. &ccu_mux_ops,
  213. CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
  214. }
  215. };
  216. static SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x054, 0, 2, 0);
  217. static struct ccu_div ahb_sun4i_clk = {
  218. .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
  219. .common = {
  220. .reg = 0x054,
  221. .hw.init = CLK_HW_INIT("ahb", "axi", &ccu_div_ops, 0),
  222. },
  223. };
  224. static const char *const ahb_sun7i_parents[] = { "axi", "pll-periph",
  225. "pll-periph" };
  226. static const struct ccu_mux_fixed_prediv ahb_sun7i_predivs[] = {
  227. { .index = 1, .div = 2, },
  228. { /* Sentinel */ },
  229. };
  230. static struct ccu_div ahb_sun7i_clk = {
  231. .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
  232. .mux = {
  233. .shift = 6,
  234. .width = 2,
  235. .fixed_predivs = ahb_sun7i_predivs,
  236. .n_predivs = ARRAY_SIZE(ahb_sun7i_predivs),
  237. },
  238. .common = {
  239. .reg = 0x054,
  240. .hw.init = CLK_HW_INIT_PARENTS("ahb",
  241. ahb_sun7i_parents,
  242. &ccu_div_ops,
  243. 0),
  244. },
  245. };
  246. static struct clk_div_table apb0_div_table[] = {
  247. { .val = 0, .div = 2 },
  248. { .val = 1, .div = 2 },
  249. { .val = 2, .div = 4 },
  250. { .val = 3, .div = 8 },
  251. { /* Sentinel */ },
  252. };
  253. static SUNXI_CCU_DIV_TABLE(apb0_clk, "apb0", "ahb",
  254. 0x054, 8, 2, apb0_div_table, 0);
  255. static const char *const apb1_parents[] = { "hosc", "pll-periph", "osc32k" };
  256. static SUNXI_CCU_MP_WITH_MUX(apb1_clk, "apb1", apb1_parents, 0x058,
  257. 0, 5, /* M */
  258. 16, 2, /* P */
  259. 24, 2, /* mux */
  260. 0);
  261. /* Not present on A20 */
  262. static SUNXI_CCU_GATE(axi_dram_clk, "axi-dram", "ahb",
  263. 0x05c, BIT(31), 0);
  264. static SUNXI_CCU_GATE(ahb_otg_clk, "ahb-otg", "ahb",
  265. 0x060, BIT(0), 0);
  266. static SUNXI_CCU_GATE(ahb_ehci0_clk, "ahb-ehci0", "ahb",
  267. 0x060, BIT(1), 0);
  268. static SUNXI_CCU_GATE(ahb_ohci0_clk, "ahb-ohci0", "ahb",
  269. 0x060, BIT(2), 0);
  270. static SUNXI_CCU_GATE(ahb_ehci1_clk, "ahb-ehci1", "ahb",
  271. 0x060, BIT(3), 0);
  272. static SUNXI_CCU_GATE(ahb_ohci1_clk, "ahb-ohci1", "ahb",
  273. 0x060, BIT(4), 0);
  274. static SUNXI_CCU_GATE(ahb_ss_clk, "ahb-ss", "ahb",
  275. 0x060, BIT(5), 0);
  276. static SUNXI_CCU_GATE(ahb_dma_clk, "ahb-dma", "ahb",
  277. 0x060, BIT(6), 0);
  278. static SUNXI_CCU_GATE(ahb_bist_clk, "ahb-bist", "ahb",
  279. 0x060, BIT(7), 0);
  280. static SUNXI_CCU_GATE(ahb_mmc0_clk, "ahb-mmc0", "ahb",
  281. 0x060, BIT(8), 0);
  282. static SUNXI_CCU_GATE(ahb_mmc1_clk, "ahb-mmc1", "ahb",
  283. 0x060, BIT(9), 0);
  284. static SUNXI_CCU_GATE(ahb_mmc2_clk, "ahb-mmc2", "ahb",
  285. 0x060, BIT(10), 0);
  286. static SUNXI_CCU_GATE(ahb_mmc3_clk, "ahb-mmc3", "ahb",
  287. 0x060, BIT(11), 0);
  288. static SUNXI_CCU_GATE(ahb_ms_clk, "ahb-ms", "ahb",
  289. 0x060, BIT(12), 0);
  290. static SUNXI_CCU_GATE(ahb_nand_clk, "ahb-nand", "ahb",
  291. 0x060, BIT(13), 0);
  292. static SUNXI_CCU_GATE(ahb_sdram_clk, "ahb-sdram", "ahb",
  293. 0x060, BIT(14), CLK_IS_CRITICAL);
  294. static SUNXI_CCU_GATE(ahb_ace_clk, "ahb-ace", "ahb",
  295. 0x060, BIT(16), 0);
  296. static SUNXI_CCU_GATE(ahb_emac_clk, "ahb-emac", "ahb",
  297. 0x060, BIT(17), 0);
  298. static SUNXI_CCU_GATE(ahb_ts_clk, "ahb-ts", "ahb",
  299. 0x060, BIT(18), 0);
  300. static SUNXI_CCU_GATE(ahb_spi0_clk, "ahb-spi0", "ahb",
  301. 0x060, BIT(20), 0);
  302. static SUNXI_CCU_GATE(ahb_spi1_clk, "ahb-spi1", "ahb",
  303. 0x060, BIT(21), 0);
  304. static SUNXI_CCU_GATE(ahb_spi2_clk, "ahb-spi2", "ahb",
  305. 0x060, BIT(22), 0);
  306. static SUNXI_CCU_GATE(ahb_spi3_clk, "ahb-spi3", "ahb",
  307. 0x060, BIT(23), 0);
  308. static SUNXI_CCU_GATE(ahb_pata_clk, "ahb-pata", "ahb",
  309. 0x060, BIT(24), 0);
  310. /* Not documented on A20 */
  311. static SUNXI_CCU_GATE(ahb_sata_clk, "ahb-sata", "ahb",
  312. 0x060, BIT(25), 0);
  313. /* Not present on A20 */
  314. static SUNXI_CCU_GATE(ahb_gps_clk, "ahb-gps", "ahb",
  315. 0x060, BIT(26), 0);
  316. /* Not present on A10 */
  317. static SUNXI_CCU_GATE(ahb_hstimer_clk, "ahb-hstimer", "ahb",
  318. 0x060, BIT(28), 0);
  319. static SUNXI_CCU_GATE(ahb_ve_clk, "ahb-ve", "ahb",
  320. 0x064, BIT(0), 0);
  321. static SUNXI_CCU_GATE(ahb_tvd_clk, "ahb-tvd", "ahb",
  322. 0x064, BIT(1), 0);
  323. static SUNXI_CCU_GATE(ahb_tve0_clk, "ahb-tve0", "ahb",
  324. 0x064, BIT(2), 0);
  325. static SUNXI_CCU_GATE(ahb_tve1_clk, "ahb-tve1", "ahb",
  326. 0x064, BIT(3), 0);
  327. static SUNXI_CCU_GATE(ahb_lcd0_clk, "ahb-lcd0", "ahb",
  328. 0x064, BIT(4), 0);
  329. static SUNXI_CCU_GATE(ahb_lcd1_clk, "ahb-lcd1", "ahb",
  330. 0x064, BIT(5), 0);
  331. static SUNXI_CCU_GATE(ahb_csi0_clk, "ahb-csi0", "ahb",
  332. 0x064, BIT(8), 0);
  333. static SUNXI_CCU_GATE(ahb_csi1_clk, "ahb-csi1", "ahb",
  334. 0x064, BIT(9), 0);
  335. /* Not present on A10 */
  336. static SUNXI_CCU_GATE(ahb_hdmi1_clk, "ahb-hdmi1", "ahb",
  337. 0x064, BIT(10), 0);
  338. static SUNXI_CCU_GATE(ahb_hdmi0_clk, "ahb-hdmi0", "ahb",
  339. 0x064, BIT(11), 0);
  340. static SUNXI_CCU_GATE(ahb_de_be0_clk, "ahb-de-be0", "ahb",
  341. 0x064, BIT(12), 0);
  342. static SUNXI_CCU_GATE(ahb_de_be1_clk, "ahb-de-be1", "ahb",
  343. 0x064, BIT(13), 0);
  344. static SUNXI_CCU_GATE(ahb_de_fe0_clk, "ahb-de-fe0", "ahb",
  345. 0x064, BIT(14), 0);
  346. static SUNXI_CCU_GATE(ahb_de_fe1_clk, "ahb-de-fe1", "ahb",
  347. 0x064, BIT(15), 0);
  348. /* Not present on A10 */
  349. static SUNXI_CCU_GATE(ahb_gmac_clk, "ahb-gmac", "ahb",
  350. 0x064, BIT(17), 0);
  351. static SUNXI_CCU_GATE(ahb_mp_clk, "ahb-mp", "ahb",
  352. 0x064, BIT(18), 0);
  353. static SUNXI_CCU_GATE(ahb_gpu_clk, "ahb-gpu", "ahb",
  354. 0x064, BIT(20), 0);
  355. static SUNXI_CCU_GATE(apb0_codec_clk, "apb0-codec", "apb0",
  356. 0x068, BIT(0), 0);
  357. static SUNXI_CCU_GATE(apb0_spdif_clk, "apb0-spdif", "apb0",
  358. 0x068, BIT(1), 0);
  359. static SUNXI_CCU_GATE(apb0_ac97_clk, "apb0-ac97", "apb0",
  360. 0x068, BIT(2), 0);
  361. static SUNXI_CCU_GATE(apb0_i2s0_clk, "apb0-i2s0", "apb0",
  362. 0x068, BIT(3), 0);
  363. /* Not present on A10 */
  364. static SUNXI_CCU_GATE(apb0_i2s1_clk, "apb0-i2s1", "apb0",
  365. 0x068, BIT(4), 0);
  366. static SUNXI_CCU_GATE(apb0_pio_clk, "apb0-pio", "apb0",
  367. 0x068, BIT(5), 0);
  368. static SUNXI_CCU_GATE(apb0_ir0_clk, "apb0-ir0", "apb0",
  369. 0x068, BIT(6), 0);
  370. static SUNXI_CCU_GATE(apb0_ir1_clk, "apb0-ir1", "apb0",
  371. 0x068, BIT(7), 0);
  372. /* Not present on A10 */
  373. static SUNXI_CCU_GATE(apb0_i2s2_clk, "apb0-i2s2", "apb0",
  374. 0x068, BIT(8), 0);
  375. static SUNXI_CCU_GATE(apb0_keypad_clk, "apb0-keypad", "apb0",
  376. 0x068, BIT(10), 0);
  377. static SUNXI_CCU_GATE(apb1_i2c0_clk, "apb1-i2c0", "apb1",
  378. 0x06c, BIT(0), 0);
  379. static SUNXI_CCU_GATE(apb1_i2c1_clk, "apb1-i2c1", "apb1",
  380. 0x06c, BIT(1), 0);
  381. static SUNXI_CCU_GATE(apb1_i2c2_clk, "apb1-i2c2", "apb1",
  382. 0x06c, BIT(2), 0);
  383. /* Not present on A10 */
  384. static SUNXI_CCU_GATE(apb1_i2c3_clk, "apb1-i2c3", "apb1",
  385. 0x06c, BIT(3), 0);
  386. static SUNXI_CCU_GATE(apb1_can_clk, "apb1-can", "apb1",
  387. 0x06c, BIT(4), 0);
  388. static SUNXI_CCU_GATE(apb1_scr_clk, "apb1-scr", "apb1",
  389. 0x06c, BIT(5), 0);
  390. static SUNXI_CCU_GATE(apb1_ps20_clk, "apb1-ps20", "apb1",
  391. 0x06c, BIT(6), 0);
  392. static SUNXI_CCU_GATE(apb1_ps21_clk, "apb1-ps21", "apb1",
  393. 0x06c, BIT(7), 0);
  394. /* Not present on A10 */
  395. static SUNXI_CCU_GATE(apb1_i2c4_clk, "apb1-i2c4", "apb1",
  396. 0x06c, BIT(15), 0);
  397. static SUNXI_CCU_GATE(apb1_uart0_clk, "apb1-uart0", "apb1",
  398. 0x06c, BIT(16), 0);
  399. static SUNXI_CCU_GATE(apb1_uart1_clk, "apb1-uart1", "apb1",
  400. 0x06c, BIT(17), 0);
  401. static SUNXI_CCU_GATE(apb1_uart2_clk, "apb1-uart2", "apb1",
  402. 0x06c, BIT(18), 0);
  403. static SUNXI_CCU_GATE(apb1_uart3_clk, "apb1-uart3", "apb1",
  404. 0x06c, BIT(19), 0);
  405. static SUNXI_CCU_GATE(apb1_uart4_clk, "apb1-uart4", "apb1",
  406. 0x06c, BIT(20), 0);
  407. static SUNXI_CCU_GATE(apb1_uart5_clk, "apb1-uart5", "apb1",
  408. 0x06c, BIT(21), 0);
  409. static SUNXI_CCU_GATE(apb1_uart6_clk, "apb1-uart6", "apb1",
  410. 0x06c, BIT(22), 0);
  411. static SUNXI_CCU_GATE(apb1_uart7_clk, "apb1-uart7", "apb1",
  412. 0x06c, BIT(23), 0);
  413. static const char *const mod0_default_parents[] = { "hosc", "pll-periph",
  414. "pll-ddr-other" };
  415. static SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
  416. 0, 4, /* M */
  417. 16, 2, /* P */
  418. 24, 2, /* mux */
  419. BIT(31), /* gate */
  420. 0);
  421. /* Undocumented on A10 */
  422. static SUNXI_CCU_MP_WITH_MUX_GATE(ms_clk, "ms", mod0_default_parents, 0x084,
  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(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
  429. 0, 4, /* M */
  430. 16, 2, /* P */
  431. 24, 2, /* mux */
  432. BIT(31), /* gate */
  433. 0);
  434. /* MMC output and sample clocks are not present on A10 */
  435. static SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0",
  436. 0x088, 8, 3, 0);
  437. static SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0",
  438. 0x088, 20, 3, 0);
  439. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
  440. 0, 4, /* M */
  441. 16, 2, /* P */
  442. 24, 2, /* mux */
  443. BIT(31), /* gate */
  444. 0);
  445. /* MMC output and sample clocks are not present on A10 */
  446. static SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1",
  447. 0x08c, 8, 3, 0);
  448. static SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1",
  449. 0x08c, 20, 3, 0);
  450. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
  451. 0, 4, /* M */
  452. 16, 2, /* P */
  453. 24, 2, /* mux */
  454. BIT(31), /* gate */
  455. 0);
  456. /* MMC output and sample clocks are not present on A10 */
  457. static SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2_output", "mmc2",
  458. 0x090, 8, 3, 0);
  459. static SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2_sample", "mmc2",
  460. 0x090, 20, 3, 0);
  461. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc3_clk, "mmc3", mod0_default_parents, 0x094,
  462. 0, 4, /* M */
  463. 16, 2, /* P */
  464. 24, 2, /* mux */
  465. BIT(31), /* gate */
  466. 0);
  467. /* MMC output and sample clocks are not present on A10 */
  468. static SUNXI_CCU_PHASE(mmc3_output_clk, "mmc3_output", "mmc3",
  469. 0x094, 8, 3, 0);
  470. static SUNXI_CCU_PHASE(mmc3_sample_clk, "mmc3_sample", "mmc3",
  471. 0x094, 20, 3, 0);
  472. static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", mod0_default_parents, 0x098,
  473. 0, 4, /* M */
  474. 16, 2, /* P */
  475. 24, 2, /* mux */
  476. BIT(31), /* gate */
  477. 0);
  478. static SUNXI_CCU_MP_WITH_MUX_GATE(ss_clk, "ss", mod0_default_parents, 0x09c,
  479. 0, 4, /* M */
  480. 16, 2, /* P */
  481. 24, 2, /* mux */
  482. BIT(31), /* gate */
  483. 0);
  484. static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
  485. 0, 4, /* M */
  486. 16, 2, /* P */
  487. 24, 2, /* mux */
  488. BIT(31), /* gate */
  489. 0);
  490. static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
  491. 0, 4, /* M */
  492. 16, 2, /* P */
  493. 24, 2, /* mux */
  494. BIT(31), /* gate */
  495. 0);
  496. static SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", mod0_default_parents, 0x0a8,
  497. 0, 4, /* M */
  498. 16, 2, /* P */
  499. 24, 2, /* mux */
  500. BIT(31), /* gate */
  501. 0);
  502. /* Undocumented on A10 */
  503. static SUNXI_CCU_MP_WITH_MUX_GATE(pata_clk, "pata", mod0_default_parents, 0x0ac,
  504. 0, 4, /* M */
  505. 16, 2, /* P */
  506. 24, 2, /* mux */
  507. BIT(31), /* gate */
  508. 0);
  509. /* TODO: Check whether A10 actually supports osc32k as 4th parent? */
  510. static const char *const ir_parents_sun4i[] = { "hosc", "pll-periph",
  511. "pll-ddr-other" };
  512. static SUNXI_CCU_MP_WITH_MUX_GATE(ir0_sun4i_clk, "ir0", ir_parents_sun4i, 0x0b0,
  513. 0, 4, /* M */
  514. 16, 2, /* P */
  515. 24, 2, /* mux */
  516. BIT(31), /* gate */
  517. 0);
  518. static SUNXI_CCU_MP_WITH_MUX_GATE(ir1_sun4i_clk, "ir1", ir_parents_sun4i, 0x0b4,
  519. 0, 4, /* M */
  520. 16, 2, /* P */
  521. 24, 2, /* mux */
  522. BIT(31), /* gate */
  523. 0);
  524. static const char *const ir_parents_sun7i[] = { "hosc", "pll-periph",
  525. "pll-ddr-other", "osc32k" };
  526. static SUNXI_CCU_MP_WITH_MUX_GATE(ir0_sun7i_clk, "ir0", ir_parents_sun7i, 0x0b0,
  527. 0, 4, /* M */
  528. 16, 2, /* P */
  529. 24, 2, /* mux */
  530. BIT(31), /* gate */
  531. 0);
  532. static SUNXI_CCU_MP_WITH_MUX_GATE(ir1_sun7i_clk, "ir1", ir_parents_sun7i, 0x0b4,
  533. 0, 4, /* M */
  534. 16, 2, /* P */
  535. 24, 2, /* mux */
  536. BIT(31), /* gate */
  537. 0);
  538. static const char *const audio_parents[] = { "pll-audio-8x", "pll-audio-4x",
  539. "pll-audio-2x", "pll-audio" };
  540. static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", audio_parents,
  541. 0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  542. static SUNXI_CCU_MUX_WITH_GATE(ac97_clk, "ac97", audio_parents,
  543. 0x0bc, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  544. /* Undocumented on A10 */
  545. static SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", audio_parents,
  546. 0x0c0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  547. static const char *const keypad_parents[] = { "hosc", "losc"};
  548. static const u8 keypad_table[] = { 0, 2 };
  549. static struct ccu_mp keypad_clk = {
  550. .enable = BIT(31),
  551. .m = _SUNXI_CCU_DIV(0, 5),
  552. .p = _SUNXI_CCU_DIV(16, 2),
  553. .mux = _SUNXI_CCU_MUX_TABLE(24, 2, keypad_table),
  554. .common = {
  555. .reg = 0x0c4,
  556. .hw.init = CLK_HW_INIT_PARENTS("keypad",
  557. keypad_parents,
  558. &ccu_mp_ops,
  559. 0),
  560. },
  561. };
  562. /*
  563. * SATA supports external clock as parent via BIT(24) and is probably an
  564. * optional crystal or oscillator that can be connected to the
  565. * SATA-CLKM / SATA-CLKP pins.
  566. */
  567. static const char *const sata_parents[] = {"pll-periph-sata", "sata-ext"};
  568. static SUNXI_CCU_MUX_WITH_GATE(sata_clk, "sata", sata_parents,
  569. 0x0c8, 24, 1, BIT(31), CLK_SET_RATE_PARENT);
  570. static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "pll-periph",
  571. 0x0cc, BIT(6), 0);
  572. static SUNXI_CCU_GATE(usb_ohci1_clk, "usb-ohci1", "pll-periph",
  573. 0x0cc, BIT(7), 0);
  574. static SUNXI_CCU_GATE(usb_phy_clk, "usb-phy", "pll-periph",
  575. 0x0cc, BIT(8), 0);
  576. /* TODO: GPS CLK 0x0d0 */
  577. static SUNXI_CCU_MP_WITH_MUX_GATE(spi3_clk, "spi3", mod0_default_parents, 0x0d4,
  578. 0, 4, /* M */
  579. 16, 2, /* P */
  580. 24, 2, /* mux */
  581. BIT(31), /* gate */
  582. 0);
  583. /* Not present on A10 */
  584. static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", audio_parents,
  585. 0x0d8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  586. /* Not present on A10 */
  587. static SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", audio_parents,
  588. 0x0dc, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
  589. static SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "pll-ddr",
  590. 0x100, BIT(0), 0);
  591. static SUNXI_CCU_GATE(dram_csi0_clk, "dram-csi0", "pll-ddr",
  592. 0x100, BIT(1), 0);
  593. static SUNXI_CCU_GATE(dram_csi1_clk, "dram-csi1", "pll-ddr",
  594. 0x100, BIT(2), 0);
  595. static SUNXI_CCU_GATE(dram_ts_clk, "dram-ts", "pll-ddr",
  596. 0x100, BIT(3), 0);
  597. static SUNXI_CCU_GATE(dram_tvd_clk, "dram-tvd", "pll-ddr",
  598. 0x100, BIT(4), 0);
  599. static SUNXI_CCU_GATE(dram_tve0_clk, "dram-tve0", "pll-ddr",
  600. 0x100, BIT(5), 0);
  601. static SUNXI_CCU_GATE(dram_tve1_clk, "dram-tve1", "pll-ddr",
  602. 0x100, BIT(6), 0);
  603. /* Clock seems to be critical only on sun4i */
  604. static SUNXI_CCU_GATE(dram_out_clk, "dram-out", "pll-ddr",
  605. 0x100, BIT(15), CLK_IS_CRITICAL);
  606. static SUNXI_CCU_GATE(dram_de_fe1_clk, "dram-de-fe1", "pll-ddr",
  607. 0x100, BIT(24), 0);
  608. static SUNXI_CCU_GATE(dram_de_fe0_clk, "dram-de-fe0", "pll-ddr",
  609. 0x100, BIT(25), 0);
  610. static SUNXI_CCU_GATE(dram_de_be0_clk, "dram-de-be0", "pll-ddr",
  611. 0x100, BIT(26), 0);
  612. static SUNXI_CCU_GATE(dram_de_be1_clk, "dram-de-be1", "pll-ddr",
  613. 0x100, BIT(27), 0);
  614. static SUNXI_CCU_GATE(dram_mp_clk, "dram-mp", "pll-ddr",
  615. 0x100, BIT(28), 0);
  616. static SUNXI_CCU_GATE(dram_ace_clk, "dram-ace", "pll-ddr",
  617. 0x100, BIT(29), 0);
  618. static const char *const de_parents[] = { "pll-video0", "pll-video1",
  619. "pll-ddr-other" };
  620. static SUNXI_CCU_M_WITH_MUX_GATE(de_be0_clk, "de-be0", de_parents,
  621. 0x104, 0, 4, 24, 2, BIT(31), 0);
  622. static SUNXI_CCU_M_WITH_MUX_GATE(de_be1_clk, "de-be1", de_parents,
  623. 0x108, 0, 4, 24, 2, BIT(31), 0);
  624. static SUNXI_CCU_M_WITH_MUX_GATE(de_fe0_clk, "de-fe0", de_parents,
  625. 0x10c, 0, 4, 24, 2, BIT(31), 0);
  626. static SUNXI_CCU_M_WITH_MUX_GATE(de_fe1_clk, "de-fe1", de_parents,
  627. 0x110, 0, 4, 24, 2, BIT(31), 0);
  628. /* Undocumented on A10 */
  629. static SUNXI_CCU_M_WITH_MUX_GATE(de_mp_clk, "de-mp", de_parents,
  630. 0x114, 0, 4, 24, 2, BIT(31), 0);
  631. static const char *const disp_parents[] = { "pll-video0", "pll-video1",
  632. "pll-video0-2x", "pll-video1-2x" };
  633. static SUNXI_CCU_MUX_WITH_GATE(tcon0_ch0_clk, "tcon0-ch0-sclk", disp_parents,
  634. 0x118, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
  635. static SUNXI_CCU_MUX_WITH_GATE(tcon1_ch0_clk, "tcon1-ch0-sclk", disp_parents,
  636. 0x11c, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
  637. static const char *const csi_sclk_parents[] = { "pll-video0", "pll-ve",
  638. "pll-ddr-other", "pll-periph" };
  639. static SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk",
  640. csi_sclk_parents,
  641. 0x120, 0, 4, 24, 2, BIT(31), 0);
  642. /* TVD clock setup for A10 */
  643. static const char *const tvd_parents[] = { "pll-video0", "pll-video1" };
  644. static SUNXI_CCU_MUX_WITH_GATE(tvd_sun4i_clk, "tvd", tvd_parents,
  645. 0x128, 24, 1, BIT(31), 0);
  646. /* TVD clock setup for A20 */
  647. static SUNXI_CCU_MP_WITH_MUX_GATE(tvd_sclk2_sun7i_clk,
  648. "tvd-sclk2", tvd_parents,
  649. 0x128,
  650. 0, 4, /* M */
  651. 16, 4, /* P */
  652. 8, 1, /* mux */
  653. BIT(15), /* gate */
  654. 0);
  655. static SUNXI_CCU_M_WITH_GATE(tvd_sclk1_sun7i_clk, "tvd-sclk1", "tvd-sclk2",
  656. 0x128, 0, 4, BIT(31), 0);
  657. static SUNXI_CCU_M_WITH_MUX_GATE(tcon0_ch1_sclk2_clk, "tcon0-ch1-sclk2",
  658. disp_parents,
  659. 0x12c, 0, 4, 24, 2, BIT(31),
  660. CLK_SET_RATE_PARENT);
  661. static SUNXI_CCU_M_WITH_GATE(tcon0_ch1_clk,
  662. "tcon0-ch1-sclk1", "tcon0-ch1-sclk2",
  663. 0x12c, 11, 1, BIT(15),
  664. CLK_SET_RATE_PARENT);
  665. static SUNXI_CCU_M_WITH_MUX_GATE(tcon1_ch1_sclk2_clk, "tcon1-ch1-sclk2",
  666. disp_parents,
  667. 0x130, 0, 4, 24, 2, BIT(31),
  668. CLK_SET_RATE_PARENT);
  669. static SUNXI_CCU_M_WITH_GATE(tcon1_ch1_clk,
  670. "tcon1-ch1-sclk1", "tcon1-ch1-sclk2",
  671. 0x130, 11, 1, BIT(15),
  672. CLK_SET_RATE_PARENT);
  673. static const char *const csi_parents[] = { "hosc", "pll-video0", "pll-video1",
  674. "pll-video0-2x", "pll-video1-2x"};
  675. static const u8 csi_table[] = { 0, 1, 2, 5, 6};
  676. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi0_clk, "csi0",
  677. csi_parents, csi_table,
  678. 0x134, 0, 5, 24, 3, BIT(31), 0);
  679. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi1_clk, "csi1",
  680. csi_parents, csi_table,
  681. 0x138, 0, 5, 24, 3, BIT(31), 0);
  682. static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 0x13c, 16, 8, BIT(31), 0);
  683. static SUNXI_CCU_GATE(codec_clk, "codec", "pll-audio",
  684. 0x140, BIT(31), CLK_SET_RATE_PARENT);
  685. static SUNXI_CCU_GATE(avs_clk, "avs", "hosc", 0x144, BIT(31), 0);
  686. static const char *const ace_parents[] = { "pll-ve", "pll-ddr-other" };
  687. static SUNXI_CCU_M_WITH_MUX_GATE(ace_clk, "ace", ace_parents,
  688. 0x148, 0, 4, 24, 1, BIT(31), 0);
  689. static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", disp_parents,
  690. 0x150, 0, 4, 24, 2, BIT(31),
  691. CLK_SET_RATE_PARENT);
  692. static const char *const gpu_parents_sun4i[] = { "pll-video0", "pll-ve",
  693. "pll-ddr-other",
  694. "pll-video1" };
  695. static SUNXI_CCU_M_WITH_MUX_GATE(gpu_sun4i_clk, "gpu", gpu_parents_sun4i,
  696. 0x154, 0, 4, 24, 2, BIT(31),
  697. CLK_SET_RATE_PARENT);
  698. static const char *const gpu_parents_sun7i[] = { "pll-video0", "pll-ve",
  699. "pll-ddr-other", "pll-video1",
  700. "pll-gpu" };
  701. static const u8 gpu_table_sun7i[] = { 0, 1, 2, 3, 4 };
  702. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(gpu_sun7i_clk, "gpu",
  703. gpu_parents_sun7i, gpu_table_sun7i,
  704. 0x154, 0, 4, 24, 3, BIT(31),
  705. CLK_SET_RATE_PARENT);
  706. static const char *const mbus_sun4i_parents[] = { "hosc", "pll-periph",
  707. "pll-ddr-other" };
  708. static SUNXI_CCU_MP_WITH_MUX_GATE(mbus_sun4i_clk, "mbus", mbus_sun4i_parents,
  709. 0x15c, 0, 4, 16, 2, 24, 2, BIT(31),
  710. 0);
  711. static const char *const mbus_sun7i_parents[] = { "hosc", "pll-periph-base",
  712. "pll-ddr-other" };
  713. static SUNXI_CCU_MP_WITH_MUX_GATE(mbus_sun7i_clk, "mbus", mbus_sun7i_parents,
  714. 0x15c, 0, 4, 16, 2, 24, 2, BIT(31),
  715. CLK_IS_CRITICAL);
  716. static SUNXI_CCU_GATE(hdmi1_slow_clk, "hdmi1-slow", "hosc", 0x178, BIT(31), 0);
  717. static const char *const hdmi1_parents[] = { "pll-video0", "pll-video1" };
  718. static const u8 hdmi1_table[] = { 0, 1};
  719. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(hdmi1_clk, "hdmi1",
  720. hdmi1_parents, hdmi1_table,
  721. 0x17c, 0, 4, 24, 2, BIT(31),
  722. CLK_SET_RATE_PARENT);
  723. static const char *const out_parents[] = { "hosc", "osc32k", "hosc" };
  724. static const struct ccu_mux_fixed_prediv clk_out_predivs[] = {
  725. { .index = 0, .div = 750, },
  726. };
  727. static struct ccu_mp out_a_clk = {
  728. .enable = BIT(31),
  729. .m = _SUNXI_CCU_DIV(8, 5),
  730. .p = _SUNXI_CCU_DIV(20, 2),
  731. .mux = {
  732. .shift = 24,
  733. .width = 2,
  734. .fixed_predivs = clk_out_predivs,
  735. .n_predivs = ARRAY_SIZE(clk_out_predivs),
  736. },
  737. .common = {
  738. .reg = 0x1f0,
  739. .features = CCU_FEATURE_FIXED_PREDIV,
  740. .hw.init = CLK_HW_INIT_PARENTS("out-a",
  741. out_parents,
  742. &ccu_mp_ops,
  743. 0),
  744. },
  745. };
  746. static struct ccu_mp out_b_clk = {
  747. .enable = BIT(31),
  748. .m = _SUNXI_CCU_DIV(8, 5),
  749. .p = _SUNXI_CCU_DIV(20, 2),
  750. .mux = {
  751. .shift = 24,
  752. .width = 2,
  753. .fixed_predivs = clk_out_predivs,
  754. .n_predivs = ARRAY_SIZE(clk_out_predivs),
  755. },
  756. .common = {
  757. .reg = 0x1f4,
  758. .features = CCU_FEATURE_FIXED_PREDIV,
  759. .hw.init = CLK_HW_INIT_PARENTS("out-b",
  760. out_parents,
  761. &ccu_mp_ops,
  762. 0),
  763. },
  764. };
  765. static struct ccu_common *sun4i_sun7i_ccu_clks[] = {
  766. &hosc_clk.common,
  767. &pll_core_clk.common,
  768. &pll_audio_base_clk.common,
  769. &pll_video0_clk.common,
  770. &pll_ve_sun4i_clk.common,
  771. &pll_ve_sun7i_clk.common,
  772. &pll_ddr_base_clk.common,
  773. &pll_ddr_clk.common,
  774. &pll_ddr_other_clk.common,
  775. &pll_periph_base_clk.common,
  776. &pll_periph_sata_clk.common,
  777. &pll_video1_clk.common,
  778. &pll_gpu_clk.common,
  779. &cpu_clk.common,
  780. &axi_clk.common,
  781. &axi_dram_clk.common,
  782. &ahb_sun4i_clk.common,
  783. &ahb_sun7i_clk.common,
  784. &apb0_clk.common,
  785. &apb1_clk.common,
  786. &ahb_otg_clk.common,
  787. &ahb_ehci0_clk.common,
  788. &ahb_ohci0_clk.common,
  789. &ahb_ehci1_clk.common,
  790. &ahb_ohci1_clk.common,
  791. &ahb_ss_clk.common,
  792. &ahb_dma_clk.common,
  793. &ahb_bist_clk.common,
  794. &ahb_mmc0_clk.common,
  795. &ahb_mmc1_clk.common,
  796. &ahb_mmc2_clk.common,
  797. &ahb_mmc3_clk.common,
  798. &ahb_ms_clk.common,
  799. &ahb_nand_clk.common,
  800. &ahb_sdram_clk.common,
  801. &ahb_ace_clk.common,
  802. &ahb_emac_clk.common,
  803. &ahb_ts_clk.common,
  804. &ahb_spi0_clk.common,
  805. &ahb_spi1_clk.common,
  806. &ahb_spi2_clk.common,
  807. &ahb_spi3_clk.common,
  808. &ahb_pata_clk.common,
  809. &ahb_sata_clk.common,
  810. &ahb_gps_clk.common,
  811. &ahb_hstimer_clk.common,
  812. &ahb_ve_clk.common,
  813. &ahb_tvd_clk.common,
  814. &ahb_tve0_clk.common,
  815. &ahb_tve1_clk.common,
  816. &ahb_lcd0_clk.common,
  817. &ahb_lcd1_clk.common,
  818. &ahb_csi0_clk.common,
  819. &ahb_csi1_clk.common,
  820. &ahb_hdmi1_clk.common,
  821. &ahb_hdmi0_clk.common,
  822. &ahb_de_be0_clk.common,
  823. &ahb_de_be1_clk.common,
  824. &ahb_de_fe0_clk.common,
  825. &ahb_de_fe1_clk.common,
  826. &ahb_gmac_clk.common,
  827. &ahb_mp_clk.common,
  828. &ahb_gpu_clk.common,
  829. &apb0_codec_clk.common,
  830. &apb0_spdif_clk.common,
  831. &apb0_ac97_clk.common,
  832. &apb0_i2s0_clk.common,
  833. &apb0_i2s1_clk.common,
  834. &apb0_pio_clk.common,
  835. &apb0_ir0_clk.common,
  836. &apb0_ir1_clk.common,
  837. &apb0_i2s2_clk.common,
  838. &apb0_keypad_clk.common,
  839. &apb1_i2c0_clk.common,
  840. &apb1_i2c1_clk.common,
  841. &apb1_i2c2_clk.common,
  842. &apb1_i2c3_clk.common,
  843. &apb1_can_clk.common,
  844. &apb1_scr_clk.common,
  845. &apb1_ps20_clk.common,
  846. &apb1_ps21_clk.common,
  847. &apb1_i2c4_clk.common,
  848. &apb1_uart0_clk.common,
  849. &apb1_uart1_clk.common,
  850. &apb1_uart2_clk.common,
  851. &apb1_uart3_clk.common,
  852. &apb1_uart4_clk.common,
  853. &apb1_uart5_clk.common,
  854. &apb1_uart6_clk.common,
  855. &apb1_uart7_clk.common,
  856. &nand_clk.common,
  857. &ms_clk.common,
  858. &mmc0_clk.common,
  859. &mmc0_output_clk.common,
  860. &mmc0_sample_clk.common,
  861. &mmc1_clk.common,
  862. &mmc1_output_clk.common,
  863. &mmc1_sample_clk.common,
  864. &mmc2_clk.common,
  865. &mmc2_output_clk.common,
  866. &mmc2_sample_clk.common,
  867. &mmc3_clk.common,
  868. &mmc3_output_clk.common,
  869. &mmc3_sample_clk.common,
  870. &ts_clk.common,
  871. &ss_clk.common,
  872. &spi0_clk.common,
  873. &spi1_clk.common,
  874. &spi2_clk.common,
  875. &pata_clk.common,
  876. &ir0_sun4i_clk.common,
  877. &ir1_sun4i_clk.common,
  878. &ir0_sun7i_clk.common,
  879. &ir1_sun7i_clk.common,
  880. &i2s0_clk.common,
  881. &ac97_clk.common,
  882. &spdif_clk.common,
  883. &keypad_clk.common,
  884. &sata_clk.common,
  885. &usb_ohci0_clk.common,
  886. &usb_ohci1_clk.common,
  887. &usb_phy_clk.common,
  888. &spi3_clk.common,
  889. &i2s1_clk.common,
  890. &i2s2_clk.common,
  891. &dram_ve_clk.common,
  892. &dram_csi0_clk.common,
  893. &dram_csi1_clk.common,
  894. &dram_ts_clk.common,
  895. &dram_tvd_clk.common,
  896. &dram_tve0_clk.common,
  897. &dram_tve1_clk.common,
  898. &dram_out_clk.common,
  899. &dram_de_fe1_clk.common,
  900. &dram_de_fe0_clk.common,
  901. &dram_de_be0_clk.common,
  902. &dram_de_be1_clk.common,
  903. &dram_mp_clk.common,
  904. &dram_ace_clk.common,
  905. &de_be0_clk.common,
  906. &de_be1_clk.common,
  907. &de_fe0_clk.common,
  908. &de_fe1_clk.common,
  909. &de_mp_clk.common,
  910. &tcon0_ch0_clk.common,
  911. &tcon1_ch0_clk.common,
  912. &csi_sclk_clk.common,
  913. &tvd_sun4i_clk.common,
  914. &tvd_sclk1_sun7i_clk.common,
  915. &tvd_sclk2_sun7i_clk.common,
  916. &tcon0_ch1_sclk2_clk.common,
  917. &tcon0_ch1_clk.common,
  918. &tcon1_ch1_sclk2_clk.common,
  919. &tcon1_ch1_clk.common,
  920. &csi0_clk.common,
  921. &csi1_clk.common,
  922. &ve_clk.common,
  923. &codec_clk.common,
  924. &avs_clk.common,
  925. &ace_clk.common,
  926. &hdmi_clk.common,
  927. &gpu_sun4i_clk.common,
  928. &gpu_sun7i_clk.common,
  929. &mbus_sun4i_clk.common,
  930. &mbus_sun7i_clk.common,
  931. &hdmi1_slow_clk.common,
  932. &hdmi1_clk.common,
  933. &out_a_clk.common,
  934. &out_b_clk.common
  935. };
  936. static const struct clk_hw *clk_parent_pll_audio[] = {
  937. &pll_audio_base_clk.common.hw
  938. };
  939. /* Post-divider for pll-audio is hardcoded to 1 */
  940. static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
  941. clk_parent_pll_audio,
  942. 1, 1, CLK_SET_RATE_PARENT);
  943. static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
  944. clk_parent_pll_audio,
  945. 2, 1, CLK_SET_RATE_PARENT);
  946. static CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x",
  947. clk_parent_pll_audio,
  948. 1, 1, CLK_SET_RATE_PARENT);
  949. static CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x",
  950. clk_parent_pll_audio,
  951. 1, 2, CLK_SET_RATE_PARENT);
  952. static CLK_FIXED_FACTOR_HW(pll_video0_2x_clk, "pll-video0-2x",
  953. &pll_video0_clk.common.hw,
  954. 1, 2, CLK_SET_RATE_PARENT);
  955. static CLK_FIXED_FACTOR_HW(pll_video1_2x_clk, "pll-video1-2x",
  956. &pll_video1_clk.common.hw,
  957. 1, 2, CLK_SET_RATE_PARENT);
  958. static struct clk_hw_onecell_data sun4i_a10_hw_clks = {
  959. .hws = {
  960. [CLK_HOSC] = &hosc_clk.common.hw,
  961. [CLK_PLL_CORE] = &pll_core_clk.common.hw,
  962. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  963. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  964. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  965. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  966. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  967. [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw,
  968. [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw,
  969. [CLK_PLL_VE] = &pll_ve_sun4i_clk.common.hw,
  970. [CLK_PLL_DDR_BASE] = &pll_ddr_base_clk.common.hw,
  971. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  972. [CLK_PLL_DDR_OTHER] = &pll_ddr_other_clk.common.hw,
  973. [CLK_PLL_PERIPH_BASE] = &pll_periph_base_clk.common.hw,
  974. [CLK_PLL_PERIPH] = &pll_periph_clk.hw,
  975. [CLK_PLL_PERIPH_SATA] = &pll_periph_sata_clk.common.hw,
  976. [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw,
  977. [CLK_PLL_VIDEO1_2X] = &pll_video1_2x_clk.hw,
  978. [CLK_CPU] = &cpu_clk.common.hw,
  979. [CLK_AXI] = &axi_clk.common.hw,
  980. [CLK_AXI_DRAM] = &axi_dram_clk.common.hw,
  981. [CLK_AHB] = &ahb_sun4i_clk.common.hw,
  982. [CLK_APB0] = &apb0_clk.common.hw,
  983. [CLK_APB1] = &apb1_clk.common.hw,
  984. [CLK_AHB_OTG] = &ahb_otg_clk.common.hw,
  985. [CLK_AHB_EHCI0] = &ahb_ehci0_clk.common.hw,
  986. [CLK_AHB_OHCI0] = &ahb_ohci0_clk.common.hw,
  987. [CLK_AHB_EHCI1] = &ahb_ehci1_clk.common.hw,
  988. [CLK_AHB_OHCI1] = &ahb_ohci1_clk.common.hw,
  989. [CLK_AHB_SS] = &ahb_ss_clk.common.hw,
  990. [CLK_AHB_DMA] = &ahb_dma_clk.common.hw,
  991. [CLK_AHB_BIST] = &ahb_bist_clk.common.hw,
  992. [CLK_AHB_MMC0] = &ahb_mmc0_clk.common.hw,
  993. [CLK_AHB_MMC1] = &ahb_mmc1_clk.common.hw,
  994. [CLK_AHB_MMC2] = &ahb_mmc2_clk.common.hw,
  995. [CLK_AHB_MMC3] = &ahb_mmc3_clk.common.hw,
  996. [CLK_AHB_MS] = &ahb_ms_clk.common.hw,
  997. [CLK_AHB_NAND] = &ahb_nand_clk.common.hw,
  998. [CLK_AHB_SDRAM] = &ahb_sdram_clk.common.hw,
  999. [CLK_AHB_ACE] = &ahb_ace_clk.common.hw,
  1000. [CLK_AHB_EMAC] = &ahb_emac_clk.common.hw,
  1001. [CLK_AHB_TS] = &ahb_ts_clk.common.hw,
  1002. [CLK_AHB_SPI0] = &ahb_spi0_clk.common.hw,
  1003. [CLK_AHB_SPI1] = &ahb_spi1_clk.common.hw,
  1004. [CLK_AHB_SPI2] = &ahb_spi2_clk.common.hw,
  1005. [CLK_AHB_SPI3] = &ahb_spi3_clk.common.hw,
  1006. [CLK_AHB_PATA] = &ahb_pata_clk.common.hw,
  1007. [CLK_AHB_SATA] = &ahb_sata_clk.common.hw,
  1008. [CLK_AHB_GPS] = &ahb_gps_clk.common.hw,
  1009. [CLK_AHB_VE] = &ahb_ve_clk.common.hw,
  1010. [CLK_AHB_TVD] = &ahb_tvd_clk.common.hw,
  1011. [CLK_AHB_TVE0] = &ahb_tve0_clk.common.hw,
  1012. [CLK_AHB_TVE1] = &ahb_tve1_clk.common.hw,
  1013. [CLK_AHB_LCD0] = &ahb_lcd0_clk.common.hw,
  1014. [CLK_AHB_LCD1] = &ahb_lcd1_clk.common.hw,
  1015. [CLK_AHB_CSI0] = &ahb_csi0_clk.common.hw,
  1016. [CLK_AHB_CSI1] = &ahb_csi1_clk.common.hw,
  1017. [CLK_AHB_HDMI0] = &ahb_hdmi0_clk.common.hw,
  1018. [CLK_AHB_DE_BE0] = &ahb_de_be0_clk.common.hw,
  1019. [CLK_AHB_DE_BE1] = &ahb_de_be1_clk.common.hw,
  1020. [CLK_AHB_DE_FE0] = &ahb_de_fe0_clk.common.hw,
  1021. [CLK_AHB_DE_FE1] = &ahb_de_fe1_clk.common.hw,
  1022. [CLK_AHB_MP] = &ahb_mp_clk.common.hw,
  1023. [CLK_AHB_GPU] = &ahb_gpu_clk.common.hw,
  1024. [CLK_APB0_CODEC] = &apb0_codec_clk.common.hw,
  1025. [CLK_APB0_SPDIF] = &apb0_spdif_clk.common.hw,
  1026. [CLK_APB0_AC97] = &apb0_ac97_clk.common.hw,
  1027. [CLK_APB0_I2S0] = &apb0_i2s0_clk.common.hw,
  1028. [CLK_APB0_PIO] = &apb0_pio_clk.common.hw,
  1029. [CLK_APB0_IR0] = &apb0_ir0_clk.common.hw,
  1030. [CLK_APB0_IR1] = &apb0_ir1_clk.common.hw,
  1031. [CLK_APB0_KEYPAD] = &apb0_keypad_clk.common.hw,
  1032. [CLK_APB1_I2C0] = &apb1_i2c0_clk.common.hw,
  1033. [CLK_APB1_I2C1] = &apb1_i2c1_clk.common.hw,
  1034. [CLK_APB1_I2C2] = &apb1_i2c2_clk.common.hw,
  1035. [CLK_APB1_CAN] = &apb1_can_clk.common.hw,
  1036. [CLK_APB1_SCR] = &apb1_scr_clk.common.hw,
  1037. [CLK_APB1_PS20] = &apb1_ps20_clk.common.hw,
  1038. [CLK_APB1_PS21] = &apb1_ps21_clk.common.hw,
  1039. [CLK_APB1_UART0] = &apb1_uart0_clk.common.hw,
  1040. [CLK_APB1_UART1] = &apb1_uart1_clk.common.hw,
  1041. [CLK_APB1_UART2] = &apb1_uart2_clk.common.hw,
  1042. [CLK_APB1_UART3] = &apb1_uart3_clk.common.hw,
  1043. [CLK_APB1_UART4] = &apb1_uart4_clk.common.hw,
  1044. [CLK_APB1_UART5] = &apb1_uart5_clk.common.hw,
  1045. [CLK_APB1_UART6] = &apb1_uart6_clk.common.hw,
  1046. [CLK_APB1_UART7] = &apb1_uart7_clk.common.hw,
  1047. [CLK_NAND] = &nand_clk.common.hw,
  1048. [CLK_MS] = &ms_clk.common.hw,
  1049. [CLK_MMC0] = &mmc0_clk.common.hw,
  1050. [CLK_MMC1] = &mmc1_clk.common.hw,
  1051. [CLK_MMC2] = &mmc2_clk.common.hw,
  1052. [CLK_MMC3] = &mmc3_clk.common.hw,
  1053. [CLK_TS] = &ts_clk.common.hw,
  1054. [CLK_SS] = &ss_clk.common.hw,
  1055. [CLK_SPI0] = &spi0_clk.common.hw,
  1056. [CLK_SPI1] = &spi1_clk.common.hw,
  1057. [CLK_SPI2] = &spi2_clk.common.hw,
  1058. [CLK_PATA] = &pata_clk.common.hw,
  1059. [CLK_IR0] = &ir0_sun4i_clk.common.hw,
  1060. [CLK_IR1] = &ir1_sun4i_clk.common.hw,
  1061. [CLK_I2S0] = &i2s0_clk.common.hw,
  1062. [CLK_AC97] = &ac97_clk.common.hw,
  1063. [CLK_SPDIF] = &spdif_clk.common.hw,
  1064. [CLK_KEYPAD] = &keypad_clk.common.hw,
  1065. [CLK_SATA] = &sata_clk.common.hw,
  1066. [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw,
  1067. [CLK_USB_OHCI1] = &usb_ohci1_clk.common.hw,
  1068. [CLK_USB_PHY] = &usb_phy_clk.common.hw,
  1069. /* CLK_GPS is unimplemented */
  1070. [CLK_SPI3] = &spi3_clk.common.hw,
  1071. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  1072. [CLK_DRAM_CSI0] = &dram_csi0_clk.common.hw,
  1073. [CLK_DRAM_CSI1] = &dram_csi1_clk.common.hw,
  1074. [CLK_DRAM_TS] = &dram_ts_clk.common.hw,
  1075. [CLK_DRAM_TVD] = &dram_tvd_clk.common.hw,
  1076. [CLK_DRAM_TVE0] = &dram_tve0_clk.common.hw,
  1077. [CLK_DRAM_TVE1] = &dram_tve1_clk.common.hw,
  1078. [CLK_DRAM_OUT] = &dram_out_clk.common.hw,
  1079. [CLK_DRAM_DE_FE1] = &dram_de_fe1_clk.common.hw,
  1080. [CLK_DRAM_DE_FE0] = &dram_de_fe0_clk.common.hw,
  1081. [CLK_DRAM_DE_BE0] = &dram_de_be0_clk.common.hw,
  1082. [CLK_DRAM_DE_BE1] = &dram_de_be1_clk.common.hw,
  1083. [CLK_DRAM_MP] = &dram_mp_clk.common.hw,
  1084. [CLK_DRAM_ACE] = &dram_ace_clk.common.hw,
  1085. [CLK_DE_BE0] = &de_be0_clk.common.hw,
  1086. [CLK_DE_BE1] = &de_be1_clk.common.hw,
  1087. [CLK_DE_FE0] = &de_fe0_clk.common.hw,
  1088. [CLK_DE_FE1] = &de_fe1_clk.common.hw,
  1089. [CLK_DE_MP] = &de_mp_clk.common.hw,
  1090. [CLK_TCON0_CH0] = &tcon0_ch0_clk.common.hw,
  1091. [CLK_TCON1_CH0] = &tcon1_ch0_clk.common.hw,
  1092. [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw,
  1093. [CLK_TVD] = &tvd_sun4i_clk.common.hw,
  1094. [CLK_TCON0_CH1_SCLK2] = &tcon0_ch1_sclk2_clk.common.hw,
  1095. [CLK_TCON0_CH1] = &tcon0_ch1_clk.common.hw,
  1096. [CLK_TCON1_CH1_SCLK2] = &tcon1_ch1_sclk2_clk.common.hw,
  1097. [CLK_TCON1_CH1] = &tcon1_ch1_clk.common.hw,
  1098. [CLK_CSI0] = &csi0_clk.common.hw,
  1099. [CLK_CSI1] = &csi1_clk.common.hw,
  1100. [CLK_VE] = &ve_clk.common.hw,
  1101. [CLK_CODEC] = &codec_clk.common.hw,
  1102. [CLK_AVS] = &avs_clk.common.hw,
  1103. [CLK_ACE] = &ace_clk.common.hw,
  1104. [CLK_HDMI] = &hdmi_clk.common.hw,
  1105. [CLK_GPU] = &gpu_sun7i_clk.common.hw,
  1106. [CLK_MBUS] = &mbus_sun4i_clk.common.hw,
  1107. },
  1108. .num = CLK_NUMBER_SUN4I,
  1109. };
  1110. static struct clk_hw_onecell_data sun7i_a20_hw_clks = {
  1111. .hws = {
  1112. [CLK_HOSC] = &hosc_clk.common.hw,
  1113. [CLK_PLL_CORE] = &pll_core_clk.common.hw,
  1114. [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw,
  1115. [CLK_PLL_AUDIO] = &pll_audio_clk.hw,
  1116. [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw,
  1117. [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw,
  1118. [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw,
  1119. [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw,
  1120. [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw,
  1121. [CLK_PLL_VE] = &pll_ve_sun7i_clk.common.hw,
  1122. [CLK_PLL_DDR_BASE] = &pll_ddr_base_clk.common.hw,
  1123. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  1124. [CLK_PLL_DDR_OTHER] = &pll_ddr_other_clk.common.hw,
  1125. [CLK_PLL_PERIPH_BASE] = &pll_periph_base_clk.common.hw,
  1126. [CLK_PLL_PERIPH] = &pll_periph_clk.hw,
  1127. [CLK_PLL_PERIPH_SATA] = &pll_periph_sata_clk.common.hw,
  1128. [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw,
  1129. [CLK_PLL_VIDEO1_2X] = &pll_video1_2x_clk.hw,
  1130. [CLK_PLL_GPU] = &pll_gpu_clk.common.hw,
  1131. [CLK_CPU] = &cpu_clk.common.hw,
  1132. [CLK_AXI] = &axi_clk.common.hw,
  1133. [CLK_AHB] = &ahb_sun7i_clk.common.hw,
  1134. [CLK_APB0] = &apb0_clk.common.hw,
  1135. [CLK_APB1] = &apb1_clk.common.hw,
  1136. [CLK_AHB_OTG] = &ahb_otg_clk.common.hw,
  1137. [CLK_AHB_EHCI0] = &ahb_ehci0_clk.common.hw,
  1138. [CLK_AHB_OHCI0] = &ahb_ohci0_clk.common.hw,
  1139. [CLK_AHB_EHCI1] = &ahb_ehci1_clk.common.hw,
  1140. [CLK_AHB_OHCI1] = &ahb_ohci1_clk.common.hw,
  1141. [CLK_AHB_SS] = &ahb_ss_clk.common.hw,
  1142. [CLK_AHB_DMA] = &ahb_dma_clk.common.hw,
  1143. [CLK_AHB_BIST] = &ahb_bist_clk.common.hw,
  1144. [CLK_AHB_MMC0] = &ahb_mmc0_clk.common.hw,
  1145. [CLK_AHB_MMC1] = &ahb_mmc1_clk.common.hw,
  1146. [CLK_AHB_MMC2] = &ahb_mmc2_clk.common.hw,
  1147. [CLK_AHB_MMC3] = &ahb_mmc3_clk.common.hw,
  1148. [CLK_AHB_MS] = &ahb_ms_clk.common.hw,
  1149. [CLK_AHB_NAND] = &ahb_nand_clk.common.hw,
  1150. [CLK_AHB_SDRAM] = &ahb_sdram_clk.common.hw,
  1151. [CLK_AHB_ACE] = &ahb_ace_clk.common.hw,
  1152. [CLK_AHB_EMAC] = &ahb_emac_clk.common.hw,
  1153. [CLK_AHB_TS] = &ahb_ts_clk.common.hw,
  1154. [CLK_AHB_SPI0] = &ahb_spi0_clk.common.hw,
  1155. [CLK_AHB_SPI1] = &ahb_spi1_clk.common.hw,
  1156. [CLK_AHB_SPI2] = &ahb_spi2_clk.common.hw,
  1157. [CLK_AHB_SPI3] = &ahb_spi3_clk.common.hw,
  1158. [CLK_AHB_PATA] = &ahb_pata_clk.common.hw,
  1159. [CLK_AHB_SATA] = &ahb_sata_clk.common.hw,
  1160. [CLK_AHB_HSTIMER] = &ahb_hstimer_clk.common.hw,
  1161. [CLK_AHB_VE] = &ahb_ve_clk.common.hw,
  1162. [CLK_AHB_TVD] = &ahb_tvd_clk.common.hw,
  1163. [CLK_AHB_TVE0] = &ahb_tve0_clk.common.hw,
  1164. [CLK_AHB_TVE1] = &ahb_tve1_clk.common.hw,
  1165. [CLK_AHB_LCD0] = &ahb_lcd0_clk.common.hw,
  1166. [CLK_AHB_LCD1] = &ahb_lcd1_clk.common.hw,
  1167. [CLK_AHB_CSI0] = &ahb_csi0_clk.common.hw,
  1168. [CLK_AHB_CSI1] = &ahb_csi1_clk.common.hw,
  1169. [CLK_AHB_HDMI1] = &ahb_hdmi1_clk.common.hw,
  1170. [CLK_AHB_HDMI0] = &ahb_hdmi0_clk.common.hw,
  1171. [CLK_AHB_DE_BE0] = &ahb_de_be0_clk.common.hw,
  1172. [CLK_AHB_DE_BE1] = &ahb_de_be1_clk.common.hw,
  1173. [CLK_AHB_DE_FE0] = &ahb_de_fe0_clk.common.hw,
  1174. [CLK_AHB_DE_FE1] = &ahb_de_fe1_clk.common.hw,
  1175. [CLK_AHB_GMAC] = &ahb_gmac_clk.common.hw,
  1176. [CLK_AHB_MP] = &ahb_mp_clk.common.hw,
  1177. [CLK_AHB_GPU] = &ahb_gpu_clk.common.hw,
  1178. [CLK_APB0_CODEC] = &apb0_codec_clk.common.hw,
  1179. [CLK_APB0_SPDIF] = &apb0_spdif_clk.common.hw,
  1180. [CLK_APB0_AC97] = &apb0_ac97_clk.common.hw,
  1181. [CLK_APB0_I2S0] = &apb0_i2s0_clk.common.hw,
  1182. [CLK_APB0_I2S1] = &apb0_i2s1_clk.common.hw,
  1183. [CLK_APB0_PIO] = &apb0_pio_clk.common.hw,
  1184. [CLK_APB0_IR0] = &apb0_ir0_clk.common.hw,
  1185. [CLK_APB0_IR1] = &apb0_ir1_clk.common.hw,
  1186. [CLK_APB0_I2S2] = &apb0_i2s2_clk.common.hw,
  1187. [CLK_APB0_KEYPAD] = &apb0_keypad_clk.common.hw,
  1188. [CLK_APB1_I2C0] = &apb1_i2c0_clk.common.hw,
  1189. [CLK_APB1_I2C1] = &apb1_i2c1_clk.common.hw,
  1190. [CLK_APB1_I2C2] = &apb1_i2c2_clk.common.hw,
  1191. [CLK_APB1_I2C3] = &apb1_i2c3_clk.common.hw,
  1192. [CLK_APB1_CAN] = &apb1_can_clk.common.hw,
  1193. [CLK_APB1_SCR] = &apb1_scr_clk.common.hw,
  1194. [CLK_APB1_PS20] = &apb1_ps20_clk.common.hw,
  1195. [CLK_APB1_PS21] = &apb1_ps21_clk.common.hw,
  1196. [CLK_APB1_I2C4] = &apb1_i2c4_clk.common.hw,
  1197. [CLK_APB1_UART0] = &apb1_uart0_clk.common.hw,
  1198. [CLK_APB1_UART1] = &apb1_uart1_clk.common.hw,
  1199. [CLK_APB1_UART2] = &apb1_uart2_clk.common.hw,
  1200. [CLK_APB1_UART3] = &apb1_uart3_clk.common.hw,
  1201. [CLK_APB1_UART4] = &apb1_uart4_clk.common.hw,
  1202. [CLK_APB1_UART5] = &apb1_uart5_clk.common.hw,
  1203. [CLK_APB1_UART6] = &apb1_uart6_clk.common.hw,
  1204. [CLK_APB1_UART7] = &apb1_uart7_clk.common.hw,
  1205. [CLK_NAND] = &nand_clk.common.hw,
  1206. [CLK_MS] = &ms_clk.common.hw,
  1207. [CLK_MMC0] = &mmc0_clk.common.hw,
  1208. [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw,
  1209. [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw,
  1210. [CLK_MMC1] = &mmc1_clk.common.hw,
  1211. [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw,
  1212. [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw,
  1213. [CLK_MMC2] = &mmc2_clk.common.hw,
  1214. [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw,
  1215. [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw,
  1216. [CLK_MMC3] = &mmc3_clk.common.hw,
  1217. [CLK_MMC3_OUTPUT] = &mmc3_output_clk.common.hw,
  1218. [CLK_MMC3_SAMPLE] = &mmc3_sample_clk.common.hw,
  1219. [CLK_TS] = &ts_clk.common.hw,
  1220. [CLK_SS] = &ss_clk.common.hw,
  1221. [CLK_SPI0] = &spi0_clk.common.hw,
  1222. [CLK_SPI1] = &spi1_clk.common.hw,
  1223. [CLK_SPI2] = &spi2_clk.common.hw,
  1224. [CLK_PATA] = &pata_clk.common.hw,
  1225. [CLK_IR0] = &ir0_sun7i_clk.common.hw,
  1226. [CLK_IR1] = &ir1_sun7i_clk.common.hw,
  1227. [CLK_I2S0] = &i2s0_clk.common.hw,
  1228. [CLK_AC97] = &ac97_clk.common.hw,
  1229. [CLK_SPDIF] = &spdif_clk.common.hw,
  1230. [CLK_KEYPAD] = &keypad_clk.common.hw,
  1231. [CLK_SATA] = &sata_clk.common.hw,
  1232. [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw,
  1233. [CLK_USB_OHCI1] = &usb_ohci1_clk.common.hw,
  1234. [CLK_USB_PHY] = &usb_phy_clk.common.hw,
  1235. /* CLK_GPS is unimplemented */
  1236. [CLK_SPI3] = &spi3_clk.common.hw,
  1237. [CLK_I2S1] = &i2s1_clk.common.hw,
  1238. [CLK_I2S2] = &i2s2_clk.common.hw,
  1239. [CLK_DRAM_VE] = &dram_ve_clk.common.hw,
  1240. [CLK_DRAM_CSI0] = &dram_csi0_clk.common.hw,
  1241. [CLK_DRAM_CSI1] = &dram_csi1_clk.common.hw,
  1242. [CLK_DRAM_TS] = &dram_ts_clk.common.hw,
  1243. [CLK_DRAM_TVD] = &dram_tvd_clk.common.hw,
  1244. [CLK_DRAM_TVE0] = &dram_tve0_clk.common.hw,
  1245. [CLK_DRAM_TVE1] = &dram_tve1_clk.common.hw,
  1246. [CLK_DRAM_OUT] = &dram_out_clk.common.hw,
  1247. [CLK_DRAM_DE_FE1] = &dram_de_fe1_clk.common.hw,
  1248. [CLK_DRAM_DE_FE0] = &dram_de_fe0_clk.common.hw,
  1249. [CLK_DRAM_DE_BE0] = &dram_de_be0_clk.common.hw,
  1250. [CLK_DRAM_DE_BE1] = &dram_de_be1_clk.common.hw,
  1251. [CLK_DRAM_MP] = &dram_mp_clk.common.hw,
  1252. [CLK_DRAM_ACE] = &dram_ace_clk.common.hw,
  1253. [CLK_DE_BE0] = &de_be0_clk.common.hw,
  1254. [CLK_DE_BE1] = &de_be1_clk.common.hw,
  1255. [CLK_DE_FE0] = &de_fe0_clk.common.hw,
  1256. [CLK_DE_FE1] = &de_fe1_clk.common.hw,
  1257. [CLK_DE_MP] = &de_mp_clk.common.hw,
  1258. [CLK_TCON0_CH0] = &tcon0_ch0_clk.common.hw,
  1259. [CLK_TCON1_CH0] = &tcon1_ch0_clk.common.hw,
  1260. [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw,
  1261. [CLK_TVD_SCLK2] = &tvd_sclk2_sun7i_clk.common.hw,
  1262. [CLK_TVD] = &tvd_sclk1_sun7i_clk.common.hw,
  1263. [CLK_TCON0_CH1_SCLK2] = &tcon0_ch1_sclk2_clk.common.hw,
  1264. [CLK_TCON0_CH1] = &tcon0_ch1_clk.common.hw,
  1265. [CLK_TCON1_CH1_SCLK2] = &tcon1_ch1_sclk2_clk.common.hw,
  1266. [CLK_TCON1_CH1] = &tcon1_ch1_clk.common.hw,
  1267. [CLK_CSI0] = &csi0_clk.common.hw,
  1268. [CLK_CSI1] = &csi1_clk.common.hw,
  1269. [CLK_VE] = &ve_clk.common.hw,
  1270. [CLK_CODEC] = &codec_clk.common.hw,
  1271. [CLK_AVS] = &avs_clk.common.hw,
  1272. [CLK_ACE] = &ace_clk.common.hw,
  1273. [CLK_HDMI] = &hdmi_clk.common.hw,
  1274. [CLK_GPU] = &gpu_sun7i_clk.common.hw,
  1275. [CLK_MBUS] = &mbus_sun7i_clk.common.hw,
  1276. [CLK_HDMI1_SLOW] = &hdmi1_slow_clk.common.hw,
  1277. [CLK_HDMI1] = &hdmi1_clk.common.hw,
  1278. [CLK_OUT_A] = &out_a_clk.common.hw,
  1279. [CLK_OUT_B] = &out_b_clk.common.hw,
  1280. },
  1281. .num = CLK_NUMBER_SUN7I,
  1282. };
  1283. static struct ccu_reset_map sunxi_a10_a20_ccu_resets[] = {
  1284. [RST_USB_PHY0] = { 0x0cc, BIT(0) },
  1285. [RST_USB_PHY1] = { 0x0cc, BIT(1) },
  1286. [RST_USB_PHY2] = { 0x0cc, BIT(2) },
  1287. [RST_GPS] = { 0x0d0, BIT(0) },
  1288. [RST_DE_BE0] = { 0x104, BIT(30) },
  1289. [RST_DE_BE1] = { 0x108, BIT(30) },
  1290. [RST_DE_FE0] = { 0x10c, BIT(30) },
  1291. [RST_DE_FE1] = { 0x110, BIT(30) },
  1292. [RST_DE_MP] = { 0x114, BIT(30) },
  1293. [RST_TVE0] = { 0x118, BIT(29) },
  1294. [RST_TCON0] = { 0x118, BIT(30) },
  1295. [RST_TVE1] = { 0x11c, BIT(29) },
  1296. [RST_TCON1] = { 0x11c, BIT(30) },
  1297. [RST_CSI0] = { 0x134, BIT(30) },
  1298. [RST_CSI1] = { 0x138, BIT(30) },
  1299. [RST_VE] = { 0x13c, BIT(0) },
  1300. [RST_ACE] = { 0x148, BIT(16) },
  1301. [RST_LVDS] = { 0x14c, BIT(0) },
  1302. [RST_GPU] = { 0x154, BIT(30) },
  1303. [RST_HDMI_H] = { 0x170, BIT(0) },
  1304. [RST_HDMI_SYS] = { 0x170, BIT(1) },
  1305. [RST_HDMI_AUDIO_DMA] = { 0x170, BIT(2) },
  1306. };
  1307. static const struct sunxi_ccu_desc sun4i_a10_ccu_desc = {
  1308. .ccu_clks = sun4i_sun7i_ccu_clks,
  1309. .num_ccu_clks = ARRAY_SIZE(sun4i_sun7i_ccu_clks),
  1310. .hw_clks = &sun4i_a10_hw_clks,
  1311. .resets = sunxi_a10_a20_ccu_resets,
  1312. .num_resets = ARRAY_SIZE(sunxi_a10_a20_ccu_resets),
  1313. };
  1314. static const struct sunxi_ccu_desc sun7i_a20_ccu_desc = {
  1315. .ccu_clks = sun4i_sun7i_ccu_clks,
  1316. .num_ccu_clks = ARRAY_SIZE(sun4i_sun7i_ccu_clks),
  1317. .hw_clks = &sun7i_a20_hw_clks,
  1318. .resets = sunxi_a10_a20_ccu_resets,
  1319. .num_resets = ARRAY_SIZE(sunxi_a10_a20_ccu_resets),
  1320. };
  1321. static int sun4i_a10_ccu_probe(struct platform_device *pdev)
  1322. {
  1323. const struct sunxi_ccu_desc *desc;
  1324. void __iomem *reg;
  1325. u32 val;
  1326. desc = of_device_get_match_data(&pdev->dev);
  1327. if (!desc)
  1328. return -EINVAL;
  1329. reg = devm_platform_ioremap_resource(pdev, 0);
  1330. if (IS_ERR(reg))
  1331. return PTR_ERR(reg);
  1332. val = readl(reg + SUN4I_PLL_AUDIO_REG);
  1333. /*
  1334. * Force VCO and PLL bias current to lowest setting. Higher
  1335. * settings interfere with sigma-delta modulation and result
  1336. * in audible noise and distortions when using SPDIF or I2S.
  1337. */
  1338. val &= ~GENMASK(25, 16);
  1339. /* Force the PLL-Audio-1x divider to 1 */
  1340. val &= ~GENMASK(29, 26);
  1341. writel(val | (1 << 26), reg + SUN4I_PLL_AUDIO_REG);
  1342. /*
  1343. * Use the peripheral PLL6 as the AHB parent, instead of CPU /
  1344. * AXI which have rate changes due to cpufreq.
  1345. *
  1346. * This is especially a big deal for the HS timer whose parent
  1347. * clock is AHB.
  1348. *
  1349. * NB! These bits are undocumented in A10 manual.
  1350. */
  1351. val = readl(reg + SUN4I_AHB_REG);
  1352. val &= ~GENMASK(7, 6);
  1353. writel(val | (2 << 6), reg + SUN4I_AHB_REG);
  1354. return devm_sunxi_ccu_probe(&pdev->dev, reg, desc);
  1355. }
  1356. static const struct of_device_id sun4i_a10_ccu_ids[] = {
  1357. {
  1358. .compatible = "allwinner,sun4i-a10-ccu",
  1359. .data = &sun4i_a10_ccu_desc,
  1360. },
  1361. {
  1362. .compatible = "allwinner,sun7i-a20-ccu",
  1363. .data = &sun7i_a20_ccu_desc,
  1364. },
  1365. { }
  1366. };
  1367. static struct platform_driver sun4i_a10_ccu_driver = {
  1368. .probe = sun4i_a10_ccu_probe,
  1369. .driver = {
  1370. .name = "sun4i-a10-ccu",
  1371. .suppress_bind_attrs = true,
  1372. .of_match_table = sun4i_a10_ccu_ids,
  1373. },
  1374. };
  1375. module_platform_driver(sun4i_a10_ccu_driver);
  1376. MODULE_IMPORT_NS(SUNXI_CCU);
  1377. MODULE_LICENSE("GPL");