c3-peripherals.c 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Amlogic C3 Peripherals Clock Controller Driver
  4. *
  5. * Copyright (c) 2023 Amlogic, inc.
  6. * Author: Chuan Liu <chuan.liu@amlogic.com>
  7. */
  8. #include <linux/clk-provider.h>
  9. #include <linux/platform_device.h>
  10. #include "clk-regmap.h"
  11. #include "clk-dualdiv.h"
  12. #include "meson-clkc-utils.h"
  13. #include <dt-bindings/clock/amlogic,c3-peripherals-clkc.h>
  14. #define RTC_BY_OSCIN_CTRL0 0x8
  15. #define RTC_BY_OSCIN_CTRL1 0xc
  16. #define RTC_CTRL 0x10
  17. #define SYS_CLK_EN0_REG0 0x44
  18. #define SYS_CLK_EN0_REG1 0x48
  19. #define SYS_CLK_EN0_REG2 0x4c
  20. #define CLK12_24_CTRL 0xa8
  21. #define AXI_CLK_EN0 0xac
  22. #define VDIN_MEAS_CLK_CTRL 0xf8
  23. #define VAPB_CLK_CTRL 0xfc
  24. #define MIPIDSI_PHY_CLK_CTRL 0x104
  25. #define GE2D_CLK_CTRL 0x10c
  26. #define ISP0_CLK_CTRL 0x110
  27. #define DEWARPA_CLK_CTRL 0x114
  28. #define VOUTENC_CLK_CTRL 0x118
  29. #define VDEC_CLK_CTRL 0x140
  30. #define VDEC3_CLK_CTRL 0x148
  31. #define TS_CLK_CTRL 0x158
  32. #define ETH_CLK_CTRL 0x164
  33. #define NAND_CLK_CTRL 0x168
  34. #define SD_EMMC_CLK_CTRL 0x16c
  35. #define SPICC_CLK_CTRL 0x174
  36. #define GEN_CLK_CTRL 0x178
  37. #define SAR_CLK_CTRL0 0x17c
  38. #define PWM_CLK_AB_CTRL 0x180
  39. #define PWM_CLK_CD_CTRL 0x184
  40. #define PWM_CLK_EF_CTRL 0x188
  41. #define PWM_CLK_GH_CTRL 0x18c
  42. #define PWM_CLK_IJ_CTRL 0x190
  43. #define PWM_CLK_KL_CTRL 0x194
  44. #define PWM_CLK_MN_CTRL 0x198
  45. #define VC9000E_CLK_CTRL 0x19c
  46. #define SPIFC_CLK_CTRL 0x1a0
  47. #define NNA_CLK_CTRL 0x220
  48. static struct clk_regmap rtc_xtal_clkin = {
  49. .data = &(struct clk_regmap_gate_data) {
  50. .offset = RTC_BY_OSCIN_CTRL0,
  51. .bit_idx = 31,
  52. },
  53. .hw.init = &(struct clk_init_data) {
  54. .name = "rtc_xtal_clkin",
  55. .ops = &clk_regmap_gate_ops,
  56. .parent_data = &(const struct clk_parent_data) {
  57. .fw_name = "oscin",
  58. },
  59. .num_parents = 1,
  60. },
  61. };
  62. static const struct meson_clk_dualdiv_param rtc_32k_div_table[] = {
  63. { 733, 732, 8, 11, 1 },
  64. { /* sentinel */ }
  65. };
  66. static struct clk_regmap rtc_32k_div = {
  67. .data = &(struct meson_clk_dualdiv_data) {
  68. .n1 = {
  69. .reg_off = RTC_BY_OSCIN_CTRL0,
  70. .shift = 0,
  71. .width = 12,
  72. },
  73. .n2 = {
  74. .reg_off = RTC_BY_OSCIN_CTRL0,
  75. .shift = 12,
  76. .width = 12,
  77. },
  78. .m1 = {
  79. .reg_off = RTC_BY_OSCIN_CTRL1,
  80. .shift = 0,
  81. .width = 12,
  82. },
  83. .m2 = {
  84. .reg_off = RTC_BY_OSCIN_CTRL1,
  85. .shift = 12,
  86. .width = 12,
  87. },
  88. .dual = {
  89. .reg_off = RTC_BY_OSCIN_CTRL0,
  90. .shift = 28,
  91. .width = 1,
  92. },
  93. .table = rtc_32k_div_table,
  94. },
  95. .hw.init = &(struct clk_init_data) {
  96. .name = "rtc_32k_div",
  97. .ops = &meson_clk_dualdiv_ops,
  98. .parent_hws = (const struct clk_hw *[]) {
  99. &rtc_xtal_clkin.hw
  100. },
  101. .num_parents = 1,
  102. },
  103. };
  104. static const struct clk_parent_data rtc_32k_mux_parent_data[] = {
  105. { .hw = &rtc_32k_div.hw },
  106. { .hw = &rtc_xtal_clkin.hw }
  107. };
  108. static struct clk_regmap rtc_32k_mux = {
  109. .data = &(struct clk_regmap_mux_data) {
  110. .offset = RTC_BY_OSCIN_CTRL1,
  111. .mask = 0x1,
  112. .shift = 24,
  113. },
  114. .hw.init = &(struct clk_init_data) {
  115. .name = "rtc_32k_mux",
  116. .ops = &clk_regmap_mux_ops,
  117. .parent_data = rtc_32k_mux_parent_data,
  118. .num_parents = ARRAY_SIZE(rtc_32k_mux_parent_data),
  119. .flags = CLK_SET_RATE_PARENT,
  120. },
  121. };
  122. static struct clk_regmap rtc_32k = {
  123. .data = &(struct clk_regmap_gate_data) {
  124. .offset = RTC_BY_OSCIN_CTRL0,
  125. .bit_idx = 30,
  126. },
  127. .hw.init = &(struct clk_init_data) {
  128. .name = "rtc_32k",
  129. .ops = &clk_regmap_gate_ops,
  130. .parent_hws = (const struct clk_hw *[]) {
  131. &rtc_32k_mux.hw
  132. },
  133. .num_parents = 1,
  134. .flags = CLK_SET_RATE_PARENT,
  135. },
  136. };
  137. static const struct clk_parent_data rtc_clk_mux_parent_data[] = {
  138. { .fw_name = "oscin" },
  139. { .hw = &rtc_32k.hw },
  140. { .fw_name = "pad_osc" }
  141. };
  142. static struct clk_regmap rtc_clk = {
  143. .data = &(struct clk_regmap_mux_data) {
  144. .offset = RTC_CTRL,
  145. .mask = 0x3,
  146. .shift = 0,
  147. },
  148. .hw.init = &(struct clk_init_data) {
  149. .name = "rtc_clk",
  150. .ops = &clk_regmap_mux_ops,
  151. .parent_data = rtc_clk_mux_parent_data,
  152. .num_parents = ARRAY_SIZE(rtc_clk_mux_parent_data),
  153. .flags = CLK_SET_RATE_PARENT,
  154. },
  155. };
  156. #define C3_CLK_GATE(_name, _reg, _bit, _fw_name, _ops, _flags) \
  157. struct clk_regmap _name = { \
  158. .data = &(struct clk_regmap_gate_data){ \
  159. .offset = (_reg), \
  160. .bit_idx = (_bit), \
  161. }, \
  162. .hw.init = &(struct clk_init_data) { \
  163. .name = #_name, \
  164. .ops = _ops, \
  165. .parent_data = &(const struct clk_parent_data) { \
  166. .fw_name = #_fw_name, \
  167. }, \
  168. .num_parents = 1, \
  169. .flags = (_flags), \
  170. }, \
  171. }
  172. #define C3_SYS_GATE(_name, _reg, _bit, _flags) \
  173. C3_CLK_GATE(_name, _reg, _bit, sysclk, \
  174. &clk_regmap_gate_ops, _flags)
  175. #define C3_SYS_GATE_RO(_name, _reg, _bit) \
  176. C3_CLK_GATE(_name, _reg, _bit, sysclk, \
  177. &clk_regmap_gate_ro_ops, 0)
  178. static C3_SYS_GATE(sys_reset_ctrl, SYS_CLK_EN0_REG0, 1, 0);
  179. static C3_SYS_GATE(sys_pwr_ctrl, SYS_CLK_EN0_REG0, 3, 0);
  180. static C3_SYS_GATE(sys_pad_ctrl, SYS_CLK_EN0_REG0, 4, 0);
  181. static C3_SYS_GATE(sys_ctrl, SYS_CLK_EN0_REG0, 5, 0);
  182. static C3_SYS_GATE(sys_ts_pll, SYS_CLK_EN0_REG0, 6, 0);
  183. /*
  184. * NOTE: sys_dev_arb provides the clock to the ETH and SPICC arbiters that
  185. * access the AXI bus.
  186. */
  187. static C3_SYS_GATE(sys_dev_arb, SYS_CLK_EN0_REG0, 7, 0);
  188. /*
  189. * FIXME: sys_mmc_pclk provides the clock for the DDR PHY, DDR will only be
  190. * initialized in bl2, and this clock should not be touched in linux.
  191. */
  192. static C3_SYS_GATE_RO(sys_mmc_pclk, SYS_CLK_EN0_REG0, 8);
  193. /*
  194. * NOTE: sys_cpu_ctrl provides the clock for CPU controller. After clock is
  195. * disabled, cpu_clk and other key CPU-related configurations cannot take effect.
  196. */
  197. static C3_SYS_GATE(sys_cpu_ctrl, SYS_CLK_EN0_REG0, 11, CLK_IS_CRITICAL);
  198. static C3_SYS_GATE(sys_jtag_ctrl, SYS_CLK_EN0_REG0, 12, 0);
  199. static C3_SYS_GATE(sys_ir_ctrl, SYS_CLK_EN0_REG0, 13, 0);
  200. /*
  201. * NOTE: sys_irq_ctrl provides the clock for IRQ controller. The IRQ controller
  202. * collects and distributes the interrupt signal to the GIC, PWR_CTRL, and
  203. * AOCPU. If the clock is disabled, interrupt-related functions will occurs an
  204. * exception.
  205. */
  206. static C3_SYS_GATE(sys_irq_ctrl, SYS_CLK_EN0_REG0, 14, CLK_IS_CRITICAL);
  207. static C3_SYS_GATE(sys_msr_clk, SYS_CLK_EN0_REG0, 15, 0);
  208. static C3_SYS_GATE(sys_rom, SYS_CLK_EN0_REG0, 16, 0);
  209. static C3_SYS_GATE(sys_uart_f, SYS_CLK_EN0_REG0, 17, 0);
  210. static C3_SYS_GATE(sys_cpu_apb, SYS_CLK_EN0_REG0, 18, 0);
  211. static C3_SYS_GATE(sys_rsa, SYS_CLK_EN0_REG0, 19, 0);
  212. static C3_SYS_GATE(sys_sar_adc, SYS_CLK_EN0_REG0, 20, 0);
  213. static C3_SYS_GATE(sys_startup, SYS_CLK_EN0_REG0, 21, 0);
  214. static C3_SYS_GATE(sys_secure, SYS_CLK_EN0_REG0, 22, 0);
  215. static C3_SYS_GATE(sys_spifc, SYS_CLK_EN0_REG0, 23, 0);
  216. static C3_SYS_GATE(sys_nna, SYS_CLK_EN0_REG0, 25, 0);
  217. static C3_SYS_GATE(sys_eth_mac, SYS_CLK_EN0_REG0, 26, 0);
  218. /*
  219. * FIXME: sys_gic provides the clock for GIC(Generic Interrupt Controller).
  220. * After clock is disabled, The GIC cannot work properly. At present, the driver
  221. * used by our GIC is the public driver in kernel, and there is no management
  222. * clock in the driver.
  223. */
  224. static C3_SYS_GATE(sys_gic, SYS_CLK_EN0_REG0, 27, CLK_IS_CRITICAL);
  225. static C3_SYS_GATE(sys_rama, SYS_CLK_EN0_REG0, 28, 0);
  226. /*
  227. * NOTE: sys_big_nic provides the clock to the control bus of the NIC(Network
  228. * Interface Controller) between multiple devices(CPU, DDR, RAM, ROM, GIC,
  229. * SPIFC, CAPU, JTAG, EMMC, SDIO, sec_top, USB, Audio, ETH, SPICC) in the
  230. * system. After clock is disabled, The NIC cannot work.
  231. */
  232. static C3_SYS_GATE(sys_big_nic, SYS_CLK_EN0_REG0, 29, CLK_IS_CRITICAL);
  233. static C3_SYS_GATE(sys_ramb, SYS_CLK_EN0_REG0, 30, 0);
  234. static C3_SYS_GATE(sys_audio_pclk, SYS_CLK_EN0_REG0, 31, 0);
  235. static C3_SYS_GATE(sys_pwm_kl, SYS_CLK_EN0_REG1, 0, 0);
  236. static C3_SYS_GATE(sys_pwm_ij, SYS_CLK_EN0_REG1, 1, 0);
  237. static C3_SYS_GATE(sys_usb, SYS_CLK_EN0_REG1, 2, 0);
  238. static C3_SYS_GATE(sys_sd_emmc_a, SYS_CLK_EN0_REG1, 3, 0);
  239. static C3_SYS_GATE(sys_sd_emmc_c, SYS_CLK_EN0_REG1, 4, 0);
  240. static C3_SYS_GATE(sys_pwm_ab, SYS_CLK_EN0_REG1, 5, 0);
  241. static C3_SYS_GATE(sys_pwm_cd, SYS_CLK_EN0_REG1, 6, 0);
  242. static C3_SYS_GATE(sys_pwm_ef, SYS_CLK_EN0_REG1, 7, 0);
  243. static C3_SYS_GATE(sys_pwm_gh, SYS_CLK_EN0_REG1, 8, 0);
  244. static C3_SYS_GATE(sys_spicc_1, SYS_CLK_EN0_REG1, 9, 0);
  245. static C3_SYS_GATE(sys_spicc_0, SYS_CLK_EN0_REG1, 10, 0);
  246. static C3_SYS_GATE(sys_uart_a, SYS_CLK_EN0_REG1, 11, 0);
  247. static C3_SYS_GATE(sys_uart_b, SYS_CLK_EN0_REG1, 12, 0);
  248. static C3_SYS_GATE(sys_uart_c, SYS_CLK_EN0_REG1, 13, 0);
  249. static C3_SYS_GATE(sys_uart_d, SYS_CLK_EN0_REG1, 14, 0);
  250. static C3_SYS_GATE(sys_uart_e, SYS_CLK_EN0_REG1, 15, 0);
  251. static C3_SYS_GATE(sys_i2c_m_a, SYS_CLK_EN0_REG1, 16, 0);
  252. static C3_SYS_GATE(sys_i2c_m_b, SYS_CLK_EN0_REG1, 17, 0);
  253. static C3_SYS_GATE(sys_i2c_m_c, SYS_CLK_EN0_REG1, 18, 0);
  254. static C3_SYS_GATE(sys_i2c_m_d, SYS_CLK_EN0_REG1, 19, 0);
  255. static C3_SYS_GATE(sys_i2c_s_a, SYS_CLK_EN0_REG1, 20, 0);
  256. static C3_SYS_GATE(sys_rtc, SYS_CLK_EN0_REG1, 21, 0);
  257. static C3_SYS_GATE(sys_ge2d, SYS_CLK_EN0_REG1, 22, 0);
  258. static C3_SYS_GATE(sys_isp, SYS_CLK_EN0_REG1, 23, 0);
  259. static C3_SYS_GATE(sys_gpv_isp_nic, SYS_CLK_EN0_REG1, 24, 0);
  260. static C3_SYS_GATE(sys_gpv_cve_nic, SYS_CLK_EN0_REG1, 25, 0);
  261. static C3_SYS_GATE(sys_mipi_dsi_host, SYS_CLK_EN0_REG1, 26, 0);
  262. static C3_SYS_GATE(sys_mipi_dsi_phy, SYS_CLK_EN0_REG1, 27, 0);
  263. static C3_SYS_GATE(sys_eth_phy, SYS_CLK_EN0_REG1, 28, 0);
  264. static C3_SYS_GATE(sys_acodec, SYS_CLK_EN0_REG1, 29, 0);
  265. static C3_SYS_GATE(sys_dwap, SYS_CLK_EN0_REG1, 30, 0);
  266. static C3_SYS_GATE(sys_dos, SYS_CLK_EN0_REG1, 31, 0);
  267. static C3_SYS_GATE(sys_cve, SYS_CLK_EN0_REG2, 0, 0);
  268. static C3_SYS_GATE(sys_vout, SYS_CLK_EN0_REG2, 1, 0);
  269. static C3_SYS_GATE(sys_vc9000e, SYS_CLK_EN0_REG2, 2, 0);
  270. static C3_SYS_GATE(sys_pwm_mn, SYS_CLK_EN0_REG2, 3, 0);
  271. static C3_SYS_GATE(sys_sd_emmc_b, SYS_CLK_EN0_REG2, 4, 0);
  272. #define C3_AXI_GATE(_name, _reg, _bit, _flags) \
  273. C3_CLK_GATE(_name, _reg, _bit, axiclk, \
  274. &clk_regmap_gate_ops, _flags)
  275. /*
  276. * NOTE: axi_sys_nic provides the clock to the AXI bus of the system NIC. After
  277. * clock is disabled, The NIC cannot work.
  278. */
  279. static C3_AXI_GATE(axi_sys_nic, AXI_CLK_EN0, 2, CLK_IS_CRITICAL);
  280. static C3_AXI_GATE(axi_isp_nic, AXI_CLK_EN0, 3, 0);
  281. static C3_AXI_GATE(axi_cve_nic, AXI_CLK_EN0, 4, 0);
  282. static C3_AXI_GATE(axi_ramb, AXI_CLK_EN0, 5, 0);
  283. static C3_AXI_GATE(axi_rama, AXI_CLK_EN0, 6, 0);
  284. /*
  285. * NOTE: axi_cpu_dmc provides the clock to the AXI bus where the CPU accesses
  286. * the DDR. After clock is disabled, The CPU will not have access to the DDR.
  287. */
  288. static C3_AXI_GATE(axi_cpu_dmc, AXI_CLK_EN0, 7, CLK_IS_CRITICAL);
  289. static C3_AXI_GATE(axi_nic, AXI_CLK_EN0, 8, 0);
  290. static C3_AXI_GATE(axi_dma, AXI_CLK_EN0, 9, 0);
  291. /*
  292. * NOTE: axi_mux_nic provides the clock to the NIC's AXI bus for NN(Neural
  293. * Network) and other devices(CPU, EMMC, SDIO, sec_top, USB, Audio, ETH, SPICC)
  294. * to access RAM space.
  295. */
  296. static C3_AXI_GATE(axi_mux_nic, AXI_CLK_EN0, 10, 0);
  297. static C3_AXI_GATE(axi_cve, AXI_CLK_EN0, 12, 0);
  298. /*
  299. * NOTE: axi_dev1_dmc provides the clock for the peripherals(EMMC, SDIO,
  300. * sec_top, USB, Audio, ETH, SPICC) to access the AXI bus of the DDR.
  301. */
  302. static C3_AXI_GATE(axi_dev1_dmc, AXI_CLK_EN0, 13, 0);
  303. static C3_AXI_GATE(axi_dev0_dmc, AXI_CLK_EN0, 14, 0);
  304. static C3_AXI_GATE(axi_dsp_dmc, AXI_CLK_EN0, 15, 0);
  305. /*
  306. * clk_12_24m model
  307. *
  308. * |------| |-----| clk_12m_24m |-----|
  309. * xtal---->| gate |---->| div |------------>| pad |
  310. * |------| |-----| |-----|
  311. */
  312. static struct clk_regmap clk_12_24m_in = {
  313. .data = &(struct clk_regmap_gate_data) {
  314. .offset = CLK12_24_CTRL,
  315. .bit_idx = 11,
  316. },
  317. .hw.init = &(struct clk_init_data) {
  318. .name = "clk_12_24m_in",
  319. .ops = &clk_regmap_gate_ops,
  320. .parent_data = &(const struct clk_parent_data) {
  321. .fw_name = "xtal_24m",
  322. },
  323. .num_parents = 1,
  324. },
  325. };
  326. static struct clk_regmap clk_12_24m = {
  327. .data = &(struct clk_regmap_div_data) {
  328. .offset = CLK12_24_CTRL,
  329. .shift = 10,
  330. .width = 1,
  331. },
  332. .hw.init = &(struct clk_init_data) {
  333. .name = "clk_12_24m",
  334. .ops = &clk_regmap_divider_ops,
  335. .parent_hws = (const struct clk_hw *[]) {
  336. &clk_12_24m_in.hw
  337. },
  338. .num_parents = 1,
  339. },
  340. };
  341. /* Fix me: set value 0 will div by 2 like value 1 */
  342. static struct clk_regmap fclk_25m_div = {
  343. .data = &(struct clk_regmap_div_data) {
  344. .offset = CLK12_24_CTRL,
  345. .shift = 0,
  346. .width = 8,
  347. },
  348. .hw.init = &(struct clk_init_data) {
  349. .name = "fclk_25m_div",
  350. .ops = &clk_regmap_divider_ops,
  351. .parent_data = &(const struct clk_parent_data) {
  352. .fw_name = "fix",
  353. },
  354. .num_parents = 1,
  355. },
  356. };
  357. static struct clk_regmap fclk_25m = {
  358. .data = &(struct clk_regmap_gate_data) {
  359. .offset = CLK12_24_CTRL,
  360. .bit_idx = 12,
  361. },
  362. .hw.init = &(struct clk_init_data) {
  363. .name = "fclk_25m",
  364. .ops = &clk_regmap_gate_ops,
  365. .parent_hws = (const struct clk_hw *[]) {
  366. &fclk_25m_div.hw
  367. },
  368. .num_parents = 1,
  369. .flags = CLK_SET_RATE_PARENT,
  370. },
  371. };
  372. /*
  373. * Channel 3(ddr_dpll_pt_clk) is manged by the DDR module; channel 12(cts_msr_clk)
  374. * is manged by clock measures module. Their hardware are out of clock tree.
  375. * Channel 4 8 9 10 11 13 14 15 16 18 are not connected.
  376. */
  377. static u32 gen_parent_table[] = { 0, 1, 2, 5, 6, 7, 17, 19, 20, 21, 22, 23, 24};
  378. static const struct clk_parent_data gen_parent_data[] = {
  379. { .fw_name = "oscin" },
  380. { .hw = &rtc_clk.hw },
  381. { .fw_name = "sysplldiv16" },
  382. { .fw_name = "gp0" },
  383. { .fw_name = "gp1" },
  384. { .fw_name = "hifi" },
  385. { .fw_name = "cpudiv16" },
  386. { .fw_name = "fdiv2" },
  387. { .fw_name = "fdiv2p5" },
  388. { .fw_name = "fdiv3" },
  389. { .fw_name = "fdiv4" },
  390. { .fw_name = "fdiv5" },
  391. { .fw_name = "fdiv7" }
  392. };
  393. static struct clk_regmap gen_sel = {
  394. .data = &(struct clk_regmap_mux_data) {
  395. .offset = GEN_CLK_CTRL,
  396. .mask = 0x1f,
  397. .shift = 12,
  398. .table = gen_parent_table,
  399. },
  400. .hw.init = &(struct clk_init_data) {
  401. .name = "gen_sel",
  402. .ops = &clk_regmap_mux_ops,
  403. .parent_data = gen_parent_data,
  404. .num_parents = ARRAY_SIZE(gen_parent_data),
  405. },
  406. };
  407. static struct clk_regmap gen_div = {
  408. .data = &(struct clk_regmap_div_data) {
  409. .offset = GEN_CLK_CTRL,
  410. .shift = 0,
  411. .width = 11,
  412. },
  413. .hw.init = &(struct clk_init_data) {
  414. .name = "gen_div",
  415. .ops = &clk_regmap_divider_ops,
  416. .parent_hws = (const struct clk_hw *[]) {
  417. &gen_sel.hw
  418. },
  419. .num_parents = 1,
  420. .flags = CLK_SET_RATE_PARENT,
  421. },
  422. };
  423. static struct clk_regmap gen = {
  424. .data = &(struct clk_regmap_gate_data) {
  425. .offset = GEN_CLK_CTRL,
  426. .bit_idx = 11,
  427. },
  428. .hw.init = &(struct clk_init_data) {
  429. .name = "gen",
  430. .ops = &clk_regmap_gate_ops,
  431. .parent_hws = (const struct clk_hw *[]) {
  432. &gen_div.hw
  433. },
  434. .num_parents = 1,
  435. .flags = CLK_SET_RATE_PARENT,
  436. },
  437. };
  438. static const struct clk_parent_data saradc_parent_data[] = {
  439. { .fw_name = "oscin" },
  440. { .fw_name = "sysclk" }
  441. };
  442. static struct clk_regmap saradc_sel = {
  443. .data = &(struct clk_regmap_mux_data) {
  444. .offset = SAR_CLK_CTRL0,
  445. .mask = 0x1,
  446. .shift = 9,
  447. },
  448. .hw.init = &(struct clk_init_data) {
  449. .name = "saradc_sel",
  450. .ops = &clk_regmap_mux_ops,
  451. .parent_data = saradc_parent_data,
  452. .num_parents = ARRAY_SIZE(saradc_parent_data),
  453. },
  454. };
  455. static struct clk_regmap saradc_div = {
  456. .data = &(struct clk_regmap_div_data) {
  457. .offset = SAR_CLK_CTRL0,
  458. .shift = 0,
  459. .width = 8,
  460. },
  461. .hw.init = &(struct clk_init_data) {
  462. .name = "saradc_div",
  463. .ops = &clk_regmap_divider_ops,
  464. .parent_hws = (const struct clk_hw *[]) {
  465. &saradc_sel.hw
  466. },
  467. .num_parents = 1,
  468. .flags = CLK_SET_RATE_PARENT,
  469. },
  470. };
  471. static struct clk_regmap saradc = {
  472. .data = &(struct clk_regmap_gate_data) {
  473. .offset = SAR_CLK_CTRL0,
  474. .bit_idx = 8,
  475. },
  476. .hw.init = &(struct clk_init_data) {
  477. .name = "saradc",
  478. .ops = &clk_regmap_gate_ops,
  479. .parent_hws = (const struct clk_hw *[]) {
  480. &saradc_div.hw
  481. },
  482. .num_parents = 1,
  483. .flags = CLK_SET_RATE_PARENT,
  484. },
  485. };
  486. static const struct clk_parent_data pwm_parent_data[] = {
  487. { .fw_name = "oscin" },
  488. { .fw_name = "gp1" },
  489. { .fw_name = "fdiv4" },
  490. { .fw_name = "fdiv3" }
  491. };
  492. #define AML_PWM_CLK_MUX(_name, _reg, _shift) { \
  493. .data = &(struct clk_regmap_mux_data) { \
  494. .offset = _reg, \
  495. .mask = 0x3, \
  496. .shift = _shift, \
  497. }, \
  498. .hw.init = &(struct clk_init_data) { \
  499. .name = #_name "_sel", \
  500. .ops = &clk_regmap_mux_ops, \
  501. .parent_data = pwm_parent_data, \
  502. .num_parents = ARRAY_SIZE(pwm_parent_data), \
  503. }, \
  504. }
  505. #define AML_PWM_CLK_DIV(_name, _reg, _shift) { \
  506. .data = &(struct clk_regmap_div_data) { \
  507. .offset = _reg, \
  508. .shift = _shift, \
  509. .width = 8, \
  510. }, \
  511. .hw.init = &(struct clk_init_data) { \
  512. .name = #_name "_div", \
  513. .ops = &clk_regmap_divider_ops, \
  514. .parent_names = (const char *[]) { #_name "_sel" },\
  515. .num_parents = 1, \
  516. .flags = CLK_SET_RATE_PARENT, \
  517. }, \
  518. }
  519. #define AML_PWM_CLK_GATE(_name, _reg, _bit) { \
  520. .data = &(struct clk_regmap_gate_data) { \
  521. .offset = _reg, \
  522. .bit_idx = _bit, \
  523. }, \
  524. .hw.init = &(struct clk_init_data) { \
  525. .name = #_name, \
  526. .ops = &clk_regmap_gate_ops, \
  527. .parent_names = (const char *[]) { #_name "_div" },\
  528. .num_parents = 1, \
  529. .flags = CLK_SET_RATE_PARENT, \
  530. }, \
  531. }
  532. static struct clk_regmap pwm_a_sel =
  533. AML_PWM_CLK_MUX(pwm_a, PWM_CLK_AB_CTRL, 9);
  534. static struct clk_regmap pwm_a_div =
  535. AML_PWM_CLK_DIV(pwm_a, PWM_CLK_AB_CTRL, 0);
  536. static struct clk_regmap pwm_a =
  537. AML_PWM_CLK_GATE(pwm_a, PWM_CLK_AB_CTRL, 8);
  538. static struct clk_regmap pwm_b_sel =
  539. AML_PWM_CLK_MUX(pwm_b, PWM_CLK_AB_CTRL, 25);
  540. static struct clk_regmap pwm_b_div =
  541. AML_PWM_CLK_DIV(pwm_b, PWM_CLK_AB_CTRL, 16);
  542. static struct clk_regmap pwm_b =
  543. AML_PWM_CLK_GATE(pwm_b, PWM_CLK_AB_CTRL, 24);
  544. static struct clk_regmap pwm_c_sel =
  545. AML_PWM_CLK_MUX(pwm_c, PWM_CLK_CD_CTRL, 9);
  546. static struct clk_regmap pwm_c_div =
  547. AML_PWM_CLK_DIV(pwm_c, PWM_CLK_CD_CTRL, 0);
  548. static struct clk_regmap pwm_c =
  549. AML_PWM_CLK_GATE(pwm_c, PWM_CLK_CD_CTRL, 8);
  550. static struct clk_regmap pwm_d_sel =
  551. AML_PWM_CLK_MUX(pwm_d, PWM_CLK_CD_CTRL, 25);
  552. static struct clk_regmap pwm_d_div =
  553. AML_PWM_CLK_DIV(pwm_d, PWM_CLK_CD_CTRL, 16);
  554. static struct clk_regmap pwm_d =
  555. AML_PWM_CLK_GATE(pwm_d, PWM_CLK_CD_CTRL, 24);
  556. static struct clk_regmap pwm_e_sel =
  557. AML_PWM_CLK_MUX(pwm_e, PWM_CLK_EF_CTRL, 9);
  558. static struct clk_regmap pwm_e_div =
  559. AML_PWM_CLK_DIV(pwm_e, PWM_CLK_EF_CTRL, 0);
  560. static struct clk_regmap pwm_e =
  561. AML_PWM_CLK_GATE(pwm_e, PWM_CLK_EF_CTRL, 8);
  562. static struct clk_regmap pwm_f_sel =
  563. AML_PWM_CLK_MUX(pwm_f, PWM_CLK_EF_CTRL, 25);
  564. static struct clk_regmap pwm_f_div =
  565. AML_PWM_CLK_DIV(pwm_f, PWM_CLK_EF_CTRL, 16);
  566. static struct clk_regmap pwm_f =
  567. AML_PWM_CLK_GATE(pwm_f, PWM_CLK_EF_CTRL, 24);
  568. static struct clk_regmap pwm_g_sel =
  569. AML_PWM_CLK_MUX(pwm_g, PWM_CLK_GH_CTRL, 9);
  570. static struct clk_regmap pwm_g_div =
  571. AML_PWM_CLK_DIV(pwm_g, PWM_CLK_GH_CTRL, 0);
  572. static struct clk_regmap pwm_g =
  573. AML_PWM_CLK_GATE(pwm_g, PWM_CLK_GH_CTRL, 8);
  574. static struct clk_regmap pwm_h_sel =
  575. AML_PWM_CLK_MUX(pwm_h, PWM_CLK_GH_CTRL, 25);
  576. static struct clk_regmap pwm_h_div =
  577. AML_PWM_CLK_DIV(pwm_h, PWM_CLK_GH_CTRL, 16);
  578. static struct clk_regmap pwm_h =
  579. AML_PWM_CLK_GATE(pwm_h, PWM_CLK_GH_CTRL, 24);
  580. static struct clk_regmap pwm_i_sel =
  581. AML_PWM_CLK_MUX(pwm_i, PWM_CLK_IJ_CTRL, 9);
  582. static struct clk_regmap pwm_i_div =
  583. AML_PWM_CLK_DIV(pwm_i, PWM_CLK_IJ_CTRL, 0);
  584. static struct clk_regmap pwm_i =
  585. AML_PWM_CLK_GATE(pwm_i, PWM_CLK_IJ_CTRL, 8);
  586. static struct clk_regmap pwm_j_sel =
  587. AML_PWM_CLK_MUX(pwm_j, PWM_CLK_IJ_CTRL, 25);
  588. static struct clk_regmap pwm_j_div =
  589. AML_PWM_CLK_DIV(pwm_j, PWM_CLK_IJ_CTRL, 16);
  590. static struct clk_regmap pwm_j =
  591. AML_PWM_CLK_GATE(pwm_j, PWM_CLK_IJ_CTRL, 24);
  592. static struct clk_regmap pwm_k_sel =
  593. AML_PWM_CLK_MUX(pwm_k, PWM_CLK_KL_CTRL, 9);
  594. static struct clk_regmap pwm_k_div =
  595. AML_PWM_CLK_DIV(pwm_k, PWM_CLK_KL_CTRL, 0);
  596. static struct clk_regmap pwm_k =
  597. AML_PWM_CLK_GATE(pwm_k, PWM_CLK_KL_CTRL, 8);
  598. static struct clk_regmap pwm_l_sel =
  599. AML_PWM_CLK_MUX(pwm_l, PWM_CLK_KL_CTRL, 25);
  600. static struct clk_regmap pwm_l_div =
  601. AML_PWM_CLK_DIV(pwm_l, PWM_CLK_KL_CTRL, 16);
  602. static struct clk_regmap pwm_l =
  603. AML_PWM_CLK_GATE(pwm_l, PWM_CLK_KL_CTRL, 24);
  604. static struct clk_regmap pwm_m_sel =
  605. AML_PWM_CLK_MUX(pwm_m, PWM_CLK_MN_CTRL, 9);
  606. static struct clk_regmap pwm_m_div =
  607. AML_PWM_CLK_DIV(pwm_m, PWM_CLK_MN_CTRL, 0);
  608. static struct clk_regmap pwm_m =
  609. AML_PWM_CLK_GATE(pwm_m, PWM_CLK_MN_CTRL, 8);
  610. static struct clk_regmap pwm_n_sel =
  611. AML_PWM_CLK_MUX(pwm_n, PWM_CLK_MN_CTRL, 25);
  612. static struct clk_regmap pwm_n_div =
  613. AML_PWM_CLK_DIV(pwm_n, PWM_CLK_MN_CTRL, 16);
  614. static struct clk_regmap pwm_n =
  615. AML_PWM_CLK_GATE(pwm_n, PWM_CLK_MN_CTRL, 24);
  616. static const struct clk_parent_data spicc_parent_data[] = {
  617. { .fw_name = "oscin" },
  618. { .fw_name = "sysclk" },
  619. { .fw_name = "fdiv4" },
  620. { .fw_name = "fdiv3" },
  621. { .fw_name = "fdiv2" },
  622. { .fw_name = "fdiv5" },
  623. { .fw_name = "fdiv7" },
  624. { .fw_name = "gp1" }
  625. };
  626. static struct clk_regmap spicc_a_sel = {
  627. .data = &(struct clk_regmap_mux_data) {
  628. .offset = SPICC_CLK_CTRL,
  629. .mask = 0x7,
  630. .shift = 7,
  631. },
  632. .hw.init = &(struct clk_init_data) {
  633. .name = "spicc_a_sel",
  634. .ops = &clk_regmap_mux_ops,
  635. .parent_data = spicc_parent_data,
  636. .num_parents = ARRAY_SIZE(spicc_parent_data),
  637. },
  638. };
  639. static struct clk_regmap spicc_a_div = {
  640. .data = &(struct clk_regmap_div_data) {
  641. .offset = SPICC_CLK_CTRL,
  642. .shift = 0,
  643. .width = 6,
  644. },
  645. .hw.init = &(struct clk_init_data) {
  646. .name = "spicc_a_div",
  647. .ops = &clk_regmap_divider_ops,
  648. .parent_hws = (const struct clk_hw *[]) {
  649. &spicc_a_sel.hw
  650. },
  651. .num_parents = 1,
  652. .flags = CLK_SET_RATE_PARENT,
  653. },
  654. };
  655. static struct clk_regmap spicc_a = {
  656. .data = &(struct clk_regmap_gate_data) {
  657. .offset = SPICC_CLK_CTRL,
  658. .bit_idx = 6,
  659. },
  660. .hw.init = &(struct clk_init_data) {
  661. .name = "spicc_a",
  662. .ops = &clk_regmap_gate_ops,
  663. .parent_hws = (const struct clk_hw *[]) {
  664. &spicc_a_div.hw
  665. },
  666. .num_parents = 1,
  667. .flags = CLK_SET_RATE_PARENT,
  668. },
  669. };
  670. static struct clk_regmap spicc_b_sel = {
  671. .data = &(struct clk_regmap_mux_data) {
  672. .offset = SPICC_CLK_CTRL,
  673. .mask = 0x7,
  674. .shift = 23,
  675. },
  676. .hw.init = &(struct clk_init_data) {
  677. .name = "spicc_b_sel",
  678. .ops = &clk_regmap_mux_ops,
  679. .parent_data = spicc_parent_data,
  680. .num_parents = ARRAY_SIZE(spicc_parent_data),
  681. },
  682. };
  683. static struct clk_regmap spicc_b_div = {
  684. .data = &(struct clk_regmap_div_data) {
  685. .offset = SPICC_CLK_CTRL,
  686. .shift = 16,
  687. .width = 6,
  688. },
  689. .hw.init = &(struct clk_init_data) {
  690. .name = "spicc_b_div",
  691. .ops = &clk_regmap_divider_ops,
  692. .parent_hws = (const struct clk_hw *[]) {
  693. &spicc_b_sel.hw
  694. },
  695. .num_parents = 1,
  696. .flags = CLK_SET_RATE_PARENT,
  697. },
  698. };
  699. static struct clk_regmap spicc_b = {
  700. .data = &(struct clk_regmap_gate_data) {
  701. .offset = SPICC_CLK_CTRL,
  702. .bit_idx = 22,
  703. },
  704. .hw.init = &(struct clk_init_data) {
  705. .name = "spicc_b",
  706. .ops = &clk_regmap_gate_ops,
  707. .parent_hws = (const struct clk_hw *[]) {
  708. &spicc_b_div.hw
  709. },
  710. .num_parents = 1,
  711. .flags = CLK_SET_RATE_PARENT,
  712. },
  713. };
  714. static const struct clk_parent_data spifc_parent_data[] = {
  715. { .fw_name = "gp0" },
  716. { .fw_name = "fdiv2" },
  717. { .fw_name = "fdiv3" },
  718. { .fw_name = "fdiv2p5" },
  719. { .fw_name = "hifi" },
  720. { .fw_name = "fdiv4" },
  721. { .fw_name = "fdiv5" },
  722. { .fw_name = "fdiv7" }
  723. };
  724. static struct clk_regmap spifc_sel = {
  725. .data = &(struct clk_regmap_mux_data) {
  726. .offset = SPIFC_CLK_CTRL,
  727. .mask = 0x7,
  728. .shift = 9,
  729. },
  730. .hw.init = &(struct clk_init_data) {
  731. .name = "spifc_sel",
  732. .ops = &clk_regmap_mux_ops,
  733. .parent_data = spifc_parent_data,
  734. .num_parents = ARRAY_SIZE(spifc_parent_data),
  735. },
  736. };
  737. static struct clk_regmap spifc_div = {
  738. .data = &(struct clk_regmap_div_data) {
  739. .offset = SPIFC_CLK_CTRL,
  740. .shift = 0,
  741. .width = 7,
  742. },
  743. .hw.init = &(struct clk_init_data) {
  744. .name = "spifc_div",
  745. .ops = &clk_regmap_divider_ops,
  746. .parent_hws = (const struct clk_hw *[]) {
  747. &spifc_sel.hw
  748. },
  749. .num_parents = 1,
  750. .flags = CLK_SET_RATE_PARENT,
  751. },
  752. };
  753. static struct clk_regmap spifc = {
  754. .data = &(struct clk_regmap_gate_data) {
  755. .offset = SPIFC_CLK_CTRL,
  756. .bit_idx = 8,
  757. },
  758. .hw.init = &(struct clk_init_data) {
  759. .name = "spifc",
  760. .ops = &clk_regmap_gate_ops,
  761. .parent_hws = (const struct clk_hw *[]) {
  762. &spifc_div.hw
  763. },
  764. .num_parents = 1,
  765. .flags = CLK_SET_RATE_PARENT,
  766. },
  767. };
  768. static const struct clk_parent_data emmc_parent_data[] = {
  769. { .fw_name = "oscin" },
  770. { .fw_name = "fdiv2" },
  771. { .fw_name = "fdiv3" },
  772. { .fw_name = "hifi" },
  773. { .fw_name = "fdiv2p5" },
  774. { .fw_name = "fdiv4" },
  775. { .fw_name = "gp1" },
  776. { .fw_name = "gp0" }
  777. };
  778. static struct clk_regmap sd_emmc_a_sel = {
  779. .data = &(struct clk_regmap_mux_data) {
  780. .offset = SD_EMMC_CLK_CTRL,
  781. .mask = 0x7,
  782. .shift = 9,
  783. },
  784. .hw.init = &(struct clk_init_data) {
  785. .name = "sd_emmc_a_sel",
  786. .ops = &clk_regmap_mux_ops,
  787. .parent_data = emmc_parent_data,
  788. .num_parents = ARRAY_SIZE(emmc_parent_data),
  789. },
  790. };
  791. static struct clk_regmap sd_emmc_a_div = {
  792. .data = &(struct clk_regmap_div_data) {
  793. .offset = SD_EMMC_CLK_CTRL,
  794. .shift = 0,
  795. .width = 7,
  796. },
  797. .hw.init = &(struct clk_init_data) {
  798. .name = "sd_emmc_a_div",
  799. .ops = &clk_regmap_divider_ops,
  800. .parent_hws = (const struct clk_hw *[]) {
  801. &sd_emmc_a_sel.hw
  802. },
  803. .num_parents = 1,
  804. .flags = CLK_SET_RATE_PARENT,
  805. },
  806. };
  807. static struct clk_regmap sd_emmc_a = {
  808. .data = &(struct clk_regmap_gate_data) {
  809. .offset = SD_EMMC_CLK_CTRL,
  810. .bit_idx = 7,
  811. },
  812. .hw.init = &(struct clk_init_data) {
  813. .name = "sd_emmc_a",
  814. .ops = &clk_regmap_gate_ops,
  815. .parent_hws = (const struct clk_hw *[]) {
  816. &sd_emmc_a_div.hw
  817. },
  818. .num_parents = 1,
  819. .flags = CLK_SET_RATE_PARENT,
  820. },
  821. };
  822. static struct clk_regmap sd_emmc_b_sel = {
  823. .data = &(struct clk_regmap_mux_data) {
  824. .offset = SD_EMMC_CLK_CTRL,
  825. .mask = 0x7,
  826. .shift = 25,
  827. },
  828. .hw.init = &(struct clk_init_data) {
  829. .name = "sd_emmc_b_sel",
  830. .ops = &clk_regmap_mux_ops,
  831. .parent_data = emmc_parent_data,
  832. .num_parents = ARRAY_SIZE(emmc_parent_data),
  833. },
  834. };
  835. static struct clk_regmap sd_emmc_b_div = {
  836. .data = &(struct clk_regmap_div_data) {
  837. .offset = SD_EMMC_CLK_CTRL,
  838. .shift = 16,
  839. .width = 7,
  840. },
  841. .hw.init = &(struct clk_init_data) {
  842. .name = "sd_emmc_b_div",
  843. .ops = &clk_regmap_divider_ops,
  844. .parent_hws = (const struct clk_hw *[]) {
  845. &sd_emmc_b_sel.hw
  846. },
  847. .num_parents = 1,
  848. .flags = CLK_SET_RATE_PARENT,
  849. },
  850. };
  851. static struct clk_regmap sd_emmc_b = {
  852. .data = &(struct clk_regmap_gate_data) {
  853. .offset = SD_EMMC_CLK_CTRL,
  854. .bit_idx = 23,
  855. },
  856. .hw.init = &(struct clk_init_data) {
  857. .name = "sd_emmc_b",
  858. .ops = &clk_regmap_gate_ops,
  859. .parent_hws = (const struct clk_hw *[]) {
  860. &sd_emmc_b_div.hw
  861. },
  862. .num_parents = 1,
  863. .flags = CLK_SET_RATE_PARENT,
  864. },
  865. };
  866. static struct clk_regmap sd_emmc_c_sel = {
  867. .data = &(struct clk_regmap_mux_data) {
  868. .offset = NAND_CLK_CTRL,
  869. .mask = 0x7,
  870. .shift = 9,
  871. },
  872. .hw.init = &(struct clk_init_data) {
  873. .name = "sd_emmc_c_sel",
  874. .ops = &clk_regmap_mux_ops,
  875. .parent_data = emmc_parent_data,
  876. .num_parents = ARRAY_SIZE(emmc_parent_data),
  877. },
  878. };
  879. static struct clk_regmap sd_emmc_c_div = {
  880. .data = &(struct clk_regmap_div_data) {
  881. .offset = NAND_CLK_CTRL,
  882. .shift = 0,
  883. .width = 7,
  884. },
  885. .hw.init = &(struct clk_init_data) {
  886. .name = "sd_emmc_c_div",
  887. .ops = &clk_regmap_divider_ops,
  888. .parent_hws = (const struct clk_hw *[]) {
  889. &sd_emmc_c_sel.hw
  890. },
  891. .num_parents = 1,
  892. .flags = CLK_SET_RATE_PARENT,
  893. },
  894. };
  895. static struct clk_regmap sd_emmc_c = {
  896. .data = &(struct clk_regmap_gate_data) {
  897. .offset = NAND_CLK_CTRL,
  898. .bit_idx = 7,
  899. },
  900. .hw.init = &(struct clk_init_data) {
  901. .name = "sd_emmc_c",
  902. .ops = &clk_regmap_gate_ops,
  903. .parent_hws = (const struct clk_hw *[]) {
  904. &sd_emmc_c_div.hw
  905. },
  906. .num_parents = 1,
  907. .flags = CLK_SET_RATE_PARENT,
  908. },
  909. };
  910. static struct clk_regmap ts_div = {
  911. .data = &(struct clk_regmap_div_data) {
  912. .offset = TS_CLK_CTRL,
  913. .shift = 0,
  914. .width = 8,
  915. },
  916. .hw.init = &(struct clk_init_data) {
  917. .name = "ts_div",
  918. .ops = &clk_regmap_divider_ops,
  919. .parent_data = &(const struct clk_parent_data) {
  920. .fw_name = "oscin",
  921. },
  922. .num_parents = 1,
  923. },
  924. };
  925. static struct clk_regmap ts = {
  926. .data = &(struct clk_regmap_gate_data) {
  927. .offset = TS_CLK_CTRL,
  928. .bit_idx = 8,
  929. },
  930. .hw.init = &(struct clk_init_data) {
  931. .name = "ts",
  932. .ops = &clk_regmap_gate_ops,
  933. .parent_hws = (const struct clk_hw *[]) {
  934. &ts_div.hw
  935. },
  936. .num_parents = 1,
  937. .flags = CLK_SET_RATE_PARENT,
  938. },
  939. };
  940. static const struct clk_parent_data eth_parent = {
  941. .fw_name = "fdiv2",
  942. };
  943. static struct clk_fixed_factor eth_125m_div = {
  944. .mult = 1,
  945. .div = 8,
  946. .hw.init = &(struct clk_init_data) {
  947. .name = "eth_125m_div",
  948. .ops = &clk_fixed_factor_ops,
  949. .parent_data = &eth_parent,
  950. .num_parents = 1,
  951. },
  952. };
  953. static struct clk_regmap eth_125m = {
  954. .data = &(struct clk_regmap_gate_data) {
  955. .offset = ETH_CLK_CTRL,
  956. .bit_idx = 7,
  957. },
  958. .hw.init = &(struct clk_init_data) {
  959. .name = "eth_125m",
  960. .ops = &clk_regmap_gate_ops,
  961. .parent_hws = (const struct clk_hw *[]) {
  962. &eth_125m_div.hw
  963. },
  964. .num_parents = 1,
  965. .flags = CLK_SET_RATE_PARENT,
  966. },
  967. };
  968. static struct clk_regmap eth_rmii_div = {
  969. .data = &(struct clk_regmap_div_data) {
  970. .offset = ETH_CLK_CTRL,
  971. .shift = 0,
  972. .width = 7,
  973. },
  974. .hw.init = &(struct clk_init_data) {
  975. .name = "eth_rmii_div",
  976. .ops = &clk_regmap_divider_ops,
  977. .parent_data = &eth_parent,
  978. .num_parents = 1,
  979. },
  980. };
  981. static struct clk_regmap eth_rmii = {
  982. .data = &(struct clk_regmap_gate_data) {
  983. .offset = ETH_CLK_CTRL,
  984. .bit_idx = 8,
  985. },
  986. .hw.init = &(struct clk_init_data) {
  987. .name = "eth_rmii",
  988. .ops = &clk_regmap_gate_ops,
  989. .parent_hws = (const struct clk_hw *[]) {
  990. &eth_rmii_div.hw
  991. },
  992. .num_parents = 1,
  993. .flags = CLK_SET_RATE_PARENT,
  994. },
  995. };
  996. static const struct clk_parent_data mipi_dsi_meas_parent_data[] = {
  997. { .fw_name = "oscin" },
  998. { .fw_name = "fdiv4" },
  999. { .fw_name = "fdiv3" },
  1000. { .fw_name = "fdiv5" },
  1001. { .fw_name = "gp1" },
  1002. { .fw_name = "gp0" },
  1003. { .fw_name = "fdiv2" },
  1004. { .fw_name = "fdiv7" }
  1005. };
  1006. static struct clk_regmap mipi_dsi_meas_sel = {
  1007. .data = &(struct clk_regmap_mux_data) {
  1008. .offset = VDIN_MEAS_CLK_CTRL,
  1009. .mask = 0x7,
  1010. .shift = 21,
  1011. },
  1012. .hw.init = &(struct clk_init_data) {
  1013. .name = "mipi_dsi_meas_sel",
  1014. .ops = &clk_regmap_mux_ops,
  1015. .parent_data = mipi_dsi_meas_parent_data,
  1016. .num_parents = ARRAY_SIZE(mipi_dsi_meas_parent_data),
  1017. },
  1018. };
  1019. static struct clk_regmap mipi_dsi_meas_div = {
  1020. .data = &(struct clk_regmap_div_data) {
  1021. .offset = VDIN_MEAS_CLK_CTRL,
  1022. .shift = 12,
  1023. .width = 7,
  1024. },
  1025. .hw.init = &(struct clk_init_data) {
  1026. .name = "mipi_dsi_meas_div",
  1027. .ops = &clk_regmap_divider_ops,
  1028. .parent_hws = (const struct clk_hw *[]) {
  1029. &mipi_dsi_meas_sel.hw
  1030. },
  1031. .num_parents = 1,
  1032. .flags = CLK_SET_RATE_PARENT,
  1033. },
  1034. };
  1035. static struct clk_regmap mipi_dsi_meas = {
  1036. .data = &(struct clk_regmap_gate_data) {
  1037. .offset = VDIN_MEAS_CLK_CTRL,
  1038. .bit_idx = 20,
  1039. },
  1040. .hw.init = &(struct clk_init_data) {
  1041. .name = "mipi_dsi_meas",
  1042. .ops = &clk_regmap_gate_ops,
  1043. .parent_hws = (const struct clk_hw *[]) {
  1044. &mipi_dsi_meas_div.hw
  1045. },
  1046. .num_parents = 1,
  1047. .flags = CLK_SET_RATE_PARENT,
  1048. },
  1049. };
  1050. static const struct clk_parent_data dsi_phy_parent_data[] = {
  1051. { .fw_name = "gp1" },
  1052. { .fw_name = "gp0" },
  1053. { .fw_name = "hifi" },
  1054. { .fw_name = "fdiv3" },
  1055. { .fw_name = "fdiv2" },
  1056. { .fw_name = "fdiv2p5" },
  1057. { .fw_name = "fdiv4" },
  1058. { .fw_name = "fdiv7" }
  1059. };
  1060. static struct clk_regmap dsi_phy_sel = {
  1061. .data = &(struct clk_regmap_mux_data) {
  1062. .offset = MIPIDSI_PHY_CLK_CTRL,
  1063. .mask = 0x7,
  1064. .shift = 12,
  1065. },
  1066. .hw.init = &(struct clk_init_data) {
  1067. .name = "dsi_phy_sel",
  1068. .ops = &clk_regmap_mux_ops,
  1069. .parent_data = dsi_phy_parent_data,
  1070. .num_parents = ARRAY_SIZE(dsi_phy_parent_data),
  1071. },
  1072. };
  1073. static struct clk_regmap dsi_phy_div = {
  1074. .data = &(struct clk_regmap_div_data) {
  1075. .offset = MIPIDSI_PHY_CLK_CTRL,
  1076. .shift = 0,
  1077. .width = 7,
  1078. },
  1079. .hw.init = &(struct clk_init_data) {
  1080. .name = "dsi_phy_div",
  1081. .ops = &clk_regmap_divider_ops,
  1082. .parent_hws = (const struct clk_hw *[]) {
  1083. &dsi_phy_sel.hw
  1084. },
  1085. .num_parents = 1,
  1086. .flags = CLK_SET_RATE_PARENT,
  1087. },
  1088. };
  1089. static struct clk_regmap dsi_phy = {
  1090. .data = &(struct clk_regmap_gate_data) {
  1091. .offset = MIPIDSI_PHY_CLK_CTRL,
  1092. .bit_idx = 8,
  1093. },
  1094. .hw.init = &(struct clk_init_data) {
  1095. .name = "dsi_phy",
  1096. .ops = &clk_regmap_gate_ops,
  1097. .parent_hws = (const struct clk_hw *[]) {
  1098. &dsi_phy_div.hw
  1099. },
  1100. .num_parents = 1,
  1101. .flags = CLK_SET_RATE_PARENT,
  1102. },
  1103. };
  1104. static const struct clk_parent_data vout_mclk_parent_data[] = {
  1105. { .fw_name = "fdiv2p5" },
  1106. { .fw_name = "fdiv3" },
  1107. { .fw_name = "fdiv4" },
  1108. { .fw_name = "fdiv5" },
  1109. { .fw_name = "gp0" },
  1110. { .fw_name = "hifi" },
  1111. { .fw_name = "gp1" },
  1112. { .fw_name = "fdiv7" }
  1113. };
  1114. static struct clk_regmap vout_mclk_sel = {
  1115. .data = &(struct clk_regmap_mux_data) {
  1116. .offset = VOUTENC_CLK_CTRL,
  1117. .mask = 0x7,
  1118. .shift = 9,
  1119. },
  1120. .hw.init = &(struct clk_init_data) {
  1121. .name = "vout_mclk_sel",
  1122. .ops = &clk_regmap_mux_ops,
  1123. .parent_data = vout_mclk_parent_data,
  1124. .num_parents = ARRAY_SIZE(vout_mclk_parent_data),
  1125. },
  1126. };
  1127. static struct clk_regmap vout_mclk_div = {
  1128. .data = &(struct clk_regmap_div_data) {
  1129. .offset = VOUTENC_CLK_CTRL,
  1130. .shift = 0,
  1131. .width = 7,
  1132. },
  1133. .hw.init = &(struct clk_init_data) {
  1134. .name = "vout_mclk_div",
  1135. .ops = &clk_regmap_divider_ops,
  1136. .parent_hws = (const struct clk_hw *[]) {
  1137. &vout_mclk_sel.hw
  1138. },
  1139. .num_parents = 1,
  1140. .flags = CLK_SET_RATE_PARENT,
  1141. },
  1142. };
  1143. static struct clk_regmap vout_mclk = {
  1144. .data = &(struct clk_regmap_gate_data) {
  1145. .offset = VOUTENC_CLK_CTRL,
  1146. .bit_idx = 8,
  1147. },
  1148. .hw.init = &(struct clk_init_data) {
  1149. .name = "vout_mclk",
  1150. .ops = &clk_regmap_gate_ops,
  1151. .parent_hws = (const struct clk_hw *[]) {
  1152. &vout_mclk_div.hw
  1153. },
  1154. .num_parents = 1,
  1155. .flags = CLK_SET_RATE_PARENT,
  1156. },
  1157. };
  1158. static const struct clk_parent_data vout_enc_parent_data[] = {
  1159. { .fw_name = "gp1" },
  1160. { .fw_name = "fdiv3" },
  1161. { .fw_name = "fdiv4" },
  1162. { .fw_name = "fdiv5" },
  1163. { .fw_name = "gp0" },
  1164. { .fw_name = "hifi" },
  1165. { .fw_name = "fdiv2p5" },
  1166. { .fw_name = "fdiv7" }
  1167. };
  1168. static struct clk_regmap vout_enc_sel = {
  1169. .data = &(struct clk_regmap_mux_data) {
  1170. .offset = VOUTENC_CLK_CTRL,
  1171. .mask = 0x7,
  1172. .shift = 25,
  1173. },
  1174. .hw.init = &(struct clk_init_data) {
  1175. .name = "vout_enc_sel",
  1176. .ops = &clk_regmap_mux_ops,
  1177. .parent_data = vout_enc_parent_data,
  1178. .num_parents = ARRAY_SIZE(vout_enc_parent_data),
  1179. },
  1180. };
  1181. static struct clk_regmap vout_enc_div = {
  1182. .data = &(struct clk_regmap_div_data) {
  1183. .offset = VOUTENC_CLK_CTRL,
  1184. .shift = 16,
  1185. .width = 7,
  1186. },
  1187. .hw.init = &(struct clk_init_data) {
  1188. .name = "vout_enc_div",
  1189. .ops = &clk_regmap_divider_ops,
  1190. .parent_hws = (const struct clk_hw *[]) {
  1191. &vout_enc_sel.hw
  1192. },
  1193. .num_parents = 1,
  1194. .flags = CLK_SET_RATE_PARENT,
  1195. },
  1196. };
  1197. static struct clk_regmap vout_enc = {
  1198. .data = &(struct clk_regmap_gate_data) {
  1199. .offset = VOUTENC_CLK_CTRL,
  1200. .bit_idx = 24,
  1201. },
  1202. .hw.init = &(struct clk_init_data) {
  1203. .name = "vout_enc",
  1204. .ops = &clk_regmap_gate_ops,
  1205. .parent_hws = (const struct clk_hw *[]) {
  1206. &vout_enc_div.hw
  1207. },
  1208. .num_parents = 1,
  1209. .flags = CLK_SET_RATE_PARENT,
  1210. },
  1211. };
  1212. static const struct clk_parent_data hcodec_pre_parent_data[] = {
  1213. { .fw_name = "fdiv2p5" },
  1214. { .fw_name = "fdiv3" },
  1215. { .fw_name = "fdiv4" },
  1216. { .fw_name = "fdiv5" },
  1217. { .fw_name = "fdiv7" },
  1218. { .fw_name = "hifi" },
  1219. { .fw_name = "gp0" },
  1220. { .fw_name = "oscin" }
  1221. };
  1222. static struct clk_regmap hcodec_0_sel = {
  1223. .data = &(struct clk_regmap_mux_data) {
  1224. .offset = VDEC_CLK_CTRL,
  1225. .mask = 0x7,
  1226. .shift = 9,
  1227. },
  1228. .hw.init = &(struct clk_init_data) {
  1229. .name = "hcodec_0_sel",
  1230. .ops = &clk_regmap_mux_ops,
  1231. .parent_data = hcodec_pre_parent_data,
  1232. .num_parents = ARRAY_SIZE(hcodec_pre_parent_data),
  1233. },
  1234. };
  1235. static struct clk_regmap hcodec_0_div = {
  1236. .data = &(struct clk_regmap_div_data) {
  1237. .offset = VDEC_CLK_CTRL,
  1238. .shift = 0,
  1239. .width = 7,
  1240. },
  1241. .hw.init = &(struct clk_init_data) {
  1242. .name = "hcodec_0_div",
  1243. .ops = &clk_regmap_divider_ops,
  1244. .parent_hws = (const struct clk_hw *[]) {
  1245. &hcodec_0_sel.hw
  1246. },
  1247. .num_parents = 1,
  1248. .flags = CLK_SET_RATE_PARENT,
  1249. },
  1250. };
  1251. static struct clk_regmap hcodec_0 = {
  1252. .data = &(struct clk_regmap_gate_data) {
  1253. .offset = VDEC_CLK_CTRL,
  1254. .bit_idx = 8,
  1255. },
  1256. .hw.init = &(struct clk_init_data) {
  1257. .name = "hcodec_0",
  1258. .ops = &clk_regmap_gate_ops,
  1259. .parent_hws = (const struct clk_hw *[]) {
  1260. &hcodec_0_div.hw
  1261. },
  1262. .num_parents = 1,
  1263. .flags = CLK_SET_RATE_PARENT,
  1264. },
  1265. };
  1266. static struct clk_regmap hcodec_1_sel = {
  1267. .data = &(struct clk_regmap_mux_data) {
  1268. .offset = VDEC3_CLK_CTRL,
  1269. .mask = 0x7,
  1270. .shift = 9,
  1271. },
  1272. .hw.init = &(struct clk_init_data) {
  1273. .name = "hcodec_1_sel",
  1274. .ops = &clk_regmap_mux_ops,
  1275. .parent_data = hcodec_pre_parent_data,
  1276. .num_parents = ARRAY_SIZE(hcodec_pre_parent_data),
  1277. },
  1278. };
  1279. static struct clk_regmap hcodec_1_div = {
  1280. .data = &(struct clk_regmap_div_data) {
  1281. .offset = VDEC3_CLK_CTRL,
  1282. .shift = 0,
  1283. .width = 7,
  1284. },
  1285. .hw.init = &(struct clk_init_data) {
  1286. .name = "hcodec_1_div",
  1287. .ops = &clk_regmap_divider_ops,
  1288. .parent_hws = (const struct clk_hw *[]) {
  1289. &hcodec_1_sel.hw
  1290. },
  1291. .num_parents = 1,
  1292. .flags = CLK_SET_RATE_PARENT,
  1293. },
  1294. };
  1295. static struct clk_regmap hcodec_1 = {
  1296. .data = &(struct clk_regmap_gate_data) {
  1297. .offset = VDEC3_CLK_CTRL,
  1298. .bit_idx = 8,
  1299. },
  1300. .hw.init = &(struct clk_init_data) {
  1301. .name = "hcodec_1",
  1302. .ops = &clk_regmap_gate_ops,
  1303. .parent_hws = (const struct clk_hw *[]) {
  1304. &hcodec_1_div.hw
  1305. },
  1306. .num_parents = 1,
  1307. .flags = CLK_SET_RATE_PARENT,
  1308. },
  1309. };
  1310. static const struct clk_parent_data hcodec_parent_data[] = {
  1311. { .hw = &hcodec_0.hw },
  1312. { .hw = &hcodec_1.hw }
  1313. };
  1314. static struct clk_regmap hcodec = {
  1315. .data = &(struct clk_regmap_mux_data) {
  1316. .offset = VDEC3_CLK_CTRL,
  1317. .mask = 0x1,
  1318. .shift = 15,
  1319. },
  1320. .hw.init = &(struct clk_init_data) {
  1321. .name = "hcodec",
  1322. .ops = &clk_regmap_mux_ops,
  1323. .parent_data = hcodec_parent_data,
  1324. .num_parents = ARRAY_SIZE(hcodec_parent_data),
  1325. .flags = CLK_SET_RATE_PARENT,
  1326. },
  1327. };
  1328. static const struct clk_parent_data vc9000e_parent_data[] = {
  1329. { .fw_name = "oscin" },
  1330. { .fw_name = "fdiv4" },
  1331. { .fw_name = "fdiv3" },
  1332. { .fw_name = "fdiv5" },
  1333. { .fw_name = "fdiv7" },
  1334. { .fw_name = "fdiv2p5" },
  1335. { .fw_name = "hifi" },
  1336. { .fw_name = "gp0" }
  1337. };
  1338. static struct clk_regmap vc9000e_aclk_sel = {
  1339. .data = &(struct clk_regmap_mux_data) {
  1340. .offset = VC9000E_CLK_CTRL,
  1341. .mask = 0x7,
  1342. .shift = 9,
  1343. },
  1344. .hw.init = &(struct clk_init_data) {
  1345. .name = "vc9000e_aclk_sel",
  1346. .ops = &clk_regmap_mux_ops,
  1347. .parent_data = vc9000e_parent_data,
  1348. .num_parents = ARRAY_SIZE(vc9000e_parent_data),
  1349. },
  1350. };
  1351. static struct clk_regmap vc9000e_aclk_div = {
  1352. .data = &(struct clk_regmap_div_data) {
  1353. .offset = VC9000E_CLK_CTRL,
  1354. .shift = 0,
  1355. .width = 7,
  1356. },
  1357. .hw.init = &(struct clk_init_data) {
  1358. .name = "vc9000e_aclk_div",
  1359. .ops = &clk_regmap_divider_ops,
  1360. .parent_hws = (const struct clk_hw *[]) {
  1361. &vc9000e_aclk_sel.hw
  1362. },
  1363. .num_parents = 1,
  1364. .flags = CLK_SET_RATE_PARENT,
  1365. },
  1366. };
  1367. static struct clk_regmap vc9000e_aclk = {
  1368. .data = &(struct clk_regmap_gate_data) {
  1369. .offset = VC9000E_CLK_CTRL,
  1370. .bit_idx = 8,
  1371. },
  1372. .hw.init = &(struct clk_init_data) {
  1373. .name = "vc9000e_aclk",
  1374. .ops = &clk_regmap_gate_ops,
  1375. .parent_hws = (const struct clk_hw *[]) {
  1376. &vc9000e_aclk_div.hw
  1377. },
  1378. .num_parents = 1,
  1379. .flags = CLK_SET_RATE_PARENT,
  1380. },
  1381. };
  1382. static struct clk_regmap vc9000e_core_sel = {
  1383. .data = &(struct clk_regmap_mux_data) {
  1384. .offset = VC9000E_CLK_CTRL,
  1385. .mask = 0x7,
  1386. .shift = 25,
  1387. },
  1388. .hw.init = &(struct clk_init_data) {
  1389. .name = "vc9000e_core_sel",
  1390. .ops = &clk_regmap_mux_ops,
  1391. .parent_data = vc9000e_parent_data,
  1392. .num_parents = ARRAY_SIZE(vc9000e_parent_data),
  1393. },
  1394. };
  1395. static struct clk_regmap vc9000e_core_div = {
  1396. .data = &(struct clk_regmap_div_data) {
  1397. .offset = VC9000E_CLK_CTRL,
  1398. .shift = 16,
  1399. .width = 7,
  1400. },
  1401. .hw.init = &(struct clk_init_data) {
  1402. .name = "vc9000e_core_div",
  1403. .ops = &clk_regmap_divider_ops,
  1404. .parent_hws = (const struct clk_hw *[]) {
  1405. &vc9000e_core_sel.hw
  1406. },
  1407. .num_parents = 1,
  1408. .flags = CLK_SET_RATE_PARENT,
  1409. },
  1410. };
  1411. static struct clk_regmap vc9000e_core = {
  1412. .data = &(struct clk_regmap_gate_data) {
  1413. .offset = VC9000E_CLK_CTRL,
  1414. .bit_idx = 24,
  1415. },
  1416. .hw.init = &(struct clk_init_data) {
  1417. .name = "vc9000e_core",
  1418. .ops = &clk_regmap_gate_ops,
  1419. .parent_hws = (const struct clk_hw *[]) {
  1420. &vc9000e_core_div.hw
  1421. },
  1422. .num_parents = 1,
  1423. .flags = CLK_SET_RATE_PARENT,
  1424. },
  1425. };
  1426. static const struct clk_parent_data csi_phy_parent_data[] = {
  1427. { .fw_name = "fdiv2p5" },
  1428. { .fw_name = "fdiv3" },
  1429. { .fw_name = "fdiv4" },
  1430. { .fw_name = "fdiv5" },
  1431. { .fw_name = "gp0" },
  1432. { .fw_name = "hifi" },
  1433. { .fw_name = "gp1" },
  1434. { .fw_name = "oscin" }
  1435. };
  1436. static struct clk_regmap csi_phy0_sel = {
  1437. .data = &(struct clk_regmap_mux_data) {
  1438. .offset = ISP0_CLK_CTRL,
  1439. .mask = 0x7,
  1440. .shift = 25,
  1441. },
  1442. .hw.init = &(struct clk_init_data) {
  1443. .name = "csi_phy0_sel",
  1444. .ops = &clk_regmap_mux_ops,
  1445. .parent_data = csi_phy_parent_data,
  1446. .num_parents = ARRAY_SIZE(csi_phy_parent_data),
  1447. },
  1448. };
  1449. static struct clk_regmap csi_phy0_div = {
  1450. .data = &(struct clk_regmap_div_data) {
  1451. .offset = ISP0_CLK_CTRL,
  1452. .shift = 16,
  1453. .width = 7,
  1454. },
  1455. .hw.init = &(struct clk_init_data) {
  1456. .name = "csi_phy0_div",
  1457. .ops = &clk_regmap_divider_ops,
  1458. .parent_hws = (const struct clk_hw *[]) {
  1459. &csi_phy0_sel.hw
  1460. },
  1461. .num_parents = 1,
  1462. .flags = CLK_SET_RATE_PARENT,
  1463. },
  1464. };
  1465. static struct clk_regmap csi_phy0 = {
  1466. .data = &(struct clk_regmap_gate_data) {
  1467. .offset = ISP0_CLK_CTRL,
  1468. .bit_idx = 24,
  1469. },
  1470. .hw.init = &(struct clk_init_data) {
  1471. .name = "csi_phy0",
  1472. .ops = &clk_regmap_gate_ops,
  1473. .parent_hws = (const struct clk_hw *[]) {
  1474. &csi_phy0_div.hw
  1475. },
  1476. .num_parents = 1,
  1477. .flags = CLK_SET_RATE_PARENT,
  1478. },
  1479. };
  1480. static const struct clk_parent_data dewarpa_parent_data[] = {
  1481. { .fw_name = "fdiv2p5" },
  1482. { .fw_name = "fdiv3" },
  1483. { .fw_name = "fdiv4" },
  1484. { .fw_name = "fdiv5" },
  1485. { .fw_name = "gp0" },
  1486. { .fw_name = "hifi" },
  1487. { .fw_name = "gp1" },
  1488. { .fw_name = "fdiv7" }
  1489. };
  1490. static struct clk_regmap dewarpa_sel = {
  1491. .data = &(struct clk_regmap_mux_data) {
  1492. .offset = DEWARPA_CLK_CTRL,
  1493. .mask = 0x7,
  1494. .shift = 9,
  1495. },
  1496. .hw.init = &(struct clk_init_data) {
  1497. .name = "dewarpa_sel",
  1498. .ops = &clk_regmap_mux_ops,
  1499. .parent_data = dewarpa_parent_data,
  1500. .num_parents = ARRAY_SIZE(dewarpa_parent_data),
  1501. },
  1502. };
  1503. static struct clk_regmap dewarpa_div = {
  1504. .data = &(struct clk_regmap_div_data) {
  1505. .offset = DEWARPA_CLK_CTRL,
  1506. .shift = 0,
  1507. .width = 7,
  1508. },
  1509. .hw.init = &(struct clk_init_data) {
  1510. .name = "dewarpa_div",
  1511. .ops = &clk_regmap_divider_ops,
  1512. .parent_hws = (const struct clk_hw *[]) {
  1513. &dewarpa_sel.hw
  1514. },
  1515. .num_parents = 1,
  1516. .flags = CLK_SET_RATE_PARENT,
  1517. },
  1518. };
  1519. static struct clk_regmap dewarpa = {
  1520. .data = &(struct clk_regmap_gate_data) {
  1521. .offset = DEWARPA_CLK_CTRL,
  1522. .bit_idx = 8,
  1523. },
  1524. .hw.init = &(struct clk_init_data) {
  1525. .name = "dewarpa",
  1526. .ops = &clk_regmap_gate_ops,
  1527. .parent_hws = (const struct clk_hw *[]) {
  1528. &dewarpa_div.hw
  1529. },
  1530. .num_parents = 1,
  1531. .flags = CLK_SET_RATE_PARENT,
  1532. },
  1533. };
  1534. static const struct clk_parent_data isp_parent_data[] = {
  1535. { .fw_name = "fdiv2p5" },
  1536. { .fw_name = "fdiv3" },
  1537. { .fw_name = "fdiv4" },
  1538. { .fw_name = "fdiv5" },
  1539. { .fw_name = "gp0" },
  1540. { .fw_name = "hifi" },
  1541. { .fw_name = "gp1" },
  1542. { .fw_name = "oscin" }
  1543. };
  1544. static struct clk_regmap isp0_sel = {
  1545. .data = &(struct clk_regmap_mux_data) {
  1546. .offset = ISP0_CLK_CTRL,
  1547. .mask = 0x7,
  1548. .shift = 9,
  1549. },
  1550. .hw.init = &(struct clk_init_data) {
  1551. .name = "isp0_sel",
  1552. .ops = &clk_regmap_mux_ops,
  1553. .parent_data = isp_parent_data,
  1554. .num_parents = ARRAY_SIZE(isp_parent_data),
  1555. },
  1556. };
  1557. static struct clk_regmap isp0_div = {
  1558. .data = &(struct clk_regmap_div_data) {
  1559. .offset = ISP0_CLK_CTRL,
  1560. .shift = 0,
  1561. .width = 7,
  1562. },
  1563. .hw.init = &(struct clk_init_data) {
  1564. .name = "isp0_div",
  1565. .ops = &clk_regmap_divider_ops,
  1566. .parent_hws = (const struct clk_hw *[]) {
  1567. &isp0_sel.hw
  1568. },
  1569. .num_parents = 1,
  1570. .flags = CLK_SET_RATE_PARENT,
  1571. },
  1572. };
  1573. static struct clk_regmap isp0 = {
  1574. .data = &(struct clk_regmap_gate_data) {
  1575. .offset = ISP0_CLK_CTRL,
  1576. .bit_idx = 8,
  1577. },
  1578. .hw.init = &(struct clk_init_data) {
  1579. .name = "isp0",
  1580. .ops = &clk_regmap_gate_ops,
  1581. .parent_hws = (const struct clk_hw *[]) {
  1582. &isp0_div.hw
  1583. },
  1584. .num_parents = 1,
  1585. .flags = CLK_SET_RATE_PARENT,
  1586. },
  1587. };
  1588. static const struct clk_parent_data nna_core_parent_data[] = {
  1589. { .fw_name = "oscin" },
  1590. { .fw_name = "fdiv2p5" },
  1591. { .fw_name = "fdiv4" },
  1592. { .fw_name = "fdiv3" },
  1593. { .fw_name = "fdiv5" },
  1594. { .fw_name = "fdiv2" },
  1595. { .fw_name = "gp1" },
  1596. { .fw_name = "hifi" }
  1597. };
  1598. static struct clk_regmap nna_core_sel = {
  1599. .data = &(struct clk_regmap_mux_data) {
  1600. .offset = NNA_CLK_CTRL,
  1601. .mask = 0x7,
  1602. .shift = 9,
  1603. },
  1604. .hw.init = &(struct clk_init_data) {
  1605. .name = "nna_core_sel",
  1606. .ops = &clk_regmap_mux_ops,
  1607. .parent_data = nna_core_parent_data,
  1608. .num_parents = ARRAY_SIZE(nna_core_parent_data),
  1609. },
  1610. };
  1611. static struct clk_regmap nna_core_div = {
  1612. .data = &(struct clk_regmap_div_data) {
  1613. .offset = NNA_CLK_CTRL,
  1614. .shift = 0,
  1615. .width = 7,
  1616. },
  1617. .hw.init = &(struct clk_init_data) {
  1618. .name = "nna_core_div",
  1619. .ops = &clk_regmap_divider_ops,
  1620. .parent_hws = (const struct clk_hw *[]) {
  1621. &nna_core_sel.hw
  1622. },
  1623. .num_parents = 1,
  1624. .flags = CLK_SET_RATE_PARENT,
  1625. },
  1626. };
  1627. static struct clk_regmap nna_core = {
  1628. .data = &(struct clk_regmap_gate_data) {
  1629. .offset = NNA_CLK_CTRL,
  1630. .bit_idx = 8,
  1631. },
  1632. .hw.init = &(struct clk_init_data) {
  1633. .name = "nna_core",
  1634. .ops = &clk_regmap_gate_ops,
  1635. .parent_hws = (const struct clk_hw *[]) {
  1636. &nna_core_div.hw
  1637. },
  1638. .num_parents = 1,
  1639. .flags = CLK_SET_RATE_PARENT,
  1640. },
  1641. };
  1642. static const struct clk_parent_data ge2d_parent_data[] = {
  1643. { .fw_name = "oscin" },
  1644. { .fw_name = "fdiv2p5" },
  1645. { .fw_name = "fdiv3" },
  1646. { .fw_name = "fdiv4" },
  1647. { .fw_name = "hifi" },
  1648. { .fw_name = "fdiv5" },
  1649. { .fw_name = "gp0" },
  1650. { .hw = &rtc_clk.hw }
  1651. };
  1652. static struct clk_regmap ge2d_sel = {
  1653. .data = &(struct clk_regmap_mux_data) {
  1654. .offset = GE2D_CLK_CTRL,
  1655. .mask = 0x7,
  1656. .shift = 9,
  1657. },
  1658. .hw.init = &(struct clk_init_data) {
  1659. .name = "ge2d_sel",
  1660. .ops = &clk_regmap_mux_ops,
  1661. .parent_data = ge2d_parent_data,
  1662. .num_parents = ARRAY_SIZE(ge2d_parent_data),
  1663. },
  1664. };
  1665. static struct clk_regmap ge2d_div = {
  1666. .data = &(struct clk_regmap_div_data) {
  1667. .offset = GE2D_CLK_CTRL,
  1668. .shift = 0,
  1669. .width = 7,
  1670. },
  1671. .hw.init = &(struct clk_init_data) {
  1672. .name = "ge2d_div",
  1673. .ops = &clk_regmap_divider_ops,
  1674. .parent_hws = (const struct clk_hw *[]) {
  1675. &ge2d_sel.hw
  1676. },
  1677. .num_parents = 1,
  1678. .flags = CLK_SET_RATE_PARENT,
  1679. },
  1680. };
  1681. static struct clk_regmap ge2d = {
  1682. .data = &(struct clk_regmap_gate_data) {
  1683. .offset = GE2D_CLK_CTRL,
  1684. .bit_idx = 8,
  1685. },
  1686. .hw.init = &(struct clk_init_data) {
  1687. .name = "ge2d",
  1688. .ops = &clk_regmap_gate_ops,
  1689. .parent_hws = (const struct clk_hw *[]) {
  1690. &ge2d_div.hw
  1691. },
  1692. .num_parents = 1,
  1693. .flags = CLK_SET_RATE_PARENT,
  1694. },
  1695. };
  1696. static const struct clk_parent_data vapb_parent_data[] = {
  1697. { .fw_name = "fdiv2p5" },
  1698. { .fw_name = "fdiv3" },
  1699. { .fw_name = "fdiv4" },
  1700. { .fw_name = "fdiv5" },
  1701. { .fw_name = "gp0" },
  1702. { .fw_name = "hifi" },
  1703. { .fw_name = "gp1" },
  1704. { .fw_name = "oscin" },
  1705. };
  1706. static struct clk_regmap vapb_sel = {
  1707. .data = &(struct clk_regmap_mux_data) {
  1708. .offset = VAPB_CLK_CTRL,
  1709. .mask = 0x7,
  1710. .shift = 9,
  1711. },
  1712. .hw.init = &(struct clk_init_data) {
  1713. .name = "vapb_sel",
  1714. .ops = &clk_regmap_mux_ops,
  1715. .parent_data = vapb_parent_data,
  1716. .num_parents = ARRAY_SIZE(vapb_parent_data),
  1717. },
  1718. };
  1719. static struct clk_regmap vapb_div = {
  1720. .data = &(struct clk_regmap_div_data) {
  1721. .offset = VAPB_CLK_CTRL,
  1722. .shift = 0,
  1723. .width = 7,
  1724. },
  1725. .hw.init = &(struct clk_init_data) {
  1726. .name = "vapb_div",
  1727. .ops = &clk_regmap_divider_ops,
  1728. .parent_hws = (const struct clk_hw *[]) {
  1729. &vapb_sel.hw
  1730. },
  1731. .num_parents = 1,
  1732. .flags = CLK_SET_RATE_PARENT,
  1733. },
  1734. };
  1735. static struct clk_regmap vapb = {
  1736. .data = &(struct clk_regmap_gate_data) {
  1737. .offset = VAPB_CLK_CTRL,
  1738. .bit_idx = 8,
  1739. },
  1740. .hw.init = &(struct clk_init_data) {
  1741. .name = "vapb",
  1742. .ops = &clk_regmap_gate_ops,
  1743. .parent_hws = (const struct clk_hw *[]) {
  1744. &vapb_div.hw
  1745. },
  1746. .num_parents = 1,
  1747. .flags = CLK_SET_RATE_PARENT,
  1748. },
  1749. };
  1750. static struct clk_hw *c3_periphs_hw_clks[] = {
  1751. [CLKID_RTC_XTAL_CLKIN] = &rtc_xtal_clkin.hw,
  1752. [CLKID_RTC_32K_DIV] = &rtc_32k_div.hw,
  1753. [CLKID_RTC_32K_MUX] = &rtc_32k_mux.hw,
  1754. [CLKID_RTC_32K] = &rtc_32k.hw,
  1755. [CLKID_RTC_CLK] = &rtc_clk.hw,
  1756. [CLKID_SYS_RESET_CTRL] = &sys_reset_ctrl.hw,
  1757. [CLKID_SYS_PWR_CTRL] = &sys_pwr_ctrl.hw,
  1758. [CLKID_SYS_PAD_CTRL] = &sys_pad_ctrl.hw,
  1759. [CLKID_SYS_CTRL] = &sys_ctrl.hw,
  1760. [CLKID_SYS_TS_PLL] = &sys_ts_pll.hw,
  1761. [CLKID_SYS_DEV_ARB] = &sys_dev_arb.hw,
  1762. [CLKID_SYS_MMC_PCLK] = &sys_mmc_pclk.hw,
  1763. [CLKID_SYS_CPU_CTRL] = &sys_cpu_ctrl.hw,
  1764. [CLKID_SYS_JTAG_CTRL] = &sys_jtag_ctrl.hw,
  1765. [CLKID_SYS_IR_CTRL] = &sys_ir_ctrl.hw,
  1766. [CLKID_SYS_IRQ_CTRL] = &sys_irq_ctrl.hw,
  1767. [CLKID_SYS_MSR_CLK] = &sys_msr_clk.hw,
  1768. [CLKID_SYS_ROM] = &sys_rom.hw,
  1769. [CLKID_SYS_UART_F] = &sys_uart_f.hw,
  1770. [CLKID_SYS_CPU_ARB] = &sys_cpu_apb.hw,
  1771. [CLKID_SYS_RSA] = &sys_rsa.hw,
  1772. [CLKID_SYS_SAR_ADC] = &sys_sar_adc.hw,
  1773. [CLKID_SYS_STARTUP] = &sys_startup.hw,
  1774. [CLKID_SYS_SECURE] = &sys_secure.hw,
  1775. [CLKID_SYS_SPIFC] = &sys_spifc.hw,
  1776. [CLKID_SYS_NNA] = &sys_nna.hw,
  1777. [CLKID_SYS_ETH_MAC] = &sys_eth_mac.hw,
  1778. [CLKID_SYS_GIC] = &sys_gic.hw,
  1779. [CLKID_SYS_RAMA] = &sys_rama.hw,
  1780. [CLKID_SYS_BIG_NIC] = &sys_big_nic.hw,
  1781. [CLKID_SYS_RAMB] = &sys_ramb.hw,
  1782. [CLKID_SYS_AUDIO_PCLK] = &sys_audio_pclk.hw,
  1783. [CLKID_SYS_PWM_KL] = &sys_pwm_kl.hw,
  1784. [CLKID_SYS_PWM_IJ] = &sys_pwm_ij.hw,
  1785. [CLKID_SYS_USB] = &sys_usb.hw,
  1786. [CLKID_SYS_SD_EMMC_A] = &sys_sd_emmc_a.hw,
  1787. [CLKID_SYS_SD_EMMC_C] = &sys_sd_emmc_c.hw,
  1788. [CLKID_SYS_PWM_AB] = &sys_pwm_ab.hw,
  1789. [CLKID_SYS_PWM_CD] = &sys_pwm_cd.hw,
  1790. [CLKID_SYS_PWM_EF] = &sys_pwm_ef.hw,
  1791. [CLKID_SYS_PWM_GH] = &sys_pwm_gh.hw,
  1792. [CLKID_SYS_SPICC_1] = &sys_spicc_1.hw,
  1793. [CLKID_SYS_SPICC_0] = &sys_spicc_0.hw,
  1794. [CLKID_SYS_UART_A] = &sys_uart_a.hw,
  1795. [CLKID_SYS_UART_B] = &sys_uart_b.hw,
  1796. [CLKID_SYS_UART_C] = &sys_uart_c.hw,
  1797. [CLKID_SYS_UART_D] = &sys_uart_d.hw,
  1798. [CLKID_SYS_UART_E] = &sys_uart_e.hw,
  1799. [CLKID_SYS_I2C_M_A] = &sys_i2c_m_a.hw,
  1800. [CLKID_SYS_I2C_M_B] = &sys_i2c_m_b.hw,
  1801. [CLKID_SYS_I2C_M_C] = &sys_i2c_m_c.hw,
  1802. [CLKID_SYS_I2C_M_D] = &sys_i2c_m_d.hw,
  1803. [CLKID_SYS_I2S_S_A] = &sys_i2c_s_a.hw,
  1804. [CLKID_SYS_RTC] = &sys_rtc.hw,
  1805. [CLKID_SYS_GE2D] = &sys_ge2d.hw,
  1806. [CLKID_SYS_ISP] = &sys_isp.hw,
  1807. [CLKID_SYS_GPV_ISP_NIC] = &sys_gpv_isp_nic.hw,
  1808. [CLKID_SYS_GPV_CVE_NIC] = &sys_gpv_cve_nic.hw,
  1809. [CLKID_SYS_MIPI_DSI_HOST] = &sys_mipi_dsi_host.hw,
  1810. [CLKID_SYS_MIPI_DSI_PHY] = &sys_mipi_dsi_phy.hw,
  1811. [CLKID_SYS_ETH_PHY] = &sys_eth_phy.hw,
  1812. [CLKID_SYS_ACODEC] = &sys_acodec.hw,
  1813. [CLKID_SYS_DWAP] = &sys_dwap.hw,
  1814. [CLKID_SYS_DOS] = &sys_dos.hw,
  1815. [CLKID_SYS_CVE] = &sys_cve.hw,
  1816. [CLKID_SYS_VOUT] = &sys_vout.hw,
  1817. [CLKID_SYS_VC9000E] = &sys_vc9000e.hw,
  1818. [CLKID_SYS_PWM_MN] = &sys_pwm_mn.hw,
  1819. [CLKID_SYS_SD_EMMC_B] = &sys_sd_emmc_b.hw,
  1820. [CLKID_AXI_SYS_NIC] = &axi_sys_nic.hw,
  1821. [CLKID_AXI_ISP_NIC] = &axi_isp_nic.hw,
  1822. [CLKID_AXI_CVE_NIC] = &axi_cve_nic.hw,
  1823. [CLKID_AXI_RAMB] = &axi_ramb.hw,
  1824. [CLKID_AXI_RAMA] = &axi_rama.hw,
  1825. [CLKID_AXI_CPU_DMC] = &axi_cpu_dmc.hw,
  1826. [CLKID_AXI_NIC] = &axi_nic.hw,
  1827. [CLKID_AXI_DMA] = &axi_dma.hw,
  1828. [CLKID_AXI_MUX_NIC] = &axi_mux_nic.hw,
  1829. [CLKID_AXI_CVE] = &axi_cve.hw,
  1830. [CLKID_AXI_DEV1_DMC] = &axi_dev1_dmc.hw,
  1831. [CLKID_AXI_DEV0_DMC] = &axi_dev0_dmc.hw,
  1832. [CLKID_AXI_DSP_DMC] = &axi_dsp_dmc.hw,
  1833. [CLKID_12_24M_IN] = &clk_12_24m_in.hw,
  1834. [CLKID_12M_24M] = &clk_12_24m.hw,
  1835. [CLKID_FCLK_25M_DIV] = &fclk_25m_div.hw,
  1836. [CLKID_FCLK_25M] = &fclk_25m.hw,
  1837. [CLKID_GEN_SEL] = &gen_sel.hw,
  1838. [CLKID_GEN_DIV] = &gen_div.hw,
  1839. [CLKID_GEN] = &gen.hw,
  1840. [CLKID_SARADC_SEL] = &saradc_sel.hw,
  1841. [CLKID_SARADC_DIV] = &saradc_div.hw,
  1842. [CLKID_SARADC] = &saradc.hw,
  1843. [CLKID_PWM_A_SEL] = &pwm_a_sel.hw,
  1844. [CLKID_PWM_A_DIV] = &pwm_a_div.hw,
  1845. [CLKID_PWM_A] = &pwm_a.hw,
  1846. [CLKID_PWM_B_SEL] = &pwm_b_sel.hw,
  1847. [CLKID_PWM_B_DIV] = &pwm_b_div.hw,
  1848. [CLKID_PWM_B] = &pwm_b.hw,
  1849. [CLKID_PWM_C_SEL] = &pwm_c_sel.hw,
  1850. [CLKID_PWM_C_DIV] = &pwm_c_div.hw,
  1851. [CLKID_PWM_C] = &pwm_c.hw,
  1852. [CLKID_PWM_D_SEL] = &pwm_d_sel.hw,
  1853. [CLKID_PWM_D_DIV] = &pwm_d_div.hw,
  1854. [CLKID_PWM_D] = &pwm_d.hw,
  1855. [CLKID_PWM_E_SEL] = &pwm_e_sel.hw,
  1856. [CLKID_PWM_E_DIV] = &pwm_e_div.hw,
  1857. [CLKID_PWM_E] = &pwm_e.hw,
  1858. [CLKID_PWM_F_SEL] = &pwm_f_sel.hw,
  1859. [CLKID_PWM_F_DIV] = &pwm_f_div.hw,
  1860. [CLKID_PWM_F] = &pwm_f.hw,
  1861. [CLKID_PWM_G_SEL] = &pwm_g_sel.hw,
  1862. [CLKID_PWM_G_DIV] = &pwm_g_div.hw,
  1863. [CLKID_PWM_G] = &pwm_g.hw,
  1864. [CLKID_PWM_H_SEL] = &pwm_h_sel.hw,
  1865. [CLKID_PWM_H_DIV] = &pwm_h_div.hw,
  1866. [CLKID_PWM_H] = &pwm_h.hw,
  1867. [CLKID_PWM_I_SEL] = &pwm_i_sel.hw,
  1868. [CLKID_PWM_I_DIV] = &pwm_i_div.hw,
  1869. [CLKID_PWM_I] = &pwm_i.hw,
  1870. [CLKID_PWM_J_SEL] = &pwm_j_sel.hw,
  1871. [CLKID_PWM_J_DIV] = &pwm_j_div.hw,
  1872. [CLKID_PWM_J] = &pwm_j.hw,
  1873. [CLKID_PWM_K_SEL] = &pwm_k_sel.hw,
  1874. [CLKID_PWM_K_DIV] = &pwm_k_div.hw,
  1875. [CLKID_PWM_K] = &pwm_k.hw,
  1876. [CLKID_PWM_L_SEL] = &pwm_l_sel.hw,
  1877. [CLKID_PWM_L_DIV] = &pwm_l_div.hw,
  1878. [CLKID_PWM_L] = &pwm_l.hw,
  1879. [CLKID_PWM_M_SEL] = &pwm_m_sel.hw,
  1880. [CLKID_PWM_M_DIV] = &pwm_m_div.hw,
  1881. [CLKID_PWM_M] = &pwm_m.hw,
  1882. [CLKID_PWM_N_SEL] = &pwm_n_sel.hw,
  1883. [CLKID_PWM_N_DIV] = &pwm_n_div.hw,
  1884. [CLKID_PWM_N] = &pwm_n.hw,
  1885. [CLKID_SPICC_A_SEL] = &spicc_a_sel.hw,
  1886. [CLKID_SPICC_A_DIV] = &spicc_a_div.hw,
  1887. [CLKID_SPICC_A] = &spicc_a.hw,
  1888. [CLKID_SPICC_B_SEL] = &spicc_b_sel.hw,
  1889. [CLKID_SPICC_B_DIV] = &spicc_b_div.hw,
  1890. [CLKID_SPICC_B] = &spicc_b.hw,
  1891. [CLKID_SPIFC_SEL] = &spifc_sel.hw,
  1892. [CLKID_SPIFC_DIV] = &spifc_div.hw,
  1893. [CLKID_SPIFC] = &spifc.hw,
  1894. [CLKID_SD_EMMC_A_SEL] = &sd_emmc_a_sel.hw,
  1895. [CLKID_SD_EMMC_A_DIV] = &sd_emmc_a_div.hw,
  1896. [CLKID_SD_EMMC_A] = &sd_emmc_a.hw,
  1897. [CLKID_SD_EMMC_B_SEL] = &sd_emmc_b_sel.hw,
  1898. [CLKID_SD_EMMC_B_DIV] = &sd_emmc_b_div.hw,
  1899. [CLKID_SD_EMMC_B] = &sd_emmc_b.hw,
  1900. [CLKID_SD_EMMC_C_SEL] = &sd_emmc_c_sel.hw,
  1901. [CLKID_SD_EMMC_C_DIV] = &sd_emmc_c_div.hw,
  1902. [CLKID_SD_EMMC_C] = &sd_emmc_c.hw,
  1903. [CLKID_TS_DIV] = &ts_div.hw,
  1904. [CLKID_TS] = &ts.hw,
  1905. [CLKID_ETH_125M_DIV] = &eth_125m_div.hw,
  1906. [CLKID_ETH_125M] = &eth_125m.hw,
  1907. [CLKID_ETH_RMII_DIV] = &eth_rmii_div.hw,
  1908. [CLKID_ETH_RMII] = &eth_rmii.hw,
  1909. [CLKID_MIPI_DSI_MEAS_SEL] = &mipi_dsi_meas_sel.hw,
  1910. [CLKID_MIPI_DSI_MEAS_DIV] = &mipi_dsi_meas_div.hw,
  1911. [CLKID_MIPI_DSI_MEAS] = &mipi_dsi_meas.hw,
  1912. [CLKID_DSI_PHY_SEL] = &dsi_phy_sel.hw,
  1913. [CLKID_DSI_PHY_DIV] = &dsi_phy_div.hw,
  1914. [CLKID_DSI_PHY] = &dsi_phy.hw,
  1915. [CLKID_VOUT_MCLK_SEL] = &vout_mclk_sel.hw,
  1916. [CLKID_VOUT_MCLK_DIV] = &vout_mclk_div.hw,
  1917. [CLKID_VOUT_MCLK] = &vout_mclk.hw,
  1918. [CLKID_VOUT_ENC_SEL] = &vout_enc_sel.hw,
  1919. [CLKID_VOUT_ENC_DIV] = &vout_enc_div.hw,
  1920. [CLKID_VOUT_ENC] = &vout_enc.hw,
  1921. [CLKID_HCODEC_0_SEL] = &hcodec_0_sel.hw,
  1922. [CLKID_HCODEC_0_DIV] = &hcodec_0_div.hw,
  1923. [CLKID_HCODEC_0] = &hcodec_0.hw,
  1924. [CLKID_HCODEC_1_SEL] = &hcodec_1_sel.hw,
  1925. [CLKID_HCODEC_1_DIV] = &hcodec_1_div.hw,
  1926. [CLKID_HCODEC_1] = &hcodec_1.hw,
  1927. [CLKID_HCODEC] = &hcodec.hw,
  1928. [CLKID_VC9000E_ACLK_SEL] = &vc9000e_aclk_sel.hw,
  1929. [CLKID_VC9000E_ACLK_DIV] = &vc9000e_aclk_div.hw,
  1930. [CLKID_VC9000E_ACLK] = &vc9000e_aclk.hw,
  1931. [CLKID_VC9000E_CORE_SEL] = &vc9000e_core_sel.hw,
  1932. [CLKID_VC9000E_CORE_DIV] = &vc9000e_core_div.hw,
  1933. [CLKID_VC9000E_CORE] = &vc9000e_core.hw,
  1934. [CLKID_CSI_PHY0_SEL] = &csi_phy0_sel.hw,
  1935. [CLKID_CSI_PHY0_DIV] = &csi_phy0_div.hw,
  1936. [CLKID_CSI_PHY0] = &csi_phy0.hw,
  1937. [CLKID_DEWARPA_SEL] = &dewarpa_sel.hw,
  1938. [CLKID_DEWARPA_DIV] = &dewarpa_div.hw,
  1939. [CLKID_DEWARPA] = &dewarpa.hw,
  1940. [CLKID_ISP0_SEL] = &isp0_sel.hw,
  1941. [CLKID_ISP0_DIV] = &isp0_div.hw,
  1942. [CLKID_ISP0] = &isp0.hw,
  1943. [CLKID_NNA_CORE_SEL] = &nna_core_sel.hw,
  1944. [CLKID_NNA_CORE_DIV] = &nna_core_div.hw,
  1945. [CLKID_NNA_CORE] = &nna_core.hw,
  1946. [CLKID_GE2D_SEL] = &ge2d_sel.hw,
  1947. [CLKID_GE2D_DIV] = &ge2d_div.hw,
  1948. [CLKID_GE2D] = &ge2d.hw,
  1949. [CLKID_VAPB_SEL] = &vapb_sel.hw,
  1950. [CLKID_VAPB_DIV] = &vapb_div.hw,
  1951. [CLKID_VAPB] = &vapb.hw,
  1952. };
  1953. /* Convenience table to populate regmap in .probe */
  1954. static struct clk_regmap *const c3_periphs_clk_regmaps[] = {
  1955. &rtc_xtal_clkin,
  1956. &rtc_32k_div,
  1957. &rtc_32k_mux,
  1958. &rtc_32k,
  1959. &rtc_clk,
  1960. &sys_reset_ctrl,
  1961. &sys_pwr_ctrl,
  1962. &sys_pad_ctrl,
  1963. &sys_ctrl,
  1964. &sys_ts_pll,
  1965. &sys_dev_arb,
  1966. &sys_mmc_pclk,
  1967. &sys_cpu_ctrl,
  1968. &sys_jtag_ctrl,
  1969. &sys_ir_ctrl,
  1970. &sys_irq_ctrl,
  1971. &sys_msr_clk,
  1972. &sys_rom,
  1973. &sys_uart_f,
  1974. &sys_cpu_apb,
  1975. &sys_rsa,
  1976. &sys_sar_adc,
  1977. &sys_startup,
  1978. &sys_secure,
  1979. &sys_spifc,
  1980. &sys_nna,
  1981. &sys_eth_mac,
  1982. &sys_gic,
  1983. &sys_rama,
  1984. &sys_big_nic,
  1985. &sys_ramb,
  1986. &sys_audio_pclk,
  1987. &sys_pwm_kl,
  1988. &sys_pwm_ij,
  1989. &sys_usb,
  1990. &sys_sd_emmc_a,
  1991. &sys_sd_emmc_c,
  1992. &sys_pwm_ab,
  1993. &sys_pwm_cd,
  1994. &sys_pwm_ef,
  1995. &sys_pwm_gh,
  1996. &sys_spicc_1,
  1997. &sys_spicc_0,
  1998. &sys_uart_a,
  1999. &sys_uart_b,
  2000. &sys_uart_c,
  2001. &sys_uart_d,
  2002. &sys_uart_e,
  2003. &sys_i2c_m_a,
  2004. &sys_i2c_m_b,
  2005. &sys_i2c_m_c,
  2006. &sys_i2c_m_d,
  2007. &sys_i2c_s_a,
  2008. &sys_rtc,
  2009. &sys_ge2d,
  2010. &sys_isp,
  2011. &sys_gpv_isp_nic,
  2012. &sys_gpv_cve_nic,
  2013. &sys_mipi_dsi_host,
  2014. &sys_mipi_dsi_phy,
  2015. &sys_eth_phy,
  2016. &sys_acodec,
  2017. &sys_dwap,
  2018. &sys_dos,
  2019. &sys_cve,
  2020. &sys_vout,
  2021. &sys_vc9000e,
  2022. &sys_pwm_mn,
  2023. &sys_sd_emmc_b,
  2024. &axi_sys_nic,
  2025. &axi_isp_nic,
  2026. &axi_cve_nic,
  2027. &axi_ramb,
  2028. &axi_rama,
  2029. &axi_cpu_dmc,
  2030. &axi_nic,
  2031. &axi_dma,
  2032. &axi_mux_nic,
  2033. &axi_cve,
  2034. &axi_dev1_dmc,
  2035. &axi_dev0_dmc,
  2036. &axi_dsp_dmc,
  2037. &clk_12_24m_in,
  2038. &clk_12_24m,
  2039. &fclk_25m_div,
  2040. &fclk_25m,
  2041. &gen_sel,
  2042. &gen_div,
  2043. &gen,
  2044. &saradc_sel,
  2045. &saradc_div,
  2046. &saradc,
  2047. &pwm_a_sel,
  2048. &pwm_a_div,
  2049. &pwm_a,
  2050. &pwm_b_sel,
  2051. &pwm_b_div,
  2052. &pwm_b,
  2053. &pwm_c_sel,
  2054. &pwm_c_div,
  2055. &pwm_c,
  2056. &pwm_d_sel,
  2057. &pwm_d_div,
  2058. &pwm_d,
  2059. &pwm_e_sel,
  2060. &pwm_e_div,
  2061. &pwm_e,
  2062. &pwm_f_sel,
  2063. &pwm_f_div,
  2064. &pwm_f,
  2065. &pwm_g_sel,
  2066. &pwm_g_div,
  2067. &pwm_g,
  2068. &pwm_h_sel,
  2069. &pwm_h_div,
  2070. &pwm_h,
  2071. &pwm_i_sel,
  2072. &pwm_i_div,
  2073. &pwm_i,
  2074. &pwm_j_sel,
  2075. &pwm_j_div,
  2076. &pwm_j,
  2077. &pwm_k_sel,
  2078. &pwm_k_div,
  2079. &pwm_k,
  2080. &pwm_l_sel,
  2081. &pwm_l_div,
  2082. &pwm_l,
  2083. &pwm_m_sel,
  2084. &pwm_m_div,
  2085. &pwm_m,
  2086. &pwm_n_sel,
  2087. &pwm_n_div,
  2088. &pwm_n,
  2089. &spicc_a_sel,
  2090. &spicc_a_div,
  2091. &spicc_a,
  2092. &spicc_b_sel,
  2093. &spicc_b_div,
  2094. &spicc_b,
  2095. &spifc_sel,
  2096. &spifc_div,
  2097. &spifc,
  2098. &sd_emmc_a_sel,
  2099. &sd_emmc_a_div,
  2100. &sd_emmc_a,
  2101. &sd_emmc_b_sel,
  2102. &sd_emmc_b_div,
  2103. &sd_emmc_b,
  2104. &sd_emmc_c_sel,
  2105. &sd_emmc_c_div,
  2106. &sd_emmc_c,
  2107. &ts_div,
  2108. &ts,
  2109. &eth_125m,
  2110. &eth_rmii_div,
  2111. &eth_rmii,
  2112. &mipi_dsi_meas_sel,
  2113. &mipi_dsi_meas_div,
  2114. &mipi_dsi_meas,
  2115. &dsi_phy_sel,
  2116. &dsi_phy_div,
  2117. &dsi_phy,
  2118. &vout_mclk_sel,
  2119. &vout_mclk_div,
  2120. &vout_mclk,
  2121. &vout_enc_sel,
  2122. &vout_enc_div,
  2123. &vout_enc,
  2124. &hcodec_0_sel,
  2125. &hcodec_0_div,
  2126. &hcodec_0,
  2127. &hcodec_1_sel,
  2128. &hcodec_1_div,
  2129. &hcodec_1,
  2130. &hcodec,
  2131. &vc9000e_aclk_sel,
  2132. &vc9000e_aclk_div,
  2133. &vc9000e_aclk,
  2134. &vc9000e_core_sel,
  2135. &vc9000e_core_div,
  2136. &vc9000e_core,
  2137. &csi_phy0_sel,
  2138. &csi_phy0_div,
  2139. &csi_phy0,
  2140. &dewarpa_sel,
  2141. &dewarpa_div,
  2142. &dewarpa,
  2143. &isp0_sel,
  2144. &isp0_div,
  2145. &isp0,
  2146. &nna_core_sel,
  2147. &nna_core_div,
  2148. &nna_core,
  2149. &ge2d_sel,
  2150. &ge2d_div,
  2151. &ge2d,
  2152. &vapb_sel,
  2153. &vapb_div,
  2154. &vapb,
  2155. };
  2156. static const struct regmap_config clkc_regmap_config = {
  2157. .reg_bits = 32,
  2158. .val_bits = 32,
  2159. .reg_stride = 4,
  2160. .max_register = NNA_CLK_CTRL,
  2161. };
  2162. static struct meson_clk_hw_data c3_periphs_clks = {
  2163. .hws = c3_periphs_hw_clks,
  2164. .num = ARRAY_SIZE(c3_periphs_hw_clks),
  2165. };
  2166. static int c3_peripherals_probe(struct platform_device *pdev)
  2167. {
  2168. struct device *dev = &pdev->dev;
  2169. struct regmap *regmap;
  2170. void __iomem *base;
  2171. int clkid, ret, i;
  2172. base = devm_platform_ioremap_resource(pdev, 0);
  2173. if (IS_ERR(base))
  2174. return PTR_ERR(base);
  2175. regmap = devm_regmap_init_mmio(dev, base, &clkc_regmap_config);
  2176. if (IS_ERR(regmap))
  2177. return PTR_ERR(regmap);
  2178. /* Populate regmap for the regmap backed clocks */
  2179. for (i = 0; i < ARRAY_SIZE(c3_periphs_clk_regmaps); i++)
  2180. c3_periphs_clk_regmaps[i]->map = regmap;
  2181. for (clkid = 0; clkid < c3_periphs_clks.num; clkid++) {
  2182. /* array might be sparse */
  2183. if (!c3_periphs_clks.hws[clkid])
  2184. continue;
  2185. ret = devm_clk_hw_register(dev, c3_periphs_clks.hws[clkid]);
  2186. if (ret) {
  2187. dev_err(dev, "Clock registration failed\n");
  2188. return ret;
  2189. }
  2190. }
  2191. return devm_of_clk_add_hw_provider(dev, meson_clk_hw_get,
  2192. &c3_periphs_clks);
  2193. }
  2194. static const struct of_device_id c3_peripherals_clkc_match_table[] = {
  2195. {
  2196. .compatible = "amlogic,c3-peripherals-clkc",
  2197. },
  2198. { /* sentinel */ }
  2199. };
  2200. MODULE_DEVICE_TABLE(of, c3_peripherals_clkc_match_table);
  2201. static struct platform_driver c3_peripherals_driver = {
  2202. .probe = c3_peripherals_probe,
  2203. .driver = {
  2204. .name = "c3-peripherals-clkc",
  2205. .of_match_table = c3_peripherals_clkc_match_table,
  2206. },
  2207. };
  2208. module_platform_driver(c3_peripherals_driver);
  2209. MODULE_DESCRIPTION("Amlogic C3 Peripherals Clock Controller driver");
  2210. MODULE_AUTHOR("Chuan Liu <chuan.liu@amlogic.com>");
  2211. MODULE_LICENSE("GPL");
  2212. MODULE_IMPORT_NS(CLK_MESON);