axg.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * AmLogic Meson-AXG Clock Controller Driver
  4. *
  5. * Copyright (c) 2016 Baylibre SAS.
  6. * Author: Michael Turquette <mturquette@baylibre.com>
  7. *
  8. * Copyright (c) 2017 Amlogic, inc.
  9. * Author: Qiufang Dai <qiufang.dai@amlogic.com>
  10. */
  11. #include <linux/clk.h>
  12. #include <linux/clk-provider.h>
  13. #include <linux/init.h>
  14. #include <linux/of_device.h>
  15. #include <linux/mfd/syscon.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/regmap.h>
  18. #include "clkc.h"
  19. #include "axg.h"
  20. static DEFINE_SPINLOCK(meson_clk_lock);
  21. static struct clk_regmap axg_fixed_pll = {
  22. .data = &(struct meson_clk_pll_data){
  23. .m = {
  24. .reg_off = HHI_MPLL_CNTL,
  25. .shift = 0,
  26. .width = 9,
  27. },
  28. .n = {
  29. .reg_off = HHI_MPLL_CNTL,
  30. .shift = 9,
  31. .width = 5,
  32. },
  33. .od = {
  34. .reg_off = HHI_MPLL_CNTL,
  35. .shift = 16,
  36. .width = 2,
  37. },
  38. .frac = {
  39. .reg_off = HHI_MPLL_CNTL2,
  40. .shift = 0,
  41. .width = 12,
  42. },
  43. .l = {
  44. .reg_off = HHI_MPLL_CNTL,
  45. .shift = 31,
  46. .width = 1,
  47. },
  48. .rst = {
  49. .reg_off = HHI_MPLL_CNTL,
  50. .shift = 29,
  51. .width = 1,
  52. },
  53. },
  54. .hw.init = &(struct clk_init_data){
  55. .name = "fixed_pll",
  56. .ops = &meson_clk_pll_ro_ops,
  57. .parent_names = (const char *[]){ "xtal" },
  58. .num_parents = 1,
  59. },
  60. };
  61. static struct clk_regmap axg_sys_pll = {
  62. .data = &(struct meson_clk_pll_data){
  63. .m = {
  64. .reg_off = HHI_SYS_PLL_CNTL,
  65. .shift = 0,
  66. .width = 9,
  67. },
  68. .n = {
  69. .reg_off = HHI_SYS_PLL_CNTL,
  70. .shift = 9,
  71. .width = 5,
  72. },
  73. .od = {
  74. .reg_off = HHI_SYS_PLL_CNTL,
  75. .shift = 16,
  76. .width = 2,
  77. },
  78. .l = {
  79. .reg_off = HHI_SYS_PLL_CNTL,
  80. .shift = 31,
  81. .width = 1,
  82. },
  83. .rst = {
  84. .reg_off = HHI_SYS_PLL_CNTL,
  85. .shift = 29,
  86. .width = 1,
  87. },
  88. },
  89. .hw.init = &(struct clk_init_data){
  90. .name = "sys_pll",
  91. .ops = &meson_clk_pll_ro_ops,
  92. .parent_names = (const char *[]){ "xtal" },
  93. .num_parents = 1,
  94. },
  95. };
  96. static const struct pll_rate_table axg_gp0_pll_rate_table[] = {
  97. PLL_RATE(240000000, 40, 1, 2),
  98. PLL_RATE(246000000, 41, 1, 2),
  99. PLL_RATE(252000000, 42, 1, 2),
  100. PLL_RATE(258000000, 43, 1, 2),
  101. PLL_RATE(264000000, 44, 1, 2),
  102. PLL_RATE(270000000, 45, 1, 2),
  103. PLL_RATE(276000000, 46, 1, 2),
  104. PLL_RATE(282000000, 47, 1, 2),
  105. PLL_RATE(288000000, 48, 1, 2),
  106. PLL_RATE(294000000, 49, 1, 2),
  107. PLL_RATE(300000000, 50, 1, 2),
  108. PLL_RATE(306000000, 51, 1, 2),
  109. PLL_RATE(312000000, 52, 1, 2),
  110. PLL_RATE(318000000, 53, 1, 2),
  111. PLL_RATE(324000000, 54, 1, 2),
  112. PLL_RATE(330000000, 55, 1, 2),
  113. PLL_RATE(336000000, 56, 1, 2),
  114. PLL_RATE(342000000, 57, 1, 2),
  115. PLL_RATE(348000000, 58, 1, 2),
  116. PLL_RATE(354000000, 59, 1, 2),
  117. PLL_RATE(360000000, 60, 1, 2),
  118. PLL_RATE(366000000, 61, 1, 2),
  119. PLL_RATE(372000000, 62, 1, 2),
  120. PLL_RATE(378000000, 63, 1, 2),
  121. PLL_RATE(384000000, 64, 1, 2),
  122. PLL_RATE(390000000, 65, 1, 3),
  123. PLL_RATE(396000000, 66, 1, 3),
  124. PLL_RATE(402000000, 67, 1, 3),
  125. PLL_RATE(408000000, 68, 1, 3),
  126. PLL_RATE(480000000, 40, 1, 1),
  127. PLL_RATE(492000000, 41, 1, 1),
  128. PLL_RATE(504000000, 42, 1, 1),
  129. PLL_RATE(516000000, 43, 1, 1),
  130. PLL_RATE(528000000, 44, 1, 1),
  131. PLL_RATE(540000000, 45, 1, 1),
  132. PLL_RATE(552000000, 46, 1, 1),
  133. PLL_RATE(564000000, 47, 1, 1),
  134. PLL_RATE(576000000, 48, 1, 1),
  135. PLL_RATE(588000000, 49, 1, 1),
  136. PLL_RATE(600000000, 50, 1, 1),
  137. PLL_RATE(612000000, 51, 1, 1),
  138. PLL_RATE(624000000, 52, 1, 1),
  139. PLL_RATE(636000000, 53, 1, 1),
  140. PLL_RATE(648000000, 54, 1, 1),
  141. PLL_RATE(660000000, 55, 1, 1),
  142. PLL_RATE(672000000, 56, 1, 1),
  143. PLL_RATE(684000000, 57, 1, 1),
  144. PLL_RATE(696000000, 58, 1, 1),
  145. PLL_RATE(708000000, 59, 1, 1),
  146. PLL_RATE(720000000, 60, 1, 1),
  147. PLL_RATE(732000000, 61, 1, 1),
  148. PLL_RATE(744000000, 62, 1, 1),
  149. PLL_RATE(756000000, 63, 1, 1),
  150. PLL_RATE(768000000, 64, 1, 1),
  151. PLL_RATE(780000000, 65, 1, 1),
  152. PLL_RATE(792000000, 66, 1, 1),
  153. PLL_RATE(804000000, 67, 1, 1),
  154. PLL_RATE(816000000, 68, 1, 1),
  155. PLL_RATE(960000000, 40, 1, 0),
  156. PLL_RATE(984000000, 41, 1, 0),
  157. PLL_RATE(1008000000, 42, 1, 0),
  158. PLL_RATE(1032000000, 43, 1, 0),
  159. PLL_RATE(1056000000, 44, 1, 0),
  160. PLL_RATE(1080000000, 45, 1, 0),
  161. PLL_RATE(1104000000, 46, 1, 0),
  162. PLL_RATE(1128000000, 47, 1, 0),
  163. PLL_RATE(1152000000, 48, 1, 0),
  164. PLL_RATE(1176000000, 49, 1, 0),
  165. PLL_RATE(1200000000, 50, 1, 0),
  166. PLL_RATE(1224000000, 51, 1, 0),
  167. PLL_RATE(1248000000, 52, 1, 0),
  168. PLL_RATE(1272000000, 53, 1, 0),
  169. PLL_RATE(1296000000, 54, 1, 0),
  170. PLL_RATE(1320000000, 55, 1, 0),
  171. PLL_RATE(1344000000, 56, 1, 0),
  172. PLL_RATE(1368000000, 57, 1, 0),
  173. PLL_RATE(1392000000, 58, 1, 0),
  174. PLL_RATE(1416000000, 59, 1, 0),
  175. PLL_RATE(1440000000, 60, 1, 0),
  176. PLL_RATE(1464000000, 61, 1, 0),
  177. PLL_RATE(1488000000, 62, 1, 0),
  178. PLL_RATE(1512000000, 63, 1, 0),
  179. PLL_RATE(1536000000, 64, 1, 0),
  180. PLL_RATE(1560000000, 65, 1, 0),
  181. PLL_RATE(1584000000, 66, 1, 0),
  182. PLL_RATE(1608000000, 67, 1, 0),
  183. PLL_RATE(1632000000, 68, 1, 0),
  184. { /* sentinel */ },
  185. };
  186. static const struct reg_sequence axg_gp0_init_regs[] = {
  187. { .reg = HHI_GP0_PLL_CNTL1, .def = 0xc084b000 },
  188. { .reg = HHI_GP0_PLL_CNTL2, .def = 0xb75020be },
  189. { .reg = HHI_GP0_PLL_CNTL3, .def = 0x0a59a288 },
  190. { .reg = HHI_GP0_PLL_CNTL4, .def = 0xc000004d },
  191. { .reg = HHI_GP0_PLL_CNTL5, .def = 0x00078000 },
  192. { .reg = HHI_GP0_PLL_CNTL, .def = 0x40010250 },
  193. };
  194. static struct clk_regmap axg_gp0_pll = {
  195. .data = &(struct meson_clk_pll_data){
  196. .m = {
  197. .reg_off = HHI_GP0_PLL_CNTL,
  198. .shift = 0,
  199. .width = 9,
  200. },
  201. .n = {
  202. .reg_off = HHI_GP0_PLL_CNTL,
  203. .shift = 9,
  204. .width = 5,
  205. },
  206. .od = {
  207. .reg_off = HHI_GP0_PLL_CNTL,
  208. .shift = 16,
  209. .width = 2,
  210. },
  211. .frac = {
  212. .reg_off = HHI_GP0_PLL_CNTL1,
  213. .shift = 0,
  214. .width = 10,
  215. },
  216. .l = {
  217. .reg_off = HHI_GP0_PLL_CNTL,
  218. .shift = 31,
  219. .width = 1,
  220. },
  221. .rst = {
  222. .reg_off = HHI_GP0_PLL_CNTL,
  223. .shift = 29,
  224. .width = 1,
  225. },
  226. .table = axg_gp0_pll_rate_table,
  227. .init_regs = axg_gp0_init_regs,
  228. .init_count = ARRAY_SIZE(axg_gp0_init_regs),
  229. },
  230. .hw.init = &(struct clk_init_data){
  231. .name = "gp0_pll",
  232. .ops = &meson_clk_pll_ops,
  233. .parent_names = (const char *[]){ "xtal" },
  234. .num_parents = 1,
  235. },
  236. };
  237. static const struct reg_sequence axg_hifi_init_regs[] = {
  238. { .reg = HHI_HIFI_PLL_CNTL1, .def = 0xc084b000 },
  239. { .reg = HHI_HIFI_PLL_CNTL2, .def = 0xb75020be },
  240. { .reg = HHI_HIFI_PLL_CNTL3, .def = 0x0a6a3a88 },
  241. { .reg = HHI_HIFI_PLL_CNTL4, .def = 0xc000004d },
  242. { .reg = HHI_HIFI_PLL_CNTL5, .def = 0x00058000 },
  243. { .reg = HHI_HIFI_PLL_CNTL, .def = 0x40010250 },
  244. };
  245. static struct clk_regmap axg_hifi_pll = {
  246. .data = &(struct meson_clk_pll_data){
  247. .m = {
  248. .reg_off = HHI_HIFI_PLL_CNTL,
  249. .shift = 0,
  250. .width = 9,
  251. },
  252. .n = {
  253. .reg_off = HHI_HIFI_PLL_CNTL,
  254. .shift = 9,
  255. .width = 5,
  256. },
  257. .od = {
  258. .reg_off = HHI_HIFI_PLL_CNTL,
  259. .shift = 16,
  260. .width = 2,
  261. },
  262. .frac = {
  263. .reg_off = HHI_HIFI_PLL_CNTL5,
  264. .shift = 0,
  265. .width = 13,
  266. },
  267. .l = {
  268. .reg_off = HHI_HIFI_PLL_CNTL,
  269. .shift = 31,
  270. .width = 1,
  271. },
  272. .rst = {
  273. .reg_off = HHI_HIFI_PLL_CNTL,
  274. .shift = 29,
  275. .width = 1,
  276. },
  277. .table = axg_gp0_pll_rate_table,
  278. .init_regs = axg_hifi_init_regs,
  279. .init_count = ARRAY_SIZE(axg_hifi_init_regs),
  280. .flags = CLK_MESON_PLL_ROUND_CLOSEST,
  281. },
  282. .hw.init = &(struct clk_init_data){
  283. .name = "hifi_pll",
  284. .ops = &meson_clk_pll_ops,
  285. .parent_names = (const char *[]){ "xtal" },
  286. .num_parents = 1,
  287. },
  288. };
  289. static struct clk_fixed_factor axg_fclk_div2_div = {
  290. .mult = 1,
  291. .div = 2,
  292. .hw.init = &(struct clk_init_data){
  293. .name = "fclk_div2_div",
  294. .ops = &clk_fixed_factor_ops,
  295. .parent_names = (const char *[]){ "fixed_pll" },
  296. .num_parents = 1,
  297. },
  298. };
  299. static struct clk_regmap axg_fclk_div2 = {
  300. .data = &(struct clk_regmap_gate_data){
  301. .offset = HHI_MPLL_CNTL6,
  302. .bit_idx = 27,
  303. },
  304. .hw.init = &(struct clk_init_data){
  305. .name = "fclk_div2",
  306. .ops = &clk_regmap_gate_ops,
  307. .parent_names = (const char *[]){ "fclk_div2_div" },
  308. .num_parents = 1,
  309. .flags = CLK_IS_CRITICAL,
  310. },
  311. };
  312. static struct clk_fixed_factor axg_fclk_div3_div = {
  313. .mult = 1,
  314. .div = 3,
  315. .hw.init = &(struct clk_init_data){
  316. .name = "fclk_div3_div",
  317. .ops = &clk_fixed_factor_ops,
  318. .parent_names = (const char *[]){ "fixed_pll" },
  319. .num_parents = 1,
  320. },
  321. };
  322. static struct clk_regmap axg_fclk_div3 = {
  323. .data = &(struct clk_regmap_gate_data){
  324. .offset = HHI_MPLL_CNTL6,
  325. .bit_idx = 28,
  326. },
  327. .hw.init = &(struct clk_init_data){
  328. .name = "fclk_div3",
  329. .ops = &clk_regmap_gate_ops,
  330. .parent_names = (const char *[]){ "fclk_div3_div" },
  331. .num_parents = 1,
  332. /*
  333. * FIXME:
  334. * This clock, as fdiv2, is used by the SCPI FW and is required
  335. * by the platform to operate correctly.
  336. * Until the following condition are met, we need this clock to
  337. * be marked as critical:
  338. * a) The SCPI generic driver claims and enable all the clocks
  339. * it needs
  340. * b) CCF has a clock hand-off mechanism to make the sure the
  341. * clock stays on until the proper driver comes along
  342. */
  343. .flags = CLK_IS_CRITICAL,
  344. },
  345. };
  346. static struct clk_fixed_factor axg_fclk_div4_div = {
  347. .mult = 1,
  348. .div = 4,
  349. .hw.init = &(struct clk_init_data){
  350. .name = "fclk_div4_div",
  351. .ops = &clk_fixed_factor_ops,
  352. .parent_names = (const char *[]){ "fixed_pll" },
  353. .num_parents = 1,
  354. },
  355. };
  356. static struct clk_regmap axg_fclk_div4 = {
  357. .data = &(struct clk_regmap_gate_data){
  358. .offset = HHI_MPLL_CNTL6,
  359. .bit_idx = 29,
  360. },
  361. .hw.init = &(struct clk_init_data){
  362. .name = "fclk_div4",
  363. .ops = &clk_regmap_gate_ops,
  364. .parent_names = (const char *[]){ "fclk_div4_div" },
  365. .num_parents = 1,
  366. },
  367. };
  368. static struct clk_fixed_factor axg_fclk_div5_div = {
  369. .mult = 1,
  370. .div = 5,
  371. .hw.init = &(struct clk_init_data){
  372. .name = "fclk_div5_div",
  373. .ops = &clk_fixed_factor_ops,
  374. .parent_names = (const char *[]){ "fixed_pll" },
  375. .num_parents = 1,
  376. },
  377. };
  378. static struct clk_regmap axg_fclk_div5 = {
  379. .data = &(struct clk_regmap_gate_data){
  380. .offset = HHI_MPLL_CNTL6,
  381. .bit_idx = 30,
  382. },
  383. .hw.init = &(struct clk_init_data){
  384. .name = "fclk_div5",
  385. .ops = &clk_regmap_gate_ops,
  386. .parent_names = (const char *[]){ "fclk_div5_div" },
  387. .num_parents = 1,
  388. },
  389. };
  390. static struct clk_fixed_factor axg_fclk_div7_div = {
  391. .mult = 1,
  392. .div = 7,
  393. .hw.init = &(struct clk_init_data){
  394. .name = "fclk_div7_div",
  395. .ops = &clk_fixed_factor_ops,
  396. .parent_names = (const char *[]){ "fixed_pll" },
  397. .num_parents = 1,
  398. },
  399. };
  400. static struct clk_regmap axg_fclk_div7 = {
  401. .data = &(struct clk_regmap_gate_data){
  402. .offset = HHI_MPLL_CNTL6,
  403. .bit_idx = 31,
  404. },
  405. .hw.init = &(struct clk_init_data){
  406. .name = "fclk_div7",
  407. .ops = &clk_regmap_gate_ops,
  408. .parent_names = (const char *[]){ "fclk_div7_div" },
  409. .num_parents = 1,
  410. },
  411. };
  412. static struct clk_regmap axg_mpll_prediv = {
  413. .data = &(struct clk_regmap_div_data){
  414. .offset = HHI_MPLL_CNTL5,
  415. .shift = 12,
  416. .width = 1,
  417. },
  418. .hw.init = &(struct clk_init_data){
  419. .name = "mpll_prediv",
  420. .ops = &clk_regmap_divider_ro_ops,
  421. .parent_names = (const char *[]){ "fixed_pll" },
  422. .num_parents = 1,
  423. },
  424. };
  425. static struct clk_regmap axg_mpll0_div = {
  426. .data = &(struct meson_clk_mpll_data){
  427. .sdm = {
  428. .reg_off = HHI_MPLL_CNTL7,
  429. .shift = 0,
  430. .width = 14,
  431. },
  432. .sdm_en = {
  433. .reg_off = HHI_MPLL_CNTL7,
  434. .shift = 15,
  435. .width = 1,
  436. },
  437. .n2 = {
  438. .reg_off = HHI_MPLL_CNTL7,
  439. .shift = 16,
  440. .width = 9,
  441. },
  442. .misc = {
  443. .reg_off = HHI_PLL_TOP_MISC,
  444. .shift = 0,
  445. .width = 1,
  446. },
  447. .lock = &meson_clk_lock,
  448. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  449. },
  450. .hw.init = &(struct clk_init_data){
  451. .name = "mpll0_div",
  452. .ops = &meson_clk_mpll_ops,
  453. .parent_names = (const char *[]){ "mpll_prediv" },
  454. .num_parents = 1,
  455. },
  456. };
  457. static struct clk_regmap axg_mpll0 = {
  458. .data = &(struct clk_regmap_gate_data){
  459. .offset = HHI_MPLL_CNTL7,
  460. .bit_idx = 14,
  461. },
  462. .hw.init = &(struct clk_init_data){
  463. .name = "mpll0",
  464. .ops = &clk_regmap_gate_ops,
  465. .parent_names = (const char *[]){ "mpll0_div" },
  466. .num_parents = 1,
  467. .flags = CLK_SET_RATE_PARENT,
  468. },
  469. };
  470. static struct clk_regmap axg_mpll1_div = {
  471. .data = &(struct meson_clk_mpll_data){
  472. .sdm = {
  473. .reg_off = HHI_MPLL_CNTL8,
  474. .shift = 0,
  475. .width = 14,
  476. },
  477. .sdm_en = {
  478. .reg_off = HHI_MPLL_CNTL8,
  479. .shift = 15,
  480. .width = 1,
  481. },
  482. .n2 = {
  483. .reg_off = HHI_MPLL_CNTL8,
  484. .shift = 16,
  485. .width = 9,
  486. },
  487. .misc = {
  488. .reg_off = HHI_PLL_TOP_MISC,
  489. .shift = 1,
  490. .width = 1,
  491. },
  492. .lock = &meson_clk_lock,
  493. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  494. },
  495. .hw.init = &(struct clk_init_data){
  496. .name = "mpll1_div",
  497. .ops = &meson_clk_mpll_ops,
  498. .parent_names = (const char *[]){ "mpll_prediv" },
  499. .num_parents = 1,
  500. },
  501. };
  502. static struct clk_regmap axg_mpll1 = {
  503. .data = &(struct clk_regmap_gate_data){
  504. .offset = HHI_MPLL_CNTL8,
  505. .bit_idx = 14,
  506. },
  507. .hw.init = &(struct clk_init_data){
  508. .name = "mpll1",
  509. .ops = &clk_regmap_gate_ops,
  510. .parent_names = (const char *[]){ "mpll1_div" },
  511. .num_parents = 1,
  512. .flags = CLK_SET_RATE_PARENT,
  513. },
  514. };
  515. static struct clk_regmap axg_mpll2_div = {
  516. .data = &(struct meson_clk_mpll_data){
  517. .sdm = {
  518. .reg_off = HHI_MPLL_CNTL9,
  519. .shift = 0,
  520. .width = 14,
  521. },
  522. .sdm_en = {
  523. .reg_off = HHI_MPLL_CNTL9,
  524. .shift = 15,
  525. .width = 1,
  526. },
  527. .n2 = {
  528. .reg_off = HHI_MPLL_CNTL9,
  529. .shift = 16,
  530. .width = 9,
  531. },
  532. .ssen = {
  533. .reg_off = HHI_MPLL_CNTL,
  534. .shift = 25,
  535. .width = 1,
  536. },
  537. .misc = {
  538. .reg_off = HHI_PLL_TOP_MISC,
  539. .shift = 2,
  540. .width = 1,
  541. },
  542. .lock = &meson_clk_lock,
  543. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  544. },
  545. .hw.init = &(struct clk_init_data){
  546. .name = "mpll2_div",
  547. .ops = &meson_clk_mpll_ops,
  548. .parent_names = (const char *[]){ "mpll_prediv" },
  549. .num_parents = 1,
  550. },
  551. };
  552. static struct clk_regmap axg_mpll2 = {
  553. .data = &(struct clk_regmap_gate_data){
  554. .offset = HHI_MPLL_CNTL9,
  555. .bit_idx = 14,
  556. },
  557. .hw.init = &(struct clk_init_data){
  558. .name = "mpll2",
  559. .ops = &clk_regmap_gate_ops,
  560. .parent_names = (const char *[]){ "mpll2_div" },
  561. .num_parents = 1,
  562. .flags = CLK_SET_RATE_PARENT,
  563. },
  564. };
  565. static struct clk_regmap axg_mpll3_div = {
  566. .data = &(struct meson_clk_mpll_data){
  567. .sdm = {
  568. .reg_off = HHI_MPLL3_CNTL0,
  569. .shift = 12,
  570. .width = 14,
  571. },
  572. .sdm_en = {
  573. .reg_off = HHI_MPLL3_CNTL0,
  574. .shift = 11,
  575. .width = 1,
  576. },
  577. .n2 = {
  578. .reg_off = HHI_MPLL3_CNTL0,
  579. .shift = 2,
  580. .width = 9,
  581. },
  582. .misc = {
  583. .reg_off = HHI_PLL_TOP_MISC,
  584. .shift = 3,
  585. .width = 1,
  586. },
  587. .lock = &meson_clk_lock,
  588. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  589. },
  590. .hw.init = &(struct clk_init_data){
  591. .name = "mpll3_div",
  592. .ops = &meson_clk_mpll_ops,
  593. .parent_names = (const char *[]){ "mpll_prediv" },
  594. .num_parents = 1,
  595. },
  596. };
  597. static struct clk_regmap axg_mpll3 = {
  598. .data = &(struct clk_regmap_gate_data){
  599. .offset = HHI_MPLL3_CNTL0,
  600. .bit_idx = 0,
  601. },
  602. .hw.init = &(struct clk_init_data){
  603. .name = "mpll3",
  604. .ops = &clk_regmap_gate_ops,
  605. .parent_names = (const char *[]){ "mpll3_div" },
  606. .num_parents = 1,
  607. .flags = CLK_SET_RATE_PARENT,
  608. },
  609. };
  610. static const struct pll_rate_table axg_pcie_pll_rate_table[] = {
  611. {
  612. .rate = 100000000,
  613. .m = 200,
  614. .n = 3,
  615. .od = 1,
  616. .od2 = 3,
  617. },
  618. { /* sentinel */ },
  619. };
  620. static const struct reg_sequence axg_pcie_init_regs[] = {
  621. { .reg = HHI_PCIE_PLL_CNTL, .def = 0x400106c8 },
  622. { .reg = HHI_PCIE_PLL_CNTL1, .def = 0x0084a2aa },
  623. { .reg = HHI_PCIE_PLL_CNTL2, .def = 0xb75020be },
  624. { .reg = HHI_PCIE_PLL_CNTL3, .def = 0x0a47488e },
  625. { .reg = HHI_PCIE_PLL_CNTL4, .def = 0xc000004d },
  626. { .reg = HHI_PCIE_PLL_CNTL5, .def = 0x00078000 },
  627. { .reg = HHI_PCIE_PLL_CNTL6, .def = 0x002323c6 },
  628. };
  629. static struct clk_regmap axg_pcie_pll = {
  630. .data = &(struct meson_clk_pll_data){
  631. .m = {
  632. .reg_off = HHI_PCIE_PLL_CNTL,
  633. .shift = 0,
  634. .width = 9,
  635. },
  636. .n = {
  637. .reg_off = HHI_PCIE_PLL_CNTL,
  638. .shift = 9,
  639. .width = 5,
  640. },
  641. .od = {
  642. .reg_off = HHI_PCIE_PLL_CNTL,
  643. .shift = 16,
  644. .width = 2,
  645. },
  646. .od2 = {
  647. .reg_off = HHI_PCIE_PLL_CNTL6,
  648. .shift = 6,
  649. .width = 2,
  650. },
  651. .frac = {
  652. .reg_off = HHI_PCIE_PLL_CNTL1,
  653. .shift = 0,
  654. .width = 12,
  655. },
  656. .l = {
  657. .reg_off = HHI_PCIE_PLL_CNTL,
  658. .shift = 31,
  659. .width = 1,
  660. },
  661. .rst = {
  662. .reg_off = HHI_PCIE_PLL_CNTL,
  663. .shift = 29,
  664. .width = 1,
  665. },
  666. .table = axg_pcie_pll_rate_table,
  667. .init_regs = axg_pcie_init_regs,
  668. .init_count = ARRAY_SIZE(axg_pcie_init_regs),
  669. },
  670. .hw.init = &(struct clk_init_data){
  671. .name = "pcie_pll",
  672. .ops = &meson_clk_pll_ops,
  673. .parent_names = (const char *[]){ "xtal" },
  674. .num_parents = 1,
  675. },
  676. };
  677. static struct clk_regmap axg_pcie_mux = {
  678. .data = &(struct clk_regmap_mux_data){
  679. .offset = HHI_PCIE_PLL_CNTL6,
  680. .mask = 0x1,
  681. .shift = 2,
  682. /* skip the parent mpll3, reserved for debug */
  683. .table = (u32[]){ 1 },
  684. },
  685. .hw.init = &(struct clk_init_data){
  686. .name = "pcie_mux",
  687. .ops = &clk_regmap_mux_ops,
  688. .parent_names = (const char *[]){ "pcie_pll" },
  689. .num_parents = 1,
  690. .flags = CLK_SET_RATE_PARENT,
  691. },
  692. };
  693. static struct clk_regmap axg_pcie_ref = {
  694. .data = &(struct clk_regmap_mux_data){
  695. .offset = HHI_PCIE_PLL_CNTL6,
  696. .mask = 0x1,
  697. .shift = 1,
  698. /* skip the parent 0, reserved for debug */
  699. .table = (u32[]){ 1 },
  700. },
  701. .hw.init = &(struct clk_init_data){
  702. .name = "pcie_ref",
  703. .ops = &clk_regmap_mux_ops,
  704. .parent_names = (const char *[]){ "pcie_mux" },
  705. .num_parents = 1,
  706. .flags = CLK_SET_RATE_PARENT,
  707. },
  708. };
  709. static struct clk_regmap axg_pcie_cml_en0 = {
  710. .data = &(struct clk_regmap_gate_data){
  711. .offset = HHI_PCIE_PLL_CNTL6,
  712. .bit_idx = 4,
  713. },
  714. .hw.init = &(struct clk_init_data) {
  715. .name = "pcie_cml_en0",
  716. .ops = &clk_regmap_gate_ops,
  717. .parent_names = (const char *[]){ "pcie_ref" },
  718. .num_parents = 1,
  719. .flags = CLK_SET_RATE_PARENT,
  720. },
  721. };
  722. static struct clk_regmap axg_pcie_cml_en1 = {
  723. .data = &(struct clk_regmap_gate_data){
  724. .offset = HHI_PCIE_PLL_CNTL6,
  725. .bit_idx = 3,
  726. },
  727. .hw.init = &(struct clk_init_data) {
  728. .name = "pcie_cml_en1",
  729. .ops = &clk_regmap_gate_ops,
  730. .parent_names = (const char *[]){ "pcie_ref" },
  731. .num_parents = 1,
  732. .flags = CLK_SET_RATE_PARENT,
  733. },
  734. };
  735. static u32 mux_table_clk81[] = { 0, 2, 3, 4, 5, 6, 7 };
  736. static const char * const clk81_parent_names[] = {
  737. "xtal", "fclk_div7", "mpll1", "mpll2", "fclk_div4",
  738. "fclk_div3", "fclk_div5"
  739. };
  740. static struct clk_regmap axg_mpeg_clk_sel = {
  741. .data = &(struct clk_regmap_mux_data){
  742. .offset = HHI_MPEG_CLK_CNTL,
  743. .mask = 0x7,
  744. .shift = 12,
  745. .table = mux_table_clk81,
  746. },
  747. .hw.init = &(struct clk_init_data){
  748. .name = "mpeg_clk_sel",
  749. .ops = &clk_regmap_mux_ro_ops,
  750. .parent_names = clk81_parent_names,
  751. .num_parents = ARRAY_SIZE(clk81_parent_names),
  752. },
  753. };
  754. static struct clk_regmap axg_mpeg_clk_div = {
  755. .data = &(struct clk_regmap_div_data){
  756. .offset = HHI_MPEG_CLK_CNTL,
  757. .shift = 0,
  758. .width = 7,
  759. },
  760. .hw.init = &(struct clk_init_data){
  761. .name = "mpeg_clk_div",
  762. .ops = &clk_regmap_divider_ops,
  763. .parent_names = (const char *[]){ "mpeg_clk_sel" },
  764. .num_parents = 1,
  765. .flags = CLK_SET_RATE_PARENT,
  766. },
  767. };
  768. static struct clk_regmap axg_clk81 = {
  769. .data = &(struct clk_regmap_gate_data){
  770. .offset = HHI_MPEG_CLK_CNTL,
  771. .bit_idx = 7,
  772. },
  773. .hw.init = &(struct clk_init_data){
  774. .name = "clk81",
  775. .ops = &clk_regmap_gate_ops,
  776. .parent_names = (const char *[]){ "mpeg_clk_div" },
  777. .num_parents = 1,
  778. .flags = (CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
  779. },
  780. };
  781. static const char * const axg_sd_emmc_clk0_parent_names[] = {
  782. "xtal", "fclk_div2", "fclk_div3", "fclk_div5", "fclk_div7",
  783. /*
  784. * Following these parent clocks, we should also have had mpll2, mpll3
  785. * and gp0_pll but these clocks are too precious to be used here. All
  786. * the necessary rates for MMC and NAND operation can be acheived using
  787. * xtal or fclk_div clocks
  788. */
  789. };
  790. /* SDcard clock */
  791. static struct clk_regmap axg_sd_emmc_b_clk0_sel = {
  792. .data = &(struct clk_regmap_mux_data){
  793. .offset = HHI_SD_EMMC_CLK_CNTL,
  794. .mask = 0x7,
  795. .shift = 25,
  796. },
  797. .hw.init = &(struct clk_init_data) {
  798. .name = "sd_emmc_b_clk0_sel",
  799. .ops = &clk_regmap_mux_ops,
  800. .parent_names = axg_sd_emmc_clk0_parent_names,
  801. .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names),
  802. .flags = CLK_SET_RATE_PARENT,
  803. },
  804. };
  805. static struct clk_regmap axg_sd_emmc_b_clk0_div = {
  806. .data = &(struct clk_regmap_div_data){
  807. .offset = HHI_SD_EMMC_CLK_CNTL,
  808. .shift = 16,
  809. .width = 7,
  810. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  811. },
  812. .hw.init = &(struct clk_init_data) {
  813. .name = "sd_emmc_b_clk0_div",
  814. .ops = &clk_regmap_divider_ops,
  815. .parent_names = (const char *[]){ "sd_emmc_b_clk0_sel" },
  816. .num_parents = 1,
  817. .flags = CLK_SET_RATE_PARENT,
  818. },
  819. };
  820. static struct clk_regmap axg_sd_emmc_b_clk0 = {
  821. .data = &(struct clk_regmap_gate_data){
  822. .offset = HHI_SD_EMMC_CLK_CNTL,
  823. .bit_idx = 23,
  824. },
  825. .hw.init = &(struct clk_init_data){
  826. .name = "sd_emmc_b_clk0",
  827. .ops = &clk_regmap_gate_ops,
  828. .parent_names = (const char *[]){ "sd_emmc_b_clk0_div" },
  829. .num_parents = 1,
  830. .flags = CLK_SET_RATE_PARENT,
  831. },
  832. };
  833. /* EMMC/NAND clock */
  834. static struct clk_regmap axg_sd_emmc_c_clk0_sel = {
  835. .data = &(struct clk_regmap_mux_data){
  836. .offset = HHI_NAND_CLK_CNTL,
  837. .mask = 0x7,
  838. .shift = 9,
  839. },
  840. .hw.init = &(struct clk_init_data) {
  841. .name = "sd_emmc_c_clk0_sel",
  842. .ops = &clk_regmap_mux_ops,
  843. .parent_names = axg_sd_emmc_clk0_parent_names,
  844. .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names),
  845. .flags = CLK_SET_RATE_PARENT,
  846. },
  847. };
  848. static struct clk_regmap axg_sd_emmc_c_clk0_div = {
  849. .data = &(struct clk_regmap_div_data){
  850. .offset = HHI_NAND_CLK_CNTL,
  851. .shift = 0,
  852. .width = 7,
  853. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  854. },
  855. .hw.init = &(struct clk_init_data) {
  856. .name = "sd_emmc_c_clk0_div",
  857. .ops = &clk_regmap_divider_ops,
  858. .parent_names = (const char *[]){ "sd_emmc_c_clk0_sel" },
  859. .num_parents = 1,
  860. .flags = CLK_SET_RATE_PARENT,
  861. },
  862. };
  863. static struct clk_regmap axg_sd_emmc_c_clk0 = {
  864. .data = &(struct clk_regmap_gate_data){
  865. .offset = HHI_NAND_CLK_CNTL,
  866. .bit_idx = 7,
  867. },
  868. .hw.init = &(struct clk_init_data){
  869. .name = "sd_emmc_c_clk0",
  870. .ops = &clk_regmap_gate_ops,
  871. .parent_names = (const char *[]){ "sd_emmc_c_clk0_div" },
  872. .num_parents = 1,
  873. .flags = CLK_SET_RATE_PARENT,
  874. },
  875. };
  876. static u32 mux_table_gen_clk[] = { 0, 4, 5, 6, 7, 8,
  877. 9, 10, 11, 13, 14, };
  878. static const char * const gen_clk_parent_names[] = {
  879. "xtal", "hifi_pll", "mpll0", "mpll1", "mpll2", "mpll3",
  880. "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7", "gp0_pll",
  881. };
  882. static struct clk_regmap axg_gen_clk_sel = {
  883. .data = &(struct clk_regmap_mux_data){
  884. .offset = HHI_GEN_CLK_CNTL,
  885. .mask = 0xf,
  886. .shift = 12,
  887. .table = mux_table_gen_clk,
  888. },
  889. .hw.init = &(struct clk_init_data){
  890. .name = "gen_clk_sel",
  891. .ops = &clk_regmap_mux_ops,
  892. /*
  893. * bits 15:12 selects from 14 possible parents:
  894. * xtal, [rtc_oscin_i], [sys_cpu_div16], [ddr_dpll_pt],
  895. * hifi_pll, mpll0, mpll1, mpll2, mpll3, fdiv4,
  896. * fdiv3, fdiv5, [cts_msr_clk], fdiv7, gp0_pll
  897. */
  898. .parent_names = gen_clk_parent_names,
  899. .num_parents = ARRAY_SIZE(gen_clk_parent_names),
  900. },
  901. };
  902. static struct clk_regmap axg_gen_clk_div = {
  903. .data = &(struct clk_regmap_div_data){
  904. .offset = HHI_GEN_CLK_CNTL,
  905. .shift = 0,
  906. .width = 11,
  907. },
  908. .hw.init = &(struct clk_init_data){
  909. .name = "gen_clk_div",
  910. .ops = &clk_regmap_divider_ops,
  911. .parent_names = (const char *[]){ "gen_clk_sel" },
  912. .num_parents = 1,
  913. .flags = CLK_SET_RATE_PARENT,
  914. },
  915. };
  916. static struct clk_regmap axg_gen_clk = {
  917. .data = &(struct clk_regmap_gate_data){
  918. .offset = HHI_GEN_CLK_CNTL,
  919. .bit_idx = 7,
  920. },
  921. .hw.init = &(struct clk_init_data){
  922. .name = "gen_clk",
  923. .ops = &clk_regmap_gate_ops,
  924. .parent_names = (const char *[]){ "gen_clk_div" },
  925. .num_parents = 1,
  926. .flags = CLK_SET_RATE_PARENT,
  927. },
  928. };
  929. /* Everything Else (EE) domain gates */
  930. static MESON_GATE(axg_ddr, HHI_GCLK_MPEG0, 0);
  931. static MESON_GATE(axg_audio_locker, HHI_GCLK_MPEG0, 2);
  932. static MESON_GATE(axg_mipi_dsi_host, HHI_GCLK_MPEG0, 3);
  933. static MESON_GATE(axg_isa, HHI_GCLK_MPEG0, 5);
  934. static MESON_GATE(axg_pl301, HHI_GCLK_MPEG0, 6);
  935. static MESON_GATE(axg_periphs, HHI_GCLK_MPEG0, 7);
  936. static MESON_GATE(axg_spicc_0, HHI_GCLK_MPEG0, 8);
  937. static MESON_GATE(axg_i2c, HHI_GCLK_MPEG0, 9);
  938. static MESON_GATE(axg_rng0, HHI_GCLK_MPEG0, 12);
  939. static MESON_GATE(axg_uart0, HHI_GCLK_MPEG0, 13);
  940. static MESON_GATE(axg_mipi_dsi_phy, HHI_GCLK_MPEG0, 14);
  941. static MESON_GATE(axg_spicc_1, HHI_GCLK_MPEG0, 15);
  942. static MESON_GATE(axg_pcie_a, HHI_GCLK_MPEG0, 16);
  943. static MESON_GATE(axg_pcie_b, HHI_GCLK_MPEG0, 17);
  944. static MESON_GATE(axg_hiu_reg, HHI_GCLK_MPEG0, 19);
  945. static MESON_GATE(axg_assist_misc, HHI_GCLK_MPEG0, 23);
  946. static MESON_GATE(axg_emmc_b, HHI_GCLK_MPEG0, 25);
  947. static MESON_GATE(axg_emmc_c, HHI_GCLK_MPEG0, 26);
  948. static MESON_GATE(axg_dma, HHI_GCLK_MPEG0, 27);
  949. static MESON_GATE(axg_spi, HHI_GCLK_MPEG0, 30);
  950. static MESON_GATE(axg_audio, HHI_GCLK_MPEG1, 0);
  951. static MESON_GATE(axg_eth_core, HHI_GCLK_MPEG1, 3);
  952. static MESON_GATE(axg_uart1, HHI_GCLK_MPEG1, 16);
  953. static MESON_GATE(axg_g2d, HHI_GCLK_MPEG1, 20);
  954. static MESON_GATE(axg_usb0, HHI_GCLK_MPEG1, 21);
  955. static MESON_GATE(axg_usb1, HHI_GCLK_MPEG1, 22);
  956. static MESON_GATE(axg_reset, HHI_GCLK_MPEG1, 23);
  957. static MESON_GATE(axg_usb_general, HHI_GCLK_MPEG1, 26);
  958. static MESON_GATE(axg_ahb_arb0, HHI_GCLK_MPEG1, 29);
  959. static MESON_GATE(axg_efuse, HHI_GCLK_MPEG1, 30);
  960. static MESON_GATE(axg_boot_rom, HHI_GCLK_MPEG1, 31);
  961. static MESON_GATE(axg_ahb_data_bus, HHI_GCLK_MPEG2, 1);
  962. static MESON_GATE(axg_ahb_ctrl_bus, HHI_GCLK_MPEG2, 2);
  963. static MESON_GATE(axg_usb1_to_ddr, HHI_GCLK_MPEG2, 8);
  964. static MESON_GATE(axg_usb0_to_ddr, HHI_GCLK_MPEG2, 9);
  965. static MESON_GATE(axg_mmc_pclk, HHI_GCLK_MPEG2, 11);
  966. static MESON_GATE(axg_vpu_intr, HHI_GCLK_MPEG2, 25);
  967. static MESON_GATE(axg_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26);
  968. static MESON_GATE(axg_gic, HHI_GCLK_MPEG2, 30);
  969. static MESON_GATE(axg_mipi_enable, HHI_MIPI_CNTL0, 29);
  970. /* Always On (AO) domain gates */
  971. static MESON_GATE(axg_ao_media_cpu, HHI_GCLK_AO, 0);
  972. static MESON_GATE(axg_ao_ahb_sram, HHI_GCLK_AO, 1);
  973. static MESON_GATE(axg_ao_ahb_bus, HHI_GCLK_AO, 2);
  974. static MESON_GATE(axg_ao_iface, HHI_GCLK_AO, 3);
  975. static MESON_GATE(axg_ao_i2c, HHI_GCLK_AO, 4);
  976. /* Array of all clocks provided by this provider */
  977. static struct clk_hw_onecell_data axg_hw_onecell_data = {
  978. .hws = {
  979. [CLKID_SYS_PLL] = &axg_sys_pll.hw,
  980. [CLKID_FIXED_PLL] = &axg_fixed_pll.hw,
  981. [CLKID_FCLK_DIV2] = &axg_fclk_div2.hw,
  982. [CLKID_FCLK_DIV3] = &axg_fclk_div3.hw,
  983. [CLKID_FCLK_DIV4] = &axg_fclk_div4.hw,
  984. [CLKID_FCLK_DIV5] = &axg_fclk_div5.hw,
  985. [CLKID_FCLK_DIV7] = &axg_fclk_div7.hw,
  986. [CLKID_GP0_PLL] = &axg_gp0_pll.hw,
  987. [CLKID_MPEG_SEL] = &axg_mpeg_clk_sel.hw,
  988. [CLKID_MPEG_DIV] = &axg_mpeg_clk_div.hw,
  989. [CLKID_CLK81] = &axg_clk81.hw,
  990. [CLKID_MPLL0] = &axg_mpll0.hw,
  991. [CLKID_MPLL1] = &axg_mpll1.hw,
  992. [CLKID_MPLL2] = &axg_mpll2.hw,
  993. [CLKID_MPLL3] = &axg_mpll3.hw,
  994. [CLKID_DDR] = &axg_ddr.hw,
  995. [CLKID_AUDIO_LOCKER] = &axg_audio_locker.hw,
  996. [CLKID_MIPI_DSI_HOST] = &axg_mipi_dsi_host.hw,
  997. [CLKID_ISA] = &axg_isa.hw,
  998. [CLKID_PL301] = &axg_pl301.hw,
  999. [CLKID_PERIPHS] = &axg_periphs.hw,
  1000. [CLKID_SPICC0] = &axg_spicc_0.hw,
  1001. [CLKID_I2C] = &axg_i2c.hw,
  1002. [CLKID_RNG0] = &axg_rng0.hw,
  1003. [CLKID_UART0] = &axg_uart0.hw,
  1004. [CLKID_MIPI_DSI_PHY] = &axg_mipi_dsi_phy.hw,
  1005. [CLKID_SPICC1] = &axg_spicc_1.hw,
  1006. [CLKID_PCIE_A] = &axg_pcie_a.hw,
  1007. [CLKID_PCIE_B] = &axg_pcie_b.hw,
  1008. [CLKID_HIU_IFACE] = &axg_hiu_reg.hw,
  1009. [CLKID_ASSIST_MISC] = &axg_assist_misc.hw,
  1010. [CLKID_SD_EMMC_B] = &axg_emmc_b.hw,
  1011. [CLKID_SD_EMMC_C] = &axg_emmc_c.hw,
  1012. [CLKID_DMA] = &axg_dma.hw,
  1013. [CLKID_SPI] = &axg_spi.hw,
  1014. [CLKID_AUDIO] = &axg_audio.hw,
  1015. [CLKID_ETH] = &axg_eth_core.hw,
  1016. [CLKID_UART1] = &axg_uart1.hw,
  1017. [CLKID_G2D] = &axg_g2d.hw,
  1018. [CLKID_USB0] = &axg_usb0.hw,
  1019. [CLKID_USB1] = &axg_usb1.hw,
  1020. [CLKID_RESET] = &axg_reset.hw,
  1021. [CLKID_USB] = &axg_usb_general.hw,
  1022. [CLKID_AHB_ARB0] = &axg_ahb_arb0.hw,
  1023. [CLKID_EFUSE] = &axg_efuse.hw,
  1024. [CLKID_BOOT_ROM] = &axg_boot_rom.hw,
  1025. [CLKID_AHB_DATA_BUS] = &axg_ahb_data_bus.hw,
  1026. [CLKID_AHB_CTRL_BUS] = &axg_ahb_ctrl_bus.hw,
  1027. [CLKID_USB1_DDR_BRIDGE] = &axg_usb1_to_ddr.hw,
  1028. [CLKID_USB0_DDR_BRIDGE] = &axg_usb0_to_ddr.hw,
  1029. [CLKID_MMC_PCLK] = &axg_mmc_pclk.hw,
  1030. [CLKID_VPU_INTR] = &axg_vpu_intr.hw,
  1031. [CLKID_SEC_AHB_AHB3_BRIDGE] = &axg_sec_ahb_ahb3_bridge.hw,
  1032. [CLKID_GIC] = &axg_gic.hw,
  1033. [CLKID_AO_MEDIA_CPU] = &axg_ao_media_cpu.hw,
  1034. [CLKID_AO_AHB_SRAM] = &axg_ao_ahb_sram.hw,
  1035. [CLKID_AO_AHB_BUS] = &axg_ao_ahb_bus.hw,
  1036. [CLKID_AO_IFACE] = &axg_ao_iface.hw,
  1037. [CLKID_AO_I2C] = &axg_ao_i2c.hw,
  1038. [CLKID_SD_EMMC_B_CLK0_SEL] = &axg_sd_emmc_b_clk0_sel.hw,
  1039. [CLKID_SD_EMMC_B_CLK0_DIV] = &axg_sd_emmc_b_clk0_div.hw,
  1040. [CLKID_SD_EMMC_B_CLK0] = &axg_sd_emmc_b_clk0.hw,
  1041. [CLKID_SD_EMMC_C_CLK0_SEL] = &axg_sd_emmc_c_clk0_sel.hw,
  1042. [CLKID_SD_EMMC_C_CLK0_DIV] = &axg_sd_emmc_c_clk0_div.hw,
  1043. [CLKID_SD_EMMC_C_CLK0] = &axg_sd_emmc_c_clk0.hw,
  1044. [CLKID_MPLL0_DIV] = &axg_mpll0_div.hw,
  1045. [CLKID_MPLL1_DIV] = &axg_mpll1_div.hw,
  1046. [CLKID_MPLL2_DIV] = &axg_mpll2_div.hw,
  1047. [CLKID_MPLL3_DIV] = &axg_mpll3_div.hw,
  1048. [CLKID_HIFI_PLL] = &axg_hifi_pll.hw,
  1049. [CLKID_MPLL_PREDIV] = &axg_mpll_prediv.hw,
  1050. [CLKID_FCLK_DIV2_DIV] = &axg_fclk_div2_div.hw,
  1051. [CLKID_FCLK_DIV3_DIV] = &axg_fclk_div3_div.hw,
  1052. [CLKID_FCLK_DIV4_DIV] = &axg_fclk_div4_div.hw,
  1053. [CLKID_FCLK_DIV5_DIV] = &axg_fclk_div5_div.hw,
  1054. [CLKID_FCLK_DIV7_DIV] = &axg_fclk_div7_div.hw,
  1055. [CLKID_PCIE_PLL] = &axg_pcie_pll.hw,
  1056. [CLKID_PCIE_MUX] = &axg_pcie_mux.hw,
  1057. [CLKID_PCIE_REF] = &axg_pcie_ref.hw,
  1058. [CLKID_PCIE_CML_EN0] = &axg_pcie_cml_en0.hw,
  1059. [CLKID_PCIE_CML_EN1] = &axg_pcie_cml_en1.hw,
  1060. [CLKID_MIPI_ENABLE] = &axg_mipi_enable.hw,
  1061. [CLKID_GEN_CLK_SEL] = &axg_gen_clk_sel.hw,
  1062. [CLKID_GEN_CLK_DIV] = &axg_gen_clk_div.hw,
  1063. [CLKID_GEN_CLK] = &axg_gen_clk.hw,
  1064. [NR_CLKS] = NULL,
  1065. },
  1066. .num = NR_CLKS,
  1067. };
  1068. /* Convenience table to populate regmap in .probe */
  1069. static struct clk_regmap *const axg_clk_regmaps[] = {
  1070. &axg_clk81,
  1071. &axg_ddr,
  1072. &axg_audio_locker,
  1073. &axg_mipi_dsi_host,
  1074. &axg_isa,
  1075. &axg_pl301,
  1076. &axg_periphs,
  1077. &axg_spicc_0,
  1078. &axg_i2c,
  1079. &axg_rng0,
  1080. &axg_uart0,
  1081. &axg_mipi_dsi_phy,
  1082. &axg_spicc_1,
  1083. &axg_pcie_a,
  1084. &axg_pcie_b,
  1085. &axg_hiu_reg,
  1086. &axg_assist_misc,
  1087. &axg_emmc_b,
  1088. &axg_emmc_c,
  1089. &axg_dma,
  1090. &axg_spi,
  1091. &axg_audio,
  1092. &axg_eth_core,
  1093. &axg_uart1,
  1094. &axg_g2d,
  1095. &axg_usb0,
  1096. &axg_usb1,
  1097. &axg_reset,
  1098. &axg_usb_general,
  1099. &axg_ahb_arb0,
  1100. &axg_efuse,
  1101. &axg_boot_rom,
  1102. &axg_ahb_data_bus,
  1103. &axg_ahb_ctrl_bus,
  1104. &axg_usb1_to_ddr,
  1105. &axg_usb0_to_ddr,
  1106. &axg_mmc_pclk,
  1107. &axg_vpu_intr,
  1108. &axg_sec_ahb_ahb3_bridge,
  1109. &axg_gic,
  1110. &axg_ao_media_cpu,
  1111. &axg_ao_ahb_sram,
  1112. &axg_ao_ahb_bus,
  1113. &axg_ao_iface,
  1114. &axg_ao_i2c,
  1115. &axg_sd_emmc_b_clk0,
  1116. &axg_sd_emmc_c_clk0,
  1117. &axg_mpeg_clk_div,
  1118. &axg_sd_emmc_b_clk0_div,
  1119. &axg_sd_emmc_c_clk0_div,
  1120. &axg_mpeg_clk_sel,
  1121. &axg_sd_emmc_b_clk0_sel,
  1122. &axg_sd_emmc_c_clk0_sel,
  1123. &axg_mpll0,
  1124. &axg_mpll1,
  1125. &axg_mpll2,
  1126. &axg_mpll3,
  1127. &axg_mpll0_div,
  1128. &axg_mpll1_div,
  1129. &axg_mpll2_div,
  1130. &axg_mpll3_div,
  1131. &axg_fixed_pll,
  1132. &axg_sys_pll,
  1133. &axg_gp0_pll,
  1134. &axg_hifi_pll,
  1135. &axg_mpll_prediv,
  1136. &axg_fclk_div2,
  1137. &axg_fclk_div3,
  1138. &axg_fclk_div4,
  1139. &axg_fclk_div5,
  1140. &axg_fclk_div7,
  1141. &axg_pcie_pll,
  1142. &axg_pcie_mux,
  1143. &axg_pcie_ref,
  1144. &axg_pcie_cml_en0,
  1145. &axg_pcie_cml_en1,
  1146. &axg_mipi_enable,
  1147. &axg_gen_clk_sel,
  1148. &axg_gen_clk_div,
  1149. &axg_gen_clk,
  1150. };
  1151. static const struct of_device_id clkc_match_table[] = {
  1152. { .compatible = "amlogic,axg-clkc" },
  1153. {}
  1154. };
  1155. static int axg_clkc_probe(struct platform_device *pdev)
  1156. {
  1157. struct device *dev = &pdev->dev;
  1158. struct regmap *map;
  1159. int ret, i;
  1160. /* Get the hhi system controller node if available */
  1161. map = syscon_node_to_regmap(of_get_parent(dev->of_node));
  1162. if (IS_ERR(map)) {
  1163. dev_err(dev, "failed to get HHI regmap\n");
  1164. return PTR_ERR(map);
  1165. }
  1166. /* Populate regmap for the regmap backed clocks */
  1167. for (i = 0; i < ARRAY_SIZE(axg_clk_regmaps); i++)
  1168. axg_clk_regmaps[i]->map = map;
  1169. for (i = 0; i < axg_hw_onecell_data.num; i++) {
  1170. /* array might be sparse */
  1171. if (!axg_hw_onecell_data.hws[i])
  1172. continue;
  1173. ret = devm_clk_hw_register(dev, axg_hw_onecell_data.hws[i]);
  1174. if (ret) {
  1175. dev_err(dev, "Clock registration failed\n");
  1176. return ret;
  1177. }
  1178. }
  1179. return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
  1180. &axg_hw_onecell_data);
  1181. }
  1182. static struct platform_driver axg_driver = {
  1183. .probe = axg_clkc_probe,
  1184. .driver = {
  1185. .name = "axg-clkc",
  1186. .of_match_table = clkc_match_table,
  1187. },
  1188. };
  1189. builtin_platform_driver(axg_driver);