s4-peripherals.c 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817
  1. // SPDX-License-Identifier: (GPL-2.0-only OR MIT)
  2. /*
  3. * Amlogic S4 Peripherals Clock Controller Driver
  4. *
  5. * Copyright (c) 2022-2023 Amlogic, inc. All rights reserved
  6. * Author: Yu Tu <yu.tu@amlogic.com>
  7. */
  8. #include <linux/clk-provider.h>
  9. #include <linux/of_device.h>
  10. #include <linux/platform_device.h>
  11. #include "clk-regmap.h"
  12. #include "vid-pll-div.h"
  13. #include "clk-dualdiv.h"
  14. #include "s4-peripherals.h"
  15. #include "meson-clkc-utils.h"
  16. #include <dt-bindings/clock/amlogic,s4-peripherals-clkc.h>
  17. static struct clk_regmap s4_rtc_32k_by_oscin_clkin = {
  18. .data = &(struct clk_regmap_gate_data){
  19. .offset = CLKCTRL_RTC_BY_OSCIN_CTRL0,
  20. .bit_idx = 31,
  21. },
  22. .hw.init = &(struct clk_init_data) {
  23. .name = "rtc_32k_by_oscin_clkin",
  24. .ops = &clk_regmap_gate_ops,
  25. .parent_data = (const struct clk_parent_data []) {
  26. { .fw_name = "xtal", }
  27. },
  28. .num_parents = 1,
  29. },
  30. };
  31. static const struct meson_clk_dualdiv_param s4_32k_div_table[] = {
  32. {
  33. .dual = 1,
  34. .n1 = 733,
  35. .m1 = 8,
  36. .n2 = 732,
  37. .m2 = 11,
  38. },
  39. {}
  40. };
  41. static struct clk_regmap s4_rtc_32k_by_oscin_div = {
  42. .data = &(struct meson_clk_dualdiv_data){
  43. .n1 = {
  44. .reg_off = CLKCTRL_RTC_BY_OSCIN_CTRL0,
  45. .shift = 0,
  46. .width = 12,
  47. },
  48. .n2 = {
  49. .reg_off = CLKCTRL_RTC_BY_OSCIN_CTRL0,
  50. .shift = 12,
  51. .width = 12,
  52. },
  53. .m1 = {
  54. .reg_off = CLKCTRL_RTC_BY_OSCIN_CTRL1,
  55. .shift = 0,
  56. .width = 12,
  57. },
  58. .m2 = {
  59. .reg_off = CLKCTRL_RTC_BY_OSCIN_CTRL1,
  60. .shift = 12,
  61. .width = 12,
  62. },
  63. .dual = {
  64. .reg_off = CLKCTRL_RTC_BY_OSCIN_CTRL0,
  65. .shift = 28,
  66. .width = 1,
  67. },
  68. .table = s4_32k_div_table,
  69. },
  70. .hw.init = &(struct clk_init_data){
  71. .name = "rtc_32k_by_oscin_div",
  72. .ops = &meson_clk_dualdiv_ops,
  73. .parent_hws = (const struct clk_hw *[]) {
  74. &s4_rtc_32k_by_oscin_clkin.hw
  75. },
  76. .num_parents = 1,
  77. },
  78. };
  79. static struct clk_regmap s4_rtc_32k_by_oscin_sel = {
  80. .data = &(struct clk_regmap_mux_data) {
  81. .offset = CLKCTRL_RTC_BY_OSCIN_CTRL1,
  82. .mask = 0x1,
  83. .shift = 24,
  84. .flags = CLK_MUX_ROUND_CLOSEST,
  85. },
  86. .hw.init = &(struct clk_init_data){
  87. .name = "rtc_32k_by_oscin_sel",
  88. .ops = &clk_regmap_mux_ops,
  89. .parent_hws = (const struct clk_hw *[]) {
  90. &s4_rtc_32k_by_oscin_div.hw,
  91. &s4_rtc_32k_by_oscin_clkin.hw,
  92. },
  93. .num_parents = 2,
  94. .flags = CLK_SET_RATE_PARENT,
  95. },
  96. };
  97. static struct clk_regmap s4_rtc_32k_by_oscin = {
  98. .data = &(struct clk_regmap_gate_data){
  99. .offset = CLKCTRL_RTC_BY_OSCIN_CTRL0,
  100. .bit_idx = 30,
  101. },
  102. .hw.init = &(struct clk_init_data) {
  103. .name = "rtc_32k_by_oscin",
  104. .ops = &clk_regmap_gate_ops,
  105. .parent_hws = (const struct clk_hw *[]) {
  106. &s4_rtc_32k_by_oscin_sel.hw
  107. },
  108. .num_parents = 1,
  109. .flags = CLK_SET_RATE_PARENT,
  110. },
  111. };
  112. static struct clk_regmap s4_rtc_clk = {
  113. .data = &(struct clk_regmap_mux_data) {
  114. .offset = CLKCTRL_RTC_CTRL,
  115. .mask = 0x3,
  116. .shift = 0,
  117. .flags = CLK_MUX_ROUND_CLOSEST,
  118. },
  119. .hw.init = &(struct clk_init_data){
  120. .name = "rtc_clk_sel",
  121. .ops = &clk_regmap_mux_ops,
  122. .parent_hws = (const struct clk_hw *[]) {
  123. &s4_rtc_32k_by_oscin.hw,
  124. &s4_rtc_32k_by_oscin_div.hw,
  125. },
  126. .num_parents = 2,
  127. .flags = CLK_SET_RATE_PARENT,
  128. },
  129. };
  130. /* The index 5 is AXI_CLK, which is dedicated to AXI. So skip it. */
  131. static u32 mux_table_sys_ab_clk_sel[] = { 0, 1, 2, 3, 4, 6, 7 };
  132. static const struct clk_parent_data sys_ab_clk_parent_data[] = {
  133. { .fw_name = "xtal" },
  134. { .fw_name = "fclk_div2" },
  135. { .fw_name = "fclk_div3" },
  136. { .fw_name = "fclk_div4" },
  137. { .fw_name = "fclk_div5" },
  138. { .fw_name = "fclk_div7" },
  139. { .hw = &s4_rtc_clk.hw }
  140. };
  141. /*
  142. * This clock is initialized by ROMcode.
  143. * The chip was changed SYS CLK for security reasons. SYS CLK registers are not writable
  144. * in the kernel phase. Write of SYS related register will cause the system to crash.
  145. * Meanwhile, these clock won't ever change at runtime.
  146. * For the above reasons, we can only use ro_ops for SYS related clocks.
  147. */
  148. static struct clk_regmap s4_sysclk_b_sel = {
  149. .data = &(struct clk_regmap_mux_data){
  150. .offset = CLKCTRL_SYS_CLK_CTRL0,
  151. .mask = 0x7,
  152. .shift = 26,
  153. .table = mux_table_sys_ab_clk_sel,
  154. },
  155. .hw.init = &(struct clk_init_data){
  156. .name = "sysclk_b_sel",
  157. .ops = &clk_regmap_mux_ro_ops,
  158. .parent_data = sys_ab_clk_parent_data,
  159. .num_parents = ARRAY_SIZE(sys_ab_clk_parent_data),
  160. },
  161. };
  162. static struct clk_regmap s4_sysclk_b_div = {
  163. .data = &(struct clk_regmap_div_data){
  164. .offset = CLKCTRL_SYS_CLK_CTRL0,
  165. .shift = 16,
  166. .width = 10,
  167. },
  168. .hw.init = &(struct clk_init_data){
  169. .name = "sysclk_b_div",
  170. .ops = &clk_regmap_divider_ro_ops,
  171. .parent_hws = (const struct clk_hw *[]) {
  172. &s4_sysclk_b_sel.hw
  173. },
  174. .num_parents = 1,
  175. },
  176. };
  177. static struct clk_regmap s4_sysclk_b = {
  178. .data = &(struct clk_regmap_gate_data){
  179. .offset = CLKCTRL_SYS_CLK_CTRL0,
  180. .bit_idx = 29,
  181. },
  182. .hw.init = &(struct clk_init_data) {
  183. .name = "sysclk_b",
  184. .ops = &clk_regmap_gate_ro_ops,
  185. .parent_hws = (const struct clk_hw *[]) {
  186. &s4_sysclk_b_div.hw
  187. },
  188. .num_parents = 1,
  189. },
  190. };
  191. static struct clk_regmap s4_sysclk_a_sel = {
  192. .data = &(struct clk_regmap_mux_data){
  193. .offset = CLKCTRL_SYS_CLK_CTRL0,
  194. .mask = 0x7,
  195. .shift = 10,
  196. .table = mux_table_sys_ab_clk_sel,
  197. },
  198. .hw.init = &(struct clk_init_data){
  199. .name = "sysclk_a_sel",
  200. .ops = &clk_regmap_mux_ro_ops,
  201. .parent_data = sys_ab_clk_parent_data,
  202. .num_parents = ARRAY_SIZE(sys_ab_clk_parent_data),
  203. },
  204. };
  205. static struct clk_regmap s4_sysclk_a_div = {
  206. .data = &(struct clk_regmap_div_data){
  207. .offset = CLKCTRL_SYS_CLK_CTRL0,
  208. .shift = 0,
  209. .width = 10,
  210. },
  211. .hw.init = &(struct clk_init_data){
  212. .name = "sysclk_a_div",
  213. .ops = &clk_regmap_divider_ro_ops,
  214. .parent_hws = (const struct clk_hw *[]) {
  215. &s4_sysclk_a_sel.hw
  216. },
  217. .num_parents = 1,
  218. },
  219. };
  220. static struct clk_regmap s4_sysclk_a = {
  221. .data = &(struct clk_regmap_gate_data){
  222. .offset = CLKCTRL_SYS_CLK_CTRL0,
  223. .bit_idx = 13,
  224. },
  225. .hw.init = &(struct clk_init_data) {
  226. .name = "sysclk_a",
  227. .ops = &clk_regmap_gate_ro_ops,
  228. .parent_hws = (const struct clk_hw *[]) {
  229. &s4_sysclk_a_div.hw
  230. },
  231. .num_parents = 1,
  232. },
  233. };
  234. static struct clk_regmap s4_sys_clk = {
  235. .data = &(struct clk_regmap_mux_data){
  236. .offset = CLKCTRL_SYS_CLK_CTRL0,
  237. .mask = 0x1,
  238. .shift = 31,
  239. },
  240. .hw.init = &(struct clk_init_data){
  241. .name = "sys_clk",
  242. .ops = &clk_regmap_mux_ro_ops,
  243. .parent_hws = (const struct clk_hw *[]) {
  244. &s4_sysclk_a.hw,
  245. &s4_sysclk_b.hw
  246. },
  247. .num_parents = 2,
  248. },
  249. };
  250. static struct clk_regmap s4_ceca_32k_clkin = {
  251. .data = &(struct clk_regmap_gate_data){
  252. .offset = CLKCTRL_CECA_CTRL0,
  253. .bit_idx = 31,
  254. },
  255. .hw.init = &(struct clk_init_data) {
  256. .name = "ceca_32k_clkin",
  257. .ops = &clk_regmap_gate_ops,
  258. .parent_data = (const struct clk_parent_data []) {
  259. { .fw_name = "xtal", }
  260. },
  261. .num_parents = 1,
  262. },
  263. };
  264. static struct clk_regmap s4_ceca_32k_div = {
  265. .data = &(struct meson_clk_dualdiv_data){
  266. .n1 = {
  267. .reg_off = CLKCTRL_CECA_CTRL0,
  268. .shift = 0,
  269. .width = 12,
  270. },
  271. .n2 = {
  272. .reg_off = CLKCTRL_CECA_CTRL0,
  273. .shift = 12,
  274. .width = 12,
  275. },
  276. .m1 = {
  277. .reg_off = CLKCTRL_CECA_CTRL1,
  278. .shift = 0,
  279. .width = 12,
  280. },
  281. .m2 = {
  282. .reg_off = CLKCTRL_CECA_CTRL1,
  283. .shift = 12,
  284. .width = 12,
  285. },
  286. .dual = {
  287. .reg_off = CLKCTRL_CECA_CTRL0,
  288. .shift = 28,
  289. .width = 1,
  290. },
  291. .table = s4_32k_div_table,
  292. },
  293. .hw.init = &(struct clk_init_data){
  294. .name = "ceca_32k_div",
  295. .ops = &meson_clk_dualdiv_ops,
  296. .parent_hws = (const struct clk_hw *[]) {
  297. &s4_ceca_32k_clkin.hw
  298. },
  299. .num_parents = 1,
  300. },
  301. };
  302. static struct clk_regmap s4_ceca_32k_sel_pre = {
  303. .data = &(struct clk_regmap_mux_data) {
  304. .offset = CLKCTRL_CECA_CTRL1,
  305. .mask = 0x1,
  306. .shift = 24,
  307. .flags = CLK_MUX_ROUND_CLOSEST,
  308. },
  309. .hw.init = &(struct clk_init_data){
  310. .name = "ceca_32k_sel_pre",
  311. .ops = &clk_regmap_mux_ops,
  312. .parent_hws = (const struct clk_hw *[]) {
  313. &s4_ceca_32k_div.hw,
  314. &s4_ceca_32k_clkin.hw
  315. },
  316. .num_parents = 2,
  317. .flags = CLK_SET_RATE_PARENT,
  318. },
  319. };
  320. static struct clk_regmap s4_ceca_32k_sel = {
  321. .data = &(struct clk_regmap_mux_data) {
  322. .offset = CLKCTRL_CECA_CTRL1,
  323. .mask = 0x1,
  324. .shift = 31,
  325. .flags = CLK_MUX_ROUND_CLOSEST,
  326. },
  327. .hw.init = &(struct clk_init_data){
  328. .name = "ceca_32k_sel",
  329. .ops = &clk_regmap_mux_ops,
  330. .parent_hws = (const struct clk_hw *[]) {
  331. &s4_ceca_32k_sel_pre.hw,
  332. &s4_rtc_clk.hw
  333. },
  334. .num_parents = 2,
  335. },
  336. };
  337. static struct clk_regmap s4_ceca_32k_clkout = {
  338. .data = &(struct clk_regmap_gate_data){
  339. .offset = CLKCTRL_CECA_CTRL0,
  340. .bit_idx = 30,
  341. },
  342. .hw.init = &(struct clk_init_data){
  343. .name = "ceca_32k_clkout",
  344. .ops = &clk_regmap_gate_ops,
  345. .parent_hws = (const struct clk_hw *[]) {
  346. &s4_ceca_32k_sel.hw
  347. },
  348. .num_parents = 1,
  349. .flags = CLK_SET_RATE_PARENT,
  350. },
  351. };
  352. static struct clk_regmap s4_cecb_32k_clkin = {
  353. .data = &(struct clk_regmap_gate_data){
  354. .offset = CLKCTRL_CECB_CTRL0,
  355. .bit_idx = 31,
  356. },
  357. .hw.init = &(struct clk_init_data) {
  358. .name = "cecb_32k_clkin",
  359. .ops = &clk_regmap_gate_ops,
  360. .parent_data = (const struct clk_parent_data []) {
  361. { .fw_name = "xtal", }
  362. },
  363. .num_parents = 1,
  364. },
  365. };
  366. static struct clk_regmap s4_cecb_32k_div = {
  367. .data = &(struct meson_clk_dualdiv_data){
  368. .n1 = {
  369. .reg_off = CLKCTRL_CECB_CTRL0,
  370. .shift = 0,
  371. .width = 12,
  372. },
  373. .n2 = {
  374. .reg_off = CLKCTRL_CECB_CTRL0,
  375. .shift = 12,
  376. .width = 12,
  377. },
  378. .m1 = {
  379. .reg_off = CLKCTRL_CECB_CTRL1,
  380. .shift = 0,
  381. .width = 12,
  382. },
  383. .m2 = {
  384. .reg_off = CLKCTRL_CECB_CTRL1,
  385. .shift = 12,
  386. .width = 12,
  387. },
  388. .dual = {
  389. .reg_off = CLKCTRL_CECB_CTRL0,
  390. .shift = 28,
  391. .width = 1,
  392. },
  393. .table = s4_32k_div_table,
  394. },
  395. .hw.init = &(struct clk_init_data){
  396. .name = "cecb_32k_div",
  397. .ops = &meson_clk_dualdiv_ops,
  398. .parent_hws = (const struct clk_hw *[]) {
  399. &s4_cecb_32k_clkin.hw
  400. },
  401. .num_parents = 1,
  402. },
  403. };
  404. static struct clk_regmap s4_cecb_32k_sel_pre = {
  405. .data = &(struct clk_regmap_mux_data) {
  406. .offset = CLKCTRL_CECB_CTRL1,
  407. .mask = 0x1,
  408. .shift = 24,
  409. .flags = CLK_MUX_ROUND_CLOSEST,
  410. },
  411. .hw.init = &(struct clk_init_data){
  412. .name = "cecb_32k_sel_pre",
  413. .ops = &clk_regmap_mux_ops,
  414. .parent_hws = (const struct clk_hw *[]) {
  415. &s4_cecb_32k_div.hw,
  416. &s4_cecb_32k_clkin.hw
  417. },
  418. .num_parents = 2,
  419. .flags = CLK_SET_RATE_PARENT,
  420. },
  421. };
  422. static struct clk_regmap s4_cecb_32k_sel = {
  423. .data = &(struct clk_regmap_mux_data) {
  424. .offset = CLKCTRL_CECB_CTRL1,
  425. .mask = 0x1,
  426. .shift = 31,
  427. .flags = CLK_MUX_ROUND_CLOSEST,
  428. },
  429. .hw.init = &(struct clk_init_data){
  430. .name = "cecb_32k_sel",
  431. .ops = &clk_regmap_mux_ops,
  432. .parent_hws = (const struct clk_hw *[]) {
  433. &s4_cecb_32k_sel_pre.hw,
  434. &s4_rtc_clk.hw
  435. },
  436. .num_parents = 2,
  437. },
  438. };
  439. static struct clk_regmap s4_cecb_32k_clkout = {
  440. .data = &(struct clk_regmap_gate_data){
  441. .offset = CLKCTRL_CECB_CTRL0,
  442. .bit_idx = 30,
  443. },
  444. .hw.init = &(struct clk_init_data){
  445. .name = "cecb_32k_clkout",
  446. .ops = &clk_regmap_gate_ops,
  447. .parent_hws = (const struct clk_hw *[]) {
  448. &s4_cecb_32k_sel.hw
  449. },
  450. .num_parents = 1,
  451. .flags = CLK_SET_RATE_PARENT,
  452. },
  453. };
  454. static const struct clk_parent_data s4_sc_parent_data[] = {
  455. { .fw_name = "fclk_div4" },
  456. { .fw_name = "fclk_div3" },
  457. { .fw_name = "fclk_div5" },
  458. { .fw_name = "xtal", }
  459. };
  460. static struct clk_regmap s4_sc_clk_mux = {
  461. .data = &(struct clk_regmap_mux_data){
  462. .offset = CLKCTRL_SC_CLK_CTRL,
  463. .mask = 0x3,
  464. .shift = 9,
  465. },
  466. .hw.init = &(struct clk_init_data) {
  467. .name = "sc_clk_mux",
  468. .ops = &clk_regmap_mux_ops,
  469. .parent_data = s4_sc_parent_data,
  470. .num_parents = ARRAY_SIZE(s4_sc_parent_data),
  471. .flags = CLK_SET_RATE_PARENT,
  472. },
  473. };
  474. static struct clk_regmap s4_sc_clk_div = {
  475. .data = &(struct clk_regmap_div_data){
  476. .offset = CLKCTRL_SC_CLK_CTRL,
  477. .shift = 0,
  478. .width = 8,
  479. },
  480. .hw.init = &(struct clk_init_data) {
  481. .name = "sc_clk_div",
  482. .ops = &clk_regmap_divider_ops,
  483. .parent_hws = (const struct clk_hw *[]) {
  484. &s4_sc_clk_mux.hw
  485. },
  486. .num_parents = 1,
  487. .flags = CLK_SET_RATE_PARENT,
  488. },
  489. };
  490. static struct clk_regmap s4_sc_clk_gate = {
  491. .data = &(struct clk_regmap_gate_data){
  492. .offset = CLKCTRL_SC_CLK_CTRL,
  493. .bit_idx = 8,
  494. },
  495. .hw.init = &(struct clk_init_data){
  496. .name = "sc_clk_gate",
  497. .ops = &clk_regmap_gate_ops,
  498. .parent_hws = (const struct clk_hw *[]) {
  499. &s4_sc_clk_div.hw
  500. },
  501. .num_parents = 1,
  502. .flags = CLK_SET_RATE_PARENT,
  503. },
  504. };
  505. static struct clk_regmap s4_12_24M_clk_gate = {
  506. .data = &(struct clk_regmap_gate_data){
  507. .offset = CLKCTRL_CLK12_24_CTRL,
  508. .bit_idx = 11,
  509. },
  510. .hw.init = &(struct clk_init_data) {
  511. .name = "12_24m_gate",
  512. .ops = &clk_regmap_gate_ops,
  513. .parent_data = (const struct clk_parent_data []) {
  514. { .fw_name = "xtal", }
  515. },
  516. .num_parents = 1,
  517. },
  518. };
  519. static struct clk_fixed_factor s4_12M_clk_div = {
  520. .mult = 1,
  521. .div = 2,
  522. .hw.init = &(struct clk_init_data){
  523. .name = "12M",
  524. .ops = &clk_fixed_factor_ops,
  525. .parent_hws = (const struct clk_hw *[]) {
  526. &s4_12_24M_clk_gate.hw
  527. },
  528. .num_parents = 1,
  529. .flags = CLK_SET_RATE_PARENT,
  530. },
  531. };
  532. static struct clk_regmap s4_12_24M_clk = {
  533. .data = &(struct clk_regmap_mux_data){
  534. .offset = CLKCTRL_CLK12_24_CTRL,
  535. .mask = 0x1,
  536. .shift = 10,
  537. },
  538. .hw.init = &(struct clk_init_data) {
  539. .name = "12_24m",
  540. .ops = &clk_regmap_mux_ops,
  541. .parent_hws = (const struct clk_hw *[]) {
  542. &s4_12_24M_clk_gate.hw,
  543. &s4_12M_clk_div.hw,
  544. },
  545. .num_parents = 2,
  546. .flags = CLK_SET_RATE_PARENT,
  547. },
  548. };
  549. /* Video Clocks */
  550. static struct clk_regmap s4_vid_pll_div = {
  551. .data = &(struct meson_vid_pll_div_data){
  552. .val = {
  553. .reg_off = CLKCTRL_VID_PLL_CLK_DIV,
  554. .shift = 0,
  555. .width = 15,
  556. },
  557. .sel = {
  558. .reg_off = CLKCTRL_VID_PLL_CLK_DIV,
  559. .shift = 16,
  560. .width = 2,
  561. },
  562. },
  563. .hw.init = &(struct clk_init_data) {
  564. .name = "vid_pll_div",
  565. /*
  566. * TODO meson_vid_pll_div_ro_ops to meson_vid_pll_div_ops
  567. */
  568. .ops = &meson_vid_pll_div_ro_ops,
  569. .parent_data = (const struct clk_parent_data []) {
  570. { .fw_name = "hdmi_pll", }
  571. },
  572. .num_parents = 1,
  573. .flags = CLK_SET_RATE_PARENT,
  574. },
  575. };
  576. static struct clk_regmap s4_vid_pll_sel = {
  577. .data = &(struct clk_regmap_mux_data){
  578. .offset = CLKCTRL_VID_PLL_CLK_DIV,
  579. .mask = 0x1,
  580. .shift = 18,
  581. },
  582. .hw.init = &(struct clk_init_data){
  583. .name = "vid_pll_sel",
  584. .ops = &clk_regmap_mux_ops,
  585. .parent_data = (const struct clk_parent_data []) {
  586. { .hw = &s4_vid_pll_div.hw },
  587. { .fw_name = "hdmi_pll", }
  588. },
  589. .num_parents = 2,
  590. .flags = CLK_SET_RATE_PARENT,
  591. },
  592. };
  593. static struct clk_regmap s4_vid_pll = {
  594. .data = &(struct clk_regmap_gate_data){
  595. .offset = CLKCTRL_VID_PLL_CLK_DIV,
  596. .bit_idx = 19,
  597. },
  598. .hw.init = &(struct clk_init_data) {
  599. .name = "vid_pll",
  600. .ops = &clk_regmap_gate_ops,
  601. .parent_hws = (const struct clk_hw *[]) {
  602. &s4_vid_pll_sel.hw
  603. },
  604. .num_parents = 1,
  605. .flags = CLK_SET_RATE_PARENT,
  606. },
  607. };
  608. static const struct clk_parent_data s4_vclk_parent_data[] = {
  609. { .hw = &s4_vid_pll.hw },
  610. { .fw_name = "gp0_pll", },
  611. { .fw_name = "hifi_pll", },
  612. { .fw_name = "mpll1", },
  613. { .fw_name = "fclk_div3", },
  614. { .fw_name = "fclk_div4", },
  615. { .fw_name = "fclk_div5", },
  616. { .fw_name = "fclk_div7", },
  617. };
  618. static struct clk_regmap s4_vclk_sel = {
  619. .data = &(struct clk_regmap_mux_data){
  620. .offset = CLKCTRL_VID_CLK_CTRL,
  621. .mask = 0x7,
  622. .shift = 16,
  623. },
  624. .hw.init = &(struct clk_init_data){
  625. .name = "vclk_sel",
  626. .ops = &clk_regmap_mux_ops,
  627. .parent_data = s4_vclk_parent_data,
  628. .num_parents = ARRAY_SIZE(s4_vclk_parent_data),
  629. .flags = 0,
  630. },
  631. };
  632. static struct clk_regmap s4_vclk2_sel = {
  633. .data = &(struct clk_regmap_mux_data){
  634. .offset = CLKCTRL_VIID_CLK_CTRL,
  635. .mask = 0x7,
  636. .shift = 16,
  637. },
  638. .hw.init = &(struct clk_init_data){
  639. .name = "vclk2_sel",
  640. .ops = &clk_regmap_mux_ops,
  641. .parent_data = s4_vclk_parent_data,
  642. .num_parents = ARRAY_SIZE(s4_vclk_parent_data),
  643. .flags = 0,
  644. },
  645. };
  646. static struct clk_regmap s4_vclk_input = {
  647. .data = &(struct clk_regmap_gate_data){
  648. .offset = CLKCTRL_VID_CLK_DIV,
  649. .bit_idx = 16,
  650. },
  651. .hw.init = &(struct clk_init_data) {
  652. .name = "vclk_input",
  653. .ops = &clk_regmap_gate_ops,
  654. .parent_hws = (const struct clk_hw *[]) { &s4_vclk_sel.hw },
  655. .num_parents = 1,
  656. .flags = CLK_SET_RATE_PARENT,
  657. },
  658. };
  659. static struct clk_regmap s4_vclk2_input = {
  660. .data = &(struct clk_regmap_gate_data){
  661. .offset = CLKCTRL_VIID_CLK_DIV,
  662. .bit_idx = 16,
  663. },
  664. .hw.init = &(struct clk_init_data) {
  665. .name = "vclk2_input",
  666. .ops = &clk_regmap_gate_ops,
  667. .parent_hws = (const struct clk_hw *[]) { &s4_vclk2_sel.hw },
  668. .num_parents = 1,
  669. .flags = CLK_SET_RATE_PARENT,
  670. },
  671. };
  672. static struct clk_regmap s4_vclk_div = {
  673. .data = &(struct clk_regmap_div_data){
  674. .offset = CLKCTRL_VID_CLK_DIV,
  675. .shift = 0,
  676. .width = 8,
  677. },
  678. .hw.init = &(struct clk_init_data){
  679. .name = "vclk_div",
  680. .ops = &clk_regmap_divider_ops,
  681. .parent_hws = (const struct clk_hw *[]) {
  682. &s4_vclk_input.hw
  683. },
  684. .num_parents = 1,
  685. .flags = CLK_SET_RATE_PARENT,
  686. },
  687. };
  688. static struct clk_regmap s4_vclk2_div = {
  689. .data = &(struct clk_regmap_div_data){
  690. .offset = CLKCTRL_VIID_CLK_DIV,
  691. .shift = 0,
  692. .width = 8,
  693. },
  694. .hw.init = &(struct clk_init_data){
  695. .name = "vclk2_div",
  696. .ops = &clk_regmap_divider_ops,
  697. .parent_hws = (const struct clk_hw *[]) {
  698. &s4_vclk2_input.hw
  699. },
  700. .num_parents = 1,
  701. .flags = CLK_SET_RATE_PARENT,
  702. },
  703. };
  704. static struct clk_regmap s4_vclk = {
  705. .data = &(struct clk_regmap_gate_data){
  706. .offset = CLKCTRL_VID_CLK_CTRL,
  707. .bit_idx = 19,
  708. },
  709. .hw.init = &(struct clk_init_data) {
  710. .name = "vclk",
  711. .ops = &clk_regmap_gate_ops,
  712. .parent_hws = (const struct clk_hw *[]) { &s4_vclk_div.hw },
  713. .num_parents = 1,
  714. .flags = CLK_SET_RATE_PARENT,
  715. },
  716. };
  717. static struct clk_regmap s4_vclk2 = {
  718. .data = &(struct clk_regmap_gate_data){
  719. .offset = CLKCTRL_VIID_CLK_CTRL,
  720. .bit_idx = 19,
  721. },
  722. .hw.init = &(struct clk_init_data) {
  723. .name = "vclk2",
  724. .ops = &clk_regmap_gate_ops,
  725. .parent_hws = (const struct clk_hw *[]) { &s4_vclk2_div.hw },
  726. .num_parents = 1,
  727. .flags = CLK_SET_RATE_PARENT,
  728. },
  729. };
  730. static struct clk_regmap s4_vclk_div1 = {
  731. .data = &(struct clk_regmap_gate_data){
  732. .offset = CLKCTRL_VID_CLK_CTRL,
  733. .bit_idx = 0,
  734. },
  735. .hw.init = &(struct clk_init_data) {
  736. .name = "vclk_div1",
  737. .ops = &clk_regmap_gate_ops,
  738. .parent_hws = (const struct clk_hw *[]) { &s4_vclk.hw },
  739. .num_parents = 1,
  740. .flags = CLK_SET_RATE_PARENT,
  741. },
  742. };
  743. static struct clk_regmap s4_vclk_div2_en = {
  744. .data = &(struct clk_regmap_gate_data){
  745. .offset = CLKCTRL_VID_CLK_CTRL,
  746. .bit_idx = 1,
  747. },
  748. .hw.init = &(struct clk_init_data) {
  749. .name = "vclk_div2_en",
  750. .ops = &clk_regmap_gate_ops,
  751. .parent_hws = (const struct clk_hw *[]) { &s4_vclk.hw },
  752. .num_parents = 1,
  753. .flags = CLK_SET_RATE_PARENT,
  754. },
  755. };
  756. static struct clk_regmap s4_vclk_div4_en = {
  757. .data = &(struct clk_regmap_gate_data){
  758. .offset = CLKCTRL_VID_CLK_CTRL,
  759. .bit_idx = 2,
  760. },
  761. .hw.init = &(struct clk_init_data) {
  762. .name = "vclk_div4_en",
  763. .ops = &clk_regmap_gate_ops,
  764. .parent_hws = (const struct clk_hw *[]) { &s4_vclk.hw },
  765. .num_parents = 1,
  766. .flags = CLK_SET_RATE_PARENT,
  767. },
  768. };
  769. static struct clk_regmap s4_vclk_div6_en = {
  770. .data = &(struct clk_regmap_gate_data){
  771. .offset = CLKCTRL_VID_CLK_CTRL,
  772. .bit_idx = 3,
  773. },
  774. .hw.init = &(struct clk_init_data) {
  775. .name = "vclk_div6_en",
  776. .ops = &clk_regmap_gate_ops,
  777. .parent_hws = (const struct clk_hw *[]) { &s4_vclk.hw },
  778. .num_parents = 1,
  779. .flags = CLK_SET_RATE_PARENT,
  780. },
  781. };
  782. static struct clk_regmap s4_vclk_div12_en = {
  783. .data = &(struct clk_regmap_gate_data){
  784. .offset = CLKCTRL_VID_CLK_CTRL,
  785. .bit_idx = 4,
  786. },
  787. .hw.init = &(struct clk_init_data) {
  788. .name = "vclk_div12_en",
  789. .ops = &clk_regmap_gate_ops,
  790. .parent_hws = (const struct clk_hw *[]) { &s4_vclk.hw },
  791. .num_parents = 1,
  792. .flags = CLK_SET_RATE_PARENT,
  793. },
  794. };
  795. static struct clk_regmap s4_vclk2_div1 = {
  796. .data = &(struct clk_regmap_gate_data){
  797. .offset = CLKCTRL_VIID_CLK_CTRL,
  798. .bit_idx = 0,
  799. },
  800. .hw.init = &(struct clk_init_data) {
  801. .name = "vclk2_div1",
  802. .ops = &clk_regmap_gate_ops,
  803. .parent_hws = (const struct clk_hw *[]) { &s4_vclk2.hw },
  804. .num_parents = 1,
  805. .flags = CLK_SET_RATE_PARENT,
  806. },
  807. };
  808. static struct clk_regmap s4_vclk2_div2_en = {
  809. .data = &(struct clk_regmap_gate_data){
  810. .offset = CLKCTRL_VIID_CLK_CTRL,
  811. .bit_idx = 1,
  812. },
  813. .hw.init = &(struct clk_init_data) {
  814. .name = "vclk2_div2_en",
  815. .ops = &clk_regmap_gate_ops,
  816. .parent_hws = (const struct clk_hw *[]) { &s4_vclk2.hw },
  817. .num_parents = 1,
  818. .flags = CLK_SET_RATE_PARENT,
  819. },
  820. };
  821. static struct clk_regmap s4_vclk2_div4_en = {
  822. .data = &(struct clk_regmap_gate_data){
  823. .offset = CLKCTRL_VIID_CLK_CTRL,
  824. .bit_idx = 2,
  825. },
  826. .hw.init = &(struct clk_init_data) {
  827. .name = "vclk2_div4_en",
  828. .ops = &clk_regmap_gate_ops,
  829. .parent_hws = (const struct clk_hw *[]) { &s4_vclk2.hw },
  830. .num_parents = 1,
  831. .flags = CLK_SET_RATE_PARENT,
  832. },
  833. };
  834. static struct clk_regmap s4_vclk2_div6_en = {
  835. .data = &(struct clk_regmap_gate_data){
  836. .offset = CLKCTRL_VIID_CLK_CTRL,
  837. .bit_idx = 3,
  838. },
  839. .hw.init = &(struct clk_init_data) {
  840. .name = "vclk2_div6_en",
  841. .ops = &clk_regmap_gate_ops,
  842. .parent_hws = (const struct clk_hw *[]) { &s4_vclk2.hw },
  843. .num_parents = 1,
  844. .flags = CLK_SET_RATE_PARENT,
  845. },
  846. };
  847. static struct clk_regmap s4_vclk2_div12_en = {
  848. .data = &(struct clk_regmap_gate_data){
  849. .offset = CLKCTRL_VIID_CLK_CTRL,
  850. .bit_idx = 4,
  851. },
  852. .hw.init = &(struct clk_init_data) {
  853. .name = "vclk2_div12_en",
  854. .ops = &clk_regmap_gate_ops,
  855. .parent_hws = (const struct clk_hw *[]) { &s4_vclk2.hw },
  856. .num_parents = 1,
  857. .flags = CLK_SET_RATE_PARENT,
  858. },
  859. };
  860. static struct clk_fixed_factor s4_vclk_div2 = {
  861. .mult = 1,
  862. .div = 2,
  863. .hw.init = &(struct clk_init_data){
  864. .name = "vclk_div2",
  865. .ops = &clk_fixed_factor_ops,
  866. .parent_hws = (const struct clk_hw *[]) {
  867. &s4_vclk_div2_en.hw
  868. },
  869. .num_parents = 1,
  870. .flags = CLK_SET_RATE_PARENT,
  871. },
  872. };
  873. static struct clk_fixed_factor s4_vclk_div4 = {
  874. .mult = 1,
  875. .div = 4,
  876. .hw.init = &(struct clk_init_data){
  877. .name = "vclk_div4",
  878. .ops = &clk_fixed_factor_ops,
  879. .parent_hws = (const struct clk_hw *[]) {
  880. &s4_vclk_div4_en.hw
  881. },
  882. .num_parents = 1,
  883. .flags = CLK_SET_RATE_PARENT,
  884. },
  885. };
  886. static struct clk_fixed_factor s4_vclk_div6 = {
  887. .mult = 1,
  888. .div = 6,
  889. .hw.init = &(struct clk_init_data){
  890. .name = "vclk_div6",
  891. .ops = &clk_fixed_factor_ops,
  892. .parent_hws = (const struct clk_hw *[]) {
  893. &s4_vclk_div6_en.hw
  894. },
  895. .num_parents = 1,
  896. .flags = CLK_SET_RATE_PARENT,
  897. },
  898. };
  899. static struct clk_fixed_factor s4_vclk_div12 = {
  900. .mult = 1,
  901. .div = 12,
  902. .hw.init = &(struct clk_init_data){
  903. .name = "vclk_div12",
  904. .ops = &clk_fixed_factor_ops,
  905. .parent_hws = (const struct clk_hw *[]) {
  906. &s4_vclk_div12_en.hw
  907. },
  908. .num_parents = 1,
  909. .flags = CLK_SET_RATE_PARENT,
  910. },
  911. };
  912. static struct clk_fixed_factor s4_vclk2_div2 = {
  913. .mult = 1,
  914. .div = 2,
  915. .hw.init = &(struct clk_init_data){
  916. .name = "vclk2_div2",
  917. .ops = &clk_fixed_factor_ops,
  918. .parent_hws = (const struct clk_hw *[]) {
  919. &s4_vclk2_div2_en.hw
  920. },
  921. .num_parents = 1,
  922. .flags = CLK_SET_RATE_PARENT,
  923. },
  924. };
  925. static struct clk_fixed_factor s4_vclk2_div4 = {
  926. .mult = 1,
  927. .div = 4,
  928. .hw.init = &(struct clk_init_data){
  929. .name = "vclk2_div4",
  930. .ops = &clk_fixed_factor_ops,
  931. .parent_hws = (const struct clk_hw *[]) {
  932. &s4_vclk2_div4_en.hw
  933. },
  934. .num_parents = 1,
  935. .flags = CLK_SET_RATE_PARENT,
  936. },
  937. };
  938. static struct clk_fixed_factor s4_vclk2_div6 = {
  939. .mult = 1,
  940. .div = 6,
  941. .hw.init = &(struct clk_init_data){
  942. .name = "vclk2_div6",
  943. .ops = &clk_fixed_factor_ops,
  944. .parent_hws = (const struct clk_hw *[]) {
  945. &s4_vclk2_div6_en.hw
  946. },
  947. .num_parents = 1,
  948. .flags = CLK_SET_RATE_PARENT,
  949. },
  950. };
  951. static struct clk_fixed_factor s4_vclk2_div12 = {
  952. .mult = 1,
  953. .div = 12,
  954. .hw.init = &(struct clk_init_data){
  955. .name = "vclk2_div12",
  956. .ops = &clk_fixed_factor_ops,
  957. .parent_hws = (const struct clk_hw *[]) {
  958. &s4_vclk2_div12_en.hw
  959. },
  960. .num_parents = 1,
  961. .flags = CLK_SET_RATE_PARENT,
  962. },
  963. };
  964. /* The 5,6,7 indexes corresponds to no real clock, so there are not used. */
  965. static u32 mux_table_cts_sel[] = { 0, 1, 2, 3, 4, 8, 9, 10, 11, 12 };
  966. static const struct clk_hw *s4_cts_parent_hws[] = {
  967. &s4_vclk_div1.hw,
  968. &s4_vclk_div2.hw,
  969. &s4_vclk_div4.hw,
  970. &s4_vclk_div6.hw,
  971. &s4_vclk_div12.hw,
  972. &s4_vclk2_div1.hw,
  973. &s4_vclk2_div2.hw,
  974. &s4_vclk2_div4.hw,
  975. &s4_vclk2_div6.hw,
  976. &s4_vclk2_div12.hw
  977. };
  978. static struct clk_regmap s4_cts_enci_sel = {
  979. .data = &(struct clk_regmap_mux_data){
  980. .offset = CLKCTRL_VID_CLK_DIV,
  981. .mask = 0xf,
  982. .shift = 28,
  983. .table = mux_table_cts_sel,
  984. },
  985. .hw.init = &(struct clk_init_data){
  986. .name = "cts_enci_sel",
  987. .ops = &clk_regmap_mux_ops,
  988. .parent_hws = s4_cts_parent_hws,
  989. .num_parents = ARRAY_SIZE(s4_cts_parent_hws),
  990. .flags = CLK_SET_RATE_PARENT,
  991. },
  992. };
  993. static struct clk_regmap s4_cts_encp_sel = {
  994. .data = &(struct clk_regmap_mux_data){
  995. .offset = CLKCTRL_VID_CLK_DIV,
  996. .mask = 0xf,
  997. .shift = 20,
  998. .table = mux_table_cts_sel,
  999. },
  1000. .hw.init = &(struct clk_init_data){
  1001. .name = "cts_encp_sel",
  1002. .ops = &clk_regmap_mux_ops,
  1003. .parent_hws = s4_cts_parent_hws,
  1004. .num_parents = ARRAY_SIZE(s4_cts_parent_hws),
  1005. .flags = CLK_SET_RATE_PARENT,
  1006. },
  1007. };
  1008. static struct clk_regmap s4_cts_vdac_sel = {
  1009. .data = &(struct clk_regmap_mux_data){
  1010. .offset = CLKCTRL_VIID_CLK_DIV,
  1011. .mask = 0xf,
  1012. .shift = 28,
  1013. .table = mux_table_cts_sel,
  1014. },
  1015. .hw.init = &(struct clk_init_data){
  1016. .name = "cts_vdac_sel",
  1017. .ops = &clk_regmap_mux_ops,
  1018. .parent_hws = s4_cts_parent_hws,
  1019. .num_parents = ARRAY_SIZE(s4_cts_parent_hws),
  1020. .flags = CLK_SET_RATE_PARENT,
  1021. },
  1022. };
  1023. /* The 5,6,7 indexes corresponds to no real clock, so there are not used. */
  1024. static u32 mux_table_hdmi_tx_sel[] = { 0, 1, 2, 3, 4, 8, 9, 10, 11, 12 };
  1025. static const struct clk_hw *s4_cts_hdmi_tx_parent_hws[] = {
  1026. &s4_vclk_div1.hw,
  1027. &s4_vclk_div2.hw,
  1028. &s4_vclk_div4.hw,
  1029. &s4_vclk_div6.hw,
  1030. &s4_vclk_div12.hw,
  1031. &s4_vclk2_div1.hw,
  1032. &s4_vclk2_div2.hw,
  1033. &s4_vclk2_div4.hw,
  1034. &s4_vclk2_div6.hw,
  1035. &s4_vclk2_div12.hw
  1036. };
  1037. static struct clk_regmap s4_hdmi_tx_sel = {
  1038. .data = &(struct clk_regmap_mux_data){
  1039. .offset = CLKCTRL_HDMI_CLK_CTRL,
  1040. .mask = 0xf,
  1041. .shift = 16,
  1042. .table = mux_table_hdmi_tx_sel,
  1043. },
  1044. .hw.init = &(struct clk_init_data){
  1045. .name = "hdmi_tx_sel",
  1046. .ops = &clk_regmap_mux_ops,
  1047. .parent_hws = s4_cts_hdmi_tx_parent_hws,
  1048. .num_parents = ARRAY_SIZE(s4_cts_hdmi_tx_parent_hws),
  1049. .flags = CLK_SET_RATE_PARENT,
  1050. },
  1051. };
  1052. static struct clk_regmap s4_cts_enci = {
  1053. .data = &(struct clk_regmap_gate_data){
  1054. .offset = CLKCTRL_VID_CLK_CTRL2,
  1055. .bit_idx = 0,
  1056. },
  1057. .hw.init = &(struct clk_init_data) {
  1058. .name = "cts_enci",
  1059. .ops = &clk_regmap_gate_ops,
  1060. .parent_hws = (const struct clk_hw *[]) {
  1061. &s4_cts_enci_sel.hw
  1062. },
  1063. .num_parents = 1,
  1064. .flags = CLK_SET_RATE_PARENT,
  1065. },
  1066. };
  1067. static struct clk_regmap s4_cts_encp = {
  1068. .data = &(struct clk_regmap_gate_data){
  1069. .offset = CLKCTRL_VID_CLK_CTRL2,
  1070. .bit_idx = 2,
  1071. },
  1072. .hw.init = &(struct clk_init_data) {
  1073. .name = "cts_encp",
  1074. .ops = &clk_regmap_gate_ops,
  1075. .parent_hws = (const struct clk_hw *[]) {
  1076. &s4_cts_encp_sel.hw
  1077. },
  1078. .num_parents = 1,
  1079. .flags = CLK_SET_RATE_PARENT,
  1080. },
  1081. };
  1082. static struct clk_regmap s4_cts_vdac = {
  1083. .data = &(struct clk_regmap_gate_data){
  1084. .offset = CLKCTRL_VID_CLK_CTRL2,
  1085. .bit_idx = 4,
  1086. },
  1087. .hw.init = &(struct clk_init_data) {
  1088. .name = "cts_vdac",
  1089. .ops = &clk_regmap_gate_ops,
  1090. .parent_hws = (const struct clk_hw *[]) {
  1091. &s4_cts_vdac_sel.hw
  1092. },
  1093. .num_parents = 1,
  1094. .flags = CLK_SET_RATE_PARENT,
  1095. },
  1096. };
  1097. static struct clk_regmap s4_hdmi_tx = {
  1098. .data = &(struct clk_regmap_gate_data){
  1099. .offset = CLKCTRL_VID_CLK_CTRL2,
  1100. .bit_idx = 5,
  1101. },
  1102. .hw.init = &(struct clk_init_data) {
  1103. .name = "hdmi_tx",
  1104. .ops = &clk_regmap_gate_ops,
  1105. .parent_hws = (const struct clk_hw *[]) {
  1106. &s4_hdmi_tx_sel.hw
  1107. },
  1108. .num_parents = 1,
  1109. .flags = CLK_SET_RATE_PARENT,
  1110. },
  1111. };
  1112. /* HDMI Clocks */
  1113. static const struct clk_parent_data s4_hdmi_parent_data[] = {
  1114. { .fw_name = "xtal", },
  1115. { .fw_name = "fclk_div4", },
  1116. { .fw_name = "fclk_div3", },
  1117. { .fw_name = "fclk_div5", }
  1118. };
  1119. static struct clk_regmap s4_hdmi_sel = {
  1120. .data = &(struct clk_regmap_mux_data){
  1121. .offset = CLKCTRL_HDMI_CLK_CTRL,
  1122. .mask = 0x3,
  1123. .shift = 9,
  1124. .flags = CLK_MUX_ROUND_CLOSEST,
  1125. },
  1126. .hw.init = &(struct clk_init_data){
  1127. .name = "hdmi_sel",
  1128. .ops = &clk_regmap_mux_ops,
  1129. .parent_data = s4_hdmi_parent_data,
  1130. .num_parents = ARRAY_SIZE(s4_hdmi_parent_data),
  1131. .flags = CLK_SET_RATE_PARENT,
  1132. },
  1133. };
  1134. static struct clk_regmap s4_hdmi_div = {
  1135. .data = &(struct clk_regmap_div_data){
  1136. .offset = CLKCTRL_HDMI_CLK_CTRL,
  1137. .shift = 0,
  1138. .width = 7,
  1139. },
  1140. .hw.init = &(struct clk_init_data){
  1141. .name = "hdmi_div",
  1142. .ops = &clk_regmap_divider_ops,
  1143. .parent_hws = (const struct clk_hw *[]) { &s4_hdmi_sel.hw },
  1144. .num_parents = 1,
  1145. .flags = CLK_SET_RATE_PARENT,
  1146. },
  1147. };
  1148. static struct clk_regmap s4_hdmi = {
  1149. .data = &(struct clk_regmap_gate_data){
  1150. .offset = CLKCTRL_HDMI_CLK_CTRL,
  1151. .bit_idx = 8,
  1152. },
  1153. .hw.init = &(struct clk_init_data) {
  1154. .name = "hdmi",
  1155. .ops = &clk_regmap_gate_ops,
  1156. .parent_hws = (const struct clk_hw *[]) { &s4_hdmi_div.hw },
  1157. .num_parents = 1,
  1158. .flags = CLK_SET_RATE_PARENT,
  1159. },
  1160. };
  1161. static struct clk_regmap s4_ts_clk_div = {
  1162. .data = &(struct clk_regmap_div_data){
  1163. .offset = CLKCTRL_TS_CLK_CTRL,
  1164. .shift = 0,
  1165. .width = 8,
  1166. },
  1167. .hw.init = &(struct clk_init_data){
  1168. .name = "ts_clk_div",
  1169. .ops = &clk_regmap_divider_ops,
  1170. .parent_data = &(const struct clk_parent_data) {
  1171. .fw_name = "xtal",
  1172. },
  1173. .num_parents = 1,
  1174. .flags = CLK_SET_RATE_PARENT,
  1175. },
  1176. };
  1177. static struct clk_regmap s4_ts_clk_gate = {
  1178. .data = &(struct clk_regmap_gate_data){
  1179. .offset = CLKCTRL_TS_CLK_CTRL,
  1180. .bit_idx = 8,
  1181. },
  1182. .hw.init = &(struct clk_init_data){
  1183. .name = "ts_clk",
  1184. .ops = &clk_regmap_gate_ops,
  1185. .parent_hws = (const struct clk_hw *[]) {
  1186. &s4_ts_clk_div.hw
  1187. },
  1188. .num_parents = 1,
  1189. .flags = CLK_SET_RATE_PARENT,
  1190. },
  1191. };
  1192. /*
  1193. * The MALI IP is clocked by two identical clocks (mali_0 and mali_1)
  1194. * muxed by a glitch-free switch. The CCF can manage this glitch-free
  1195. * mux because it does top-to-bottom updates the each clock tree and
  1196. * switches to the "inactive" one when CLK_SET_RATE_GATE is set.
  1197. */
  1198. static const struct clk_parent_data s4_mali_0_1_parent_data[] = {
  1199. { .fw_name = "xtal", },
  1200. { .fw_name = "gp0_pll", },
  1201. { .fw_name = "hifi_pll", },
  1202. { .fw_name = "fclk_div2p5", },
  1203. { .fw_name = "fclk_div3", },
  1204. { .fw_name = "fclk_div4", },
  1205. { .fw_name = "fclk_div5", },
  1206. { .fw_name = "fclk_div7", }
  1207. };
  1208. static struct clk_regmap s4_mali_0_sel = {
  1209. .data = &(struct clk_regmap_mux_data){
  1210. .offset = CLKCTRL_MALI_CLK_CTRL,
  1211. .mask = 0x7,
  1212. .shift = 9,
  1213. },
  1214. .hw.init = &(struct clk_init_data){
  1215. .name = "mali_0_sel",
  1216. .ops = &clk_regmap_mux_ops,
  1217. .parent_data = s4_mali_0_1_parent_data,
  1218. .num_parents = ARRAY_SIZE(s4_mali_0_1_parent_data),
  1219. /*
  1220. * Don't request the parent to change the rate because
  1221. * all GPU frequencies can be derived from the fclk_*
  1222. * clocks and one special GP0_PLL setting. This is
  1223. * important because we need the HIFI PLL clock for audio.
  1224. */
  1225. .flags = 0,
  1226. },
  1227. };
  1228. static struct clk_regmap s4_mali_0_div = {
  1229. .data = &(struct clk_regmap_div_data){
  1230. .offset = CLKCTRL_MALI_CLK_CTRL,
  1231. .shift = 0,
  1232. .width = 7,
  1233. },
  1234. .hw.init = &(struct clk_init_data){
  1235. .name = "mali_0_div",
  1236. .ops = &clk_regmap_divider_ops,
  1237. .parent_hws = (const struct clk_hw *[]) {
  1238. &s4_mali_0_sel.hw
  1239. },
  1240. .num_parents = 1,
  1241. .flags = CLK_SET_RATE_PARENT,
  1242. },
  1243. };
  1244. static struct clk_regmap s4_mali_0 = {
  1245. .data = &(struct clk_regmap_gate_data){
  1246. .offset = CLKCTRL_MALI_CLK_CTRL,
  1247. .bit_idx = 8,
  1248. },
  1249. .hw.init = &(struct clk_init_data){
  1250. .name = "mali_0",
  1251. .ops = &clk_regmap_gate_ops,
  1252. .parent_hws = (const struct clk_hw *[]) {
  1253. &s4_mali_0_div.hw
  1254. },
  1255. .num_parents = 1,
  1256. .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
  1257. },
  1258. };
  1259. static struct clk_regmap s4_mali_1_sel = {
  1260. .data = &(struct clk_regmap_mux_data){
  1261. .offset = CLKCTRL_MALI_CLK_CTRL,
  1262. .mask = 0x7,
  1263. .shift = 25,
  1264. },
  1265. .hw.init = &(struct clk_init_data){
  1266. .name = "mali_1_sel",
  1267. .ops = &clk_regmap_mux_ops,
  1268. .parent_data = s4_mali_0_1_parent_data,
  1269. .num_parents = ARRAY_SIZE(s4_mali_0_1_parent_data),
  1270. .flags = 0,
  1271. },
  1272. };
  1273. static struct clk_regmap s4_mali_1_div = {
  1274. .data = &(struct clk_regmap_div_data){
  1275. .offset = CLKCTRL_MALI_CLK_CTRL,
  1276. .shift = 16,
  1277. .width = 7,
  1278. },
  1279. .hw.init = &(struct clk_init_data){
  1280. .name = "mali_1_div",
  1281. .ops = &clk_regmap_divider_ops,
  1282. .parent_hws = (const struct clk_hw *[]) {
  1283. &s4_mali_1_sel.hw
  1284. },
  1285. .num_parents = 1,
  1286. .flags = CLK_SET_RATE_PARENT,
  1287. },
  1288. };
  1289. static struct clk_regmap s4_mali_1 = {
  1290. .data = &(struct clk_regmap_gate_data){
  1291. .offset = CLKCTRL_MALI_CLK_CTRL,
  1292. .bit_idx = 24,
  1293. },
  1294. .hw.init = &(struct clk_init_data){
  1295. .name = "mali_1",
  1296. .ops = &clk_regmap_gate_ops,
  1297. .parent_hws = (const struct clk_hw *[]) {
  1298. &s4_mali_1_div.hw
  1299. },
  1300. .num_parents = 1,
  1301. .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
  1302. },
  1303. };
  1304. static const struct clk_hw *s4_mali_parent_hws[] = {
  1305. &s4_mali_0.hw,
  1306. &s4_mali_1.hw
  1307. };
  1308. static struct clk_regmap s4_mali_mux = {
  1309. .data = &(struct clk_regmap_mux_data){
  1310. .offset = CLKCTRL_MALI_CLK_CTRL,
  1311. .mask = 1,
  1312. .shift = 31,
  1313. },
  1314. .hw.init = &(struct clk_init_data){
  1315. .name = "mali",
  1316. .ops = &clk_regmap_mux_ops,
  1317. .parent_hws = s4_mali_parent_hws,
  1318. .num_parents = 2,
  1319. .flags = CLK_SET_RATE_PARENT,
  1320. },
  1321. };
  1322. /* VDEC clocks */
  1323. static const struct clk_parent_data s4_dec_parent_data[] = {
  1324. { .fw_name = "fclk_div2p5", },
  1325. { .fw_name = "fclk_div3", },
  1326. { .fw_name = "fclk_div4", },
  1327. { .fw_name = "fclk_div5", },
  1328. { .fw_name = "fclk_div7", },
  1329. { .fw_name = "hifi_pll", },
  1330. { .fw_name = "gp0_pll", },
  1331. { .fw_name = "xtal", }
  1332. };
  1333. static struct clk_regmap s4_vdec_p0_mux = {
  1334. .data = &(struct clk_regmap_mux_data){
  1335. .offset = CLKCTRL_VDEC_CLK_CTRL,
  1336. .mask = 0x7,
  1337. .shift = 9,
  1338. .flags = CLK_MUX_ROUND_CLOSEST,
  1339. },
  1340. .hw.init = &(struct clk_init_data) {
  1341. .name = "vdec_p0_mux",
  1342. .ops = &clk_regmap_mux_ops,
  1343. .parent_data = s4_dec_parent_data,
  1344. .num_parents = ARRAY_SIZE(s4_dec_parent_data),
  1345. .flags = 0,
  1346. },
  1347. };
  1348. static struct clk_regmap s4_vdec_p0_div = {
  1349. .data = &(struct clk_regmap_div_data){
  1350. .offset = CLKCTRL_VDEC_CLK_CTRL,
  1351. .shift = 0,
  1352. .width = 7,
  1353. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  1354. },
  1355. .hw.init = &(struct clk_init_data) {
  1356. .name = "vdec_p0_div",
  1357. .ops = &clk_regmap_divider_ops,
  1358. .parent_hws = (const struct clk_hw *[]) {
  1359. &s4_vdec_p0_mux.hw
  1360. },
  1361. .num_parents = 1,
  1362. .flags = CLK_SET_RATE_PARENT,
  1363. },
  1364. };
  1365. static struct clk_regmap s4_vdec_p0 = {
  1366. .data = &(struct clk_regmap_gate_data){
  1367. .offset = CLKCTRL_VDEC_CLK_CTRL,
  1368. .bit_idx = 8,
  1369. },
  1370. .hw.init = &(struct clk_init_data){
  1371. .name = "vdec_p0",
  1372. .ops = &clk_regmap_gate_ops,
  1373. .parent_hws = (const struct clk_hw *[]) {
  1374. &s4_vdec_p0_div.hw
  1375. },
  1376. .num_parents = 1,
  1377. .flags = CLK_SET_RATE_PARENT,
  1378. },
  1379. };
  1380. static struct clk_regmap s4_vdec_p1_mux = {
  1381. .data = &(struct clk_regmap_mux_data){
  1382. .offset = CLKCTRL_VDEC3_CLK_CTRL,
  1383. .mask = 0x7,
  1384. .shift = 9,
  1385. .flags = CLK_MUX_ROUND_CLOSEST,
  1386. },
  1387. .hw.init = &(struct clk_init_data) {
  1388. .name = "vdec_p1_mux",
  1389. .ops = &clk_regmap_mux_ops,
  1390. .parent_data = s4_dec_parent_data,
  1391. .num_parents = ARRAY_SIZE(s4_dec_parent_data),
  1392. .flags = 0,
  1393. },
  1394. };
  1395. static struct clk_regmap s4_vdec_p1_div = {
  1396. .data = &(struct clk_regmap_div_data){
  1397. .offset = CLKCTRL_VDEC3_CLK_CTRL,
  1398. .shift = 0,
  1399. .width = 7,
  1400. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  1401. },
  1402. .hw.init = &(struct clk_init_data) {
  1403. .name = "vdec_p1_div",
  1404. .ops = &clk_regmap_divider_ops,
  1405. .parent_hws = (const struct clk_hw *[]) {
  1406. &s4_vdec_p1_mux.hw
  1407. },
  1408. .num_parents = 1,
  1409. .flags = CLK_SET_RATE_PARENT,
  1410. },
  1411. };
  1412. static struct clk_regmap s4_vdec_p1 = {
  1413. .data = &(struct clk_regmap_gate_data){
  1414. .offset = CLKCTRL_VDEC3_CLK_CTRL,
  1415. .bit_idx = 8,
  1416. },
  1417. .hw.init = &(struct clk_init_data){
  1418. .name = "vdec_p1",
  1419. .ops = &clk_regmap_gate_ops,
  1420. .parent_hws = (const struct clk_hw *[]) {
  1421. &s4_vdec_p1_div.hw
  1422. },
  1423. .num_parents = 1,
  1424. .flags = CLK_SET_RATE_PARENT,
  1425. },
  1426. };
  1427. static const struct clk_hw *s4_vdec_mux_parent_hws[] = {
  1428. &s4_vdec_p0.hw,
  1429. &s4_vdec_p1.hw
  1430. };
  1431. static struct clk_regmap s4_vdec_mux = {
  1432. .data = &(struct clk_regmap_mux_data){
  1433. .offset = CLKCTRL_VDEC3_CLK_CTRL,
  1434. .mask = 0x1,
  1435. .shift = 15,
  1436. },
  1437. .hw.init = &(struct clk_init_data) {
  1438. .name = "vdec_mux",
  1439. .ops = &clk_regmap_mux_ops,
  1440. .parent_hws = s4_vdec_mux_parent_hws,
  1441. .num_parents = ARRAY_SIZE(s4_vdec_mux_parent_hws),
  1442. .flags = CLK_SET_RATE_PARENT,
  1443. },
  1444. };
  1445. static struct clk_regmap s4_hevcf_p0_mux = {
  1446. .data = &(struct clk_regmap_mux_data){
  1447. .offset = CLKCTRL_VDEC2_CLK_CTRL,
  1448. .mask = 0x7,
  1449. .shift = 9,
  1450. .flags = CLK_MUX_ROUND_CLOSEST,
  1451. },
  1452. .hw.init = &(struct clk_init_data) {
  1453. .name = "hevcf_p0_mux",
  1454. .ops = &clk_regmap_mux_ops,
  1455. .parent_data = s4_dec_parent_data,
  1456. .num_parents = ARRAY_SIZE(s4_dec_parent_data),
  1457. .flags = 0,
  1458. },
  1459. };
  1460. static struct clk_regmap s4_hevcf_p0_div = {
  1461. .data = &(struct clk_regmap_div_data){
  1462. .offset = CLKCTRL_VDEC2_CLK_CTRL,
  1463. .shift = 0,
  1464. .width = 7,
  1465. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  1466. },
  1467. .hw.init = &(struct clk_init_data) {
  1468. .name = "hevcf_p0_div",
  1469. .ops = &clk_regmap_divider_ops,
  1470. .parent_hws = (const struct clk_hw *[]) {
  1471. &s4_hevcf_p0_mux.hw
  1472. },
  1473. .num_parents = 1,
  1474. .flags = CLK_SET_RATE_PARENT,
  1475. },
  1476. };
  1477. static struct clk_regmap s4_hevcf_p0 = {
  1478. .data = &(struct clk_regmap_gate_data){
  1479. .offset = CLKCTRL_VDEC2_CLK_CTRL,
  1480. .bit_idx = 8,
  1481. },
  1482. .hw.init = &(struct clk_init_data){
  1483. .name = "hevcf_p0_gate",
  1484. .ops = &clk_regmap_gate_ops,
  1485. .parent_hws = (const struct clk_hw *[]) {
  1486. &s4_hevcf_p0_div.hw
  1487. },
  1488. .num_parents = 1,
  1489. .flags = CLK_SET_RATE_PARENT,
  1490. },
  1491. };
  1492. static struct clk_regmap s4_hevcf_p1_mux = {
  1493. .data = &(struct clk_regmap_mux_data){
  1494. .offset = CLKCTRL_VDEC4_CLK_CTRL,
  1495. .mask = 0x7,
  1496. .shift = 9,
  1497. .flags = CLK_MUX_ROUND_CLOSEST,
  1498. },
  1499. .hw.init = &(struct clk_init_data) {
  1500. .name = "hevcf_p1_mux",
  1501. .ops = &clk_regmap_mux_ops,
  1502. .parent_data = s4_dec_parent_data,
  1503. .num_parents = ARRAY_SIZE(s4_dec_parent_data),
  1504. .flags = 0,
  1505. },
  1506. };
  1507. static struct clk_regmap s4_hevcf_p1_div = {
  1508. .data = &(struct clk_regmap_div_data){
  1509. .offset = CLKCTRL_VDEC4_CLK_CTRL,
  1510. .shift = 0,
  1511. .width = 7,
  1512. .flags = CLK_DIVIDER_ROUND_CLOSEST,
  1513. },
  1514. .hw.init = &(struct clk_init_data) {
  1515. .name = "hevcf_p1_div",
  1516. .ops = &clk_regmap_divider_ops,
  1517. .parent_hws = (const struct clk_hw *[]) {
  1518. &s4_hevcf_p1_mux.hw
  1519. },
  1520. .num_parents = 1,
  1521. .flags = CLK_SET_RATE_PARENT,
  1522. },
  1523. };
  1524. static struct clk_regmap s4_hevcf_p1 = {
  1525. .data = &(struct clk_regmap_gate_data){
  1526. .offset = CLKCTRL_VDEC4_CLK_CTRL,
  1527. .bit_idx = 8,
  1528. },
  1529. .hw.init = &(struct clk_init_data){
  1530. .name = "hevcf_p1",
  1531. .ops = &clk_regmap_gate_ops,
  1532. .parent_hws = (const struct clk_hw *[]) {
  1533. &s4_hevcf_p1_div.hw
  1534. },
  1535. .num_parents = 1,
  1536. .flags = CLK_SET_RATE_PARENT,
  1537. },
  1538. };
  1539. static const struct clk_hw *s4_hevcf_mux_parent_hws[] = {
  1540. &s4_hevcf_p0.hw,
  1541. &s4_hevcf_p1.hw
  1542. };
  1543. static struct clk_regmap s4_hevcf_mux = {
  1544. .data = &(struct clk_regmap_mux_data){
  1545. .offset = CLKCTRL_VDEC4_CLK_CTRL,
  1546. .mask = 0x1,
  1547. .shift = 15,
  1548. },
  1549. .hw.init = &(struct clk_init_data) {
  1550. .name = "hevcf",
  1551. .ops = &clk_regmap_mux_ops,
  1552. .parent_hws = s4_hevcf_mux_parent_hws,
  1553. .num_parents = ARRAY_SIZE(s4_hevcf_mux_parent_hws),
  1554. .flags = CLK_SET_RATE_PARENT,
  1555. },
  1556. };
  1557. /* VPU Clock */
  1558. static const struct clk_parent_data s4_vpu_parent_data[] = {
  1559. { .fw_name = "fclk_div3", },
  1560. { .fw_name = "fclk_div4", },
  1561. { .fw_name = "fclk_div5", },
  1562. { .fw_name = "fclk_div7", },
  1563. { .fw_name = "mpll1", },
  1564. { .hw = &s4_vid_pll.hw },
  1565. { .fw_name = "hifi_pll", },
  1566. { .fw_name = "gp0_pll", },
  1567. };
  1568. static struct clk_regmap s4_vpu_0_sel = {
  1569. .data = &(struct clk_regmap_mux_data){
  1570. .offset = CLKCTRL_VPU_CLK_CTRL,
  1571. .mask = 0x7,
  1572. .shift = 9,
  1573. },
  1574. .hw.init = &(struct clk_init_data){
  1575. .name = "vpu_0_sel",
  1576. .ops = &clk_regmap_mux_ops,
  1577. .parent_data = s4_vpu_parent_data,
  1578. .num_parents = ARRAY_SIZE(s4_vpu_parent_data),
  1579. .flags = 0,
  1580. },
  1581. };
  1582. static struct clk_regmap s4_vpu_0_div = {
  1583. .data = &(struct clk_regmap_div_data){
  1584. .offset = CLKCTRL_VPU_CLK_CTRL,
  1585. .shift = 0,
  1586. .width = 7,
  1587. },
  1588. .hw.init = &(struct clk_init_data){
  1589. .name = "vpu_0_div",
  1590. .ops = &clk_regmap_divider_ops,
  1591. .parent_hws = (const struct clk_hw *[]) { &s4_vpu_0_sel.hw },
  1592. .num_parents = 1,
  1593. .flags = CLK_SET_RATE_PARENT,
  1594. },
  1595. };
  1596. static struct clk_regmap s4_vpu_0 = {
  1597. .data = &(struct clk_regmap_gate_data){
  1598. .offset = CLKCTRL_VPU_CLK_CTRL,
  1599. .bit_idx = 8,
  1600. },
  1601. .hw.init = &(struct clk_init_data) {
  1602. .name = "vpu_0",
  1603. .ops = &clk_regmap_gate_ops,
  1604. .parent_hws = (const struct clk_hw *[]) { &s4_vpu_0_div.hw },
  1605. .num_parents = 1,
  1606. .flags = CLK_SET_RATE_PARENT,
  1607. },
  1608. };
  1609. static struct clk_regmap s4_vpu_1_sel = {
  1610. .data = &(struct clk_regmap_mux_data){
  1611. .offset = CLKCTRL_VPU_CLK_CTRL,
  1612. .mask = 0x7,
  1613. .shift = 25,
  1614. },
  1615. .hw.init = &(struct clk_init_data){
  1616. .name = "vpu_1_sel",
  1617. .ops = &clk_regmap_mux_ops,
  1618. .parent_data = s4_vpu_parent_data,
  1619. .num_parents = ARRAY_SIZE(s4_vpu_parent_data),
  1620. .flags = 0,
  1621. },
  1622. };
  1623. static struct clk_regmap s4_vpu_1_div = {
  1624. .data = &(struct clk_regmap_div_data){
  1625. .offset = CLKCTRL_VPU_CLK_CTRL,
  1626. .shift = 16,
  1627. .width = 7,
  1628. },
  1629. .hw.init = &(struct clk_init_data){
  1630. .name = "vpu_1_div",
  1631. .ops = &clk_regmap_divider_ops,
  1632. .parent_hws = (const struct clk_hw *[]) { &s4_vpu_1_sel.hw },
  1633. .num_parents = 1,
  1634. .flags = CLK_SET_RATE_PARENT,
  1635. },
  1636. };
  1637. static struct clk_regmap s4_vpu_1 = {
  1638. .data = &(struct clk_regmap_gate_data){
  1639. .offset = CLKCTRL_VPU_CLK_CTRL,
  1640. .bit_idx = 24,
  1641. },
  1642. .hw.init = &(struct clk_init_data) {
  1643. .name = "vpu_1",
  1644. .ops = &clk_regmap_gate_ops,
  1645. .parent_hws = (const struct clk_hw *[]) { &s4_vpu_1_div.hw },
  1646. .num_parents = 1,
  1647. .flags = CLK_SET_RATE_PARENT,
  1648. },
  1649. };
  1650. static struct clk_regmap s4_vpu = {
  1651. .data = &(struct clk_regmap_mux_data){
  1652. .offset = CLKCTRL_VPU_CLK_CTRL,
  1653. .mask = 1,
  1654. .shift = 31,
  1655. },
  1656. .hw.init = &(struct clk_init_data){
  1657. .name = "vpu",
  1658. .ops = &clk_regmap_mux_ops,
  1659. .parent_hws = (const struct clk_hw *[]) {
  1660. &s4_vpu_0.hw,
  1661. &s4_vpu_1.hw,
  1662. },
  1663. .num_parents = 2,
  1664. .flags = CLK_SET_RATE_PARENT,
  1665. },
  1666. };
  1667. static const struct clk_parent_data vpu_clkb_tmp_parent_data[] = {
  1668. { .hw = &s4_vpu.hw },
  1669. { .fw_name = "fclk_div4", },
  1670. { .fw_name = "fclk_div5", },
  1671. { .fw_name = "fclk_div7", }
  1672. };
  1673. static struct clk_regmap s4_vpu_clkb_tmp_mux = {
  1674. .data = &(struct clk_regmap_mux_data){
  1675. .offset = CLKCTRL_VPU_CLKB_CTRL,
  1676. .mask = 0x3,
  1677. .shift = 20,
  1678. },
  1679. .hw.init = &(struct clk_init_data) {
  1680. .name = "vpu_clkb_tmp_mux",
  1681. .ops = &clk_regmap_mux_ops,
  1682. .parent_data = vpu_clkb_tmp_parent_data,
  1683. .num_parents = ARRAY_SIZE(vpu_clkb_tmp_parent_data),
  1684. .flags = CLK_SET_RATE_PARENT,
  1685. },
  1686. };
  1687. static struct clk_regmap s4_vpu_clkb_tmp_div = {
  1688. .data = &(struct clk_regmap_div_data){
  1689. .offset = CLKCTRL_VPU_CLKB_CTRL,
  1690. .shift = 16,
  1691. .width = 4,
  1692. },
  1693. .hw.init = &(struct clk_init_data) {
  1694. .name = "vpu_clkb_tmp_div",
  1695. .ops = &clk_regmap_divider_ops,
  1696. .parent_hws = (const struct clk_hw *[]) {
  1697. &s4_vpu_clkb_tmp_mux.hw
  1698. },
  1699. .num_parents = 1,
  1700. .flags = CLK_SET_RATE_PARENT,
  1701. },
  1702. };
  1703. static struct clk_regmap s4_vpu_clkb_tmp = {
  1704. .data = &(struct clk_regmap_gate_data){
  1705. .offset = CLKCTRL_VPU_CLKB_CTRL,
  1706. .bit_idx = 24,
  1707. },
  1708. .hw.init = &(struct clk_init_data){
  1709. .name = "vpu_clkb_tmp",
  1710. .ops = &clk_regmap_gate_ops,
  1711. .parent_hws = (const struct clk_hw *[]) {
  1712. &s4_vpu_clkb_tmp_div.hw
  1713. },
  1714. .num_parents = 1,
  1715. .flags = CLK_SET_RATE_PARENT,
  1716. },
  1717. };
  1718. static struct clk_regmap s4_vpu_clkb_div = {
  1719. .data = &(struct clk_regmap_div_data){
  1720. .offset = CLKCTRL_VPU_CLKB_CTRL,
  1721. .shift = 0,
  1722. .width = 8,
  1723. },
  1724. .hw.init = &(struct clk_init_data) {
  1725. .name = "vpu_clkb_div",
  1726. .ops = &clk_regmap_divider_ops,
  1727. .parent_hws = (const struct clk_hw *[]) {
  1728. &s4_vpu_clkb_tmp.hw
  1729. },
  1730. .num_parents = 1,
  1731. .flags = CLK_SET_RATE_PARENT,
  1732. },
  1733. };
  1734. static struct clk_regmap s4_vpu_clkb = {
  1735. .data = &(struct clk_regmap_gate_data){
  1736. .offset = CLKCTRL_VPU_CLKB_CTRL,
  1737. .bit_idx = 8,
  1738. },
  1739. .hw.init = &(struct clk_init_data){
  1740. .name = "vpu_clkb",
  1741. .ops = &clk_regmap_gate_ops,
  1742. .parent_hws = (const struct clk_hw *[]) {
  1743. &s4_vpu_clkb_div.hw
  1744. },
  1745. .num_parents = 1,
  1746. .flags = CLK_SET_RATE_PARENT,
  1747. },
  1748. };
  1749. static const struct clk_parent_data s4_vpu_clkc_parent_data[] = {
  1750. { .fw_name = "fclk_div4", },
  1751. { .fw_name = "fclk_div3", },
  1752. { .fw_name = "fclk_div5", },
  1753. { .fw_name = "fclk_div7", },
  1754. { .fw_name = "mpll1", },
  1755. { .hw = &s4_vid_pll.hw },
  1756. { .fw_name = "mpll2", },
  1757. { .fw_name = "gp0_pll", },
  1758. };
  1759. static struct clk_regmap s4_vpu_clkc_p0_mux = {
  1760. .data = &(struct clk_regmap_mux_data){
  1761. .offset = CLKCTRL_VPU_CLKC_CTRL,
  1762. .mask = 0x7,
  1763. .shift = 9,
  1764. },
  1765. .hw.init = &(struct clk_init_data) {
  1766. .name = "vpu_clkc_p0_mux",
  1767. .ops = &clk_regmap_mux_ops,
  1768. .parent_data = s4_vpu_clkc_parent_data,
  1769. .num_parents = ARRAY_SIZE(s4_vpu_clkc_parent_data),
  1770. .flags = 0,
  1771. },
  1772. };
  1773. static struct clk_regmap s4_vpu_clkc_p0_div = {
  1774. .data = &(struct clk_regmap_div_data){
  1775. .offset = CLKCTRL_VPU_CLKC_CTRL,
  1776. .shift = 0,
  1777. .width = 7,
  1778. },
  1779. .hw.init = &(struct clk_init_data) {
  1780. .name = "vpu_clkc_p0_div",
  1781. .ops = &clk_regmap_divider_ops,
  1782. .parent_hws = (const struct clk_hw *[]) {
  1783. &s4_vpu_clkc_p0_mux.hw
  1784. },
  1785. .num_parents = 1,
  1786. .flags = CLK_SET_RATE_PARENT,
  1787. },
  1788. };
  1789. static struct clk_regmap s4_vpu_clkc_p0 = {
  1790. .data = &(struct clk_regmap_gate_data){
  1791. .offset = CLKCTRL_VPU_CLKC_CTRL,
  1792. .bit_idx = 8,
  1793. },
  1794. .hw.init = &(struct clk_init_data){
  1795. .name = "vpu_clkc_p0",
  1796. .ops = &clk_regmap_gate_ops,
  1797. .parent_hws = (const struct clk_hw *[]) {
  1798. &s4_vpu_clkc_p0_div.hw
  1799. },
  1800. .num_parents = 1,
  1801. .flags = CLK_SET_RATE_PARENT,
  1802. },
  1803. };
  1804. static struct clk_regmap s4_vpu_clkc_p1_mux = {
  1805. .data = &(struct clk_regmap_mux_data){
  1806. .offset = CLKCTRL_VPU_CLKC_CTRL,
  1807. .mask = 0x7,
  1808. .shift = 25,
  1809. },
  1810. .hw.init = &(struct clk_init_data) {
  1811. .name = "vpu_clkc_p1_mux",
  1812. .ops = &clk_regmap_mux_ops,
  1813. .parent_data = s4_vpu_clkc_parent_data,
  1814. .num_parents = ARRAY_SIZE(s4_vpu_clkc_parent_data),
  1815. .flags = 0,
  1816. },
  1817. };
  1818. static struct clk_regmap s4_vpu_clkc_p1_div = {
  1819. .data = &(struct clk_regmap_div_data){
  1820. .offset = CLKCTRL_VPU_CLKC_CTRL,
  1821. .shift = 16,
  1822. .width = 7,
  1823. },
  1824. .hw.init = &(struct clk_init_data) {
  1825. .name = "vpu_clkc_p1_div",
  1826. .ops = &clk_regmap_divider_ops,
  1827. .parent_hws = (const struct clk_hw *[]) {
  1828. &s4_vpu_clkc_p1_mux.hw
  1829. },
  1830. .num_parents = 1,
  1831. .flags = CLK_SET_RATE_PARENT,
  1832. },
  1833. };
  1834. static struct clk_regmap s4_vpu_clkc_p1 = {
  1835. .data = &(struct clk_regmap_gate_data){
  1836. .offset = CLKCTRL_VPU_CLKC_CTRL,
  1837. .bit_idx = 24,
  1838. },
  1839. .hw.init = &(struct clk_init_data){
  1840. .name = "vpu_clkc_p1",
  1841. .ops = &clk_regmap_gate_ops,
  1842. .parent_hws = (const struct clk_hw *[]) {
  1843. &s4_vpu_clkc_p1_div.hw
  1844. },
  1845. .num_parents = 1,
  1846. .flags = CLK_SET_RATE_PARENT,
  1847. },
  1848. };
  1849. static const struct clk_hw *s4_vpu_mux_parent_hws[] = {
  1850. &s4_vpu_clkc_p0.hw,
  1851. &s4_vpu_clkc_p1.hw
  1852. };
  1853. static struct clk_regmap s4_vpu_clkc_mux = {
  1854. .data = &(struct clk_regmap_mux_data){
  1855. .offset = CLKCTRL_VPU_CLKC_CTRL,
  1856. .mask = 0x1,
  1857. .shift = 31,
  1858. },
  1859. .hw.init = &(struct clk_init_data) {
  1860. .name = "vpu_clkc_mux",
  1861. .ops = &clk_regmap_mux_ops,
  1862. .parent_hws = s4_vpu_mux_parent_hws,
  1863. .num_parents = ARRAY_SIZE(s4_vpu_mux_parent_hws),
  1864. .flags = CLK_SET_RATE_PARENT,
  1865. },
  1866. };
  1867. /* VAPB Clock */
  1868. static const struct clk_parent_data s4_vapb_parent_data[] = {
  1869. { .fw_name = "fclk_div4", },
  1870. { .fw_name = "fclk_div3", },
  1871. { .fw_name = "fclk_div5", },
  1872. { .fw_name = "fclk_div7", },
  1873. { .fw_name = "mpll1", },
  1874. { .hw = &s4_vid_pll.hw },
  1875. { .fw_name = "mpll2", },
  1876. { .fw_name = "fclk_div2p5", },
  1877. };
  1878. static struct clk_regmap s4_vapb_0_sel = {
  1879. .data = &(struct clk_regmap_mux_data){
  1880. .offset = CLKCTRL_VAPBCLK_CTRL,
  1881. .mask = 0x7,
  1882. .shift = 9,
  1883. },
  1884. .hw.init = &(struct clk_init_data){
  1885. .name = "vapb_0_sel",
  1886. .ops = &clk_regmap_mux_ops,
  1887. .parent_data = s4_vapb_parent_data,
  1888. .num_parents = ARRAY_SIZE(s4_vapb_parent_data),
  1889. .flags = 0,
  1890. },
  1891. };
  1892. static struct clk_regmap s4_vapb_0_div = {
  1893. .data = &(struct clk_regmap_div_data){
  1894. .offset = CLKCTRL_VAPBCLK_CTRL,
  1895. .shift = 0,
  1896. .width = 7,
  1897. },
  1898. .hw.init = &(struct clk_init_data){
  1899. .name = "vapb_0_div",
  1900. .ops = &clk_regmap_divider_ops,
  1901. .parent_hws = (const struct clk_hw *[]) {
  1902. &s4_vapb_0_sel.hw
  1903. },
  1904. .num_parents = 1,
  1905. .flags = CLK_SET_RATE_PARENT,
  1906. },
  1907. };
  1908. static struct clk_regmap s4_vapb_0 = {
  1909. .data = &(struct clk_regmap_gate_data){
  1910. .offset = CLKCTRL_VAPBCLK_CTRL,
  1911. .bit_idx = 8,
  1912. },
  1913. .hw.init = &(struct clk_init_data) {
  1914. .name = "vapb_0",
  1915. .ops = &clk_regmap_gate_ops,
  1916. .parent_hws = (const struct clk_hw *[]) {
  1917. &s4_vapb_0_div.hw
  1918. },
  1919. .num_parents = 1,
  1920. .flags = CLK_SET_RATE_PARENT,
  1921. },
  1922. };
  1923. static struct clk_regmap s4_vapb_1_sel = {
  1924. .data = &(struct clk_regmap_mux_data){
  1925. .offset = CLKCTRL_VAPBCLK_CTRL,
  1926. .mask = 0x7,
  1927. .shift = 25,
  1928. },
  1929. .hw.init = &(struct clk_init_data){
  1930. .name = "vapb_1_sel",
  1931. .ops = &clk_regmap_mux_ops,
  1932. .parent_data = s4_vapb_parent_data,
  1933. .num_parents = ARRAY_SIZE(s4_vapb_parent_data),
  1934. .flags = 0,
  1935. },
  1936. };
  1937. static struct clk_regmap s4_vapb_1_div = {
  1938. .data = &(struct clk_regmap_div_data){
  1939. .offset = CLKCTRL_VAPBCLK_CTRL,
  1940. .shift = 16,
  1941. .width = 7,
  1942. },
  1943. .hw.init = &(struct clk_init_data){
  1944. .name = "vapb_1_div",
  1945. .ops = &clk_regmap_divider_ops,
  1946. .parent_hws = (const struct clk_hw *[]) {
  1947. &s4_vapb_1_sel.hw
  1948. },
  1949. .num_parents = 1,
  1950. .flags = CLK_SET_RATE_PARENT,
  1951. },
  1952. };
  1953. static struct clk_regmap s4_vapb_1 = {
  1954. .data = &(struct clk_regmap_gate_data){
  1955. .offset = CLKCTRL_VAPBCLK_CTRL,
  1956. .bit_idx = 24,
  1957. },
  1958. .hw.init = &(struct clk_init_data) {
  1959. .name = "vapb_1",
  1960. .ops = &clk_regmap_gate_ops,
  1961. .parent_hws = (const struct clk_hw *[]) {
  1962. &s4_vapb_1_div.hw
  1963. },
  1964. .num_parents = 1,
  1965. .flags = CLK_SET_RATE_PARENT,
  1966. },
  1967. };
  1968. static struct clk_regmap s4_vapb = {
  1969. .data = &(struct clk_regmap_mux_data){
  1970. .offset = CLKCTRL_VAPBCLK_CTRL,
  1971. .mask = 1,
  1972. .shift = 31,
  1973. },
  1974. .hw.init = &(struct clk_init_data){
  1975. .name = "vapb_sel",
  1976. .ops = &clk_regmap_mux_ops,
  1977. .parent_hws = (const struct clk_hw *[]) {
  1978. &s4_vapb_0.hw,
  1979. &s4_vapb_1.hw
  1980. },
  1981. .num_parents = 2,
  1982. .flags = CLK_SET_RATE_PARENT,
  1983. },
  1984. };
  1985. static struct clk_regmap s4_ge2d_gate = {
  1986. .data = &(struct clk_regmap_gate_data){
  1987. .offset = CLKCTRL_VAPBCLK_CTRL,
  1988. .bit_idx = 30,
  1989. },
  1990. .hw.init = &(struct clk_init_data) {
  1991. .name = "ge2d_clk",
  1992. .ops = &clk_regmap_gate_ops,
  1993. .parent_hws = (const struct clk_hw *[]) { &s4_vapb.hw },
  1994. .num_parents = 1,
  1995. .flags = CLK_SET_RATE_PARENT,
  1996. },
  1997. };
  1998. static const struct clk_parent_data s4_esmclk_parent_data[] = {
  1999. { .fw_name = "fclk_div7", },
  2000. { .fw_name = "fclk_div4", },
  2001. { .fw_name = "fclk_div3", },
  2002. { .fw_name = "fclk_div5", },
  2003. };
  2004. static struct clk_regmap s4_hdcp22_esmclk_mux = {
  2005. .data = &(struct clk_regmap_mux_data){
  2006. .offset = CLKCTRL_HDCP22_CTRL,
  2007. .mask = 0x3,
  2008. .shift = 9,
  2009. },
  2010. .hw.init = &(struct clk_init_data) {
  2011. .name = "hdcp22_esmclk_mux",
  2012. .ops = &clk_regmap_mux_ops,
  2013. .parent_data = s4_esmclk_parent_data,
  2014. .num_parents = ARRAY_SIZE(s4_esmclk_parent_data),
  2015. .flags = CLK_SET_RATE_PARENT,
  2016. },
  2017. };
  2018. static struct clk_regmap s4_hdcp22_esmclk_div = {
  2019. .data = &(struct clk_regmap_div_data){
  2020. .offset = CLKCTRL_HDCP22_CTRL,
  2021. .shift = 0,
  2022. .width = 7,
  2023. },
  2024. .hw.init = &(struct clk_init_data) {
  2025. .name = "hdcp22_esmclk_div",
  2026. .ops = &clk_regmap_divider_ops,
  2027. .parent_hws = (const struct clk_hw *[]) {
  2028. &s4_hdcp22_esmclk_mux.hw
  2029. },
  2030. .num_parents = 1,
  2031. .flags = CLK_SET_RATE_PARENT,
  2032. },
  2033. };
  2034. static struct clk_regmap s4_hdcp22_esmclk_gate = {
  2035. .data = &(struct clk_regmap_gate_data){
  2036. .offset = CLKCTRL_HDCP22_CTRL,
  2037. .bit_idx = 8,
  2038. },
  2039. .hw.init = &(struct clk_init_data){
  2040. .name = "hdcp22_esmclk_gate",
  2041. .ops = &clk_regmap_gate_ops,
  2042. .parent_hws = (const struct clk_hw *[]) {
  2043. &s4_hdcp22_esmclk_div.hw
  2044. },
  2045. .num_parents = 1,
  2046. .flags = CLK_SET_RATE_PARENT,
  2047. },
  2048. };
  2049. static const struct clk_parent_data s4_skpclk_parent_data[] = {
  2050. { .fw_name = "xtal", },
  2051. { .fw_name = "fclk_div4", },
  2052. { .fw_name = "fclk_div3", },
  2053. { .fw_name = "fclk_div5", },
  2054. };
  2055. static struct clk_regmap s4_hdcp22_skpclk_mux = {
  2056. .data = &(struct clk_regmap_mux_data){
  2057. .offset = CLKCTRL_HDCP22_CTRL,
  2058. .mask = 0x3,
  2059. .shift = 25,
  2060. },
  2061. .hw.init = &(struct clk_init_data) {
  2062. .name = "hdcp22_skpclk_mux",
  2063. .ops = &clk_regmap_mux_ops,
  2064. .parent_data = s4_skpclk_parent_data,
  2065. .num_parents = ARRAY_SIZE(s4_skpclk_parent_data),
  2066. .flags = CLK_SET_RATE_PARENT,
  2067. },
  2068. };
  2069. static struct clk_regmap s4_hdcp22_skpclk_div = {
  2070. .data = &(struct clk_regmap_div_data){
  2071. .offset = CLKCTRL_HDCP22_CTRL,
  2072. .shift = 16,
  2073. .width = 7,
  2074. },
  2075. .hw.init = &(struct clk_init_data) {
  2076. .name = "hdcp22_skpclk_div",
  2077. .ops = &clk_regmap_divider_ops,
  2078. .parent_hws = (const struct clk_hw *[]) {
  2079. &s4_hdcp22_skpclk_mux.hw
  2080. },
  2081. .num_parents = 1,
  2082. .flags = CLK_SET_RATE_PARENT,
  2083. },
  2084. };
  2085. static struct clk_regmap s4_hdcp22_skpclk_gate = {
  2086. .data = &(struct clk_regmap_gate_data){
  2087. .offset = CLKCTRL_HDCP22_CTRL,
  2088. .bit_idx = 24,
  2089. },
  2090. .hw.init = &(struct clk_init_data){
  2091. .name = "hdcp22_skpclk_gate",
  2092. .ops = &clk_regmap_gate_ops,
  2093. .parent_hws = (const struct clk_hw *[]) {
  2094. &s4_hdcp22_skpclk_div.hw
  2095. },
  2096. .num_parents = 1,
  2097. .flags = CLK_SET_RATE_PARENT,
  2098. },
  2099. };
  2100. static const struct clk_parent_data s4_vdin_parent_data[] = {
  2101. { .fw_name = "xtal", },
  2102. { .fw_name = "fclk_div4", },
  2103. { .fw_name = "fclk_div3", },
  2104. { .fw_name = "fclk_div5", },
  2105. { .hw = &s4_vid_pll.hw }
  2106. };
  2107. static struct clk_regmap s4_vdin_meas_mux = {
  2108. .data = &(struct clk_regmap_mux_data){
  2109. .offset = CLKCTRL_VDIN_MEAS_CLK_CTRL,
  2110. .mask = 0x7,
  2111. .shift = 9,
  2112. },
  2113. .hw.init = &(struct clk_init_data) {
  2114. .name = "vdin_meas_mux",
  2115. .ops = &clk_regmap_mux_ops,
  2116. .parent_data = s4_vdin_parent_data,
  2117. .num_parents = ARRAY_SIZE(s4_vdin_parent_data),
  2118. .flags = CLK_SET_RATE_PARENT,
  2119. },
  2120. };
  2121. static struct clk_regmap s4_vdin_meas_div = {
  2122. .data = &(struct clk_regmap_div_data){
  2123. .offset = CLKCTRL_VDIN_MEAS_CLK_CTRL,
  2124. .shift = 0,
  2125. .width = 7,
  2126. },
  2127. .hw.init = &(struct clk_init_data) {
  2128. .name = "vdin_meas_div",
  2129. .ops = &clk_regmap_divider_ops,
  2130. .parent_hws = (const struct clk_hw *[]) {
  2131. &s4_vdin_meas_mux.hw
  2132. },
  2133. .num_parents = 1,
  2134. .flags = CLK_SET_RATE_PARENT,
  2135. },
  2136. };
  2137. static struct clk_regmap s4_vdin_meas_gate = {
  2138. .data = &(struct clk_regmap_gate_data){
  2139. .offset = CLKCTRL_VDIN_MEAS_CLK_CTRL,
  2140. .bit_idx = 8,
  2141. },
  2142. .hw.init = &(struct clk_init_data){
  2143. .name = "vdin_meas_gate",
  2144. .ops = &clk_regmap_gate_ops,
  2145. .parent_hws = (const struct clk_hw *[]) {
  2146. &s4_vdin_meas_div.hw
  2147. },
  2148. .num_parents = 1,
  2149. .flags = CLK_SET_RATE_PARENT,
  2150. },
  2151. };
  2152. /* EMMC/NAND clock */
  2153. static const struct clk_parent_data s4_sd_emmc_clk0_parent_data[] = {
  2154. { .fw_name = "xtal", },
  2155. { .fw_name = "fclk_div2", },
  2156. { .fw_name = "fclk_div3", },
  2157. { .fw_name = "hifi_pll", },
  2158. { .fw_name = "fclk_div2p5", },
  2159. { .fw_name = "mpll2", },
  2160. { .fw_name = "mpll3", },
  2161. { .fw_name = "gp0_pll", },
  2162. };
  2163. static struct clk_regmap s4_sd_emmc_c_clk0_sel = {
  2164. .data = &(struct clk_regmap_mux_data){
  2165. .offset = CLKCTRL_NAND_CLK_CTRL,
  2166. .mask = 0x7,
  2167. .shift = 9,
  2168. },
  2169. .hw.init = &(struct clk_init_data) {
  2170. .name = "sd_emmc_c_clk0_sel",
  2171. .ops = &clk_regmap_mux_ops,
  2172. .parent_data = s4_sd_emmc_clk0_parent_data,
  2173. .num_parents = ARRAY_SIZE(s4_sd_emmc_clk0_parent_data),
  2174. .flags = 0,
  2175. },
  2176. };
  2177. static struct clk_regmap s4_sd_emmc_c_clk0_div = {
  2178. .data = &(struct clk_regmap_div_data){
  2179. .offset = CLKCTRL_NAND_CLK_CTRL,
  2180. .shift = 0,
  2181. .width = 7,
  2182. },
  2183. .hw.init = &(struct clk_init_data) {
  2184. .name = "sd_emmc_c_clk0_div",
  2185. .ops = &clk_regmap_divider_ops,
  2186. .parent_hws = (const struct clk_hw *[]) {
  2187. &s4_sd_emmc_c_clk0_sel.hw
  2188. },
  2189. .num_parents = 1,
  2190. .flags = CLK_SET_RATE_PARENT,
  2191. },
  2192. };
  2193. static struct clk_regmap s4_sd_emmc_c_clk0 = {
  2194. .data = &(struct clk_regmap_gate_data){
  2195. .offset = CLKCTRL_NAND_CLK_CTRL,
  2196. .bit_idx = 7,
  2197. },
  2198. .hw.init = &(struct clk_init_data){
  2199. .name = "sd_emmc_c_clk0",
  2200. .ops = &clk_regmap_gate_ops,
  2201. .parent_hws = (const struct clk_hw *[]) {
  2202. &s4_sd_emmc_c_clk0_div.hw
  2203. },
  2204. .num_parents = 1,
  2205. .flags = CLK_SET_RATE_PARENT,
  2206. },
  2207. };
  2208. static struct clk_regmap s4_sd_emmc_a_clk0_sel = {
  2209. .data = &(struct clk_regmap_mux_data){
  2210. .offset = CLKCTRL_SD_EMMC_CLK_CTRL,
  2211. .mask = 0x7,
  2212. .shift = 9,
  2213. },
  2214. .hw.init = &(struct clk_init_data) {
  2215. .name = "sd_emmc_a_clk0_sel",
  2216. .ops = &clk_regmap_mux_ops,
  2217. .parent_data = s4_sd_emmc_clk0_parent_data,
  2218. .num_parents = ARRAY_SIZE(s4_sd_emmc_clk0_parent_data),
  2219. .flags = 0,
  2220. },
  2221. };
  2222. static struct clk_regmap s4_sd_emmc_a_clk0_div = {
  2223. .data = &(struct clk_regmap_div_data){
  2224. .offset = CLKCTRL_SD_EMMC_CLK_CTRL,
  2225. .shift = 0,
  2226. .width = 7,
  2227. },
  2228. .hw.init = &(struct clk_init_data) {
  2229. .name = "sd_emmc_a_clk0_div",
  2230. .ops = &clk_regmap_divider_ops,
  2231. .parent_hws = (const struct clk_hw *[]) {
  2232. &s4_sd_emmc_a_clk0_sel.hw
  2233. },
  2234. .num_parents = 1,
  2235. .flags = CLK_SET_RATE_PARENT,
  2236. },
  2237. };
  2238. static struct clk_regmap s4_sd_emmc_a_clk0 = {
  2239. .data = &(struct clk_regmap_gate_data){
  2240. .offset = CLKCTRL_SD_EMMC_CLK_CTRL,
  2241. .bit_idx = 7,
  2242. },
  2243. .hw.init = &(struct clk_init_data){
  2244. .name = "sd_emmc_a_clk0",
  2245. .ops = &clk_regmap_gate_ops,
  2246. .parent_hws = (const struct clk_hw *[]) {
  2247. &s4_sd_emmc_a_clk0_div.hw
  2248. },
  2249. .num_parents = 1,
  2250. .flags = CLK_SET_RATE_PARENT,
  2251. },
  2252. };
  2253. static struct clk_regmap s4_sd_emmc_b_clk0_sel = {
  2254. .data = &(struct clk_regmap_mux_data){
  2255. .offset = CLKCTRL_SD_EMMC_CLK_CTRL,
  2256. .mask = 0x7,
  2257. .shift = 25,
  2258. },
  2259. .hw.init = &(struct clk_init_data) {
  2260. .name = "sd_emmc_b_clk0_sel",
  2261. .ops = &clk_regmap_mux_ops,
  2262. .parent_data = s4_sd_emmc_clk0_parent_data,
  2263. .num_parents = ARRAY_SIZE(s4_sd_emmc_clk0_parent_data),
  2264. .flags = 0,
  2265. },
  2266. };
  2267. static struct clk_regmap s4_sd_emmc_b_clk0_div = {
  2268. .data = &(struct clk_regmap_div_data){
  2269. .offset = CLKCTRL_SD_EMMC_CLK_CTRL,
  2270. .shift = 16,
  2271. .width = 7,
  2272. },
  2273. .hw.init = &(struct clk_init_data) {
  2274. .name = "sd_emmc_b_clk0_div",
  2275. .ops = &clk_regmap_divider_ops,
  2276. .parent_hws = (const struct clk_hw *[]) {
  2277. &s4_sd_emmc_b_clk0_sel.hw
  2278. },
  2279. .num_parents = 1,
  2280. .flags = CLK_SET_RATE_PARENT,
  2281. },
  2282. };
  2283. static struct clk_regmap s4_sd_emmc_b_clk0 = {
  2284. .data = &(struct clk_regmap_gate_data){
  2285. .offset = CLKCTRL_SD_EMMC_CLK_CTRL,
  2286. .bit_idx = 23,
  2287. },
  2288. .hw.init = &(struct clk_init_data){
  2289. .name = "sd_emmc_b_clk0",
  2290. .ops = &clk_regmap_gate_ops,
  2291. .parent_hws = (const struct clk_hw *[]) {
  2292. &s4_sd_emmc_b_clk0_div.hw
  2293. },
  2294. .num_parents = 1,
  2295. .flags = CLK_SET_RATE_PARENT,
  2296. },
  2297. };
  2298. /* SPICC Clock */
  2299. static const struct clk_parent_data s4_spicc_parent_data[] = {
  2300. { .fw_name = "xtal", },
  2301. { .hw = &s4_sys_clk.hw },
  2302. { .fw_name = "fclk_div4", },
  2303. { .fw_name = "fclk_div3", },
  2304. { .fw_name = "fclk_div2", },
  2305. { .fw_name = "fclk_div5", },
  2306. { .fw_name = "fclk_div7", },
  2307. };
  2308. static struct clk_regmap s4_spicc0_mux = {
  2309. .data = &(struct clk_regmap_mux_data){
  2310. .offset = CLKCTRL_SPICC_CLK_CTRL,
  2311. .mask = 0x7,
  2312. .shift = 7,
  2313. },
  2314. .hw.init = &(struct clk_init_data) {
  2315. .name = "spicc0_mux",
  2316. .ops = &clk_regmap_mux_ops,
  2317. .parent_data = s4_spicc_parent_data,
  2318. .num_parents = ARRAY_SIZE(s4_spicc_parent_data),
  2319. .flags = CLK_SET_RATE_PARENT,
  2320. },
  2321. };
  2322. static struct clk_regmap s4_spicc0_div = {
  2323. .data = &(struct clk_regmap_div_data){
  2324. .offset = CLKCTRL_SPICC_CLK_CTRL,
  2325. .shift = 0,
  2326. .width = 6,
  2327. },
  2328. .hw.init = &(struct clk_init_data) {
  2329. .name = "spicc0_div",
  2330. .ops = &clk_regmap_divider_ops,
  2331. .parent_hws = (const struct clk_hw *[]) {
  2332. &s4_spicc0_mux.hw
  2333. },
  2334. .num_parents = 1,
  2335. .flags = CLK_SET_RATE_PARENT,
  2336. },
  2337. };
  2338. static struct clk_regmap s4_spicc0_gate = {
  2339. .data = &(struct clk_regmap_gate_data){
  2340. .offset = CLKCTRL_SPICC_CLK_CTRL,
  2341. .bit_idx = 6,
  2342. },
  2343. .hw.init = &(struct clk_init_data){
  2344. .name = "spicc0",
  2345. .ops = &clk_regmap_gate_ops,
  2346. .parent_hws = (const struct clk_hw *[]) {
  2347. &s4_spicc0_div.hw
  2348. },
  2349. .num_parents = 1,
  2350. .flags = CLK_SET_RATE_PARENT,
  2351. },
  2352. };
  2353. /* PWM Clock */
  2354. static const struct clk_parent_data s4_pwm_parent_data[] = {
  2355. { .fw_name = "xtal", },
  2356. { .hw = &s4_vid_pll.hw },
  2357. { .fw_name = "fclk_div4", },
  2358. { .fw_name = "fclk_div3", },
  2359. };
  2360. static struct clk_regmap s4_pwm_a_mux = {
  2361. .data = &(struct clk_regmap_mux_data) {
  2362. .offset = CLKCTRL_PWM_CLK_AB_CTRL,
  2363. .mask = 0x3,
  2364. .shift = 9,
  2365. },
  2366. .hw.init = &(struct clk_init_data){
  2367. .name = "pwm_a_mux",
  2368. .ops = &clk_regmap_mux_ops,
  2369. .parent_data = s4_pwm_parent_data,
  2370. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2371. .flags = 0,
  2372. },
  2373. };
  2374. static struct clk_regmap s4_pwm_a_div = {
  2375. .data = &(struct clk_regmap_div_data) {
  2376. .offset = CLKCTRL_PWM_CLK_AB_CTRL,
  2377. .shift = 0,
  2378. .width = 8,
  2379. },
  2380. .hw.init = &(struct clk_init_data){
  2381. .name = "pwm_a_div",
  2382. .ops = &clk_regmap_divider_ops,
  2383. .parent_hws = (const struct clk_hw *[]) {
  2384. &s4_pwm_a_mux.hw
  2385. },
  2386. .num_parents = 1,
  2387. .flags = CLK_SET_RATE_PARENT,
  2388. },
  2389. };
  2390. static struct clk_regmap s4_pwm_a_gate = {
  2391. .data = &(struct clk_regmap_gate_data) {
  2392. .offset = CLKCTRL_PWM_CLK_AB_CTRL,
  2393. .bit_idx = 8,
  2394. },
  2395. .hw.init = &(struct clk_init_data){
  2396. .name = "pwm_a_gate",
  2397. .ops = &clk_regmap_gate_ops,
  2398. .parent_hws = (const struct clk_hw *[]) {
  2399. &s4_pwm_a_div.hw
  2400. },
  2401. .num_parents = 1,
  2402. .flags = CLK_SET_RATE_PARENT,
  2403. },
  2404. };
  2405. static struct clk_regmap s4_pwm_b_mux = {
  2406. .data = &(struct clk_regmap_mux_data) {
  2407. .offset = CLKCTRL_PWM_CLK_AB_CTRL,
  2408. .mask = 0x3,
  2409. .shift = 25,
  2410. },
  2411. .hw.init = &(struct clk_init_data){
  2412. .name = "pwm_b_mux",
  2413. .ops = &clk_regmap_mux_ops,
  2414. .parent_data = s4_pwm_parent_data,
  2415. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2416. .flags = 0,
  2417. },
  2418. };
  2419. static struct clk_regmap s4_pwm_b_div = {
  2420. .data = &(struct clk_regmap_div_data) {
  2421. .offset = CLKCTRL_PWM_CLK_AB_CTRL,
  2422. .shift = 16,
  2423. .width = 8,
  2424. },
  2425. .hw.init = &(struct clk_init_data){
  2426. .name = "pwm_b_div",
  2427. .ops = &clk_regmap_divider_ops,
  2428. .parent_hws = (const struct clk_hw *[]) {
  2429. &s4_pwm_b_mux.hw
  2430. },
  2431. .num_parents = 1,
  2432. .flags = CLK_SET_RATE_PARENT,
  2433. },
  2434. };
  2435. static struct clk_regmap s4_pwm_b_gate = {
  2436. .data = &(struct clk_regmap_gate_data) {
  2437. .offset = CLKCTRL_PWM_CLK_AB_CTRL,
  2438. .bit_idx = 24,
  2439. },
  2440. .hw.init = &(struct clk_init_data){
  2441. .name = "pwm_b_gate",
  2442. .ops = &clk_regmap_gate_ops,
  2443. .parent_hws = (const struct clk_hw *[]) {
  2444. &s4_pwm_b_div.hw
  2445. },
  2446. .num_parents = 1,
  2447. .flags = CLK_SET_RATE_PARENT,
  2448. },
  2449. };
  2450. static struct clk_regmap s4_pwm_c_mux = {
  2451. .data = &(struct clk_regmap_mux_data) {
  2452. .offset = CLKCTRL_PWM_CLK_CD_CTRL,
  2453. .mask = 0x3,
  2454. .shift = 9,
  2455. },
  2456. .hw.init = &(struct clk_init_data){
  2457. .name = "pwm_c_mux",
  2458. .ops = &clk_regmap_mux_ops,
  2459. .parent_data = s4_pwm_parent_data,
  2460. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2461. .flags = 0,
  2462. },
  2463. };
  2464. static struct clk_regmap s4_pwm_c_div = {
  2465. .data = &(struct clk_regmap_div_data) {
  2466. .offset = CLKCTRL_PWM_CLK_CD_CTRL,
  2467. .shift = 0,
  2468. .width = 8,
  2469. },
  2470. .hw.init = &(struct clk_init_data){
  2471. .name = "pwm_c_div",
  2472. .ops = &clk_regmap_divider_ops,
  2473. .parent_hws = (const struct clk_hw *[]) {
  2474. &s4_pwm_c_mux.hw
  2475. },
  2476. .num_parents = 1,
  2477. },
  2478. };
  2479. static struct clk_regmap s4_pwm_c_gate = {
  2480. .data = &(struct clk_regmap_gate_data) {
  2481. .offset = CLKCTRL_PWM_CLK_CD_CTRL,
  2482. .bit_idx = 8,
  2483. },
  2484. .hw.init = &(struct clk_init_data){
  2485. .name = "pwm_c_gate",
  2486. .ops = &clk_regmap_gate_ops,
  2487. .parent_hws = (const struct clk_hw *[]) {
  2488. &s4_pwm_c_div.hw
  2489. },
  2490. .num_parents = 1,
  2491. .flags = CLK_SET_RATE_PARENT,
  2492. },
  2493. };
  2494. static struct clk_regmap s4_pwm_d_mux = {
  2495. .data = &(struct clk_regmap_mux_data) {
  2496. .offset = CLKCTRL_PWM_CLK_CD_CTRL,
  2497. .mask = 0x3,
  2498. .shift = 25,
  2499. },
  2500. .hw.init = &(struct clk_init_data){
  2501. .name = "pwm_d_mux",
  2502. .ops = &clk_regmap_mux_ops,
  2503. .parent_data = s4_pwm_parent_data,
  2504. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2505. .flags = 0,
  2506. },
  2507. };
  2508. static struct clk_regmap s4_pwm_d_div = {
  2509. .data = &(struct clk_regmap_div_data) {
  2510. .offset = CLKCTRL_PWM_CLK_CD_CTRL,
  2511. .shift = 16,
  2512. .width = 8,
  2513. },
  2514. .hw.init = &(struct clk_init_data){
  2515. .name = "pwm_d_div",
  2516. .ops = &clk_regmap_divider_ops,
  2517. .parent_hws = (const struct clk_hw *[]) {
  2518. &s4_pwm_d_mux.hw
  2519. },
  2520. .num_parents = 1,
  2521. .flags = CLK_SET_RATE_PARENT,
  2522. },
  2523. };
  2524. static struct clk_regmap s4_pwm_d_gate = {
  2525. .data = &(struct clk_regmap_gate_data) {
  2526. .offset = CLKCTRL_PWM_CLK_CD_CTRL,
  2527. .bit_idx = 24,
  2528. },
  2529. .hw.init = &(struct clk_init_data){
  2530. .name = "pwm_d_gate",
  2531. .ops = &clk_regmap_gate_ops,
  2532. .parent_hws = (const struct clk_hw *[]) {
  2533. &s4_pwm_d_div.hw
  2534. },
  2535. .num_parents = 1,
  2536. .flags = CLK_SET_RATE_PARENT,
  2537. },
  2538. };
  2539. static struct clk_regmap s4_pwm_e_mux = {
  2540. .data = &(struct clk_regmap_mux_data) {
  2541. .offset = CLKCTRL_PWM_CLK_EF_CTRL,
  2542. .mask = 0x3,
  2543. .shift = 9,
  2544. },
  2545. .hw.init = &(struct clk_init_data){
  2546. .name = "pwm_e_mux",
  2547. .ops = &clk_regmap_mux_ops,
  2548. .parent_data = s4_pwm_parent_data,
  2549. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2550. .flags = 0,
  2551. },
  2552. };
  2553. static struct clk_regmap s4_pwm_e_div = {
  2554. .data = &(struct clk_regmap_div_data) {
  2555. .offset = CLKCTRL_PWM_CLK_EF_CTRL,
  2556. .shift = 0,
  2557. .width = 8,
  2558. },
  2559. .hw.init = &(struct clk_init_data){
  2560. .name = "pwm_e_div",
  2561. .ops = &clk_regmap_divider_ops,
  2562. .parent_hws = (const struct clk_hw *[]) {
  2563. &s4_pwm_e_mux.hw
  2564. },
  2565. .num_parents = 1,
  2566. .flags = CLK_SET_RATE_PARENT,
  2567. },
  2568. };
  2569. static struct clk_regmap s4_pwm_e_gate = {
  2570. .data = &(struct clk_regmap_gate_data) {
  2571. .offset = CLKCTRL_PWM_CLK_EF_CTRL,
  2572. .bit_idx = 8,
  2573. },
  2574. .hw.init = &(struct clk_init_data){
  2575. .name = "pwm_e_gate",
  2576. .ops = &clk_regmap_gate_ops,
  2577. .parent_hws = (const struct clk_hw *[]) {
  2578. &s4_pwm_e_div.hw
  2579. },
  2580. .num_parents = 1,
  2581. .flags = CLK_SET_RATE_PARENT,
  2582. },
  2583. };
  2584. static struct clk_regmap s4_pwm_f_mux = {
  2585. .data = &(struct clk_regmap_mux_data) {
  2586. .offset = CLKCTRL_PWM_CLK_EF_CTRL,
  2587. .mask = 0x3,
  2588. .shift = 25,
  2589. },
  2590. .hw.init = &(struct clk_init_data){
  2591. .name = "pwm_f_mux",
  2592. .ops = &clk_regmap_mux_ops,
  2593. .parent_data = s4_pwm_parent_data,
  2594. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2595. .flags = 0,
  2596. },
  2597. };
  2598. static struct clk_regmap s4_pwm_f_div = {
  2599. .data = &(struct clk_regmap_div_data) {
  2600. .offset = CLKCTRL_PWM_CLK_EF_CTRL,
  2601. .shift = 16,
  2602. .width = 8,
  2603. },
  2604. .hw.init = &(struct clk_init_data){
  2605. .name = "pwm_f_div",
  2606. .ops = &clk_regmap_divider_ops,
  2607. .parent_hws = (const struct clk_hw *[]) {
  2608. &s4_pwm_f_mux.hw
  2609. },
  2610. .num_parents = 1,
  2611. .flags = CLK_SET_RATE_PARENT,
  2612. },
  2613. };
  2614. static struct clk_regmap s4_pwm_f_gate = {
  2615. .data = &(struct clk_regmap_gate_data) {
  2616. .offset = CLKCTRL_PWM_CLK_EF_CTRL,
  2617. .bit_idx = 24,
  2618. },
  2619. .hw.init = &(struct clk_init_data){
  2620. .name = "pwm_f_gate",
  2621. .ops = &clk_regmap_gate_ops,
  2622. .parent_hws = (const struct clk_hw *[]) {
  2623. &s4_pwm_f_div.hw
  2624. },
  2625. .num_parents = 1,
  2626. .flags = CLK_SET_RATE_PARENT,
  2627. },
  2628. };
  2629. static struct clk_regmap s4_pwm_g_mux = {
  2630. .data = &(struct clk_regmap_mux_data) {
  2631. .offset = CLKCTRL_PWM_CLK_GH_CTRL,
  2632. .mask = 0x3,
  2633. .shift = 9,
  2634. },
  2635. .hw.init = &(struct clk_init_data){
  2636. .name = "pwm_g_mux",
  2637. .ops = &clk_regmap_mux_ops,
  2638. .parent_data = s4_pwm_parent_data,
  2639. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2640. .flags = 0,
  2641. },
  2642. };
  2643. static struct clk_regmap s4_pwm_g_div = {
  2644. .data = &(struct clk_regmap_div_data) {
  2645. .offset = CLKCTRL_PWM_CLK_GH_CTRL,
  2646. .shift = 0,
  2647. .width = 8,
  2648. },
  2649. .hw.init = &(struct clk_init_data){
  2650. .name = "pwm_g_div",
  2651. .ops = &clk_regmap_divider_ops,
  2652. .parent_hws = (const struct clk_hw *[]) {
  2653. &s4_pwm_g_mux.hw
  2654. },
  2655. .num_parents = 1,
  2656. .flags = CLK_SET_RATE_PARENT,
  2657. },
  2658. };
  2659. static struct clk_regmap s4_pwm_g_gate = {
  2660. .data = &(struct clk_regmap_gate_data) {
  2661. .offset = CLKCTRL_PWM_CLK_GH_CTRL,
  2662. .bit_idx = 8,
  2663. },
  2664. .hw.init = &(struct clk_init_data){
  2665. .name = "pwm_g_gate",
  2666. .ops = &clk_regmap_gate_ops,
  2667. .parent_hws = (const struct clk_hw *[]) {
  2668. &s4_pwm_g_div.hw
  2669. },
  2670. .num_parents = 1,
  2671. .flags = CLK_SET_RATE_PARENT,
  2672. },
  2673. };
  2674. static struct clk_regmap s4_pwm_h_mux = {
  2675. .data = &(struct clk_regmap_mux_data) {
  2676. .offset = CLKCTRL_PWM_CLK_GH_CTRL,
  2677. .mask = 0x3,
  2678. .shift = 25,
  2679. },
  2680. .hw.init = &(struct clk_init_data){
  2681. .name = "pwm_h_mux",
  2682. .ops = &clk_regmap_mux_ops,
  2683. .parent_data = s4_pwm_parent_data,
  2684. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2685. .flags = 0,
  2686. },
  2687. };
  2688. static struct clk_regmap s4_pwm_h_div = {
  2689. .data = &(struct clk_regmap_div_data) {
  2690. .offset = CLKCTRL_PWM_CLK_GH_CTRL,
  2691. .shift = 16,
  2692. .width = 8,
  2693. },
  2694. .hw.init = &(struct clk_init_data){
  2695. .name = "pwm_h_div",
  2696. .ops = &clk_regmap_divider_ops,
  2697. .parent_hws = (const struct clk_hw *[]) {
  2698. &s4_pwm_h_mux.hw
  2699. },
  2700. .num_parents = 1,
  2701. .flags = CLK_SET_RATE_PARENT,
  2702. },
  2703. };
  2704. static struct clk_regmap s4_pwm_h_gate = {
  2705. .data = &(struct clk_regmap_gate_data) {
  2706. .offset = CLKCTRL_PWM_CLK_GH_CTRL,
  2707. .bit_idx = 24,
  2708. },
  2709. .hw.init = &(struct clk_init_data){
  2710. .name = "pwm_h_gate",
  2711. .ops = &clk_regmap_gate_ops,
  2712. .parent_hws = (const struct clk_hw *[]) {
  2713. &s4_pwm_h_div.hw
  2714. },
  2715. .num_parents = 1,
  2716. .flags = CLK_SET_RATE_PARENT,
  2717. },
  2718. };
  2719. static struct clk_regmap s4_pwm_i_mux = {
  2720. .data = &(struct clk_regmap_mux_data) {
  2721. .offset = CLKCTRL_PWM_CLK_IJ_CTRL,
  2722. .mask = 0x3,
  2723. .shift = 9,
  2724. },
  2725. .hw.init = &(struct clk_init_data){
  2726. .name = "pwm_i_mux",
  2727. .ops = &clk_regmap_mux_ops,
  2728. .parent_data = s4_pwm_parent_data,
  2729. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2730. .flags = 0,
  2731. },
  2732. };
  2733. static struct clk_regmap s4_pwm_i_div = {
  2734. .data = &(struct clk_regmap_div_data) {
  2735. .offset = CLKCTRL_PWM_CLK_IJ_CTRL,
  2736. .shift = 0,
  2737. .width = 8,
  2738. },
  2739. .hw.init = &(struct clk_init_data){
  2740. .name = "pwm_i_div",
  2741. .ops = &clk_regmap_divider_ops,
  2742. .parent_hws = (const struct clk_hw *[]) {
  2743. &s4_pwm_i_mux.hw
  2744. },
  2745. .num_parents = 1,
  2746. .flags = CLK_SET_RATE_PARENT,
  2747. },
  2748. };
  2749. static struct clk_regmap s4_pwm_i_gate = {
  2750. .data = &(struct clk_regmap_gate_data) {
  2751. .offset = CLKCTRL_PWM_CLK_IJ_CTRL,
  2752. .bit_idx = 8,
  2753. },
  2754. .hw.init = &(struct clk_init_data){
  2755. .name = "pwm_i_gate",
  2756. .ops = &clk_regmap_gate_ops,
  2757. .parent_hws = (const struct clk_hw *[]) {
  2758. &s4_pwm_i_div.hw
  2759. },
  2760. .num_parents = 1,
  2761. .flags = CLK_SET_RATE_PARENT,
  2762. },
  2763. };
  2764. static struct clk_regmap s4_pwm_j_mux = {
  2765. .data = &(struct clk_regmap_mux_data) {
  2766. .offset = CLKCTRL_PWM_CLK_IJ_CTRL,
  2767. .mask = 0x3,
  2768. .shift = 25,
  2769. },
  2770. .hw.init = &(struct clk_init_data){
  2771. .name = "pwm_j_mux",
  2772. .ops = &clk_regmap_mux_ops,
  2773. .parent_data = s4_pwm_parent_data,
  2774. .num_parents = ARRAY_SIZE(s4_pwm_parent_data),
  2775. .flags = 0,
  2776. },
  2777. };
  2778. static struct clk_regmap s4_pwm_j_div = {
  2779. .data = &(struct clk_regmap_div_data) {
  2780. .offset = CLKCTRL_PWM_CLK_IJ_CTRL,
  2781. .shift = 16,
  2782. .width = 8,
  2783. },
  2784. .hw.init = &(struct clk_init_data){
  2785. .name = "pwm_j_div",
  2786. .ops = &clk_regmap_divider_ops,
  2787. .parent_hws = (const struct clk_hw *[]) {
  2788. &s4_pwm_j_mux.hw
  2789. },
  2790. .num_parents = 1,
  2791. .flags = CLK_SET_RATE_PARENT,
  2792. },
  2793. };
  2794. static struct clk_regmap s4_pwm_j_gate = {
  2795. .data = &(struct clk_regmap_gate_data) {
  2796. .offset = CLKCTRL_PWM_CLK_IJ_CTRL,
  2797. .bit_idx = 24,
  2798. },
  2799. .hw.init = &(struct clk_init_data){
  2800. .name = "pwm_j_gate",
  2801. .ops = &clk_regmap_gate_ops,
  2802. .parent_hws = (const struct clk_hw *[]) {
  2803. &s4_pwm_j_div.hw
  2804. },
  2805. .num_parents = 1,
  2806. .flags = CLK_SET_RATE_PARENT,
  2807. },
  2808. };
  2809. static struct clk_regmap s4_saradc_mux = {
  2810. .data = &(struct clk_regmap_mux_data) {
  2811. .offset = CLKCTRL_SAR_CLK_CTRL,
  2812. .mask = 0x3,
  2813. .shift = 9,
  2814. },
  2815. .hw.init = &(struct clk_init_data){
  2816. .name = "saradc_mux",
  2817. .ops = &clk_regmap_mux_ops,
  2818. .parent_data = (const struct clk_parent_data []) {
  2819. { .fw_name = "xtal", },
  2820. { .hw = &s4_sys_clk.hw },
  2821. },
  2822. .num_parents = 2,
  2823. .flags = CLK_SET_RATE_PARENT,
  2824. },
  2825. };
  2826. static struct clk_regmap s4_saradc_div = {
  2827. .data = &(struct clk_regmap_div_data) {
  2828. .offset = CLKCTRL_SAR_CLK_CTRL,
  2829. .shift = 0,
  2830. .width = 8,
  2831. },
  2832. .hw.init = &(struct clk_init_data){
  2833. .name = "saradc_div",
  2834. .ops = &clk_regmap_divider_ops,
  2835. .parent_hws = (const struct clk_hw *[]) {
  2836. &s4_saradc_mux.hw
  2837. },
  2838. .num_parents = 1,
  2839. .flags = CLK_SET_RATE_PARENT,
  2840. },
  2841. };
  2842. static struct clk_regmap s4_saradc_gate = {
  2843. .data = &(struct clk_regmap_gate_data) {
  2844. .offset = CLKCTRL_SAR_CLK_CTRL,
  2845. .bit_idx = 8,
  2846. },
  2847. .hw.init = &(struct clk_init_data){
  2848. .name = "saradc_clk",
  2849. .ops = &clk_regmap_gate_ops,
  2850. .parent_hws = (const struct clk_hw *[]) {
  2851. &s4_saradc_div.hw
  2852. },
  2853. .num_parents = 1,
  2854. .flags = CLK_SET_RATE_PARENT,
  2855. },
  2856. };
  2857. /*
  2858. * gen clk is designed for debug/monitor some internal clock quality. Some of the
  2859. * corresponding clock sources are not described in the clock tree and internal clock
  2860. * for debug, so they are skipped.
  2861. */
  2862. static u32 s4_gen_clk_mux_table[] = { 0, 4, 5, 7, 19, 21, 22,
  2863. 23, 24, 25, 26, 27, 28 };
  2864. static const struct clk_parent_data s4_gen_clk_parent_data[] = {
  2865. { .fw_name = "xtal", },
  2866. { .hw = &s4_vid_pll.hw },
  2867. { .fw_name = "gp0_pll", },
  2868. { .fw_name = "hifi_pll", },
  2869. { .fw_name = "fclk_div2", },
  2870. { .fw_name = "fclk_div3", },
  2871. { .fw_name = "fclk_div4", },
  2872. { .fw_name = "fclk_div5", },
  2873. { .fw_name = "fclk_div7", },
  2874. { .fw_name = "mpll0", },
  2875. { .fw_name = "mpll1", },
  2876. { .fw_name = "mpll2", },
  2877. { .fw_name = "mpll3", },
  2878. };
  2879. static struct clk_regmap s4_gen_clk_sel = {
  2880. .data = &(struct clk_regmap_mux_data){
  2881. .offset = CLKCTRL_GEN_CLK_CTRL,
  2882. .mask = 0x1f,
  2883. .shift = 12,
  2884. .table = s4_gen_clk_mux_table,
  2885. },
  2886. .hw.init = &(struct clk_init_data){
  2887. .name = "gen_clk_sel",
  2888. .ops = &clk_regmap_mux_ops,
  2889. .parent_data = s4_gen_clk_parent_data,
  2890. .num_parents = ARRAY_SIZE(s4_gen_clk_parent_data),
  2891. /*
  2892. * Because the GEN clock can be connected to an external pad
  2893. * and may be set up directly from the device tree. Don't
  2894. * really want to automatically reparent.
  2895. */
  2896. .flags = CLK_SET_RATE_NO_REPARENT,
  2897. },
  2898. };
  2899. static struct clk_regmap s4_gen_clk_div = {
  2900. .data = &(struct clk_regmap_div_data){
  2901. .offset = CLKCTRL_GEN_CLK_CTRL,
  2902. .shift = 0,
  2903. .width = 11,
  2904. },
  2905. .hw.init = &(struct clk_init_data){
  2906. .name = "gen_clk_div",
  2907. .ops = &clk_regmap_divider_ops,
  2908. .parent_hws = (const struct clk_hw *[]) {
  2909. &s4_gen_clk_sel.hw
  2910. },
  2911. .num_parents = 1,
  2912. .flags = CLK_SET_RATE_PARENT,
  2913. },
  2914. };
  2915. static struct clk_regmap s4_gen_clk = {
  2916. .data = &(struct clk_regmap_gate_data){
  2917. .offset = CLKCTRL_GEN_CLK_CTRL,
  2918. .bit_idx = 11,
  2919. },
  2920. .hw.init = &(struct clk_init_data) {
  2921. .name = "gen_clk",
  2922. .ops = &clk_regmap_gate_ops,
  2923. .parent_hws = (const struct clk_hw *[]) {
  2924. &s4_gen_clk_div.hw
  2925. },
  2926. .num_parents = 1,
  2927. .flags = CLK_SET_RATE_PARENT,
  2928. },
  2929. };
  2930. static const struct clk_parent_data s4_adc_extclk_in_parent_data[] = {
  2931. { .fw_name = "xtal", },
  2932. { .fw_name = "fclk_div4", },
  2933. { .fw_name = "fclk_div3", },
  2934. { .fw_name = "fclk_div5", },
  2935. { .fw_name = "fclk_div7", },
  2936. { .fw_name = "mpll2", },
  2937. { .fw_name = "gp0_pll", },
  2938. { .fw_name = "hifi_pll", },
  2939. };
  2940. static struct clk_regmap s4_adc_extclk_in_mux = {
  2941. .data = &(struct clk_regmap_mux_data) {
  2942. .offset = CLKCTRL_DEMOD_CLK_CTRL,
  2943. .mask = 0x7,
  2944. .shift = 25,
  2945. },
  2946. .hw.init = &(struct clk_init_data){
  2947. .name = "adc_extclk_in_mux",
  2948. .ops = &clk_regmap_mux_ops,
  2949. .parent_data = s4_adc_extclk_in_parent_data,
  2950. .num_parents = ARRAY_SIZE(s4_adc_extclk_in_parent_data),
  2951. .flags = 0,
  2952. },
  2953. };
  2954. static struct clk_regmap s4_adc_extclk_in_div = {
  2955. .data = &(struct clk_regmap_div_data) {
  2956. .offset = CLKCTRL_DEMOD_CLK_CTRL,
  2957. .shift = 16,
  2958. .width = 7,
  2959. },
  2960. .hw.init = &(struct clk_init_data){
  2961. .name = "adc_extclk_in_div",
  2962. .ops = &clk_regmap_divider_ops,
  2963. .parent_hws = (const struct clk_hw *[]) {
  2964. &s4_adc_extclk_in_mux.hw
  2965. },
  2966. .num_parents = 1,
  2967. .flags = CLK_SET_RATE_PARENT,
  2968. },
  2969. };
  2970. static struct clk_regmap s4_adc_extclk_in_gate = {
  2971. .data = &(struct clk_regmap_gate_data) {
  2972. .offset = CLKCTRL_DEMOD_CLK_CTRL,
  2973. .bit_idx = 24,
  2974. },
  2975. .hw.init = &(struct clk_init_data){
  2976. .name = "adc_extclk_in",
  2977. .ops = &clk_regmap_gate_ops,
  2978. .parent_hws = (const struct clk_hw *[]) {
  2979. &s4_adc_extclk_in_div.hw
  2980. },
  2981. .num_parents = 1,
  2982. .flags = CLK_SET_RATE_PARENT,
  2983. },
  2984. };
  2985. static struct clk_regmap s4_demod_core_clk_mux = {
  2986. .data = &(struct clk_regmap_mux_data) {
  2987. .offset = CLKCTRL_DEMOD_CLK_CTRL,
  2988. .mask = 0x3,
  2989. .shift = 9,
  2990. },
  2991. .hw.init = &(struct clk_init_data){
  2992. .name = "demod_core_clk_mux",
  2993. .ops = &clk_regmap_mux_ops,
  2994. .parent_data = (const struct clk_parent_data []) {
  2995. { .fw_name = "xtal", },
  2996. { .fw_name = "fclk_div7", },
  2997. { .fw_name = "fclk_div4", },
  2998. { .hw = &s4_adc_extclk_in_gate.hw }
  2999. },
  3000. .num_parents = 4,
  3001. .flags = CLK_SET_RATE_PARENT,
  3002. },
  3003. };
  3004. static struct clk_regmap s4_demod_core_clk_div = {
  3005. .data = &(struct clk_regmap_div_data) {
  3006. .offset = CLKCTRL_DEMOD_CLK_CTRL,
  3007. .shift = 0,
  3008. .width = 7,
  3009. },
  3010. .hw.init = &(struct clk_init_data){
  3011. .name = "demod_core_clk_div",
  3012. .ops = &clk_regmap_divider_ops,
  3013. .parent_hws = (const struct clk_hw *[]) {
  3014. &s4_demod_core_clk_mux.hw
  3015. },
  3016. .num_parents = 1,
  3017. .flags = CLK_SET_RATE_PARENT,
  3018. },
  3019. };
  3020. static struct clk_regmap s4_demod_core_clk_gate = {
  3021. .data = &(struct clk_regmap_gate_data) {
  3022. .offset = CLKCTRL_DEMOD_CLK_CTRL,
  3023. .bit_idx = 8,
  3024. },
  3025. .hw.init = &(struct clk_init_data){
  3026. .name = "demod_core_clk",
  3027. .ops = &clk_regmap_gate_ops,
  3028. .parent_hws = (const struct clk_hw *[]) {
  3029. &s4_demod_core_clk_div.hw
  3030. },
  3031. .num_parents = 1,
  3032. .flags = CLK_SET_RATE_PARENT,
  3033. },
  3034. };
  3035. #define MESON_GATE(_name, _reg, _bit) \
  3036. MESON_PCLK(_name, _reg, _bit, &s4_sys_clk.hw)
  3037. static MESON_GATE(s4_ddr, CLKCTRL_SYS_CLK_EN0_REG0, 0);
  3038. static MESON_GATE(s4_dos, CLKCTRL_SYS_CLK_EN0_REG0, 1);
  3039. static MESON_GATE(s4_ethphy, CLKCTRL_SYS_CLK_EN0_REG0, 4);
  3040. static MESON_GATE(s4_mali, CLKCTRL_SYS_CLK_EN0_REG0, 6);
  3041. static MESON_GATE(s4_aocpu, CLKCTRL_SYS_CLK_EN0_REG0, 13);
  3042. static MESON_GATE(s4_aucpu, CLKCTRL_SYS_CLK_EN0_REG0, 14);
  3043. static MESON_GATE(s4_cec, CLKCTRL_SYS_CLK_EN0_REG0, 16);
  3044. static MESON_GATE(s4_sdemmca, CLKCTRL_SYS_CLK_EN0_REG0, 24);
  3045. static MESON_GATE(s4_sdemmcb, CLKCTRL_SYS_CLK_EN0_REG0, 25);
  3046. static MESON_GATE(s4_nand, CLKCTRL_SYS_CLK_EN0_REG0, 26);
  3047. static MESON_GATE(s4_smartcard, CLKCTRL_SYS_CLK_EN0_REG0, 27);
  3048. static MESON_GATE(s4_acodec, CLKCTRL_SYS_CLK_EN0_REG0, 28);
  3049. static MESON_GATE(s4_spifc, CLKCTRL_SYS_CLK_EN0_REG0, 29);
  3050. static MESON_GATE(s4_msr_clk, CLKCTRL_SYS_CLK_EN0_REG0, 30);
  3051. static MESON_GATE(s4_ir_ctrl, CLKCTRL_SYS_CLK_EN0_REG0, 31);
  3052. static MESON_GATE(s4_audio, CLKCTRL_SYS_CLK_EN0_REG1, 0);
  3053. static MESON_GATE(s4_eth, CLKCTRL_SYS_CLK_EN0_REG1, 3);
  3054. static MESON_GATE(s4_uart_a, CLKCTRL_SYS_CLK_EN0_REG1, 5);
  3055. static MESON_GATE(s4_uart_b, CLKCTRL_SYS_CLK_EN0_REG1, 6);
  3056. static MESON_GATE(s4_uart_c, CLKCTRL_SYS_CLK_EN0_REG1, 7);
  3057. static MESON_GATE(s4_uart_d, CLKCTRL_SYS_CLK_EN0_REG1, 8);
  3058. static MESON_GATE(s4_uart_e, CLKCTRL_SYS_CLK_EN0_REG1, 9);
  3059. static MESON_GATE(s4_aififo, CLKCTRL_SYS_CLK_EN0_REG1, 11);
  3060. static MESON_GATE(s4_ts_ddr, CLKCTRL_SYS_CLK_EN0_REG1, 15);
  3061. static MESON_GATE(s4_ts_pll, CLKCTRL_SYS_CLK_EN0_REG1, 16);
  3062. static MESON_GATE(s4_g2d, CLKCTRL_SYS_CLK_EN0_REG1, 20);
  3063. static MESON_GATE(s4_spicc0, CLKCTRL_SYS_CLK_EN0_REG1, 21);
  3064. static MESON_GATE(s4_usb, CLKCTRL_SYS_CLK_EN0_REG1, 26);
  3065. static MESON_GATE(s4_i2c_m_a, CLKCTRL_SYS_CLK_EN0_REG1, 30);
  3066. static MESON_GATE(s4_i2c_m_b, CLKCTRL_SYS_CLK_EN0_REG1, 31);
  3067. static MESON_GATE(s4_i2c_m_c, CLKCTRL_SYS_CLK_EN0_REG2, 0);
  3068. static MESON_GATE(s4_i2c_m_d, CLKCTRL_SYS_CLK_EN0_REG2, 1);
  3069. static MESON_GATE(s4_i2c_m_e, CLKCTRL_SYS_CLK_EN0_REG2, 2);
  3070. static MESON_GATE(s4_hdmitx_apb, CLKCTRL_SYS_CLK_EN0_REG2, 4);
  3071. static MESON_GATE(s4_i2c_s_a, CLKCTRL_SYS_CLK_EN0_REG2, 5);
  3072. static MESON_GATE(s4_usb1_to_ddr, CLKCTRL_SYS_CLK_EN0_REG2, 8);
  3073. static MESON_GATE(s4_hdcp22, CLKCTRL_SYS_CLK_EN0_REG2, 10);
  3074. static MESON_GATE(s4_mmc_apb, CLKCTRL_SYS_CLK_EN0_REG2, 11);
  3075. static MESON_GATE(s4_rsa, CLKCTRL_SYS_CLK_EN0_REG2, 18);
  3076. static MESON_GATE(s4_cpu_debug, CLKCTRL_SYS_CLK_EN0_REG2, 19);
  3077. static MESON_GATE(s4_vpu_intr, CLKCTRL_SYS_CLK_EN0_REG2, 25);
  3078. static MESON_GATE(s4_demod, CLKCTRL_SYS_CLK_EN0_REG2, 27);
  3079. static MESON_GATE(s4_sar_adc, CLKCTRL_SYS_CLK_EN0_REG2, 28);
  3080. static MESON_GATE(s4_gic, CLKCTRL_SYS_CLK_EN0_REG2, 30);
  3081. static MESON_GATE(s4_pwm_ab, CLKCTRL_SYS_CLK_EN0_REG3, 7);
  3082. static MESON_GATE(s4_pwm_cd, CLKCTRL_SYS_CLK_EN0_REG3, 8);
  3083. static MESON_GATE(s4_pwm_ef, CLKCTRL_SYS_CLK_EN0_REG3, 9);
  3084. static MESON_GATE(s4_pwm_gh, CLKCTRL_SYS_CLK_EN0_REG3, 10);
  3085. static MESON_GATE(s4_pwm_ij, CLKCTRL_SYS_CLK_EN0_REG3, 11);
  3086. /* Array of all clocks provided by this provider */
  3087. static struct clk_hw *s4_periphs_hw_clks[] = {
  3088. [CLKID_RTC_32K_CLKIN] = &s4_rtc_32k_by_oscin_clkin.hw,
  3089. [CLKID_RTC_32K_DIV] = &s4_rtc_32k_by_oscin_div.hw,
  3090. [CLKID_RTC_32K_SEL] = &s4_rtc_32k_by_oscin_sel.hw,
  3091. [CLKID_RTC_32K_XATL] = &s4_rtc_32k_by_oscin.hw,
  3092. [CLKID_RTC] = &s4_rtc_clk.hw,
  3093. [CLKID_SYS_CLK_B_SEL] = &s4_sysclk_b_sel.hw,
  3094. [CLKID_SYS_CLK_B_DIV] = &s4_sysclk_b_div.hw,
  3095. [CLKID_SYS_CLK_B] = &s4_sysclk_b.hw,
  3096. [CLKID_SYS_CLK_A_SEL] = &s4_sysclk_a_sel.hw,
  3097. [CLKID_SYS_CLK_A_DIV] = &s4_sysclk_a_div.hw,
  3098. [CLKID_SYS_CLK_A] = &s4_sysclk_a.hw,
  3099. [CLKID_SYS] = &s4_sys_clk.hw,
  3100. [CLKID_CECA_32K_CLKIN] = &s4_ceca_32k_clkin.hw,
  3101. [CLKID_CECA_32K_DIV] = &s4_ceca_32k_div.hw,
  3102. [CLKID_CECA_32K_SEL_PRE] = &s4_ceca_32k_sel_pre.hw,
  3103. [CLKID_CECA_32K_SEL] = &s4_ceca_32k_sel.hw,
  3104. [CLKID_CECA_32K_CLKOUT] = &s4_ceca_32k_clkout.hw,
  3105. [CLKID_CECB_32K_CLKIN] = &s4_cecb_32k_clkin.hw,
  3106. [CLKID_CECB_32K_DIV] = &s4_cecb_32k_div.hw,
  3107. [CLKID_CECB_32K_SEL_PRE] = &s4_cecb_32k_sel_pre.hw,
  3108. [CLKID_CECB_32K_SEL] = &s4_cecb_32k_sel.hw,
  3109. [CLKID_CECB_32K_CLKOUT] = &s4_cecb_32k_clkout.hw,
  3110. [CLKID_SC_CLK_SEL] = &s4_sc_clk_mux.hw,
  3111. [CLKID_SC_CLK_DIV] = &s4_sc_clk_div.hw,
  3112. [CLKID_SC] = &s4_sc_clk_gate.hw,
  3113. [CLKID_12_24M] = &s4_12_24M_clk_gate.hw,
  3114. [CLKID_12M_CLK_DIV] = &s4_12M_clk_div.hw,
  3115. [CLKID_12_24M_CLK_SEL] = &s4_12_24M_clk.hw,
  3116. [CLKID_VID_PLL_DIV] = &s4_vid_pll_div.hw,
  3117. [CLKID_VID_PLL_SEL] = &s4_vid_pll_sel.hw,
  3118. [CLKID_VID_PLL] = &s4_vid_pll.hw,
  3119. [CLKID_VCLK_SEL] = &s4_vclk_sel.hw,
  3120. [CLKID_VCLK2_SEL] = &s4_vclk2_sel.hw,
  3121. [CLKID_VCLK_INPUT] = &s4_vclk_input.hw,
  3122. [CLKID_VCLK2_INPUT] = &s4_vclk2_input.hw,
  3123. [CLKID_VCLK_DIV] = &s4_vclk_div.hw,
  3124. [CLKID_VCLK2_DIV] = &s4_vclk2_div.hw,
  3125. [CLKID_VCLK] = &s4_vclk.hw,
  3126. [CLKID_VCLK2] = &s4_vclk2.hw,
  3127. [CLKID_VCLK_DIV1] = &s4_vclk_div1.hw,
  3128. [CLKID_VCLK_DIV2_EN] = &s4_vclk_div2_en.hw,
  3129. [CLKID_VCLK_DIV4_EN] = &s4_vclk_div4_en.hw,
  3130. [CLKID_VCLK_DIV6_EN] = &s4_vclk_div6_en.hw,
  3131. [CLKID_VCLK_DIV12_EN] = &s4_vclk_div12_en.hw,
  3132. [CLKID_VCLK2_DIV1] = &s4_vclk2_div1.hw,
  3133. [CLKID_VCLK2_DIV2_EN] = &s4_vclk2_div2_en.hw,
  3134. [CLKID_VCLK2_DIV4_EN] = &s4_vclk2_div4_en.hw,
  3135. [CLKID_VCLK2_DIV6_EN] = &s4_vclk2_div6_en.hw,
  3136. [CLKID_VCLK2_DIV12_EN] = &s4_vclk2_div12_en.hw,
  3137. [CLKID_VCLK_DIV2] = &s4_vclk_div2.hw,
  3138. [CLKID_VCLK_DIV4] = &s4_vclk_div4.hw,
  3139. [CLKID_VCLK_DIV6] = &s4_vclk_div6.hw,
  3140. [CLKID_VCLK_DIV12] = &s4_vclk_div12.hw,
  3141. [CLKID_VCLK2_DIV2] = &s4_vclk2_div2.hw,
  3142. [CLKID_VCLK2_DIV4] = &s4_vclk2_div4.hw,
  3143. [CLKID_VCLK2_DIV6] = &s4_vclk2_div6.hw,
  3144. [CLKID_VCLK2_DIV12] = &s4_vclk2_div12.hw,
  3145. [CLKID_CTS_ENCI_SEL] = &s4_cts_enci_sel.hw,
  3146. [CLKID_CTS_ENCP_SEL] = &s4_cts_encp_sel.hw,
  3147. [CLKID_CTS_VDAC_SEL] = &s4_cts_vdac_sel.hw,
  3148. [CLKID_HDMI_TX_SEL] = &s4_hdmi_tx_sel.hw,
  3149. [CLKID_CTS_ENCI] = &s4_cts_enci.hw,
  3150. [CLKID_CTS_ENCP] = &s4_cts_encp.hw,
  3151. [CLKID_CTS_VDAC] = &s4_cts_vdac.hw,
  3152. [CLKID_HDMI_TX] = &s4_hdmi_tx.hw,
  3153. [CLKID_HDMI_SEL] = &s4_hdmi_sel.hw,
  3154. [CLKID_HDMI_DIV] = &s4_hdmi_div.hw,
  3155. [CLKID_HDMI] = &s4_hdmi.hw,
  3156. [CLKID_TS_CLK_DIV] = &s4_ts_clk_div.hw,
  3157. [CLKID_TS] = &s4_ts_clk_gate.hw,
  3158. [CLKID_MALI_0_SEL] = &s4_mali_0_sel.hw,
  3159. [CLKID_MALI_0_DIV] = &s4_mali_0_div.hw,
  3160. [CLKID_MALI_0] = &s4_mali_0.hw,
  3161. [CLKID_MALI_1_SEL] = &s4_mali_1_sel.hw,
  3162. [CLKID_MALI_1_DIV] = &s4_mali_1_div.hw,
  3163. [CLKID_MALI_1] = &s4_mali_1.hw,
  3164. [CLKID_MALI_SEL] = &s4_mali_mux.hw,
  3165. [CLKID_VDEC_P0_SEL] = &s4_vdec_p0_mux.hw,
  3166. [CLKID_VDEC_P0_DIV] = &s4_vdec_p0_div.hw,
  3167. [CLKID_VDEC_P0] = &s4_vdec_p0.hw,
  3168. [CLKID_VDEC_P1_SEL] = &s4_vdec_p1_mux.hw,
  3169. [CLKID_VDEC_P1_DIV] = &s4_vdec_p1_div.hw,
  3170. [CLKID_VDEC_P1] = &s4_vdec_p1.hw,
  3171. [CLKID_VDEC_SEL] = &s4_vdec_mux.hw,
  3172. [CLKID_HEVCF_P0_SEL] = &s4_hevcf_p0_mux.hw,
  3173. [CLKID_HEVCF_P0_DIV] = &s4_hevcf_p0_div.hw,
  3174. [CLKID_HEVCF_P0] = &s4_hevcf_p0.hw,
  3175. [CLKID_HEVCF_P1_SEL] = &s4_hevcf_p1_mux.hw,
  3176. [CLKID_HEVCF_P1_DIV] = &s4_hevcf_p1_div.hw,
  3177. [CLKID_HEVCF_P1] = &s4_hevcf_p1.hw,
  3178. [CLKID_HEVCF_SEL] = &s4_hevcf_mux.hw,
  3179. [CLKID_VPU_0_SEL] = &s4_vpu_0_sel.hw,
  3180. [CLKID_VPU_0_DIV] = &s4_vpu_0_div.hw,
  3181. [CLKID_VPU_0] = &s4_vpu_0.hw,
  3182. [CLKID_VPU_1_SEL] = &s4_vpu_1_sel.hw,
  3183. [CLKID_VPU_1_DIV] = &s4_vpu_1_div.hw,
  3184. [CLKID_VPU_1] = &s4_vpu_1.hw,
  3185. [CLKID_VPU] = &s4_vpu.hw,
  3186. [CLKID_VPU_CLKB_TMP_SEL] = &s4_vpu_clkb_tmp_mux.hw,
  3187. [CLKID_VPU_CLKB_TMP_DIV] = &s4_vpu_clkb_tmp_div.hw,
  3188. [CLKID_VPU_CLKB_TMP] = &s4_vpu_clkb_tmp.hw,
  3189. [CLKID_VPU_CLKB_DIV] = &s4_vpu_clkb_div.hw,
  3190. [CLKID_VPU_CLKB] = &s4_vpu_clkb.hw,
  3191. [CLKID_VPU_CLKC_P0_SEL] = &s4_vpu_clkc_p0_mux.hw,
  3192. [CLKID_VPU_CLKC_P0_DIV] = &s4_vpu_clkc_p0_div.hw,
  3193. [CLKID_VPU_CLKC_P0] = &s4_vpu_clkc_p0.hw,
  3194. [CLKID_VPU_CLKC_P1_SEL] = &s4_vpu_clkc_p1_mux.hw,
  3195. [CLKID_VPU_CLKC_P1_DIV] = &s4_vpu_clkc_p1_div.hw,
  3196. [CLKID_VPU_CLKC_P1] = &s4_vpu_clkc_p1.hw,
  3197. [CLKID_VPU_CLKC_SEL] = &s4_vpu_clkc_mux.hw,
  3198. [CLKID_VAPB_0_SEL] = &s4_vapb_0_sel.hw,
  3199. [CLKID_VAPB_0_DIV] = &s4_vapb_0_div.hw,
  3200. [CLKID_VAPB_0] = &s4_vapb_0.hw,
  3201. [CLKID_VAPB_1_SEL] = &s4_vapb_1_sel.hw,
  3202. [CLKID_VAPB_1_DIV] = &s4_vapb_1_div.hw,
  3203. [CLKID_VAPB_1] = &s4_vapb_1.hw,
  3204. [CLKID_VAPB] = &s4_vapb.hw,
  3205. [CLKID_GE2D] = &s4_ge2d_gate.hw,
  3206. [CLKID_VDIN_MEAS_SEL] = &s4_vdin_meas_mux.hw,
  3207. [CLKID_VDIN_MEAS_DIV] = &s4_vdin_meas_div.hw,
  3208. [CLKID_VDIN_MEAS] = &s4_vdin_meas_gate.hw,
  3209. [CLKID_SD_EMMC_C_CLK_SEL] = &s4_sd_emmc_c_clk0_sel.hw,
  3210. [CLKID_SD_EMMC_C_CLK_DIV] = &s4_sd_emmc_c_clk0_div.hw,
  3211. [CLKID_SD_EMMC_C] = &s4_sd_emmc_c_clk0.hw,
  3212. [CLKID_SD_EMMC_A_CLK_SEL] = &s4_sd_emmc_a_clk0_sel.hw,
  3213. [CLKID_SD_EMMC_A_CLK_DIV] = &s4_sd_emmc_a_clk0_div.hw,
  3214. [CLKID_SD_EMMC_A] = &s4_sd_emmc_a_clk0.hw,
  3215. [CLKID_SD_EMMC_B_CLK_SEL] = &s4_sd_emmc_b_clk0_sel.hw,
  3216. [CLKID_SD_EMMC_B_CLK_DIV] = &s4_sd_emmc_b_clk0_div.hw,
  3217. [CLKID_SD_EMMC_B] = &s4_sd_emmc_b_clk0.hw,
  3218. [CLKID_SPICC0_SEL] = &s4_spicc0_mux.hw,
  3219. [CLKID_SPICC0_DIV] = &s4_spicc0_div.hw,
  3220. [CLKID_SPICC0_EN] = &s4_spicc0_gate.hw,
  3221. [CLKID_PWM_A_SEL] = &s4_pwm_a_mux.hw,
  3222. [CLKID_PWM_A_DIV] = &s4_pwm_a_div.hw,
  3223. [CLKID_PWM_A] = &s4_pwm_a_gate.hw,
  3224. [CLKID_PWM_B_SEL] = &s4_pwm_b_mux.hw,
  3225. [CLKID_PWM_B_DIV] = &s4_pwm_b_div.hw,
  3226. [CLKID_PWM_B] = &s4_pwm_b_gate.hw,
  3227. [CLKID_PWM_C_SEL] = &s4_pwm_c_mux.hw,
  3228. [CLKID_PWM_C_DIV] = &s4_pwm_c_div.hw,
  3229. [CLKID_PWM_C] = &s4_pwm_c_gate.hw,
  3230. [CLKID_PWM_D_SEL] = &s4_pwm_d_mux.hw,
  3231. [CLKID_PWM_D_DIV] = &s4_pwm_d_div.hw,
  3232. [CLKID_PWM_D] = &s4_pwm_d_gate.hw,
  3233. [CLKID_PWM_E_SEL] = &s4_pwm_e_mux.hw,
  3234. [CLKID_PWM_E_DIV] = &s4_pwm_e_div.hw,
  3235. [CLKID_PWM_E] = &s4_pwm_e_gate.hw,
  3236. [CLKID_PWM_F_SEL] = &s4_pwm_f_mux.hw,
  3237. [CLKID_PWM_F_DIV] = &s4_pwm_f_div.hw,
  3238. [CLKID_PWM_F] = &s4_pwm_f_gate.hw,
  3239. [CLKID_PWM_G_SEL] = &s4_pwm_g_mux.hw,
  3240. [CLKID_PWM_G_DIV] = &s4_pwm_g_div.hw,
  3241. [CLKID_PWM_G] = &s4_pwm_g_gate.hw,
  3242. [CLKID_PWM_H_SEL] = &s4_pwm_h_mux.hw,
  3243. [CLKID_PWM_H_DIV] = &s4_pwm_h_div.hw,
  3244. [CLKID_PWM_H] = &s4_pwm_h_gate.hw,
  3245. [CLKID_PWM_I_SEL] = &s4_pwm_i_mux.hw,
  3246. [CLKID_PWM_I_DIV] = &s4_pwm_i_div.hw,
  3247. [CLKID_PWM_I] = &s4_pwm_i_gate.hw,
  3248. [CLKID_PWM_J_SEL] = &s4_pwm_j_mux.hw,
  3249. [CLKID_PWM_J_DIV] = &s4_pwm_j_div.hw,
  3250. [CLKID_PWM_J] = &s4_pwm_j_gate.hw,
  3251. [CLKID_SARADC_SEL] = &s4_saradc_mux.hw,
  3252. [CLKID_SARADC_DIV] = &s4_saradc_div.hw,
  3253. [CLKID_SARADC] = &s4_saradc_gate.hw,
  3254. [CLKID_GEN_SEL] = &s4_gen_clk_sel.hw,
  3255. [CLKID_GEN_DIV] = &s4_gen_clk_div.hw,
  3256. [CLKID_GEN] = &s4_gen_clk.hw,
  3257. [CLKID_DDR] = &s4_ddr.hw,
  3258. [CLKID_DOS] = &s4_dos.hw,
  3259. [CLKID_ETHPHY] = &s4_ethphy.hw,
  3260. [CLKID_MALI] = &s4_mali.hw,
  3261. [CLKID_AOCPU] = &s4_aocpu.hw,
  3262. [CLKID_AUCPU] = &s4_aucpu.hw,
  3263. [CLKID_CEC] = &s4_cec.hw,
  3264. [CLKID_SDEMMC_A] = &s4_sdemmca.hw,
  3265. [CLKID_SDEMMC_B] = &s4_sdemmcb.hw,
  3266. [CLKID_NAND] = &s4_nand.hw,
  3267. [CLKID_SMARTCARD] = &s4_smartcard.hw,
  3268. [CLKID_ACODEC] = &s4_acodec.hw,
  3269. [CLKID_SPIFC] = &s4_spifc.hw,
  3270. [CLKID_MSR] = &s4_msr_clk.hw,
  3271. [CLKID_IR_CTRL] = &s4_ir_ctrl.hw,
  3272. [CLKID_AUDIO] = &s4_audio.hw,
  3273. [CLKID_ETH] = &s4_eth.hw,
  3274. [CLKID_UART_A] = &s4_uart_a.hw,
  3275. [CLKID_UART_B] = &s4_uart_b.hw,
  3276. [CLKID_UART_C] = &s4_uart_c.hw,
  3277. [CLKID_UART_D] = &s4_uart_d.hw,
  3278. [CLKID_UART_E] = &s4_uart_e.hw,
  3279. [CLKID_AIFIFO] = &s4_aififo.hw,
  3280. [CLKID_TS_DDR] = &s4_ts_ddr.hw,
  3281. [CLKID_TS_PLL] = &s4_ts_pll.hw,
  3282. [CLKID_G2D] = &s4_g2d.hw,
  3283. [CLKID_SPICC0] = &s4_spicc0.hw,
  3284. [CLKID_USB] = &s4_usb.hw,
  3285. [CLKID_I2C_M_A] = &s4_i2c_m_a.hw,
  3286. [CLKID_I2C_M_B] = &s4_i2c_m_b.hw,
  3287. [CLKID_I2C_M_C] = &s4_i2c_m_c.hw,
  3288. [CLKID_I2C_M_D] = &s4_i2c_m_d.hw,
  3289. [CLKID_I2C_M_E] = &s4_i2c_m_e.hw,
  3290. [CLKID_HDMITX_APB] = &s4_hdmitx_apb.hw,
  3291. [CLKID_I2C_S_A] = &s4_i2c_s_a.hw,
  3292. [CLKID_USB1_TO_DDR] = &s4_usb1_to_ddr.hw,
  3293. [CLKID_HDCP22] = &s4_hdcp22.hw,
  3294. [CLKID_MMC_APB] = &s4_mmc_apb.hw,
  3295. [CLKID_RSA] = &s4_rsa.hw,
  3296. [CLKID_CPU_DEBUG] = &s4_cpu_debug.hw,
  3297. [CLKID_VPU_INTR] = &s4_vpu_intr.hw,
  3298. [CLKID_DEMOD] = &s4_demod.hw,
  3299. [CLKID_SAR_ADC] = &s4_sar_adc.hw,
  3300. [CLKID_GIC] = &s4_gic.hw,
  3301. [CLKID_PWM_AB] = &s4_pwm_ab.hw,
  3302. [CLKID_PWM_CD] = &s4_pwm_cd.hw,
  3303. [CLKID_PWM_EF] = &s4_pwm_ef.hw,
  3304. [CLKID_PWM_GH] = &s4_pwm_gh.hw,
  3305. [CLKID_PWM_IJ] = &s4_pwm_ij.hw,
  3306. [CLKID_HDCP22_ESMCLK_SEL] = &s4_hdcp22_esmclk_mux.hw,
  3307. [CLKID_HDCP22_ESMCLK_DIV] = &s4_hdcp22_esmclk_div.hw,
  3308. [CLKID_HDCP22_ESMCLK] = &s4_hdcp22_esmclk_gate.hw,
  3309. [CLKID_HDCP22_SKPCLK_SEL] = &s4_hdcp22_skpclk_mux.hw,
  3310. [CLKID_HDCP22_SKPCLK_DIV] = &s4_hdcp22_skpclk_div.hw,
  3311. [CLKID_HDCP22_SKPCLK] = &s4_hdcp22_skpclk_gate.hw,
  3312. };
  3313. /* Convenience table to populate regmap in .probe */
  3314. static struct clk_regmap *const s4_periphs_clk_regmaps[] = {
  3315. &s4_rtc_32k_by_oscin_clkin,
  3316. &s4_rtc_32k_by_oscin_div,
  3317. &s4_rtc_32k_by_oscin_sel,
  3318. &s4_rtc_32k_by_oscin,
  3319. &s4_rtc_clk,
  3320. &s4_sysclk_b_sel,
  3321. &s4_sysclk_b_div,
  3322. &s4_sysclk_b,
  3323. &s4_sysclk_a_sel,
  3324. &s4_sysclk_a_div,
  3325. &s4_sysclk_a,
  3326. &s4_sys_clk,
  3327. &s4_ceca_32k_clkin,
  3328. &s4_ceca_32k_div,
  3329. &s4_ceca_32k_sel_pre,
  3330. &s4_ceca_32k_sel,
  3331. &s4_ceca_32k_clkout,
  3332. &s4_cecb_32k_clkin,
  3333. &s4_cecb_32k_div,
  3334. &s4_cecb_32k_sel_pre,
  3335. &s4_cecb_32k_sel,
  3336. &s4_cecb_32k_clkout,
  3337. &s4_sc_clk_mux,
  3338. &s4_sc_clk_div,
  3339. &s4_sc_clk_gate,
  3340. &s4_12_24M_clk_gate,
  3341. &s4_12_24M_clk,
  3342. &s4_vid_pll_div,
  3343. &s4_vid_pll_sel,
  3344. &s4_vid_pll,
  3345. &s4_vclk_sel,
  3346. &s4_vclk2_sel,
  3347. &s4_vclk_input,
  3348. &s4_vclk2_input,
  3349. &s4_vclk_div,
  3350. &s4_vclk2_div,
  3351. &s4_vclk,
  3352. &s4_vclk2,
  3353. &s4_vclk_div1,
  3354. &s4_vclk_div2_en,
  3355. &s4_vclk_div4_en,
  3356. &s4_vclk_div6_en,
  3357. &s4_vclk_div12_en,
  3358. &s4_vclk2_div1,
  3359. &s4_vclk2_div2_en,
  3360. &s4_vclk2_div4_en,
  3361. &s4_vclk2_div6_en,
  3362. &s4_vclk2_div12_en,
  3363. &s4_cts_enci_sel,
  3364. &s4_cts_encp_sel,
  3365. &s4_cts_vdac_sel,
  3366. &s4_hdmi_tx_sel,
  3367. &s4_cts_enci,
  3368. &s4_cts_encp,
  3369. &s4_cts_vdac,
  3370. &s4_hdmi_tx,
  3371. &s4_hdmi_sel,
  3372. &s4_hdmi_div,
  3373. &s4_hdmi,
  3374. &s4_ts_clk_div,
  3375. &s4_ts_clk_gate,
  3376. &s4_mali_0_sel,
  3377. &s4_mali_0_div,
  3378. &s4_mali_0,
  3379. &s4_mali_1_sel,
  3380. &s4_mali_1_div,
  3381. &s4_mali_1,
  3382. &s4_mali_mux,
  3383. &s4_vdec_p0_mux,
  3384. &s4_vdec_p0_div,
  3385. &s4_vdec_p0,
  3386. &s4_vdec_p1_mux,
  3387. &s4_vdec_p1_div,
  3388. &s4_vdec_p1,
  3389. &s4_vdec_mux,
  3390. &s4_hevcf_p0_mux,
  3391. &s4_hevcf_p0_div,
  3392. &s4_hevcf_p0,
  3393. &s4_hevcf_p1_mux,
  3394. &s4_hevcf_p1_div,
  3395. &s4_hevcf_p1,
  3396. &s4_hevcf_mux,
  3397. &s4_vpu_0_sel,
  3398. &s4_vpu_0_div,
  3399. &s4_vpu_0,
  3400. &s4_vpu_1_sel,
  3401. &s4_vpu_1_div,
  3402. &s4_vpu_1,
  3403. &s4_vpu,
  3404. &s4_vpu_clkb_tmp_mux,
  3405. &s4_vpu_clkb_tmp_div,
  3406. &s4_vpu_clkb_tmp,
  3407. &s4_vpu_clkb_div,
  3408. &s4_vpu_clkb,
  3409. &s4_vpu_clkc_p0_mux,
  3410. &s4_vpu_clkc_p0_div,
  3411. &s4_vpu_clkc_p0,
  3412. &s4_vpu_clkc_p1_mux,
  3413. &s4_vpu_clkc_p1_div,
  3414. &s4_vpu_clkc_p1,
  3415. &s4_vpu_clkc_mux,
  3416. &s4_vapb_0_sel,
  3417. &s4_vapb_0_div,
  3418. &s4_vapb_0,
  3419. &s4_vapb_1_sel,
  3420. &s4_vapb_1_div,
  3421. &s4_vapb_1,
  3422. &s4_vapb,
  3423. &s4_ge2d_gate,
  3424. &s4_hdcp22_esmclk_mux,
  3425. &s4_hdcp22_esmclk_div,
  3426. &s4_hdcp22_esmclk_gate,
  3427. &s4_hdcp22_skpclk_mux,
  3428. &s4_hdcp22_skpclk_div,
  3429. &s4_hdcp22_skpclk_gate,
  3430. &s4_vdin_meas_mux,
  3431. &s4_vdin_meas_div,
  3432. &s4_vdin_meas_gate,
  3433. &s4_sd_emmc_c_clk0_sel,
  3434. &s4_sd_emmc_c_clk0_div,
  3435. &s4_sd_emmc_c_clk0,
  3436. &s4_sd_emmc_a_clk0_sel,
  3437. &s4_sd_emmc_a_clk0_div,
  3438. &s4_sd_emmc_a_clk0,
  3439. &s4_sd_emmc_b_clk0_sel,
  3440. &s4_sd_emmc_b_clk0_div,
  3441. &s4_sd_emmc_b_clk0,
  3442. &s4_spicc0_mux,
  3443. &s4_spicc0_div,
  3444. &s4_spicc0_gate,
  3445. &s4_pwm_a_mux,
  3446. &s4_pwm_a_div,
  3447. &s4_pwm_a_gate,
  3448. &s4_pwm_b_mux,
  3449. &s4_pwm_b_div,
  3450. &s4_pwm_b_gate,
  3451. &s4_pwm_c_mux,
  3452. &s4_pwm_c_div,
  3453. &s4_pwm_c_gate,
  3454. &s4_pwm_d_mux,
  3455. &s4_pwm_d_div,
  3456. &s4_pwm_d_gate,
  3457. &s4_pwm_e_mux,
  3458. &s4_pwm_e_div,
  3459. &s4_pwm_e_gate,
  3460. &s4_pwm_f_mux,
  3461. &s4_pwm_f_div,
  3462. &s4_pwm_f_gate,
  3463. &s4_pwm_g_mux,
  3464. &s4_pwm_g_div,
  3465. &s4_pwm_g_gate,
  3466. &s4_pwm_h_mux,
  3467. &s4_pwm_h_div,
  3468. &s4_pwm_h_gate,
  3469. &s4_pwm_i_mux,
  3470. &s4_pwm_i_div,
  3471. &s4_pwm_i_gate,
  3472. &s4_pwm_j_mux,
  3473. &s4_pwm_j_div,
  3474. &s4_pwm_j_gate,
  3475. &s4_saradc_mux,
  3476. &s4_saradc_div,
  3477. &s4_saradc_gate,
  3478. &s4_gen_clk_sel,
  3479. &s4_gen_clk_div,
  3480. &s4_gen_clk,
  3481. &s4_ddr,
  3482. &s4_dos,
  3483. &s4_ethphy,
  3484. &s4_mali,
  3485. &s4_aocpu,
  3486. &s4_aucpu,
  3487. &s4_cec,
  3488. &s4_sdemmca,
  3489. &s4_sdemmcb,
  3490. &s4_nand,
  3491. &s4_smartcard,
  3492. &s4_acodec,
  3493. &s4_spifc,
  3494. &s4_msr_clk,
  3495. &s4_ir_ctrl,
  3496. &s4_audio,
  3497. &s4_eth,
  3498. &s4_uart_a,
  3499. &s4_uart_b,
  3500. &s4_uart_c,
  3501. &s4_uart_d,
  3502. &s4_uart_e,
  3503. &s4_aififo,
  3504. &s4_ts_ddr,
  3505. &s4_ts_pll,
  3506. &s4_g2d,
  3507. &s4_spicc0,
  3508. &s4_usb,
  3509. &s4_i2c_m_a,
  3510. &s4_i2c_m_b,
  3511. &s4_i2c_m_c,
  3512. &s4_i2c_m_d,
  3513. &s4_i2c_m_e,
  3514. &s4_hdmitx_apb,
  3515. &s4_i2c_s_a,
  3516. &s4_usb1_to_ddr,
  3517. &s4_hdcp22,
  3518. &s4_mmc_apb,
  3519. &s4_rsa,
  3520. &s4_cpu_debug,
  3521. &s4_vpu_intr,
  3522. &s4_demod,
  3523. &s4_sar_adc,
  3524. &s4_gic,
  3525. &s4_pwm_ab,
  3526. &s4_pwm_cd,
  3527. &s4_pwm_ef,
  3528. &s4_pwm_gh,
  3529. &s4_pwm_ij,
  3530. &s4_demod_core_clk_mux,
  3531. &s4_demod_core_clk_div,
  3532. &s4_demod_core_clk_gate,
  3533. &s4_adc_extclk_in_mux,
  3534. &s4_adc_extclk_in_div,
  3535. &s4_adc_extclk_in_gate,
  3536. };
  3537. static const struct regmap_config clkc_regmap_config = {
  3538. .reg_bits = 32,
  3539. .val_bits = 32,
  3540. .reg_stride = 4,
  3541. .max_register = CLKCTRL_DEMOD_CLK_CTRL,
  3542. };
  3543. static struct meson_clk_hw_data s4_periphs_clks = {
  3544. .hws = s4_periphs_hw_clks,
  3545. .num = ARRAY_SIZE(s4_periphs_hw_clks),
  3546. };
  3547. static int meson_s4_periphs_probe(struct platform_device *pdev)
  3548. {
  3549. struct device *dev = &pdev->dev;
  3550. struct regmap *regmap;
  3551. void __iomem *base;
  3552. int ret, i;
  3553. base = devm_platform_ioremap_resource(pdev, 0);
  3554. if (IS_ERR(base))
  3555. return dev_err_probe(dev, PTR_ERR(base),
  3556. "can't ioremap resource\n");
  3557. regmap = devm_regmap_init_mmio(dev, base, &clkc_regmap_config);
  3558. if (IS_ERR(regmap))
  3559. return dev_err_probe(dev, PTR_ERR(regmap),
  3560. "can't init regmap mmio region\n");
  3561. /* Populate regmap for the regmap backed clocks */
  3562. for (i = 0; i < ARRAY_SIZE(s4_periphs_clk_regmaps); i++)
  3563. s4_periphs_clk_regmaps[i]->map = regmap;
  3564. for (i = 0; i < s4_periphs_clks.num; i++) {
  3565. /* array might be sparse */
  3566. if (!s4_periphs_clks.hws[i])
  3567. continue;
  3568. ret = devm_clk_hw_register(dev, s4_periphs_clks.hws[i]);
  3569. if (ret)
  3570. return dev_err_probe(dev, ret,
  3571. "clock[%d] registration failed\n", i);
  3572. }
  3573. return devm_of_clk_add_hw_provider(dev, meson_clk_hw_get, &s4_periphs_clks);
  3574. }
  3575. static const struct of_device_id clkc_match_table[] = {
  3576. {
  3577. .compatible = "amlogic,s4-peripherals-clkc",
  3578. },
  3579. {}
  3580. };
  3581. MODULE_DEVICE_TABLE(of, clkc_match_table);
  3582. static struct platform_driver s4_driver = {
  3583. .probe = meson_s4_periphs_probe,
  3584. .driver = {
  3585. .name = "s4-periphs-clkc",
  3586. .of_match_table = clkc_match_table,
  3587. },
  3588. };
  3589. module_platform_driver(s4_driver);
  3590. MODULE_DESCRIPTION("Amlogic S4 Peripherals Clock Controller driver");
  3591. MODULE_AUTHOR("Yu Tu <yu.tu@amlogic.com>");
  3592. MODULE_LICENSE("GPL");
  3593. MODULE_IMPORT_NS(CLK_MESON);