axg.c 31 KB

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