axg.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  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. .flags = CLK_IS_CRITICAL,
  313. },
  314. };
  315. static struct clk_fixed_factor axg_fclk_div3_div = {
  316. .mult = 1,
  317. .div = 3,
  318. .hw.init = &(struct clk_init_data){
  319. .name = "fclk_div3_div",
  320. .ops = &clk_fixed_factor_ops,
  321. .parent_names = (const char *[]){ "fixed_pll" },
  322. .num_parents = 1,
  323. },
  324. };
  325. static struct clk_regmap axg_fclk_div3 = {
  326. .data = &(struct clk_regmap_gate_data){
  327. .offset = HHI_MPLL_CNTL6,
  328. .bit_idx = 28,
  329. },
  330. .hw.init = &(struct clk_init_data){
  331. .name = "fclk_div3",
  332. .ops = &clk_regmap_gate_ops,
  333. .parent_names = (const char *[]){ "fclk_div3_div" },
  334. .num_parents = 1,
  335. /*
  336. * FIXME:
  337. * This clock, as fdiv2, is used by the SCPI FW and is required
  338. * by the platform to operate correctly.
  339. * Until the following condition are met, we need this clock to
  340. * be marked as critical:
  341. * a) The SCPI generic driver claims and enable all the clocks
  342. * it needs
  343. * b) CCF has a clock hand-off mechanism to make the sure the
  344. * clock stays on until the proper driver comes along
  345. */
  346. .flags = CLK_IS_CRITICAL,
  347. },
  348. };
  349. static struct clk_fixed_factor axg_fclk_div4_div = {
  350. .mult = 1,
  351. .div = 4,
  352. .hw.init = &(struct clk_init_data){
  353. .name = "fclk_div4_div",
  354. .ops = &clk_fixed_factor_ops,
  355. .parent_names = (const char *[]){ "fixed_pll" },
  356. .num_parents = 1,
  357. },
  358. };
  359. static struct clk_regmap axg_fclk_div4 = {
  360. .data = &(struct clk_regmap_gate_data){
  361. .offset = HHI_MPLL_CNTL6,
  362. .bit_idx = 29,
  363. },
  364. .hw.init = &(struct clk_init_data){
  365. .name = "fclk_div4",
  366. .ops = &clk_regmap_gate_ops,
  367. .parent_names = (const char *[]){ "fclk_div4_div" },
  368. .num_parents = 1,
  369. },
  370. };
  371. static struct clk_fixed_factor axg_fclk_div5_div = {
  372. .mult = 1,
  373. .div = 5,
  374. .hw.init = &(struct clk_init_data){
  375. .name = "fclk_div5_div",
  376. .ops = &clk_fixed_factor_ops,
  377. .parent_names = (const char *[]){ "fixed_pll" },
  378. .num_parents = 1,
  379. },
  380. };
  381. static struct clk_regmap axg_fclk_div5 = {
  382. .data = &(struct clk_regmap_gate_data){
  383. .offset = HHI_MPLL_CNTL6,
  384. .bit_idx = 30,
  385. },
  386. .hw.init = &(struct clk_init_data){
  387. .name = "fclk_div5",
  388. .ops = &clk_regmap_gate_ops,
  389. .parent_names = (const char *[]){ "fclk_div5_div" },
  390. .num_parents = 1,
  391. },
  392. };
  393. static struct clk_fixed_factor axg_fclk_div7_div = {
  394. .mult = 1,
  395. .div = 7,
  396. .hw.init = &(struct clk_init_data){
  397. .name = "fclk_div7_div",
  398. .ops = &clk_fixed_factor_ops,
  399. .parent_names = (const char *[]){ "fixed_pll" },
  400. .num_parents = 1,
  401. },
  402. };
  403. static struct clk_regmap axg_fclk_div7 = {
  404. .data = &(struct clk_regmap_gate_data){
  405. .offset = HHI_MPLL_CNTL6,
  406. .bit_idx = 31,
  407. },
  408. .hw.init = &(struct clk_init_data){
  409. .name = "fclk_div7",
  410. .ops = &clk_regmap_gate_ops,
  411. .parent_names = (const char *[]){ "fclk_div7_div" },
  412. .num_parents = 1,
  413. },
  414. };
  415. static struct clk_regmap axg_mpll_prediv = {
  416. .data = &(struct clk_regmap_div_data){
  417. .offset = HHI_MPLL_CNTL5,
  418. .shift = 12,
  419. .width = 1,
  420. },
  421. .hw.init = &(struct clk_init_data){
  422. .name = "mpll_prediv",
  423. .ops = &clk_regmap_divider_ro_ops,
  424. .parent_names = (const char *[]){ "fixed_pll" },
  425. .num_parents = 1,
  426. },
  427. };
  428. static struct clk_regmap axg_mpll0_div = {
  429. .data = &(struct meson_clk_mpll_data){
  430. .sdm = {
  431. .reg_off = HHI_MPLL_CNTL7,
  432. .shift = 0,
  433. .width = 14,
  434. },
  435. .sdm_en = {
  436. .reg_off = HHI_MPLL_CNTL7,
  437. .shift = 15,
  438. .width = 1,
  439. },
  440. .n2 = {
  441. .reg_off = HHI_MPLL_CNTL7,
  442. .shift = 16,
  443. .width = 9,
  444. },
  445. .ssen = {
  446. .reg_off = HHI_MPLL_CNTL,
  447. .shift = 25,
  448. .width = 1,
  449. },
  450. .misc = {
  451. .reg_off = HHI_PLL_TOP_MISC,
  452. .shift = 0,
  453. .width = 1,
  454. },
  455. .lock = &meson_clk_lock,
  456. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  457. },
  458. .hw.init = &(struct clk_init_data){
  459. .name = "mpll0_div",
  460. .ops = &meson_clk_mpll_ops,
  461. .parent_names = (const char *[]){ "mpll_prediv" },
  462. .num_parents = 1,
  463. },
  464. };
  465. static struct clk_regmap axg_mpll0 = {
  466. .data = &(struct clk_regmap_gate_data){
  467. .offset = HHI_MPLL_CNTL7,
  468. .bit_idx = 14,
  469. },
  470. .hw.init = &(struct clk_init_data){
  471. .name = "mpll0",
  472. .ops = &clk_regmap_gate_ops,
  473. .parent_names = (const char *[]){ "mpll0_div" },
  474. .num_parents = 1,
  475. .flags = CLK_SET_RATE_PARENT,
  476. },
  477. };
  478. static struct clk_regmap axg_mpll1_div = {
  479. .data = &(struct meson_clk_mpll_data){
  480. .sdm = {
  481. .reg_off = HHI_MPLL_CNTL8,
  482. .shift = 0,
  483. .width = 14,
  484. },
  485. .sdm_en = {
  486. .reg_off = HHI_MPLL_CNTL8,
  487. .shift = 15,
  488. .width = 1,
  489. },
  490. .n2 = {
  491. .reg_off = HHI_MPLL_CNTL8,
  492. .shift = 16,
  493. .width = 9,
  494. },
  495. .misc = {
  496. .reg_off = HHI_PLL_TOP_MISC,
  497. .shift = 1,
  498. .width = 1,
  499. },
  500. .lock = &meson_clk_lock,
  501. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  502. },
  503. .hw.init = &(struct clk_init_data){
  504. .name = "mpll1_div",
  505. .ops = &meson_clk_mpll_ops,
  506. .parent_names = (const char *[]){ "mpll_prediv" },
  507. .num_parents = 1,
  508. },
  509. };
  510. static struct clk_regmap axg_mpll1 = {
  511. .data = &(struct clk_regmap_gate_data){
  512. .offset = HHI_MPLL_CNTL8,
  513. .bit_idx = 14,
  514. },
  515. .hw.init = &(struct clk_init_data){
  516. .name = "mpll1",
  517. .ops = &clk_regmap_gate_ops,
  518. .parent_names = (const char *[]){ "mpll1_div" },
  519. .num_parents = 1,
  520. .flags = CLK_SET_RATE_PARENT,
  521. },
  522. };
  523. static struct clk_regmap axg_mpll2_div = {
  524. .data = &(struct meson_clk_mpll_data){
  525. .sdm = {
  526. .reg_off = HHI_MPLL_CNTL9,
  527. .shift = 0,
  528. .width = 14,
  529. },
  530. .sdm_en = {
  531. .reg_off = HHI_MPLL_CNTL9,
  532. .shift = 15,
  533. .width = 1,
  534. },
  535. .n2 = {
  536. .reg_off = HHI_MPLL_CNTL9,
  537. .shift = 16,
  538. .width = 9,
  539. },
  540. .misc = {
  541. .reg_off = HHI_PLL_TOP_MISC,
  542. .shift = 2,
  543. .width = 1,
  544. },
  545. .lock = &meson_clk_lock,
  546. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  547. },
  548. .hw.init = &(struct clk_init_data){
  549. .name = "mpll2_div",
  550. .ops = &meson_clk_mpll_ops,
  551. .parent_names = (const char *[]){ "mpll_prediv" },
  552. .num_parents = 1,
  553. },
  554. };
  555. static struct clk_regmap axg_mpll2 = {
  556. .data = &(struct clk_regmap_gate_data){
  557. .offset = HHI_MPLL_CNTL9,
  558. .bit_idx = 14,
  559. },
  560. .hw.init = &(struct clk_init_data){
  561. .name = "mpll2",
  562. .ops = &clk_regmap_gate_ops,
  563. .parent_names = (const char *[]){ "mpll2_div" },
  564. .num_parents = 1,
  565. .flags = CLK_SET_RATE_PARENT,
  566. },
  567. };
  568. static struct clk_regmap axg_mpll3_div = {
  569. .data = &(struct meson_clk_mpll_data){
  570. .sdm = {
  571. .reg_off = HHI_MPLL3_CNTL0,
  572. .shift = 12,
  573. .width = 14,
  574. },
  575. .sdm_en = {
  576. .reg_off = HHI_MPLL3_CNTL0,
  577. .shift = 11,
  578. .width = 1,
  579. },
  580. .n2 = {
  581. .reg_off = HHI_MPLL3_CNTL0,
  582. .shift = 2,
  583. .width = 9,
  584. },
  585. .misc = {
  586. .reg_off = HHI_PLL_TOP_MISC,
  587. .shift = 3,
  588. .width = 1,
  589. },
  590. .lock = &meson_clk_lock,
  591. .flags = CLK_MESON_MPLL_ROUND_CLOSEST,
  592. },
  593. .hw.init = &(struct clk_init_data){
  594. .name = "mpll3_div",
  595. .ops = &meson_clk_mpll_ops,
  596. .parent_names = (const char *[]){ "mpll_prediv" },
  597. .num_parents = 1,
  598. },
  599. };
  600. static struct clk_regmap axg_mpll3 = {
  601. .data = &(struct clk_regmap_gate_data){
  602. .offset = HHI_MPLL3_CNTL0,
  603. .bit_idx = 0,
  604. },
  605. .hw.init = &(struct clk_init_data){
  606. .name = "mpll3",
  607. .ops = &clk_regmap_gate_ops,
  608. .parent_names = (const char *[]){ "mpll3_div" },
  609. .num_parents = 1,
  610. .flags = CLK_SET_RATE_PARENT,
  611. },
  612. };
  613. static const struct pll_params_table axg_pcie_pll_params_table[] = {
  614. {
  615. .m = 200,
  616. .n = 3,
  617. },
  618. { /* sentinel */ },
  619. };
  620. static const struct reg_sequence axg_pcie_init_regs[] = {
  621. { .reg = HHI_PCIE_PLL_CNTL1, .def = 0x0084a2aa },
  622. { .reg = HHI_PCIE_PLL_CNTL2, .def = 0xb75020be },
  623. { .reg = HHI_PCIE_PLL_CNTL3, .def = 0x0a47488e },
  624. { .reg = HHI_PCIE_PLL_CNTL4, .def = 0xc000004d },
  625. { .reg = HHI_PCIE_PLL_CNTL5, .def = 0x00078000 },
  626. { .reg = HHI_PCIE_PLL_CNTL6, .def = 0x002323c6 },
  627. { .reg = HHI_PCIE_PLL_CNTL, .def = 0x400106c8 },
  628. };
  629. static struct clk_regmap axg_pcie_pll_dco = {
  630. .data = &(struct meson_clk_pll_data){
  631. .en = {
  632. .reg_off = HHI_PCIE_PLL_CNTL,
  633. .shift = 30,
  634. .width = 1,
  635. },
  636. .m = {
  637. .reg_off = HHI_PCIE_PLL_CNTL,
  638. .shift = 0,
  639. .width = 9,
  640. },
  641. .n = {
  642. .reg_off = HHI_PCIE_PLL_CNTL,
  643. .shift = 9,
  644. .width = 5,
  645. },
  646. .frac = {
  647. .reg_off = HHI_PCIE_PLL_CNTL1,
  648. .shift = 0,
  649. .width = 12,
  650. },
  651. .l = {
  652. .reg_off = HHI_PCIE_PLL_CNTL,
  653. .shift = 31,
  654. .width = 1,
  655. },
  656. .rst = {
  657. .reg_off = HHI_PCIE_PLL_CNTL,
  658. .shift = 29,
  659. .width = 1,
  660. },
  661. .table = axg_pcie_pll_params_table,
  662. .init_regs = axg_pcie_init_regs,
  663. .init_count = ARRAY_SIZE(axg_pcie_init_regs),
  664. },
  665. .hw.init = &(struct clk_init_data){
  666. .name = "pcie_pll_dco",
  667. .ops = &meson_clk_pll_ops,
  668. .parent_names = (const char *[]){ "xtal" },
  669. .num_parents = 1,
  670. },
  671. };
  672. static struct clk_regmap axg_pcie_pll_od = {
  673. .data = &(struct clk_regmap_div_data){
  674. .offset = HHI_PCIE_PLL_CNTL,
  675. .shift = 16,
  676. .width = 2,
  677. .flags = CLK_DIVIDER_POWER_OF_TWO,
  678. },
  679. .hw.init = &(struct clk_init_data){
  680. .name = "pcie_pll_od",
  681. .ops = &clk_regmap_divider_ops,
  682. .parent_names = (const char *[]){ "pcie_pll_dco" },
  683. .num_parents = 1,
  684. .flags = CLK_SET_RATE_PARENT,
  685. },
  686. };
  687. static struct clk_regmap axg_pcie_pll = {
  688. .data = &(struct clk_regmap_div_data){
  689. .offset = HHI_PCIE_PLL_CNTL6,
  690. .shift = 6,
  691. .width = 2,
  692. .flags = CLK_DIVIDER_POWER_OF_TWO,
  693. },
  694. .hw.init = &(struct clk_init_data){
  695. .name = "pcie_pll",
  696. .ops = &clk_regmap_divider_ops,
  697. .parent_names = (const char *[]){ "pcie_pll_od" },
  698. .num_parents = 1,
  699. .flags = CLK_SET_RATE_PARENT,
  700. },
  701. };
  702. static struct clk_regmap axg_pcie_mux = {
  703. .data = &(struct clk_regmap_mux_data){
  704. .offset = HHI_PCIE_PLL_CNTL6,
  705. .mask = 0x1,
  706. .shift = 2,
  707. /* skip the parent mpll3, reserved for debug */
  708. .table = (u32[]){ 1 },
  709. },
  710. .hw.init = &(struct clk_init_data){
  711. .name = "pcie_mux",
  712. .ops = &clk_regmap_mux_ops,
  713. .parent_names = (const char *[]){ "pcie_pll" },
  714. .num_parents = 1,
  715. .flags = CLK_SET_RATE_PARENT,
  716. },
  717. };
  718. static struct clk_regmap axg_pcie_ref = {
  719. .data = &(struct clk_regmap_mux_data){
  720. .offset = HHI_PCIE_PLL_CNTL6,
  721. .mask = 0x1,
  722. .shift = 1,
  723. /* skip the parent 0, reserved for debug */
  724. .table = (u32[]){ 1 },
  725. },
  726. .hw.init = &(struct clk_init_data){
  727. .name = "pcie_ref",
  728. .ops = &clk_regmap_mux_ops,
  729. .parent_names = (const char *[]){ "pcie_mux" },
  730. .num_parents = 1,
  731. .flags = CLK_SET_RATE_PARENT,
  732. },
  733. };
  734. static struct clk_regmap axg_pcie_cml_en0 = {
  735. .data = &(struct clk_regmap_gate_data){
  736. .offset = HHI_PCIE_PLL_CNTL6,
  737. .bit_idx = 4,
  738. },
  739. .hw.init = &(struct clk_init_data) {
  740. .name = "pcie_cml_en0",
  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 struct clk_regmap axg_pcie_cml_en1 = {
  748. .data = &(struct clk_regmap_gate_data){
  749. .offset = HHI_PCIE_PLL_CNTL6,
  750. .bit_idx = 3,
  751. },
  752. .hw.init = &(struct clk_init_data) {
  753. .name = "pcie_cml_en1",
  754. .ops = &clk_regmap_gate_ops,
  755. .parent_names = (const char *[]){ "pcie_ref" },
  756. .num_parents = 1,
  757. .flags = CLK_SET_RATE_PARENT,
  758. },
  759. };
  760. static u32 mux_table_clk81[] = { 0, 2, 3, 4, 5, 6, 7 };
  761. static const char * const clk81_parent_names[] = {
  762. "xtal", "fclk_div7", "mpll1", "mpll2", "fclk_div4",
  763. "fclk_div3", "fclk_div5"
  764. };
  765. static struct clk_regmap axg_mpeg_clk_sel = {
  766. .data = &(struct clk_regmap_mux_data){
  767. .offset = HHI_MPEG_CLK_CNTL,
  768. .mask = 0x7,
  769. .shift = 12,
  770. .table = mux_table_clk81,
  771. },
  772. .hw.init = &(struct clk_init_data){
  773. .name = "mpeg_clk_sel",
  774. .ops = &clk_regmap_mux_ro_ops,
  775. .parent_names = clk81_parent_names,
  776. .num_parents = ARRAY_SIZE(clk81_parent_names),
  777. },
  778. };
  779. static struct clk_regmap axg_mpeg_clk_div = {
  780. .data = &(struct clk_regmap_div_data){
  781. .offset = HHI_MPEG_CLK_CNTL,
  782. .shift = 0,
  783. .width = 7,
  784. },
  785. .hw.init = &(struct clk_init_data){
  786. .name = "mpeg_clk_div",
  787. .ops = &clk_regmap_divider_ops,
  788. .parent_names = (const char *[]){ "mpeg_clk_sel" },
  789. .num_parents = 1,
  790. .flags = CLK_SET_RATE_PARENT,
  791. },
  792. };
  793. static struct clk_regmap axg_clk81 = {
  794. .data = &(struct clk_regmap_gate_data){
  795. .offset = HHI_MPEG_CLK_CNTL,
  796. .bit_idx = 7,
  797. },
  798. .hw.init = &(struct clk_init_data){
  799. .name = "clk81",
  800. .ops = &clk_regmap_gate_ops,
  801. .parent_names = (const char *[]){ "mpeg_clk_div" },
  802. .num_parents = 1,
  803. .flags = (CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
  804. },
  805. };
  806. static const char * const axg_sd_emmc_clk0_parent_names[] = {
  807. "xtal", "fclk_div2", "fclk_div3", "fclk_div5", "fclk_div7",
  808. /*
  809. * Following these parent clocks, we should also have had mpll2, mpll3
  810. * and gp0_pll but these clocks are too precious to be used here. All
  811. * the necessary rates for MMC and NAND operation can be acheived using
  812. * xtal or fclk_div clocks
  813. */
  814. };
  815. /* SDcard clock */
  816. static struct clk_regmap axg_sd_emmc_b_clk0_sel = {
  817. .data = &(struct clk_regmap_mux_data){
  818. .offset = HHI_SD_EMMC_CLK_CNTL,
  819. .mask = 0x7,
  820. .shift = 25,
  821. },
  822. .hw.init = &(struct clk_init_data) {
  823. .name = "sd_emmc_b_clk0_sel",
  824. .ops = &clk_regmap_mux_ops,
  825. .parent_names = axg_sd_emmc_clk0_parent_names,
  826. .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names),
  827. .flags = CLK_SET_RATE_PARENT,
  828. },
  829. };
  830. static struct clk_regmap axg_sd_emmc_b_clk0_div = {
  831. .data = &(struct clk_regmap_div_data){
  832. .offset = HHI_SD_EMMC_CLK_CNTL,
  833. .shift = 16,
  834. .width = 7,
  835. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  836. },
  837. .hw.init = &(struct clk_init_data) {
  838. .name = "sd_emmc_b_clk0_div",
  839. .ops = &clk_regmap_divider_ops,
  840. .parent_names = (const char *[]){ "sd_emmc_b_clk0_sel" },
  841. .num_parents = 1,
  842. .flags = CLK_SET_RATE_PARENT,
  843. },
  844. };
  845. static struct clk_regmap axg_sd_emmc_b_clk0 = {
  846. .data = &(struct clk_regmap_gate_data){
  847. .offset = HHI_SD_EMMC_CLK_CNTL,
  848. .bit_idx = 23,
  849. },
  850. .hw.init = &(struct clk_init_data){
  851. .name = "sd_emmc_b_clk0",
  852. .ops = &clk_regmap_gate_ops,
  853. .parent_names = (const char *[]){ "sd_emmc_b_clk0_div" },
  854. .num_parents = 1,
  855. .flags = CLK_SET_RATE_PARENT,
  856. },
  857. };
  858. /* EMMC/NAND clock */
  859. static struct clk_regmap axg_sd_emmc_c_clk0_sel = {
  860. .data = &(struct clk_regmap_mux_data){
  861. .offset = HHI_NAND_CLK_CNTL,
  862. .mask = 0x7,
  863. .shift = 9,
  864. },
  865. .hw.init = &(struct clk_init_data) {
  866. .name = "sd_emmc_c_clk0_sel",
  867. .ops = &clk_regmap_mux_ops,
  868. .parent_names = axg_sd_emmc_clk0_parent_names,
  869. .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names),
  870. .flags = CLK_SET_RATE_PARENT,
  871. },
  872. };
  873. static struct clk_regmap axg_sd_emmc_c_clk0_div = {
  874. .data = &(struct clk_regmap_div_data){
  875. .offset = HHI_NAND_CLK_CNTL,
  876. .shift = 0,
  877. .width = 7,
  878. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  879. },
  880. .hw.init = &(struct clk_init_data) {
  881. .name = "sd_emmc_c_clk0_div",
  882. .ops = &clk_regmap_divider_ops,
  883. .parent_names = (const char *[]){ "sd_emmc_c_clk0_sel" },
  884. .num_parents = 1,
  885. .flags = CLK_SET_RATE_PARENT,
  886. },
  887. };
  888. static struct clk_regmap axg_sd_emmc_c_clk0 = {
  889. .data = &(struct clk_regmap_gate_data){
  890. .offset = HHI_NAND_CLK_CNTL,
  891. .bit_idx = 7,
  892. },
  893. .hw.init = &(struct clk_init_data){
  894. .name = "sd_emmc_c_clk0",
  895. .ops = &clk_regmap_gate_ops,
  896. .parent_names = (const char *[]){ "sd_emmc_c_clk0_div" },
  897. .num_parents = 1,
  898. .flags = CLK_SET_RATE_PARENT,
  899. },
  900. };
  901. static u32 mux_table_gen_clk[] = { 0, 4, 5, 6, 7, 8,
  902. 9, 10, 11, 13, 14, };
  903. static const char * const gen_clk_parent_names[] = {
  904. "xtal", "hifi_pll", "mpll0", "mpll1", "mpll2", "mpll3",
  905. "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7", "gp0_pll",
  906. };
  907. static struct clk_regmap axg_gen_clk_sel = {
  908. .data = &(struct clk_regmap_mux_data){
  909. .offset = HHI_GEN_CLK_CNTL,
  910. .mask = 0xf,
  911. .shift = 12,
  912. .table = mux_table_gen_clk,
  913. },
  914. .hw.init = &(struct clk_init_data){
  915. .name = "gen_clk_sel",
  916. .ops = &clk_regmap_mux_ops,
  917. /*
  918. * bits 15:12 selects from 14 possible parents:
  919. * xtal, [rtc_oscin_i], [sys_cpu_div16], [ddr_dpll_pt],
  920. * hifi_pll, mpll0, mpll1, mpll2, mpll3, fdiv4,
  921. * fdiv3, fdiv5, [cts_msr_clk], fdiv7, gp0_pll
  922. */
  923. .parent_names = gen_clk_parent_names,
  924. .num_parents = ARRAY_SIZE(gen_clk_parent_names),
  925. },
  926. };
  927. static struct clk_regmap axg_gen_clk_div = {
  928. .data = &(struct clk_regmap_div_data){
  929. .offset = HHI_GEN_CLK_CNTL,
  930. .shift = 0,
  931. .width = 11,
  932. },
  933. .hw.init = &(struct clk_init_data){
  934. .name = "gen_clk_div",
  935. .ops = &clk_regmap_divider_ops,
  936. .parent_names = (const char *[]){ "gen_clk_sel" },
  937. .num_parents = 1,
  938. .flags = CLK_SET_RATE_PARENT,
  939. },
  940. };
  941. static struct clk_regmap axg_gen_clk = {
  942. .data = &(struct clk_regmap_gate_data){
  943. .offset = HHI_GEN_CLK_CNTL,
  944. .bit_idx = 7,
  945. },
  946. .hw.init = &(struct clk_init_data){
  947. .name = "gen_clk",
  948. .ops = &clk_regmap_gate_ops,
  949. .parent_names = (const char *[]){ "gen_clk_div" },
  950. .num_parents = 1,
  951. .flags = CLK_SET_RATE_PARENT,
  952. },
  953. };
  954. /* Everything Else (EE) domain gates */
  955. static MESON_GATE(axg_ddr, HHI_GCLK_MPEG0, 0);
  956. static MESON_GATE(axg_audio_locker, HHI_GCLK_MPEG0, 2);
  957. static MESON_GATE(axg_mipi_dsi_host, HHI_GCLK_MPEG0, 3);
  958. static MESON_GATE(axg_isa, HHI_GCLK_MPEG0, 5);
  959. static MESON_GATE(axg_pl301, HHI_GCLK_MPEG0, 6);
  960. static MESON_GATE(axg_periphs, HHI_GCLK_MPEG0, 7);
  961. static MESON_GATE(axg_spicc_0, HHI_GCLK_MPEG0, 8);
  962. static MESON_GATE(axg_i2c, HHI_GCLK_MPEG0, 9);
  963. static MESON_GATE(axg_rng0, HHI_GCLK_MPEG0, 12);
  964. static MESON_GATE(axg_uart0, HHI_GCLK_MPEG0, 13);
  965. static MESON_GATE(axg_mipi_dsi_phy, HHI_GCLK_MPEG0, 14);
  966. static MESON_GATE(axg_spicc_1, HHI_GCLK_MPEG0, 15);
  967. static MESON_GATE(axg_pcie_a, HHI_GCLK_MPEG0, 16);
  968. static MESON_GATE(axg_pcie_b, HHI_GCLK_MPEG0, 17);
  969. static MESON_GATE(axg_hiu_reg, HHI_GCLK_MPEG0, 19);
  970. static MESON_GATE(axg_assist_misc, HHI_GCLK_MPEG0, 23);
  971. static MESON_GATE(axg_emmc_b, HHI_GCLK_MPEG0, 25);
  972. static MESON_GATE(axg_emmc_c, HHI_GCLK_MPEG0, 26);
  973. static MESON_GATE(axg_dma, HHI_GCLK_MPEG0, 27);
  974. static MESON_GATE(axg_spi, HHI_GCLK_MPEG0, 30);
  975. static MESON_GATE(axg_audio, HHI_GCLK_MPEG1, 0);
  976. static MESON_GATE(axg_eth_core, HHI_GCLK_MPEG1, 3);
  977. static MESON_GATE(axg_uart1, HHI_GCLK_MPEG1, 16);
  978. static MESON_GATE(axg_g2d, HHI_GCLK_MPEG1, 20);
  979. static MESON_GATE(axg_usb0, HHI_GCLK_MPEG1, 21);
  980. static MESON_GATE(axg_usb1, HHI_GCLK_MPEG1, 22);
  981. static MESON_GATE(axg_reset, HHI_GCLK_MPEG1, 23);
  982. static MESON_GATE(axg_usb_general, HHI_GCLK_MPEG1, 26);
  983. static MESON_GATE(axg_ahb_arb0, HHI_GCLK_MPEG1, 29);
  984. static MESON_GATE(axg_efuse, HHI_GCLK_MPEG1, 30);
  985. static MESON_GATE(axg_boot_rom, HHI_GCLK_MPEG1, 31);
  986. static MESON_GATE(axg_ahb_data_bus, HHI_GCLK_MPEG2, 1);
  987. static MESON_GATE(axg_ahb_ctrl_bus, HHI_GCLK_MPEG2, 2);
  988. static MESON_GATE(axg_usb1_to_ddr, HHI_GCLK_MPEG2, 8);
  989. static MESON_GATE(axg_usb0_to_ddr, HHI_GCLK_MPEG2, 9);
  990. static MESON_GATE(axg_mmc_pclk, HHI_GCLK_MPEG2, 11);
  991. static MESON_GATE(axg_vpu_intr, HHI_GCLK_MPEG2, 25);
  992. static MESON_GATE(axg_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26);
  993. static MESON_GATE(axg_gic, HHI_GCLK_MPEG2, 30);
  994. static MESON_GATE(axg_mipi_enable, HHI_MIPI_CNTL0, 29);
  995. /* Always On (AO) domain gates */
  996. static MESON_GATE(axg_ao_media_cpu, HHI_GCLK_AO, 0);
  997. static MESON_GATE(axg_ao_ahb_sram, HHI_GCLK_AO, 1);
  998. static MESON_GATE(axg_ao_ahb_bus, HHI_GCLK_AO, 2);
  999. static MESON_GATE(axg_ao_iface, HHI_GCLK_AO, 3);
  1000. static MESON_GATE(axg_ao_i2c, HHI_GCLK_AO, 4);
  1001. /* Array of all clocks provided by this provider */
  1002. static struct clk_hw_onecell_data axg_hw_onecell_data = {
  1003. .hws = {
  1004. [CLKID_SYS_PLL] = &axg_sys_pll.hw,
  1005. [CLKID_FIXED_PLL] = &axg_fixed_pll.hw,
  1006. [CLKID_FCLK_DIV2] = &axg_fclk_div2.hw,
  1007. [CLKID_FCLK_DIV3] = &axg_fclk_div3.hw,
  1008. [CLKID_FCLK_DIV4] = &axg_fclk_div4.hw,
  1009. [CLKID_FCLK_DIV5] = &axg_fclk_div5.hw,
  1010. [CLKID_FCLK_DIV7] = &axg_fclk_div7.hw,
  1011. [CLKID_GP0_PLL] = &axg_gp0_pll.hw,
  1012. [CLKID_MPEG_SEL] = &axg_mpeg_clk_sel.hw,
  1013. [CLKID_MPEG_DIV] = &axg_mpeg_clk_div.hw,
  1014. [CLKID_CLK81] = &axg_clk81.hw,
  1015. [CLKID_MPLL0] = &axg_mpll0.hw,
  1016. [CLKID_MPLL1] = &axg_mpll1.hw,
  1017. [CLKID_MPLL2] = &axg_mpll2.hw,
  1018. [CLKID_MPLL3] = &axg_mpll3.hw,
  1019. [CLKID_DDR] = &axg_ddr.hw,
  1020. [CLKID_AUDIO_LOCKER] = &axg_audio_locker.hw,
  1021. [CLKID_MIPI_DSI_HOST] = &axg_mipi_dsi_host.hw,
  1022. [CLKID_ISA] = &axg_isa.hw,
  1023. [CLKID_PL301] = &axg_pl301.hw,
  1024. [CLKID_PERIPHS] = &axg_periphs.hw,
  1025. [CLKID_SPICC0] = &axg_spicc_0.hw,
  1026. [CLKID_I2C] = &axg_i2c.hw,
  1027. [CLKID_RNG0] = &axg_rng0.hw,
  1028. [CLKID_UART0] = &axg_uart0.hw,
  1029. [CLKID_MIPI_DSI_PHY] = &axg_mipi_dsi_phy.hw,
  1030. [CLKID_SPICC1] = &axg_spicc_1.hw,
  1031. [CLKID_PCIE_A] = &axg_pcie_a.hw,
  1032. [CLKID_PCIE_B] = &axg_pcie_b.hw,
  1033. [CLKID_HIU_IFACE] = &axg_hiu_reg.hw,
  1034. [CLKID_ASSIST_MISC] = &axg_assist_misc.hw,
  1035. [CLKID_SD_EMMC_B] = &axg_emmc_b.hw,
  1036. [CLKID_SD_EMMC_C] = &axg_emmc_c.hw,
  1037. [CLKID_DMA] = &axg_dma.hw,
  1038. [CLKID_SPI] = &axg_spi.hw,
  1039. [CLKID_AUDIO] = &axg_audio.hw,
  1040. [CLKID_ETH] = &axg_eth_core.hw,
  1041. [CLKID_UART1] = &axg_uart1.hw,
  1042. [CLKID_G2D] = &axg_g2d.hw,
  1043. [CLKID_USB0] = &axg_usb0.hw,
  1044. [CLKID_USB1] = &axg_usb1.hw,
  1045. [CLKID_RESET] = &axg_reset.hw,
  1046. [CLKID_USB] = &axg_usb_general.hw,
  1047. [CLKID_AHB_ARB0] = &axg_ahb_arb0.hw,
  1048. [CLKID_EFUSE] = &axg_efuse.hw,
  1049. [CLKID_BOOT_ROM] = &axg_boot_rom.hw,
  1050. [CLKID_AHB_DATA_BUS] = &axg_ahb_data_bus.hw,
  1051. [CLKID_AHB_CTRL_BUS] = &axg_ahb_ctrl_bus.hw,
  1052. [CLKID_USB1_DDR_BRIDGE] = &axg_usb1_to_ddr.hw,
  1053. [CLKID_USB0_DDR_BRIDGE] = &axg_usb0_to_ddr.hw,
  1054. [CLKID_MMC_PCLK] = &axg_mmc_pclk.hw,
  1055. [CLKID_VPU_INTR] = &axg_vpu_intr.hw,
  1056. [CLKID_SEC_AHB_AHB3_BRIDGE] = &axg_sec_ahb_ahb3_bridge.hw,
  1057. [CLKID_GIC] = &axg_gic.hw,
  1058. [CLKID_AO_MEDIA_CPU] = &axg_ao_media_cpu.hw,
  1059. [CLKID_AO_AHB_SRAM] = &axg_ao_ahb_sram.hw,
  1060. [CLKID_AO_AHB_BUS] = &axg_ao_ahb_bus.hw,
  1061. [CLKID_AO_IFACE] = &axg_ao_iface.hw,
  1062. [CLKID_AO_I2C] = &axg_ao_i2c.hw,
  1063. [CLKID_SD_EMMC_B_CLK0_SEL] = &axg_sd_emmc_b_clk0_sel.hw,
  1064. [CLKID_SD_EMMC_B_CLK0_DIV] = &axg_sd_emmc_b_clk0_div.hw,
  1065. [CLKID_SD_EMMC_B_CLK0] = &axg_sd_emmc_b_clk0.hw,
  1066. [CLKID_SD_EMMC_C_CLK0_SEL] = &axg_sd_emmc_c_clk0_sel.hw,
  1067. [CLKID_SD_EMMC_C_CLK0_DIV] = &axg_sd_emmc_c_clk0_div.hw,
  1068. [CLKID_SD_EMMC_C_CLK0] = &axg_sd_emmc_c_clk0.hw,
  1069. [CLKID_MPLL0_DIV] = &axg_mpll0_div.hw,
  1070. [CLKID_MPLL1_DIV] = &axg_mpll1_div.hw,
  1071. [CLKID_MPLL2_DIV] = &axg_mpll2_div.hw,
  1072. [CLKID_MPLL3_DIV] = &axg_mpll3_div.hw,
  1073. [CLKID_HIFI_PLL] = &axg_hifi_pll.hw,
  1074. [CLKID_MPLL_PREDIV] = &axg_mpll_prediv.hw,
  1075. [CLKID_FCLK_DIV2_DIV] = &axg_fclk_div2_div.hw,
  1076. [CLKID_FCLK_DIV3_DIV] = &axg_fclk_div3_div.hw,
  1077. [CLKID_FCLK_DIV4_DIV] = &axg_fclk_div4_div.hw,
  1078. [CLKID_FCLK_DIV5_DIV] = &axg_fclk_div5_div.hw,
  1079. [CLKID_FCLK_DIV7_DIV] = &axg_fclk_div7_div.hw,
  1080. [CLKID_PCIE_PLL] = &axg_pcie_pll.hw,
  1081. [CLKID_PCIE_MUX] = &axg_pcie_mux.hw,
  1082. [CLKID_PCIE_REF] = &axg_pcie_ref.hw,
  1083. [CLKID_PCIE_CML_EN0] = &axg_pcie_cml_en0.hw,
  1084. [CLKID_PCIE_CML_EN1] = &axg_pcie_cml_en1.hw,
  1085. [CLKID_MIPI_ENABLE] = &axg_mipi_enable.hw,
  1086. [CLKID_GEN_CLK_SEL] = &axg_gen_clk_sel.hw,
  1087. [CLKID_GEN_CLK_DIV] = &axg_gen_clk_div.hw,
  1088. [CLKID_GEN_CLK] = &axg_gen_clk.hw,
  1089. [CLKID_SYS_PLL_DCO] = &axg_sys_pll_dco.hw,
  1090. [CLKID_FIXED_PLL_DCO] = &axg_fixed_pll_dco.hw,
  1091. [CLKID_GP0_PLL_DCO] = &axg_gp0_pll_dco.hw,
  1092. [CLKID_HIFI_PLL_DCO] = &axg_hifi_pll_dco.hw,
  1093. [CLKID_PCIE_PLL_DCO] = &axg_pcie_pll_dco.hw,
  1094. [CLKID_PCIE_PLL_OD] = &axg_pcie_pll_od.hw,
  1095. [NR_CLKS] = NULL,
  1096. },
  1097. .num = NR_CLKS,
  1098. };
  1099. /* Convenience table to populate regmap in .probe */
  1100. static struct clk_regmap *const axg_clk_regmaps[] = {
  1101. &axg_clk81,
  1102. &axg_ddr,
  1103. &axg_audio_locker,
  1104. &axg_mipi_dsi_host,
  1105. &axg_isa,
  1106. &axg_pl301,
  1107. &axg_periphs,
  1108. &axg_spicc_0,
  1109. &axg_i2c,
  1110. &axg_rng0,
  1111. &axg_uart0,
  1112. &axg_mipi_dsi_phy,
  1113. &axg_spicc_1,
  1114. &axg_pcie_a,
  1115. &axg_pcie_b,
  1116. &axg_hiu_reg,
  1117. &axg_assist_misc,
  1118. &axg_emmc_b,
  1119. &axg_emmc_c,
  1120. &axg_dma,
  1121. &axg_spi,
  1122. &axg_audio,
  1123. &axg_eth_core,
  1124. &axg_uart1,
  1125. &axg_g2d,
  1126. &axg_usb0,
  1127. &axg_usb1,
  1128. &axg_reset,
  1129. &axg_usb_general,
  1130. &axg_ahb_arb0,
  1131. &axg_efuse,
  1132. &axg_boot_rom,
  1133. &axg_ahb_data_bus,
  1134. &axg_ahb_ctrl_bus,
  1135. &axg_usb1_to_ddr,
  1136. &axg_usb0_to_ddr,
  1137. &axg_mmc_pclk,
  1138. &axg_vpu_intr,
  1139. &axg_sec_ahb_ahb3_bridge,
  1140. &axg_gic,
  1141. &axg_ao_media_cpu,
  1142. &axg_ao_ahb_sram,
  1143. &axg_ao_ahb_bus,
  1144. &axg_ao_iface,
  1145. &axg_ao_i2c,
  1146. &axg_sd_emmc_b_clk0,
  1147. &axg_sd_emmc_c_clk0,
  1148. &axg_mpeg_clk_div,
  1149. &axg_sd_emmc_b_clk0_div,
  1150. &axg_sd_emmc_c_clk0_div,
  1151. &axg_mpeg_clk_sel,
  1152. &axg_sd_emmc_b_clk0_sel,
  1153. &axg_sd_emmc_c_clk0_sel,
  1154. &axg_mpll0,
  1155. &axg_mpll1,
  1156. &axg_mpll2,
  1157. &axg_mpll3,
  1158. &axg_mpll0_div,
  1159. &axg_mpll1_div,
  1160. &axg_mpll2_div,
  1161. &axg_mpll3_div,
  1162. &axg_fixed_pll,
  1163. &axg_sys_pll,
  1164. &axg_gp0_pll,
  1165. &axg_hifi_pll,
  1166. &axg_mpll_prediv,
  1167. &axg_fclk_div2,
  1168. &axg_fclk_div3,
  1169. &axg_fclk_div4,
  1170. &axg_fclk_div5,
  1171. &axg_fclk_div7,
  1172. &axg_pcie_pll_dco,
  1173. &axg_pcie_pll_od,
  1174. &axg_pcie_pll,
  1175. &axg_pcie_mux,
  1176. &axg_pcie_ref,
  1177. &axg_pcie_cml_en0,
  1178. &axg_pcie_cml_en1,
  1179. &axg_mipi_enable,
  1180. &axg_gen_clk_sel,
  1181. &axg_gen_clk_div,
  1182. &axg_gen_clk,
  1183. &axg_fixed_pll_dco,
  1184. &axg_sys_pll_dco,
  1185. &axg_gp0_pll_dco,
  1186. &axg_hifi_pll_dco,
  1187. &axg_pcie_pll_dco,
  1188. &axg_pcie_pll_od,
  1189. };
  1190. static const struct of_device_id clkc_match_table[] = {
  1191. { .compatible = "amlogic,axg-clkc" },
  1192. {}
  1193. };
  1194. static int axg_clkc_probe(struct platform_device *pdev)
  1195. {
  1196. struct device *dev = &pdev->dev;
  1197. struct regmap *map;
  1198. int ret, i;
  1199. /* Get the hhi system controller node if available */
  1200. map = syscon_node_to_regmap(of_get_parent(dev->of_node));
  1201. if (IS_ERR(map)) {
  1202. dev_err(dev, "failed to get HHI regmap\n");
  1203. return PTR_ERR(map);
  1204. }
  1205. /* Populate regmap for the regmap backed clocks */
  1206. for (i = 0; i < ARRAY_SIZE(axg_clk_regmaps); i++)
  1207. axg_clk_regmaps[i]->map = map;
  1208. for (i = 0; i < axg_hw_onecell_data.num; i++) {
  1209. /* array might be sparse */
  1210. if (!axg_hw_onecell_data.hws[i])
  1211. continue;
  1212. ret = devm_clk_hw_register(dev, axg_hw_onecell_data.hws[i]);
  1213. if (ret) {
  1214. dev_err(dev, "Clock registration failed\n");
  1215. return ret;
  1216. }
  1217. }
  1218. return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
  1219. &axg_hw_onecell_data);
  1220. }
  1221. static struct platform_driver axg_driver = {
  1222. .probe = axg_clkc_probe,
  1223. .driver = {
  1224. .name = "axg-clkc",
  1225. .of_match_table = clkc_match_table,
  1226. },
  1227. };
  1228. builtin_platform_driver(axg_driver);