ccu-sun9i-a80.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. /*
  2. * Copyright (c) 2016 Chen-Yu Tsai. All rights reserved.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/clk-provider.h>
  14. #include <linux/of_address.h>
  15. #include <linux/platform_device.h>
  16. #include "ccu_common.h"
  17. #include "ccu_reset.h"
  18. #include "ccu_div.h"
  19. #include "ccu_gate.h"
  20. #include "ccu_mp.h"
  21. #include "ccu_nkmp.h"
  22. #include "ccu_nm.h"
  23. #include "ccu_phase.h"
  24. #include "ccu-sun9i-a80.h"
  25. #define CCU_SUN9I_LOCK_REG 0x09c
  26. static struct clk_div_table pll_cpux_p_div_table[] = {
  27. { .val = 0, .div = 1 },
  28. { .val = 1, .div = 4 },
  29. { /* Sentinel */ },
  30. };
  31. /*
  32. * The CPU PLLs are actually NP clocks, but P is /1 or /4, so here we
  33. * use the NM clocks with a divider table for M.
  34. */
  35. static struct ccu_nm pll_c0cpux_clk = {
  36. .enable = BIT(31),
  37. .lock = BIT(0),
  38. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  39. .m = _SUNXI_CCU_DIV_TABLE(16, 1, pll_cpux_p_div_table),
  40. .common = {
  41. .reg = 0x000,
  42. .lock_reg = CCU_SUN9I_LOCK_REG,
  43. .features = CCU_FEATURE_LOCK_REG,
  44. .hw.init = CLK_HW_INIT("pll-c0cpux", "osc24M",
  45. &ccu_nm_ops, CLK_SET_RATE_UNGATE),
  46. },
  47. };
  48. static struct ccu_nm pll_c1cpux_clk = {
  49. .enable = BIT(31),
  50. .lock = BIT(1),
  51. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  52. .m = _SUNXI_CCU_DIV_TABLE(16, 1, pll_cpux_p_div_table),
  53. .common = {
  54. .reg = 0x004,
  55. .lock_reg = CCU_SUN9I_LOCK_REG,
  56. .features = CCU_FEATURE_LOCK_REG,
  57. .hw.init = CLK_HW_INIT("pll-c1cpux", "osc24M",
  58. &ccu_nm_ops, CLK_SET_RATE_UNGATE),
  59. },
  60. };
  61. /*
  62. * The Audio PLL has d1, d2 dividers in addition to the usual N, M
  63. * factors. Since we only need 2 frequencies from this PLL: 22.5792 MHz
  64. * and 24.576 MHz, ignore them for now. Enforce the default for them,
  65. * which is d1 = 0, d2 = 1.
  66. */
  67. #define SUN9I_A80_PLL_AUDIO_REG 0x008
  68. static struct ccu_nm pll_audio_clk = {
  69. .enable = BIT(31),
  70. .lock = BIT(2),
  71. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  72. .m = _SUNXI_CCU_DIV_OFFSET(0, 6, 0),
  73. .common = {
  74. .reg = 0x008,
  75. .lock_reg = CCU_SUN9I_LOCK_REG,
  76. .features = CCU_FEATURE_LOCK_REG,
  77. .hw.init = CLK_HW_INIT("pll-audio", "osc24M",
  78. &ccu_nm_ops, CLK_SET_RATE_UNGATE),
  79. },
  80. };
  81. /* Some PLLs are input * N / div1 / div2. Model them as NKMP with no K */
  82. static struct ccu_nkmp pll_periph0_clk = {
  83. .enable = BIT(31),
  84. .lock = BIT(3),
  85. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  86. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  87. .p = _SUNXI_CCU_DIV(18, 1), /* output divider */
  88. .common = {
  89. .reg = 0x00c,
  90. .lock_reg = CCU_SUN9I_LOCK_REG,
  91. .features = CCU_FEATURE_LOCK_REG,
  92. .hw.init = CLK_HW_INIT("pll-periph0", "osc24M",
  93. &ccu_nkmp_ops,
  94. CLK_SET_RATE_UNGATE),
  95. },
  96. };
  97. static struct ccu_nkmp pll_ve_clk = {
  98. .enable = BIT(31),
  99. .lock = BIT(4),
  100. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  101. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  102. .p = _SUNXI_CCU_DIV(18, 1), /* output divider */
  103. .common = {
  104. .reg = 0x010,
  105. .lock_reg = CCU_SUN9I_LOCK_REG,
  106. .features = CCU_FEATURE_LOCK_REG,
  107. .hw.init = CLK_HW_INIT("pll-ve", "osc24M",
  108. &ccu_nkmp_ops,
  109. CLK_SET_RATE_UNGATE),
  110. },
  111. };
  112. static struct ccu_nkmp pll_ddr_clk = {
  113. .enable = BIT(31),
  114. .lock = BIT(5),
  115. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  116. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  117. .p = _SUNXI_CCU_DIV(18, 1), /* output divider */
  118. .common = {
  119. .reg = 0x014,
  120. .lock_reg = CCU_SUN9I_LOCK_REG,
  121. .features = CCU_FEATURE_LOCK_REG,
  122. .hw.init = CLK_HW_INIT("pll-ddr", "osc24M",
  123. &ccu_nkmp_ops,
  124. CLK_SET_RATE_UNGATE),
  125. },
  126. };
  127. static struct ccu_nm pll_video0_clk = {
  128. .enable = BIT(31),
  129. .lock = BIT(6),
  130. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  131. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  132. .common = {
  133. .reg = 0x018,
  134. .lock_reg = CCU_SUN9I_LOCK_REG,
  135. .features = CCU_FEATURE_LOCK_REG,
  136. .hw.init = CLK_HW_INIT("pll-video0", "osc24M",
  137. &ccu_nm_ops,
  138. CLK_SET_RATE_UNGATE),
  139. },
  140. };
  141. static struct ccu_nkmp pll_video1_clk = {
  142. .enable = BIT(31),
  143. .lock = BIT(7),
  144. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  145. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  146. .p = _SUNXI_CCU_DIV(0, 2), /* external divider p */
  147. .common = {
  148. .reg = 0x01c,
  149. .lock_reg = CCU_SUN9I_LOCK_REG,
  150. .features = CCU_FEATURE_LOCK_REG,
  151. .hw.init = CLK_HW_INIT("pll-video1", "osc24M",
  152. &ccu_nkmp_ops,
  153. CLK_SET_RATE_UNGATE),
  154. },
  155. };
  156. static struct ccu_nkmp pll_gpu_clk = {
  157. .enable = BIT(31),
  158. .lock = BIT(8),
  159. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  160. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  161. .p = _SUNXI_CCU_DIV(18, 1), /* output divider */
  162. .common = {
  163. .reg = 0x020,
  164. .lock_reg = CCU_SUN9I_LOCK_REG,
  165. .features = CCU_FEATURE_LOCK_REG,
  166. .hw.init = CLK_HW_INIT("pll-gpu", "osc24M",
  167. &ccu_nkmp_ops,
  168. CLK_SET_RATE_UNGATE),
  169. },
  170. };
  171. static struct ccu_nkmp pll_de_clk = {
  172. .enable = BIT(31),
  173. .lock = BIT(9),
  174. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  175. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  176. .p = _SUNXI_CCU_DIV(18, 1), /* output divider */
  177. .common = {
  178. .reg = 0x024,
  179. .lock_reg = CCU_SUN9I_LOCK_REG,
  180. .features = CCU_FEATURE_LOCK_REG,
  181. .hw.init = CLK_HW_INIT("pll-de", "osc24M",
  182. &ccu_nkmp_ops,
  183. CLK_SET_RATE_UNGATE),
  184. },
  185. };
  186. static struct ccu_nkmp pll_isp_clk = {
  187. .enable = BIT(31),
  188. .lock = BIT(10),
  189. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  190. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  191. .p = _SUNXI_CCU_DIV(18, 1), /* output divider */
  192. .common = {
  193. .reg = 0x028,
  194. .lock_reg = CCU_SUN9I_LOCK_REG,
  195. .features = CCU_FEATURE_LOCK_REG,
  196. .hw.init = CLK_HW_INIT("pll-isp", "osc24M",
  197. &ccu_nkmp_ops,
  198. CLK_SET_RATE_UNGATE),
  199. },
  200. };
  201. static struct ccu_nkmp pll_periph1_clk = {
  202. .enable = BIT(31),
  203. .lock = BIT(11),
  204. .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0),
  205. .m = _SUNXI_CCU_DIV(16, 1), /* input divider */
  206. .p = _SUNXI_CCU_DIV(18, 1), /* output divider */
  207. .common = {
  208. .reg = 0x028,
  209. .lock_reg = CCU_SUN9I_LOCK_REG,
  210. .features = CCU_FEATURE_LOCK_REG,
  211. .hw.init = CLK_HW_INIT("pll-periph1", "osc24M",
  212. &ccu_nkmp_ops,
  213. CLK_SET_RATE_UNGATE),
  214. },
  215. };
  216. static const char * const c0cpux_parents[] = { "osc24M", "pll-c0cpux" };
  217. static SUNXI_CCU_MUX(c0cpux_clk, "c0cpux", c0cpux_parents,
  218. 0x50, 0, 1, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL);
  219. static const char * const c1cpux_parents[] = { "osc24M", "pll-c1cpux" };
  220. static SUNXI_CCU_MUX(c1cpux_clk, "c1cpux", c1cpux_parents,
  221. 0x50, 8, 1, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL);
  222. static struct clk_div_table axi_div_table[] = {
  223. { .val = 0, .div = 1 },
  224. { .val = 1, .div = 2 },
  225. { .val = 2, .div = 3 },
  226. { .val = 3, .div = 4 },
  227. { .val = 4, .div = 4 },
  228. { .val = 5, .div = 4 },
  229. { .val = 6, .div = 4 },
  230. { .val = 7, .div = 4 },
  231. { /* Sentinel */ },
  232. };
  233. static SUNXI_CCU_M(atb0_clk, "atb0", "c0cpux", 0x054, 8, 2, 0);
  234. static SUNXI_CCU_DIV_TABLE(axi0_clk, "axi0", "c0cpux",
  235. 0x054, 0, 3, axi_div_table, 0);
  236. static SUNXI_CCU_M(atb1_clk, "atb1", "c1cpux", 0x058, 8, 2, 0);
  237. static SUNXI_CCU_DIV_TABLE(axi1_clk, "axi1", "c1cpux",
  238. 0x058, 0, 3, axi_div_table, 0);
  239. static const char * const gtbus_parents[] = { "osc24M", "pll-periph0",
  240. "pll-periph1", "pll-periph1" };
  241. static SUNXI_CCU_M_WITH_MUX(gtbus_clk, "gtbus", gtbus_parents,
  242. 0x05c, 0, 2, 24, 2, CLK_IS_CRITICAL);
  243. static const char * const ahb_parents[] = { "gtbus", "pll-periph0",
  244. "pll-periph1", "pll-periph1" };
  245. static struct ccu_div ahb0_clk = {
  246. .div = _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
  247. .mux = _SUNXI_CCU_MUX(24, 2),
  248. .common = {
  249. .reg = 0x060,
  250. .hw.init = CLK_HW_INIT_PARENTS("ahb0",
  251. ahb_parents,
  252. &ccu_div_ops,
  253. 0),
  254. },
  255. };
  256. static struct ccu_div ahb1_clk = {
  257. .div = _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
  258. .mux = _SUNXI_CCU_MUX(24, 2),
  259. .common = {
  260. .reg = 0x064,
  261. .hw.init = CLK_HW_INIT_PARENTS("ahb1",
  262. ahb_parents,
  263. &ccu_div_ops,
  264. 0),
  265. },
  266. };
  267. static struct ccu_div ahb2_clk = {
  268. .div = _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
  269. .mux = _SUNXI_CCU_MUX(24, 2),
  270. .common = {
  271. .reg = 0x068,
  272. .hw.init = CLK_HW_INIT_PARENTS("ahb2",
  273. ahb_parents,
  274. &ccu_div_ops,
  275. 0),
  276. },
  277. };
  278. static const char * const apb_parents[] = { "osc24M", "pll-periph0" };
  279. static struct ccu_div apb0_clk = {
  280. .div = _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
  281. .mux = _SUNXI_CCU_MUX(24, 1),
  282. .common = {
  283. .reg = 0x070,
  284. .hw.init = CLK_HW_INIT_PARENTS("apb0",
  285. apb_parents,
  286. &ccu_div_ops,
  287. 0),
  288. },
  289. };
  290. static struct ccu_div apb1_clk = {
  291. .div = _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
  292. .mux = _SUNXI_CCU_MUX(24, 1),
  293. .common = {
  294. .reg = 0x074,
  295. .hw.init = CLK_HW_INIT_PARENTS("apb1",
  296. apb_parents,
  297. &ccu_div_ops,
  298. 0),
  299. },
  300. };
  301. static struct ccu_div cci400_clk = {
  302. .div = _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
  303. .mux = _SUNXI_CCU_MUX(24, 2),
  304. .common = {
  305. .reg = 0x078,
  306. .hw.init = CLK_HW_INIT_PARENTS("cci400",
  307. ahb_parents,
  308. &ccu_div_ops,
  309. CLK_IS_CRITICAL),
  310. },
  311. };
  312. static SUNXI_CCU_M_WITH_MUX_GATE(ats_clk, "ats", apb_parents,
  313. 0x080, 0, 3, 24, 2, BIT(31), 0);
  314. static SUNXI_CCU_M_WITH_MUX_GATE(trace_clk, "trace", apb_parents,
  315. 0x084, 0, 3, 24, 2, BIT(31), 0);
  316. static const char * const out_parents[] = { "osc24M", "osc32k", "osc24M" };
  317. static const struct ccu_mux_fixed_prediv out_prediv = {
  318. .index = 0, .div = 750
  319. };
  320. static struct ccu_mp out_a_clk = {
  321. .enable = BIT(31),
  322. .m = _SUNXI_CCU_DIV(8, 5),
  323. .p = _SUNXI_CCU_DIV(20, 2),
  324. .mux = {
  325. .shift = 24,
  326. .width = 4,
  327. .fixed_predivs = &out_prediv,
  328. .n_predivs = 1,
  329. },
  330. .common = {
  331. .reg = 0x180,
  332. .features = CCU_FEATURE_FIXED_PREDIV,
  333. .hw.init = CLK_HW_INIT_PARENTS("out-a",
  334. out_parents,
  335. &ccu_mp_ops,
  336. 0),
  337. },
  338. };
  339. static struct ccu_mp out_b_clk = {
  340. .enable = BIT(31),
  341. .m = _SUNXI_CCU_DIV(8, 5),
  342. .p = _SUNXI_CCU_DIV(20, 2),
  343. .mux = {
  344. .shift = 24,
  345. .width = 4,
  346. .fixed_predivs = &out_prediv,
  347. .n_predivs = 1,
  348. },
  349. .common = {
  350. .reg = 0x184,
  351. .features = CCU_FEATURE_FIXED_PREDIV,
  352. .hw.init = CLK_HW_INIT_PARENTS("out-b",
  353. out_parents,
  354. &ccu_mp_ops,
  355. 0),
  356. },
  357. };
  358. static const char * const mod0_default_parents[] = { "osc24M", "pll-periph0" };
  359. static SUNXI_CCU_MP_WITH_MUX_GATE(nand0_0_clk, "nand0-0", mod0_default_parents,
  360. 0x400,
  361. 0, 4, /* M */
  362. 16, 2, /* P */
  363. 24, 4, /* mux */
  364. BIT(31), /* gate */
  365. 0);
  366. static SUNXI_CCU_MP_WITH_MUX_GATE(nand0_1_clk, "nand0-1", mod0_default_parents,
  367. 0x404,
  368. 0, 4, /* M */
  369. 16, 2, /* P */
  370. 24, 4, /* mux */
  371. BIT(31), /* gate */
  372. 0);
  373. static SUNXI_CCU_MP_WITH_MUX_GATE(nand1_0_clk, "nand1-0", mod0_default_parents,
  374. 0x408,
  375. 0, 4, /* M */
  376. 16, 2, /* P */
  377. 24, 4, /* mux */
  378. BIT(31), /* gate */
  379. 0);
  380. static SUNXI_CCU_MP_WITH_MUX_GATE(nand1_1_clk, "nand1-1", mod0_default_parents,
  381. 0x40c,
  382. 0, 4, /* M */
  383. 16, 2, /* P */
  384. 24, 4, /* mux */
  385. BIT(31), /* gate */
  386. 0);
  387. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents,
  388. 0x410,
  389. 0, 4, /* M */
  390. 16, 2, /* P */
  391. 24, 4, /* mux */
  392. BIT(31), /* gate */
  393. 0);
  394. static SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0-sample", "mmc0",
  395. 0x410, 20, 3, 0);
  396. static SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0-output", "mmc0",
  397. 0x410, 8, 3, 0);
  398. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents,
  399. 0x414,
  400. 0, 4, /* M */
  401. 16, 2, /* P */
  402. 24, 4, /* mux */
  403. BIT(31), /* gate */
  404. 0);
  405. static SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1-sample", "mmc1",
  406. 0x414, 20, 3, 0);
  407. static SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1-output", "mmc1",
  408. 0x414, 8, 3, 0);
  409. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents,
  410. 0x418,
  411. 0, 4, /* M */
  412. 16, 2, /* P */
  413. 24, 4, /* mux */
  414. BIT(31), /* gate */
  415. 0);
  416. static SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2-sample", "mmc2",
  417. 0x418, 20, 3, 0);
  418. static SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2-output", "mmc2",
  419. 0x418, 8, 3, 0);
  420. static SUNXI_CCU_MP_WITH_MUX_GATE(mmc3_clk, "mmc3", mod0_default_parents,
  421. 0x41c,
  422. 0, 4, /* M */
  423. 16, 2, /* P */
  424. 24, 4, /* mux */
  425. BIT(31), /* gate */
  426. 0);
  427. static SUNXI_CCU_PHASE(mmc3_sample_clk, "mmc3-sample", "mmc3",
  428. 0x41c, 20, 3, 0);
  429. static SUNXI_CCU_PHASE(mmc3_output_clk, "mmc3-output", "mmc3",
  430. 0x41c, 8, 3, 0);
  431. static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", mod0_default_parents,
  432. 0x428,
  433. 0, 4, /* M */
  434. 16, 2, /* P */
  435. 24, 4, /* mux */
  436. BIT(31), /* gate */
  437. 0);
  438. static const char * const ss_parents[] = { "osc24M", "pll-periph",
  439. "pll-periph1" };
  440. static const u8 ss_table[] = { 0, 1, 13 };
  441. static struct ccu_mp ss_clk = {
  442. .enable = BIT(31),
  443. .m = _SUNXI_CCU_DIV(0, 4),
  444. .p = _SUNXI_CCU_DIV(16, 2),
  445. .mux = _SUNXI_CCU_MUX_TABLE(24, 4, ss_table),
  446. .common = {
  447. .reg = 0x42c,
  448. .hw.init = CLK_HW_INIT_PARENTS("ss",
  449. ss_parents,
  450. &ccu_mp_ops,
  451. 0),
  452. },
  453. };
  454. static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents,
  455. 0x430,
  456. 0, 4, /* M */
  457. 16, 2, /* P */
  458. 24, 4, /* mux */
  459. BIT(31), /* gate */
  460. 0);
  461. static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents,
  462. 0x434,
  463. 0, 4, /* M */
  464. 16, 2, /* P */
  465. 24, 4, /* mux */
  466. BIT(31), /* gate */
  467. 0);
  468. static SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", mod0_default_parents,
  469. 0x438,
  470. 0, 4, /* M */
  471. 16, 2, /* P */
  472. 24, 4, /* mux */
  473. BIT(31), /* gate */
  474. 0);
  475. static SUNXI_CCU_MP_WITH_MUX_GATE(spi3_clk, "spi3", mod0_default_parents,
  476. 0x43c,
  477. 0, 4, /* M */
  478. 16, 2, /* P */
  479. 24, 4, /* mux */
  480. BIT(31), /* gate */
  481. 0);
  482. static SUNXI_CCU_M_WITH_GATE(i2s0_clk, "i2s0", "pll-audio",
  483. 0x440, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  484. static SUNXI_CCU_M_WITH_GATE(i2s1_clk, "i2s1", "pll-audio",
  485. 0x444, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  486. static SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio",
  487. 0x44c, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  488. static const char * const sdram_parents[] = { "pll-periph0", "pll-ddr" };
  489. static const u8 sdram_table[] = { 0, 3 };
  490. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(sdram_clk, "sdram",
  491. sdram_parents, sdram_table,
  492. 0x484,
  493. 8, 4, /* M */
  494. 12, 4, /* mux */
  495. 0, /* no gate */
  496. CLK_IS_CRITICAL);
  497. static SUNXI_CCU_M_WITH_GATE(de_clk, "de", "pll-de", 0x490,
  498. 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  499. static SUNXI_CCU_GATE(edp_clk, "edp", "osc24M", 0x494, BIT(31), 0);
  500. static const char * const mp_parents[] = { "pll-video1", "pll-gpu", "pll-de" };
  501. static const u8 mp_table[] = { 9, 10, 11 };
  502. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(mp_clk, "mp", mp_parents, mp_table,
  503. 0x498,
  504. 0, 4, /* M */
  505. 24, 4, /* mux */
  506. BIT(31), /* gate */
  507. 0);
  508. static const char * const display_parents[] = { "pll-video0", "pll-video1" };
  509. static const u8 display_table[] = { 8, 9 };
  510. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(lcd0_clk, "lcd0",
  511. display_parents, display_table,
  512. 0x49c,
  513. 0, 4, /* M */
  514. 24, 4, /* mux */
  515. BIT(31), /* gate */
  516. CLK_SET_RATE_NO_REPARENT |
  517. CLK_SET_RATE_PARENT);
  518. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(lcd1_clk, "lcd1",
  519. display_parents, display_table,
  520. 0x4a0,
  521. 0, 4, /* M */
  522. 24, 4, /* mux */
  523. BIT(31), /* gate */
  524. CLK_SET_RATE_NO_REPARENT |
  525. CLK_SET_RATE_PARENT);
  526. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(mipi_dsi0_clk, "mipi-dsi0",
  527. display_parents, display_table,
  528. 0x4a8,
  529. 0, 4, /* M */
  530. 24, 4, /* mux */
  531. BIT(31), /* gate */
  532. CLK_SET_RATE_PARENT);
  533. static const char * const mipi_dsi1_parents[] = { "osc24M", "pll-video1" };
  534. static const u8 mipi_dsi1_table[] = { 0, 9 };
  535. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(mipi_dsi1_clk, "mipi-dsi1",
  536. mipi_dsi1_parents, mipi_dsi1_table,
  537. 0x4ac,
  538. 0, 4, /* M */
  539. 24, 4, /* mux */
  540. BIT(31), /* gate */
  541. CLK_SET_RATE_PARENT);
  542. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(hdmi_clk, "hdmi",
  543. display_parents, display_table,
  544. 0x4b0,
  545. 0, 4, /* M */
  546. 24, 4, /* mux */
  547. BIT(31), /* gate */
  548. CLK_SET_RATE_NO_REPARENT |
  549. CLK_SET_RATE_PARENT);
  550. static SUNXI_CCU_GATE(hdmi_slow_clk, "hdmi-slow", "osc24M", 0x4b4, BIT(31), 0);
  551. static SUNXI_CCU_M_WITH_GATE(mipi_csi_clk, "mipi-csi", "osc24M", 0x4bc,
  552. 0, 4, BIT(31), 0);
  553. static SUNXI_CCU_M_WITH_GATE(csi_isp_clk, "csi-isp", "pll-isp", 0x4c0,
  554. 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  555. static SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M", 0x4c0, BIT(16), 0);
  556. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi0_mclk_clk, "csi0-mclk",
  557. mipi_dsi1_parents, mipi_dsi1_table,
  558. 0x4c4,
  559. 0, 4, /* M */
  560. 24, 4, /* mux */
  561. BIT(31), /* gate */
  562. CLK_SET_RATE_PARENT);
  563. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi1_mclk_clk, "csi1-mclk",
  564. mipi_dsi1_parents, mipi_dsi1_table,
  565. 0x4c8,
  566. 0, 4, /* M */
  567. 24, 4, /* mux */
  568. BIT(31), /* gate */
  569. CLK_SET_RATE_PARENT);
  570. static const char * const fd_parents[] = { "pll-periph0", "pll-isp" };
  571. static const u8 fd_table[] = { 1, 12 };
  572. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(fd_clk, "fd", fd_parents, fd_table,
  573. 0x4cc,
  574. 0, 4, /* M */
  575. 24, 4, /* mux */
  576. BIT(31), /* gate */
  577. 0);
  578. static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 0x4d0,
  579. 16, 3, BIT(31), CLK_SET_RATE_PARENT);
  580. static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 0x4d4, BIT(31), 0);
  581. static SUNXI_CCU_M_WITH_GATE(gpu_core_clk, "gpu-core", "pll-gpu", 0x4f0,
  582. 0, 3, BIT(31), CLK_SET_RATE_PARENT);
  583. static SUNXI_CCU_M_WITH_GATE(gpu_memory_clk, "gpu-memory", "pll-gpu", 0x4f4,
  584. 0, 3, BIT(31), CLK_SET_RATE_PARENT);
  585. static const char * const gpu_axi_parents[] = { "pll-periph0", "pll-gpu" };
  586. static const u8 gpu_axi_table[] = { 1, 10 };
  587. static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(gpu_axi_clk, "gpu-axi",
  588. gpu_axi_parents, gpu_axi_table,
  589. 0x4f8,
  590. 0, 4, /* M */
  591. 24, 4, /* mux */
  592. BIT(31), /* gate */
  593. CLK_SET_RATE_PARENT);
  594. static SUNXI_CCU_M_WITH_GATE(sata_clk, "sata", "pll-periph0", 0x500,
  595. 0, 4, BIT(31), 0);
  596. static SUNXI_CCU_M_WITH_GATE(ac97_clk, "ac97", "pll-audio",
  597. 0x504, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
  598. static SUNXI_CCU_M_WITH_MUX_GATE(mipi_hsi_clk, "mipi-hsi",
  599. mod0_default_parents, 0x508,
  600. 0, 4, /* M */
  601. 24, 4, /* mux */
  602. BIT(31), /* gate */
  603. 0);
  604. static const char * const gpadc_parents[] = { "osc24M", "pll-audio", "osc32k" };
  605. static const u8 gpadc_table[] = { 0, 4, 7 };
  606. static struct ccu_mp gpadc_clk = {
  607. .enable = BIT(31),
  608. .m = _SUNXI_CCU_DIV(0, 4),
  609. .p = _SUNXI_CCU_DIV(16, 2),
  610. .mux = _SUNXI_CCU_MUX_TABLE(24, 4, gpadc_table),
  611. .common = {
  612. .reg = 0x50c,
  613. .hw.init = CLK_HW_INIT_PARENTS("gpadc",
  614. gpadc_parents,
  615. &ccu_mp_ops,
  616. 0),
  617. },
  618. };
  619. static const char * const cir_tx_parents[] = { "osc24M", "osc32k" };
  620. static const u8 cir_tx_table[] = { 0, 7 };
  621. static struct ccu_mp cir_tx_clk = {
  622. .enable = BIT(31),
  623. .m = _SUNXI_CCU_DIV(0, 4),
  624. .p = _SUNXI_CCU_DIV(16, 2),
  625. .mux = _SUNXI_CCU_MUX_TABLE(24, 4, cir_tx_table),
  626. .common = {
  627. .reg = 0x510,
  628. .hw.init = CLK_HW_INIT_PARENTS("cir-tx",
  629. cir_tx_parents,
  630. &ccu_mp_ops,
  631. 0),
  632. },
  633. };
  634. /* AHB0 bus gates */
  635. static SUNXI_CCU_GATE(bus_fd_clk, "bus-fd", "ahb0",
  636. 0x580, BIT(0), 0);
  637. static SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb0",
  638. 0x580, BIT(1), 0);
  639. static SUNXI_CCU_GATE(bus_gpu_ctrl_clk, "bus-gpu-ctrl", "ahb0",
  640. 0x580, BIT(3), 0);
  641. static SUNXI_CCU_GATE(bus_ss_clk, "bus-ss", "ahb0",
  642. 0x580, BIT(5), 0);
  643. static SUNXI_CCU_GATE(bus_mmc_clk, "bus-mmc", "ahb0",
  644. 0x580, BIT(8), 0);
  645. static SUNXI_CCU_GATE(bus_nand0_clk, "bus-nand0", "ahb0",
  646. 0x580, BIT(12), 0);
  647. static SUNXI_CCU_GATE(bus_nand1_clk, "bus-nand1", "ahb0",
  648. 0x580, BIT(13), 0);
  649. static SUNXI_CCU_GATE(bus_sdram_clk, "bus-sdram", "ahb0",
  650. 0x580, BIT(14), 0);
  651. static SUNXI_CCU_GATE(bus_mipi_hsi_clk, "bus-mipi-hsi", "ahb0",
  652. 0x580, BIT(15), 0);
  653. static SUNXI_CCU_GATE(bus_sata_clk, "bus-sata", "ahb0",
  654. 0x580, BIT(16), 0);
  655. static SUNXI_CCU_GATE(bus_ts_clk, "bus-ts", "ahb0",
  656. 0x580, BIT(18), 0);
  657. static SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb0",
  658. 0x580, BIT(20), 0);
  659. static SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb0",
  660. 0x580, BIT(21), 0);
  661. static SUNXI_CCU_GATE(bus_spi2_clk, "bus-spi2", "ahb0",
  662. 0x580, BIT(22), 0);
  663. static SUNXI_CCU_GATE(bus_spi3_clk, "bus-spi3", "ahb0",
  664. 0x580, BIT(23), 0);
  665. /* AHB1 bus gates */
  666. static SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1",
  667. 0x584, BIT(0), 0);
  668. static SUNXI_CCU_GATE(bus_usb_clk, "bus-usb", "ahb1",
  669. 0x584, BIT(1), 0);
  670. static SUNXI_CCU_GATE(bus_gmac_clk, "bus-gmac", "ahb1",
  671. 0x584, BIT(17), 0);
  672. static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1",
  673. 0x584, BIT(21), 0);
  674. static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1",
  675. 0x584, BIT(22), 0);
  676. static SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1",
  677. 0x584, BIT(23), 0);
  678. static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1",
  679. 0x584, BIT(24), 0);
  680. /* AHB2 bus gates */
  681. static SUNXI_CCU_GATE(bus_lcd0_clk, "bus-lcd0", "ahb2",
  682. 0x588, BIT(0), 0);
  683. static SUNXI_CCU_GATE(bus_lcd1_clk, "bus-lcd1", "ahb2",
  684. 0x588, BIT(1), 0);
  685. static SUNXI_CCU_GATE(bus_edp_clk, "bus-edp", "ahb2",
  686. 0x588, BIT(2), 0);
  687. static SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb2",
  688. 0x588, BIT(4), 0);
  689. static SUNXI_CCU_GATE(bus_hdmi_clk, "bus-hdmi", "ahb2",
  690. 0x588, BIT(5), 0);
  691. static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb2",
  692. 0x588, BIT(7), 0);
  693. static SUNXI_CCU_GATE(bus_mp_clk, "bus-mp", "ahb2",
  694. 0x588, BIT(8), 0);
  695. static SUNXI_CCU_GATE(bus_mipi_dsi_clk, "bus-mipi-dsi", "ahb2",
  696. 0x588, BIT(11), 0);
  697. /* APB0 bus gates */
  698. static SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb0",
  699. 0x590, BIT(1), 0);
  700. static SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb0",
  701. 0x590, BIT(5), 0);
  702. static SUNXI_CCU_GATE(bus_ac97_clk, "bus-ac97", "apb0",
  703. 0x590, BIT(11), 0);
  704. static SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb0",
  705. 0x590, BIT(12), 0);
  706. static SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb0",
  707. 0x590, BIT(13), 0);
  708. static SUNXI_CCU_GATE(bus_lradc_clk, "bus-lradc", "apb0",
  709. 0x590, BIT(15), 0);
  710. static SUNXI_CCU_GATE(bus_gpadc_clk, "bus-gpadc", "apb0",
  711. 0x590, BIT(17), 0);
  712. static SUNXI_CCU_GATE(bus_twd_clk, "bus-twd", "apb0",
  713. 0x590, BIT(18), 0);
  714. static SUNXI_CCU_GATE(bus_cir_tx_clk, "bus-cir-tx", "apb0",
  715. 0x590, BIT(19), 0);
  716. /* APB1 bus gates */
  717. static SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb1",
  718. 0x594, BIT(0), 0);
  719. static SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb1",
  720. 0x594, BIT(1), 0);
  721. static SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb1",
  722. 0x594, BIT(2), 0);
  723. static SUNXI_CCU_GATE(bus_i2c3_clk, "bus-i2c3", "apb1",
  724. 0x594, BIT(3), 0);
  725. static SUNXI_CCU_GATE(bus_i2c4_clk, "bus-i2c4", "apb1",
  726. 0x594, BIT(4), 0);
  727. static SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb1",
  728. 0x594, BIT(16), 0);
  729. static SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb1",
  730. 0x594, BIT(17), 0);
  731. static SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb1",
  732. 0x594, BIT(18), 0);
  733. static SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb1",
  734. 0x594, BIT(19), 0);
  735. static SUNXI_CCU_GATE(bus_uart4_clk, "bus-uart4", "apb1",
  736. 0x594, BIT(20), 0);
  737. static SUNXI_CCU_GATE(bus_uart5_clk, "bus-uart5", "apb1",
  738. 0x594, BIT(21), 0);
  739. static struct ccu_common *sun9i_a80_ccu_clks[] = {
  740. &pll_c0cpux_clk.common,
  741. &pll_c1cpux_clk.common,
  742. &pll_audio_clk.common,
  743. &pll_periph0_clk.common,
  744. &pll_ve_clk.common,
  745. &pll_ddr_clk.common,
  746. &pll_video0_clk.common,
  747. &pll_video1_clk.common,
  748. &pll_gpu_clk.common,
  749. &pll_de_clk.common,
  750. &pll_isp_clk.common,
  751. &pll_periph1_clk.common,
  752. &c0cpux_clk.common,
  753. &c1cpux_clk.common,
  754. &atb0_clk.common,
  755. &axi0_clk.common,
  756. &atb1_clk.common,
  757. &axi1_clk.common,
  758. &gtbus_clk.common,
  759. &ahb0_clk.common,
  760. &ahb1_clk.common,
  761. &ahb2_clk.common,
  762. &apb0_clk.common,
  763. &apb1_clk.common,
  764. &cci400_clk.common,
  765. &ats_clk.common,
  766. &trace_clk.common,
  767. &out_a_clk.common,
  768. &out_b_clk.common,
  769. /* module clocks */
  770. &nand0_0_clk.common,
  771. &nand0_1_clk.common,
  772. &nand1_0_clk.common,
  773. &nand1_1_clk.common,
  774. &mmc0_clk.common,
  775. &mmc0_sample_clk.common,
  776. &mmc0_output_clk.common,
  777. &mmc1_clk.common,
  778. &mmc1_sample_clk.common,
  779. &mmc1_output_clk.common,
  780. &mmc2_clk.common,
  781. &mmc2_sample_clk.common,
  782. &mmc2_output_clk.common,
  783. &mmc3_clk.common,
  784. &mmc3_sample_clk.common,
  785. &mmc3_output_clk.common,
  786. &ts_clk.common,
  787. &ss_clk.common,
  788. &spi0_clk.common,
  789. &spi1_clk.common,
  790. &spi2_clk.common,
  791. &spi3_clk.common,
  792. &i2s0_clk.common,
  793. &i2s1_clk.common,
  794. &spdif_clk.common,
  795. &sdram_clk.common,
  796. &de_clk.common,
  797. &edp_clk.common,
  798. &mp_clk.common,
  799. &lcd0_clk.common,
  800. &lcd1_clk.common,
  801. &mipi_dsi0_clk.common,
  802. &mipi_dsi1_clk.common,
  803. &hdmi_clk.common,
  804. &hdmi_slow_clk.common,
  805. &mipi_csi_clk.common,
  806. &csi_isp_clk.common,
  807. &csi_misc_clk.common,
  808. &csi0_mclk_clk.common,
  809. &csi1_mclk_clk.common,
  810. &fd_clk.common,
  811. &ve_clk.common,
  812. &avs_clk.common,
  813. &gpu_core_clk.common,
  814. &gpu_memory_clk.common,
  815. &gpu_axi_clk.common,
  816. &sata_clk.common,
  817. &ac97_clk.common,
  818. &mipi_hsi_clk.common,
  819. &gpadc_clk.common,
  820. &cir_tx_clk.common,
  821. /* AHB0 bus gates */
  822. &bus_fd_clk.common,
  823. &bus_ve_clk.common,
  824. &bus_gpu_ctrl_clk.common,
  825. &bus_ss_clk.common,
  826. &bus_mmc_clk.common,
  827. &bus_nand0_clk.common,
  828. &bus_nand1_clk.common,
  829. &bus_sdram_clk.common,
  830. &bus_mipi_hsi_clk.common,
  831. &bus_sata_clk.common,
  832. &bus_ts_clk.common,
  833. &bus_spi0_clk.common,
  834. &bus_spi1_clk.common,
  835. &bus_spi2_clk.common,
  836. &bus_spi3_clk.common,
  837. /* AHB1 bus gates */
  838. &bus_otg_clk.common,
  839. &bus_usb_clk.common,
  840. &bus_gmac_clk.common,
  841. &bus_msgbox_clk.common,
  842. &bus_spinlock_clk.common,
  843. &bus_hstimer_clk.common,
  844. &bus_dma_clk.common,
  845. /* AHB2 bus gates */
  846. &bus_lcd0_clk.common,
  847. &bus_lcd1_clk.common,
  848. &bus_edp_clk.common,
  849. &bus_csi_clk.common,
  850. &bus_hdmi_clk.common,
  851. &bus_de_clk.common,
  852. &bus_mp_clk.common,
  853. &bus_mipi_dsi_clk.common,
  854. /* APB0 bus gates */
  855. &bus_spdif_clk.common,
  856. &bus_pio_clk.common,
  857. &bus_ac97_clk.common,
  858. &bus_i2s0_clk.common,
  859. &bus_i2s1_clk.common,
  860. &bus_lradc_clk.common,
  861. &bus_gpadc_clk.common,
  862. &bus_twd_clk.common,
  863. &bus_cir_tx_clk.common,
  864. /* APB1 bus gates */
  865. &bus_i2c0_clk.common,
  866. &bus_i2c1_clk.common,
  867. &bus_i2c2_clk.common,
  868. &bus_i2c3_clk.common,
  869. &bus_i2c4_clk.common,
  870. &bus_uart0_clk.common,
  871. &bus_uart1_clk.common,
  872. &bus_uart2_clk.common,
  873. &bus_uart3_clk.common,
  874. &bus_uart4_clk.common,
  875. &bus_uart5_clk.common,
  876. };
  877. static struct clk_hw_onecell_data sun9i_a80_hw_clks = {
  878. .hws = {
  879. [CLK_PLL_C0CPUX] = &pll_c0cpux_clk.common.hw,
  880. [CLK_PLL_C1CPUX] = &pll_c1cpux_clk.common.hw,
  881. [CLK_PLL_AUDIO] = &pll_audio_clk.common.hw,
  882. [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw,
  883. [CLK_PLL_VE] = &pll_ve_clk.common.hw,
  884. [CLK_PLL_DDR] = &pll_ddr_clk.common.hw,
  885. [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw,
  886. [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw,
  887. [CLK_PLL_GPU] = &pll_gpu_clk.common.hw,
  888. [CLK_PLL_DE] = &pll_de_clk.common.hw,
  889. [CLK_PLL_ISP] = &pll_isp_clk.common.hw,
  890. [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw,
  891. [CLK_C0CPUX] = &c0cpux_clk.common.hw,
  892. [CLK_C1CPUX] = &c1cpux_clk.common.hw,
  893. [CLK_ATB0] = &atb0_clk.common.hw,
  894. [CLK_AXI0] = &axi0_clk.common.hw,
  895. [CLK_ATB1] = &atb1_clk.common.hw,
  896. [CLK_AXI1] = &axi1_clk.common.hw,
  897. [CLK_GTBUS] = &gtbus_clk.common.hw,
  898. [CLK_AHB0] = &ahb0_clk.common.hw,
  899. [CLK_AHB1] = &ahb1_clk.common.hw,
  900. [CLK_AHB2] = &ahb2_clk.common.hw,
  901. [CLK_APB0] = &apb0_clk.common.hw,
  902. [CLK_APB1] = &apb1_clk.common.hw,
  903. [CLK_CCI400] = &cci400_clk.common.hw,
  904. [CLK_ATS] = &ats_clk.common.hw,
  905. [CLK_TRACE] = &trace_clk.common.hw,
  906. [CLK_OUT_A] = &out_a_clk.common.hw,
  907. [CLK_OUT_B] = &out_b_clk.common.hw,
  908. [CLK_NAND0_0] = &nand0_0_clk.common.hw,
  909. [CLK_NAND0_1] = &nand0_1_clk.common.hw,
  910. [CLK_NAND1_0] = &nand1_0_clk.common.hw,
  911. [CLK_NAND1_1] = &nand1_1_clk.common.hw,
  912. [CLK_MMC0] = &mmc0_clk.common.hw,
  913. [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw,
  914. [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw,
  915. [CLK_MMC1] = &mmc1_clk.common.hw,
  916. [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw,
  917. [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw,
  918. [CLK_MMC2] = &mmc2_clk.common.hw,
  919. [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw,
  920. [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw,
  921. [CLK_MMC3] = &mmc3_clk.common.hw,
  922. [CLK_MMC3_SAMPLE] = &mmc3_sample_clk.common.hw,
  923. [CLK_MMC3_OUTPUT] = &mmc3_output_clk.common.hw,
  924. [CLK_TS] = &ts_clk.common.hw,
  925. [CLK_SS] = &ss_clk.common.hw,
  926. [CLK_SPI0] = &spi0_clk.common.hw,
  927. [CLK_SPI1] = &spi1_clk.common.hw,
  928. [CLK_SPI2] = &spi2_clk.common.hw,
  929. [CLK_SPI3] = &spi3_clk.common.hw,
  930. [CLK_I2S0] = &i2s0_clk.common.hw,
  931. [CLK_I2S1] = &i2s1_clk.common.hw,
  932. [CLK_SPDIF] = &spdif_clk.common.hw,
  933. [CLK_SDRAM] = &sdram_clk.common.hw,
  934. [CLK_DE] = &de_clk.common.hw,
  935. [CLK_EDP] = &edp_clk.common.hw,
  936. [CLK_MP] = &mp_clk.common.hw,
  937. [CLK_LCD0] = &lcd0_clk.common.hw,
  938. [CLK_LCD1] = &lcd1_clk.common.hw,
  939. [CLK_MIPI_DSI0] = &mipi_dsi0_clk.common.hw,
  940. [CLK_MIPI_DSI1] = &mipi_dsi1_clk.common.hw,
  941. [CLK_HDMI] = &hdmi_clk.common.hw,
  942. [CLK_HDMI_SLOW] = &hdmi_slow_clk.common.hw,
  943. [CLK_MIPI_CSI] = &mipi_csi_clk.common.hw,
  944. [CLK_CSI_ISP] = &csi_isp_clk.common.hw,
  945. [CLK_CSI_MISC] = &csi_misc_clk.common.hw,
  946. [CLK_CSI0_MCLK] = &csi0_mclk_clk.common.hw,
  947. [CLK_CSI1_MCLK] = &csi1_mclk_clk.common.hw,
  948. [CLK_FD] = &fd_clk.common.hw,
  949. [CLK_VE] = &ve_clk.common.hw,
  950. [CLK_AVS] = &avs_clk.common.hw,
  951. [CLK_GPU_CORE] = &gpu_core_clk.common.hw,
  952. [CLK_GPU_MEMORY] = &gpu_memory_clk.common.hw,
  953. [CLK_GPU_AXI] = &gpu_axi_clk.common.hw,
  954. [CLK_SATA] = &sata_clk.common.hw,
  955. [CLK_AC97] = &ac97_clk.common.hw,
  956. [CLK_MIPI_HSI] = &mipi_hsi_clk.common.hw,
  957. [CLK_GPADC] = &gpadc_clk.common.hw,
  958. [CLK_CIR_TX] = &cir_tx_clk.common.hw,
  959. [CLK_BUS_FD] = &bus_fd_clk.common.hw,
  960. [CLK_BUS_VE] = &bus_ve_clk.common.hw,
  961. [CLK_BUS_GPU_CTRL] = &bus_gpu_ctrl_clk.common.hw,
  962. [CLK_BUS_SS] = &bus_ss_clk.common.hw,
  963. [CLK_BUS_MMC] = &bus_mmc_clk.common.hw,
  964. [CLK_BUS_NAND0] = &bus_nand0_clk.common.hw,
  965. [CLK_BUS_NAND1] = &bus_nand1_clk.common.hw,
  966. [CLK_BUS_SDRAM] = &bus_sdram_clk.common.hw,
  967. [CLK_BUS_MIPI_HSI] = &bus_mipi_hsi_clk.common.hw,
  968. [CLK_BUS_SATA] = &bus_sata_clk.common.hw,
  969. [CLK_BUS_TS] = &bus_ts_clk.common.hw,
  970. [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw,
  971. [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw,
  972. [CLK_BUS_SPI2] = &bus_spi2_clk.common.hw,
  973. [CLK_BUS_SPI3] = &bus_spi3_clk.common.hw,
  974. [CLK_BUS_OTG] = &bus_otg_clk.common.hw,
  975. [CLK_BUS_USB] = &bus_usb_clk.common.hw,
  976. [CLK_BUS_GMAC] = &bus_gmac_clk.common.hw,
  977. [CLK_BUS_MSGBOX] = &bus_msgbox_clk.common.hw,
  978. [CLK_BUS_SPINLOCK] = &bus_spinlock_clk.common.hw,
  979. [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw,
  980. [CLK_BUS_DMA] = &bus_dma_clk.common.hw,
  981. [CLK_BUS_LCD0] = &bus_lcd0_clk.common.hw,
  982. [CLK_BUS_LCD1] = &bus_lcd1_clk.common.hw,
  983. [CLK_BUS_EDP] = &bus_edp_clk.common.hw,
  984. [CLK_BUS_CSI] = &bus_csi_clk.common.hw,
  985. [CLK_BUS_HDMI] = &bus_hdmi_clk.common.hw,
  986. [CLK_BUS_DE] = &bus_de_clk.common.hw,
  987. [CLK_BUS_MP] = &bus_mp_clk.common.hw,
  988. [CLK_BUS_MIPI_DSI] = &bus_mipi_dsi_clk.common.hw,
  989. [CLK_BUS_SPDIF] = &bus_spdif_clk.common.hw,
  990. [CLK_BUS_PIO] = &bus_pio_clk.common.hw,
  991. [CLK_BUS_AC97] = &bus_ac97_clk.common.hw,
  992. [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw,
  993. [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw,
  994. [CLK_BUS_LRADC] = &bus_lradc_clk.common.hw,
  995. [CLK_BUS_GPADC] = &bus_gpadc_clk.common.hw,
  996. [CLK_BUS_TWD] = &bus_twd_clk.common.hw,
  997. [CLK_BUS_CIR_TX] = &bus_cir_tx_clk.common.hw,
  998. [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw,
  999. [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw,
  1000. [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw,
  1001. [CLK_BUS_I2C3] = &bus_i2c3_clk.common.hw,
  1002. [CLK_BUS_I2C4] = &bus_i2c4_clk.common.hw,
  1003. [CLK_BUS_UART0] = &bus_uart0_clk.common.hw,
  1004. [CLK_BUS_UART1] = &bus_uart1_clk.common.hw,
  1005. [CLK_BUS_UART2] = &bus_uart2_clk.common.hw,
  1006. [CLK_BUS_UART3] = &bus_uart3_clk.common.hw,
  1007. [CLK_BUS_UART4] = &bus_uart4_clk.common.hw,
  1008. [CLK_BUS_UART5] = &bus_uart5_clk.common.hw,
  1009. },
  1010. .num = CLK_NUMBER,
  1011. };
  1012. static struct ccu_reset_map sun9i_a80_ccu_resets[] = {
  1013. /* AHB0 reset controls */
  1014. [RST_BUS_FD] = { 0x5a0, BIT(0) },
  1015. [RST_BUS_VE] = { 0x5a0, BIT(1) },
  1016. [RST_BUS_GPU_CTRL] = { 0x5a0, BIT(3) },
  1017. [RST_BUS_SS] = { 0x5a0, BIT(5) },
  1018. [RST_BUS_MMC] = { 0x5a0, BIT(8) },
  1019. [RST_BUS_NAND0] = { 0x5a0, BIT(12) },
  1020. [RST_BUS_NAND1] = { 0x5a0, BIT(13) },
  1021. [RST_BUS_SDRAM] = { 0x5a0, BIT(14) },
  1022. [RST_BUS_SATA] = { 0x5a0, BIT(16) },
  1023. [RST_BUS_TS] = { 0x5a0, BIT(18) },
  1024. [RST_BUS_SPI0] = { 0x5a0, BIT(20) },
  1025. [RST_BUS_SPI1] = { 0x5a0, BIT(21) },
  1026. [RST_BUS_SPI2] = { 0x5a0, BIT(22) },
  1027. [RST_BUS_SPI3] = { 0x5a0, BIT(23) },
  1028. /* AHB1 reset controls */
  1029. [RST_BUS_OTG] = { 0x5a4, BIT(0) },
  1030. [RST_BUS_OTG_PHY] = { 0x5a4, BIT(1) },
  1031. [RST_BUS_MIPI_HSI] = { 0x5a4, BIT(9) },
  1032. [RST_BUS_GMAC] = { 0x5a4, BIT(17) },
  1033. [RST_BUS_MSGBOX] = { 0x5a4, BIT(21) },
  1034. [RST_BUS_SPINLOCK] = { 0x5a4, BIT(22) },
  1035. [RST_BUS_HSTIMER] = { 0x5a4, BIT(23) },
  1036. [RST_BUS_DMA] = { 0x5a4, BIT(24) },
  1037. /* AHB2 reset controls */
  1038. [RST_BUS_LCD0] = { 0x5a8, BIT(0) },
  1039. [RST_BUS_LCD1] = { 0x5a8, BIT(1) },
  1040. [RST_BUS_EDP] = { 0x5a8, BIT(2) },
  1041. [RST_BUS_LVDS] = { 0x5a8, BIT(3) },
  1042. [RST_BUS_CSI] = { 0x5a8, BIT(4) },
  1043. [RST_BUS_HDMI0] = { 0x5a8, BIT(5) },
  1044. [RST_BUS_HDMI1] = { 0x5a8, BIT(6) },
  1045. [RST_BUS_DE] = { 0x5a8, BIT(7) },
  1046. [RST_BUS_MP] = { 0x5a8, BIT(8) },
  1047. [RST_BUS_GPU] = { 0x5a8, BIT(9) },
  1048. [RST_BUS_MIPI_DSI] = { 0x5a8, BIT(11) },
  1049. /* APB0 reset controls */
  1050. [RST_BUS_SPDIF] = { 0x5b0, BIT(1) },
  1051. [RST_BUS_AC97] = { 0x5b0, BIT(11) },
  1052. [RST_BUS_I2S0] = { 0x5b0, BIT(12) },
  1053. [RST_BUS_I2S1] = { 0x5b0, BIT(13) },
  1054. [RST_BUS_LRADC] = { 0x5b0, BIT(15) },
  1055. [RST_BUS_GPADC] = { 0x5b0, BIT(17) },
  1056. [RST_BUS_CIR_TX] = { 0x5b0, BIT(19) },
  1057. /* APB1 reset controls */
  1058. [RST_BUS_I2C0] = { 0x5b4, BIT(0) },
  1059. [RST_BUS_I2C1] = { 0x5b4, BIT(1) },
  1060. [RST_BUS_I2C2] = { 0x5b4, BIT(2) },
  1061. [RST_BUS_I2C3] = { 0x5b4, BIT(3) },
  1062. [RST_BUS_I2C4] = { 0x5b4, BIT(4) },
  1063. [RST_BUS_UART0] = { 0x5b4, BIT(16) },
  1064. [RST_BUS_UART1] = { 0x5b4, BIT(17) },
  1065. [RST_BUS_UART2] = { 0x5b4, BIT(18) },
  1066. [RST_BUS_UART3] = { 0x5b4, BIT(19) },
  1067. [RST_BUS_UART4] = { 0x5b4, BIT(20) },
  1068. [RST_BUS_UART5] = { 0x5b4, BIT(21) },
  1069. };
  1070. static const struct sunxi_ccu_desc sun9i_a80_ccu_desc = {
  1071. .ccu_clks = sun9i_a80_ccu_clks,
  1072. .num_ccu_clks = ARRAY_SIZE(sun9i_a80_ccu_clks),
  1073. .hw_clks = &sun9i_a80_hw_clks,
  1074. .resets = sun9i_a80_ccu_resets,
  1075. .num_resets = ARRAY_SIZE(sun9i_a80_ccu_resets),
  1076. };
  1077. static int sun9i_a80_ccu_probe(struct platform_device *pdev)
  1078. {
  1079. struct resource *res;
  1080. void __iomem *reg;
  1081. u32 val;
  1082. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1083. reg = devm_ioremap_resource(&pdev->dev, res);
  1084. if (IS_ERR(reg))
  1085. return PTR_ERR(reg);
  1086. /* Enforce d1 = 0, d2 = 0 for Audio PLL */
  1087. val = readl(reg + SUN9I_A80_PLL_AUDIO_REG);
  1088. val &= (BIT(16) & BIT(18));
  1089. writel(val, reg + SUN9I_A80_PLL_AUDIO_REG);
  1090. return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun9i_a80_ccu_desc);
  1091. }
  1092. static const struct of_device_id sun9i_a80_ccu_ids[] = {
  1093. { .compatible = "allwinner,sun9i-a80-ccu" },
  1094. { }
  1095. };
  1096. static struct platform_driver sun9i_a80_ccu_driver = {
  1097. .probe = sun9i_a80_ccu_probe,
  1098. .driver = {
  1099. .name = "sun9i-a80-ccu",
  1100. .of_match_table = sun9i_a80_ccu_ids,
  1101. },
  1102. };
  1103. builtin_platform_driver(sun9i_a80_ccu_driver);