ccu-sun4i-a10.c 48 KB

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