meson8b.c 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2015 Endless Mobile, Inc.
  4. * Author: Carlo Caione <carlo@endlessm.com>
  5. *
  6. * Copyright (c) 2016 BayLibre, Inc.
  7. * Michael Turquette <mturquette@baylibre.com>
  8. */
  9. #include <linux/clk.h>
  10. #include <linux/clk-provider.h>
  11. #include <linux/init.h>
  12. #include <linux/mfd/syscon.h>
  13. #include <linux/of_address.h>
  14. #include <linux/reset-controller.h>
  15. #include <linux/slab.h>
  16. #include <linux/regmap.h>
  17. #include "meson8b.h"
  18. #include "clk-regmap.h"
  19. #include "meson-clkc-utils.h"
  20. #include "clk-pll.h"
  21. #include "clk-mpll.h"
  22. #include <dt-bindings/clock/meson8b-clkc.h>
  23. #include <dt-bindings/reset/amlogic,meson8b-clkc-reset.h>
  24. static DEFINE_SPINLOCK(meson_clk_lock);
  25. struct meson8b_clk_reset {
  26. struct reset_controller_dev reset;
  27. struct regmap *regmap;
  28. };
  29. static const struct pll_params_table sys_pll_params_table[] = {
  30. PLL_PARAMS(50, 1),
  31. PLL_PARAMS(51, 1),
  32. PLL_PARAMS(52, 1),
  33. PLL_PARAMS(53, 1),
  34. PLL_PARAMS(54, 1),
  35. PLL_PARAMS(55, 1),
  36. PLL_PARAMS(56, 1),
  37. PLL_PARAMS(57, 1),
  38. PLL_PARAMS(58, 1),
  39. PLL_PARAMS(59, 1),
  40. PLL_PARAMS(60, 1),
  41. PLL_PARAMS(61, 1),
  42. PLL_PARAMS(62, 1),
  43. PLL_PARAMS(63, 1),
  44. PLL_PARAMS(64, 1),
  45. PLL_PARAMS(65, 1),
  46. PLL_PARAMS(66, 1),
  47. PLL_PARAMS(67, 1),
  48. PLL_PARAMS(68, 1),
  49. PLL_PARAMS(84, 1),
  50. { /* sentinel */ },
  51. };
  52. static struct clk_regmap meson8b_fixed_pll_dco = {
  53. .data = &(struct meson_clk_pll_data){
  54. .en = {
  55. .reg_off = HHI_MPLL_CNTL,
  56. .shift = 30,
  57. .width = 1,
  58. },
  59. .m = {
  60. .reg_off = HHI_MPLL_CNTL,
  61. .shift = 0,
  62. .width = 9,
  63. },
  64. .n = {
  65. .reg_off = HHI_MPLL_CNTL,
  66. .shift = 9,
  67. .width = 5,
  68. },
  69. .frac = {
  70. .reg_off = HHI_MPLL_CNTL2,
  71. .shift = 0,
  72. .width = 12,
  73. },
  74. .l = {
  75. .reg_off = HHI_MPLL_CNTL,
  76. .shift = 31,
  77. .width = 1,
  78. },
  79. .rst = {
  80. .reg_off = HHI_MPLL_CNTL,
  81. .shift = 29,
  82. .width = 1,
  83. },
  84. },
  85. .hw.init = &(struct clk_init_data){
  86. .name = "fixed_pll_dco",
  87. .ops = &meson_clk_pll_ro_ops,
  88. .parent_data = &(const struct clk_parent_data) {
  89. .fw_name = "xtal",
  90. .name = "xtal",
  91. .index = -1,
  92. },
  93. .num_parents = 1,
  94. },
  95. };
  96. static struct clk_regmap meson8b_fixed_pll = {
  97. .data = &(struct clk_regmap_div_data){
  98. .offset = HHI_MPLL_CNTL,
  99. .shift = 16,
  100. .width = 2,
  101. .flags = CLK_DIVIDER_POWER_OF_TWO,
  102. },
  103. .hw.init = &(struct clk_init_data){
  104. .name = "fixed_pll",
  105. .ops = &clk_regmap_divider_ro_ops,
  106. .parent_hws = (const struct clk_hw *[]) {
  107. &meson8b_fixed_pll_dco.hw
  108. },
  109. .num_parents = 1,
  110. /*
  111. * This clock won't ever change at runtime so
  112. * CLK_SET_RATE_PARENT is not required
  113. */
  114. },
  115. };
  116. static struct clk_fixed_factor hdmi_pll_dco_in = {
  117. .mult = 2,
  118. .div = 1,
  119. .hw.init = &(struct clk_init_data){
  120. .name = "hdmi_pll_dco_in",
  121. .ops = &clk_fixed_factor_ops,
  122. .parent_data = &(const struct clk_parent_data) {
  123. .fw_name = "xtal",
  124. .index = -1,
  125. },
  126. .num_parents = 1,
  127. },
  128. };
  129. /*
  130. * Taken from the vendor driver for the 2970/2975MHz (both only differ in the
  131. * FRAC part in HHI_VID_PLL_CNTL2) where these values are identical for Meson8,
  132. * Meson8b and Meson8m2. This doubles the input (or output - it's not clear
  133. * which one but the result is the same) clock. The vendor driver additionally
  134. * has the following comment about: "optimise HPLL VCO 2.97GHz performance".
  135. */
  136. static const struct reg_sequence meson8b_hdmi_pll_init_regs[] = {
  137. { .reg = HHI_VID_PLL_CNTL2, .def = 0x69c84000 },
  138. { .reg = HHI_VID_PLL_CNTL3, .def = 0x8a46c023 },
  139. { .reg = HHI_VID_PLL_CNTL4, .def = 0x4123b100 },
  140. { .reg = HHI_VID_PLL_CNTL5, .def = 0x00012385 },
  141. { .reg = HHI_VID2_PLL_CNTL2, .def = 0x0430a800 },
  142. };
  143. static const struct pll_params_table hdmi_pll_params_table[] = {
  144. PLL_PARAMS(40, 1),
  145. PLL_PARAMS(42, 1),
  146. PLL_PARAMS(44, 1),
  147. PLL_PARAMS(45, 1),
  148. PLL_PARAMS(49, 1),
  149. PLL_PARAMS(52, 1),
  150. PLL_PARAMS(54, 1),
  151. PLL_PARAMS(56, 1),
  152. PLL_PARAMS(59, 1),
  153. PLL_PARAMS(60, 1),
  154. PLL_PARAMS(61, 1),
  155. PLL_PARAMS(62, 1),
  156. PLL_PARAMS(64, 1),
  157. PLL_PARAMS(66, 1),
  158. PLL_PARAMS(68, 1),
  159. PLL_PARAMS(71, 1),
  160. PLL_PARAMS(82, 1),
  161. { /* sentinel */ }
  162. };
  163. static struct clk_regmap meson8b_hdmi_pll_dco = {
  164. .data = &(struct meson_clk_pll_data){
  165. .en = {
  166. .reg_off = HHI_VID_PLL_CNTL,
  167. .shift = 30,
  168. .width = 1,
  169. },
  170. .m = {
  171. .reg_off = HHI_VID_PLL_CNTL,
  172. .shift = 0,
  173. .width = 9,
  174. },
  175. .n = {
  176. .reg_off = HHI_VID_PLL_CNTL,
  177. .shift = 10,
  178. .width = 5,
  179. },
  180. .frac = {
  181. .reg_off = HHI_VID_PLL_CNTL2,
  182. .shift = 0,
  183. .width = 12,
  184. },
  185. .l = {
  186. .reg_off = HHI_VID_PLL_CNTL,
  187. .shift = 31,
  188. .width = 1,
  189. },
  190. .rst = {
  191. .reg_off = HHI_VID_PLL_CNTL,
  192. .shift = 29,
  193. .width = 1,
  194. },
  195. .table = hdmi_pll_params_table,
  196. .init_regs = meson8b_hdmi_pll_init_regs,
  197. .init_count = ARRAY_SIZE(meson8b_hdmi_pll_init_regs),
  198. },
  199. .hw.init = &(struct clk_init_data){
  200. /* sometimes also called "HPLL" or "HPLL PLL" */
  201. .name = "hdmi_pll_dco",
  202. .ops = &meson_clk_pll_ops,
  203. .parent_hws = (const struct clk_hw *[]) {
  204. &hdmi_pll_dco_in.hw
  205. },
  206. .num_parents = 1,
  207. },
  208. };
  209. static struct clk_regmap meson8b_hdmi_pll_lvds_out = {
  210. .data = &(struct clk_regmap_div_data){
  211. .offset = HHI_VID_PLL_CNTL,
  212. .shift = 16,
  213. .width = 2,
  214. .flags = CLK_DIVIDER_POWER_OF_TWO,
  215. },
  216. .hw.init = &(struct clk_init_data){
  217. .name = "hdmi_pll_lvds_out",
  218. .ops = &clk_regmap_divider_ops,
  219. .parent_hws = (const struct clk_hw *[]) {
  220. &meson8b_hdmi_pll_dco.hw
  221. },
  222. .num_parents = 1,
  223. .flags = CLK_SET_RATE_PARENT,
  224. },
  225. };
  226. static struct clk_regmap meson8b_hdmi_pll_hdmi_out = {
  227. .data = &(struct clk_regmap_div_data){
  228. .offset = HHI_VID_PLL_CNTL,
  229. .shift = 18,
  230. .width = 2,
  231. .flags = CLK_DIVIDER_POWER_OF_TWO,
  232. },
  233. .hw.init = &(struct clk_init_data){
  234. .name = "hdmi_pll_hdmi_out",
  235. .ops = &clk_regmap_divider_ops,
  236. .parent_hws = (const struct clk_hw *[]) {
  237. &meson8b_hdmi_pll_dco.hw
  238. },
  239. .num_parents = 1,
  240. .flags = CLK_SET_RATE_PARENT,
  241. },
  242. };
  243. static struct clk_regmap meson8b_sys_pll_dco = {
  244. .data = &(struct meson_clk_pll_data){
  245. .en = {
  246. .reg_off = HHI_SYS_PLL_CNTL,
  247. .shift = 30,
  248. .width = 1,
  249. },
  250. .m = {
  251. .reg_off = HHI_SYS_PLL_CNTL,
  252. .shift = 0,
  253. .width = 9,
  254. },
  255. .n = {
  256. .reg_off = HHI_SYS_PLL_CNTL,
  257. .shift = 9,
  258. .width = 5,
  259. },
  260. .l = {
  261. .reg_off = HHI_SYS_PLL_CNTL,
  262. .shift = 31,
  263. .width = 1,
  264. },
  265. .rst = {
  266. .reg_off = HHI_SYS_PLL_CNTL,
  267. .shift = 29,
  268. .width = 1,
  269. },
  270. .table = sys_pll_params_table,
  271. },
  272. .hw.init = &(struct clk_init_data){
  273. .name = "sys_pll_dco",
  274. .ops = &meson_clk_pll_ops,
  275. .parent_data = &(const struct clk_parent_data) {
  276. .fw_name = "xtal",
  277. .name = "xtal",
  278. .index = -1,
  279. },
  280. .num_parents = 1,
  281. },
  282. };
  283. static struct clk_regmap meson8b_sys_pll = {
  284. .data = &(struct clk_regmap_div_data){
  285. .offset = HHI_SYS_PLL_CNTL,
  286. .shift = 16,
  287. .width = 2,
  288. .flags = CLK_DIVIDER_POWER_OF_TWO,
  289. },
  290. .hw.init = &(struct clk_init_data){
  291. .name = "sys_pll",
  292. .ops = &clk_regmap_divider_ops,
  293. .parent_hws = (const struct clk_hw *[]) {
  294. &meson8b_sys_pll_dco.hw
  295. },
  296. .num_parents = 1,
  297. .flags = CLK_SET_RATE_PARENT,
  298. },
  299. };
  300. static struct clk_fixed_factor meson8b_fclk_div2_div = {
  301. .mult = 1,
  302. .div = 2,
  303. .hw.init = &(struct clk_init_data){
  304. .name = "fclk_div2_div",
  305. .ops = &clk_fixed_factor_ops,
  306. .parent_hws = (const struct clk_hw *[]) {
  307. &meson8b_fixed_pll.hw
  308. },
  309. .num_parents = 1,
  310. },
  311. };
  312. static struct clk_regmap meson8b_fclk_div2 = {
  313. .data = &(struct clk_regmap_gate_data){
  314. .offset = HHI_MPLL_CNTL6,
  315. .bit_idx = 27,
  316. },
  317. .hw.init = &(struct clk_init_data){
  318. .name = "fclk_div2",
  319. .ops = &clk_regmap_gate_ops,
  320. .parent_hws = (const struct clk_hw *[]) {
  321. &meson8b_fclk_div2_div.hw
  322. },
  323. .num_parents = 1,
  324. },
  325. };
  326. static struct clk_fixed_factor meson8b_fclk_div3_div = {
  327. .mult = 1,
  328. .div = 3,
  329. .hw.init = &(struct clk_init_data){
  330. .name = "fclk_div3_div",
  331. .ops = &clk_fixed_factor_ops,
  332. .parent_hws = (const struct clk_hw *[]) {
  333. &meson8b_fixed_pll.hw
  334. },
  335. .num_parents = 1,
  336. },
  337. };
  338. static struct clk_regmap meson8b_fclk_div3 = {
  339. .data = &(struct clk_regmap_gate_data){
  340. .offset = HHI_MPLL_CNTL6,
  341. .bit_idx = 28,
  342. },
  343. .hw.init = &(struct clk_init_data){
  344. .name = "fclk_div3",
  345. .ops = &clk_regmap_gate_ops,
  346. .parent_hws = (const struct clk_hw *[]) {
  347. &meson8b_fclk_div3_div.hw
  348. },
  349. .num_parents = 1,
  350. },
  351. };
  352. static struct clk_fixed_factor meson8b_fclk_div4_div = {
  353. .mult = 1,
  354. .div = 4,
  355. .hw.init = &(struct clk_init_data){
  356. .name = "fclk_div4_div",
  357. .ops = &clk_fixed_factor_ops,
  358. .parent_hws = (const struct clk_hw *[]) {
  359. &meson8b_fixed_pll.hw
  360. },
  361. .num_parents = 1,
  362. },
  363. };
  364. static struct clk_regmap meson8b_fclk_div4 = {
  365. .data = &(struct clk_regmap_gate_data){
  366. .offset = HHI_MPLL_CNTL6,
  367. .bit_idx = 29,
  368. },
  369. .hw.init = &(struct clk_init_data){
  370. .name = "fclk_div4",
  371. .ops = &clk_regmap_gate_ops,
  372. .parent_hws = (const struct clk_hw *[]) {
  373. &meson8b_fclk_div4_div.hw
  374. },
  375. .num_parents = 1,
  376. },
  377. };
  378. static struct clk_fixed_factor meson8b_fclk_div5_div = {
  379. .mult = 1,
  380. .div = 5,
  381. .hw.init = &(struct clk_init_data){
  382. .name = "fclk_div5_div",
  383. .ops = &clk_fixed_factor_ops,
  384. .parent_hws = (const struct clk_hw *[]) {
  385. &meson8b_fixed_pll.hw
  386. },
  387. .num_parents = 1,
  388. },
  389. };
  390. static struct clk_regmap meson8b_fclk_div5 = {
  391. .data = &(struct clk_regmap_gate_data){
  392. .offset = HHI_MPLL_CNTL6,
  393. .bit_idx = 30,
  394. },
  395. .hw.init = &(struct clk_init_data){
  396. .name = "fclk_div5",
  397. .ops = &clk_regmap_gate_ops,
  398. .parent_hws = (const struct clk_hw *[]) {
  399. &meson8b_fclk_div5_div.hw
  400. },
  401. .num_parents = 1,
  402. },
  403. };
  404. static struct clk_fixed_factor meson8b_fclk_div7_div = {
  405. .mult = 1,
  406. .div = 7,
  407. .hw.init = &(struct clk_init_data){
  408. .name = "fclk_div7_div",
  409. .ops = &clk_fixed_factor_ops,
  410. .parent_hws = (const struct clk_hw *[]) {
  411. &meson8b_fixed_pll.hw
  412. },
  413. .num_parents = 1,
  414. },
  415. };
  416. static struct clk_regmap meson8b_fclk_div7 = {
  417. .data = &(struct clk_regmap_gate_data){
  418. .offset = HHI_MPLL_CNTL6,
  419. .bit_idx = 31,
  420. },
  421. .hw.init = &(struct clk_init_data){
  422. .name = "fclk_div7",
  423. .ops = &clk_regmap_gate_ops,
  424. .parent_hws = (const struct clk_hw *[]) {
  425. &meson8b_fclk_div7_div.hw
  426. },
  427. .num_parents = 1,
  428. },
  429. };
  430. static struct clk_regmap meson8b_mpll_prediv = {
  431. .data = &(struct clk_regmap_div_data){
  432. .offset = HHI_MPLL_CNTL5,
  433. .shift = 12,
  434. .width = 1,
  435. },
  436. .hw.init = &(struct clk_init_data){
  437. .name = "mpll_prediv",
  438. .ops = &clk_regmap_divider_ro_ops,
  439. .parent_hws = (const struct clk_hw *[]) {
  440. &meson8b_fixed_pll.hw
  441. },
  442. .num_parents = 1,
  443. },
  444. };
  445. static struct clk_regmap meson8b_mpll0_div = {
  446. .data = &(struct meson_clk_mpll_data){
  447. .sdm = {
  448. .reg_off = HHI_MPLL_CNTL7,
  449. .shift = 0,
  450. .width = 14,
  451. },
  452. .sdm_en = {
  453. .reg_off = HHI_MPLL_CNTL7,
  454. .shift = 15,
  455. .width = 1,
  456. },
  457. .n2 = {
  458. .reg_off = HHI_MPLL_CNTL7,
  459. .shift = 16,
  460. .width = 9,
  461. },
  462. .ssen = {
  463. .reg_off = HHI_MPLL_CNTL,
  464. .shift = 25,
  465. .width = 1,
  466. },
  467. .lock = &meson_clk_lock,
  468. },
  469. .hw.init = &(struct clk_init_data){
  470. .name = "mpll0_div",
  471. .ops = &meson_clk_mpll_ops,
  472. .parent_hws = (const struct clk_hw *[]) {
  473. &meson8b_mpll_prediv.hw
  474. },
  475. .num_parents = 1,
  476. },
  477. };
  478. static struct clk_regmap meson8b_mpll0 = {
  479. .data = &(struct clk_regmap_gate_data){
  480. .offset = HHI_MPLL_CNTL7,
  481. .bit_idx = 14,
  482. },
  483. .hw.init = &(struct clk_init_data){
  484. .name = "mpll0",
  485. .ops = &clk_regmap_gate_ops,
  486. .parent_hws = (const struct clk_hw *[]) {
  487. &meson8b_mpll0_div.hw
  488. },
  489. .num_parents = 1,
  490. .flags = CLK_SET_RATE_PARENT,
  491. },
  492. };
  493. static struct clk_regmap meson8b_mpll1_div = {
  494. .data = &(struct meson_clk_mpll_data){
  495. .sdm = {
  496. .reg_off = HHI_MPLL_CNTL8,
  497. .shift = 0,
  498. .width = 14,
  499. },
  500. .sdm_en = {
  501. .reg_off = HHI_MPLL_CNTL8,
  502. .shift = 15,
  503. .width = 1,
  504. },
  505. .n2 = {
  506. .reg_off = HHI_MPLL_CNTL8,
  507. .shift = 16,
  508. .width = 9,
  509. },
  510. .lock = &meson_clk_lock,
  511. },
  512. .hw.init = &(struct clk_init_data){
  513. .name = "mpll1_div",
  514. .ops = &meson_clk_mpll_ops,
  515. .parent_hws = (const struct clk_hw *[]) {
  516. &meson8b_mpll_prediv.hw
  517. },
  518. .num_parents = 1,
  519. },
  520. };
  521. static struct clk_regmap meson8b_mpll1 = {
  522. .data = &(struct clk_regmap_gate_data){
  523. .offset = HHI_MPLL_CNTL8,
  524. .bit_idx = 14,
  525. },
  526. .hw.init = &(struct clk_init_data){
  527. .name = "mpll1",
  528. .ops = &clk_regmap_gate_ops,
  529. .parent_hws = (const struct clk_hw *[]) {
  530. &meson8b_mpll1_div.hw
  531. },
  532. .num_parents = 1,
  533. .flags = CLK_SET_RATE_PARENT,
  534. },
  535. };
  536. static struct clk_regmap meson8b_mpll2_div = {
  537. .data = &(struct meson_clk_mpll_data){
  538. .sdm = {
  539. .reg_off = HHI_MPLL_CNTL9,
  540. .shift = 0,
  541. .width = 14,
  542. },
  543. .sdm_en = {
  544. .reg_off = HHI_MPLL_CNTL9,
  545. .shift = 15,
  546. .width = 1,
  547. },
  548. .n2 = {
  549. .reg_off = HHI_MPLL_CNTL9,
  550. .shift = 16,
  551. .width = 9,
  552. },
  553. .lock = &meson_clk_lock,
  554. },
  555. .hw.init = &(struct clk_init_data){
  556. .name = "mpll2_div",
  557. .ops = &meson_clk_mpll_ops,
  558. .parent_hws = (const struct clk_hw *[]) {
  559. &meson8b_mpll_prediv.hw
  560. },
  561. .num_parents = 1,
  562. },
  563. };
  564. static struct clk_regmap meson8b_mpll2 = {
  565. .data = &(struct clk_regmap_gate_data){
  566. .offset = HHI_MPLL_CNTL9,
  567. .bit_idx = 14,
  568. },
  569. .hw.init = &(struct clk_init_data){
  570. .name = "mpll2",
  571. .ops = &clk_regmap_gate_ops,
  572. .parent_hws = (const struct clk_hw *[]) {
  573. &meson8b_mpll2_div.hw
  574. },
  575. .num_parents = 1,
  576. .flags = CLK_SET_RATE_PARENT,
  577. },
  578. };
  579. static u32 mux_table_clk81[] = { 6, 5, 7 };
  580. static struct clk_regmap meson8b_mpeg_clk_sel = {
  581. .data = &(struct clk_regmap_mux_data){
  582. .offset = HHI_MPEG_CLK_CNTL,
  583. .mask = 0x7,
  584. .shift = 12,
  585. .table = mux_table_clk81,
  586. },
  587. .hw.init = &(struct clk_init_data){
  588. .name = "mpeg_clk_sel",
  589. .ops = &clk_regmap_mux_ro_ops,
  590. /*
  591. * FIXME bits 14:12 selects from 8 possible parents:
  592. * xtal, 1'b0 (wtf), fclk_div7, mpll_clkout1, mpll_clkout2,
  593. * fclk_div4, fclk_div3, fclk_div5
  594. */
  595. .parent_hws = (const struct clk_hw *[]) {
  596. &meson8b_fclk_div3.hw,
  597. &meson8b_fclk_div4.hw,
  598. &meson8b_fclk_div5.hw,
  599. },
  600. .num_parents = 3,
  601. },
  602. };
  603. static struct clk_regmap meson8b_mpeg_clk_div = {
  604. .data = &(struct clk_regmap_div_data){
  605. .offset = HHI_MPEG_CLK_CNTL,
  606. .shift = 0,
  607. .width = 7,
  608. },
  609. .hw.init = &(struct clk_init_data){
  610. .name = "mpeg_clk_div",
  611. .ops = &clk_regmap_divider_ro_ops,
  612. .parent_hws = (const struct clk_hw *[]) {
  613. &meson8b_mpeg_clk_sel.hw
  614. },
  615. .num_parents = 1,
  616. },
  617. };
  618. static struct clk_regmap meson8b_clk81 = {
  619. .data = &(struct clk_regmap_gate_data){
  620. .offset = HHI_MPEG_CLK_CNTL,
  621. .bit_idx = 7,
  622. },
  623. .hw.init = &(struct clk_init_data){
  624. .name = "clk81",
  625. .ops = &clk_regmap_gate_ops,
  626. .parent_hws = (const struct clk_hw *[]) {
  627. &meson8b_mpeg_clk_div.hw
  628. },
  629. .num_parents = 1,
  630. .flags = CLK_IS_CRITICAL,
  631. },
  632. };
  633. static struct clk_regmap meson8b_cpu_in_sel = {
  634. .data = &(struct clk_regmap_mux_data){
  635. .offset = HHI_SYS_CPU_CLK_CNTL0,
  636. .mask = 0x1,
  637. .shift = 0,
  638. },
  639. .hw.init = &(struct clk_init_data){
  640. .name = "cpu_in_sel",
  641. .ops = &clk_regmap_mux_ops,
  642. .parent_data = (const struct clk_parent_data[]) {
  643. { .fw_name = "xtal", .name = "xtal", .index = -1, },
  644. { .hw = &meson8b_sys_pll.hw, },
  645. },
  646. .num_parents = 2,
  647. .flags = (CLK_SET_RATE_PARENT |
  648. CLK_SET_RATE_NO_REPARENT),
  649. },
  650. };
  651. static struct clk_fixed_factor meson8b_cpu_in_div2 = {
  652. .mult = 1,
  653. .div = 2,
  654. .hw.init = &(struct clk_init_data){
  655. .name = "cpu_in_div2",
  656. .ops = &clk_fixed_factor_ops,
  657. .parent_hws = (const struct clk_hw *[]) {
  658. &meson8b_cpu_in_sel.hw
  659. },
  660. .num_parents = 1,
  661. .flags = CLK_SET_RATE_PARENT,
  662. },
  663. };
  664. static struct clk_fixed_factor meson8b_cpu_in_div3 = {
  665. .mult = 1,
  666. .div = 3,
  667. .hw.init = &(struct clk_init_data){
  668. .name = "cpu_in_div3",
  669. .ops = &clk_fixed_factor_ops,
  670. .parent_hws = (const struct clk_hw *[]) {
  671. &meson8b_cpu_in_sel.hw
  672. },
  673. .num_parents = 1,
  674. .flags = CLK_SET_RATE_PARENT,
  675. },
  676. };
  677. static const struct clk_div_table cpu_scale_table[] = {
  678. { .val = 1, .div = 4 },
  679. { .val = 2, .div = 6 },
  680. { .val = 3, .div = 8 },
  681. { .val = 4, .div = 10 },
  682. { .val = 5, .div = 12 },
  683. { .val = 6, .div = 14 },
  684. { .val = 7, .div = 16 },
  685. { .val = 8, .div = 18 },
  686. { /* sentinel */ },
  687. };
  688. static struct clk_regmap meson8b_cpu_scale_div = {
  689. .data = &(struct clk_regmap_div_data){
  690. .offset = HHI_SYS_CPU_CLK_CNTL1,
  691. .shift = 20,
  692. .width = 10,
  693. .table = cpu_scale_table,
  694. .flags = CLK_DIVIDER_ALLOW_ZERO,
  695. },
  696. .hw.init = &(struct clk_init_data){
  697. .name = "cpu_scale_div",
  698. .ops = &clk_regmap_divider_ops,
  699. .parent_hws = (const struct clk_hw *[]) {
  700. &meson8b_cpu_in_sel.hw
  701. },
  702. .num_parents = 1,
  703. .flags = CLK_SET_RATE_PARENT,
  704. },
  705. };
  706. static u32 mux_table_cpu_scale_out_sel[] = { 0, 1, 3 };
  707. static struct clk_regmap meson8b_cpu_scale_out_sel = {
  708. .data = &(struct clk_regmap_mux_data){
  709. .offset = HHI_SYS_CPU_CLK_CNTL0,
  710. .mask = 0x3,
  711. .shift = 2,
  712. .table = mux_table_cpu_scale_out_sel,
  713. },
  714. .hw.init = &(struct clk_init_data){
  715. .name = "cpu_scale_out_sel",
  716. .ops = &clk_regmap_mux_ops,
  717. /*
  718. * NOTE: We are skipping the parent with value 0x2 (which is
  719. * meson8b_cpu_in_div3) because it results in a duty cycle of
  720. * 33% which makes the system unstable and can result in a
  721. * lockup of the whole system.
  722. */
  723. .parent_hws = (const struct clk_hw *[]) {
  724. &meson8b_cpu_in_sel.hw,
  725. &meson8b_cpu_in_div2.hw,
  726. &meson8b_cpu_scale_div.hw,
  727. },
  728. .num_parents = 3,
  729. .flags = CLK_SET_RATE_PARENT,
  730. },
  731. };
  732. static struct clk_regmap meson8b_cpu_clk = {
  733. .data = &(struct clk_regmap_mux_data){
  734. .offset = HHI_SYS_CPU_CLK_CNTL0,
  735. .mask = 0x1,
  736. .shift = 7,
  737. },
  738. .hw.init = &(struct clk_init_data){
  739. .name = "cpu_clk",
  740. .ops = &clk_regmap_mux_ops,
  741. .parent_data = (const struct clk_parent_data[]) {
  742. { .fw_name = "xtal", .name = "xtal", .index = -1, },
  743. { .hw = &meson8b_cpu_scale_out_sel.hw, },
  744. },
  745. .num_parents = 2,
  746. .flags = (CLK_SET_RATE_PARENT |
  747. CLK_SET_RATE_NO_REPARENT |
  748. CLK_IS_CRITICAL),
  749. },
  750. };
  751. static struct clk_regmap meson8b_nand_clk_sel = {
  752. .data = &(struct clk_regmap_mux_data){
  753. .offset = HHI_NAND_CLK_CNTL,
  754. .mask = 0x7,
  755. .shift = 9,
  756. .flags = CLK_MUX_ROUND_CLOSEST,
  757. },
  758. .hw.init = &(struct clk_init_data){
  759. .name = "nand_clk_sel",
  760. .ops = &clk_regmap_mux_ops,
  761. /* FIXME all other parents are unknown: */
  762. .parent_data = (const struct clk_parent_data[]) {
  763. { .hw = &meson8b_fclk_div4.hw, },
  764. { .hw = &meson8b_fclk_div3.hw, },
  765. { .hw = &meson8b_fclk_div5.hw, },
  766. { .hw = &meson8b_fclk_div7.hw, },
  767. { .fw_name = "xtal", .name = "xtal", .index = -1, },
  768. },
  769. .num_parents = 5,
  770. .flags = CLK_SET_RATE_PARENT,
  771. },
  772. };
  773. static struct clk_regmap meson8b_nand_clk_div = {
  774. .data = &(struct clk_regmap_div_data){
  775. .offset = HHI_NAND_CLK_CNTL,
  776. .shift = 0,
  777. .width = 7,
  778. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  779. },
  780. .hw.init = &(struct clk_init_data){
  781. .name = "nand_clk_div",
  782. .ops = &clk_regmap_divider_ops,
  783. .parent_hws = (const struct clk_hw *[]) {
  784. &meson8b_nand_clk_sel.hw
  785. },
  786. .num_parents = 1,
  787. .flags = CLK_SET_RATE_PARENT,
  788. },
  789. };
  790. static struct clk_regmap meson8b_nand_clk_gate = {
  791. .data = &(struct clk_regmap_gate_data){
  792. .offset = HHI_NAND_CLK_CNTL,
  793. .bit_idx = 8,
  794. },
  795. .hw.init = &(struct clk_init_data){
  796. .name = "nand_clk_gate",
  797. .ops = &clk_regmap_gate_ops,
  798. .parent_hws = (const struct clk_hw *[]) {
  799. &meson8b_nand_clk_div.hw
  800. },
  801. .num_parents = 1,
  802. .flags = CLK_SET_RATE_PARENT,
  803. },
  804. };
  805. static struct clk_fixed_factor meson8b_cpu_clk_div2 = {
  806. .mult = 1,
  807. .div = 2,
  808. .hw.init = &(struct clk_init_data){
  809. .name = "cpu_clk_div2",
  810. .ops = &clk_fixed_factor_ops,
  811. .parent_hws = (const struct clk_hw *[]) {
  812. &meson8b_cpu_clk.hw
  813. },
  814. .num_parents = 1,
  815. },
  816. };
  817. static struct clk_fixed_factor meson8b_cpu_clk_div3 = {
  818. .mult = 1,
  819. .div = 3,
  820. .hw.init = &(struct clk_init_data){
  821. .name = "cpu_clk_div3",
  822. .ops = &clk_fixed_factor_ops,
  823. .parent_hws = (const struct clk_hw *[]) {
  824. &meson8b_cpu_clk.hw
  825. },
  826. .num_parents = 1,
  827. },
  828. };
  829. static struct clk_fixed_factor meson8b_cpu_clk_div4 = {
  830. .mult = 1,
  831. .div = 4,
  832. .hw.init = &(struct clk_init_data){
  833. .name = "cpu_clk_div4",
  834. .ops = &clk_fixed_factor_ops,
  835. .parent_hws = (const struct clk_hw *[]) {
  836. &meson8b_cpu_clk.hw
  837. },
  838. .num_parents = 1,
  839. },
  840. };
  841. static struct clk_fixed_factor meson8b_cpu_clk_div5 = {
  842. .mult = 1,
  843. .div = 5,
  844. .hw.init = &(struct clk_init_data){
  845. .name = "cpu_clk_div5",
  846. .ops = &clk_fixed_factor_ops,
  847. .parent_hws = (const struct clk_hw *[]) {
  848. &meson8b_cpu_clk.hw
  849. },
  850. .num_parents = 1,
  851. },
  852. };
  853. static struct clk_fixed_factor meson8b_cpu_clk_div6 = {
  854. .mult = 1,
  855. .div = 6,
  856. .hw.init = &(struct clk_init_data){
  857. .name = "cpu_clk_div6",
  858. .ops = &clk_fixed_factor_ops,
  859. .parent_hws = (const struct clk_hw *[]) {
  860. &meson8b_cpu_clk.hw
  861. },
  862. .num_parents = 1,
  863. },
  864. };
  865. static struct clk_fixed_factor meson8b_cpu_clk_div7 = {
  866. .mult = 1,
  867. .div = 7,
  868. .hw.init = &(struct clk_init_data){
  869. .name = "cpu_clk_div7",
  870. .ops = &clk_fixed_factor_ops,
  871. .parent_hws = (const struct clk_hw *[]) {
  872. &meson8b_cpu_clk.hw
  873. },
  874. .num_parents = 1,
  875. },
  876. };
  877. static struct clk_fixed_factor meson8b_cpu_clk_div8 = {
  878. .mult = 1,
  879. .div = 8,
  880. .hw.init = &(struct clk_init_data){
  881. .name = "cpu_clk_div8",
  882. .ops = &clk_fixed_factor_ops,
  883. .parent_hws = (const struct clk_hw *[]) {
  884. &meson8b_cpu_clk.hw
  885. },
  886. .num_parents = 1,
  887. },
  888. };
  889. static u32 mux_table_apb[] = { 1, 2, 3, 4, 5, 6, 7 };
  890. static struct clk_regmap meson8b_apb_clk_sel = {
  891. .data = &(struct clk_regmap_mux_data){
  892. .offset = HHI_SYS_CPU_CLK_CNTL1,
  893. .mask = 0x7,
  894. .shift = 3,
  895. .table = mux_table_apb,
  896. },
  897. .hw.init = &(struct clk_init_data){
  898. .name = "apb_clk_sel",
  899. .ops = &clk_regmap_mux_ops,
  900. .parent_hws = (const struct clk_hw *[]) {
  901. &meson8b_cpu_clk_div2.hw,
  902. &meson8b_cpu_clk_div3.hw,
  903. &meson8b_cpu_clk_div4.hw,
  904. &meson8b_cpu_clk_div5.hw,
  905. &meson8b_cpu_clk_div6.hw,
  906. &meson8b_cpu_clk_div7.hw,
  907. &meson8b_cpu_clk_div8.hw,
  908. },
  909. .num_parents = 7,
  910. },
  911. };
  912. static struct clk_regmap meson8b_apb_clk_gate = {
  913. .data = &(struct clk_regmap_gate_data){
  914. .offset = HHI_SYS_CPU_CLK_CNTL1,
  915. .bit_idx = 16,
  916. .flags = CLK_GATE_SET_TO_DISABLE,
  917. },
  918. .hw.init = &(struct clk_init_data){
  919. .name = "apb_clk_dis",
  920. .ops = &clk_regmap_gate_ro_ops,
  921. .parent_hws = (const struct clk_hw *[]) {
  922. &meson8b_apb_clk_sel.hw
  923. },
  924. .num_parents = 1,
  925. .flags = CLK_SET_RATE_PARENT,
  926. },
  927. };
  928. static struct clk_regmap meson8b_periph_clk_sel = {
  929. .data = &(struct clk_regmap_mux_data){
  930. .offset = HHI_SYS_CPU_CLK_CNTL1,
  931. .mask = 0x7,
  932. .shift = 6,
  933. },
  934. .hw.init = &(struct clk_init_data){
  935. .name = "periph_clk_sel",
  936. .ops = &clk_regmap_mux_ops,
  937. .parent_hws = (const struct clk_hw *[]) {
  938. &meson8b_cpu_clk_div2.hw,
  939. &meson8b_cpu_clk_div3.hw,
  940. &meson8b_cpu_clk_div4.hw,
  941. &meson8b_cpu_clk_div5.hw,
  942. &meson8b_cpu_clk_div6.hw,
  943. &meson8b_cpu_clk_div7.hw,
  944. &meson8b_cpu_clk_div8.hw,
  945. },
  946. .num_parents = 7,
  947. },
  948. };
  949. static struct clk_regmap meson8b_periph_clk_gate = {
  950. .data = &(struct clk_regmap_gate_data){
  951. .offset = HHI_SYS_CPU_CLK_CNTL1,
  952. .bit_idx = 17,
  953. .flags = CLK_GATE_SET_TO_DISABLE,
  954. },
  955. .hw.init = &(struct clk_init_data){
  956. .name = "periph_clk_dis",
  957. .ops = &clk_regmap_gate_ro_ops,
  958. .parent_hws = (const struct clk_hw *[]) {
  959. &meson8b_periph_clk_sel.hw
  960. },
  961. .num_parents = 1,
  962. .flags = CLK_SET_RATE_PARENT,
  963. },
  964. };
  965. static u32 mux_table_axi[] = { 1, 2, 3, 4, 5, 6, 7 };
  966. static struct clk_regmap meson8b_axi_clk_sel = {
  967. .data = &(struct clk_regmap_mux_data){
  968. .offset = HHI_SYS_CPU_CLK_CNTL1,
  969. .mask = 0x7,
  970. .shift = 9,
  971. .table = mux_table_axi,
  972. },
  973. .hw.init = &(struct clk_init_data){
  974. .name = "axi_clk_sel",
  975. .ops = &clk_regmap_mux_ops,
  976. .parent_hws = (const struct clk_hw *[]) {
  977. &meson8b_cpu_clk_div2.hw,
  978. &meson8b_cpu_clk_div3.hw,
  979. &meson8b_cpu_clk_div4.hw,
  980. &meson8b_cpu_clk_div5.hw,
  981. &meson8b_cpu_clk_div6.hw,
  982. &meson8b_cpu_clk_div7.hw,
  983. &meson8b_cpu_clk_div8.hw,
  984. },
  985. .num_parents = 7,
  986. },
  987. };
  988. static struct clk_regmap meson8b_axi_clk_gate = {
  989. .data = &(struct clk_regmap_gate_data){
  990. .offset = HHI_SYS_CPU_CLK_CNTL1,
  991. .bit_idx = 18,
  992. .flags = CLK_GATE_SET_TO_DISABLE,
  993. },
  994. .hw.init = &(struct clk_init_data){
  995. .name = "axi_clk_dis",
  996. .ops = &clk_regmap_gate_ro_ops,
  997. .parent_hws = (const struct clk_hw *[]) {
  998. &meson8b_axi_clk_sel.hw
  999. },
  1000. .num_parents = 1,
  1001. .flags = CLK_SET_RATE_PARENT,
  1002. },
  1003. };
  1004. static struct clk_regmap meson8b_l2_dram_clk_sel = {
  1005. .data = &(struct clk_regmap_mux_data){
  1006. .offset = HHI_SYS_CPU_CLK_CNTL1,
  1007. .mask = 0x7,
  1008. .shift = 12,
  1009. },
  1010. .hw.init = &(struct clk_init_data){
  1011. .name = "l2_dram_clk_sel",
  1012. .ops = &clk_regmap_mux_ops,
  1013. .parent_hws = (const struct clk_hw *[]) {
  1014. &meson8b_cpu_clk_div2.hw,
  1015. &meson8b_cpu_clk_div3.hw,
  1016. &meson8b_cpu_clk_div4.hw,
  1017. &meson8b_cpu_clk_div5.hw,
  1018. &meson8b_cpu_clk_div6.hw,
  1019. &meson8b_cpu_clk_div7.hw,
  1020. &meson8b_cpu_clk_div8.hw,
  1021. },
  1022. .num_parents = 7,
  1023. },
  1024. };
  1025. static struct clk_regmap meson8b_l2_dram_clk_gate = {
  1026. .data = &(struct clk_regmap_gate_data){
  1027. .offset = HHI_SYS_CPU_CLK_CNTL1,
  1028. .bit_idx = 19,
  1029. .flags = CLK_GATE_SET_TO_DISABLE,
  1030. },
  1031. .hw.init = &(struct clk_init_data){
  1032. .name = "l2_dram_clk_dis",
  1033. .ops = &clk_regmap_gate_ro_ops,
  1034. .parent_hws = (const struct clk_hw *[]) {
  1035. &meson8b_l2_dram_clk_sel.hw
  1036. },
  1037. .num_parents = 1,
  1038. .flags = CLK_SET_RATE_PARENT,
  1039. },
  1040. };
  1041. /* also called LVDS_CLK_EN */
  1042. static struct clk_regmap meson8b_vid_pll_lvds_en = {
  1043. .data = &(struct clk_regmap_gate_data){
  1044. .offset = HHI_VID_DIVIDER_CNTL,
  1045. .bit_idx = 11,
  1046. },
  1047. .hw.init = &(struct clk_init_data){
  1048. .name = "vid_pll_lvds_en",
  1049. .ops = &clk_regmap_gate_ops,
  1050. .parent_hws = (const struct clk_hw *[]) {
  1051. &meson8b_hdmi_pll_lvds_out.hw
  1052. },
  1053. .num_parents = 1,
  1054. .flags = CLK_SET_RATE_PARENT,
  1055. },
  1056. };
  1057. static struct clk_regmap meson8b_vid_pll_in_sel = {
  1058. .data = &(struct clk_regmap_mux_data){
  1059. .offset = HHI_VID_DIVIDER_CNTL,
  1060. .mask = 0x1,
  1061. .shift = 15,
  1062. },
  1063. .hw.init = &(struct clk_init_data){
  1064. .name = "vid_pll_in_sel",
  1065. .ops = &clk_regmap_mux_ops,
  1066. /*
  1067. * TODO: depending on the SoC there is also a second parent:
  1068. * Meson8: unknown
  1069. * Meson8b: hdmi_pll_dco
  1070. * Meson8m2: vid2_pll
  1071. */
  1072. .parent_hws = (const struct clk_hw *[]) {
  1073. &meson8b_vid_pll_lvds_en.hw
  1074. },
  1075. .num_parents = 1,
  1076. .flags = CLK_SET_RATE_PARENT,
  1077. },
  1078. };
  1079. static struct clk_regmap meson8b_vid_pll_in_en = {
  1080. .data = &(struct clk_regmap_gate_data){
  1081. .offset = HHI_VID_DIVIDER_CNTL,
  1082. .bit_idx = 16,
  1083. },
  1084. .hw.init = &(struct clk_init_data){
  1085. .name = "vid_pll_in_en",
  1086. .ops = &clk_regmap_gate_ops,
  1087. .parent_hws = (const struct clk_hw *[]) {
  1088. &meson8b_vid_pll_in_sel.hw
  1089. },
  1090. .num_parents = 1,
  1091. .flags = CLK_SET_RATE_PARENT,
  1092. },
  1093. };
  1094. static struct clk_regmap meson8b_vid_pll_pre_div = {
  1095. .data = &(struct clk_regmap_div_data){
  1096. .offset = HHI_VID_DIVIDER_CNTL,
  1097. .shift = 4,
  1098. .width = 3,
  1099. },
  1100. .hw.init = &(struct clk_init_data){
  1101. .name = "vid_pll_pre_div",
  1102. .ops = &clk_regmap_divider_ops,
  1103. .parent_hws = (const struct clk_hw *[]) {
  1104. &meson8b_vid_pll_in_en.hw
  1105. },
  1106. .num_parents = 1,
  1107. .flags = CLK_SET_RATE_PARENT,
  1108. },
  1109. };
  1110. static struct clk_regmap meson8b_vid_pll_post_div = {
  1111. .data = &(struct clk_regmap_div_data){
  1112. .offset = HHI_VID_DIVIDER_CNTL,
  1113. .shift = 12,
  1114. .width = 3,
  1115. },
  1116. .hw.init = &(struct clk_init_data){
  1117. .name = "vid_pll_post_div",
  1118. .ops = &clk_regmap_divider_ops,
  1119. .parent_hws = (const struct clk_hw *[]) {
  1120. &meson8b_vid_pll_pre_div.hw
  1121. },
  1122. .num_parents = 1,
  1123. .flags = CLK_SET_RATE_PARENT,
  1124. },
  1125. };
  1126. static struct clk_regmap meson8b_vid_pll = {
  1127. .data = &(struct clk_regmap_mux_data){
  1128. .offset = HHI_VID_DIVIDER_CNTL,
  1129. .mask = 0x3,
  1130. .shift = 8,
  1131. },
  1132. .hw.init = &(struct clk_init_data){
  1133. .name = "vid_pll",
  1134. .ops = &clk_regmap_mux_ops,
  1135. /* TODO: parent 0x2 is vid_pll_pre_div_mult7_div2 */
  1136. .parent_hws = (const struct clk_hw *[]) {
  1137. &meson8b_vid_pll_pre_div.hw,
  1138. &meson8b_vid_pll_post_div.hw,
  1139. },
  1140. .num_parents = 2,
  1141. .flags = CLK_SET_RATE_PARENT,
  1142. },
  1143. };
  1144. static struct clk_regmap meson8b_vid_pll_final_div = {
  1145. .data = &(struct clk_regmap_div_data){
  1146. .offset = HHI_VID_CLK_DIV,
  1147. .shift = 0,
  1148. .width = 8,
  1149. },
  1150. .hw.init = &(struct clk_init_data){
  1151. .name = "vid_pll_final_div",
  1152. .ops = &clk_regmap_divider_ops,
  1153. .parent_hws = (const struct clk_hw *[]) {
  1154. &meson8b_vid_pll.hw
  1155. },
  1156. .num_parents = 1,
  1157. .flags = CLK_SET_RATE_PARENT,
  1158. },
  1159. };
  1160. static const struct clk_hw *meson8b_vclk_mux_parent_hws[] = {
  1161. &meson8b_vid_pll_final_div.hw,
  1162. &meson8b_fclk_div4.hw,
  1163. &meson8b_fclk_div3.hw,
  1164. &meson8b_fclk_div5.hw,
  1165. &meson8b_vid_pll_final_div.hw,
  1166. &meson8b_fclk_div7.hw,
  1167. &meson8b_mpll1.hw,
  1168. };
  1169. static struct clk_regmap meson8b_vclk_in_sel = {
  1170. .data = &(struct clk_regmap_mux_data){
  1171. .offset = HHI_VID_CLK_CNTL,
  1172. .mask = 0x7,
  1173. .shift = 16,
  1174. },
  1175. .hw.init = &(struct clk_init_data){
  1176. .name = "vclk_in_sel",
  1177. .ops = &clk_regmap_mux_ops,
  1178. .parent_hws = meson8b_vclk_mux_parent_hws,
  1179. .num_parents = ARRAY_SIZE(meson8b_vclk_mux_parent_hws),
  1180. .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
  1181. },
  1182. };
  1183. static struct clk_regmap meson8b_vclk_in_en = {
  1184. .data = &(struct clk_regmap_gate_data){
  1185. .offset = HHI_VID_CLK_DIV,
  1186. .bit_idx = 16,
  1187. },
  1188. .hw.init = &(struct clk_init_data){
  1189. .name = "vclk_in_en",
  1190. .ops = &clk_regmap_gate_ops,
  1191. .parent_hws = (const struct clk_hw *[]) {
  1192. &meson8b_vclk_in_sel.hw
  1193. },
  1194. .num_parents = 1,
  1195. .flags = CLK_SET_RATE_PARENT,
  1196. },
  1197. };
  1198. static struct clk_regmap meson8b_vclk_en = {
  1199. .data = &(struct clk_regmap_gate_data){
  1200. .offset = HHI_VID_CLK_CNTL,
  1201. .bit_idx = 19,
  1202. },
  1203. .hw.init = &(struct clk_init_data){
  1204. .name = "vclk_en",
  1205. .ops = &clk_regmap_gate_ops,
  1206. .parent_hws = (const struct clk_hw *[]) {
  1207. &meson8b_vclk_in_en.hw
  1208. },
  1209. .num_parents = 1,
  1210. .flags = CLK_SET_RATE_PARENT,
  1211. },
  1212. };
  1213. static struct clk_regmap meson8b_vclk_div1_gate = {
  1214. .data = &(struct clk_regmap_gate_data){
  1215. .offset = HHI_VID_CLK_CNTL,
  1216. .bit_idx = 0,
  1217. },
  1218. .hw.init = &(struct clk_init_data){
  1219. .name = "vclk_div1_en",
  1220. .ops = &clk_regmap_gate_ops,
  1221. .parent_hws = (const struct clk_hw *[]) {
  1222. &meson8b_vclk_en.hw
  1223. },
  1224. .num_parents = 1,
  1225. .flags = CLK_SET_RATE_PARENT,
  1226. },
  1227. };
  1228. static struct clk_fixed_factor meson8b_vclk_div2_div = {
  1229. .mult = 1,
  1230. .div = 2,
  1231. .hw.init = &(struct clk_init_data){
  1232. .name = "vclk_div2",
  1233. .ops = &clk_fixed_factor_ops,
  1234. .parent_hws = (const struct clk_hw *[]) {
  1235. &meson8b_vclk_en.hw
  1236. },
  1237. .num_parents = 1,
  1238. .flags = CLK_SET_RATE_PARENT,
  1239. }
  1240. };
  1241. static struct clk_regmap meson8b_vclk_div2_div_gate = {
  1242. .data = &(struct clk_regmap_gate_data){
  1243. .offset = HHI_VID_CLK_CNTL,
  1244. .bit_idx = 1,
  1245. },
  1246. .hw.init = &(struct clk_init_data){
  1247. .name = "vclk_div2_en",
  1248. .ops = &clk_regmap_gate_ops,
  1249. .parent_hws = (const struct clk_hw *[]) {
  1250. &meson8b_vclk_div2_div.hw
  1251. },
  1252. .num_parents = 1,
  1253. .flags = CLK_SET_RATE_PARENT,
  1254. },
  1255. };
  1256. static struct clk_fixed_factor meson8b_vclk_div4_div = {
  1257. .mult = 1,
  1258. .div = 4,
  1259. .hw.init = &(struct clk_init_data){
  1260. .name = "vclk_div4",
  1261. .ops = &clk_fixed_factor_ops,
  1262. .parent_hws = (const struct clk_hw *[]) {
  1263. &meson8b_vclk_en.hw
  1264. },
  1265. .num_parents = 1,
  1266. .flags = CLK_SET_RATE_PARENT,
  1267. }
  1268. };
  1269. static struct clk_regmap meson8b_vclk_div4_div_gate = {
  1270. .data = &(struct clk_regmap_gate_data){
  1271. .offset = HHI_VID_CLK_CNTL,
  1272. .bit_idx = 2,
  1273. },
  1274. .hw.init = &(struct clk_init_data){
  1275. .name = "vclk_div4_en",
  1276. .ops = &clk_regmap_gate_ops,
  1277. .parent_hws = (const struct clk_hw *[]) {
  1278. &meson8b_vclk_div4_div.hw
  1279. },
  1280. .num_parents = 1,
  1281. .flags = CLK_SET_RATE_PARENT,
  1282. },
  1283. };
  1284. static struct clk_fixed_factor meson8b_vclk_div6_div = {
  1285. .mult = 1,
  1286. .div = 6,
  1287. .hw.init = &(struct clk_init_data){
  1288. .name = "vclk_div6",
  1289. .ops = &clk_fixed_factor_ops,
  1290. .parent_hws = (const struct clk_hw *[]) {
  1291. &meson8b_vclk_en.hw
  1292. },
  1293. .num_parents = 1,
  1294. .flags = CLK_SET_RATE_PARENT,
  1295. }
  1296. };
  1297. static struct clk_regmap meson8b_vclk_div6_div_gate = {
  1298. .data = &(struct clk_regmap_gate_data){
  1299. .offset = HHI_VID_CLK_CNTL,
  1300. .bit_idx = 3,
  1301. },
  1302. .hw.init = &(struct clk_init_data){
  1303. .name = "vclk_div6_en",
  1304. .ops = &clk_regmap_gate_ops,
  1305. .parent_hws = (const struct clk_hw *[]) {
  1306. &meson8b_vclk_div6_div.hw
  1307. },
  1308. .num_parents = 1,
  1309. .flags = CLK_SET_RATE_PARENT,
  1310. },
  1311. };
  1312. static struct clk_fixed_factor meson8b_vclk_div12_div = {
  1313. .mult = 1,
  1314. .div = 12,
  1315. .hw.init = &(struct clk_init_data){
  1316. .name = "vclk_div12",
  1317. .ops = &clk_fixed_factor_ops,
  1318. .parent_hws = (const struct clk_hw *[]) {
  1319. &meson8b_vclk_en.hw
  1320. },
  1321. .num_parents = 1,
  1322. .flags = CLK_SET_RATE_PARENT,
  1323. }
  1324. };
  1325. static struct clk_regmap meson8b_vclk_div12_div_gate = {
  1326. .data = &(struct clk_regmap_gate_data){
  1327. .offset = HHI_VID_CLK_CNTL,
  1328. .bit_idx = 4,
  1329. },
  1330. .hw.init = &(struct clk_init_data){
  1331. .name = "vclk_div12_en",
  1332. .ops = &clk_regmap_gate_ops,
  1333. .parent_hws = (const struct clk_hw *[]) {
  1334. &meson8b_vclk_div12_div.hw
  1335. },
  1336. .num_parents = 1,
  1337. .flags = CLK_SET_RATE_PARENT,
  1338. },
  1339. };
  1340. static struct clk_regmap meson8b_vclk2_in_sel = {
  1341. .data = &(struct clk_regmap_mux_data){
  1342. .offset = HHI_VIID_CLK_CNTL,
  1343. .mask = 0x7,
  1344. .shift = 16,
  1345. },
  1346. .hw.init = &(struct clk_init_data){
  1347. .name = "vclk2_in_sel",
  1348. .ops = &clk_regmap_mux_ops,
  1349. .parent_hws = meson8b_vclk_mux_parent_hws,
  1350. .num_parents = ARRAY_SIZE(meson8b_vclk_mux_parent_hws),
  1351. .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
  1352. },
  1353. };
  1354. static struct clk_regmap meson8b_vclk2_clk_in_en = {
  1355. .data = &(struct clk_regmap_gate_data){
  1356. .offset = HHI_VIID_CLK_DIV,
  1357. .bit_idx = 16,
  1358. },
  1359. .hw.init = &(struct clk_init_data){
  1360. .name = "vclk2_in_en",
  1361. .ops = &clk_regmap_gate_ops,
  1362. .parent_hws = (const struct clk_hw *[]) {
  1363. &meson8b_vclk2_in_sel.hw
  1364. },
  1365. .num_parents = 1,
  1366. .flags = CLK_SET_RATE_PARENT,
  1367. },
  1368. };
  1369. static struct clk_regmap meson8b_vclk2_clk_en = {
  1370. .data = &(struct clk_regmap_gate_data){
  1371. .offset = HHI_VIID_CLK_DIV,
  1372. .bit_idx = 19,
  1373. },
  1374. .hw.init = &(struct clk_init_data){
  1375. .name = "vclk2_en",
  1376. .ops = &clk_regmap_gate_ops,
  1377. .parent_hws = (const struct clk_hw *[]) {
  1378. &meson8b_vclk2_clk_in_en.hw
  1379. },
  1380. .num_parents = 1,
  1381. .flags = CLK_SET_RATE_PARENT,
  1382. },
  1383. };
  1384. static struct clk_regmap meson8b_vclk2_div1_gate = {
  1385. .data = &(struct clk_regmap_gate_data){
  1386. .offset = HHI_VIID_CLK_DIV,
  1387. .bit_idx = 0,
  1388. },
  1389. .hw.init = &(struct clk_init_data){
  1390. .name = "vclk2_div1_en",
  1391. .ops = &clk_regmap_gate_ops,
  1392. .parent_hws = (const struct clk_hw *[]) {
  1393. &meson8b_vclk2_clk_en.hw
  1394. },
  1395. .num_parents = 1,
  1396. .flags = CLK_SET_RATE_PARENT,
  1397. },
  1398. };
  1399. static struct clk_fixed_factor meson8b_vclk2_div2_div = {
  1400. .mult = 1,
  1401. .div = 2,
  1402. .hw.init = &(struct clk_init_data){
  1403. .name = "vclk2_div2",
  1404. .ops = &clk_fixed_factor_ops,
  1405. .parent_hws = (const struct clk_hw *[]) {
  1406. &meson8b_vclk2_clk_en.hw
  1407. },
  1408. .num_parents = 1,
  1409. .flags = CLK_SET_RATE_PARENT,
  1410. }
  1411. };
  1412. static struct clk_regmap meson8b_vclk2_div2_div_gate = {
  1413. .data = &(struct clk_regmap_gate_data){
  1414. .offset = HHI_VIID_CLK_DIV,
  1415. .bit_idx = 1,
  1416. },
  1417. .hw.init = &(struct clk_init_data){
  1418. .name = "vclk2_div2_en",
  1419. .ops = &clk_regmap_gate_ops,
  1420. .parent_hws = (const struct clk_hw *[]) {
  1421. &meson8b_vclk2_div2_div.hw
  1422. },
  1423. .num_parents = 1,
  1424. .flags = CLK_SET_RATE_PARENT,
  1425. },
  1426. };
  1427. static struct clk_fixed_factor meson8b_vclk2_div4_div = {
  1428. .mult = 1,
  1429. .div = 4,
  1430. .hw.init = &(struct clk_init_data){
  1431. .name = "vclk2_div4",
  1432. .ops = &clk_fixed_factor_ops,
  1433. .parent_hws = (const struct clk_hw *[]) {
  1434. &meson8b_vclk2_clk_en.hw
  1435. },
  1436. .num_parents = 1,
  1437. .flags = CLK_SET_RATE_PARENT,
  1438. }
  1439. };
  1440. static struct clk_regmap meson8b_vclk2_div4_div_gate = {
  1441. .data = &(struct clk_regmap_gate_data){
  1442. .offset = HHI_VIID_CLK_DIV,
  1443. .bit_idx = 2,
  1444. },
  1445. .hw.init = &(struct clk_init_data){
  1446. .name = "vclk2_div4_en",
  1447. .ops = &clk_regmap_gate_ops,
  1448. .parent_hws = (const struct clk_hw *[]) {
  1449. &meson8b_vclk2_div4_div.hw
  1450. },
  1451. .num_parents = 1,
  1452. .flags = CLK_SET_RATE_PARENT,
  1453. },
  1454. };
  1455. static struct clk_fixed_factor meson8b_vclk2_div6_div = {
  1456. .mult = 1,
  1457. .div = 6,
  1458. .hw.init = &(struct clk_init_data){
  1459. .name = "vclk2_div6",
  1460. .ops = &clk_fixed_factor_ops,
  1461. .parent_hws = (const struct clk_hw *[]) {
  1462. &meson8b_vclk2_clk_en.hw
  1463. },
  1464. .num_parents = 1,
  1465. .flags = CLK_SET_RATE_PARENT,
  1466. }
  1467. };
  1468. static struct clk_regmap meson8b_vclk2_div6_div_gate = {
  1469. .data = &(struct clk_regmap_gate_data){
  1470. .offset = HHI_VIID_CLK_DIV,
  1471. .bit_idx = 3,
  1472. },
  1473. .hw.init = &(struct clk_init_data){
  1474. .name = "vclk2_div6_en",
  1475. .ops = &clk_regmap_gate_ops,
  1476. .parent_hws = (const struct clk_hw *[]) {
  1477. &meson8b_vclk2_div6_div.hw
  1478. },
  1479. .num_parents = 1,
  1480. .flags = CLK_SET_RATE_PARENT,
  1481. },
  1482. };
  1483. static struct clk_fixed_factor meson8b_vclk2_div12_div = {
  1484. .mult = 1,
  1485. .div = 12,
  1486. .hw.init = &(struct clk_init_data){
  1487. .name = "vclk2_div12",
  1488. .ops = &clk_fixed_factor_ops,
  1489. .parent_hws = (const struct clk_hw *[]) {
  1490. &meson8b_vclk2_clk_en.hw
  1491. },
  1492. .num_parents = 1,
  1493. .flags = CLK_SET_RATE_PARENT,
  1494. }
  1495. };
  1496. static struct clk_regmap meson8b_vclk2_div12_div_gate = {
  1497. .data = &(struct clk_regmap_gate_data){
  1498. .offset = HHI_VIID_CLK_DIV,
  1499. .bit_idx = 4,
  1500. },
  1501. .hw.init = &(struct clk_init_data){
  1502. .name = "vclk2_div12_en",
  1503. .ops = &clk_regmap_gate_ops,
  1504. .parent_hws = (const struct clk_hw *[]) {
  1505. &meson8b_vclk2_div12_div.hw
  1506. },
  1507. .num_parents = 1,
  1508. .flags = CLK_SET_RATE_PARENT,
  1509. },
  1510. };
  1511. static const struct clk_hw *meson8b_vclk_enc_mux_parent_hws[] = {
  1512. &meson8b_vclk_div1_gate.hw,
  1513. &meson8b_vclk_div2_div_gate.hw,
  1514. &meson8b_vclk_div4_div_gate.hw,
  1515. &meson8b_vclk_div6_div_gate.hw,
  1516. &meson8b_vclk_div12_div_gate.hw,
  1517. };
  1518. static struct clk_regmap meson8b_cts_enct_sel = {
  1519. .data = &(struct clk_regmap_mux_data){
  1520. .offset = HHI_VID_CLK_DIV,
  1521. .mask = 0xf,
  1522. .shift = 20,
  1523. },
  1524. .hw.init = &(struct clk_init_data){
  1525. .name = "cts_enct_sel",
  1526. .ops = &clk_regmap_mux_ops,
  1527. .parent_hws = meson8b_vclk_enc_mux_parent_hws,
  1528. .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
  1529. .flags = CLK_SET_RATE_PARENT,
  1530. },
  1531. };
  1532. static struct clk_regmap meson8b_cts_enct = {
  1533. .data = &(struct clk_regmap_gate_data){
  1534. .offset = HHI_VID_CLK_CNTL2,
  1535. .bit_idx = 1,
  1536. },
  1537. .hw.init = &(struct clk_init_data){
  1538. .name = "cts_enct",
  1539. .ops = &clk_regmap_gate_ops,
  1540. .parent_hws = (const struct clk_hw *[]) {
  1541. &meson8b_cts_enct_sel.hw
  1542. },
  1543. .num_parents = 1,
  1544. .flags = CLK_SET_RATE_PARENT,
  1545. },
  1546. };
  1547. static struct clk_regmap meson8b_cts_encp_sel = {
  1548. .data = &(struct clk_regmap_mux_data){
  1549. .offset = HHI_VID_CLK_DIV,
  1550. .mask = 0xf,
  1551. .shift = 24,
  1552. },
  1553. .hw.init = &(struct clk_init_data){
  1554. .name = "cts_encp_sel",
  1555. .ops = &clk_regmap_mux_ops,
  1556. .parent_hws = meson8b_vclk_enc_mux_parent_hws,
  1557. .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
  1558. .flags = CLK_SET_RATE_PARENT,
  1559. },
  1560. };
  1561. static struct clk_regmap meson8b_cts_encp = {
  1562. .data = &(struct clk_regmap_gate_data){
  1563. .offset = HHI_VID_CLK_CNTL2,
  1564. .bit_idx = 2,
  1565. },
  1566. .hw.init = &(struct clk_init_data){
  1567. .name = "cts_encp",
  1568. .ops = &clk_regmap_gate_ops,
  1569. .parent_hws = (const struct clk_hw *[]) {
  1570. &meson8b_cts_encp_sel.hw
  1571. },
  1572. .num_parents = 1,
  1573. .flags = CLK_SET_RATE_PARENT,
  1574. },
  1575. };
  1576. static struct clk_regmap meson8b_cts_enci_sel = {
  1577. .data = &(struct clk_regmap_mux_data){
  1578. .offset = HHI_VID_CLK_DIV,
  1579. .mask = 0xf,
  1580. .shift = 28,
  1581. },
  1582. .hw.init = &(struct clk_init_data){
  1583. .name = "cts_enci_sel",
  1584. .ops = &clk_regmap_mux_ops,
  1585. .parent_hws = meson8b_vclk_enc_mux_parent_hws,
  1586. .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
  1587. .flags = CLK_SET_RATE_PARENT,
  1588. },
  1589. };
  1590. static struct clk_regmap meson8b_cts_enci = {
  1591. .data = &(struct clk_regmap_gate_data){
  1592. .offset = HHI_VID_CLK_CNTL2,
  1593. .bit_idx = 0,
  1594. },
  1595. .hw.init = &(struct clk_init_data){
  1596. .name = "cts_enci",
  1597. .ops = &clk_regmap_gate_ops,
  1598. .parent_hws = (const struct clk_hw *[]) {
  1599. &meson8b_cts_enci_sel.hw
  1600. },
  1601. .num_parents = 1,
  1602. .flags = CLK_SET_RATE_PARENT,
  1603. },
  1604. };
  1605. static struct clk_regmap meson8b_hdmi_tx_pixel_sel = {
  1606. .data = &(struct clk_regmap_mux_data){
  1607. .offset = HHI_HDMI_CLK_CNTL,
  1608. .mask = 0xf,
  1609. .shift = 16,
  1610. },
  1611. .hw.init = &(struct clk_init_data){
  1612. .name = "hdmi_tx_pixel_sel",
  1613. .ops = &clk_regmap_mux_ops,
  1614. .parent_hws = meson8b_vclk_enc_mux_parent_hws,
  1615. .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
  1616. .flags = CLK_SET_RATE_PARENT,
  1617. },
  1618. };
  1619. static struct clk_regmap meson8b_hdmi_tx_pixel = {
  1620. .data = &(struct clk_regmap_gate_data){
  1621. .offset = HHI_VID_CLK_CNTL2,
  1622. .bit_idx = 5,
  1623. },
  1624. .hw.init = &(struct clk_init_data){
  1625. .name = "hdmi_tx_pixel",
  1626. .ops = &clk_regmap_gate_ops,
  1627. .parent_hws = (const struct clk_hw *[]) {
  1628. &meson8b_hdmi_tx_pixel_sel.hw
  1629. },
  1630. .num_parents = 1,
  1631. .flags = CLK_SET_RATE_PARENT,
  1632. },
  1633. };
  1634. static const struct clk_hw *meson8b_vclk2_enc_mux_parent_hws[] = {
  1635. &meson8b_vclk2_div1_gate.hw,
  1636. &meson8b_vclk2_div2_div_gate.hw,
  1637. &meson8b_vclk2_div4_div_gate.hw,
  1638. &meson8b_vclk2_div6_div_gate.hw,
  1639. &meson8b_vclk2_div12_div_gate.hw,
  1640. };
  1641. static struct clk_regmap meson8b_cts_encl_sel = {
  1642. .data = &(struct clk_regmap_mux_data){
  1643. .offset = HHI_VIID_CLK_DIV,
  1644. .mask = 0xf,
  1645. .shift = 12,
  1646. },
  1647. .hw.init = &(struct clk_init_data){
  1648. .name = "cts_encl_sel",
  1649. .ops = &clk_regmap_mux_ops,
  1650. .parent_hws = meson8b_vclk2_enc_mux_parent_hws,
  1651. .num_parents = ARRAY_SIZE(meson8b_vclk2_enc_mux_parent_hws),
  1652. .flags = CLK_SET_RATE_PARENT,
  1653. },
  1654. };
  1655. static struct clk_regmap meson8b_cts_encl = {
  1656. .data = &(struct clk_regmap_gate_data){
  1657. .offset = HHI_VID_CLK_CNTL2,
  1658. .bit_idx = 3,
  1659. },
  1660. .hw.init = &(struct clk_init_data){
  1661. .name = "cts_encl",
  1662. .ops = &clk_regmap_gate_ops,
  1663. .parent_hws = (const struct clk_hw *[]) {
  1664. &meson8b_cts_encl_sel.hw
  1665. },
  1666. .num_parents = 1,
  1667. .flags = CLK_SET_RATE_PARENT,
  1668. },
  1669. };
  1670. static struct clk_regmap meson8b_cts_vdac0_sel = {
  1671. .data = &(struct clk_regmap_mux_data){
  1672. .offset = HHI_VIID_CLK_DIV,
  1673. .mask = 0xf,
  1674. .shift = 28,
  1675. },
  1676. .hw.init = &(struct clk_init_data){
  1677. .name = "cts_vdac0_sel",
  1678. .ops = &clk_regmap_mux_ops,
  1679. .parent_hws = meson8b_vclk2_enc_mux_parent_hws,
  1680. .num_parents = ARRAY_SIZE(meson8b_vclk2_enc_mux_parent_hws),
  1681. .flags = CLK_SET_RATE_PARENT,
  1682. },
  1683. };
  1684. static struct clk_regmap meson8b_cts_vdac0 = {
  1685. .data = &(struct clk_regmap_gate_data){
  1686. .offset = HHI_VID_CLK_CNTL2,
  1687. .bit_idx = 4,
  1688. },
  1689. .hw.init = &(struct clk_init_data){
  1690. .name = "cts_vdac0",
  1691. .ops = &clk_regmap_gate_ops,
  1692. .parent_hws = (const struct clk_hw *[]) {
  1693. &meson8b_cts_vdac0_sel.hw
  1694. },
  1695. .num_parents = 1,
  1696. .flags = CLK_SET_RATE_PARENT,
  1697. },
  1698. };
  1699. static struct clk_regmap meson8b_hdmi_sys_sel = {
  1700. .data = &(struct clk_regmap_mux_data){
  1701. .offset = HHI_HDMI_CLK_CNTL,
  1702. .mask = 0x3,
  1703. .shift = 9,
  1704. .flags = CLK_MUX_ROUND_CLOSEST,
  1705. },
  1706. .hw.init = &(struct clk_init_data){
  1707. .name = "hdmi_sys_sel",
  1708. .ops = &clk_regmap_mux_ops,
  1709. /* FIXME: all other parents are unknown */
  1710. .parent_data = &(const struct clk_parent_data) {
  1711. .fw_name = "xtal",
  1712. .name = "xtal",
  1713. .index = -1,
  1714. },
  1715. .num_parents = 1,
  1716. .flags = CLK_SET_RATE_NO_REPARENT,
  1717. },
  1718. };
  1719. static struct clk_regmap meson8b_hdmi_sys_div = {
  1720. .data = &(struct clk_regmap_div_data){
  1721. .offset = HHI_HDMI_CLK_CNTL,
  1722. .shift = 0,
  1723. .width = 7,
  1724. },
  1725. .hw.init = &(struct clk_init_data){
  1726. .name = "hdmi_sys_div",
  1727. .ops = &clk_regmap_divider_ops,
  1728. .parent_hws = (const struct clk_hw *[]) {
  1729. &meson8b_hdmi_sys_sel.hw
  1730. },
  1731. .num_parents = 1,
  1732. .flags = CLK_SET_RATE_PARENT,
  1733. },
  1734. };
  1735. static struct clk_regmap meson8b_hdmi_sys = {
  1736. .data = &(struct clk_regmap_gate_data){
  1737. .offset = HHI_HDMI_CLK_CNTL,
  1738. .bit_idx = 8,
  1739. },
  1740. .hw.init = &(struct clk_init_data) {
  1741. .name = "hdmi_sys",
  1742. .ops = &clk_regmap_gate_ops,
  1743. .parent_hws = (const struct clk_hw *[]) {
  1744. &meson8b_hdmi_sys_div.hw
  1745. },
  1746. .num_parents = 1,
  1747. .flags = CLK_SET_RATE_PARENT,
  1748. },
  1749. };
  1750. /*
  1751. * The MALI IP is clocked by two identical clocks (mali_0 and mali_1)
  1752. * muxed by a glitch-free switch on Meson8b and Meson8m2. The CCF can
  1753. * actually manage this glitch-free mux because it does top-to-bottom
  1754. * updates the each clock tree and switches to the "inactive" one when
  1755. * CLK_SET_RATE_GATE is set.
  1756. * Meson8 only has mali_0 and no glitch-free mux.
  1757. */
  1758. static const struct clk_parent_data meson8b_mali_0_1_parent_data[] = {
  1759. { .fw_name = "xtal", .name = "xtal", .index = -1, },
  1760. { .hw = &meson8b_mpll2.hw, },
  1761. { .hw = &meson8b_mpll1.hw, },
  1762. { .hw = &meson8b_fclk_div7.hw, },
  1763. { .hw = &meson8b_fclk_div4.hw, },
  1764. { .hw = &meson8b_fclk_div3.hw, },
  1765. { .hw = &meson8b_fclk_div5.hw, },
  1766. };
  1767. static u32 meson8b_mali_0_1_mux_table[] = { 0, 2, 3, 4, 5, 6, 7 };
  1768. static struct clk_regmap meson8b_mali_0_sel = {
  1769. .data = &(struct clk_regmap_mux_data){
  1770. .offset = HHI_MALI_CLK_CNTL,
  1771. .mask = 0x7,
  1772. .shift = 9,
  1773. .table = meson8b_mali_0_1_mux_table,
  1774. },
  1775. .hw.init = &(struct clk_init_data){
  1776. .name = "mali_0_sel",
  1777. .ops = &clk_regmap_mux_ops,
  1778. .parent_data = meson8b_mali_0_1_parent_data,
  1779. .num_parents = ARRAY_SIZE(meson8b_mali_0_1_parent_data),
  1780. /*
  1781. * Don't propagate rate changes up because the only changeable
  1782. * parents are mpll1 and mpll2 but we need those for audio and
  1783. * RGMII (Ethernet). We don't want to change the audio or
  1784. * Ethernet clocks when setting the GPU frequency.
  1785. */
  1786. .flags = 0,
  1787. },
  1788. };
  1789. static struct clk_regmap meson8b_mali_0_div = {
  1790. .data = &(struct clk_regmap_div_data){
  1791. .offset = HHI_MALI_CLK_CNTL,
  1792. .shift = 0,
  1793. .width = 7,
  1794. },
  1795. .hw.init = &(struct clk_init_data){
  1796. .name = "mali_0_div",
  1797. .ops = &clk_regmap_divider_ops,
  1798. .parent_hws = (const struct clk_hw *[]) {
  1799. &meson8b_mali_0_sel.hw
  1800. },
  1801. .num_parents = 1,
  1802. .flags = CLK_SET_RATE_PARENT,
  1803. },
  1804. };
  1805. static struct clk_regmap meson8b_mali_0 = {
  1806. .data = &(struct clk_regmap_gate_data){
  1807. .offset = HHI_MALI_CLK_CNTL,
  1808. .bit_idx = 8,
  1809. },
  1810. .hw.init = &(struct clk_init_data){
  1811. .name = "mali_0",
  1812. .ops = &clk_regmap_gate_ops,
  1813. .parent_hws = (const struct clk_hw *[]) {
  1814. &meson8b_mali_0_div.hw
  1815. },
  1816. .num_parents = 1,
  1817. .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
  1818. },
  1819. };
  1820. static struct clk_regmap meson8b_mali_1_sel = {
  1821. .data = &(struct clk_regmap_mux_data){
  1822. .offset = HHI_MALI_CLK_CNTL,
  1823. .mask = 0x7,
  1824. .shift = 25,
  1825. .table = meson8b_mali_0_1_mux_table,
  1826. },
  1827. .hw.init = &(struct clk_init_data){
  1828. .name = "mali_1_sel",
  1829. .ops = &clk_regmap_mux_ops,
  1830. .parent_data = meson8b_mali_0_1_parent_data,
  1831. .num_parents = ARRAY_SIZE(meson8b_mali_0_1_parent_data),
  1832. /*
  1833. * Don't propagate rate changes up because the only changeable
  1834. * parents are mpll1 and mpll2 but we need those for audio and
  1835. * RGMII (Ethernet). We don't want to change the audio or
  1836. * Ethernet clocks when setting the GPU frequency.
  1837. */
  1838. .flags = 0,
  1839. },
  1840. };
  1841. static struct clk_regmap meson8b_mali_1_div = {
  1842. .data = &(struct clk_regmap_div_data){
  1843. .offset = HHI_MALI_CLK_CNTL,
  1844. .shift = 16,
  1845. .width = 7,
  1846. },
  1847. .hw.init = &(struct clk_init_data){
  1848. .name = "mali_1_div",
  1849. .ops = &clk_regmap_divider_ops,
  1850. .parent_hws = (const struct clk_hw *[]) {
  1851. &meson8b_mali_1_sel.hw
  1852. },
  1853. .num_parents = 1,
  1854. .flags = CLK_SET_RATE_PARENT,
  1855. },
  1856. };
  1857. static struct clk_regmap meson8b_mali_1 = {
  1858. .data = &(struct clk_regmap_gate_data){
  1859. .offset = HHI_MALI_CLK_CNTL,
  1860. .bit_idx = 24,
  1861. },
  1862. .hw.init = &(struct clk_init_data){
  1863. .name = "mali_1",
  1864. .ops = &clk_regmap_gate_ops,
  1865. .parent_hws = (const struct clk_hw *[]) {
  1866. &meson8b_mali_1_div.hw
  1867. },
  1868. .num_parents = 1,
  1869. .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
  1870. },
  1871. };
  1872. static struct clk_regmap meson8b_mali = {
  1873. .data = &(struct clk_regmap_mux_data){
  1874. .offset = HHI_MALI_CLK_CNTL,
  1875. .mask = 1,
  1876. .shift = 31,
  1877. },
  1878. .hw.init = &(struct clk_init_data){
  1879. .name = "mali",
  1880. .ops = &clk_regmap_mux_ops,
  1881. .parent_hws = (const struct clk_hw *[]) {
  1882. &meson8b_mali_0.hw,
  1883. &meson8b_mali_1.hw,
  1884. },
  1885. .num_parents = 2,
  1886. .flags = CLK_SET_RATE_PARENT,
  1887. },
  1888. };
  1889. static const struct reg_sequence meson8m2_gp_pll_init_regs[] = {
  1890. { .reg = HHI_GP_PLL_CNTL2, .def = 0x59c88000 },
  1891. { .reg = HHI_GP_PLL_CNTL3, .def = 0xca463823 },
  1892. { .reg = HHI_GP_PLL_CNTL4, .def = 0x0286a027 },
  1893. { .reg = HHI_GP_PLL_CNTL5, .def = 0x00003000 },
  1894. };
  1895. static const struct pll_params_table meson8m2_gp_pll_params_table[] = {
  1896. PLL_PARAMS(182, 3),
  1897. { /* sentinel */ },
  1898. };
  1899. static struct clk_regmap meson8m2_gp_pll_dco = {
  1900. .data = &(struct meson_clk_pll_data){
  1901. .en = {
  1902. .reg_off = HHI_GP_PLL_CNTL,
  1903. .shift = 30,
  1904. .width = 1,
  1905. },
  1906. .m = {
  1907. .reg_off = HHI_GP_PLL_CNTL,
  1908. .shift = 0,
  1909. .width = 9,
  1910. },
  1911. .n = {
  1912. .reg_off = HHI_GP_PLL_CNTL,
  1913. .shift = 9,
  1914. .width = 5,
  1915. },
  1916. .l = {
  1917. .reg_off = HHI_GP_PLL_CNTL,
  1918. .shift = 31,
  1919. .width = 1,
  1920. },
  1921. .rst = {
  1922. .reg_off = HHI_GP_PLL_CNTL,
  1923. .shift = 29,
  1924. .width = 1,
  1925. },
  1926. .table = meson8m2_gp_pll_params_table,
  1927. .init_regs = meson8m2_gp_pll_init_regs,
  1928. .init_count = ARRAY_SIZE(meson8m2_gp_pll_init_regs),
  1929. },
  1930. .hw.init = &(struct clk_init_data){
  1931. .name = "gp_pll_dco",
  1932. .ops = &meson_clk_pll_ops,
  1933. .parent_data = &(const struct clk_parent_data) {
  1934. .fw_name = "xtal",
  1935. .name = "xtal",
  1936. .index = -1,
  1937. },
  1938. .num_parents = 1,
  1939. },
  1940. };
  1941. static struct clk_regmap meson8m2_gp_pll = {
  1942. .data = &(struct clk_regmap_div_data){
  1943. .offset = HHI_GP_PLL_CNTL,
  1944. .shift = 16,
  1945. .width = 2,
  1946. .flags = CLK_DIVIDER_POWER_OF_TWO,
  1947. },
  1948. .hw.init = &(struct clk_init_data){
  1949. .name = "gp_pll",
  1950. .ops = &clk_regmap_divider_ops,
  1951. .parent_hws = (const struct clk_hw *[]) {
  1952. &meson8m2_gp_pll_dco.hw
  1953. },
  1954. .num_parents = 1,
  1955. .flags = CLK_SET_RATE_PARENT,
  1956. },
  1957. };
  1958. static const struct clk_hw *meson8b_vpu_0_1_parent_hws[] = {
  1959. &meson8b_fclk_div4.hw,
  1960. &meson8b_fclk_div3.hw,
  1961. &meson8b_fclk_div5.hw,
  1962. &meson8b_fclk_div7.hw,
  1963. };
  1964. static const struct clk_hw *mmeson8m2_vpu_0_1_parent_hws[] = {
  1965. &meson8b_fclk_div4.hw,
  1966. &meson8b_fclk_div3.hw,
  1967. &meson8b_fclk_div5.hw,
  1968. &meson8m2_gp_pll.hw,
  1969. };
  1970. static struct clk_regmap meson8b_vpu_0_sel = {
  1971. .data = &(struct clk_regmap_mux_data){
  1972. .offset = HHI_VPU_CLK_CNTL,
  1973. .mask = 0x3,
  1974. .shift = 9,
  1975. },
  1976. .hw.init = &(struct clk_init_data){
  1977. .name = "vpu_0_sel",
  1978. .ops = &clk_regmap_mux_ops,
  1979. .parent_hws = meson8b_vpu_0_1_parent_hws,
  1980. .num_parents = ARRAY_SIZE(meson8b_vpu_0_1_parent_hws),
  1981. .flags = CLK_SET_RATE_PARENT,
  1982. },
  1983. };
  1984. static struct clk_regmap meson8m2_vpu_0_sel = {
  1985. .data = &(struct clk_regmap_mux_data){
  1986. .offset = HHI_VPU_CLK_CNTL,
  1987. .mask = 0x3,
  1988. .shift = 9,
  1989. },
  1990. .hw.init = &(struct clk_init_data){
  1991. .name = "vpu_0_sel",
  1992. .ops = &clk_regmap_mux_ops,
  1993. .parent_hws = mmeson8m2_vpu_0_1_parent_hws,
  1994. .num_parents = ARRAY_SIZE(mmeson8m2_vpu_0_1_parent_hws),
  1995. .flags = CLK_SET_RATE_PARENT,
  1996. },
  1997. };
  1998. static struct clk_regmap meson8b_vpu_0_div = {
  1999. .data = &(struct clk_regmap_div_data){
  2000. .offset = HHI_VPU_CLK_CNTL,
  2001. .shift = 0,
  2002. .width = 7,
  2003. },
  2004. .hw.init = &(struct clk_init_data){
  2005. .name = "vpu_0_div",
  2006. .ops = &clk_regmap_divider_ops,
  2007. .parent_data = &(const struct clk_parent_data) {
  2008. /*
  2009. * Note:
  2010. * meson8b and meson8m2 have different vpu_0_sels (with
  2011. * different struct clk_hw). We fallback to the global
  2012. * naming string mechanism so vpu_0_div picks up the
  2013. * appropriate one.
  2014. */
  2015. .name = "vpu_0_sel",
  2016. .index = -1,
  2017. },
  2018. .num_parents = 1,
  2019. .flags = CLK_SET_RATE_PARENT,
  2020. },
  2021. };
  2022. static struct clk_regmap meson8b_vpu_0 = {
  2023. .data = &(struct clk_regmap_gate_data){
  2024. .offset = HHI_VPU_CLK_CNTL,
  2025. .bit_idx = 8,
  2026. },
  2027. .hw.init = &(struct clk_init_data) {
  2028. .name = "vpu_0",
  2029. .ops = &clk_regmap_gate_ops,
  2030. .parent_hws = (const struct clk_hw *[]) {
  2031. &meson8b_vpu_0_div.hw
  2032. },
  2033. .num_parents = 1,
  2034. .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
  2035. },
  2036. };
  2037. static struct clk_regmap meson8b_vpu_1_sel = {
  2038. .data = &(struct clk_regmap_mux_data){
  2039. .offset = HHI_VPU_CLK_CNTL,
  2040. .mask = 0x3,
  2041. .shift = 25,
  2042. },
  2043. .hw.init = &(struct clk_init_data){
  2044. .name = "vpu_1_sel",
  2045. .ops = &clk_regmap_mux_ops,
  2046. .parent_hws = meson8b_vpu_0_1_parent_hws,
  2047. .num_parents = ARRAY_SIZE(meson8b_vpu_0_1_parent_hws),
  2048. .flags = CLK_SET_RATE_PARENT,
  2049. },
  2050. };
  2051. static struct clk_regmap meson8m2_vpu_1_sel = {
  2052. .data = &(struct clk_regmap_mux_data){
  2053. .offset = HHI_VPU_CLK_CNTL,
  2054. .mask = 0x3,
  2055. .shift = 25,
  2056. },
  2057. .hw.init = &(struct clk_init_data){
  2058. .name = "vpu_1_sel",
  2059. .ops = &clk_regmap_mux_ops,
  2060. .parent_hws = mmeson8m2_vpu_0_1_parent_hws,
  2061. .num_parents = ARRAY_SIZE(mmeson8m2_vpu_0_1_parent_hws),
  2062. .flags = CLK_SET_RATE_PARENT,
  2063. },
  2064. };
  2065. static struct clk_regmap meson8b_vpu_1_div = {
  2066. .data = &(struct clk_regmap_div_data){
  2067. .offset = HHI_VPU_CLK_CNTL,
  2068. .shift = 16,
  2069. .width = 7,
  2070. },
  2071. .hw.init = &(struct clk_init_data){
  2072. .name = "vpu_1_div",
  2073. .ops = &clk_regmap_divider_ops,
  2074. .parent_data = &(const struct clk_parent_data) {
  2075. /*
  2076. * Note:
  2077. * meson8b and meson8m2 have different vpu_1_sels (with
  2078. * different struct clk_hw). We fallback to the global
  2079. * naming string mechanism so vpu_1_div picks up the
  2080. * appropriate one.
  2081. */
  2082. .name = "vpu_1_sel",
  2083. .index = -1,
  2084. },
  2085. .num_parents = 1,
  2086. .flags = CLK_SET_RATE_PARENT,
  2087. },
  2088. };
  2089. static struct clk_regmap meson8b_vpu_1 = {
  2090. .data = &(struct clk_regmap_gate_data){
  2091. .offset = HHI_VPU_CLK_CNTL,
  2092. .bit_idx = 24,
  2093. },
  2094. .hw.init = &(struct clk_init_data) {
  2095. .name = "vpu_1",
  2096. .ops = &clk_regmap_gate_ops,
  2097. .parent_hws = (const struct clk_hw *[]) {
  2098. &meson8b_vpu_1_div.hw
  2099. },
  2100. .num_parents = 1,
  2101. .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
  2102. },
  2103. };
  2104. /*
  2105. * The VPU clock has two identical clock trees (vpu_0 and vpu_1)
  2106. * muxed by a glitch-free switch on Meson8b and Meson8m2. The CCF can
  2107. * actually manage this glitch-free mux because it does top-to-bottom
  2108. * updates the each clock tree and switches to the "inactive" one when
  2109. * CLK_SET_RATE_GATE is set.
  2110. * Meson8 only has vpu_0 and no glitch-free mux.
  2111. */
  2112. static struct clk_regmap meson8b_vpu = {
  2113. .data = &(struct clk_regmap_mux_data){
  2114. .offset = HHI_VPU_CLK_CNTL,
  2115. .mask = 1,
  2116. .shift = 31,
  2117. },
  2118. .hw.init = &(struct clk_init_data){
  2119. .name = "vpu",
  2120. .ops = &clk_regmap_mux_ops,
  2121. .parent_hws = (const struct clk_hw *[]) {
  2122. &meson8b_vpu_0.hw,
  2123. &meson8b_vpu_1.hw,
  2124. },
  2125. .num_parents = 2,
  2126. .flags = CLK_SET_RATE_PARENT,
  2127. },
  2128. };
  2129. static const struct clk_hw *meson8b_vdec_parent_hws[] = {
  2130. &meson8b_fclk_div4.hw,
  2131. &meson8b_fclk_div3.hw,
  2132. &meson8b_fclk_div5.hw,
  2133. &meson8b_fclk_div7.hw,
  2134. &meson8b_mpll2.hw,
  2135. &meson8b_mpll1.hw,
  2136. };
  2137. static struct clk_regmap meson8b_vdec_1_sel = {
  2138. .data = &(struct clk_regmap_mux_data){
  2139. .offset = HHI_VDEC_CLK_CNTL,
  2140. .mask = 0x3,
  2141. .shift = 9,
  2142. .flags = CLK_MUX_ROUND_CLOSEST,
  2143. },
  2144. .hw.init = &(struct clk_init_data){
  2145. .name = "vdec_1_sel",
  2146. .ops = &clk_regmap_mux_ops,
  2147. .parent_hws = meson8b_vdec_parent_hws,
  2148. .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
  2149. .flags = CLK_SET_RATE_PARENT,
  2150. },
  2151. };
  2152. static struct clk_regmap meson8b_vdec_1_1_div = {
  2153. .data = &(struct clk_regmap_div_data){
  2154. .offset = HHI_VDEC_CLK_CNTL,
  2155. .shift = 0,
  2156. .width = 7,
  2157. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  2158. },
  2159. .hw.init = &(struct clk_init_data){
  2160. .name = "vdec_1_1_div",
  2161. .ops = &clk_regmap_divider_ops,
  2162. .parent_hws = (const struct clk_hw *[]) {
  2163. &meson8b_vdec_1_sel.hw
  2164. },
  2165. .num_parents = 1,
  2166. .flags = CLK_SET_RATE_PARENT,
  2167. },
  2168. };
  2169. static struct clk_regmap meson8b_vdec_1_1 = {
  2170. .data = &(struct clk_regmap_gate_data){
  2171. .offset = HHI_VDEC_CLK_CNTL,
  2172. .bit_idx = 8,
  2173. },
  2174. .hw.init = &(struct clk_init_data) {
  2175. .name = "vdec_1_1",
  2176. .ops = &clk_regmap_gate_ops,
  2177. .parent_hws = (const struct clk_hw *[]) {
  2178. &meson8b_vdec_1_1_div.hw
  2179. },
  2180. .num_parents = 1,
  2181. .flags = CLK_SET_RATE_PARENT,
  2182. },
  2183. };
  2184. static struct clk_regmap meson8b_vdec_1_2_div = {
  2185. .data = &(struct clk_regmap_div_data){
  2186. .offset = HHI_VDEC3_CLK_CNTL,
  2187. .shift = 0,
  2188. .width = 7,
  2189. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  2190. },
  2191. .hw.init = &(struct clk_init_data){
  2192. .name = "vdec_1_2_div",
  2193. .ops = &clk_regmap_divider_ops,
  2194. .parent_hws = (const struct clk_hw *[]) {
  2195. &meson8b_vdec_1_sel.hw
  2196. },
  2197. .num_parents = 1,
  2198. .flags = CLK_SET_RATE_PARENT,
  2199. },
  2200. };
  2201. static struct clk_regmap meson8b_vdec_1_2 = {
  2202. .data = &(struct clk_regmap_gate_data){
  2203. .offset = HHI_VDEC3_CLK_CNTL,
  2204. .bit_idx = 8,
  2205. },
  2206. .hw.init = &(struct clk_init_data) {
  2207. .name = "vdec_1_2",
  2208. .ops = &clk_regmap_gate_ops,
  2209. .parent_hws = (const struct clk_hw *[]) {
  2210. &meson8b_vdec_1_2_div.hw
  2211. },
  2212. .num_parents = 1,
  2213. .flags = CLK_SET_RATE_PARENT,
  2214. },
  2215. };
  2216. static struct clk_regmap meson8b_vdec_1 = {
  2217. .data = &(struct clk_regmap_mux_data){
  2218. .offset = HHI_VDEC3_CLK_CNTL,
  2219. .mask = 0x1,
  2220. .shift = 15,
  2221. .flags = CLK_MUX_ROUND_CLOSEST,
  2222. },
  2223. .hw.init = &(struct clk_init_data){
  2224. .name = "vdec_1",
  2225. .ops = &clk_regmap_mux_ops,
  2226. .parent_hws = (const struct clk_hw *[]) {
  2227. &meson8b_vdec_1_1.hw,
  2228. &meson8b_vdec_1_2.hw,
  2229. },
  2230. .num_parents = 2,
  2231. .flags = CLK_SET_RATE_PARENT,
  2232. },
  2233. };
  2234. static struct clk_regmap meson8b_vdec_hcodec_sel = {
  2235. .data = &(struct clk_regmap_mux_data){
  2236. .offset = HHI_VDEC_CLK_CNTL,
  2237. .mask = 0x3,
  2238. .shift = 25,
  2239. .flags = CLK_MUX_ROUND_CLOSEST,
  2240. },
  2241. .hw.init = &(struct clk_init_data){
  2242. .name = "vdec_hcodec_sel",
  2243. .ops = &clk_regmap_mux_ops,
  2244. .parent_hws = meson8b_vdec_parent_hws,
  2245. .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
  2246. .flags = CLK_SET_RATE_PARENT,
  2247. },
  2248. };
  2249. static struct clk_regmap meson8b_vdec_hcodec_div = {
  2250. .data = &(struct clk_regmap_div_data){
  2251. .offset = HHI_VDEC_CLK_CNTL,
  2252. .shift = 16,
  2253. .width = 7,
  2254. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  2255. },
  2256. .hw.init = &(struct clk_init_data){
  2257. .name = "vdec_hcodec_div",
  2258. .ops = &clk_regmap_divider_ops,
  2259. .parent_hws = (const struct clk_hw *[]) {
  2260. &meson8b_vdec_hcodec_sel.hw
  2261. },
  2262. .num_parents = 1,
  2263. .flags = CLK_SET_RATE_PARENT,
  2264. },
  2265. };
  2266. static struct clk_regmap meson8b_vdec_hcodec = {
  2267. .data = &(struct clk_regmap_gate_data){
  2268. .offset = HHI_VDEC_CLK_CNTL,
  2269. .bit_idx = 24,
  2270. },
  2271. .hw.init = &(struct clk_init_data) {
  2272. .name = "vdec_hcodec",
  2273. .ops = &clk_regmap_gate_ops,
  2274. .parent_hws = (const struct clk_hw *[]) {
  2275. &meson8b_vdec_hcodec_div.hw
  2276. },
  2277. .num_parents = 1,
  2278. .flags = CLK_SET_RATE_PARENT,
  2279. },
  2280. };
  2281. static struct clk_regmap meson8b_vdec_2_sel = {
  2282. .data = &(struct clk_regmap_mux_data){
  2283. .offset = HHI_VDEC2_CLK_CNTL,
  2284. .mask = 0x3,
  2285. .shift = 9,
  2286. .flags = CLK_MUX_ROUND_CLOSEST,
  2287. },
  2288. .hw.init = &(struct clk_init_data){
  2289. .name = "vdec_2_sel",
  2290. .ops = &clk_regmap_mux_ops,
  2291. .parent_hws = meson8b_vdec_parent_hws,
  2292. .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
  2293. .flags = CLK_SET_RATE_PARENT,
  2294. },
  2295. };
  2296. static struct clk_regmap meson8b_vdec_2_div = {
  2297. .data = &(struct clk_regmap_div_data){
  2298. .offset = HHI_VDEC2_CLK_CNTL,
  2299. .shift = 0,
  2300. .width = 7,
  2301. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  2302. },
  2303. .hw.init = &(struct clk_init_data){
  2304. .name = "vdec_2_div",
  2305. .ops = &clk_regmap_divider_ops,
  2306. .parent_hws = (const struct clk_hw *[]) {
  2307. &meson8b_vdec_2_sel.hw
  2308. },
  2309. .num_parents = 1,
  2310. .flags = CLK_SET_RATE_PARENT,
  2311. },
  2312. };
  2313. static struct clk_regmap meson8b_vdec_2 = {
  2314. .data = &(struct clk_regmap_gate_data){
  2315. .offset = HHI_VDEC2_CLK_CNTL,
  2316. .bit_idx = 8,
  2317. },
  2318. .hw.init = &(struct clk_init_data) {
  2319. .name = "vdec_2",
  2320. .ops = &clk_regmap_gate_ops,
  2321. .parent_hws = (const struct clk_hw *[]) {
  2322. &meson8b_vdec_2_div.hw
  2323. },
  2324. .num_parents = 1,
  2325. .flags = CLK_SET_RATE_PARENT,
  2326. },
  2327. };
  2328. static struct clk_regmap meson8b_vdec_hevc_sel = {
  2329. .data = &(struct clk_regmap_mux_data){
  2330. .offset = HHI_VDEC2_CLK_CNTL,
  2331. .mask = 0x3,
  2332. .shift = 25,
  2333. .flags = CLK_MUX_ROUND_CLOSEST,
  2334. },
  2335. .hw.init = &(struct clk_init_data){
  2336. .name = "vdec_hevc_sel",
  2337. .ops = &clk_regmap_mux_ops,
  2338. .parent_hws = meson8b_vdec_parent_hws,
  2339. .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
  2340. .flags = CLK_SET_RATE_PARENT,
  2341. },
  2342. };
  2343. static struct clk_regmap meson8b_vdec_hevc_div = {
  2344. .data = &(struct clk_regmap_div_data){
  2345. .offset = HHI_VDEC2_CLK_CNTL,
  2346. .shift = 16,
  2347. .width = 7,
  2348. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  2349. },
  2350. .hw.init = &(struct clk_init_data){
  2351. .name = "vdec_hevc_div",
  2352. .ops = &clk_regmap_divider_ops,
  2353. .parent_hws = (const struct clk_hw *[]) {
  2354. &meson8b_vdec_hevc_sel.hw
  2355. },
  2356. .num_parents = 1,
  2357. .flags = CLK_SET_RATE_PARENT,
  2358. },
  2359. };
  2360. static struct clk_regmap meson8b_vdec_hevc_en = {
  2361. .data = &(struct clk_regmap_gate_data){
  2362. .offset = HHI_VDEC2_CLK_CNTL,
  2363. .bit_idx = 24,
  2364. },
  2365. .hw.init = &(struct clk_init_data) {
  2366. .name = "vdec_hevc_en",
  2367. .ops = &clk_regmap_gate_ops,
  2368. .parent_hws = (const struct clk_hw *[]) {
  2369. &meson8b_vdec_hevc_div.hw
  2370. },
  2371. .num_parents = 1,
  2372. .flags = CLK_SET_RATE_PARENT,
  2373. },
  2374. };
  2375. static struct clk_regmap meson8b_vdec_hevc = {
  2376. .data = &(struct clk_regmap_mux_data){
  2377. .offset = HHI_VDEC2_CLK_CNTL,
  2378. .mask = 0x1,
  2379. .shift = 31,
  2380. .flags = CLK_MUX_ROUND_CLOSEST,
  2381. },
  2382. .hw.init = &(struct clk_init_data){
  2383. .name = "vdec_hevc",
  2384. .ops = &clk_regmap_mux_ops,
  2385. /* TODO: The second parent is currently unknown */
  2386. .parent_hws = (const struct clk_hw *[]) {
  2387. &meson8b_vdec_hevc_en.hw
  2388. },
  2389. .num_parents = 1,
  2390. .flags = CLK_SET_RATE_PARENT,
  2391. },
  2392. };
  2393. /* TODO: the clock at index 0 is "DDR_PLL" which we don't support yet */
  2394. static const struct clk_hw *meson8b_cts_amclk_parent_hws[] = {
  2395. &meson8b_mpll0.hw,
  2396. &meson8b_mpll1.hw,
  2397. &meson8b_mpll2.hw
  2398. };
  2399. static u32 meson8b_cts_amclk_mux_table[] = { 1, 2, 3 };
  2400. static struct clk_regmap meson8b_cts_amclk_sel = {
  2401. .data = &(struct clk_regmap_mux_data){
  2402. .offset = HHI_AUD_CLK_CNTL,
  2403. .mask = 0x3,
  2404. .shift = 9,
  2405. .table = meson8b_cts_amclk_mux_table,
  2406. .flags = CLK_MUX_ROUND_CLOSEST,
  2407. },
  2408. .hw.init = &(struct clk_init_data){
  2409. .name = "cts_amclk_sel",
  2410. .ops = &clk_regmap_mux_ops,
  2411. .parent_hws = meson8b_cts_amclk_parent_hws,
  2412. .num_parents = ARRAY_SIZE(meson8b_cts_amclk_parent_hws),
  2413. },
  2414. };
  2415. static struct clk_regmap meson8b_cts_amclk_div = {
  2416. .data = &(struct clk_regmap_div_data) {
  2417. .offset = HHI_AUD_CLK_CNTL,
  2418. .shift = 0,
  2419. .width = 8,
  2420. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  2421. },
  2422. .hw.init = &(struct clk_init_data){
  2423. .name = "cts_amclk_div",
  2424. .ops = &clk_regmap_divider_ops,
  2425. .parent_hws = (const struct clk_hw *[]) {
  2426. &meson8b_cts_amclk_sel.hw
  2427. },
  2428. .num_parents = 1,
  2429. .flags = CLK_SET_RATE_PARENT,
  2430. },
  2431. };
  2432. static struct clk_regmap meson8b_cts_amclk = {
  2433. .data = &(struct clk_regmap_gate_data){
  2434. .offset = HHI_AUD_CLK_CNTL,
  2435. .bit_idx = 8,
  2436. },
  2437. .hw.init = &(struct clk_init_data){
  2438. .name = "cts_amclk",
  2439. .ops = &clk_regmap_gate_ops,
  2440. .parent_hws = (const struct clk_hw *[]) {
  2441. &meson8b_cts_amclk_div.hw
  2442. },
  2443. .num_parents = 1,
  2444. .flags = CLK_SET_RATE_PARENT,
  2445. },
  2446. };
  2447. /* TODO: the clock at index 0 is "DDR_PLL" which we don't support yet */
  2448. static const struct clk_hw *meson8b_cts_mclk_i958_parent_hws[] = {
  2449. &meson8b_mpll0.hw,
  2450. &meson8b_mpll1.hw,
  2451. &meson8b_mpll2.hw
  2452. };
  2453. static u32 meson8b_cts_mclk_i958_mux_table[] = { 1, 2, 3 };
  2454. static struct clk_regmap meson8b_cts_mclk_i958_sel = {
  2455. .data = &(struct clk_regmap_mux_data){
  2456. .offset = HHI_AUD_CLK_CNTL2,
  2457. .mask = 0x3,
  2458. .shift = 25,
  2459. .table = meson8b_cts_mclk_i958_mux_table,
  2460. .flags = CLK_MUX_ROUND_CLOSEST,
  2461. },
  2462. .hw.init = &(struct clk_init_data) {
  2463. .name = "cts_mclk_i958_sel",
  2464. .ops = &clk_regmap_mux_ops,
  2465. .parent_hws = meson8b_cts_mclk_i958_parent_hws,
  2466. .num_parents = ARRAY_SIZE(meson8b_cts_mclk_i958_parent_hws),
  2467. },
  2468. };
  2469. static struct clk_regmap meson8b_cts_mclk_i958_div = {
  2470. .data = &(struct clk_regmap_div_data){
  2471. .offset = HHI_AUD_CLK_CNTL2,
  2472. .shift = 16,
  2473. .width = 8,
  2474. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  2475. },
  2476. .hw.init = &(struct clk_init_data) {
  2477. .name = "cts_mclk_i958_div",
  2478. .ops = &clk_regmap_divider_ops,
  2479. .parent_hws = (const struct clk_hw *[]) {
  2480. &meson8b_cts_mclk_i958_sel.hw
  2481. },
  2482. .num_parents = 1,
  2483. .flags = CLK_SET_RATE_PARENT,
  2484. },
  2485. };
  2486. static struct clk_regmap meson8b_cts_mclk_i958 = {
  2487. .data = &(struct clk_regmap_gate_data){
  2488. .offset = HHI_AUD_CLK_CNTL2,
  2489. .bit_idx = 24,
  2490. },
  2491. .hw.init = &(struct clk_init_data){
  2492. .name = "cts_mclk_i958",
  2493. .ops = &clk_regmap_gate_ops,
  2494. .parent_hws = (const struct clk_hw *[]) {
  2495. &meson8b_cts_mclk_i958_div.hw
  2496. },
  2497. .num_parents = 1,
  2498. .flags = CLK_SET_RATE_PARENT,
  2499. },
  2500. };
  2501. static struct clk_regmap meson8b_cts_i958 = {
  2502. .data = &(struct clk_regmap_mux_data){
  2503. .offset = HHI_AUD_CLK_CNTL2,
  2504. .mask = 0x1,
  2505. .shift = 27,
  2506. },
  2507. .hw.init = &(struct clk_init_data){
  2508. .name = "cts_i958",
  2509. .ops = &clk_regmap_mux_ops,
  2510. .parent_hws = (const struct clk_hw *[]) {
  2511. &meson8b_cts_amclk.hw,
  2512. &meson8b_cts_mclk_i958.hw
  2513. },
  2514. .num_parents = 2,
  2515. /*
  2516. * The parent is specific to origin of the audio data. Let the
  2517. * consumer choose the appropriate parent.
  2518. */
  2519. .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
  2520. },
  2521. };
  2522. #define MESON_GATE(_name, _reg, _bit) \
  2523. MESON_PCLK(_name, _reg, _bit, &meson8b_clk81.hw)
  2524. /* Everything Else (EE) domain gates */
  2525. static MESON_GATE(meson8b_ddr, HHI_GCLK_MPEG0, 0);
  2526. static MESON_GATE(meson8b_dos, HHI_GCLK_MPEG0, 1);
  2527. static MESON_GATE(meson8b_isa, HHI_GCLK_MPEG0, 5);
  2528. static MESON_GATE(meson8b_pl301, HHI_GCLK_MPEG0, 6);
  2529. static MESON_GATE(meson8b_periphs, HHI_GCLK_MPEG0, 7);
  2530. static MESON_GATE(meson8b_spicc, HHI_GCLK_MPEG0, 8);
  2531. static MESON_GATE(meson8b_i2c, HHI_GCLK_MPEG0, 9);
  2532. static MESON_GATE(meson8b_sar_adc, HHI_GCLK_MPEG0, 10);
  2533. static MESON_GATE(meson8b_smart_card, HHI_GCLK_MPEG0, 11);
  2534. static MESON_GATE(meson8b_rng0, HHI_GCLK_MPEG0, 12);
  2535. static MESON_GATE(meson8b_uart0, HHI_GCLK_MPEG0, 13);
  2536. static MESON_GATE(meson8b_sdhc, HHI_GCLK_MPEG0, 14);
  2537. static MESON_GATE(meson8b_stream, HHI_GCLK_MPEG0, 15);
  2538. static MESON_GATE(meson8b_async_fifo, HHI_GCLK_MPEG0, 16);
  2539. static MESON_GATE(meson8b_sdio, HHI_GCLK_MPEG0, 17);
  2540. static MESON_GATE(meson8b_abuf, HHI_GCLK_MPEG0, 18);
  2541. static MESON_GATE(meson8b_hiu_iface, HHI_GCLK_MPEG0, 19);
  2542. static MESON_GATE(meson8b_assist_misc, HHI_GCLK_MPEG0, 23);
  2543. static MESON_GATE(meson8b_spi, HHI_GCLK_MPEG0, 30);
  2544. static MESON_GATE(meson8b_i2s_spdif, HHI_GCLK_MPEG1, 2);
  2545. static MESON_GATE(meson8b_eth, HHI_GCLK_MPEG1, 3);
  2546. static MESON_GATE(meson8b_demux, HHI_GCLK_MPEG1, 4);
  2547. static MESON_GATE(meson8b_blkmv, HHI_GCLK_MPEG1, 14);
  2548. static MESON_GATE(meson8b_aiu, HHI_GCLK_MPEG1, 15);
  2549. static MESON_GATE(meson8b_uart1, HHI_GCLK_MPEG1, 16);
  2550. static MESON_GATE(meson8b_g2d, HHI_GCLK_MPEG1, 20);
  2551. static MESON_GATE(meson8b_usb0, HHI_GCLK_MPEG1, 21);
  2552. static MESON_GATE(meson8b_usb1, HHI_GCLK_MPEG1, 22);
  2553. static MESON_GATE(meson8b_reset, HHI_GCLK_MPEG1, 23);
  2554. static MESON_GATE(meson8b_nand, HHI_GCLK_MPEG1, 24);
  2555. static MESON_GATE(meson8b_dos_parser, HHI_GCLK_MPEG1, 25);
  2556. static MESON_GATE(meson8b_usb, HHI_GCLK_MPEG1, 26);
  2557. static MESON_GATE(meson8b_vdin1, HHI_GCLK_MPEG1, 28);
  2558. static MESON_GATE(meson8b_ahb_arb0, HHI_GCLK_MPEG1, 29);
  2559. static MESON_GATE(meson8b_efuse, HHI_GCLK_MPEG1, 30);
  2560. static MESON_GATE(meson8b_boot_rom, HHI_GCLK_MPEG1, 31);
  2561. static MESON_GATE(meson8b_ahb_data_bus, HHI_GCLK_MPEG2, 1);
  2562. static MESON_GATE(meson8b_ahb_ctrl_bus, HHI_GCLK_MPEG2, 2);
  2563. static MESON_GATE(meson8b_hdmi_intr_sync, HHI_GCLK_MPEG2, 3);
  2564. static MESON_GATE(meson8b_hdmi_pclk, HHI_GCLK_MPEG2, 4);
  2565. static MESON_GATE(meson8b_usb1_ddr_bridge, HHI_GCLK_MPEG2, 8);
  2566. static MESON_GATE(meson8b_usb0_ddr_bridge, HHI_GCLK_MPEG2, 9);
  2567. static MESON_GATE(meson8b_mmc_pclk, HHI_GCLK_MPEG2, 11);
  2568. static MESON_GATE(meson8b_dvin, HHI_GCLK_MPEG2, 12);
  2569. static MESON_GATE(meson8b_uart2, HHI_GCLK_MPEG2, 15);
  2570. static MESON_GATE(meson8b_sana, HHI_GCLK_MPEG2, 22);
  2571. static MESON_GATE(meson8b_vpu_intr, HHI_GCLK_MPEG2, 25);
  2572. static MESON_GATE(meson8b_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26);
  2573. static MESON_GATE(meson8b_clk81_a9, HHI_GCLK_MPEG2, 29);
  2574. static MESON_GATE(meson8b_vclk2_venci0, HHI_GCLK_OTHER, 1);
  2575. static MESON_GATE(meson8b_vclk2_venci1, HHI_GCLK_OTHER, 2);
  2576. static MESON_GATE(meson8b_vclk2_vencp0, HHI_GCLK_OTHER, 3);
  2577. static MESON_GATE(meson8b_vclk2_vencp1, HHI_GCLK_OTHER, 4);
  2578. static MESON_GATE(meson8b_gclk_venci_int, HHI_GCLK_OTHER, 8);
  2579. static MESON_GATE(meson8b_gclk_vencp_int, HHI_GCLK_OTHER, 9);
  2580. static MESON_GATE(meson8b_dac_clk, HHI_GCLK_OTHER, 10);
  2581. static MESON_GATE(meson8b_aoclk_gate, HHI_GCLK_OTHER, 14);
  2582. static MESON_GATE(meson8b_iec958_gate, HHI_GCLK_OTHER, 16);
  2583. static MESON_GATE(meson8b_enc480p, HHI_GCLK_OTHER, 20);
  2584. static MESON_GATE(meson8b_rng1, HHI_GCLK_OTHER, 21);
  2585. static MESON_GATE(meson8b_gclk_vencl_int, HHI_GCLK_OTHER, 22);
  2586. static MESON_GATE(meson8b_vclk2_venclmcc, HHI_GCLK_OTHER, 24);
  2587. static MESON_GATE(meson8b_vclk2_vencl, HHI_GCLK_OTHER, 25);
  2588. static MESON_GATE(meson8b_vclk2_other, HHI_GCLK_OTHER, 26);
  2589. static MESON_GATE(meson8b_edp, HHI_GCLK_OTHER, 31);
  2590. /* AIU gates */
  2591. #define MESON_AIU_GLUE_GATE(_name, _reg, _bit) \
  2592. MESON_PCLK(_name, _reg, _bit, &meson8b_aiu_glue.hw)
  2593. static MESON_PCLK(meson8b_aiu_glue, HHI_GCLK_MPEG1, 6, &meson8b_aiu.hw);
  2594. static MESON_AIU_GLUE_GATE(meson8b_iec958, HHI_GCLK_MPEG1, 7);
  2595. static MESON_AIU_GLUE_GATE(meson8b_i2s_out, HHI_GCLK_MPEG1, 8);
  2596. static MESON_AIU_GLUE_GATE(meson8b_amclk, HHI_GCLK_MPEG1, 9);
  2597. static MESON_AIU_GLUE_GATE(meson8b_aififo2, HHI_GCLK_MPEG1, 10);
  2598. static MESON_AIU_GLUE_GATE(meson8b_mixer, HHI_GCLK_MPEG1, 11);
  2599. static MESON_AIU_GLUE_GATE(meson8b_mixer_iface, HHI_GCLK_MPEG1, 12);
  2600. static MESON_AIU_GLUE_GATE(meson8b_adc, HHI_GCLK_MPEG1, 13);
  2601. /* Always On (AO) domain gates */
  2602. static MESON_GATE(meson8b_ao_media_cpu, HHI_GCLK_AO, 0);
  2603. static MESON_GATE(meson8b_ao_ahb_sram, HHI_GCLK_AO, 1);
  2604. static MESON_GATE(meson8b_ao_ahb_bus, HHI_GCLK_AO, 2);
  2605. static MESON_GATE(meson8b_ao_iface, HHI_GCLK_AO, 3);
  2606. static struct clk_hw *meson8_hw_clks[] = {
  2607. [CLKID_PLL_FIXED] = &meson8b_fixed_pll.hw,
  2608. [CLKID_PLL_VID] = &meson8b_vid_pll.hw,
  2609. [CLKID_PLL_SYS] = &meson8b_sys_pll.hw,
  2610. [CLKID_FCLK_DIV2] = &meson8b_fclk_div2.hw,
  2611. [CLKID_FCLK_DIV3] = &meson8b_fclk_div3.hw,
  2612. [CLKID_FCLK_DIV4] = &meson8b_fclk_div4.hw,
  2613. [CLKID_FCLK_DIV5] = &meson8b_fclk_div5.hw,
  2614. [CLKID_FCLK_DIV7] = &meson8b_fclk_div7.hw,
  2615. [CLKID_CPUCLK] = &meson8b_cpu_clk.hw,
  2616. [CLKID_MPEG_SEL] = &meson8b_mpeg_clk_sel.hw,
  2617. [CLKID_MPEG_DIV] = &meson8b_mpeg_clk_div.hw,
  2618. [CLKID_CLK81] = &meson8b_clk81.hw,
  2619. [CLKID_DDR] = &meson8b_ddr.hw,
  2620. [CLKID_DOS] = &meson8b_dos.hw,
  2621. [CLKID_ISA] = &meson8b_isa.hw,
  2622. [CLKID_PL301] = &meson8b_pl301.hw,
  2623. [CLKID_PERIPHS] = &meson8b_periphs.hw,
  2624. [CLKID_SPICC] = &meson8b_spicc.hw,
  2625. [CLKID_I2C] = &meson8b_i2c.hw,
  2626. [CLKID_SAR_ADC] = &meson8b_sar_adc.hw,
  2627. [CLKID_SMART_CARD] = &meson8b_smart_card.hw,
  2628. [CLKID_RNG0] = &meson8b_rng0.hw,
  2629. [CLKID_UART0] = &meson8b_uart0.hw,
  2630. [CLKID_SDHC] = &meson8b_sdhc.hw,
  2631. [CLKID_STREAM] = &meson8b_stream.hw,
  2632. [CLKID_ASYNC_FIFO] = &meson8b_async_fifo.hw,
  2633. [CLKID_SDIO] = &meson8b_sdio.hw,
  2634. [CLKID_ABUF] = &meson8b_abuf.hw,
  2635. [CLKID_HIU_IFACE] = &meson8b_hiu_iface.hw,
  2636. [CLKID_ASSIST_MISC] = &meson8b_assist_misc.hw,
  2637. [CLKID_SPI] = &meson8b_spi.hw,
  2638. [CLKID_I2S_SPDIF] = &meson8b_i2s_spdif.hw,
  2639. [CLKID_ETH] = &meson8b_eth.hw,
  2640. [CLKID_DEMUX] = &meson8b_demux.hw,
  2641. [CLKID_AIU_GLUE] = &meson8b_aiu_glue.hw,
  2642. [CLKID_IEC958] = &meson8b_iec958.hw,
  2643. [CLKID_I2S_OUT] = &meson8b_i2s_out.hw,
  2644. [CLKID_AMCLK] = &meson8b_amclk.hw,
  2645. [CLKID_AIFIFO2] = &meson8b_aififo2.hw,
  2646. [CLKID_MIXER] = &meson8b_mixer.hw,
  2647. [CLKID_MIXER_IFACE] = &meson8b_mixer_iface.hw,
  2648. [CLKID_ADC] = &meson8b_adc.hw,
  2649. [CLKID_BLKMV] = &meson8b_blkmv.hw,
  2650. [CLKID_AIU] = &meson8b_aiu.hw,
  2651. [CLKID_UART1] = &meson8b_uart1.hw,
  2652. [CLKID_G2D] = &meson8b_g2d.hw,
  2653. [CLKID_USB0] = &meson8b_usb0.hw,
  2654. [CLKID_USB1] = &meson8b_usb1.hw,
  2655. [CLKID_RESET] = &meson8b_reset.hw,
  2656. [CLKID_NAND] = &meson8b_nand.hw,
  2657. [CLKID_DOS_PARSER] = &meson8b_dos_parser.hw,
  2658. [CLKID_USB] = &meson8b_usb.hw,
  2659. [CLKID_VDIN1] = &meson8b_vdin1.hw,
  2660. [CLKID_AHB_ARB0] = &meson8b_ahb_arb0.hw,
  2661. [CLKID_EFUSE] = &meson8b_efuse.hw,
  2662. [CLKID_BOOT_ROM] = &meson8b_boot_rom.hw,
  2663. [CLKID_AHB_DATA_BUS] = &meson8b_ahb_data_bus.hw,
  2664. [CLKID_AHB_CTRL_BUS] = &meson8b_ahb_ctrl_bus.hw,
  2665. [CLKID_HDMI_INTR_SYNC] = &meson8b_hdmi_intr_sync.hw,
  2666. [CLKID_HDMI_PCLK] = &meson8b_hdmi_pclk.hw,
  2667. [CLKID_USB1_DDR_BRIDGE] = &meson8b_usb1_ddr_bridge.hw,
  2668. [CLKID_USB0_DDR_BRIDGE] = &meson8b_usb0_ddr_bridge.hw,
  2669. [CLKID_MMC_PCLK] = &meson8b_mmc_pclk.hw,
  2670. [CLKID_DVIN] = &meson8b_dvin.hw,
  2671. [CLKID_UART2] = &meson8b_uart2.hw,
  2672. [CLKID_SANA] = &meson8b_sana.hw,
  2673. [CLKID_VPU_INTR] = &meson8b_vpu_intr.hw,
  2674. [CLKID_SEC_AHB_AHB3_BRIDGE] = &meson8b_sec_ahb_ahb3_bridge.hw,
  2675. [CLKID_CLK81_A9] = &meson8b_clk81_a9.hw,
  2676. [CLKID_VCLK2_VENCI0] = &meson8b_vclk2_venci0.hw,
  2677. [CLKID_VCLK2_VENCI1] = &meson8b_vclk2_venci1.hw,
  2678. [CLKID_VCLK2_VENCP0] = &meson8b_vclk2_vencp0.hw,
  2679. [CLKID_VCLK2_VENCP1] = &meson8b_vclk2_vencp1.hw,
  2680. [CLKID_GCLK_VENCI_INT] = &meson8b_gclk_venci_int.hw,
  2681. [CLKID_GCLK_VENCP_INT] = &meson8b_gclk_vencp_int.hw,
  2682. [CLKID_DAC_CLK] = &meson8b_dac_clk.hw,
  2683. [CLKID_AOCLK_GATE] = &meson8b_aoclk_gate.hw,
  2684. [CLKID_IEC958_GATE] = &meson8b_iec958_gate.hw,
  2685. [CLKID_ENC480P] = &meson8b_enc480p.hw,
  2686. [CLKID_RNG1] = &meson8b_rng1.hw,
  2687. [CLKID_GCLK_VENCL_INT] = &meson8b_gclk_vencl_int.hw,
  2688. [CLKID_VCLK2_VENCLMCC] = &meson8b_vclk2_venclmcc.hw,
  2689. [CLKID_VCLK2_VENCL] = &meson8b_vclk2_vencl.hw,
  2690. [CLKID_VCLK2_OTHER] = &meson8b_vclk2_other.hw,
  2691. [CLKID_EDP] = &meson8b_edp.hw,
  2692. [CLKID_AO_MEDIA_CPU] = &meson8b_ao_media_cpu.hw,
  2693. [CLKID_AO_AHB_SRAM] = &meson8b_ao_ahb_sram.hw,
  2694. [CLKID_AO_AHB_BUS] = &meson8b_ao_ahb_bus.hw,
  2695. [CLKID_AO_IFACE] = &meson8b_ao_iface.hw,
  2696. [CLKID_MPLL0] = &meson8b_mpll0.hw,
  2697. [CLKID_MPLL1] = &meson8b_mpll1.hw,
  2698. [CLKID_MPLL2] = &meson8b_mpll2.hw,
  2699. [CLKID_MPLL0_DIV] = &meson8b_mpll0_div.hw,
  2700. [CLKID_MPLL1_DIV] = &meson8b_mpll1_div.hw,
  2701. [CLKID_MPLL2_DIV] = &meson8b_mpll2_div.hw,
  2702. [CLKID_CPU_IN_SEL] = &meson8b_cpu_in_sel.hw,
  2703. [CLKID_CPU_IN_DIV2] = &meson8b_cpu_in_div2.hw,
  2704. [CLKID_CPU_IN_DIV3] = &meson8b_cpu_in_div3.hw,
  2705. [CLKID_CPU_SCALE_DIV] = &meson8b_cpu_scale_div.hw,
  2706. [CLKID_CPU_SCALE_OUT_SEL] = &meson8b_cpu_scale_out_sel.hw,
  2707. [CLKID_MPLL_PREDIV] = &meson8b_mpll_prediv.hw,
  2708. [CLKID_FCLK_DIV2_DIV] = &meson8b_fclk_div2_div.hw,
  2709. [CLKID_FCLK_DIV3_DIV] = &meson8b_fclk_div3_div.hw,
  2710. [CLKID_FCLK_DIV4_DIV] = &meson8b_fclk_div4_div.hw,
  2711. [CLKID_FCLK_DIV5_DIV] = &meson8b_fclk_div5_div.hw,
  2712. [CLKID_FCLK_DIV7_DIV] = &meson8b_fclk_div7_div.hw,
  2713. [CLKID_NAND_SEL] = &meson8b_nand_clk_sel.hw,
  2714. [CLKID_NAND_DIV] = &meson8b_nand_clk_div.hw,
  2715. [CLKID_NAND_CLK] = &meson8b_nand_clk_gate.hw,
  2716. [CLKID_PLL_FIXED_DCO] = &meson8b_fixed_pll_dco.hw,
  2717. [CLKID_HDMI_PLL_DCO] = &meson8b_hdmi_pll_dco.hw,
  2718. [CLKID_PLL_SYS_DCO] = &meson8b_sys_pll_dco.hw,
  2719. [CLKID_CPU_CLK_DIV2] = &meson8b_cpu_clk_div2.hw,
  2720. [CLKID_CPU_CLK_DIV3] = &meson8b_cpu_clk_div3.hw,
  2721. [CLKID_CPU_CLK_DIV4] = &meson8b_cpu_clk_div4.hw,
  2722. [CLKID_CPU_CLK_DIV5] = &meson8b_cpu_clk_div5.hw,
  2723. [CLKID_CPU_CLK_DIV6] = &meson8b_cpu_clk_div6.hw,
  2724. [CLKID_CPU_CLK_DIV7] = &meson8b_cpu_clk_div7.hw,
  2725. [CLKID_CPU_CLK_DIV8] = &meson8b_cpu_clk_div8.hw,
  2726. [CLKID_APB_SEL] = &meson8b_apb_clk_sel.hw,
  2727. [CLKID_APB] = &meson8b_apb_clk_gate.hw,
  2728. [CLKID_PERIPH_SEL] = &meson8b_periph_clk_sel.hw,
  2729. [CLKID_PERIPH] = &meson8b_periph_clk_gate.hw,
  2730. [CLKID_AXI_SEL] = &meson8b_axi_clk_sel.hw,
  2731. [CLKID_AXI] = &meson8b_axi_clk_gate.hw,
  2732. [CLKID_L2_DRAM_SEL] = &meson8b_l2_dram_clk_sel.hw,
  2733. [CLKID_L2_DRAM] = &meson8b_l2_dram_clk_gate.hw,
  2734. [CLKID_HDMI_PLL_LVDS_OUT] = &meson8b_hdmi_pll_lvds_out.hw,
  2735. [CLKID_HDMI_PLL_HDMI_OUT] = &meson8b_hdmi_pll_hdmi_out.hw,
  2736. [CLKID_VID_PLL_IN_SEL] = &meson8b_vid_pll_in_sel.hw,
  2737. [CLKID_VID_PLL_IN_EN] = &meson8b_vid_pll_in_en.hw,
  2738. [CLKID_VID_PLL_PRE_DIV] = &meson8b_vid_pll_pre_div.hw,
  2739. [CLKID_VID_PLL_POST_DIV] = &meson8b_vid_pll_post_div.hw,
  2740. [CLKID_VID_PLL_FINAL_DIV] = &meson8b_vid_pll_final_div.hw,
  2741. [CLKID_VCLK_IN_SEL] = &meson8b_vclk_in_sel.hw,
  2742. [CLKID_VCLK_IN_EN] = &meson8b_vclk_in_en.hw,
  2743. [CLKID_VCLK_EN] = &meson8b_vclk_en.hw,
  2744. [CLKID_VCLK_DIV1] = &meson8b_vclk_div1_gate.hw,
  2745. [CLKID_VCLK_DIV2_DIV] = &meson8b_vclk_div2_div.hw,
  2746. [CLKID_VCLK_DIV2] = &meson8b_vclk_div2_div_gate.hw,
  2747. [CLKID_VCLK_DIV4_DIV] = &meson8b_vclk_div4_div.hw,
  2748. [CLKID_VCLK_DIV4] = &meson8b_vclk_div4_div_gate.hw,
  2749. [CLKID_VCLK_DIV6_DIV] = &meson8b_vclk_div6_div.hw,
  2750. [CLKID_VCLK_DIV6] = &meson8b_vclk_div6_div_gate.hw,
  2751. [CLKID_VCLK_DIV12_DIV] = &meson8b_vclk_div12_div.hw,
  2752. [CLKID_VCLK_DIV12] = &meson8b_vclk_div12_div_gate.hw,
  2753. [CLKID_VCLK2_IN_SEL] = &meson8b_vclk2_in_sel.hw,
  2754. [CLKID_VCLK2_IN_EN] = &meson8b_vclk2_clk_in_en.hw,
  2755. [CLKID_VCLK2_EN] = &meson8b_vclk2_clk_en.hw,
  2756. [CLKID_VCLK2_DIV1] = &meson8b_vclk2_div1_gate.hw,
  2757. [CLKID_VCLK2_DIV2_DIV] = &meson8b_vclk2_div2_div.hw,
  2758. [CLKID_VCLK2_DIV2] = &meson8b_vclk2_div2_div_gate.hw,
  2759. [CLKID_VCLK2_DIV4_DIV] = &meson8b_vclk2_div4_div.hw,
  2760. [CLKID_VCLK2_DIV4] = &meson8b_vclk2_div4_div_gate.hw,
  2761. [CLKID_VCLK2_DIV6_DIV] = &meson8b_vclk2_div6_div.hw,
  2762. [CLKID_VCLK2_DIV6] = &meson8b_vclk2_div6_div_gate.hw,
  2763. [CLKID_VCLK2_DIV12_DIV] = &meson8b_vclk2_div12_div.hw,
  2764. [CLKID_VCLK2_DIV12] = &meson8b_vclk2_div12_div_gate.hw,
  2765. [CLKID_CTS_ENCT_SEL] = &meson8b_cts_enct_sel.hw,
  2766. [CLKID_CTS_ENCT] = &meson8b_cts_enct.hw,
  2767. [CLKID_CTS_ENCP_SEL] = &meson8b_cts_encp_sel.hw,
  2768. [CLKID_CTS_ENCP] = &meson8b_cts_encp.hw,
  2769. [CLKID_CTS_ENCI_SEL] = &meson8b_cts_enci_sel.hw,
  2770. [CLKID_CTS_ENCI] = &meson8b_cts_enci.hw,
  2771. [CLKID_HDMI_TX_PIXEL_SEL] = &meson8b_hdmi_tx_pixel_sel.hw,
  2772. [CLKID_HDMI_TX_PIXEL] = &meson8b_hdmi_tx_pixel.hw,
  2773. [CLKID_CTS_ENCL_SEL] = &meson8b_cts_encl_sel.hw,
  2774. [CLKID_CTS_ENCL] = &meson8b_cts_encl.hw,
  2775. [CLKID_CTS_VDAC0_SEL] = &meson8b_cts_vdac0_sel.hw,
  2776. [CLKID_CTS_VDAC0] = &meson8b_cts_vdac0.hw,
  2777. [CLKID_HDMI_SYS_SEL] = &meson8b_hdmi_sys_sel.hw,
  2778. [CLKID_HDMI_SYS_DIV] = &meson8b_hdmi_sys_div.hw,
  2779. [CLKID_HDMI_SYS] = &meson8b_hdmi_sys.hw,
  2780. [CLKID_MALI_0_SEL] = &meson8b_mali_0_sel.hw,
  2781. [CLKID_MALI_0_DIV] = &meson8b_mali_0_div.hw,
  2782. [CLKID_MALI] = &meson8b_mali_0.hw,
  2783. [CLKID_VPU_0_SEL] = &meson8b_vpu_0_sel.hw,
  2784. [CLKID_VPU_0_DIV] = &meson8b_vpu_0_div.hw,
  2785. [CLKID_VPU] = &meson8b_vpu_0.hw,
  2786. [CLKID_VDEC_1_SEL] = &meson8b_vdec_1_sel.hw,
  2787. [CLKID_VDEC_1_1_DIV] = &meson8b_vdec_1_1_div.hw,
  2788. [CLKID_VDEC_1] = &meson8b_vdec_1_1.hw,
  2789. [CLKID_VDEC_HCODEC_SEL] = &meson8b_vdec_hcodec_sel.hw,
  2790. [CLKID_VDEC_HCODEC_DIV] = &meson8b_vdec_hcodec_div.hw,
  2791. [CLKID_VDEC_HCODEC] = &meson8b_vdec_hcodec.hw,
  2792. [CLKID_VDEC_2_SEL] = &meson8b_vdec_2_sel.hw,
  2793. [CLKID_VDEC_2_DIV] = &meson8b_vdec_2_div.hw,
  2794. [CLKID_VDEC_2] = &meson8b_vdec_2.hw,
  2795. [CLKID_VDEC_HEVC_SEL] = &meson8b_vdec_hevc_sel.hw,
  2796. [CLKID_VDEC_HEVC_DIV] = &meson8b_vdec_hevc_div.hw,
  2797. [CLKID_VDEC_HEVC_EN] = &meson8b_vdec_hevc_en.hw,
  2798. [CLKID_VDEC_HEVC] = &meson8b_vdec_hevc.hw,
  2799. [CLKID_CTS_AMCLK_SEL] = &meson8b_cts_amclk_sel.hw,
  2800. [CLKID_CTS_AMCLK_DIV] = &meson8b_cts_amclk_div.hw,
  2801. [CLKID_CTS_AMCLK] = &meson8b_cts_amclk.hw,
  2802. [CLKID_CTS_MCLK_I958_SEL] = &meson8b_cts_mclk_i958_sel.hw,
  2803. [CLKID_CTS_MCLK_I958_DIV] = &meson8b_cts_mclk_i958_div.hw,
  2804. [CLKID_CTS_MCLK_I958] = &meson8b_cts_mclk_i958.hw,
  2805. [CLKID_CTS_I958] = &meson8b_cts_i958.hw,
  2806. [CLKID_VID_PLL_LVDS_EN] = &meson8b_vid_pll_lvds_en.hw,
  2807. [CLKID_HDMI_PLL_DCO_IN] = &hdmi_pll_dco_in.hw,
  2808. };
  2809. static struct clk_hw *meson8b_hw_clks[] = {
  2810. [CLKID_PLL_FIXED] = &meson8b_fixed_pll.hw,
  2811. [CLKID_PLL_VID] = &meson8b_vid_pll.hw,
  2812. [CLKID_PLL_SYS] = &meson8b_sys_pll.hw,
  2813. [CLKID_FCLK_DIV2] = &meson8b_fclk_div2.hw,
  2814. [CLKID_FCLK_DIV3] = &meson8b_fclk_div3.hw,
  2815. [CLKID_FCLK_DIV4] = &meson8b_fclk_div4.hw,
  2816. [CLKID_FCLK_DIV5] = &meson8b_fclk_div5.hw,
  2817. [CLKID_FCLK_DIV7] = &meson8b_fclk_div7.hw,
  2818. [CLKID_CPUCLK] = &meson8b_cpu_clk.hw,
  2819. [CLKID_MPEG_SEL] = &meson8b_mpeg_clk_sel.hw,
  2820. [CLKID_MPEG_DIV] = &meson8b_mpeg_clk_div.hw,
  2821. [CLKID_CLK81] = &meson8b_clk81.hw,
  2822. [CLKID_DDR] = &meson8b_ddr.hw,
  2823. [CLKID_DOS] = &meson8b_dos.hw,
  2824. [CLKID_ISA] = &meson8b_isa.hw,
  2825. [CLKID_PL301] = &meson8b_pl301.hw,
  2826. [CLKID_PERIPHS] = &meson8b_periphs.hw,
  2827. [CLKID_SPICC] = &meson8b_spicc.hw,
  2828. [CLKID_I2C] = &meson8b_i2c.hw,
  2829. [CLKID_SAR_ADC] = &meson8b_sar_adc.hw,
  2830. [CLKID_SMART_CARD] = &meson8b_smart_card.hw,
  2831. [CLKID_RNG0] = &meson8b_rng0.hw,
  2832. [CLKID_UART0] = &meson8b_uart0.hw,
  2833. [CLKID_SDHC] = &meson8b_sdhc.hw,
  2834. [CLKID_STREAM] = &meson8b_stream.hw,
  2835. [CLKID_ASYNC_FIFO] = &meson8b_async_fifo.hw,
  2836. [CLKID_SDIO] = &meson8b_sdio.hw,
  2837. [CLKID_ABUF] = &meson8b_abuf.hw,
  2838. [CLKID_HIU_IFACE] = &meson8b_hiu_iface.hw,
  2839. [CLKID_ASSIST_MISC] = &meson8b_assist_misc.hw,
  2840. [CLKID_SPI] = &meson8b_spi.hw,
  2841. [CLKID_I2S_SPDIF] = &meson8b_i2s_spdif.hw,
  2842. [CLKID_ETH] = &meson8b_eth.hw,
  2843. [CLKID_DEMUX] = &meson8b_demux.hw,
  2844. [CLKID_AIU_GLUE] = &meson8b_aiu_glue.hw,
  2845. [CLKID_IEC958] = &meson8b_iec958.hw,
  2846. [CLKID_I2S_OUT] = &meson8b_i2s_out.hw,
  2847. [CLKID_AMCLK] = &meson8b_amclk.hw,
  2848. [CLKID_AIFIFO2] = &meson8b_aififo2.hw,
  2849. [CLKID_MIXER] = &meson8b_mixer.hw,
  2850. [CLKID_MIXER_IFACE] = &meson8b_mixer_iface.hw,
  2851. [CLKID_ADC] = &meson8b_adc.hw,
  2852. [CLKID_BLKMV] = &meson8b_blkmv.hw,
  2853. [CLKID_AIU] = &meson8b_aiu.hw,
  2854. [CLKID_UART1] = &meson8b_uart1.hw,
  2855. [CLKID_G2D] = &meson8b_g2d.hw,
  2856. [CLKID_USB0] = &meson8b_usb0.hw,
  2857. [CLKID_USB1] = &meson8b_usb1.hw,
  2858. [CLKID_RESET] = &meson8b_reset.hw,
  2859. [CLKID_NAND] = &meson8b_nand.hw,
  2860. [CLKID_DOS_PARSER] = &meson8b_dos_parser.hw,
  2861. [CLKID_USB] = &meson8b_usb.hw,
  2862. [CLKID_VDIN1] = &meson8b_vdin1.hw,
  2863. [CLKID_AHB_ARB0] = &meson8b_ahb_arb0.hw,
  2864. [CLKID_EFUSE] = &meson8b_efuse.hw,
  2865. [CLKID_BOOT_ROM] = &meson8b_boot_rom.hw,
  2866. [CLKID_AHB_DATA_BUS] = &meson8b_ahb_data_bus.hw,
  2867. [CLKID_AHB_CTRL_BUS] = &meson8b_ahb_ctrl_bus.hw,
  2868. [CLKID_HDMI_INTR_SYNC] = &meson8b_hdmi_intr_sync.hw,
  2869. [CLKID_HDMI_PCLK] = &meson8b_hdmi_pclk.hw,
  2870. [CLKID_USB1_DDR_BRIDGE] = &meson8b_usb1_ddr_bridge.hw,
  2871. [CLKID_USB0_DDR_BRIDGE] = &meson8b_usb0_ddr_bridge.hw,
  2872. [CLKID_MMC_PCLK] = &meson8b_mmc_pclk.hw,
  2873. [CLKID_DVIN] = &meson8b_dvin.hw,
  2874. [CLKID_UART2] = &meson8b_uart2.hw,
  2875. [CLKID_SANA] = &meson8b_sana.hw,
  2876. [CLKID_VPU_INTR] = &meson8b_vpu_intr.hw,
  2877. [CLKID_SEC_AHB_AHB3_BRIDGE] = &meson8b_sec_ahb_ahb3_bridge.hw,
  2878. [CLKID_CLK81_A9] = &meson8b_clk81_a9.hw,
  2879. [CLKID_VCLK2_VENCI0] = &meson8b_vclk2_venci0.hw,
  2880. [CLKID_VCLK2_VENCI1] = &meson8b_vclk2_venci1.hw,
  2881. [CLKID_VCLK2_VENCP0] = &meson8b_vclk2_vencp0.hw,
  2882. [CLKID_VCLK2_VENCP1] = &meson8b_vclk2_vencp1.hw,
  2883. [CLKID_GCLK_VENCI_INT] = &meson8b_gclk_venci_int.hw,
  2884. [CLKID_GCLK_VENCP_INT] = &meson8b_gclk_vencp_int.hw,
  2885. [CLKID_DAC_CLK] = &meson8b_dac_clk.hw,
  2886. [CLKID_AOCLK_GATE] = &meson8b_aoclk_gate.hw,
  2887. [CLKID_IEC958_GATE] = &meson8b_iec958_gate.hw,
  2888. [CLKID_ENC480P] = &meson8b_enc480p.hw,
  2889. [CLKID_RNG1] = &meson8b_rng1.hw,
  2890. [CLKID_GCLK_VENCL_INT] = &meson8b_gclk_vencl_int.hw,
  2891. [CLKID_VCLK2_VENCLMCC] = &meson8b_vclk2_venclmcc.hw,
  2892. [CLKID_VCLK2_VENCL] = &meson8b_vclk2_vencl.hw,
  2893. [CLKID_VCLK2_OTHER] = &meson8b_vclk2_other.hw,
  2894. [CLKID_EDP] = &meson8b_edp.hw,
  2895. [CLKID_AO_MEDIA_CPU] = &meson8b_ao_media_cpu.hw,
  2896. [CLKID_AO_AHB_SRAM] = &meson8b_ao_ahb_sram.hw,
  2897. [CLKID_AO_AHB_BUS] = &meson8b_ao_ahb_bus.hw,
  2898. [CLKID_AO_IFACE] = &meson8b_ao_iface.hw,
  2899. [CLKID_MPLL0] = &meson8b_mpll0.hw,
  2900. [CLKID_MPLL1] = &meson8b_mpll1.hw,
  2901. [CLKID_MPLL2] = &meson8b_mpll2.hw,
  2902. [CLKID_MPLL0_DIV] = &meson8b_mpll0_div.hw,
  2903. [CLKID_MPLL1_DIV] = &meson8b_mpll1_div.hw,
  2904. [CLKID_MPLL2_DIV] = &meson8b_mpll2_div.hw,
  2905. [CLKID_CPU_IN_SEL] = &meson8b_cpu_in_sel.hw,
  2906. [CLKID_CPU_IN_DIV2] = &meson8b_cpu_in_div2.hw,
  2907. [CLKID_CPU_IN_DIV3] = &meson8b_cpu_in_div3.hw,
  2908. [CLKID_CPU_SCALE_DIV] = &meson8b_cpu_scale_div.hw,
  2909. [CLKID_CPU_SCALE_OUT_SEL] = &meson8b_cpu_scale_out_sel.hw,
  2910. [CLKID_MPLL_PREDIV] = &meson8b_mpll_prediv.hw,
  2911. [CLKID_FCLK_DIV2_DIV] = &meson8b_fclk_div2_div.hw,
  2912. [CLKID_FCLK_DIV3_DIV] = &meson8b_fclk_div3_div.hw,
  2913. [CLKID_FCLK_DIV4_DIV] = &meson8b_fclk_div4_div.hw,
  2914. [CLKID_FCLK_DIV5_DIV] = &meson8b_fclk_div5_div.hw,
  2915. [CLKID_FCLK_DIV7_DIV] = &meson8b_fclk_div7_div.hw,
  2916. [CLKID_NAND_SEL] = &meson8b_nand_clk_sel.hw,
  2917. [CLKID_NAND_DIV] = &meson8b_nand_clk_div.hw,
  2918. [CLKID_NAND_CLK] = &meson8b_nand_clk_gate.hw,
  2919. [CLKID_PLL_FIXED_DCO] = &meson8b_fixed_pll_dco.hw,
  2920. [CLKID_HDMI_PLL_DCO] = &meson8b_hdmi_pll_dco.hw,
  2921. [CLKID_PLL_SYS_DCO] = &meson8b_sys_pll_dco.hw,
  2922. [CLKID_CPU_CLK_DIV2] = &meson8b_cpu_clk_div2.hw,
  2923. [CLKID_CPU_CLK_DIV3] = &meson8b_cpu_clk_div3.hw,
  2924. [CLKID_CPU_CLK_DIV4] = &meson8b_cpu_clk_div4.hw,
  2925. [CLKID_CPU_CLK_DIV5] = &meson8b_cpu_clk_div5.hw,
  2926. [CLKID_CPU_CLK_DIV6] = &meson8b_cpu_clk_div6.hw,
  2927. [CLKID_CPU_CLK_DIV7] = &meson8b_cpu_clk_div7.hw,
  2928. [CLKID_CPU_CLK_DIV8] = &meson8b_cpu_clk_div8.hw,
  2929. [CLKID_APB_SEL] = &meson8b_apb_clk_sel.hw,
  2930. [CLKID_APB] = &meson8b_apb_clk_gate.hw,
  2931. [CLKID_PERIPH_SEL] = &meson8b_periph_clk_sel.hw,
  2932. [CLKID_PERIPH] = &meson8b_periph_clk_gate.hw,
  2933. [CLKID_AXI_SEL] = &meson8b_axi_clk_sel.hw,
  2934. [CLKID_AXI] = &meson8b_axi_clk_gate.hw,
  2935. [CLKID_L2_DRAM_SEL] = &meson8b_l2_dram_clk_sel.hw,
  2936. [CLKID_L2_DRAM] = &meson8b_l2_dram_clk_gate.hw,
  2937. [CLKID_HDMI_PLL_LVDS_OUT] = &meson8b_hdmi_pll_lvds_out.hw,
  2938. [CLKID_HDMI_PLL_HDMI_OUT] = &meson8b_hdmi_pll_hdmi_out.hw,
  2939. [CLKID_VID_PLL_IN_SEL] = &meson8b_vid_pll_in_sel.hw,
  2940. [CLKID_VID_PLL_IN_EN] = &meson8b_vid_pll_in_en.hw,
  2941. [CLKID_VID_PLL_PRE_DIV] = &meson8b_vid_pll_pre_div.hw,
  2942. [CLKID_VID_PLL_POST_DIV] = &meson8b_vid_pll_post_div.hw,
  2943. [CLKID_VID_PLL_FINAL_DIV] = &meson8b_vid_pll_final_div.hw,
  2944. [CLKID_VCLK_IN_SEL] = &meson8b_vclk_in_sel.hw,
  2945. [CLKID_VCLK_IN_EN] = &meson8b_vclk_in_en.hw,
  2946. [CLKID_VCLK_EN] = &meson8b_vclk_en.hw,
  2947. [CLKID_VCLK_DIV1] = &meson8b_vclk_div1_gate.hw,
  2948. [CLKID_VCLK_DIV2_DIV] = &meson8b_vclk_div2_div.hw,
  2949. [CLKID_VCLK_DIV2] = &meson8b_vclk_div2_div_gate.hw,
  2950. [CLKID_VCLK_DIV4_DIV] = &meson8b_vclk_div4_div.hw,
  2951. [CLKID_VCLK_DIV4] = &meson8b_vclk_div4_div_gate.hw,
  2952. [CLKID_VCLK_DIV6_DIV] = &meson8b_vclk_div6_div.hw,
  2953. [CLKID_VCLK_DIV6] = &meson8b_vclk_div6_div_gate.hw,
  2954. [CLKID_VCLK_DIV12_DIV] = &meson8b_vclk_div12_div.hw,
  2955. [CLKID_VCLK_DIV12] = &meson8b_vclk_div12_div_gate.hw,
  2956. [CLKID_VCLK2_IN_SEL] = &meson8b_vclk2_in_sel.hw,
  2957. [CLKID_VCLK2_IN_EN] = &meson8b_vclk2_clk_in_en.hw,
  2958. [CLKID_VCLK2_EN] = &meson8b_vclk2_clk_en.hw,
  2959. [CLKID_VCLK2_DIV1] = &meson8b_vclk2_div1_gate.hw,
  2960. [CLKID_VCLK2_DIV2_DIV] = &meson8b_vclk2_div2_div.hw,
  2961. [CLKID_VCLK2_DIV2] = &meson8b_vclk2_div2_div_gate.hw,
  2962. [CLKID_VCLK2_DIV4_DIV] = &meson8b_vclk2_div4_div.hw,
  2963. [CLKID_VCLK2_DIV4] = &meson8b_vclk2_div4_div_gate.hw,
  2964. [CLKID_VCLK2_DIV6_DIV] = &meson8b_vclk2_div6_div.hw,
  2965. [CLKID_VCLK2_DIV6] = &meson8b_vclk2_div6_div_gate.hw,
  2966. [CLKID_VCLK2_DIV12_DIV] = &meson8b_vclk2_div12_div.hw,
  2967. [CLKID_VCLK2_DIV12] = &meson8b_vclk2_div12_div_gate.hw,
  2968. [CLKID_CTS_ENCT_SEL] = &meson8b_cts_enct_sel.hw,
  2969. [CLKID_CTS_ENCT] = &meson8b_cts_enct.hw,
  2970. [CLKID_CTS_ENCP_SEL] = &meson8b_cts_encp_sel.hw,
  2971. [CLKID_CTS_ENCP] = &meson8b_cts_encp.hw,
  2972. [CLKID_CTS_ENCI_SEL] = &meson8b_cts_enci_sel.hw,
  2973. [CLKID_CTS_ENCI] = &meson8b_cts_enci.hw,
  2974. [CLKID_HDMI_TX_PIXEL_SEL] = &meson8b_hdmi_tx_pixel_sel.hw,
  2975. [CLKID_HDMI_TX_PIXEL] = &meson8b_hdmi_tx_pixel.hw,
  2976. [CLKID_CTS_ENCL_SEL] = &meson8b_cts_encl_sel.hw,
  2977. [CLKID_CTS_ENCL] = &meson8b_cts_encl.hw,
  2978. [CLKID_CTS_VDAC0_SEL] = &meson8b_cts_vdac0_sel.hw,
  2979. [CLKID_CTS_VDAC0] = &meson8b_cts_vdac0.hw,
  2980. [CLKID_HDMI_SYS_SEL] = &meson8b_hdmi_sys_sel.hw,
  2981. [CLKID_HDMI_SYS_DIV] = &meson8b_hdmi_sys_div.hw,
  2982. [CLKID_HDMI_SYS] = &meson8b_hdmi_sys.hw,
  2983. [CLKID_MALI_0_SEL] = &meson8b_mali_0_sel.hw,
  2984. [CLKID_MALI_0_DIV] = &meson8b_mali_0_div.hw,
  2985. [CLKID_MALI_0] = &meson8b_mali_0.hw,
  2986. [CLKID_MALI_1_SEL] = &meson8b_mali_1_sel.hw,
  2987. [CLKID_MALI_1_DIV] = &meson8b_mali_1_div.hw,
  2988. [CLKID_MALI_1] = &meson8b_mali_1.hw,
  2989. [CLKID_MALI] = &meson8b_mali.hw,
  2990. [CLKID_VPU_0_SEL] = &meson8b_vpu_0_sel.hw,
  2991. [CLKID_VPU_0_DIV] = &meson8b_vpu_0_div.hw,
  2992. [CLKID_VPU_0] = &meson8b_vpu_0.hw,
  2993. [CLKID_VPU_1_SEL] = &meson8b_vpu_1_sel.hw,
  2994. [CLKID_VPU_1_DIV] = &meson8b_vpu_1_div.hw,
  2995. [CLKID_VPU_1] = &meson8b_vpu_1.hw,
  2996. [CLKID_VPU] = &meson8b_vpu.hw,
  2997. [CLKID_VDEC_1_SEL] = &meson8b_vdec_1_sel.hw,
  2998. [CLKID_VDEC_1_1_DIV] = &meson8b_vdec_1_1_div.hw,
  2999. [CLKID_VDEC_1_1] = &meson8b_vdec_1_1.hw,
  3000. [CLKID_VDEC_1_2_DIV] = &meson8b_vdec_1_2_div.hw,
  3001. [CLKID_VDEC_1_2] = &meson8b_vdec_1_2.hw,
  3002. [CLKID_VDEC_1] = &meson8b_vdec_1.hw,
  3003. [CLKID_VDEC_HCODEC_SEL] = &meson8b_vdec_hcodec_sel.hw,
  3004. [CLKID_VDEC_HCODEC_DIV] = &meson8b_vdec_hcodec_div.hw,
  3005. [CLKID_VDEC_HCODEC] = &meson8b_vdec_hcodec.hw,
  3006. [CLKID_VDEC_2_SEL] = &meson8b_vdec_2_sel.hw,
  3007. [CLKID_VDEC_2_DIV] = &meson8b_vdec_2_div.hw,
  3008. [CLKID_VDEC_2] = &meson8b_vdec_2.hw,
  3009. [CLKID_VDEC_HEVC_SEL] = &meson8b_vdec_hevc_sel.hw,
  3010. [CLKID_VDEC_HEVC_DIV] = &meson8b_vdec_hevc_div.hw,
  3011. [CLKID_VDEC_HEVC_EN] = &meson8b_vdec_hevc_en.hw,
  3012. [CLKID_VDEC_HEVC] = &meson8b_vdec_hevc.hw,
  3013. [CLKID_CTS_AMCLK_SEL] = &meson8b_cts_amclk_sel.hw,
  3014. [CLKID_CTS_AMCLK_DIV] = &meson8b_cts_amclk_div.hw,
  3015. [CLKID_CTS_AMCLK] = &meson8b_cts_amclk.hw,
  3016. [CLKID_CTS_MCLK_I958_SEL] = &meson8b_cts_mclk_i958_sel.hw,
  3017. [CLKID_CTS_MCLK_I958_DIV] = &meson8b_cts_mclk_i958_div.hw,
  3018. [CLKID_CTS_MCLK_I958] = &meson8b_cts_mclk_i958.hw,
  3019. [CLKID_CTS_I958] = &meson8b_cts_i958.hw,
  3020. [CLKID_VID_PLL_LVDS_EN] = &meson8b_vid_pll_lvds_en.hw,
  3021. [CLKID_HDMI_PLL_DCO_IN] = &hdmi_pll_dco_in.hw,
  3022. };
  3023. static struct clk_hw *meson8m2_hw_clks[] = {
  3024. [CLKID_PLL_FIXED] = &meson8b_fixed_pll.hw,
  3025. [CLKID_PLL_VID] = &meson8b_vid_pll.hw,
  3026. [CLKID_PLL_SYS] = &meson8b_sys_pll.hw,
  3027. [CLKID_FCLK_DIV2] = &meson8b_fclk_div2.hw,
  3028. [CLKID_FCLK_DIV3] = &meson8b_fclk_div3.hw,
  3029. [CLKID_FCLK_DIV4] = &meson8b_fclk_div4.hw,
  3030. [CLKID_FCLK_DIV5] = &meson8b_fclk_div5.hw,
  3031. [CLKID_FCLK_DIV7] = &meson8b_fclk_div7.hw,
  3032. [CLKID_CPUCLK] = &meson8b_cpu_clk.hw,
  3033. [CLKID_MPEG_SEL] = &meson8b_mpeg_clk_sel.hw,
  3034. [CLKID_MPEG_DIV] = &meson8b_mpeg_clk_div.hw,
  3035. [CLKID_CLK81] = &meson8b_clk81.hw,
  3036. [CLKID_DDR] = &meson8b_ddr.hw,
  3037. [CLKID_DOS] = &meson8b_dos.hw,
  3038. [CLKID_ISA] = &meson8b_isa.hw,
  3039. [CLKID_PL301] = &meson8b_pl301.hw,
  3040. [CLKID_PERIPHS] = &meson8b_periphs.hw,
  3041. [CLKID_SPICC] = &meson8b_spicc.hw,
  3042. [CLKID_I2C] = &meson8b_i2c.hw,
  3043. [CLKID_SAR_ADC] = &meson8b_sar_adc.hw,
  3044. [CLKID_SMART_CARD] = &meson8b_smart_card.hw,
  3045. [CLKID_RNG0] = &meson8b_rng0.hw,
  3046. [CLKID_UART0] = &meson8b_uart0.hw,
  3047. [CLKID_SDHC] = &meson8b_sdhc.hw,
  3048. [CLKID_STREAM] = &meson8b_stream.hw,
  3049. [CLKID_ASYNC_FIFO] = &meson8b_async_fifo.hw,
  3050. [CLKID_SDIO] = &meson8b_sdio.hw,
  3051. [CLKID_ABUF] = &meson8b_abuf.hw,
  3052. [CLKID_HIU_IFACE] = &meson8b_hiu_iface.hw,
  3053. [CLKID_ASSIST_MISC] = &meson8b_assist_misc.hw,
  3054. [CLKID_SPI] = &meson8b_spi.hw,
  3055. [CLKID_I2S_SPDIF] = &meson8b_i2s_spdif.hw,
  3056. [CLKID_ETH] = &meson8b_eth.hw,
  3057. [CLKID_DEMUX] = &meson8b_demux.hw,
  3058. [CLKID_AIU_GLUE] = &meson8b_aiu_glue.hw,
  3059. [CLKID_IEC958] = &meson8b_iec958.hw,
  3060. [CLKID_I2S_OUT] = &meson8b_i2s_out.hw,
  3061. [CLKID_AMCLK] = &meson8b_amclk.hw,
  3062. [CLKID_AIFIFO2] = &meson8b_aififo2.hw,
  3063. [CLKID_MIXER] = &meson8b_mixer.hw,
  3064. [CLKID_MIXER_IFACE] = &meson8b_mixer_iface.hw,
  3065. [CLKID_ADC] = &meson8b_adc.hw,
  3066. [CLKID_BLKMV] = &meson8b_blkmv.hw,
  3067. [CLKID_AIU] = &meson8b_aiu.hw,
  3068. [CLKID_UART1] = &meson8b_uart1.hw,
  3069. [CLKID_G2D] = &meson8b_g2d.hw,
  3070. [CLKID_USB0] = &meson8b_usb0.hw,
  3071. [CLKID_USB1] = &meson8b_usb1.hw,
  3072. [CLKID_RESET] = &meson8b_reset.hw,
  3073. [CLKID_NAND] = &meson8b_nand.hw,
  3074. [CLKID_DOS_PARSER] = &meson8b_dos_parser.hw,
  3075. [CLKID_USB] = &meson8b_usb.hw,
  3076. [CLKID_VDIN1] = &meson8b_vdin1.hw,
  3077. [CLKID_AHB_ARB0] = &meson8b_ahb_arb0.hw,
  3078. [CLKID_EFUSE] = &meson8b_efuse.hw,
  3079. [CLKID_BOOT_ROM] = &meson8b_boot_rom.hw,
  3080. [CLKID_AHB_DATA_BUS] = &meson8b_ahb_data_bus.hw,
  3081. [CLKID_AHB_CTRL_BUS] = &meson8b_ahb_ctrl_bus.hw,
  3082. [CLKID_HDMI_INTR_SYNC] = &meson8b_hdmi_intr_sync.hw,
  3083. [CLKID_HDMI_PCLK] = &meson8b_hdmi_pclk.hw,
  3084. [CLKID_USB1_DDR_BRIDGE] = &meson8b_usb1_ddr_bridge.hw,
  3085. [CLKID_USB0_DDR_BRIDGE] = &meson8b_usb0_ddr_bridge.hw,
  3086. [CLKID_MMC_PCLK] = &meson8b_mmc_pclk.hw,
  3087. [CLKID_DVIN] = &meson8b_dvin.hw,
  3088. [CLKID_UART2] = &meson8b_uart2.hw,
  3089. [CLKID_SANA] = &meson8b_sana.hw,
  3090. [CLKID_VPU_INTR] = &meson8b_vpu_intr.hw,
  3091. [CLKID_SEC_AHB_AHB3_BRIDGE] = &meson8b_sec_ahb_ahb3_bridge.hw,
  3092. [CLKID_CLK81_A9] = &meson8b_clk81_a9.hw,
  3093. [CLKID_VCLK2_VENCI0] = &meson8b_vclk2_venci0.hw,
  3094. [CLKID_VCLK2_VENCI1] = &meson8b_vclk2_venci1.hw,
  3095. [CLKID_VCLK2_VENCP0] = &meson8b_vclk2_vencp0.hw,
  3096. [CLKID_VCLK2_VENCP1] = &meson8b_vclk2_vencp1.hw,
  3097. [CLKID_GCLK_VENCI_INT] = &meson8b_gclk_venci_int.hw,
  3098. [CLKID_GCLK_VENCP_INT] = &meson8b_gclk_vencp_int.hw,
  3099. [CLKID_DAC_CLK] = &meson8b_dac_clk.hw,
  3100. [CLKID_AOCLK_GATE] = &meson8b_aoclk_gate.hw,
  3101. [CLKID_IEC958_GATE] = &meson8b_iec958_gate.hw,
  3102. [CLKID_ENC480P] = &meson8b_enc480p.hw,
  3103. [CLKID_RNG1] = &meson8b_rng1.hw,
  3104. [CLKID_GCLK_VENCL_INT] = &meson8b_gclk_vencl_int.hw,
  3105. [CLKID_VCLK2_VENCLMCC] = &meson8b_vclk2_venclmcc.hw,
  3106. [CLKID_VCLK2_VENCL] = &meson8b_vclk2_vencl.hw,
  3107. [CLKID_VCLK2_OTHER] = &meson8b_vclk2_other.hw,
  3108. [CLKID_EDP] = &meson8b_edp.hw,
  3109. [CLKID_AO_MEDIA_CPU] = &meson8b_ao_media_cpu.hw,
  3110. [CLKID_AO_AHB_SRAM] = &meson8b_ao_ahb_sram.hw,
  3111. [CLKID_AO_AHB_BUS] = &meson8b_ao_ahb_bus.hw,
  3112. [CLKID_AO_IFACE] = &meson8b_ao_iface.hw,
  3113. [CLKID_MPLL0] = &meson8b_mpll0.hw,
  3114. [CLKID_MPLL1] = &meson8b_mpll1.hw,
  3115. [CLKID_MPLL2] = &meson8b_mpll2.hw,
  3116. [CLKID_MPLL0_DIV] = &meson8b_mpll0_div.hw,
  3117. [CLKID_MPLL1_DIV] = &meson8b_mpll1_div.hw,
  3118. [CLKID_MPLL2_DIV] = &meson8b_mpll2_div.hw,
  3119. [CLKID_CPU_IN_SEL] = &meson8b_cpu_in_sel.hw,
  3120. [CLKID_CPU_IN_DIV2] = &meson8b_cpu_in_div2.hw,
  3121. [CLKID_CPU_IN_DIV3] = &meson8b_cpu_in_div3.hw,
  3122. [CLKID_CPU_SCALE_DIV] = &meson8b_cpu_scale_div.hw,
  3123. [CLKID_CPU_SCALE_OUT_SEL] = &meson8b_cpu_scale_out_sel.hw,
  3124. [CLKID_MPLL_PREDIV] = &meson8b_mpll_prediv.hw,
  3125. [CLKID_FCLK_DIV2_DIV] = &meson8b_fclk_div2_div.hw,
  3126. [CLKID_FCLK_DIV3_DIV] = &meson8b_fclk_div3_div.hw,
  3127. [CLKID_FCLK_DIV4_DIV] = &meson8b_fclk_div4_div.hw,
  3128. [CLKID_FCLK_DIV5_DIV] = &meson8b_fclk_div5_div.hw,
  3129. [CLKID_FCLK_DIV7_DIV] = &meson8b_fclk_div7_div.hw,
  3130. [CLKID_NAND_SEL] = &meson8b_nand_clk_sel.hw,
  3131. [CLKID_NAND_DIV] = &meson8b_nand_clk_div.hw,
  3132. [CLKID_NAND_CLK] = &meson8b_nand_clk_gate.hw,
  3133. [CLKID_PLL_FIXED_DCO] = &meson8b_fixed_pll_dco.hw,
  3134. [CLKID_HDMI_PLL_DCO] = &meson8b_hdmi_pll_dco.hw,
  3135. [CLKID_PLL_SYS_DCO] = &meson8b_sys_pll_dco.hw,
  3136. [CLKID_CPU_CLK_DIV2] = &meson8b_cpu_clk_div2.hw,
  3137. [CLKID_CPU_CLK_DIV3] = &meson8b_cpu_clk_div3.hw,
  3138. [CLKID_CPU_CLK_DIV4] = &meson8b_cpu_clk_div4.hw,
  3139. [CLKID_CPU_CLK_DIV5] = &meson8b_cpu_clk_div5.hw,
  3140. [CLKID_CPU_CLK_DIV6] = &meson8b_cpu_clk_div6.hw,
  3141. [CLKID_CPU_CLK_DIV7] = &meson8b_cpu_clk_div7.hw,
  3142. [CLKID_CPU_CLK_DIV8] = &meson8b_cpu_clk_div8.hw,
  3143. [CLKID_APB_SEL] = &meson8b_apb_clk_sel.hw,
  3144. [CLKID_APB] = &meson8b_apb_clk_gate.hw,
  3145. [CLKID_PERIPH_SEL] = &meson8b_periph_clk_sel.hw,
  3146. [CLKID_PERIPH] = &meson8b_periph_clk_gate.hw,
  3147. [CLKID_AXI_SEL] = &meson8b_axi_clk_sel.hw,
  3148. [CLKID_AXI] = &meson8b_axi_clk_gate.hw,
  3149. [CLKID_L2_DRAM_SEL] = &meson8b_l2_dram_clk_sel.hw,
  3150. [CLKID_L2_DRAM] = &meson8b_l2_dram_clk_gate.hw,
  3151. [CLKID_HDMI_PLL_LVDS_OUT] = &meson8b_hdmi_pll_lvds_out.hw,
  3152. [CLKID_HDMI_PLL_HDMI_OUT] = &meson8b_hdmi_pll_hdmi_out.hw,
  3153. [CLKID_VID_PLL_IN_SEL] = &meson8b_vid_pll_in_sel.hw,
  3154. [CLKID_VID_PLL_IN_EN] = &meson8b_vid_pll_in_en.hw,
  3155. [CLKID_VID_PLL_PRE_DIV] = &meson8b_vid_pll_pre_div.hw,
  3156. [CLKID_VID_PLL_POST_DIV] = &meson8b_vid_pll_post_div.hw,
  3157. [CLKID_VID_PLL_FINAL_DIV] = &meson8b_vid_pll_final_div.hw,
  3158. [CLKID_VCLK_IN_SEL] = &meson8b_vclk_in_sel.hw,
  3159. [CLKID_VCLK_IN_EN] = &meson8b_vclk_in_en.hw,
  3160. [CLKID_VCLK_EN] = &meson8b_vclk_en.hw,
  3161. [CLKID_VCLK_DIV1] = &meson8b_vclk_div1_gate.hw,
  3162. [CLKID_VCLK_DIV2_DIV] = &meson8b_vclk_div2_div.hw,
  3163. [CLKID_VCLK_DIV2] = &meson8b_vclk_div2_div_gate.hw,
  3164. [CLKID_VCLK_DIV4_DIV] = &meson8b_vclk_div4_div.hw,
  3165. [CLKID_VCLK_DIV4] = &meson8b_vclk_div4_div_gate.hw,
  3166. [CLKID_VCLK_DIV6_DIV] = &meson8b_vclk_div6_div.hw,
  3167. [CLKID_VCLK_DIV6] = &meson8b_vclk_div6_div_gate.hw,
  3168. [CLKID_VCLK_DIV12_DIV] = &meson8b_vclk_div12_div.hw,
  3169. [CLKID_VCLK_DIV12] = &meson8b_vclk_div12_div_gate.hw,
  3170. [CLKID_VCLK2_IN_SEL] = &meson8b_vclk2_in_sel.hw,
  3171. [CLKID_VCLK2_IN_EN] = &meson8b_vclk2_clk_in_en.hw,
  3172. [CLKID_VCLK2_EN] = &meson8b_vclk2_clk_en.hw,
  3173. [CLKID_VCLK2_DIV1] = &meson8b_vclk2_div1_gate.hw,
  3174. [CLKID_VCLK2_DIV2_DIV] = &meson8b_vclk2_div2_div.hw,
  3175. [CLKID_VCLK2_DIV2] = &meson8b_vclk2_div2_div_gate.hw,
  3176. [CLKID_VCLK2_DIV4_DIV] = &meson8b_vclk2_div4_div.hw,
  3177. [CLKID_VCLK2_DIV4] = &meson8b_vclk2_div4_div_gate.hw,
  3178. [CLKID_VCLK2_DIV6_DIV] = &meson8b_vclk2_div6_div.hw,
  3179. [CLKID_VCLK2_DIV6] = &meson8b_vclk2_div6_div_gate.hw,
  3180. [CLKID_VCLK2_DIV12_DIV] = &meson8b_vclk2_div12_div.hw,
  3181. [CLKID_VCLK2_DIV12] = &meson8b_vclk2_div12_div_gate.hw,
  3182. [CLKID_CTS_ENCT_SEL] = &meson8b_cts_enct_sel.hw,
  3183. [CLKID_CTS_ENCT] = &meson8b_cts_enct.hw,
  3184. [CLKID_CTS_ENCP_SEL] = &meson8b_cts_encp_sel.hw,
  3185. [CLKID_CTS_ENCP] = &meson8b_cts_encp.hw,
  3186. [CLKID_CTS_ENCI_SEL] = &meson8b_cts_enci_sel.hw,
  3187. [CLKID_CTS_ENCI] = &meson8b_cts_enci.hw,
  3188. [CLKID_HDMI_TX_PIXEL_SEL] = &meson8b_hdmi_tx_pixel_sel.hw,
  3189. [CLKID_HDMI_TX_PIXEL] = &meson8b_hdmi_tx_pixel.hw,
  3190. [CLKID_CTS_ENCL_SEL] = &meson8b_cts_encl_sel.hw,
  3191. [CLKID_CTS_ENCL] = &meson8b_cts_encl.hw,
  3192. [CLKID_CTS_VDAC0_SEL] = &meson8b_cts_vdac0_sel.hw,
  3193. [CLKID_CTS_VDAC0] = &meson8b_cts_vdac0.hw,
  3194. [CLKID_HDMI_SYS_SEL] = &meson8b_hdmi_sys_sel.hw,
  3195. [CLKID_HDMI_SYS_DIV] = &meson8b_hdmi_sys_div.hw,
  3196. [CLKID_HDMI_SYS] = &meson8b_hdmi_sys.hw,
  3197. [CLKID_MALI_0_SEL] = &meson8b_mali_0_sel.hw,
  3198. [CLKID_MALI_0_DIV] = &meson8b_mali_0_div.hw,
  3199. [CLKID_MALI_0] = &meson8b_mali_0.hw,
  3200. [CLKID_MALI_1_SEL] = &meson8b_mali_1_sel.hw,
  3201. [CLKID_MALI_1_DIV] = &meson8b_mali_1_div.hw,
  3202. [CLKID_MALI_1] = &meson8b_mali_1.hw,
  3203. [CLKID_MALI] = &meson8b_mali.hw,
  3204. [CLKID_GP_PLL_DCO] = &meson8m2_gp_pll_dco.hw,
  3205. [CLKID_GP_PLL] = &meson8m2_gp_pll.hw,
  3206. [CLKID_VPU_0_SEL] = &meson8m2_vpu_0_sel.hw,
  3207. [CLKID_VPU_0_DIV] = &meson8b_vpu_0_div.hw,
  3208. [CLKID_VPU_0] = &meson8b_vpu_0.hw,
  3209. [CLKID_VPU_1_SEL] = &meson8m2_vpu_1_sel.hw,
  3210. [CLKID_VPU_1_DIV] = &meson8b_vpu_1_div.hw,
  3211. [CLKID_VPU_1] = &meson8b_vpu_1.hw,
  3212. [CLKID_VPU] = &meson8b_vpu.hw,
  3213. [CLKID_VDEC_1_SEL] = &meson8b_vdec_1_sel.hw,
  3214. [CLKID_VDEC_1_1_DIV] = &meson8b_vdec_1_1_div.hw,
  3215. [CLKID_VDEC_1_1] = &meson8b_vdec_1_1.hw,
  3216. [CLKID_VDEC_1_2_DIV] = &meson8b_vdec_1_2_div.hw,
  3217. [CLKID_VDEC_1_2] = &meson8b_vdec_1_2.hw,
  3218. [CLKID_VDEC_1] = &meson8b_vdec_1.hw,
  3219. [CLKID_VDEC_HCODEC_SEL] = &meson8b_vdec_hcodec_sel.hw,
  3220. [CLKID_VDEC_HCODEC_DIV] = &meson8b_vdec_hcodec_div.hw,
  3221. [CLKID_VDEC_HCODEC] = &meson8b_vdec_hcodec.hw,
  3222. [CLKID_VDEC_2_SEL] = &meson8b_vdec_2_sel.hw,
  3223. [CLKID_VDEC_2_DIV] = &meson8b_vdec_2_div.hw,
  3224. [CLKID_VDEC_2] = &meson8b_vdec_2.hw,
  3225. [CLKID_VDEC_HEVC_SEL] = &meson8b_vdec_hevc_sel.hw,
  3226. [CLKID_VDEC_HEVC_DIV] = &meson8b_vdec_hevc_div.hw,
  3227. [CLKID_VDEC_HEVC_EN] = &meson8b_vdec_hevc_en.hw,
  3228. [CLKID_VDEC_HEVC] = &meson8b_vdec_hevc.hw,
  3229. [CLKID_CTS_AMCLK_SEL] = &meson8b_cts_amclk_sel.hw,
  3230. [CLKID_CTS_AMCLK_DIV] = &meson8b_cts_amclk_div.hw,
  3231. [CLKID_CTS_AMCLK] = &meson8b_cts_amclk.hw,
  3232. [CLKID_CTS_MCLK_I958_SEL] = &meson8b_cts_mclk_i958_sel.hw,
  3233. [CLKID_CTS_MCLK_I958_DIV] = &meson8b_cts_mclk_i958_div.hw,
  3234. [CLKID_CTS_MCLK_I958] = &meson8b_cts_mclk_i958.hw,
  3235. [CLKID_CTS_I958] = &meson8b_cts_i958.hw,
  3236. [CLKID_VID_PLL_LVDS_EN] = &meson8b_vid_pll_lvds_en.hw,
  3237. [CLKID_HDMI_PLL_DCO_IN] = &hdmi_pll_dco_in.hw,
  3238. };
  3239. static struct clk_regmap *const meson8b_clk_regmaps[] = {
  3240. &meson8b_clk81,
  3241. &meson8b_ddr,
  3242. &meson8b_dos,
  3243. &meson8b_isa,
  3244. &meson8b_pl301,
  3245. &meson8b_periphs,
  3246. &meson8b_spicc,
  3247. &meson8b_i2c,
  3248. &meson8b_sar_adc,
  3249. &meson8b_smart_card,
  3250. &meson8b_rng0,
  3251. &meson8b_uart0,
  3252. &meson8b_sdhc,
  3253. &meson8b_stream,
  3254. &meson8b_async_fifo,
  3255. &meson8b_sdio,
  3256. &meson8b_abuf,
  3257. &meson8b_hiu_iface,
  3258. &meson8b_assist_misc,
  3259. &meson8b_spi,
  3260. &meson8b_i2s_spdif,
  3261. &meson8b_eth,
  3262. &meson8b_demux,
  3263. &meson8b_aiu_glue,
  3264. &meson8b_iec958,
  3265. &meson8b_i2s_out,
  3266. &meson8b_amclk,
  3267. &meson8b_aififo2,
  3268. &meson8b_mixer,
  3269. &meson8b_mixer_iface,
  3270. &meson8b_adc,
  3271. &meson8b_blkmv,
  3272. &meson8b_aiu,
  3273. &meson8b_uart1,
  3274. &meson8b_g2d,
  3275. &meson8b_usb0,
  3276. &meson8b_usb1,
  3277. &meson8b_reset,
  3278. &meson8b_nand,
  3279. &meson8b_dos_parser,
  3280. &meson8b_usb,
  3281. &meson8b_vdin1,
  3282. &meson8b_ahb_arb0,
  3283. &meson8b_efuse,
  3284. &meson8b_boot_rom,
  3285. &meson8b_ahb_data_bus,
  3286. &meson8b_ahb_ctrl_bus,
  3287. &meson8b_hdmi_intr_sync,
  3288. &meson8b_hdmi_pclk,
  3289. &meson8b_usb1_ddr_bridge,
  3290. &meson8b_usb0_ddr_bridge,
  3291. &meson8b_mmc_pclk,
  3292. &meson8b_dvin,
  3293. &meson8b_uart2,
  3294. &meson8b_sana,
  3295. &meson8b_vpu_intr,
  3296. &meson8b_sec_ahb_ahb3_bridge,
  3297. &meson8b_clk81_a9,
  3298. &meson8b_vclk2_venci0,
  3299. &meson8b_vclk2_venci1,
  3300. &meson8b_vclk2_vencp0,
  3301. &meson8b_vclk2_vencp1,
  3302. &meson8b_gclk_venci_int,
  3303. &meson8b_gclk_vencp_int,
  3304. &meson8b_dac_clk,
  3305. &meson8b_aoclk_gate,
  3306. &meson8b_iec958_gate,
  3307. &meson8b_enc480p,
  3308. &meson8b_rng1,
  3309. &meson8b_gclk_vencl_int,
  3310. &meson8b_vclk2_venclmcc,
  3311. &meson8b_vclk2_vencl,
  3312. &meson8b_vclk2_other,
  3313. &meson8b_edp,
  3314. &meson8b_ao_media_cpu,
  3315. &meson8b_ao_ahb_sram,
  3316. &meson8b_ao_ahb_bus,
  3317. &meson8b_ao_iface,
  3318. &meson8b_mpeg_clk_div,
  3319. &meson8b_mpeg_clk_sel,
  3320. &meson8b_mpll0,
  3321. &meson8b_mpll1,
  3322. &meson8b_mpll2,
  3323. &meson8b_mpll0_div,
  3324. &meson8b_mpll1_div,
  3325. &meson8b_mpll2_div,
  3326. &meson8b_fixed_pll,
  3327. &meson8b_sys_pll,
  3328. &meson8b_cpu_in_sel,
  3329. &meson8b_cpu_scale_div,
  3330. &meson8b_cpu_scale_out_sel,
  3331. &meson8b_cpu_clk,
  3332. &meson8b_mpll_prediv,
  3333. &meson8b_fclk_div2,
  3334. &meson8b_fclk_div3,
  3335. &meson8b_fclk_div4,
  3336. &meson8b_fclk_div5,
  3337. &meson8b_fclk_div7,
  3338. &meson8b_nand_clk_sel,
  3339. &meson8b_nand_clk_div,
  3340. &meson8b_nand_clk_gate,
  3341. &meson8b_fixed_pll_dco,
  3342. &meson8b_hdmi_pll_dco,
  3343. &meson8b_sys_pll_dco,
  3344. &meson8b_apb_clk_sel,
  3345. &meson8b_apb_clk_gate,
  3346. &meson8b_periph_clk_sel,
  3347. &meson8b_periph_clk_gate,
  3348. &meson8b_axi_clk_sel,
  3349. &meson8b_axi_clk_gate,
  3350. &meson8b_l2_dram_clk_sel,
  3351. &meson8b_l2_dram_clk_gate,
  3352. &meson8b_hdmi_pll_lvds_out,
  3353. &meson8b_hdmi_pll_hdmi_out,
  3354. &meson8b_vid_pll_in_sel,
  3355. &meson8b_vid_pll_in_en,
  3356. &meson8b_vid_pll_pre_div,
  3357. &meson8b_vid_pll_post_div,
  3358. &meson8b_vid_pll,
  3359. &meson8b_vid_pll_final_div,
  3360. &meson8b_vclk_in_sel,
  3361. &meson8b_vclk_in_en,
  3362. &meson8b_vclk_en,
  3363. &meson8b_vclk_div1_gate,
  3364. &meson8b_vclk_div2_div_gate,
  3365. &meson8b_vclk_div4_div_gate,
  3366. &meson8b_vclk_div6_div_gate,
  3367. &meson8b_vclk_div12_div_gate,
  3368. &meson8b_vclk2_in_sel,
  3369. &meson8b_vclk2_clk_in_en,
  3370. &meson8b_vclk2_clk_en,
  3371. &meson8b_vclk2_div1_gate,
  3372. &meson8b_vclk2_div2_div_gate,
  3373. &meson8b_vclk2_div4_div_gate,
  3374. &meson8b_vclk2_div6_div_gate,
  3375. &meson8b_vclk2_div12_div_gate,
  3376. &meson8b_cts_enct_sel,
  3377. &meson8b_cts_enct,
  3378. &meson8b_cts_encp_sel,
  3379. &meson8b_cts_encp,
  3380. &meson8b_cts_enci_sel,
  3381. &meson8b_cts_enci,
  3382. &meson8b_hdmi_tx_pixel_sel,
  3383. &meson8b_hdmi_tx_pixel,
  3384. &meson8b_cts_encl_sel,
  3385. &meson8b_cts_encl,
  3386. &meson8b_cts_vdac0_sel,
  3387. &meson8b_cts_vdac0,
  3388. &meson8b_hdmi_sys_sel,
  3389. &meson8b_hdmi_sys_div,
  3390. &meson8b_hdmi_sys,
  3391. &meson8b_mali_0_sel,
  3392. &meson8b_mali_0_div,
  3393. &meson8b_mali_0,
  3394. &meson8b_mali_1_sel,
  3395. &meson8b_mali_1_div,
  3396. &meson8b_mali_1,
  3397. &meson8b_mali,
  3398. &meson8m2_gp_pll_dco,
  3399. &meson8m2_gp_pll,
  3400. &meson8b_vpu_0_sel,
  3401. &meson8m2_vpu_0_sel,
  3402. &meson8b_vpu_0_div,
  3403. &meson8b_vpu_0,
  3404. &meson8b_vpu_1_sel,
  3405. &meson8m2_vpu_1_sel,
  3406. &meson8b_vpu_1_div,
  3407. &meson8b_vpu_1,
  3408. &meson8b_vpu,
  3409. &meson8b_vdec_1_sel,
  3410. &meson8b_vdec_1_1_div,
  3411. &meson8b_vdec_1_1,
  3412. &meson8b_vdec_1_2_div,
  3413. &meson8b_vdec_1_2,
  3414. &meson8b_vdec_1,
  3415. &meson8b_vdec_hcodec_sel,
  3416. &meson8b_vdec_hcodec_div,
  3417. &meson8b_vdec_hcodec,
  3418. &meson8b_vdec_2_sel,
  3419. &meson8b_vdec_2_div,
  3420. &meson8b_vdec_2,
  3421. &meson8b_vdec_hevc_sel,
  3422. &meson8b_vdec_hevc_div,
  3423. &meson8b_vdec_hevc_en,
  3424. &meson8b_vdec_hevc,
  3425. &meson8b_cts_amclk,
  3426. &meson8b_cts_amclk_sel,
  3427. &meson8b_cts_amclk_div,
  3428. &meson8b_cts_mclk_i958_sel,
  3429. &meson8b_cts_mclk_i958_div,
  3430. &meson8b_cts_mclk_i958,
  3431. &meson8b_cts_i958,
  3432. &meson8b_vid_pll_lvds_en,
  3433. };
  3434. static const struct meson8b_clk_reset_line {
  3435. u32 reg;
  3436. u8 bit_idx;
  3437. bool active_low;
  3438. } meson8b_clk_reset_bits[] = {
  3439. [CLKC_RESET_L2_CACHE_SOFT_RESET] = {
  3440. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3441. .bit_idx = 30,
  3442. .active_low = false,
  3443. },
  3444. [CLKC_RESET_AXI_64_TO_128_BRIDGE_A5_SOFT_RESET] = {
  3445. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3446. .bit_idx = 29,
  3447. .active_low = false,
  3448. },
  3449. [CLKC_RESET_SCU_SOFT_RESET] = {
  3450. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3451. .bit_idx = 28,
  3452. .active_low = false,
  3453. },
  3454. [CLKC_RESET_CPU3_SOFT_RESET] = {
  3455. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3456. .bit_idx = 27,
  3457. .active_low = false,
  3458. },
  3459. [CLKC_RESET_CPU2_SOFT_RESET] = {
  3460. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3461. .bit_idx = 26,
  3462. .active_low = false,
  3463. },
  3464. [CLKC_RESET_CPU1_SOFT_RESET] = {
  3465. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3466. .bit_idx = 25,
  3467. .active_low = false,
  3468. },
  3469. [CLKC_RESET_CPU0_SOFT_RESET] = {
  3470. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3471. .bit_idx = 24,
  3472. .active_low = false,
  3473. },
  3474. [CLKC_RESET_A5_GLOBAL_RESET] = {
  3475. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3476. .bit_idx = 18,
  3477. .active_low = false,
  3478. },
  3479. [CLKC_RESET_A5_AXI_SOFT_RESET] = {
  3480. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3481. .bit_idx = 17,
  3482. .active_low = false,
  3483. },
  3484. [CLKC_RESET_A5_ABP_SOFT_RESET] = {
  3485. .reg = HHI_SYS_CPU_CLK_CNTL0,
  3486. .bit_idx = 16,
  3487. .active_low = false,
  3488. },
  3489. [CLKC_RESET_AXI_64_TO_128_BRIDGE_MMC_SOFT_RESET] = {
  3490. .reg = HHI_SYS_CPU_CLK_CNTL1,
  3491. .bit_idx = 30,
  3492. .active_low = false,
  3493. },
  3494. [CLKC_RESET_VID_CLK_CNTL_SOFT_RESET] = {
  3495. .reg = HHI_VID_CLK_CNTL,
  3496. .bit_idx = 15,
  3497. .active_low = false,
  3498. },
  3499. [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_POST] = {
  3500. .reg = HHI_VID_DIVIDER_CNTL,
  3501. .bit_idx = 7,
  3502. .active_low = false,
  3503. },
  3504. [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_PRE] = {
  3505. .reg = HHI_VID_DIVIDER_CNTL,
  3506. .bit_idx = 3,
  3507. .active_low = false,
  3508. },
  3509. [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_POST] = {
  3510. .reg = HHI_VID_DIVIDER_CNTL,
  3511. .bit_idx = 1,
  3512. .active_low = true,
  3513. },
  3514. [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_PRE] = {
  3515. .reg = HHI_VID_DIVIDER_CNTL,
  3516. .bit_idx = 0,
  3517. .active_low = true,
  3518. },
  3519. };
  3520. static int meson8b_clk_reset_update(struct reset_controller_dev *rcdev,
  3521. unsigned long id, bool assert)
  3522. {
  3523. struct meson8b_clk_reset *meson8b_clk_reset =
  3524. container_of(rcdev, struct meson8b_clk_reset, reset);
  3525. const struct meson8b_clk_reset_line *reset;
  3526. unsigned int value = 0;
  3527. unsigned long flags;
  3528. if (id >= ARRAY_SIZE(meson8b_clk_reset_bits))
  3529. return -EINVAL;
  3530. reset = &meson8b_clk_reset_bits[id];
  3531. if (assert != reset->active_low)
  3532. value = BIT(reset->bit_idx);
  3533. spin_lock_irqsave(&meson_clk_lock, flags);
  3534. regmap_update_bits(meson8b_clk_reset->regmap, reset->reg,
  3535. BIT(reset->bit_idx), value);
  3536. spin_unlock_irqrestore(&meson_clk_lock, flags);
  3537. return 0;
  3538. }
  3539. static int meson8b_clk_reset_assert(struct reset_controller_dev *rcdev,
  3540. unsigned long id)
  3541. {
  3542. return meson8b_clk_reset_update(rcdev, id, true);
  3543. }
  3544. static int meson8b_clk_reset_deassert(struct reset_controller_dev *rcdev,
  3545. unsigned long id)
  3546. {
  3547. return meson8b_clk_reset_update(rcdev, id, false);
  3548. }
  3549. static const struct reset_control_ops meson8b_clk_reset_ops = {
  3550. .assert = meson8b_clk_reset_assert,
  3551. .deassert = meson8b_clk_reset_deassert,
  3552. };
  3553. struct meson8b_nb_data {
  3554. struct notifier_block nb;
  3555. struct clk_hw *cpu_clk;
  3556. };
  3557. static int meson8b_cpu_clk_notifier_cb(struct notifier_block *nb,
  3558. unsigned long event, void *data)
  3559. {
  3560. struct meson8b_nb_data *nb_data =
  3561. container_of(nb, struct meson8b_nb_data, nb);
  3562. struct clk_hw *parent_clk;
  3563. int ret;
  3564. switch (event) {
  3565. case PRE_RATE_CHANGE:
  3566. /* xtal */
  3567. parent_clk = clk_hw_get_parent_by_index(nb_data->cpu_clk, 0);
  3568. break;
  3569. case POST_RATE_CHANGE:
  3570. /* cpu_scale_out_sel */
  3571. parent_clk = clk_hw_get_parent_by_index(nb_data->cpu_clk, 1);
  3572. break;
  3573. default:
  3574. return NOTIFY_DONE;
  3575. }
  3576. ret = clk_hw_set_parent(nb_data->cpu_clk, parent_clk);
  3577. if (ret)
  3578. return notifier_from_errno(ret);
  3579. udelay(100);
  3580. return NOTIFY_OK;
  3581. }
  3582. static struct meson8b_nb_data meson8b_cpu_nb_data = {
  3583. .nb.notifier_call = meson8b_cpu_clk_notifier_cb,
  3584. };
  3585. static struct meson_clk_hw_data meson8_clks = {
  3586. .hws = meson8_hw_clks,
  3587. .num = ARRAY_SIZE(meson8_hw_clks),
  3588. };
  3589. static struct meson_clk_hw_data meson8b_clks = {
  3590. .hws = meson8b_hw_clks,
  3591. .num = ARRAY_SIZE(meson8b_hw_clks),
  3592. };
  3593. static struct meson_clk_hw_data meson8m2_clks = {
  3594. .hws = meson8m2_hw_clks,
  3595. .num = ARRAY_SIZE(meson8m2_hw_clks),
  3596. };
  3597. static void __init meson8b_clkc_init_common(struct device_node *np,
  3598. struct meson_clk_hw_data *hw_clks)
  3599. {
  3600. struct meson8b_clk_reset *rstc;
  3601. struct device_node *parent_np;
  3602. const char *notifier_clk_name;
  3603. struct clk *notifier_clk;
  3604. struct regmap *map;
  3605. int i, ret;
  3606. parent_np = of_get_parent(np);
  3607. map = syscon_node_to_regmap(parent_np);
  3608. of_node_put(parent_np);
  3609. if (IS_ERR(map)) {
  3610. pr_err("failed to get HHI regmap - Trying obsolete regs\n");
  3611. return;
  3612. }
  3613. rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
  3614. if (!rstc)
  3615. return;
  3616. /* Reset Controller */
  3617. rstc->regmap = map;
  3618. rstc->reset.ops = &meson8b_clk_reset_ops;
  3619. rstc->reset.nr_resets = ARRAY_SIZE(meson8b_clk_reset_bits);
  3620. rstc->reset.of_node = np;
  3621. ret = reset_controller_register(&rstc->reset);
  3622. if (ret) {
  3623. pr_err("%s: Failed to register clkc reset controller: %d\n",
  3624. __func__, ret);
  3625. return;
  3626. }
  3627. /* Populate regmap for the regmap backed clocks */
  3628. for (i = 0; i < ARRAY_SIZE(meson8b_clk_regmaps); i++)
  3629. meson8b_clk_regmaps[i]->map = map;
  3630. /*
  3631. * register all clks and start with the first used ID (which is
  3632. * CLKID_PLL_FIXED)
  3633. */
  3634. for (i = CLKID_PLL_FIXED; i < hw_clks->num; i++) {
  3635. /* array might be sparse */
  3636. if (!hw_clks->hws[i])
  3637. continue;
  3638. ret = of_clk_hw_register(np, hw_clks->hws[i]);
  3639. if (ret)
  3640. return;
  3641. }
  3642. meson8b_cpu_nb_data.cpu_clk = hw_clks->hws[CLKID_CPUCLK];
  3643. /*
  3644. * FIXME we shouldn't program the muxes in notifier handlers. The
  3645. * tricky programming sequence will be handled by the forthcoming
  3646. * coordinated clock rates mechanism once that feature is released.
  3647. */
  3648. notifier_clk_name = clk_hw_get_name(&meson8b_cpu_scale_out_sel.hw);
  3649. notifier_clk = __clk_lookup(notifier_clk_name);
  3650. ret = clk_notifier_register(notifier_clk, &meson8b_cpu_nb_data.nb);
  3651. if (ret) {
  3652. pr_err("%s: failed to register the CPU clock notifier\n",
  3653. __func__);
  3654. return;
  3655. }
  3656. ret = of_clk_add_hw_provider(np, meson_clk_hw_get, hw_clks);
  3657. if (ret)
  3658. pr_err("%s: failed to register clock provider\n", __func__);
  3659. }
  3660. static void __init meson8_clkc_init(struct device_node *np)
  3661. {
  3662. return meson8b_clkc_init_common(np, &meson8_clks);
  3663. }
  3664. static void __init meson8b_clkc_init(struct device_node *np)
  3665. {
  3666. return meson8b_clkc_init_common(np, &meson8b_clks);
  3667. }
  3668. static void __init meson8m2_clkc_init(struct device_node *np)
  3669. {
  3670. return meson8b_clkc_init_common(np, &meson8m2_clks);
  3671. }
  3672. CLK_OF_DECLARE_DRIVER(meson8_clkc, "amlogic,meson8-clkc",
  3673. meson8_clkc_init);
  3674. CLK_OF_DECLARE_DRIVER(meson8b_clkc, "amlogic,meson8b-clkc",
  3675. meson8b_clkc_init);
  3676. CLK_OF_DECLARE_DRIVER(meson8m2_clkc, "amlogic,meson8m2-clkc",
  3677. meson8m2_clkc_init);