meson8b.c 109 KB

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