a1-peripherals.c 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
  4. * Author: Jian Hu <jian.hu@amlogic.com>
  5. *
  6. * Copyright (c) 2023, SberDevices. All Rights Reserved.
  7. * Author: Dmitry Rokosov <ddrokosov@sberdevices.ru>
  8. */
  9. #include <linux/clk-provider.h>
  10. #include <linux/mod_devicetable.h>
  11. #include <linux/platform_device.h>
  12. #include "a1-peripherals.h"
  13. #include "clk-dualdiv.h"
  14. #include "clk-regmap.h"
  15. #include "meson-clkc-utils.h"
  16. #include <dt-bindings/clock/amlogic,a1-peripherals-clkc.h>
  17. static struct clk_regmap xtal_in = {
  18. .data = &(struct clk_regmap_gate_data){
  19. .offset = SYS_OSCIN_CTRL,
  20. .bit_idx = 0,
  21. },
  22. .hw.init = &(struct clk_init_data) {
  23. .name = "xtal_in",
  24. .ops = &clk_regmap_gate_ro_ops,
  25. .parent_data = &(const struct clk_parent_data) {
  26. .fw_name = "xtal",
  27. },
  28. .num_parents = 1,
  29. },
  30. };
  31. static struct clk_regmap fixpll_in = {
  32. .data = &(struct clk_regmap_gate_data){
  33. .offset = SYS_OSCIN_CTRL,
  34. .bit_idx = 1,
  35. },
  36. .hw.init = &(struct clk_init_data) {
  37. .name = "fixpll_in",
  38. .ops = &clk_regmap_gate_ro_ops,
  39. .parent_data = &(const struct clk_parent_data) {
  40. .fw_name = "xtal",
  41. },
  42. .num_parents = 1,
  43. },
  44. };
  45. static struct clk_regmap usb_phy_in = {
  46. .data = &(struct clk_regmap_gate_data){
  47. .offset = SYS_OSCIN_CTRL,
  48. .bit_idx = 2,
  49. },
  50. .hw.init = &(struct clk_init_data) {
  51. .name = "usb_phy_in",
  52. .ops = &clk_regmap_gate_ops,
  53. .parent_data = &(const struct clk_parent_data) {
  54. .fw_name = "xtal",
  55. },
  56. .num_parents = 1,
  57. },
  58. };
  59. static struct clk_regmap usb_ctrl_in = {
  60. .data = &(struct clk_regmap_gate_data){
  61. .offset = SYS_OSCIN_CTRL,
  62. .bit_idx = 3,
  63. },
  64. .hw.init = &(struct clk_init_data) {
  65. .name = "usb_ctrl_in",
  66. .ops = &clk_regmap_gate_ops,
  67. .parent_data = &(const struct clk_parent_data) {
  68. .fw_name = "xtal",
  69. },
  70. .num_parents = 1,
  71. },
  72. };
  73. static struct clk_regmap hifipll_in = {
  74. .data = &(struct clk_regmap_gate_data){
  75. .offset = SYS_OSCIN_CTRL,
  76. .bit_idx = 4,
  77. },
  78. .hw.init = &(struct clk_init_data) {
  79. .name = "hifipll_in",
  80. .ops = &clk_regmap_gate_ops,
  81. .parent_data = &(const struct clk_parent_data) {
  82. .fw_name = "xtal",
  83. },
  84. .num_parents = 1,
  85. },
  86. };
  87. static struct clk_regmap syspll_in = {
  88. .data = &(struct clk_regmap_gate_data){
  89. .offset = SYS_OSCIN_CTRL,
  90. .bit_idx = 5,
  91. },
  92. .hw.init = &(struct clk_init_data) {
  93. .name = "syspll_in",
  94. .ops = &clk_regmap_gate_ops,
  95. .parent_data = &(const struct clk_parent_data) {
  96. .fw_name = "xtal",
  97. },
  98. .num_parents = 1,
  99. },
  100. };
  101. static struct clk_regmap dds_in = {
  102. .data = &(struct clk_regmap_gate_data){
  103. .offset = SYS_OSCIN_CTRL,
  104. .bit_idx = 6,
  105. },
  106. .hw.init = &(struct clk_init_data) {
  107. .name = "dds_in",
  108. .ops = &clk_regmap_gate_ops,
  109. .parent_data = &(const struct clk_parent_data) {
  110. .fw_name = "xtal",
  111. },
  112. .num_parents = 1,
  113. },
  114. };
  115. static struct clk_regmap rtc_32k_in = {
  116. .data = &(struct clk_regmap_gate_data){
  117. .offset = RTC_BY_OSCIN_CTRL0,
  118. .bit_idx = 31,
  119. },
  120. .hw.init = &(struct clk_init_data) {
  121. .name = "rtc_32k_in",
  122. .ops = &clk_regmap_gate_ops,
  123. .parent_data = &(const struct clk_parent_data) {
  124. .fw_name = "xtal",
  125. },
  126. .num_parents = 1,
  127. },
  128. };
  129. static const struct meson_clk_dualdiv_param clk_32k_div_table[] = {
  130. {
  131. .dual = 1,
  132. .n1 = 733,
  133. .m1 = 8,
  134. .n2 = 732,
  135. .m2 = 11,
  136. },
  137. {}
  138. };
  139. static struct clk_regmap rtc_32k_div = {
  140. .data = &(struct meson_clk_dualdiv_data){
  141. .n1 = {
  142. .reg_off = RTC_BY_OSCIN_CTRL0,
  143. .shift = 0,
  144. .width = 12,
  145. },
  146. .n2 = {
  147. .reg_off = RTC_BY_OSCIN_CTRL0,
  148. .shift = 12,
  149. .width = 12,
  150. },
  151. .m1 = {
  152. .reg_off = RTC_BY_OSCIN_CTRL1,
  153. .shift = 0,
  154. .width = 12,
  155. },
  156. .m2 = {
  157. .reg_off = RTC_BY_OSCIN_CTRL1,
  158. .shift = 12,
  159. .width = 12,
  160. },
  161. .dual = {
  162. .reg_off = RTC_BY_OSCIN_CTRL0,
  163. .shift = 28,
  164. .width = 1,
  165. },
  166. .table = clk_32k_div_table,
  167. },
  168. .hw.init = &(struct clk_init_data){
  169. .name = "rtc_32k_div",
  170. .ops = &meson_clk_dualdiv_ops,
  171. .parent_hws = (const struct clk_hw *[]) {
  172. &rtc_32k_in.hw
  173. },
  174. .num_parents = 1,
  175. },
  176. };
  177. static struct clk_regmap rtc_32k_xtal = {
  178. .data = &(struct clk_regmap_gate_data){
  179. .offset = RTC_BY_OSCIN_CTRL1,
  180. .bit_idx = 24,
  181. },
  182. .hw.init = &(struct clk_init_data) {
  183. .name = "rtc_32k_xtal",
  184. .ops = &clk_regmap_gate_ops,
  185. .parent_hws = (const struct clk_hw *[]) {
  186. &rtc_32k_in.hw
  187. },
  188. .num_parents = 1,
  189. },
  190. };
  191. static struct clk_regmap rtc_32k_sel = {
  192. .data = &(struct clk_regmap_mux_data) {
  193. .offset = RTC_CTRL,
  194. .mask = 0x3,
  195. .shift = 0,
  196. .flags = CLK_MUX_ROUND_CLOSEST,
  197. },
  198. .hw.init = &(struct clk_init_data){
  199. .name = "rtc_32k_sel",
  200. .ops = &clk_regmap_mux_ops,
  201. .parent_hws = (const struct clk_hw *[]) {
  202. &rtc_32k_xtal.hw,
  203. &rtc_32k_div.hw,
  204. },
  205. .num_parents = 2,
  206. .flags = CLK_SET_RATE_PARENT,
  207. },
  208. };
  209. static struct clk_regmap rtc = {
  210. .data = &(struct clk_regmap_gate_data){
  211. .offset = RTC_BY_OSCIN_CTRL0,
  212. .bit_idx = 30,
  213. },
  214. .hw.init = &(struct clk_init_data){
  215. .name = "rtc",
  216. .ops = &clk_regmap_gate_ops,
  217. .parent_hws = (const struct clk_hw *[]) {
  218. &rtc_32k_sel.hw
  219. },
  220. .num_parents = 1,
  221. .flags = CLK_SET_RATE_PARENT,
  222. },
  223. };
  224. static u32 mux_table_sys[] = { 0, 1, 2, 3, 7 };
  225. static const struct clk_parent_data sys_parents[] = {
  226. { .fw_name = "xtal" },
  227. { .fw_name = "fclk_div2" },
  228. { .fw_name = "fclk_div3" },
  229. { .fw_name = "fclk_div5" },
  230. { .hw = &rtc.hw },
  231. };
  232. static struct clk_regmap sys_b_sel = {
  233. .data = &(struct clk_regmap_mux_data){
  234. .offset = SYS_CLK_CTRL0,
  235. .mask = 0x7,
  236. .shift = 26,
  237. .table = mux_table_sys,
  238. },
  239. .hw.init = &(struct clk_init_data){
  240. .name = "sys_b_sel",
  241. .ops = &clk_regmap_mux_ro_ops,
  242. .parent_data = sys_parents,
  243. .num_parents = ARRAY_SIZE(sys_parents),
  244. },
  245. };
  246. static struct clk_regmap sys_b_div = {
  247. .data = &(struct clk_regmap_div_data){
  248. .offset = SYS_CLK_CTRL0,
  249. .shift = 16,
  250. .width = 10,
  251. },
  252. .hw.init = &(struct clk_init_data){
  253. .name = "sys_b_div",
  254. .ops = &clk_regmap_divider_ro_ops,
  255. .parent_hws = (const struct clk_hw *[]) {
  256. &sys_b_sel.hw
  257. },
  258. .num_parents = 1,
  259. .flags = CLK_SET_RATE_PARENT,
  260. },
  261. };
  262. static struct clk_regmap sys_b = {
  263. .data = &(struct clk_regmap_gate_data){
  264. .offset = SYS_CLK_CTRL0,
  265. .bit_idx = 29,
  266. },
  267. .hw.init = &(struct clk_init_data) {
  268. .name = "sys_b",
  269. .ops = &clk_regmap_gate_ro_ops,
  270. .parent_hws = (const struct clk_hw *[]) {
  271. &sys_b_div.hw
  272. },
  273. .num_parents = 1,
  274. .flags = CLK_SET_RATE_PARENT,
  275. },
  276. };
  277. static struct clk_regmap sys_a_sel = {
  278. .data = &(struct clk_regmap_mux_data){
  279. .offset = SYS_CLK_CTRL0,
  280. .mask = 0x7,
  281. .shift = 10,
  282. .table = mux_table_sys,
  283. },
  284. .hw.init = &(struct clk_init_data){
  285. .name = "sys_a_sel",
  286. .ops = &clk_regmap_mux_ro_ops,
  287. .parent_data = sys_parents,
  288. .num_parents = ARRAY_SIZE(sys_parents),
  289. },
  290. };
  291. static struct clk_regmap sys_a_div = {
  292. .data = &(struct clk_regmap_div_data){
  293. .offset = SYS_CLK_CTRL0,
  294. .shift = 0,
  295. .width = 10,
  296. },
  297. .hw.init = &(struct clk_init_data){
  298. .name = "sys_a_div",
  299. .ops = &clk_regmap_divider_ro_ops,
  300. .parent_hws = (const struct clk_hw *[]) {
  301. &sys_a_sel.hw
  302. },
  303. .num_parents = 1,
  304. .flags = CLK_SET_RATE_PARENT,
  305. },
  306. };
  307. static struct clk_regmap sys_a = {
  308. .data = &(struct clk_regmap_gate_data){
  309. .offset = SYS_CLK_CTRL0,
  310. .bit_idx = 13,
  311. },
  312. .hw.init = &(struct clk_init_data) {
  313. .name = "sys_a",
  314. .ops = &clk_regmap_gate_ro_ops,
  315. .parent_hws = (const struct clk_hw *[]) {
  316. &sys_a_div.hw
  317. },
  318. .num_parents = 1,
  319. .flags = CLK_SET_RATE_PARENT,
  320. },
  321. };
  322. static struct clk_regmap sys = {
  323. .data = &(struct clk_regmap_mux_data){
  324. .offset = SYS_CLK_CTRL0,
  325. .mask = 0x1,
  326. .shift = 31,
  327. },
  328. .hw.init = &(struct clk_init_data){
  329. .name = "sys",
  330. .ops = &clk_regmap_mux_ro_ops,
  331. .parent_hws = (const struct clk_hw *[]) {
  332. &sys_a.hw,
  333. &sys_b.hw,
  334. },
  335. .num_parents = 2,
  336. /*
  337. * This clock is used by APB bus which is set in boot ROM code
  338. * and is required 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) Mark the clock used by a firmware resource, if possible
  342. * b) CCF has a clock hand-off mechanism to make the sure the
  343. * clock stays on until the proper driver comes along
  344. */
  345. .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
  346. },
  347. };
  348. static u32 mux_table_dsp_ab[] = { 0, 1, 2, 3, 4, 7 };
  349. static const struct clk_parent_data dsp_ab_parent_data[] = {
  350. { .fw_name = "xtal", },
  351. { .fw_name = "fclk_div2", },
  352. { .fw_name = "fclk_div3", },
  353. { .fw_name = "fclk_div5", },
  354. { .fw_name = "hifi_pll", },
  355. { .hw = &rtc.hw },
  356. };
  357. static struct clk_regmap dspa_a_sel = {
  358. .data = &(struct clk_regmap_mux_data){
  359. .offset = DSPA_CLK_CTRL0,
  360. .mask = 0x7,
  361. .shift = 10,
  362. .table = mux_table_dsp_ab,
  363. },
  364. .hw.init = &(struct clk_init_data){
  365. .name = "dspa_a_sel",
  366. .ops = &clk_regmap_mux_ops,
  367. .parent_data = dsp_ab_parent_data,
  368. .num_parents = ARRAY_SIZE(dsp_ab_parent_data),
  369. },
  370. };
  371. static struct clk_regmap dspa_a_div = {
  372. .data = &(struct clk_regmap_div_data){
  373. .offset = DSPA_CLK_CTRL0,
  374. .shift = 0,
  375. .width = 10,
  376. },
  377. .hw.init = &(struct clk_init_data){
  378. .name = "dspa_a_div",
  379. .ops = &clk_regmap_divider_ops,
  380. .parent_hws = (const struct clk_hw *[]) {
  381. &dspa_a_sel.hw
  382. },
  383. .num_parents = 1,
  384. .flags = CLK_SET_RATE_PARENT,
  385. },
  386. };
  387. static struct clk_regmap dspa_a = {
  388. .data = &(struct clk_regmap_gate_data){
  389. .offset = DSPA_CLK_CTRL0,
  390. .bit_idx = 13,
  391. },
  392. .hw.init = &(struct clk_init_data) {
  393. .name = "dspa_a",
  394. .ops = &clk_regmap_gate_ops,
  395. .parent_hws = (const struct clk_hw *[]) {
  396. &dspa_a_div.hw
  397. },
  398. .num_parents = 1,
  399. .flags = CLK_SET_RATE_PARENT,
  400. },
  401. };
  402. static struct clk_regmap dspa_b_sel = {
  403. .data = &(struct clk_regmap_mux_data){
  404. .offset = DSPA_CLK_CTRL0,
  405. .mask = 0x7,
  406. .shift = 26,
  407. .table = mux_table_dsp_ab,
  408. },
  409. .hw.init = &(struct clk_init_data){
  410. .name = "dspa_b_sel",
  411. .ops = &clk_regmap_mux_ops,
  412. .parent_data = dsp_ab_parent_data,
  413. .num_parents = ARRAY_SIZE(dsp_ab_parent_data),
  414. },
  415. };
  416. static struct clk_regmap dspa_b_div = {
  417. .data = &(struct clk_regmap_div_data){
  418. .offset = DSPA_CLK_CTRL0,
  419. .shift = 16,
  420. .width = 10,
  421. },
  422. .hw.init = &(struct clk_init_data){
  423. .name = "dspa_b_div",
  424. .ops = &clk_regmap_divider_ops,
  425. .parent_hws = (const struct clk_hw *[]) {
  426. &dspa_b_sel.hw
  427. },
  428. .num_parents = 1,
  429. .flags = CLK_SET_RATE_PARENT,
  430. },
  431. };
  432. static struct clk_regmap dspa_b = {
  433. .data = &(struct clk_regmap_gate_data){
  434. .offset = DSPA_CLK_CTRL0,
  435. .bit_idx = 29,
  436. },
  437. .hw.init = &(struct clk_init_data) {
  438. .name = "dspa_b",
  439. .ops = &clk_regmap_gate_ops,
  440. .parent_hws = (const struct clk_hw *[]) {
  441. &dspa_b_div.hw
  442. },
  443. .num_parents = 1,
  444. .flags = CLK_SET_RATE_PARENT,
  445. },
  446. };
  447. static struct clk_regmap dspa_sel = {
  448. .data = &(struct clk_regmap_mux_data){
  449. .offset = DSPA_CLK_CTRL0,
  450. .mask = 0x1,
  451. .shift = 15,
  452. },
  453. .hw.init = &(struct clk_init_data){
  454. .name = "dspa_sel",
  455. .ops = &clk_regmap_mux_ops,
  456. .parent_hws = (const struct clk_hw *[]) {
  457. &dspa_a.hw,
  458. &dspa_b.hw,
  459. },
  460. .num_parents = 2,
  461. .flags = CLK_SET_RATE_PARENT,
  462. },
  463. };
  464. static struct clk_regmap dspa_en = {
  465. .data = &(struct clk_regmap_gate_data){
  466. .offset = DSPA_CLK_EN,
  467. .bit_idx = 1,
  468. },
  469. .hw.init = &(struct clk_init_data) {
  470. .name = "dspa_en",
  471. .ops = &clk_regmap_gate_ops,
  472. .parent_hws = (const struct clk_hw *[]) {
  473. &dspa_sel.hw
  474. },
  475. .num_parents = 1,
  476. .flags = CLK_SET_RATE_PARENT,
  477. },
  478. };
  479. static struct clk_regmap dspa_en_nic = {
  480. .data = &(struct clk_regmap_gate_data){
  481. .offset = DSPA_CLK_EN,
  482. .bit_idx = 0,
  483. },
  484. .hw.init = &(struct clk_init_data) {
  485. .name = "dspa_en_nic",
  486. .ops = &clk_regmap_gate_ops,
  487. .parent_hws = (const struct clk_hw *[]) {
  488. &dspa_sel.hw
  489. },
  490. .num_parents = 1,
  491. .flags = CLK_SET_RATE_PARENT,
  492. },
  493. };
  494. static struct clk_regmap dspb_a_sel = {
  495. .data = &(struct clk_regmap_mux_data){
  496. .offset = DSPB_CLK_CTRL0,
  497. .mask = 0x7,
  498. .shift = 10,
  499. .table = mux_table_dsp_ab,
  500. },
  501. .hw.init = &(struct clk_init_data){
  502. .name = "dspb_a_sel",
  503. .ops = &clk_regmap_mux_ops,
  504. .parent_data = dsp_ab_parent_data,
  505. .num_parents = ARRAY_SIZE(dsp_ab_parent_data),
  506. },
  507. };
  508. static struct clk_regmap dspb_a_div = {
  509. .data = &(struct clk_regmap_div_data){
  510. .offset = DSPB_CLK_CTRL0,
  511. .shift = 0,
  512. .width = 10,
  513. },
  514. .hw.init = &(struct clk_init_data){
  515. .name = "dspb_a_div",
  516. .ops = &clk_regmap_divider_ops,
  517. .parent_hws = (const struct clk_hw *[]) {
  518. &dspb_a_sel.hw
  519. },
  520. .num_parents = 1,
  521. .flags = CLK_SET_RATE_PARENT,
  522. },
  523. };
  524. static struct clk_regmap dspb_a = {
  525. .data = &(struct clk_regmap_gate_data){
  526. .offset = DSPB_CLK_CTRL0,
  527. .bit_idx = 13,
  528. },
  529. .hw.init = &(struct clk_init_data) {
  530. .name = "dspb_a",
  531. .ops = &clk_regmap_gate_ops,
  532. .parent_hws = (const struct clk_hw *[]) {
  533. &dspb_a_div.hw
  534. },
  535. .num_parents = 1,
  536. .flags = CLK_SET_RATE_PARENT,
  537. },
  538. };
  539. static struct clk_regmap dspb_b_sel = {
  540. .data = &(struct clk_regmap_mux_data){
  541. .offset = DSPB_CLK_CTRL0,
  542. .mask = 0x7,
  543. .shift = 26,
  544. .table = mux_table_dsp_ab,
  545. },
  546. .hw.init = &(struct clk_init_data){
  547. .name = "dspb_b_sel",
  548. .ops = &clk_regmap_mux_ops,
  549. .parent_data = dsp_ab_parent_data,
  550. .num_parents = ARRAY_SIZE(dsp_ab_parent_data),
  551. },
  552. };
  553. static struct clk_regmap dspb_b_div = {
  554. .data = &(struct clk_regmap_div_data){
  555. .offset = DSPB_CLK_CTRL0,
  556. .shift = 16,
  557. .width = 10,
  558. },
  559. .hw.init = &(struct clk_init_data){
  560. .name = "dspb_b_div",
  561. .ops = &clk_regmap_divider_ops,
  562. .parent_hws = (const struct clk_hw *[]) {
  563. &dspb_b_sel.hw
  564. },
  565. .num_parents = 1,
  566. .flags = CLK_SET_RATE_PARENT,
  567. },
  568. };
  569. static struct clk_regmap dspb_b = {
  570. .data = &(struct clk_regmap_gate_data){
  571. .offset = DSPB_CLK_CTRL0,
  572. .bit_idx = 29,
  573. },
  574. .hw.init = &(struct clk_init_data) {
  575. .name = "dspb_b",
  576. .ops = &clk_regmap_gate_ops,
  577. .parent_hws = (const struct clk_hw *[]) {
  578. &dspb_b_div.hw
  579. },
  580. .num_parents = 1,
  581. .flags = CLK_SET_RATE_PARENT,
  582. },
  583. };
  584. static struct clk_regmap dspb_sel = {
  585. .data = &(struct clk_regmap_mux_data){
  586. .offset = DSPB_CLK_CTRL0,
  587. .mask = 0x1,
  588. .shift = 15,
  589. },
  590. .hw.init = &(struct clk_init_data){
  591. .name = "dspb_sel",
  592. .ops = &clk_regmap_mux_ops,
  593. .parent_hws = (const struct clk_hw *[]) {
  594. &dspb_a.hw,
  595. &dspb_b.hw,
  596. },
  597. .num_parents = 2,
  598. .flags = CLK_SET_RATE_PARENT,
  599. },
  600. };
  601. static struct clk_regmap dspb_en = {
  602. .data = &(struct clk_regmap_gate_data){
  603. .offset = DSPB_CLK_EN,
  604. .bit_idx = 1,
  605. },
  606. .hw.init = &(struct clk_init_data) {
  607. .name = "dspb_en",
  608. .ops = &clk_regmap_gate_ops,
  609. .parent_hws = (const struct clk_hw *[]) {
  610. &dspb_sel.hw
  611. },
  612. .num_parents = 1,
  613. .flags = CLK_SET_RATE_PARENT,
  614. },
  615. };
  616. static struct clk_regmap dspb_en_nic = {
  617. .data = &(struct clk_regmap_gate_data){
  618. .offset = DSPB_CLK_EN,
  619. .bit_idx = 0,
  620. },
  621. .hw.init = &(struct clk_init_data) {
  622. .name = "dspb_en_nic",
  623. .ops = &clk_regmap_gate_ops,
  624. .parent_hws = (const struct clk_hw *[]) {
  625. &dspb_sel.hw
  626. },
  627. .num_parents = 1,
  628. .flags = CLK_SET_RATE_PARENT,
  629. },
  630. };
  631. static struct clk_regmap clk_24m = {
  632. .data = &(struct clk_regmap_gate_data){
  633. .offset = CLK12_24_CTRL,
  634. .bit_idx = 11,
  635. },
  636. .hw.init = &(struct clk_init_data) {
  637. .name = "24m",
  638. .ops = &clk_regmap_gate_ops,
  639. .parent_data = &(const struct clk_parent_data) {
  640. .fw_name = "xtal",
  641. },
  642. .num_parents = 1,
  643. },
  644. };
  645. static struct clk_fixed_factor clk_24m_div2 = {
  646. .mult = 1,
  647. .div = 2,
  648. .hw.init = &(struct clk_init_data){
  649. .name = "24m_div2",
  650. .ops = &clk_fixed_factor_ops,
  651. .parent_hws = (const struct clk_hw *[]) {
  652. &clk_24m.hw
  653. },
  654. .num_parents = 1,
  655. },
  656. };
  657. static struct clk_regmap clk_12m = {
  658. .data = &(struct clk_regmap_gate_data){
  659. .offset = CLK12_24_CTRL,
  660. .bit_idx = 10,
  661. },
  662. .hw.init = &(struct clk_init_data) {
  663. .name = "12m",
  664. .ops = &clk_regmap_gate_ops,
  665. .parent_hws = (const struct clk_hw *[]) {
  666. &clk_24m_div2.hw
  667. },
  668. .num_parents = 1,
  669. },
  670. };
  671. static struct clk_regmap fclk_div2_divn_pre = {
  672. .data = &(struct clk_regmap_div_data){
  673. .offset = CLK12_24_CTRL,
  674. .shift = 0,
  675. .width = 8,
  676. },
  677. .hw.init = &(struct clk_init_data){
  678. .name = "fclk_div2_divn_pre",
  679. .ops = &clk_regmap_divider_ops,
  680. .parent_data = &(const struct clk_parent_data) {
  681. .fw_name = "fclk_div2",
  682. },
  683. .num_parents = 1,
  684. },
  685. };
  686. static struct clk_regmap fclk_div2_divn = {
  687. .data = &(struct clk_regmap_gate_data){
  688. .offset = CLK12_24_CTRL,
  689. .bit_idx = 12,
  690. },
  691. .hw.init = &(struct clk_init_data){
  692. .name = "fclk_div2_divn",
  693. .ops = &clk_regmap_gate_ops,
  694. .parent_hws = (const struct clk_hw *[]) {
  695. &fclk_div2_divn_pre.hw
  696. },
  697. .num_parents = 1,
  698. .flags = CLK_SET_RATE_PARENT,
  699. },
  700. };
  701. /*
  702. * the index 2 is sys_pll_div16, it will be implemented in the CPU clock driver,
  703. * the index 4 is the clock measurement source, it's not supported yet
  704. */
  705. static u32 gen_table[] = { 0, 1, 3, 5, 6, 7, 8 };
  706. static const struct clk_parent_data gen_parent_data[] = {
  707. { .fw_name = "xtal", },
  708. { .hw = &rtc.hw },
  709. { .fw_name = "hifi_pll", },
  710. { .fw_name = "fclk_div2", },
  711. { .fw_name = "fclk_div3", },
  712. { .fw_name = "fclk_div5", },
  713. { .fw_name = "fclk_div7", },
  714. };
  715. static struct clk_regmap gen_sel = {
  716. .data = &(struct clk_regmap_mux_data){
  717. .offset = GEN_CLK_CTRL,
  718. .mask = 0xf,
  719. .shift = 12,
  720. .table = gen_table,
  721. },
  722. .hw.init = &(struct clk_init_data){
  723. .name = "gen_sel",
  724. .ops = &clk_regmap_mux_ops,
  725. .parent_data = gen_parent_data,
  726. .num_parents = ARRAY_SIZE(gen_parent_data),
  727. /*
  728. * The GEN clock can be connected to an external pad, so it
  729. * may be set up directly from the device tree. Additionally,
  730. * the GEN clock can be inherited from a more accurate RTC
  731. * clock, so in certain situations, it may be necessary
  732. * to freeze its parent.
  733. */
  734. .flags = CLK_SET_RATE_NO_REPARENT,
  735. },
  736. };
  737. static struct clk_regmap gen_div = {
  738. .data = &(struct clk_regmap_div_data){
  739. .offset = GEN_CLK_CTRL,
  740. .shift = 0,
  741. .width = 11,
  742. },
  743. .hw.init = &(struct clk_init_data){
  744. .name = "gen_div",
  745. .ops = &clk_regmap_divider_ops,
  746. .parent_hws = (const struct clk_hw *[]) {
  747. &gen_sel.hw
  748. },
  749. .num_parents = 1,
  750. .flags = CLK_SET_RATE_PARENT,
  751. },
  752. };
  753. static struct clk_regmap gen = {
  754. .data = &(struct clk_regmap_gate_data){
  755. .offset = GEN_CLK_CTRL,
  756. .bit_idx = 11,
  757. },
  758. .hw.init = &(struct clk_init_data) {
  759. .name = "gen",
  760. .ops = &clk_regmap_gate_ops,
  761. .parent_hws = (const struct clk_hw *[]) {
  762. &gen_div.hw
  763. },
  764. .num_parents = 1,
  765. .flags = CLK_SET_RATE_PARENT,
  766. },
  767. };
  768. static struct clk_regmap saradc_sel = {
  769. .data = &(struct clk_regmap_mux_data){
  770. .offset = SAR_ADC_CLK_CTRL,
  771. .mask = 0x1,
  772. .shift = 9,
  773. },
  774. .hw.init = &(struct clk_init_data){
  775. .name = "saradc_sel",
  776. .ops = &clk_regmap_mux_ops,
  777. .parent_data = (const struct clk_parent_data []) {
  778. { .fw_name = "xtal", },
  779. { .hw = &sys.hw, },
  780. },
  781. .num_parents = 2,
  782. },
  783. };
  784. static struct clk_regmap saradc_div = {
  785. .data = &(struct clk_regmap_div_data){
  786. .offset = SAR_ADC_CLK_CTRL,
  787. .shift = 0,
  788. .width = 8,
  789. },
  790. .hw.init = &(struct clk_init_data){
  791. .name = "saradc_div",
  792. .ops = &clk_regmap_divider_ops,
  793. .parent_hws = (const struct clk_hw *[]) {
  794. &saradc_sel.hw
  795. },
  796. .num_parents = 1,
  797. .flags = CLK_SET_RATE_PARENT,
  798. },
  799. };
  800. static struct clk_regmap saradc = {
  801. .data = &(struct clk_regmap_gate_data){
  802. .offset = SAR_ADC_CLK_CTRL,
  803. .bit_idx = 8,
  804. },
  805. .hw.init = &(struct clk_init_data) {
  806. .name = "saradc",
  807. .ops = &clk_regmap_gate_ops,
  808. .parent_hws = (const struct clk_hw *[]) {
  809. &saradc_div.hw
  810. },
  811. .num_parents = 1,
  812. .flags = CLK_SET_RATE_PARENT,
  813. },
  814. };
  815. static const struct clk_parent_data pwm_abcd_parents[] = {
  816. { .fw_name = "xtal", },
  817. { .hw = &sys.hw },
  818. { .hw = &rtc.hw },
  819. };
  820. static struct clk_regmap pwm_a_sel = {
  821. .data = &(struct clk_regmap_mux_data){
  822. .offset = PWM_CLK_AB_CTRL,
  823. .mask = 0x1,
  824. .shift = 9,
  825. },
  826. .hw.init = &(struct clk_init_data){
  827. .name = "pwm_a_sel",
  828. .ops = &clk_regmap_mux_ops,
  829. .parent_data = pwm_abcd_parents,
  830. .num_parents = ARRAY_SIZE(pwm_abcd_parents),
  831. },
  832. };
  833. static struct clk_regmap pwm_a_div = {
  834. .data = &(struct clk_regmap_div_data){
  835. .offset = PWM_CLK_AB_CTRL,
  836. .shift = 0,
  837. .width = 8,
  838. },
  839. .hw.init = &(struct clk_init_data){
  840. .name = "pwm_a_div",
  841. .ops = &clk_regmap_divider_ops,
  842. .parent_hws = (const struct clk_hw *[]) {
  843. &pwm_a_sel.hw
  844. },
  845. .num_parents = 1,
  846. .flags = CLK_SET_RATE_PARENT,
  847. },
  848. };
  849. static struct clk_regmap pwm_a = {
  850. .data = &(struct clk_regmap_gate_data){
  851. .offset = PWM_CLK_AB_CTRL,
  852. .bit_idx = 8,
  853. },
  854. .hw.init = &(struct clk_init_data) {
  855. .name = "pwm_a",
  856. .ops = &clk_regmap_gate_ops,
  857. .parent_hws = (const struct clk_hw *[]) {
  858. &pwm_a_div.hw
  859. },
  860. .num_parents = 1,
  861. .flags = CLK_SET_RATE_PARENT,
  862. },
  863. };
  864. static struct clk_regmap pwm_b_sel = {
  865. .data = &(struct clk_regmap_mux_data){
  866. .offset = PWM_CLK_AB_CTRL,
  867. .mask = 0x1,
  868. .shift = 25,
  869. },
  870. .hw.init = &(struct clk_init_data){
  871. .name = "pwm_b_sel",
  872. .ops = &clk_regmap_mux_ops,
  873. .parent_data = pwm_abcd_parents,
  874. .num_parents = ARRAY_SIZE(pwm_abcd_parents),
  875. },
  876. };
  877. static struct clk_regmap pwm_b_div = {
  878. .data = &(struct clk_regmap_div_data){
  879. .offset = PWM_CLK_AB_CTRL,
  880. .shift = 16,
  881. .width = 8,
  882. },
  883. .hw.init = &(struct clk_init_data){
  884. .name = "pwm_b_div",
  885. .ops = &clk_regmap_divider_ops,
  886. .parent_hws = (const struct clk_hw *[]) {
  887. &pwm_b_sel.hw
  888. },
  889. .num_parents = 1,
  890. .flags = CLK_SET_RATE_PARENT,
  891. },
  892. };
  893. static struct clk_regmap pwm_b = {
  894. .data = &(struct clk_regmap_gate_data){
  895. .offset = PWM_CLK_AB_CTRL,
  896. .bit_idx = 24,
  897. },
  898. .hw.init = &(struct clk_init_data) {
  899. .name = "pwm_b",
  900. .ops = &clk_regmap_gate_ops,
  901. .parent_hws = (const struct clk_hw *[]) {
  902. &pwm_b_div.hw
  903. },
  904. .num_parents = 1,
  905. .flags = CLK_SET_RATE_PARENT,
  906. },
  907. };
  908. static struct clk_regmap pwm_c_sel = {
  909. .data = &(struct clk_regmap_mux_data){
  910. .offset = PWM_CLK_CD_CTRL,
  911. .mask = 0x1,
  912. .shift = 9,
  913. },
  914. .hw.init = &(struct clk_init_data){
  915. .name = "pwm_c_sel",
  916. .ops = &clk_regmap_mux_ops,
  917. .parent_data = pwm_abcd_parents,
  918. .num_parents = ARRAY_SIZE(pwm_abcd_parents),
  919. },
  920. };
  921. static struct clk_regmap pwm_c_div = {
  922. .data = &(struct clk_regmap_div_data){
  923. .offset = PWM_CLK_CD_CTRL,
  924. .shift = 0,
  925. .width = 8,
  926. },
  927. .hw.init = &(struct clk_init_data){
  928. .name = "pwm_c_div",
  929. .ops = &clk_regmap_divider_ops,
  930. .parent_hws = (const struct clk_hw *[]) {
  931. &pwm_c_sel.hw
  932. },
  933. .num_parents = 1,
  934. .flags = CLK_SET_RATE_PARENT,
  935. },
  936. };
  937. static struct clk_regmap pwm_c = {
  938. .data = &(struct clk_regmap_gate_data){
  939. .offset = PWM_CLK_CD_CTRL,
  940. .bit_idx = 8,
  941. },
  942. .hw.init = &(struct clk_init_data) {
  943. .name = "pwm_c",
  944. .ops = &clk_regmap_gate_ops,
  945. .parent_hws = (const struct clk_hw *[]) {
  946. &pwm_c_div.hw
  947. },
  948. .num_parents = 1,
  949. .flags = CLK_SET_RATE_PARENT,
  950. },
  951. };
  952. static struct clk_regmap pwm_d_sel = {
  953. .data = &(struct clk_regmap_mux_data){
  954. .offset = PWM_CLK_CD_CTRL,
  955. .mask = 0x1,
  956. .shift = 25,
  957. },
  958. .hw.init = &(struct clk_init_data){
  959. .name = "pwm_d_sel",
  960. .ops = &clk_regmap_mux_ops,
  961. .parent_data = pwm_abcd_parents,
  962. .num_parents = ARRAY_SIZE(pwm_abcd_parents),
  963. },
  964. };
  965. static struct clk_regmap pwm_d_div = {
  966. .data = &(struct clk_regmap_div_data){
  967. .offset = PWM_CLK_CD_CTRL,
  968. .shift = 16,
  969. .width = 8,
  970. },
  971. .hw.init = &(struct clk_init_data){
  972. .name = "pwm_d_div",
  973. .ops = &clk_regmap_divider_ops,
  974. .parent_hws = (const struct clk_hw *[]) {
  975. &pwm_d_sel.hw
  976. },
  977. .num_parents = 1,
  978. .flags = CLK_SET_RATE_PARENT,
  979. },
  980. };
  981. static struct clk_regmap pwm_d = {
  982. .data = &(struct clk_regmap_gate_data){
  983. .offset = PWM_CLK_CD_CTRL,
  984. .bit_idx = 24,
  985. },
  986. .hw.init = &(struct clk_init_data) {
  987. .name = "pwm_d",
  988. .ops = &clk_regmap_gate_ops,
  989. .parent_hws = (const struct clk_hw *[]) {
  990. &pwm_d_div.hw
  991. },
  992. .num_parents = 1,
  993. .flags = CLK_SET_RATE_PARENT,
  994. },
  995. };
  996. static const struct clk_parent_data pwm_ef_parents[] = {
  997. { .fw_name = "xtal", },
  998. { .hw = &sys.hw },
  999. { .fw_name = "fclk_div5", },
  1000. { .hw = &rtc.hw },
  1001. };
  1002. static struct clk_regmap pwm_e_sel = {
  1003. .data = &(struct clk_regmap_mux_data){
  1004. .offset = PWM_CLK_EF_CTRL,
  1005. .mask = 0x3,
  1006. .shift = 9,
  1007. },
  1008. .hw.init = &(struct clk_init_data){
  1009. .name = "pwm_e_sel",
  1010. .ops = &clk_regmap_mux_ops,
  1011. .parent_data = pwm_ef_parents,
  1012. .num_parents = ARRAY_SIZE(pwm_ef_parents),
  1013. },
  1014. };
  1015. static struct clk_regmap pwm_e_div = {
  1016. .data = &(struct clk_regmap_div_data){
  1017. .offset = PWM_CLK_EF_CTRL,
  1018. .shift = 0,
  1019. .width = 8,
  1020. },
  1021. .hw.init = &(struct clk_init_data){
  1022. .name = "pwm_e_div",
  1023. .ops = &clk_regmap_divider_ops,
  1024. .parent_hws = (const struct clk_hw *[]) {
  1025. &pwm_e_sel.hw
  1026. },
  1027. .num_parents = 1,
  1028. .flags = CLK_SET_RATE_PARENT,
  1029. },
  1030. };
  1031. static struct clk_regmap pwm_e = {
  1032. .data = &(struct clk_regmap_gate_data){
  1033. .offset = PWM_CLK_EF_CTRL,
  1034. .bit_idx = 8,
  1035. },
  1036. .hw.init = &(struct clk_init_data) {
  1037. .name = "pwm_e",
  1038. .ops = &clk_regmap_gate_ops,
  1039. .parent_hws = (const struct clk_hw *[]) {
  1040. &pwm_e_div.hw
  1041. },
  1042. .num_parents = 1,
  1043. .flags = CLK_SET_RATE_PARENT,
  1044. },
  1045. };
  1046. static struct clk_regmap pwm_f_sel = {
  1047. .data = &(struct clk_regmap_mux_data){
  1048. .offset = PWM_CLK_EF_CTRL,
  1049. .mask = 0x3,
  1050. .shift = 25,
  1051. },
  1052. .hw.init = &(struct clk_init_data){
  1053. .name = "pwm_f_sel",
  1054. .ops = &clk_regmap_mux_ops,
  1055. .parent_data = pwm_ef_parents,
  1056. .num_parents = ARRAY_SIZE(pwm_ef_parents),
  1057. },
  1058. };
  1059. static struct clk_regmap pwm_f_div = {
  1060. .data = &(struct clk_regmap_div_data){
  1061. .offset = PWM_CLK_EF_CTRL,
  1062. .shift = 16,
  1063. .width = 8,
  1064. },
  1065. .hw.init = &(struct clk_init_data){
  1066. .name = "pwm_f_div",
  1067. .ops = &clk_regmap_divider_ops,
  1068. .parent_hws = (const struct clk_hw *[]) {
  1069. &pwm_f_sel.hw
  1070. },
  1071. .num_parents = 1,
  1072. .flags = CLK_SET_RATE_PARENT,
  1073. },
  1074. };
  1075. static struct clk_regmap pwm_f = {
  1076. .data = &(struct clk_regmap_gate_data){
  1077. .offset = PWM_CLK_EF_CTRL,
  1078. .bit_idx = 24,
  1079. },
  1080. .hw.init = &(struct clk_init_data) {
  1081. .name = "pwm_f",
  1082. .ops = &clk_regmap_gate_ops,
  1083. .parent_hws = (const struct clk_hw *[]) {
  1084. &pwm_f_div.hw
  1085. },
  1086. .num_parents = 1,
  1087. .flags = CLK_SET_RATE_PARENT,
  1088. },
  1089. };
  1090. /*
  1091. * spicc clk
  1092. * fdiv2 |\ |\ _____
  1093. * ---------| |---DIV--| | | | spicc out
  1094. * ---------| | | |-----|GATE |---------
  1095. * ..... |/ | / |_____|
  1096. * --------------------|/
  1097. * 24M
  1098. */
  1099. static const struct clk_parent_data spicc_spifc_parents[] = {
  1100. { .fw_name = "fclk_div2"},
  1101. { .fw_name = "fclk_div3"},
  1102. { .fw_name = "fclk_div5"},
  1103. { .fw_name = "hifi_pll" },
  1104. };
  1105. static struct clk_regmap spicc_sel = {
  1106. .data = &(struct clk_regmap_mux_data){
  1107. .offset = SPICC_CLK_CTRL,
  1108. .mask = 0x3,
  1109. .shift = 9,
  1110. },
  1111. .hw.init = &(struct clk_init_data){
  1112. .name = "spicc_sel",
  1113. .ops = &clk_regmap_mux_ops,
  1114. .parent_data = spicc_spifc_parents,
  1115. .num_parents = ARRAY_SIZE(spicc_spifc_parents),
  1116. },
  1117. };
  1118. static struct clk_regmap spicc_div = {
  1119. .data = &(struct clk_regmap_div_data){
  1120. .offset = SPICC_CLK_CTRL,
  1121. .shift = 0,
  1122. .width = 8,
  1123. },
  1124. .hw.init = &(struct clk_init_data){
  1125. .name = "spicc_div",
  1126. .ops = &clk_regmap_divider_ops,
  1127. .parent_hws = (const struct clk_hw *[]) {
  1128. &spicc_sel.hw
  1129. },
  1130. .num_parents = 1,
  1131. .flags = CLK_SET_RATE_PARENT,
  1132. },
  1133. };
  1134. static struct clk_regmap spicc_sel2 = {
  1135. .data = &(struct clk_regmap_mux_data){
  1136. .offset = SPICC_CLK_CTRL,
  1137. .mask = 0x1,
  1138. .shift = 15,
  1139. },
  1140. .hw.init = &(struct clk_init_data){
  1141. .name = "spicc_sel2",
  1142. .ops = &clk_regmap_mux_ops,
  1143. .parent_data = (const struct clk_parent_data []) {
  1144. { .hw = &spicc_div.hw },
  1145. { .fw_name = "xtal", },
  1146. },
  1147. .num_parents = 2,
  1148. .flags = CLK_SET_RATE_PARENT,
  1149. },
  1150. };
  1151. static struct clk_regmap spicc = {
  1152. .data = &(struct clk_regmap_gate_data){
  1153. .offset = SPICC_CLK_CTRL,
  1154. .bit_idx = 8,
  1155. },
  1156. .hw.init = &(struct clk_init_data) {
  1157. .name = "spicc",
  1158. .ops = &clk_regmap_gate_ops,
  1159. .parent_hws = (const struct clk_hw *[]) {
  1160. &spicc_sel2.hw
  1161. },
  1162. .num_parents = 1,
  1163. .flags = CLK_SET_RATE_PARENT,
  1164. },
  1165. };
  1166. static struct clk_regmap ts_div = {
  1167. .data = &(struct clk_regmap_div_data){
  1168. .offset = TS_CLK_CTRL,
  1169. .shift = 0,
  1170. .width = 8,
  1171. },
  1172. .hw.init = &(struct clk_init_data){
  1173. .name = "ts_div",
  1174. .ops = &clk_regmap_divider_ops,
  1175. .parent_data = &(const struct clk_parent_data) {
  1176. .fw_name = "xtal",
  1177. },
  1178. .num_parents = 1,
  1179. },
  1180. };
  1181. static struct clk_regmap ts = {
  1182. .data = &(struct clk_regmap_gate_data){
  1183. .offset = TS_CLK_CTRL,
  1184. .bit_idx = 8,
  1185. },
  1186. .hw.init = &(struct clk_init_data) {
  1187. .name = "ts",
  1188. .ops = &clk_regmap_gate_ops,
  1189. .parent_hws = (const struct clk_hw *[]) {
  1190. &ts_div.hw
  1191. },
  1192. .num_parents = 1,
  1193. .flags = CLK_SET_RATE_PARENT,
  1194. },
  1195. };
  1196. static struct clk_regmap spifc_sel = {
  1197. .data = &(struct clk_regmap_mux_data){
  1198. .offset = SPIFC_CLK_CTRL,
  1199. .mask = 0x3,
  1200. .shift = 9,
  1201. },
  1202. .hw.init = &(struct clk_init_data){
  1203. .name = "spifc_sel",
  1204. .ops = &clk_regmap_mux_ops,
  1205. .parent_data = spicc_spifc_parents,
  1206. .num_parents = ARRAY_SIZE(spicc_spifc_parents),
  1207. },
  1208. };
  1209. static struct clk_regmap spifc_div = {
  1210. .data = &(struct clk_regmap_div_data){
  1211. .offset = SPIFC_CLK_CTRL,
  1212. .shift = 0,
  1213. .width = 8,
  1214. },
  1215. .hw.init = &(struct clk_init_data){
  1216. .name = "spifc_div",
  1217. .ops = &clk_regmap_divider_ops,
  1218. .parent_hws = (const struct clk_hw *[]) {
  1219. &spifc_sel.hw
  1220. },
  1221. .num_parents = 1,
  1222. .flags = CLK_SET_RATE_PARENT,
  1223. },
  1224. };
  1225. static struct clk_regmap spifc_sel2 = {
  1226. .data = &(struct clk_regmap_mux_data){
  1227. .offset = SPIFC_CLK_CTRL,
  1228. .mask = 0x1,
  1229. .shift = 15,
  1230. },
  1231. .hw.init = &(struct clk_init_data){
  1232. .name = "spifc_sel2",
  1233. .ops = &clk_regmap_mux_ops,
  1234. .parent_data = (const struct clk_parent_data []) {
  1235. { .hw = &spifc_div.hw },
  1236. { .fw_name = "xtal", },
  1237. },
  1238. .num_parents = 2,
  1239. .flags = CLK_SET_RATE_PARENT,
  1240. },
  1241. };
  1242. static struct clk_regmap spifc = {
  1243. .data = &(struct clk_regmap_gate_data){
  1244. .offset = SPIFC_CLK_CTRL,
  1245. .bit_idx = 8,
  1246. },
  1247. .hw.init = &(struct clk_init_data) {
  1248. .name = "spifc",
  1249. .ops = &clk_regmap_gate_ops,
  1250. .parent_hws = (const struct clk_hw *[]) {
  1251. &spifc_sel2.hw
  1252. },
  1253. .num_parents = 1,
  1254. .flags = CLK_SET_RATE_PARENT,
  1255. },
  1256. };
  1257. static const struct clk_parent_data usb_bus_parents[] = {
  1258. { .fw_name = "xtal", },
  1259. { .hw = &sys.hw },
  1260. { .fw_name = "fclk_div3", },
  1261. { .fw_name = "fclk_div5", },
  1262. };
  1263. static struct clk_regmap usb_bus_sel = {
  1264. .data = &(struct clk_regmap_mux_data){
  1265. .offset = USB_BUSCLK_CTRL,
  1266. .mask = 0x3,
  1267. .shift = 9,
  1268. },
  1269. .hw.init = &(struct clk_init_data){
  1270. .name = "usb_bus_sel",
  1271. .ops = &clk_regmap_mux_ops,
  1272. .parent_data = usb_bus_parents,
  1273. .num_parents = ARRAY_SIZE(usb_bus_parents),
  1274. .flags = CLK_SET_RATE_PARENT,
  1275. },
  1276. };
  1277. static struct clk_regmap usb_bus_div = {
  1278. .data = &(struct clk_regmap_div_data){
  1279. .offset = USB_BUSCLK_CTRL,
  1280. .shift = 0,
  1281. .width = 8,
  1282. },
  1283. .hw.init = &(struct clk_init_data){
  1284. .name = "usb_bus_div",
  1285. .ops = &clk_regmap_divider_ops,
  1286. .parent_hws = (const struct clk_hw *[]) {
  1287. &usb_bus_sel.hw
  1288. },
  1289. .num_parents = 1,
  1290. .flags = CLK_SET_RATE_PARENT,
  1291. },
  1292. };
  1293. static struct clk_regmap usb_bus = {
  1294. .data = &(struct clk_regmap_gate_data){
  1295. .offset = USB_BUSCLK_CTRL,
  1296. .bit_idx = 8,
  1297. },
  1298. .hw.init = &(struct clk_init_data) {
  1299. .name = "usb_bus",
  1300. .ops = &clk_regmap_gate_ops,
  1301. .parent_hws = (const struct clk_hw *[]) {
  1302. &usb_bus_div.hw
  1303. },
  1304. .num_parents = 1,
  1305. .flags = CLK_SET_RATE_PARENT,
  1306. },
  1307. };
  1308. static const struct clk_parent_data sd_emmc_psram_dmc_parents[] = {
  1309. { .fw_name = "fclk_div2", },
  1310. { .fw_name = "fclk_div3", },
  1311. { .fw_name = "fclk_div5", },
  1312. { .fw_name = "hifi_pll", },
  1313. };
  1314. static struct clk_regmap sd_emmc_sel = {
  1315. .data = &(struct clk_regmap_mux_data){
  1316. .offset = SD_EMMC_CLK_CTRL,
  1317. .mask = 0x3,
  1318. .shift = 9,
  1319. },
  1320. .hw.init = &(struct clk_init_data){
  1321. .name = "sd_emmc_sel",
  1322. .ops = &clk_regmap_mux_ops,
  1323. .parent_data = sd_emmc_psram_dmc_parents,
  1324. .num_parents = ARRAY_SIZE(sd_emmc_psram_dmc_parents),
  1325. },
  1326. };
  1327. static struct clk_regmap sd_emmc_div = {
  1328. .data = &(struct clk_regmap_div_data){
  1329. .offset = SD_EMMC_CLK_CTRL,
  1330. .shift = 0,
  1331. .width = 8,
  1332. },
  1333. .hw.init = &(struct clk_init_data){
  1334. .name = "sd_emmc_div",
  1335. .ops = &clk_regmap_divider_ops,
  1336. .parent_hws = (const struct clk_hw *[]) {
  1337. &sd_emmc_sel.hw
  1338. },
  1339. .num_parents = 1,
  1340. .flags = CLK_SET_RATE_PARENT,
  1341. },
  1342. };
  1343. static struct clk_regmap sd_emmc_sel2 = {
  1344. .data = &(struct clk_regmap_mux_data){
  1345. .offset = SD_EMMC_CLK_CTRL,
  1346. .mask = 0x1,
  1347. .shift = 15,
  1348. },
  1349. .hw.init = &(struct clk_init_data){
  1350. .name = "sd_emmc_sel2",
  1351. .ops = &clk_regmap_mux_ops,
  1352. .parent_data = (const struct clk_parent_data []) {
  1353. { .hw = &sd_emmc_div.hw },
  1354. { .fw_name = "xtal", },
  1355. },
  1356. .num_parents = 2,
  1357. .flags = CLK_SET_RATE_PARENT,
  1358. },
  1359. };
  1360. static struct clk_regmap sd_emmc = {
  1361. .data = &(struct clk_regmap_gate_data){
  1362. .offset = SD_EMMC_CLK_CTRL,
  1363. .bit_idx = 8,
  1364. },
  1365. .hw.init = &(struct clk_init_data) {
  1366. .name = "sd_emmc",
  1367. .ops = &clk_regmap_gate_ops,
  1368. .parent_hws = (const struct clk_hw *[]) {
  1369. &sd_emmc_sel2.hw
  1370. },
  1371. .num_parents = 1,
  1372. .flags = CLK_SET_RATE_PARENT,
  1373. },
  1374. };
  1375. static struct clk_regmap psram_sel = {
  1376. .data = &(struct clk_regmap_mux_data){
  1377. .offset = PSRAM_CLK_CTRL,
  1378. .mask = 0x3,
  1379. .shift = 9,
  1380. },
  1381. .hw.init = &(struct clk_init_data){
  1382. .name = "psram_sel",
  1383. .ops = &clk_regmap_mux_ops,
  1384. .parent_data = sd_emmc_psram_dmc_parents,
  1385. .num_parents = ARRAY_SIZE(sd_emmc_psram_dmc_parents),
  1386. },
  1387. };
  1388. static struct clk_regmap psram_div = {
  1389. .data = &(struct clk_regmap_div_data){
  1390. .offset = PSRAM_CLK_CTRL,
  1391. .shift = 0,
  1392. .width = 8,
  1393. },
  1394. .hw.init = &(struct clk_init_data){
  1395. .name = "psram_div",
  1396. .ops = &clk_regmap_divider_ops,
  1397. .parent_hws = (const struct clk_hw *[]) {
  1398. &psram_sel.hw
  1399. },
  1400. .num_parents = 1,
  1401. .flags = CLK_SET_RATE_PARENT,
  1402. },
  1403. };
  1404. static struct clk_regmap psram_sel2 = {
  1405. .data = &(struct clk_regmap_mux_data){
  1406. .offset = PSRAM_CLK_CTRL,
  1407. .mask = 0x1,
  1408. .shift = 15,
  1409. },
  1410. .hw.init = &(struct clk_init_data){
  1411. .name = "psram_sel2",
  1412. .ops = &clk_regmap_mux_ops,
  1413. .parent_data = (const struct clk_parent_data []) {
  1414. { .hw = &psram_div.hw },
  1415. { .fw_name = "xtal", },
  1416. },
  1417. .num_parents = 2,
  1418. .flags = CLK_SET_RATE_PARENT,
  1419. },
  1420. };
  1421. static struct clk_regmap psram = {
  1422. .data = &(struct clk_regmap_gate_data){
  1423. .offset = PSRAM_CLK_CTRL,
  1424. .bit_idx = 8,
  1425. },
  1426. .hw.init = &(struct clk_init_data) {
  1427. .name = "psram",
  1428. .ops = &clk_regmap_gate_ops,
  1429. .parent_hws = (const struct clk_hw *[]) {
  1430. &psram_sel2.hw
  1431. },
  1432. .num_parents = 1,
  1433. .flags = CLK_SET_RATE_PARENT,
  1434. },
  1435. };
  1436. static struct clk_regmap dmc_sel = {
  1437. .data = &(struct clk_regmap_mux_data){
  1438. .offset = DMC_CLK_CTRL,
  1439. .mask = 0x3,
  1440. .shift = 9,
  1441. },
  1442. .hw.init = &(struct clk_init_data){
  1443. .name = "dmc_sel",
  1444. .ops = &clk_regmap_mux_ops,
  1445. .parent_data = sd_emmc_psram_dmc_parents,
  1446. .num_parents = ARRAY_SIZE(sd_emmc_psram_dmc_parents),
  1447. },
  1448. };
  1449. static struct clk_regmap dmc_div = {
  1450. .data = &(struct clk_regmap_div_data){
  1451. .offset = DMC_CLK_CTRL,
  1452. .shift = 0,
  1453. .width = 8,
  1454. },
  1455. .hw.init = &(struct clk_init_data){
  1456. .name = "dmc_div",
  1457. .ops = &clk_regmap_divider_ops,
  1458. .parent_hws = (const struct clk_hw *[]) {
  1459. &dmc_sel.hw
  1460. },
  1461. .num_parents = 1,
  1462. .flags = CLK_SET_RATE_PARENT,
  1463. },
  1464. };
  1465. static struct clk_regmap dmc_sel2 = {
  1466. .data = &(struct clk_regmap_mux_data){
  1467. .offset = DMC_CLK_CTRL,
  1468. .mask = 0x1,
  1469. .shift = 15,
  1470. },
  1471. .hw.init = &(struct clk_init_data){
  1472. .name = "dmc_sel2",
  1473. .ops = &clk_regmap_mux_ops,
  1474. .parent_data = (const struct clk_parent_data []) {
  1475. { .hw = &dmc_div.hw },
  1476. { .fw_name = "xtal", },
  1477. },
  1478. .num_parents = 2,
  1479. .flags = CLK_SET_RATE_PARENT,
  1480. },
  1481. };
  1482. static struct clk_regmap dmc = {
  1483. .data = &(struct clk_regmap_gate_data){
  1484. .offset = DMC_CLK_CTRL,
  1485. .bit_idx = 8,
  1486. },
  1487. .hw.init = &(struct clk_init_data) {
  1488. .name = "dmc",
  1489. .ops = &clk_regmap_gate_ro_ops,
  1490. .parent_hws = (const struct clk_hw *[]) {
  1491. &dmc_sel2.hw
  1492. },
  1493. .num_parents = 1,
  1494. .flags = CLK_SET_RATE_PARENT,
  1495. },
  1496. };
  1497. static struct clk_regmap ceca_32k_in = {
  1498. .data = &(struct clk_regmap_gate_data){
  1499. .offset = CECA_CLK_CTRL0,
  1500. .bit_idx = 31,
  1501. },
  1502. .hw.init = &(struct clk_init_data) {
  1503. .name = "ceca_32k_in",
  1504. .ops = &clk_regmap_gate_ops,
  1505. .parent_data = &(const struct clk_parent_data) {
  1506. .fw_name = "xtal",
  1507. },
  1508. .num_parents = 1,
  1509. },
  1510. };
  1511. static struct clk_regmap ceca_32k_div = {
  1512. .data = &(struct meson_clk_dualdiv_data){
  1513. .n1 = {
  1514. .reg_off = CECA_CLK_CTRL0,
  1515. .shift = 0,
  1516. .width = 12,
  1517. },
  1518. .n2 = {
  1519. .reg_off = CECA_CLK_CTRL0,
  1520. .shift = 12,
  1521. .width = 12,
  1522. },
  1523. .m1 = {
  1524. .reg_off = CECA_CLK_CTRL1,
  1525. .shift = 0,
  1526. .width = 12,
  1527. },
  1528. .m2 = {
  1529. .reg_off = CECA_CLK_CTRL1,
  1530. .shift = 12,
  1531. .width = 12,
  1532. },
  1533. .dual = {
  1534. .reg_off = CECA_CLK_CTRL0,
  1535. .shift = 28,
  1536. .width = 1,
  1537. },
  1538. .table = clk_32k_div_table,
  1539. },
  1540. .hw.init = &(struct clk_init_data){
  1541. .name = "ceca_32k_div",
  1542. .ops = &meson_clk_dualdiv_ops,
  1543. .parent_hws = (const struct clk_hw *[]) {
  1544. &ceca_32k_in.hw
  1545. },
  1546. .num_parents = 1,
  1547. },
  1548. };
  1549. static struct clk_regmap ceca_32k_sel_pre = {
  1550. .data = &(struct clk_regmap_mux_data) {
  1551. .offset = CECA_CLK_CTRL1,
  1552. .mask = 0x1,
  1553. .shift = 24,
  1554. .flags = CLK_MUX_ROUND_CLOSEST,
  1555. },
  1556. .hw.init = &(struct clk_init_data){
  1557. .name = "ceca_32k_sel_pre",
  1558. .ops = &clk_regmap_mux_ops,
  1559. .parent_hws = (const struct clk_hw *[]) {
  1560. &ceca_32k_div.hw,
  1561. &ceca_32k_in.hw,
  1562. },
  1563. .num_parents = 2,
  1564. .flags = CLK_SET_RATE_PARENT,
  1565. },
  1566. };
  1567. static struct clk_regmap ceca_32k_sel = {
  1568. .data = &(struct clk_regmap_mux_data) {
  1569. .offset = CECA_CLK_CTRL1,
  1570. .mask = 0x1,
  1571. .shift = 31,
  1572. .flags = CLK_MUX_ROUND_CLOSEST,
  1573. },
  1574. .hw.init = &(struct clk_init_data){
  1575. .name = "ceca_32k_sel",
  1576. .ops = &clk_regmap_mux_ops,
  1577. .parent_hws = (const struct clk_hw *[]) {
  1578. &ceca_32k_sel_pre.hw,
  1579. &rtc.hw,
  1580. },
  1581. .num_parents = 2,
  1582. },
  1583. };
  1584. static struct clk_regmap ceca_32k_out = {
  1585. .data = &(struct clk_regmap_gate_data){
  1586. .offset = CECA_CLK_CTRL0,
  1587. .bit_idx = 30,
  1588. },
  1589. .hw.init = &(struct clk_init_data){
  1590. .name = "ceca_32k_out",
  1591. .ops = &clk_regmap_gate_ops,
  1592. .parent_hws = (const struct clk_hw *[]) {
  1593. &ceca_32k_sel.hw
  1594. },
  1595. .num_parents = 1,
  1596. .flags = CLK_SET_RATE_PARENT,
  1597. },
  1598. };
  1599. static struct clk_regmap cecb_32k_in = {
  1600. .data = &(struct clk_regmap_gate_data){
  1601. .offset = CECB_CLK_CTRL0,
  1602. .bit_idx = 31,
  1603. },
  1604. .hw.init = &(struct clk_init_data) {
  1605. .name = "cecb_32k_in",
  1606. .ops = &clk_regmap_gate_ops,
  1607. .parent_data = &(const struct clk_parent_data) {
  1608. .fw_name = "xtal",
  1609. },
  1610. .num_parents = 1,
  1611. },
  1612. };
  1613. static struct clk_regmap cecb_32k_div = {
  1614. .data = &(struct meson_clk_dualdiv_data){
  1615. .n1 = {
  1616. .reg_off = CECB_CLK_CTRL0,
  1617. .shift = 0,
  1618. .width = 12,
  1619. },
  1620. .n2 = {
  1621. .reg_off = CECB_CLK_CTRL0,
  1622. .shift = 12,
  1623. .width = 12,
  1624. },
  1625. .m1 = {
  1626. .reg_off = CECB_CLK_CTRL1,
  1627. .shift = 0,
  1628. .width = 12,
  1629. },
  1630. .m2 = {
  1631. .reg_off = CECB_CLK_CTRL1,
  1632. .shift = 12,
  1633. .width = 12,
  1634. },
  1635. .dual = {
  1636. .reg_off = CECB_CLK_CTRL0,
  1637. .shift = 28,
  1638. .width = 1,
  1639. },
  1640. .table = clk_32k_div_table,
  1641. },
  1642. .hw.init = &(struct clk_init_data){
  1643. .name = "cecb_32k_div",
  1644. .ops = &meson_clk_dualdiv_ops,
  1645. .parent_hws = (const struct clk_hw *[]) {
  1646. &cecb_32k_in.hw
  1647. },
  1648. .num_parents = 1,
  1649. },
  1650. };
  1651. static struct clk_regmap cecb_32k_sel_pre = {
  1652. .data = &(struct clk_regmap_mux_data) {
  1653. .offset = CECB_CLK_CTRL1,
  1654. .mask = 0x1,
  1655. .shift = 24,
  1656. .flags = CLK_MUX_ROUND_CLOSEST,
  1657. },
  1658. .hw.init = &(struct clk_init_data){
  1659. .name = "cecb_32k_sel_pre",
  1660. .ops = &clk_regmap_mux_ops,
  1661. .parent_hws = (const struct clk_hw *[]) {
  1662. &cecb_32k_div.hw,
  1663. &cecb_32k_in.hw,
  1664. },
  1665. .num_parents = 2,
  1666. .flags = CLK_SET_RATE_PARENT,
  1667. },
  1668. };
  1669. static struct clk_regmap cecb_32k_sel = {
  1670. .data = &(struct clk_regmap_mux_data) {
  1671. .offset = CECB_CLK_CTRL1,
  1672. .mask = 0x1,
  1673. .shift = 31,
  1674. .flags = CLK_MUX_ROUND_CLOSEST,
  1675. },
  1676. .hw.init = &(struct clk_init_data){
  1677. .name = "cecb_32k_sel",
  1678. .ops = &clk_regmap_mux_ops,
  1679. .parent_hws = (const struct clk_hw *[]) {
  1680. &cecb_32k_sel_pre.hw,
  1681. &rtc.hw,
  1682. },
  1683. .num_parents = 2,
  1684. },
  1685. };
  1686. static struct clk_regmap cecb_32k_out = {
  1687. .data = &(struct clk_regmap_gate_data){
  1688. .offset = CECB_CLK_CTRL0,
  1689. .bit_idx = 30,
  1690. },
  1691. .hw.init = &(struct clk_init_data){
  1692. .name = "cecb_32k_out",
  1693. .ops = &clk_regmap_gate_ops,
  1694. .parent_hws = (const struct clk_hw *[]) {
  1695. &cecb_32k_sel.hw
  1696. },
  1697. .num_parents = 1,
  1698. .flags = CLK_SET_RATE_PARENT,
  1699. },
  1700. };
  1701. #define MESON_GATE(_name, _reg, _bit) \
  1702. MESON_PCLK(_name, _reg, _bit, &sys.hw)
  1703. static MESON_GATE(clktree, SYS_CLK_EN0, 0);
  1704. static MESON_GATE(reset_ctrl, SYS_CLK_EN0, 1);
  1705. static MESON_GATE(analog_ctrl, SYS_CLK_EN0, 2);
  1706. static MESON_GATE(pwr_ctrl, SYS_CLK_EN0, 3);
  1707. static MESON_GATE(pad_ctrl, SYS_CLK_EN0, 4);
  1708. static MESON_GATE(sys_ctrl, SYS_CLK_EN0, 5);
  1709. static MESON_GATE(temp_sensor, SYS_CLK_EN0, 6);
  1710. static MESON_GATE(am2axi_dev, SYS_CLK_EN0, 7);
  1711. static MESON_GATE(spicc_b, SYS_CLK_EN0, 8);
  1712. static MESON_GATE(spicc_a, SYS_CLK_EN0, 9);
  1713. static MESON_GATE(msr, SYS_CLK_EN0, 10);
  1714. static MESON_GATE(audio, SYS_CLK_EN0, 11);
  1715. static MESON_GATE(jtag_ctrl, SYS_CLK_EN0, 12);
  1716. static MESON_GATE(saradc_en, SYS_CLK_EN0, 13);
  1717. static MESON_GATE(pwm_ef, SYS_CLK_EN0, 14);
  1718. static MESON_GATE(pwm_cd, SYS_CLK_EN0, 15);
  1719. static MESON_GATE(pwm_ab, SYS_CLK_EN0, 16);
  1720. static MESON_GATE(cec, SYS_CLK_EN0, 17);
  1721. static MESON_GATE(i2c_s, SYS_CLK_EN0, 18);
  1722. static MESON_GATE(ir_ctrl, SYS_CLK_EN0, 19);
  1723. static MESON_GATE(i2c_m_d, SYS_CLK_EN0, 20);
  1724. static MESON_GATE(i2c_m_c, SYS_CLK_EN0, 21);
  1725. static MESON_GATE(i2c_m_b, SYS_CLK_EN0, 22);
  1726. static MESON_GATE(i2c_m_a, SYS_CLK_EN0, 23);
  1727. static MESON_GATE(acodec, SYS_CLK_EN0, 24);
  1728. static MESON_GATE(otp, SYS_CLK_EN0, 25);
  1729. static MESON_GATE(sd_emmc_a, SYS_CLK_EN0, 26);
  1730. static MESON_GATE(usb_phy, SYS_CLK_EN0, 27);
  1731. static MESON_GATE(usb_ctrl, SYS_CLK_EN0, 28);
  1732. static MESON_GATE(sys_dspb, SYS_CLK_EN0, 29);
  1733. static MESON_GATE(sys_dspa, SYS_CLK_EN0, 30);
  1734. static MESON_GATE(dma, SYS_CLK_EN0, 31);
  1735. static MESON_GATE(irq_ctrl, SYS_CLK_EN1, 0);
  1736. static MESON_GATE(nic, SYS_CLK_EN1, 1);
  1737. static MESON_GATE(gic, SYS_CLK_EN1, 2);
  1738. static MESON_GATE(uart_c, SYS_CLK_EN1, 3);
  1739. static MESON_GATE(uart_b, SYS_CLK_EN1, 4);
  1740. static MESON_GATE(uart_a, SYS_CLK_EN1, 5);
  1741. static MESON_GATE(sys_psram, SYS_CLK_EN1, 6);
  1742. static MESON_GATE(rsa, SYS_CLK_EN1, 8);
  1743. static MESON_GATE(coresight, SYS_CLK_EN1, 9);
  1744. static MESON_GATE(am2axi_vad, AXI_CLK_EN, 0);
  1745. static MESON_GATE(audio_vad, AXI_CLK_EN, 1);
  1746. static MESON_GATE(axi_dmc, AXI_CLK_EN, 3);
  1747. static MESON_GATE(axi_psram, AXI_CLK_EN, 4);
  1748. static MESON_GATE(ramb, AXI_CLK_EN, 5);
  1749. static MESON_GATE(rama, AXI_CLK_EN, 6);
  1750. static MESON_GATE(axi_spifc, AXI_CLK_EN, 7);
  1751. static MESON_GATE(axi_nic, AXI_CLK_EN, 8);
  1752. static MESON_GATE(axi_dma, AXI_CLK_EN, 9);
  1753. static MESON_GATE(cpu_ctrl, AXI_CLK_EN, 10);
  1754. static MESON_GATE(rom, AXI_CLK_EN, 11);
  1755. static MESON_GATE(prod_i2c, AXI_CLK_EN, 12);
  1756. /* Array of all clocks registered by this provider */
  1757. static struct clk_hw *a1_periphs_hw_clks[] = {
  1758. [CLKID_XTAL_IN] = &xtal_in.hw,
  1759. [CLKID_FIXPLL_IN] = &fixpll_in.hw,
  1760. [CLKID_USB_PHY_IN] = &usb_phy_in.hw,
  1761. [CLKID_USB_CTRL_IN] = &usb_ctrl_in.hw,
  1762. [CLKID_HIFIPLL_IN] = &hifipll_in.hw,
  1763. [CLKID_SYSPLL_IN] = &syspll_in.hw,
  1764. [CLKID_DDS_IN] = &dds_in.hw,
  1765. [CLKID_SYS] = &sys.hw,
  1766. [CLKID_CLKTREE] = &clktree.hw,
  1767. [CLKID_RESET_CTRL] = &reset_ctrl.hw,
  1768. [CLKID_ANALOG_CTRL] = &analog_ctrl.hw,
  1769. [CLKID_PWR_CTRL] = &pwr_ctrl.hw,
  1770. [CLKID_PAD_CTRL] = &pad_ctrl.hw,
  1771. [CLKID_SYS_CTRL] = &sys_ctrl.hw,
  1772. [CLKID_TEMP_SENSOR] = &temp_sensor.hw,
  1773. [CLKID_AM2AXI_DIV] = &am2axi_dev.hw,
  1774. [CLKID_SPICC_B] = &spicc_b.hw,
  1775. [CLKID_SPICC_A] = &spicc_a.hw,
  1776. [CLKID_MSR] = &msr.hw,
  1777. [CLKID_AUDIO] = &audio.hw,
  1778. [CLKID_JTAG_CTRL] = &jtag_ctrl.hw,
  1779. [CLKID_SARADC_EN] = &saradc_en.hw,
  1780. [CLKID_PWM_EF] = &pwm_ef.hw,
  1781. [CLKID_PWM_CD] = &pwm_cd.hw,
  1782. [CLKID_PWM_AB] = &pwm_ab.hw,
  1783. [CLKID_CEC] = &cec.hw,
  1784. [CLKID_I2C_S] = &i2c_s.hw,
  1785. [CLKID_IR_CTRL] = &ir_ctrl.hw,
  1786. [CLKID_I2C_M_D] = &i2c_m_d.hw,
  1787. [CLKID_I2C_M_C] = &i2c_m_c.hw,
  1788. [CLKID_I2C_M_B] = &i2c_m_b.hw,
  1789. [CLKID_I2C_M_A] = &i2c_m_a.hw,
  1790. [CLKID_ACODEC] = &acodec.hw,
  1791. [CLKID_OTP] = &otp.hw,
  1792. [CLKID_SD_EMMC_A] = &sd_emmc_a.hw,
  1793. [CLKID_USB_PHY] = &usb_phy.hw,
  1794. [CLKID_USB_CTRL] = &usb_ctrl.hw,
  1795. [CLKID_SYS_DSPB] = &sys_dspb.hw,
  1796. [CLKID_SYS_DSPA] = &sys_dspa.hw,
  1797. [CLKID_DMA] = &dma.hw,
  1798. [CLKID_IRQ_CTRL] = &irq_ctrl.hw,
  1799. [CLKID_NIC] = &nic.hw,
  1800. [CLKID_GIC] = &gic.hw,
  1801. [CLKID_UART_C] = &uart_c.hw,
  1802. [CLKID_UART_B] = &uart_b.hw,
  1803. [CLKID_UART_A] = &uart_a.hw,
  1804. [CLKID_SYS_PSRAM] = &sys_psram.hw,
  1805. [CLKID_RSA] = &rsa.hw,
  1806. [CLKID_CORESIGHT] = &coresight.hw,
  1807. [CLKID_AM2AXI_VAD] = &am2axi_vad.hw,
  1808. [CLKID_AUDIO_VAD] = &audio_vad.hw,
  1809. [CLKID_AXI_DMC] = &axi_dmc.hw,
  1810. [CLKID_AXI_PSRAM] = &axi_psram.hw,
  1811. [CLKID_RAMB] = &ramb.hw,
  1812. [CLKID_RAMA] = &rama.hw,
  1813. [CLKID_AXI_SPIFC] = &axi_spifc.hw,
  1814. [CLKID_AXI_NIC] = &axi_nic.hw,
  1815. [CLKID_AXI_DMA] = &axi_dma.hw,
  1816. [CLKID_CPU_CTRL] = &cpu_ctrl.hw,
  1817. [CLKID_ROM] = &rom.hw,
  1818. [CLKID_PROC_I2C] = &prod_i2c.hw,
  1819. [CLKID_DSPA_SEL] = &dspa_sel.hw,
  1820. [CLKID_DSPB_SEL] = &dspb_sel.hw,
  1821. [CLKID_DSPA_EN] = &dspa_en.hw,
  1822. [CLKID_DSPA_EN_NIC] = &dspa_en_nic.hw,
  1823. [CLKID_DSPB_EN] = &dspb_en.hw,
  1824. [CLKID_DSPB_EN_NIC] = &dspb_en_nic.hw,
  1825. [CLKID_RTC] = &rtc.hw,
  1826. [CLKID_CECA_32K] = &ceca_32k_out.hw,
  1827. [CLKID_CECB_32K] = &cecb_32k_out.hw,
  1828. [CLKID_24M] = &clk_24m.hw,
  1829. [CLKID_12M] = &clk_12m.hw,
  1830. [CLKID_FCLK_DIV2_DIVN] = &fclk_div2_divn.hw,
  1831. [CLKID_GEN] = &gen.hw,
  1832. [CLKID_SARADC_SEL] = &saradc_sel.hw,
  1833. [CLKID_SARADC] = &saradc.hw,
  1834. [CLKID_PWM_A] = &pwm_a.hw,
  1835. [CLKID_PWM_B] = &pwm_b.hw,
  1836. [CLKID_PWM_C] = &pwm_c.hw,
  1837. [CLKID_PWM_D] = &pwm_d.hw,
  1838. [CLKID_PWM_E] = &pwm_e.hw,
  1839. [CLKID_PWM_F] = &pwm_f.hw,
  1840. [CLKID_SPICC] = &spicc.hw,
  1841. [CLKID_TS] = &ts.hw,
  1842. [CLKID_SPIFC] = &spifc.hw,
  1843. [CLKID_USB_BUS] = &usb_bus.hw,
  1844. [CLKID_SD_EMMC] = &sd_emmc.hw,
  1845. [CLKID_PSRAM] = &psram.hw,
  1846. [CLKID_DMC] = &dmc.hw,
  1847. [CLKID_SYS_A_SEL] = &sys_a_sel.hw,
  1848. [CLKID_SYS_A_DIV] = &sys_a_div.hw,
  1849. [CLKID_SYS_A] = &sys_a.hw,
  1850. [CLKID_SYS_B_SEL] = &sys_b_sel.hw,
  1851. [CLKID_SYS_B_DIV] = &sys_b_div.hw,
  1852. [CLKID_SYS_B] = &sys_b.hw,
  1853. [CLKID_DSPA_A_SEL] = &dspa_a_sel.hw,
  1854. [CLKID_DSPA_A_DIV] = &dspa_a_div.hw,
  1855. [CLKID_DSPA_A] = &dspa_a.hw,
  1856. [CLKID_DSPA_B_SEL] = &dspa_b_sel.hw,
  1857. [CLKID_DSPA_B_DIV] = &dspa_b_div.hw,
  1858. [CLKID_DSPA_B] = &dspa_b.hw,
  1859. [CLKID_DSPB_A_SEL] = &dspb_a_sel.hw,
  1860. [CLKID_DSPB_A_DIV] = &dspb_a_div.hw,
  1861. [CLKID_DSPB_A] = &dspb_a.hw,
  1862. [CLKID_DSPB_B_SEL] = &dspb_b_sel.hw,
  1863. [CLKID_DSPB_B_DIV] = &dspb_b_div.hw,
  1864. [CLKID_DSPB_B] = &dspb_b.hw,
  1865. [CLKID_RTC_32K_IN] = &rtc_32k_in.hw,
  1866. [CLKID_RTC_32K_DIV] = &rtc_32k_div.hw,
  1867. [CLKID_RTC_32K_XTAL] = &rtc_32k_xtal.hw,
  1868. [CLKID_RTC_32K_SEL] = &rtc_32k_sel.hw,
  1869. [CLKID_CECB_32K_IN] = &cecb_32k_in.hw,
  1870. [CLKID_CECB_32K_DIV] = &cecb_32k_div.hw,
  1871. [CLKID_CECB_32K_SEL_PRE] = &cecb_32k_sel_pre.hw,
  1872. [CLKID_CECB_32K_SEL] = &cecb_32k_sel.hw,
  1873. [CLKID_CECA_32K_IN] = &ceca_32k_in.hw,
  1874. [CLKID_CECA_32K_DIV] = &ceca_32k_div.hw,
  1875. [CLKID_CECA_32K_SEL_PRE] = &ceca_32k_sel_pre.hw,
  1876. [CLKID_CECA_32K_SEL] = &ceca_32k_sel.hw,
  1877. [CLKID_DIV2_PRE] = &fclk_div2_divn_pre.hw,
  1878. [CLKID_24M_DIV2] = &clk_24m_div2.hw,
  1879. [CLKID_GEN_SEL] = &gen_sel.hw,
  1880. [CLKID_GEN_DIV] = &gen_div.hw,
  1881. [CLKID_SARADC_DIV] = &saradc_div.hw,
  1882. [CLKID_PWM_A_SEL] = &pwm_a_sel.hw,
  1883. [CLKID_PWM_A_DIV] = &pwm_a_div.hw,
  1884. [CLKID_PWM_B_SEL] = &pwm_b_sel.hw,
  1885. [CLKID_PWM_B_DIV] = &pwm_b_div.hw,
  1886. [CLKID_PWM_C_SEL] = &pwm_c_sel.hw,
  1887. [CLKID_PWM_C_DIV] = &pwm_c_div.hw,
  1888. [CLKID_PWM_D_SEL] = &pwm_d_sel.hw,
  1889. [CLKID_PWM_D_DIV] = &pwm_d_div.hw,
  1890. [CLKID_PWM_E_SEL] = &pwm_e_sel.hw,
  1891. [CLKID_PWM_E_DIV] = &pwm_e_div.hw,
  1892. [CLKID_PWM_F_SEL] = &pwm_f_sel.hw,
  1893. [CLKID_PWM_F_DIV] = &pwm_f_div.hw,
  1894. [CLKID_SPICC_SEL] = &spicc_sel.hw,
  1895. [CLKID_SPICC_DIV] = &spicc_div.hw,
  1896. [CLKID_SPICC_SEL2] = &spicc_sel2.hw,
  1897. [CLKID_TS_DIV] = &ts_div.hw,
  1898. [CLKID_SPIFC_SEL] = &spifc_sel.hw,
  1899. [CLKID_SPIFC_DIV] = &spifc_div.hw,
  1900. [CLKID_SPIFC_SEL2] = &spifc_sel2.hw,
  1901. [CLKID_USB_BUS_SEL] = &usb_bus_sel.hw,
  1902. [CLKID_USB_BUS_DIV] = &usb_bus_div.hw,
  1903. [CLKID_SD_EMMC_SEL] = &sd_emmc_sel.hw,
  1904. [CLKID_SD_EMMC_DIV] = &sd_emmc_div.hw,
  1905. [CLKID_SD_EMMC_SEL2] = &sd_emmc_sel2.hw,
  1906. [CLKID_PSRAM_SEL] = &psram_sel.hw,
  1907. [CLKID_PSRAM_DIV] = &psram_div.hw,
  1908. [CLKID_PSRAM_SEL2] = &psram_sel2.hw,
  1909. [CLKID_DMC_SEL] = &dmc_sel.hw,
  1910. [CLKID_DMC_DIV] = &dmc_div.hw,
  1911. [CLKID_DMC_SEL2] = &dmc_sel2.hw,
  1912. };
  1913. /* Convenience table to populate regmap in .probe */
  1914. static struct clk_regmap *const a1_periphs_regmaps[] = {
  1915. &xtal_in,
  1916. &fixpll_in,
  1917. &usb_phy_in,
  1918. &usb_ctrl_in,
  1919. &hifipll_in,
  1920. &syspll_in,
  1921. &dds_in,
  1922. &sys,
  1923. &clktree,
  1924. &reset_ctrl,
  1925. &analog_ctrl,
  1926. &pwr_ctrl,
  1927. &pad_ctrl,
  1928. &sys_ctrl,
  1929. &temp_sensor,
  1930. &am2axi_dev,
  1931. &spicc_b,
  1932. &spicc_a,
  1933. &msr,
  1934. &audio,
  1935. &jtag_ctrl,
  1936. &saradc_en,
  1937. &pwm_ef,
  1938. &pwm_cd,
  1939. &pwm_ab,
  1940. &cec,
  1941. &i2c_s,
  1942. &ir_ctrl,
  1943. &i2c_m_d,
  1944. &i2c_m_c,
  1945. &i2c_m_b,
  1946. &i2c_m_a,
  1947. &acodec,
  1948. &otp,
  1949. &sd_emmc_a,
  1950. &usb_phy,
  1951. &usb_ctrl,
  1952. &sys_dspb,
  1953. &sys_dspa,
  1954. &dma,
  1955. &irq_ctrl,
  1956. &nic,
  1957. &gic,
  1958. &uart_c,
  1959. &uart_b,
  1960. &uart_a,
  1961. &sys_psram,
  1962. &rsa,
  1963. &coresight,
  1964. &am2axi_vad,
  1965. &audio_vad,
  1966. &axi_dmc,
  1967. &axi_psram,
  1968. &ramb,
  1969. &rama,
  1970. &axi_spifc,
  1971. &axi_nic,
  1972. &axi_dma,
  1973. &cpu_ctrl,
  1974. &rom,
  1975. &prod_i2c,
  1976. &dspa_sel,
  1977. &dspb_sel,
  1978. &dspa_en,
  1979. &dspa_en_nic,
  1980. &dspb_en,
  1981. &dspb_en_nic,
  1982. &rtc,
  1983. &ceca_32k_out,
  1984. &cecb_32k_out,
  1985. &clk_24m,
  1986. &clk_12m,
  1987. &fclk_div2_divn,
  1988. &gen,
  1989. &saradc_sel,
  1990. &saradc,
  1991. &pwm_a,
  1992. &pwm_b,
  1993. &pwm_c,
  1994. &pwm_d,
  1995. &pwm_e,
  1996. &pwm_f,
  1997. &spicc,
  1998. &ts,
  1999. &spifc,
  2000. &usb_bus,
  2001. &sd_emmc,
  2002. &psram,
  2003. &dmc,
  2004. &sys_a_sel,
  2005. &sys_a_div,
  2006. &sys_a,
  2007. &sys_b_sel,
  2008. &sys_b_div,
  2009. &sys_b,
  2010. &dspa_a_sel,
  2011. &dspa_a_div,
  2012. &dspa_a,
  2013. &dspa_b_sel,
  2014. &dspa_b_div,
  2015. &dspa_b,
  2016. &dspb_a_sel,
  2017. &dspb_a_div,
  2018. &dspb_a,
  2019. &dspb_b_sel,
  2020. &dspb_b_div,
  2021. &dspb_b,
  2022. &rtc_32k_in,
  2023. &rtc_32k_div,
  2024. &rtc_32k_xtal,
  2025. &rtc_32k_sel,
  2026. &cecb_32k_in,
  2027. &cecb_32k_div,
  2028. &cecb_32k_sel_pre,
  2029. &cecb_32k_sel,
  2030. &ceca_32k_in,
  2031. &ceca_32k_div,
  2032. &ceca_32k_sel_pre,
  2033. &ceca_32k_sel,
  2034. &fclk_div2_divn_pre,
  2035. &gen_sel,
  2036. &gen_div,
  2037. &saradc_div,
  2038. &pwm_a_sel,
  2039. &pwm_a_div,
  2040. &pwm_b_sel,
  2041. &pwm_b_div,
  2042. &pwm_c_sel,
  2043. &pwm_c_div,
  2044. &pwm_d_sel,
  2045. &pwm_d_div,
  2046. &pwm_e_sel,
  2047. &pwm_e_div,
  2048. &pwm_f_sel,
  2049. &pwm_f_div,
  2050. &spicc_sel,
  2051. &spicc_div,
  2052. &spicc_sel2,
  2053. &ts_div,
  2054. &spifc_sel,
  2055. &spifc_div,
  2056. &spifc_sel2,
  2057. &usb_bus_sel,
  2058. &usb_bus_div,
  2059. &sd_emmc_sel,
  2060. &sd_emmc_div,
  2061. &sd_emmc_sel2,
  2062. &psram_sel,
  2063. &psram_div,
  2064. &psram_sel2,
  2065. &dmc_sel,
  2066. &dmc_div,
  2067. &dmc_sel2,
  2068. };
  2069. static const struct regmap_config a1_periphs_regmap_cfg = {
  2070. .reg_bits = 32,
  2071. .val_bits = 32,
  2072. .reg_stride = 4,
  2073. .max_register = DMC_CLK_CTRL,
  2074. };
  2075. static struct meson_clk_hw_data a1_periphs_clks = {
  2076. .hws = a1_periphs_hw_clks,
  2077. .num = ARRAY_SIZE(a1_periphs_hw_clks),
  2078. };
  2079. static int meson_a1_periphs_probe(struct platform_device *pdev)
  2080. {
  2081. struct device *dev = &pdev->dev;
  2082. void __iomem *base;
  2083. struct regmap *map;
  2084. int clkid, i, err;
  2085. base = devm_platform_ioremap_resource(pdev, 0);
  2086. if (IS_ERR(base))
  2087. return dev_err_probe(dev, PTR_ERR(base),
  2088. "can't ioremap resource\n");
  2089. map = devm_regmap_init_mmio(dev, base, &a1_periphs_regmap_cfg);
  2090. if (IS_ERR(map))
  2091. return dev_err_probe(dev, PTR_ERR(map),
  2092. "can't init regmap mmio region\n");
  2093. /* Populate regmap for the regmap backed clocks */
  2094. for (i = 0; i < ARRAY_SIZE(a1_periphs_regmaps); i++)
  2095. a1_periphs_regmaps[i]->map = map;
  2096. for (clkid = 0; clkid < a1_periphs_clks.num; clkid++) {
  2097. err = devm_clk_hw_register(dev, a1_periphs_clks.hws[clkid]);
  2098. if (err)
  2099. return dev_err_probe(dev, err,
  2100. "clock[%d] registration failed\n",
  2101. clkid);
  2102. }
  2103. return devm_of_clk_add_hw_provider(dev, meson_clk_hw_get, &a1_periphs_clks);
  2104. }
  2105. static const struct of_device_id a1_periphs_clkc_match_table[] = {
  2106. { .compatible = "amlogic,a1-peripherals-clkc", },
  2107. {}
  2108. };
  2109. MODULE_DEVICE_TABLE(of, a1_periphs_clkc_match_table);
  2110. static struct platform_driver a1_periphs_clkc_driver = {
  2111. .probe = meson_a1_periphs_probe,
  2112. .driver = {
  2113. .name = "a1-peripherals-clkc",
  2114. .of_match_table = a1_periphs_clkc_match_table,
  2115. },
  2116. };
  2117. module_platform_driver(a1_periphs_clkc_driver);
  2118. MODULE_DESCRIPTION("Amlogic A1 Peripherals Clock Controller driver");
  2119. MODULE_AUTHOR("Jian Hu <jian.hu@amlogic.com>");
  2120. MODULE_AUTHOR("Dmitry Rokosov <ddrokosov@sberdevices.ru>");
  2121. MODULE_LICENSE("GPL");
  2122. MODULE_IMPORT_NS(CLK_MESON);