pm_api_clock.c 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075
  1. /*
  2. * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. /*
  8. * ZynqMP system level PM-API functions for clock control.
  9. */
  10. #include <stdbool.h>
  11. #include <string.h>
  12. #include <arch_helpers.h>
  13. #include <lib/mmio.h>
  14. #include <plat/common/platform.h>
  15. #include "pm_api_clock.h"
  16. #include "pm_client.h"
  17. #include "pm_common.h"
  18. #include "pm_ipi.h"
  19. #include "zynqmp_pm_api_sys.h"
  20. #define CLK_NODE_MAX (6U)
  21. #define CLK_PARENTS_ID_LEN (16U)
  22. #define CLK_TOPOLOGY_NODE_OFFSET (16U)
  23. #define CLK_TOPOLOGY_PAYLOAD_LEN (12U)
  24. #define CLK_PARENTS_PAYLOAD_LEN (12U)
  25. #define CLK_TYPE_SHIFT (2U)
  26. #define CLK_CLKFLAGS_SHIFT (8U)
  27. #define CLK_TYPEFLAGS_SHIFT (24U)
  28. #define CLK_TYPEFLAGS2_SHIFT (4U)
  29. #define CLK_TYPEFLAGS_BITS_MASK (0xFFU)
  30. #define CLK_TYPEFLAGS2_BITS_MASK (0x0F00U)
  31. #define CLK_TYPEFLAGS_BITS (8U)
  32. #define CLK_EXTERNAL_PARENT (PARENT_CLK_EXTERNAL << CLK_PARENTS_ID_LEN)
  33. #define NA_MULT (0U)
  34. #define NA_DIV (0U)
  35. #define NA_SHIFT (0U)
  36. #define NA_WIDTH (0U)
  37. #define NA_CLK_FLAGS (0U)
  38. #define NA_TYPE_FLAGS (0U)
  39. /* PLL nodes related definitions */
  40. #define PLL_PRESRC_MUX_SHIFT (20U)
  41. #define PLL_PRESRC_MUX_WIDTH (3U)
  42. #define PLL_POSTSRC_MUX_SHIFT (24U)
  43. #define PLL_POSTSRC_MUX_WIDTH (3U)
  44. #define PLL_DIV2_MUX_SHIFT (16U)
  45. #define PLL_DIV2_MUX_WIDTH (1U)
  46. #define PLL_BYPASS_MUX_SHIFT (3U)
  47. #define PLL_BYPASS_MUX_WIDTH (1U)
  48. /* Peripheral nodes related definitions */
  49. /* Peripheral Clocks */
  50. #define PERIPH_MUX_SHIFT (0U)
  51. #define PERIPH_MUX_WIDTH (3U)
  52. #define PERIPH_DIV1_SHIFT (8U)
  53. #define PERIPH_DIV1_WIDTH (6U)
  54. #define PERIPH_DIV2_SHIFT (16U)
  55. #define PERIPH_DIV2_WIDTH (6U)
  56. #define PERIPH_GATE_SHIFT (24U)
  57. #define PERIPH_GATE_WIDTH (1U)
  58. #define USB_GATE_SHIFT (25U)
  59. /* External clock related definitions */
  60. #define EXT_CLK_MIO_DATA(mio) \
  61. [EXT_CLK_INDEX(EXT_CLK_MIO##mio)] = { \
  62. .name = "mio_clk_"#mio, \
  63. }
  64. #define EXT_CLK_INDEX(n) (n - CLK_MAX_OUTPUT_CLK)
  65. /* Clock control related definitions */
  66. #define BIT_MASK(x, y) (((1U << (y)) - 1) << (x))
  67. #define ISPLL(id) (id == CLK_APLL_INT || \
  68. id == CLK_DPLL_INT || \
  69. id == CLK_VPLL_INT || \
  70. id == CLK_IOPLL_INT || \
  71. id == CLK_RPLL_INT)
  72. #define PLLCTRL_BP_MASK BIT(3)
  73. #define PLLCTRL_RESET_MASK (1U)
  74. #define PLL_FRAC_OFFSET (8U)
  75. #define PLL_FRAC_MODE (1U)
  76. #define PLL_INT_MODE (0U)
  77. #define PLL_FRAC_MODE_MASK (0x80000000U)
  78. #define PLL_FRAC_MODE_SHIFT (31U)
  79. #define PLL_FRAC_DATA_MASK (0xFFFFU)
  80. #define PLL_FRAC_DATA_SHIFT (0U)
  81. #define PLL_FBDIV_MASK (0x7F00U)
  82. #define PLL_FBDIV_WIDTH (7U)
  83. #define PLL_FBDIV_SHIFT (8U)
  84. #define CLK_PLL_RESET_ASSERT (1U)
  85. #define CLK_PLL_RESET_RELEASE (2U)
  86. #define CLK_PLL_RESET_PULSE (CLK_PLL_RESET_ASSERT | CLK_PLL_RESET_RELEASE)
  87. /* Common topology definitions */
  88. #define GENERIC_MUX \
  89. { \
  90. .type = TYPE_MUX, \
  91. .offset = PERIPH_MUX_SHIFT, \
  92. .width = PERIPH_MUX_WIDTH, \
  93. .clkflags = CLK_SET_RATE_NO_REPARENT | \
  94. CLK_IS_BASIC, \
  95. .typeflags = NA_TYPE_FLAGS, \
  96. .mult = NA_MULT, \
  97. .div = NA_DIV, \
  98. }
  99. #define IGNORE_UNUSED_MUX \
  100. { \
  101. .type = TYPE_MUX, \
  102. .offset = PERIPH_MUX_SHIFT, \
  103. .width = PERIPH_MUX_WIDTH, \
  104. .clkflags = CLK_IGNORE_UNUSED | \
  105. CLK_SET_RATE_NO_REPARENT | \
  106. CLK_IS_BASIC, \
  107. .typeflags = NA_TYPE_FLAGS, \
  108. .mult = NA_MULT, \
  109. .div = NA_DIV, \
  110. }
  111. #define GENERIC_DIV1 \
  112. { \
  113. .type = TYPE_DIV1, \
  114. .offset = PERIPH_DIV1_SHIFT, \
  115. .width = PERIPH_DIV1_WIDTH, \
  116. .clkflags = CLK_SET_RATE_NO_REPARENT | \
  117. CLK_IS_BASIC, \
  118. .typeflags = CLK_DIVIDER_ONE_BASED | \
  119. CLK_DIVIDER_ALLOW_ZERO, \
  120. .mult = NA_MULT, \
  121. .div = NA_DIV, \
  122. }
  123. #define GENERIC_DIV2 \
  124. { \
  125. .type = TYPE_DIV2, \
  126. .offset = PERIPH_DIV2_SHIFT, \
  127. .width = PERIPH_DIV2_WIDTH, \
  128. .clkflags = CLK_SET_RATE_NO_REPARENT | \
  129. CLK_SET_RATE_PARENT | \
  130. CLK_IS_BASIC, \
  131. .typeflags = CLK_DIVIDER_ONE_BASED | \
  132. CLK_DIVIDER_ALLOW_ZERO, \
  133. .mult = NA_MULT, \
  134. .div = NA_DIV, \
  135. }
  136. #define IGNORE_UNUSED_DIV(id) \
  137. { \
  138. .type = TYPE_DIV##id, \
  139. .offset = PERIPH_DIV##id##_SHIFT, \
  140. .width = PERIPH_DIV##id##_WIDTH, \
  141. .clkflags = CLK_IGNORE_UNUSED | \
  142. CLK_SET_RATE_NO_REPARENT | \
  143. CLK_IS_BASIC, \
  144. .typeflags = CLK_DIVIDER_ONE_BASED | \
  145. CLK_DIVIDER_ALLOW_ZERO, \
  146. .mult = NA_MULT, \
  147. .div = NA_DIV, \
  148. }
  149. #define GENERIC_GATE \
  150. { \
  151. .type = TYPE_GATE, \
  152. .offset = PERIPH_GATE_SHIFT, \
  153. .width = PERIPH_GATE_WIDTH, \
  154. .clkflags = CLK_SET_RATE_PARENT | \
  155. CLK_SET_RATE_GATE | \
  156. CLK_IS_BASIC, \
  157. .typeflags = NA_TYPE_FLAGS, \
  158. .mult = NA_MULT, \
  159. .div = NA_DIV, \
  160. }
  161. #define IGNORE_UNUSED_GATE \
  162. { \
  163. .type = TYPE_GATE, \
  164. .offset = PERIPH_GATE_SHIFT, \
  165. .width = PERIPH_GATE_WIDTH, \
  166. .clkflags = CLK_SET_RATE_PARENT | \
  167. CLK_IGNORE_UNUSED | \
  168. CLK_IS_BASIC, \
  169. .typeflags = NA_TYPE_FLAGS, \
  170. .mult = NA_MULT, \
  171. .div = NA_DIV, \
  172. }
  173. /**
  174. * struct pm_clock_node - Clock topology node information.
  175. * @type: Topology type (mux/div1/div2/gate/pll/fixed factor).
  176. * @offset: Offset in control register.
  177. * @width: Width of the specific type in control register.
  178. * @clkflags: Clk specific flags.
  179. * @typeflags: Type specific flags.
  180. * @mult: Multiplier for fixed factor.
  181. * @div: Divisor for fixed factor.
  182. *
  183. */
  184. struct pm_clock_node {
  185. uint16_t clkflags;
  186. uint16_t typeflags;
  187. uint8_t type;
  188. uint8_t offset;
  189. uint8_t width;
  190. uint8_t mult:4;
  191. uint8_t div:4;
  192. };
  193. /**
  194. * struct pm_clock - Clock structure.
  195. * @name: Clock name.
  196. * @num_nodes: number of nodes.
  197. * @control_reg: Control register address.
  198. * @status_reg: Status register address.
  199. * @parents: Parents for first clock node. Lower byte indicates parent
  200. * clock id and upper byte indicate flags for that id.
  201. * @nodes: Clock nodes.
  202. *
  203. */
  204. struct pm_clock {
  205. char name[CLK_NAME_LEN];
  206. uint8_t num_nodes;
  207. uint32_t control_reg;
  208. uint32_t status_reg;
  209. int32_t (*parents)[];
  210. struct pm_clock_node(*nodes)[];
  211. };
  212. /**
  213. * struct pm_ext_clock - Clock structure.
  214. * @name: Clock name.
  215. *
  216. */
  217. struct pm_ext_clock {
  218. char name[CLK_NAME_LEN];
  219. };
  220. /* PLL Clocks */
  221. static struct pm_clock_node generic_pll_nodes[] = {
  222. {
  223. .type = TYPE_PLL,
  224. .offset = NA_SHIFT,
  225. .width = NA_WIDTH,
  226. .clkflags = CLK_SET_RATE_NO_REPARENT,
  227. .typeflags = NA_TYPE_FLAGS,
  228. .mult = NA_MULT,
  229. .div = NA_DIV,
  230. },
  231. };
  232. static struct pm_clock_node ignore_unused_pll_nodes[] = {
  233. {
  234. .type = TYPE_PLL,
  235. .offset = NA_SHIFT,
  236. .width = NA_WIDTH,
  237. .clkflags = CLK_IGNORE_UNUSED | CLK_SET_RATE_NO_REPARENT,
  238. .typeflags = NA_TYPE_FLAGS,
  239. .mult = NA_MULT,
  240. .div = NA_DIV,
  241. },
  242. };
  243. static struct pm_clock_node generic_pll_pre_src_nodes[] = {
  244. {
  245. .type = TYPE_MUX,
  246. .offset = PLL_PRESRC_MUX_SHIFT,
  247. .width = PLL_PRESRC_MUX_WIDTH,
  248. .clkflags = CLK_IS_BASIC,
  249. .typeflags = NA_TYPE_FLAGS,
  250. .mult = NA_MULT,
  251. .div = NA_DIV,
  252. },
  253. };
  254. static struct pm_clock_node generic_pll_half_nodes[] = {
  255. {
  256. .type = TYPE_FIXEDFACTOR,
  257. .offset = NA_SHIFT,
  258. .width = NA_WIDTH,
  259. .clkflags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT,
  260. .typeflags = NA_TYPE_FLAGS,
  261. .mult = 1,
  262. .div = 2,
  263. },
  264. };
  265. static struct pm_clock_node generic_pll_int_nodes[] = {
  266. {
  267. .type = TYPE_MUX,
  268. .offset = PLL_DIV2_MUX_SHIFT,
  269. .width = PLL_DIV2_MUX_WIDTH,
  270. .clkflags = CLK_SET_RATE_NO_REPARENT |
  271. CLK_SET_RATE_PARENT |
  272. CLK_IS_BASIC,
  273. .typeflags = NA_TYPE_FLAGS,
  274. .mult = NA_MULT,
  275. .div = NA_DIV,
  276. },
  277. };
  278. static struct pm_clock_node generic_pll_post_src_nodes[] = {
  279. {
  280. .type = TYPE_MUX,
  281. .offset = PLL_POSTSRC_MUX_SHIFT,
  282. .width = PLL_POSTSRC_MUX_WIDTH,
  283. .clkflags = CLK_IS_BASIC,
  284. .typeflags = NA_TYPE_FLAGS,
  285. .mult = NA_MULT,
  286. .div = NA_DIV,
  287. },
  288. };
  289. static struct pm_clock_node generic_pll_system_nodes[] = {
  290. {
  291. .type = TYPE_MUX,
  292. .offset = PLL_BYPASS_MUX_SHIFT,
  293. .width = PLL_BYPASS_MUX_WIDTH,
  294. .clkflags = CLK_SET_RATE_NO_REPARENT |
  295. CLK_SET_RATE_PARENT |
  296. CLK_IS_BASIC,
  297. .typeflags = NA_TYPE_FLAGS,
  298. .mult = NA_MULT,
  299. .div = NA_DIV,
  300. },
  301. };
  302. static struct pm_clock_node acpu_nodes[] = {
  303. {
  304. .type = TYPE_MUX,
  305. .offset = PERIPH_MUX_SHIFT,
  306. .width = PERIPH_MUX_WIDTH,
  307. .clkflags = CLK_SET_RATE_NO_REPARENT | CLK_IS_BASIC,
  308. .typeflags = NA_TYPE_FLAGS,
  309. .mult = NA_MULT,
  310. .div = NA_DIV,
  311. },
  312. {
  313. .type = TYPE_DIV1,
  314. .offset = PERIPH_DIV1_SHIFT,
  315. .width = PERIPH_DIV1_WIDTH,
  316. .clkflags = CLK_IS_BASIC,
  317. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  318. .mult = NA_MULT,
  319. .div = NA_DIV,
  320. },
  321. };
  322. static struct pm_clock_node generic_mux_div_nodes[] = {
  323. GENERIC_MUX,
  324. GENERIC_DIV1,
  325. };
  326. static struct pm_clock_node generic_mux_div_gate_nodes[] = {
  327. GENERIC_MUX,
  328. GENERIC_DIV1,
  329. GENERIC_GATE,
  330. };
  331. static struct pm_clock_node generic_mux_div_unused_gate_nodes[] = {
  332. GENERIC_MUX,
  333. GENERIC_DIV1,
  334. IGNORE_UNUSED_GATE,
  335. };
  336. static struct pm_clock_node generic_mux_div_div_gate_nodes[] = {
  337. GENERIC_MUX,
  338. GENERIC_DIV1,
  339. GENERIC_DIV2,
  340. GENERIC_GATE,
  341. };
  342. static struct pm_clock_node dp_audio_video_ref_nodes[] = {
  343. {
  344. .type = TYPE_MUX,
  345. .offset = PERIPH_MUX_SHIFT,
  346. .width = PERIPH_MUX_WIDTH,
  347. .clkflags = CLK_SET_RATE_NO_REPARENT |
  348. CLK_SET_RATE_PARENT | CLK_IS_BASIC,
  349. .typeflags = CLK_FRAC,
  350. .mult = NA_MULT,
  351. .div = NA_DIV,
  352. },
  353. {
  354. .type = TYPE_DIV1,
  355. .offset = PERIPH_DIV1_SHIFT,
  356. .width = PERIPH_DIV1_WIDTH,
  357. .clkflags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT |
  358. CLK_IS_BASIC,
  359. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
  360. CLK_FRAC,
  361. .mult = NA_MULT,
  362. .div = NA_DIV,
  363. },
  364. {
  365. .type = TYPE_DIV2,
  366. .offset = PERIPH_DIV2_SHIFT,
  367. .width = PERIPH_DIV2_WIDTH,
  368. .clkflags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT |
  369. CLK_IS_BASIC,
  370. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
  371. CLK_FRAC,
  372. .mult = NA_MULT,
  373. .div = NA_DIV,
  374. },
  375. {
  376. .type = TYPE_GATE,
  377. .offset = PERIPH_GATE_SHIFT,
  378. .width = PERIPH_GATE_WIDTH,
  379. .clkflags = CLK_SET_RATE_PARENT |
  380. CLK_SET_RATE_GATE |
  381. CLK_IS_BASIC,
  382. .typeflags = NA_TYPE_FLAGS,
  383. .mult = NA_MULT,
  384. .div = NA_DIV,
  385. },
  386. };
  387. static struct pm_clock_node usb_nodes[] = {
  388. GENERIC_MUX,
  389. GENERIC_DIV1,
  390. GENERIC_DIV2,
  391. {
  392. .type = TYPE_GATE,
  393. .offset = USB_GATE_SHIFT,
  394. .width = PERIPH_GATE_WIDTH,
  395. .clkflags = CLK_SET_RATE_PARENT | CLK_IS_BASIC |
  396. CLK_SET_RATE_GATE,
  397. .typeflags = NA_TYPE_FLAGS,
  398. .mult = NA_MULT,
  399. .div = NA_DIV,
  400. },
  401. };
  402. static struct pm_clock_node generic_domain_crossing_nodes[] = {
  403. {
  404. .type = TYPE_DIV1,
  405. .offset = 8,
  406. .width = 6,
  407. .clkflags = CLK_IS_BASIC,
  408. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  409. .mult = NA_MULT,
  410. .div = NA_DIV,
  411. },
  412. };
  413. static struct pm_clock_node rpll_to_fpd_nodes[] = {
  414. {
  415. .type = TYPE_DIV1,
  416. .offset = 8,
  417. .width = 6,
  418. .clkflags = CLK_SET_RATE_PARENT | CLK_IS_BASIC,
  419. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  420. .mult = NA_MULT,
  421. .div = NA_DIV,
  422. },
  423. };
  424. static struct pm_clock_node acpu_half_nodes[] = {
  425. {
  426. .type = TYPE_FIXEDFACTOR,
  427. .offset = 0,
  428. .width = 1,
  429. .clkflags = 0,
  430. .typeflags = 0,
  431. .mult = 1,
  432. .div = 2,
  433. },
  434. {
  435. .type = TYPE_GATE,
  436. .offset = 25,
  437. .width = PERIPH_GATE_WIDTH,
  438. .clkflags = CLK_IGNORE_UNUSED |
  439. CLK_SET_RATE_PARENT |
  440. CLK_IS_BASIC,
  441. .typeflags = NA_TYPE_FLAGS,
  442. .mult = NA_MULT,
  443. .div = NA_DIV,
  444. },
  445. };
  446. static struct pm_clock_node acpu_full_nodes[] = {
  447. {
  448. .type = TYPE_GATE,
  449. .offset = 24,
  450. .width = PERIPH_GATE_WIDTH,
  451. .clkflags = CLK_IGNORE_UNUSED |
  452. CLK_SET_RATE_PARENT |
  453. CLK_IS_BASIC,
  454. .typeflags = NA_TYPE_FLAGS,
  455. .mult = NA_MULT,
  456. .div = NA_DIV,
  457. },
  458. };
  459. static struct pm_clock_node wdt_nodes[] = {
  460. {
  461. .type = TYPE_MUX,
  462. .offset = 0,
  463. .width = 1,
  464. .clkflags = CLK_SET_RATE_PARENT |
  465. CLK_SET_RATE_NO_REPARENT |
  466. CLK_IS_BASIC,
  467. .typeflags = NA_TYPE_FLAGS,
  468. .mult = NA_MULT,
  469. .div = NA_DIV,
  470. },
  471. };
  472. static struct pm_clock_node ddr_nodes[] = {
  473. GENERIC_MUX,
  474. {
  475. .type = TYPE_DIV1,
  476. .offset = 8,
  477. .width = 6,
  478. .clkflags = CLK_IS_BASIC | CLK_IS_CRITICAL,
  479. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  480. .mult = NA_MULT,
  481. .div = NA_DIV,
  482. },
  483. };
  484. static struct pm_clock_node pl_nodes[] = {
  485. GENERIC_MUX,
  486. {
  487. .type = TYPE_DIV1,
  488. .offset = PERIPH_DIV1_SHIFT,
  489. .width = PERIPH_DIV1_WIDTH,
  490. .clkflags = CLK_IS_BASIC,
  491. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  492. .mult = NA_MULT,
  493. .div = NA_DIV,
  494. },
  495. {
  496. .type = TYPE_DIV2,
  497. .offset = PERIPH_DIV2_SHIFT,
  498. .width = PERIPH_DIV2_WIDTH,
  499. .clkflags = CLK_IS_BASIC | CLK_SET_RATE_PARENT,
  500. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  501. .mult = NA_MULT,
  502. .div = NA_DIV,
  503. },
  504. {
  505. .type = TYPE_GATE,
  506. .offset = PERIPH_GATE_SHIFT,
  507. .width = PERIPH_GATE_WIDTH,
  508. .clkflags = CLK_SET_RATE_PARENT | CLK_IS_BASIC,
  509. .typeflags = NA_TYPE_FLAGS,
  510. .mult = NA_MULT,
  511. .div = NA_DIV,
  512. },
  513. };
  514. static struct pm_clock_node gpu_pp0_nodes[] = {
  515. {
  516. .type = TYPE_GATE,
  517. .offset = 25,
  518. .width = PERIPH_GATE_WIDTH,
  519. .clkflags = CLK_SET_RATE_PARENT | CLK_IS_BASIC,
  520. .typeflags = NA_TYPE_FLAGS,
  521. .mult = NA_MULT,
  522. .div = NA_DIV,
  523. },
  524. };
  525. static struct pm_clock_node gpu_pp1_nodes[] = {
  526. {
  527. .type = TYPE_GATE,
  528. .offset = 26,
  529. .width = PERIPH_GATE_WIDTH,
  530. .clkflags = CLK_SET_RATE_PARENT | CLK_IS_BASIC,
  531. .typeflags = NA_TYPE_FLAGS,
  532. .mult = NA_MULT,
  533. .div = NA_DIV,
  534. },
  535. };
  536. static struct pm_clock_node gem_ref_ungated_nodes[] = {
  537. GENERIC_MUX,
  538. {
  539. .type = TYPE_DIV1,
  540. .offset = 8,
  541. .width = 6,
  542. .clkflags = CLK_SET_RATE_NO_REPARENT | CLK_IS_BASIC,
  543. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  544. .mult = NA_MULT,
  545. .div = NA_DIV,
  546. },
  547. {
  548. .type = TYPE_DIV2,
  549. .offset = 16,
  550. .width = 6,
  551. .clkflags = CLK_SET_RATE_NO_REPARENT | CLK_IS_BASIC |
  552. CLK_SET_RATE_PARENT,
  553. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  554. .mult = NA_MULT,
  555. .div = NA_DIV,
  556. },
  557. };
  558. static struct pm_clock_node gem0_ref_nodes[] = {
  559. {
  560. .type = TYPE_MUX,
  561. .offset = 1,
  562. .width = 1,
  563. .clkflags = CLK_SET_RATE_PARENT |
  564. CLK_SET_RATE_NO_REPARENT |
  565. CLK_IS_BASIC,
  566. .typeflags = NA_TYPE_FLAGS,
  567. .mult = NA_MULT,
  568. .div = NA_DIV,
  569. },
  570. };
  571. static struct pm_clock_node gem1_ref_nodes[] = {
  572. {
  573. .type = TYPE_MUX,
  574. .offset = 6,
  575. .width = 1,
  576. .clkflags = CLK_SET_RATE_PARENT |
  577. CLK_SET_RATE_NO_REPARENT |
  578. CLK_IS_BASIC,
  579. .typeflags = NA_TYPE_FLAGS,
  580. .mult = NA_MULT,
  581. .div = NA_DIV,
  582. },
  583. };
  584. static struct pm_clock_node gem2_ref_nodes[] = {
  585. {
  586. .type = TYPE_MUX,
  587. .offset = 11,
  588. .width = 1,
  589. .clkflags = CLK_SET_RATE_PARENT |
  590. CLK_SET_RATE_NO_REPARENT |
  591. CLK_IS_BASIC,
  592. .typeflags = NA_TYPE_FLAGS,
  593. .mult = NA_MULT,
  594. .div = NA_DIV,
  595. },
  596. };
  597. static struct pm_clock_node gem3_ref_nodes[] = {
  598. {
  599. .type = TYPE_MUX,
  600. .offset = 16,
  601. .width = 1,
  602. .clkflags = CLK_SET_RATE_PARENT |
  603. CLK_SET_RATE_NO_REPARENT |
  604. CLK_IS_BASIC,
  605. .typeflags = NA_TYPE_FLAGS,
  606. .mult = NA_MULT,
  607. .div = NA_DIV,
  608. },
  609. };
  610. static struct pm_clock_node gem_tx_nodes[] = {
  611. {
  612. .type = TYPE_GATE,
  613. .offset = 25,
  614. .width = PERIPH_GATE_WIDTH,
  615. .clkflags = CLK_SET_RATE_PARENT | CLK_IS_BASIC,
  616. .typeflags = NA_TYPE_FLAGS,
  617. .mult = NA_MULT,
  618. .div = NA_DIV,
  619. },
  620. };
  621. static struct pm_clock_node gem_rx_nodes[] = {
  622. {
  623. .type = TYPE_GATE,
  624. .offset = 26,
  625. .width = PERIPH_GATE_WIDTH,
  626. .clkflags = CLK_IS_BASIC,
  627. .typeflags = NA_TYPE_FLAGS,
  628. .mult = NA_MULT,
  629. .div = NA_DIV,
  630. },
  631. };
  632. static struct pm_clock_node gem_tsu_nodes[] = {
  633. {
  634. .type = TYPE_MUX,
  635. .offset = 20,
  636. .width = 2,
  637. .clkflags = CLK_SET_RATE_PARENT |
  638. CLK_SET_RATE_NO_REPARENT |
  639. CLK_IS_BASIC,
  640. .typeflags = NA_TYPE_FLAGS,
  641. .mult = NA_MULT,
  642. .div = NA_DIV,
  643. },
  644. };
  645. static struct pm_clock_node can0_mio_nodes[] = {
  646. {
  647. .type = TYPE_MUX,
  648. .offset = 0,
  649. .width = 7,
  650. .clkflags = CLK_SET_RATE_PARENT |
  651. CLK_SET_RATE_NO_REPARENT |
  652. CLK_IS_BASIC,
  653. .typeflags = NA_TYPE_FLAGS,
  654. .mult = NA_MULT,
  655. .div = NA_DIV,
  656. },
  657. };
  658. static struct pm_clock_node can1_mio_nodes[] = {
  659. {
  660. .type = TYPE_MUX,
  661. .offset = 15,
  662. .width = 1,
  663. .clkflags = CLK_SET_RATE_PARENT |
  664. CLK_SET_RATE_NO_REPARENT |
  665. CLK_IS_BASIC,
  666. .typeflags = NA_TYPE_FLAGS,
  667. .mult = NA_MULT,
  668. .div = NA_DIV,
  669. },
  670. };
  671. static struct pm_clock_node can0_nodes[] = {
  672. {
  673. .type = TYPE_MUX,
  674. .offset = 7,
  675. .width = 1,
  676. .clkflags = CLK_SET_RATE_PARENT |
  677. CLK_SET_RATE_NO_REPARENT |
  678. CLK_IS_BASIC,
  679. .typeflags = NA_TYPE_FLAGS,
  680. .mult = NA_MULT,
  681. .div = NA_DIV,
  682. },
  683. };
  684. static struct pm_clock_node can1_nodes[] = {
  685. {
  686. .type = TYPE_MUX,
  687. .offset = 22,
  688. .width = 1,
  689. .clkflags = CLK_SET_RATE_PARENT |
  690. CLK_SET_RATE_NO_REPARENT |
  691. CLK_IS_BASIC,
  692. .typeflags = NA_TYPE_FLAGS,
  693. .mult = NA_MULT,
  694. .div = NA_DIV,
  695. },
  696. };
  697. static struct pm_clock_node cpu_r5_core_nodes[] = {
  698. {
  699. .type = TYPE_GATE,
  700. .offset = 25,
  701. .width = PERIPH_GATE_WIDTH,
  702. .clkflags = CLK_IGNORE_UNUSED |
  703. CLK_IS_BASIC,
  704. .typeflags = NA_TYPE_FLAGS,
  705. .mult = NA_MULT,
  706. .div = NA_DIV,
  707. },
  708. };
  709. static struct pm_clock_node dll_ref_nodes[] = {
  710. {
  711. .type = TYPE_MUX,
  712. .offset = 0,
  713. .width = 3,
  714. .clkflags = CLK_SET_RATE_PARENT |
  715. CLK_SET_RATE_NO_REPARENT |
  716. CLK_IS_BASIC,
  717. .typeflags = NA_TYPE_FLAGS,
  718. .mult = NA_MULT,
  719. .div = NA_DIV,
  720. },
  721. };
  722. static struct pm_clock_node timestamp_ref_nodes[] = {
  723. GENERIC_MUX,
  724. {
  725. .type = TYPE_DIV1,
  726. .offset = 8,
  727. .width = 6,
  728. .clkflags = CLK_IS_BASIC,
  729. .typeflags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
  730. .mult = NA_MULT,
  731. .div = NA_DIV,
  732. },
  733. IGNORE_UNUSED_GATE,
  734. };
  735. static int32_t can_mio_parents[] = {
  736. EXT_CLK_MIO0, EXT_CLK_MIO1, EXT_CLK_MIO2, EXT_CLK_MIO3,
  737. EXT_CLK_MIO4, EXT_CLK_MIO5, EXT_CLK_MIO6, EXT_CLK_MIO7,
  738. EXT_CLK_MIO8, EXT_CLK_MIO9, EXT_CLK_MIO10, EXT_CLK_MIO11,
  739. EXT_CLK_MIO12, EXT_CLK_MIO13, EXT_CLK_MIO14, EXT_CLK_MIO15,
  740. EXT_CLK_MIO16, EXT_CLK_MIO17, EXT_CLK_MIO18, EXT_CLK_MIO19,
  741. EXT_CLK_MIO20, EXT_CLK_MIO21, EXT_CLK_MIO22, EXT_CLK_MIO23,
  742. EXT_CLK_MIO24, EXT_CLK_MIO25, EXT_CLK_MIO26, EXT_CLK_MIO27,
  743. EXT_CLK_MIO28, EXT_CLK_MIO29, EXT_CLK_MIO30, EXT_CLK_MIO31,
  744. EXT_CLK_MIO32, EXT_CLK_MIO33, EXT_CLK_MIO34, EXT_CLK_MIO35,
  745. EXT_CLK_MIO36, EXT_CLK_MIO37, EXT_CLK_MIO38, EXT_CLK_MIO39,
  746. EXT_CLK_MIO40, EXT_CLK_MIO41, EXT_CLK_MIO42, EXT_CLK_MIO43,
  747. EXT_CLK_MIO44, EXT_CLK_MIO45, EXT_CLK_MIO46, EXT_CLK_MIO47,
  748. EXT_CLK_MIO48, EXT_CLK_MIO49, EXT_CLK_MIO50, EXT_CLK_MIO51,
  749. EXT_CLK_MIO52, EXT_CLK_MIO53, EXT_CLK_MIO54, EXT_CLK_MIO55,
  750. EXT_CLK_MIO56, EXT_CLK_MIO57, EXT_CLK_MIO58, EXT_CLK_MIO59,
  751. EXT_CLK_MIO60, EXT_CLK_MIO61, EXT_CLK_MIO62, EXT_CLK_MIO63,
  752. EXT_CLK_MIO64, EXT_CLK_MIO65, EXT_CLK_MIO66, EXT_CLK_MIO67,
  753. EXT_CLK_MIO68, EXT_CLK_MIO69, EXT_CLK_MIO70, EXT_CLK_MIO71,
  754. EXT_CLK_MIO72, EXT_CLK_MIO73, EXT_CLK_MIO74, EXT_CLK_MIO75,
  755. EXT_CLK_MIO76, EXT_CLK_MIO77, CLK_NA_PARENT
  756. };
  757. /* Clock array containing clock informaton */
  758. static struct pm_clock clocks[] = {
  759. [CLK_APLL_INT] = {
  760. .name = "apll_int",
  761. .control_reg = CRF_APB_APLL_CTRL,
  762. .status_reg = CRF_APB_PLL_STATUS,
  763. .parents = &((int32_t []) {CLK_APLL_PRE_SRC, CLK_NA_PARENT}),
  764. .nodes = &ignore_unused_pll_nodes,
  765. .num_nodes = ARRAY_SIZE(ignore_unused_pll_nodes),
  766. },
  767. [CLK_APLL_PRE_SRC] = {
  768. .name = "apll_pre_src",
  769. .control_reg = CRF_APB_APLL_CTRL,
  770. .status_reg = CRF_APB_PLL_STATUS,
  771. .parents = &((int32_t []) {
  772. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  773. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  774. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  775. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  776. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  777. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  778. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  779. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  780. CLK_NA_PARENT
  781. }),
  782. .nodes = &generic_pll_pre_src_nodes,
  783. .num_nodes = ARRAY_SIZE(generic_pll_pre_src_nodes),
  784. },
  785. [CLK_APLL_HALF] = {
  786. .name = "apll_half",
  787. .control_reg = CRF_APB_APLL_CTRL,
  788. .status_reg = CRF_APB_PLL_STATUS,
  789. .parents = &((int32_t []) {CLK_APLL_INT, CLK_NA_PARENT}),
  790. .nodes = &generic_pll_half_nodes,
  791. .num_nodes = ARRAY_SIZE(generic_pll_half_nodes),
  792. },
  793. [CLK_APLL_INT_MUX] = {
  794. .name = "apll_int_mux",
  795. .control_reg = CRF_APB_APLL_CTRL,
  796. .status_reg = CRF_APB_PLL_STATUS,
  797. .parents = &((int32_t []) {
  798. CLK_APLL_INT,
  799. CLK_APLL_HALF,
  800. CLK_NA_PARENT
  801. }),
  802. .nodes = &generic_pll_int_nodes,
  803. .num_nodes = ARRAY_SIZE(generic_pll_int_nodes),
  804. },
  805. [CLK_APLL_POST_SRC] = {
  806. .name = "apll_post_src",
  807. .control_reg = CRF_APB_APLL_CTRL,
  808. .status_reg = CRF_APB_PLL_STATUS,
  809. .parents = &((int32_t []) {
  810. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  811. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  812. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  813. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  814. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  815. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  816. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  817. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  818. CLK_NA_PARENT
  819. }),
  820. .nodes = &generic_pll_post_src_nodes,
  821. .num_nodes = ARRAY_SIZE(generic_pll_post_src_nodes),
  822. },
  823. [CLK_APLL] = {
  824. .name = "apll",
  825. .control_reg = CRF_APB_APLL_CTRL,
  826. .status_reg = CRF_APB_PLL_STATUS,
  827. .parents = &((int32_t []) {
  828. CLK_APLL_INT_MUX,
  829. CLK_APLL_POST_SRC,
  830. CLK_NA_PARENT
  831. }),
  832. .nodes = &generic_pll_system_nodes,
  833. .num_nodes = ARRAY_SIZE(generic_pll_system_nodes),
  834. },
  835. [CLK_DPLL_INT] = {
  836. .name = "dpll_int",
  837. .control_reg = CRF_APB_DPLL_CTRL,
  838. .status_reg = CRF_APB_PLL_STATUS,
  839. .parents = &((int32_t []) {CLK_DPLL_PRE_SRC, CLK_NA_PARENT}),
  840. .nodes = &generic_pll_nodes,
  841. .num_nodes = ARRAY_SIZE(generic_pll_nodes),
  842. },
  843. [CLK_DPLL_PRE_SRC] = {
  844. .name = "dpll_pre_src",
  845. .control_reg = CRF_APB_DPLL_CTRL,
  846. .status_reg = CRF_APB_PLL_STATUS,
  847. .parents = &((int32_t []) {
  848. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  849. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  850. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  851. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  852. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  853. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  854. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  855. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  856. CLK_NA_PARENT
  857. }),
  858. .nodes = &generic_pll_pre_src_nodes,
  859. .num_nodes = ARRAY_SIZE(generic_pll_pre_src_nodes),
  860. },
  861. [CLK_DPLL_HALF] = {
  862. .name = "dpll_half",
  863. .control_reg = CRF_APB_DPLL_CTRL,
  864. .status_reg = CRF_APB_PLL_STATUS,
  865. .parents = &((int32_t []) {CLK_DPLL_INT, CLK_NA_PARENT}),
  866. .nodes = &generic_pll_half_nodes,
  867. .num_nodes = ARRAY_SIZE(generic_pll_half_nodes),
  868. },
  869. [CLK_DPLL_INT_MUX] = {
  870. .name = "dpll_int_mux",
  871. .control_reg = CRF_APB_DPLL_CTRL,
  872. .status_reg = CRF_APB_PLL_STATUS,
  873. .parents = &((int32_t []) {
  874. CLK_DPLL_INT,
  875. CLK_DPLL_HALF,
  876. CLK_NA_PARENT
  877. }),
  878. .nodes = &generic_pll_int_nodes,
  879. .num_nodes = ARRAY_SIZE(generic_pll_int_nodes),
  880. },
  881. [CLK_DPLL_POST_SRC] = {
  882. .name = "dpll_post_src",
  883. .control_reg = CRF_APB_DPLL_CTRL,
  884. .status_reg = CRF_APB_PLL_STATUS,
  885. .parents = &((int32_t []) {
  886. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  887. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  888. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  889. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  890. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  891. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  892. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  893. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  894. CLK_NA_PARENT
  895. }),
  896. .nodes = &generic_pll_post_src_nodes,
  897. .num_nodes = ARRAY_SIZE(generic_pll_post_src_nodes),
  898. },
  899. [CLK_DPLL] = {
  900. .name = "dpll",
  901. .control_reg = CRF_APB_DPLL_CTRL,
  902. .status_reg = CRF_APB_PLL_STATUS,
  903. .parents = &((int32_t []) {
  904. CLK_DPLL_INT_MUX,
  905. CLK_DPLL_POST_SRC,
  906. CLK_NA_PARENT
  907. }),
  908. .nodes = &generic_pll_system_nodes,
  909. .num_nodes = ARRAY_SIZE(generic_pll_system_nodes),
  910. },
  911. [CLK_VPLL_INT] = {
  912. .name = "vpll_int",
  913. .control_reg = CRF_APB_VPLL_CTRL,
  914. .status_reg = CRF_APB_PLL_STATUS,
  915. .parents = &((int32_t []) {CLK_VPLL_PRE_SRC, CLK_NA_PARENT}),
  916. .nodes = &ignore_unused_pll_nodes,
  917. .num_nodes = ARRAY_SIZE(ignore_unused_pll_nodes),
  918. },
  919. [CLK_VPLL_PRE_SRC] = {
  920. .name = "vpll_pre_src",
  921. .control_reg = CRF_APB_VPLL_CTRL,
  922. .status_reg = CRF_APB_PLL_STATUS,
  923. .parents = &((int32_t []) {
  924. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  925. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  926. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  927. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  928. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  929. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  930. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  931. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  932. CLK_NA_PARENT
  933. }),
  934. .nodes = &generic_pll_pre_src_nodes,
  935. .num_nodes = ARRAY_SIZE(generic_pll_pre_src_nodes),
  936. },
  937. [CLK_VPLL_HALF] = {
  938. .name = "vpll_half",
  939. .control_reg = CRF_APB_VPLL_CTRL,
  940. .status_reg = CRF_APB_PLL_STATUS,
  941. .parents = &((int32_t []) {CLK_VPLL_INT, CLK_NA_PARENT}),
  942. .nodes = &generic_pll_half_nodes,
  943. .num_nodes = ARRAY_SIZE(generic_pll_half_nodes),
  944. },
  945. [CLK_VPLL_INT_MUX] = {
  946. .name = "vpll_int_mux",
  947. .control_reg = CRF_APB_VPLL_CTRL,
  948. .status_reg = CRF_APB_PLL_STATUS,
  949. .parents = &((int32_t []) {
  950. CLK_VPLL_INT,
  951. CLK_VPLL_HALF,
  952. CLK_NA_PARENT
  953. }),
  954. .nodes = &generic_pll_int_nodes,
  955. .num_nodes = ARRAY_SIZE(generic_pll_int_nodes),
  956. },
  957. [CLK_VPLL_POST_SRC] = {
  958. .name = "vpll_post_src",
  959. .control_reg = CRF_APB_VPLL_CTRL,
  960. .status_reg = CRF_APB_PLL_STATUS,
  961. .parents = &((int32_t []) {
  962. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  963. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  964. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  965. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  966. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  967. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  968. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  969. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  970. CLK_NA_PARENT
  971. }),
  972. .nodes = &generic_pll_post_src_nodes,
  973. .num_nodes = ARRAY_SIZE(generic_pll_post_src_nodes),
  974. },
  975. [CLK_VPLL] = {
  976. .name = "vpll",
  977. .control_reg = CRF_APB_VPLL_CTRL,
  978. .status_reg = CRF_APB_PLL_STATUS,
  979. .parents = &((int32_t []) {
  980. CLK_VPLL_INT_MUX,
  981. CLK_VPLL_POST_SRC,
  982. CLK_NA_PARENT
  983. }),
  984. .nodes = &generic_pll_system_nodes,
  985. .num_nodes = ARRAY_SIZE(generic_pll_system_nodes),
  986. },
  987. [CLK_IOPLL_INT] = {
  988. .name = "iopll_int",
  989. .control_reg = CRL_APB_IOPLL_CTRL,
  990. .status_reg = CRF_APB_PLL_STATUS,
  991. .parents = &((int32_t []) {CLK_IOPLL_PRE_SRC, CLK_NA_PARENT}),
  992. .nodes = &generic_pll_nodes,
  993. .num_nodes = ARRAY_SIZE(generic_pll_nodes),
  994. },
  995. [CLK_IOPLL_PRE_SRC] = {
  996. .name = "iopll_pre_src",
  997. .control_reg = CRL_APB_IOPLL_CTRL,
  998. .status_reg = CRF_APB_PLL_STATUS,
  999. .parents = &((int32_t []) {
  1000. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1001. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1002. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1003. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1004. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  1005. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  1006. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  1007. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  1008. CLK_NA_PARENT
  1009. }),
  1010. .nodes = &generic_pll_pre_src_nodes,
  1011. .num_nodes = ARRAY_SIZE(generic_pll_pre_src_nodes),
  1012. },
  1013. [CLK_IOPLL_HALF] = {
  1014. .name = "iopll_half",
  1015. .control_reg = CRL_APB_IOPLL_CTRL,
  1016. .status_reg = CRF_APB_PLL_STATUS,
  1017. .parents = &((int32_t []) {CLK_IOPLL_INT, CLK_NA_PARENT}),
  1018. .nodes = &generic_pll_half_nodes,
  1019. .num_nodes = ARRAY_SIZE(generic_pll_half_nodes),
  1020. },
  1021. [CLK_IOPLL_INT_MUX] = {
  1022. .name = "iopll_int_mux",
  1023. .control_reg = CRL_APB_IOPLL_CTRL,
  1024. .status_reg = CRF_APB_PLL_STATUS,
  1025. .parents = &((int32_t []) {
  1026. CLK_IOPLL_INT,
  1027. CLK_IOPLL_HALF,
  1028. CLK_NA_PARENT
  1029. }),
  1030. .nodes = &generic_pll_int_nodes,
  1031. .num_nodes = ARRAY_SIZE(generic_pll_int_nodes),
  1032. },
  1033. [CLK_IOPLL_POST_SRC] = {
  1034. .name = "iopll_post_src",
  1035. .control_reg = CRL_APB_IOPLL_CTRL,
  1036. .status_reg = CRF_APB_PLL_STATUS,
  1037. .parents = &((int32_t []) {
  1038. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1039. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1040. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1041. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1042. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  1043. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  1044. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  1045. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  1046. CLK_NA_PARENT
  1047. }),
  1048. .nodes = &generic_pll_post_src_nodes,
  1049. .num_nodes = ARRAY_SIZE(generic_pll_post_src_nodes),
  1050. },
  1051. [CLK_IOPLL] = {
  1052. .name = "iopll",
  1053. .control_reg = CRL_APB_IOPLL_CTRL,
  1054. .status_reg = CRF_APB_PLL_STATUS,
  1055. .parents = &((int32_t []) {
  1056. CLK_IOPLL_INT_MUX,
  1057. CLK_IOPLL_POST_SRC,
  1058. CLK_NA_PARENT
  1059. }),
  1060. .nodes = &generic_pll_system_nodes,
  1061. .num_nodes = ARRAY_SIZE(generic_pll_system_nodes),
  1062. },
  1063. [CLK_RPLL_INT] = {
  1064. .name = "rpll_int",
  1065. .control_reg = CRL_APB_RPLL_CTRL,
  1066. .status_reg = CRF_APB_PLL_STATUS,
  1067. .parents = &((int32_t []) {CLK_RPLL_PRE_SRC, CLK_NA_PARENT}),
  1068. .nodes = &generic_pll_nodes,
  1069. .num_nodes = ARRAY_SIZE(generic_pll_nodes),
  1070. },
  1071. [CLK_RPLL_PRE_SRC] = {
  1072. .name = "rpll_pre_src",
  1073. .control_reg = CRL_APB_RPLL_CTRL,
  1074. .status_reg = CRF_APB_PLL_STATUS,
  1075. .parents = &((int32_t []) {
  1076. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1077. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1078. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1079. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1080. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  1081. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  1082. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  1083. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  1084. CLK_NA_PARENT
  1085. }),
  1086. .nodes = &generic_pll_pre_src_nodes,
  1087. .num_nodes = ARRAY_SIZE(generic_pll_pre_src_nodes),
  1088. },
  1089. [CLK_RPLL_HALF] = {
  1090. .name = "rpll_half",
  1091. .control_reg = CRL_APB_RPLL_CTRL,
  1092. .status_reg = CRF_APB_PLL_STATUS,
  1093. .parents = &((int32_t []) {CLK_RPLL_INT, CLK_NA_PARENT}),
  1094. .nodes = &generic_pll_half_nodes,
  1095. .num_nodes = ARRAY_SIZE(generic_pll_half_nodes),
  1096. },
  1097. [CLK_RPLL_INT_MUX] = {
  1098. .name = "rpll_int_mux",
  1099. .control_reg = CRL_APB_RPLL_CTRL,
  1100. .status_reg = CRF_APB_PLL_STATUS,
  1101. .parents = &((int32_t []) {
  1102. CLK_RPLL_INT,
  1103. CLK_RPLL_HALF,
  1104. CLK_NA_PARENT
  1105. }),
  1106. .nodes = &generic_pll_int_nodes,
  1107. .num_nodes = ARRAY_SIZE(generic_pll_int_nodes),
  1108. },
  1109. [CLK_RPLL_POST_SRC] = {
  1110. .name = "rpll_post_src",
  1111. .control_reg = CRL_APB_RPLL_CTRL,
  1112. .status_reg = CRF_APB_PLL_STATUS,
  1113. .parents = &((int32_t []) {
  1114. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1115. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1116. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1117. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1118. EXT_CLK_VIDEO | CLK_EXTERNAL_PARENT,
  1119. EXT_CLK_PSS_ALT_REF | CLK_EXTERNAL_PARENT,
  1120. EXT_CLK_AUX_REF | CLK_EXTERNAL_PARENT,
  1121. EXT_CLK_GT_CRX_REF | CLK_EXTERNAL_PARENT,
  1122. CLK_NA_PARENT
  1123. }),
  1124. .nodes = &generic_pll_post_src_nodes,
  1125. .num_nodes = ARRAY_SIZE(generic_pll_post_src_nodes),
  1126. },
  1127. [CLK_RPLL] = {
  1128. .name = "rpll",
  1129. .control_reg = CRL_APB_RPLL_CTRL,
  1130. .status_reg = CRL_APB_PLL_STATUS,
  1131. .parents = &((int32_t []) {
  1132. CLK_RPLL_INT_MUX,
  1133. CLK_RPLL_POST_SRC,
  1134. CLK_NA_PARENT
  1135. }),
  1136. .nodes = &generic_pll_system_nodes,
  1137. .num_nodes = ARRAY_SIZE(generic_pll_system_nodes),
  1138. },
  1139. /* Peripheral Clocks */
  1140. [CLK_ACPU] = {
  1141. .name = "acpu",
  1142. .control_reg = CRF_APB_ACPU_CTRL,
  1143. .status_reg = 0,
  1144. .parents = &((int32_t []) {
  1145. CLK_APLL,
  1146. CLK_DUMMY_PARENT,
  1147. CLK_DPLL,
  1148. CLK_VPLL,
  1149. CLK_NA_PARENT
  1150. }),
  1151. .nodes = &acpu_nodes,
  1152. .num_nodes = ARRAY_SIZE(acpu_nodes),
  1153. },
  1154. [CLK_ACPU_FULL] = {
  1155. .name = "acpu_full",
  1156. .control_reg = CRF_APB_ACPU_CTRL,
  1157. .status_reg = 0,
  1158. .parents = &((int32_t []) {
  1159. (CLK_ACPU | (PARENT_CLK_NODE2 << CLK_PARENTS_ID_LEN)),
  1160. CLK_NA_PARENT
  1161. }),
  1162. .nodes = &acpu_full_nodes,
  1163. .num_nodes = ARRAY_SIZE(acpu_full_nodes),
  1164. },
  1165. [CLK_DBG_TRACE] = {
  1166. .name = "dbg_trace",
  1167. .control_reg = CRF_APB_DBG_TRACE_CTRL,
  1168. .status_reg = 0,
  1169. .parents = &((int32_t []) {
  1170. CLK_IOPLL_TO_FPD,
  1171. CLK_DUMMY_PARENT,
  1172. CLK_DPLL,
  1173. CLK_APLL,
  1174. CLK_NA_PARENT
  1175. }),
  1176. .nodes = &generic_mux_div_gate_nodes,
  1177. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1178. },
  1179. [CLK_DBG_FPD] = {
  1180. .name = "dbg_fpd",
  1181. .control_reg = CRF_APB_DBG_FPD_CTRL,
  1182. .status_reg = 0,
  1183. .parents = &((int32_t []) {
  1184. CLK_IOPLL_TO_FPD,
  1185. CLK_DUMMY_PARENT,
  1186. CLK_DPLL,
  1187. CLK_APLL,
  1188. CLK_NA_PARENT
  1189. }),
  1190. .nodes = &generic_mux_div_gate_nodes,
  1191. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1192. },
  1193. [CLK_DBG_TSTMP] = {
  1194. .name = "dbg_tstmp",
  1195. .control_reg = CRF_APB_DBG_TSTMP_CTRL,
  1196. .status_reg = 0,
  1197. .parents = &((int32_t []) {
  1198. CLK_IOPLL_TO_FPD,
  1199. CLK_DUMMY_PARENT,
  1200. CLK_DPLL,
  1201. CLK_APLL,
  1202. CLK_NA_PARENT
  1203. }),
  1204. .nodes = &generic_mux_div_nodes,
  1205. .num_nodes = ARRAY_SIZE(generic_mux_div_nodes),
  1206. },
  1207. [CLK_DP_VIDEO_REF] = {
  1208. .name = "dp_video_ref",
  1209. .control_reg = CRF_APB_DP_VIDEO_REF_CTRL,
  1210. .status_reg = 0,
  1211. .parents = &((int32_t []) {
  1212. CLK_VPLL,
  1213. CLK_DUMMY_PARENT,
  1214. CLK_DPLL,
  1215. CLK_RPLL_TO_FPD,
  1216. CLK_NA_PARENT
  1217. }),
  1218. .nodes = &dp_audio_video_ref_nodes,
  1219. .num_nodes = ARRAY_SIZE(dp_audio_video_ref_nodes),
  1220. },
  1221. [CLK_DP_AUDIO_REF] = {
  1222. .name = "dp_audio_ref",
  1223. .control_reg = CRF_APB_DP_AUDIO_REF_CTRL,
  1224. .status_reg = 0,
  1225. .parents = &((int32_t []) {
  1226. CLK_VPLL,
  1227. CLK_DUMMY_PARENT,
  1228. CLK_DPLL,
  1229. CLK_RPLL_TO_FPD,
  1230. CLK_NA_PARENT
  1231. }),
  1232. .nodes = &dp_audio_video_ref_nodes,
  1233. .num_nodes = ARRAY_SIZE(dp_audio_video_ref_nodes),
  1234. },
  1235. [CLK_DP_STC_REF] = {
  1236. .name = "dp_stc_ref",
  1237. .control_reg = CRF_APB_DP_STC_REF_CTRL,
  1238. .status_reg = 0,
  1239. .parents = &((int32_t []) {
  1240. CLK_VPLL,
  1241. CLK_DUMMY_PARENT,
  1242. CLK_DPLL,
  1243. CLK_RPLL_TO_FPD,
  1244. CLK_NA_PARENT
  1245. }),
  1246. .nodes = &generic_mux_div_div_gate_nodes,
  1247. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1248. },
  1249. [CLK_DPDMA_REF] = {
  1250. .name = "dpdma_ref",
  1251. .control_reg = CRF_APB_DPDMA_REF_CTRL,
  1252. .status_reg = 0,
  1253. .parents = &((int32_t []) {
  1254. CLK_APLL,
  1255. CLK_DUMMY_PARENT,
  1256. CLK_VPLL,
  1257. CLK_DPLL,
  1258. CLK_NA_PARENT
  1259. }),
  1260. .nodes = &generic_mux_div_gate_nodes,
  1261. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1262. },
  1263. [CLK_DDR_REF] = {
  1264. .name = "ddr_ref",
  1265. .control_reg = CRF_APB_DDR_CTRL,
  1266. .status_reg = 0,
  1267. .parents = &((int32_t []) {
  1268. CLK_DPLL,
  1269. CLK_VPLL,
  1270. CLK_NA_PARENT
  1271. }),
  1272. .nodes = &ddr_nodes,
  1273. .num_nodes = ARRAY_SIZE(ddr_nodes),
  1274. },
  1275. [CLK_GPU_REF] = {
  1276. .name = "gpu_ref",
  1277. .control_reg = CRF_APB_GPU_REF_CTRL,
  1278. .status_reg = 0,
  1279. .parents = &((int32_t []) {
  1280. CLK_IOPLL_TO_FPD,
  1281. CLK_DUMMY_PARENT,
  1282. CLK_VPLL,
  1283. CLK_DPLL,
  1284. CLK_NA_PARENT
  1285. }),
  1286. .nodes = &generic_mux_div_gate_nodes,
  1287. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1288. },
  1289. [CLK_SATA_REF] = {
  1290. .name = "sata_ref",
  1291. .control_reg = CRF_APB_SATA_REF_CTRL,
  1292. .status_reg = 0,
  1293. .parents = &((int32_t []) {
  1294. CLK_IOPLL_TO_FPD,
  1295. CLK_DUMMY_PARENT,
  1296. CLK_APLL,
  1297. CLK_DPLL,
  1298. CLK_NA_PARENT
  1299. }),
  1300. .nodes = &generic_mux_div_gate_nodes,
  1301. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1302. },
  1303. [CLK_PCIE_REF] = {
  1304. .name = "pcie_ref",
  1305. .control_reg = CRF_APB_PCIE_REF_CTRL,
  1306. .status_reg = 0,
  1307. .parents = &((int32_t []) {
  1308. CLK_IOPLL_TO_FPD,
  1309. CLK_DUMMY_PARENT,
  1310. CLK_RPLL_TO_FPD,
  1311. CLK_DPLL,
  1312. CLK_NA_PARENT
  1313. }),
  1314. .nodes = &generic_mux_div_gate_nodes,
  1315. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1316. },
  1317. [CLK_GDMA_REF] = {
  1318. .name = "gdma_ref",
  1319. .control_reg = CRF_APB_GDMA_REF_CTRL,
  1320. .status_reg = 0,
  1321. .parents = &((int32_t []) {
  1322. CLK_APLL,
  1323. CLK_DUMMY_PARENT,
  1324. CLK_VPLL,
  1325. CLK_DPLL,
  1326. CLK_NA_PARENT
  1327. }),
  1328. .nodes = &generic_mux_div_gate_nodes,
  1329. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1330. },
  1331. [CLK_GTGREF0_REF] = {
  1332. .name = "gtgref0_ref",
  1333. .control_reg = CRF_APB_GTGREF0_REF_CTRL,
  1334. .status_reg = 0,
  1335. .parents = &((int32_t []) {
  1336. CLK_IOPLL_TO_FPD,
  1337. CLK_DUMMY_PARENT,
  1338. CLK_APLL,
  1339. CLK_DPLL,
  1340. CLK_NA_PARENT
  1341. }),
  1342. .nodes = &generic_mux_div_gate_nodes,
  1343. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1344. },
  1345. [CLK_TOPSW_MAIN] = {
  1346. .name = "topsw_main",
  1347. .control_reg = CRF_APB_TOPSW_MAIN_CTRL,
  1348. .status_reg = 0,
  1349. .parents = &((int32_t []) {
  1350. CLK_APLL,
  1351. CLK_DUMMY_PARENT,
  1352. CLK_VPLL,
  1353. CLK_DPLL,
  1354. CLK_NA_PARENT
  1355. }),
  1356. .nodes = &generic_mux_div_unused_gate_nodes,
  1357. .num_nodes = ARRAY_SIZE(generic_mux_div_unused_gate_nodes),
  1358. },
  1359. [CLK_TOPSW_LSBUS] = {
  1360. .name = "topsw_lsbus",
  1361. .control_reg = CRF_APB_TOPSW_LSBUS_CTRL,
  1362. .status_reg = 0,
  1363. .parents = &((int32_t []) {
  1364. CLK_APLL,
  1365. CLK_DUMMY_PARENT,
  1366. CLK_IOPLL_TO_FPD,
  1367. CLK_DPLL,
  1368. CLK_NA_PARENT
  1369. }),
  1370. .nodes = &generic_mux_div_unused_gate_nodes,
  1371. .num_nodes = ARRAY_SIZE(generic_mux_div_unused_gate_nodes),
  1372. },
  1373. [CLK_IOU_SWITCH] = {
  1374. .name = "iou_switch",
  1375. .control_reg = CRL_APB_IOU_SWITCH_CTRL,
  1376. .status_reg = 0,
  1377. .parents = &((int32_t []) {
  1378. CLK_RPLL,
  1379. CLK_DUMMY_PARENT,
  1380. CLK_IOPLL,
  1381. CLK_DPLL_TO_LPD,
  1382. CLK_NA_PARENT
  1383. }),
  1384. .nodes = &generic_mux_div_unused_gate_nodes,
  1385. .num_nodes = ARRAY_SIZE(generic_mux_div_unused_gate_nodes),
  1386. },
  1387. [CLK_GEM0_REF_UNGATED] = {
  1388. .name = "gem0_ref_ung",
  1389. .control_reg = CRL_APB_GEM0_REF_CTRL,
  1390. .status_reg = 0,
  1391. .parents = &((int32_t []) {
  1392. CLK_IOPLL,
  1393. CLK_DUMMY_PARENT,
  1394. CLK_RPLL,
  1395. CLK_DPLL_TO_LPD,
  1396. CLK_NA_PARENT
  1397. }),
  1398. .nodes = &gem_ref_ungated_nodes,
  1399. .num_nodes = ARRAY_SIZE(gem_ref_ungated_nodes),
  1400. },
  1401. [CLK_GEM1_REF_UNGATED] = {
  1402. .name = "gem1_ref_ung",
  1403. .control_reg = CRL_APB_GEM1_REF_CTRL,
  1404. .status_reg = 0,
  1405. .parents = &((int32_t []) {
  1406. CLK_IOPLL,
  1407. CLK_DUMMY_PARENT,
  1408. CLK_RPLL,
  1409. CLK_DPLL_TO_LPD,
  1410. CLK_NA_PARENT
  1411. }),
  1412. .nodes = &gem_ref_ungated_nodes,
  1413. .num_nodes = ARRAY_SIZE(gem_ref_ungated_nodes),
  1414. },
  1415. [CLK_GEM2_REF_UNGATED] = {
  1416. .name = "gem2_ref_ung",
  1417. .control_reg = CRL_APB_GEM2_REF_CTRL,
  1418. .status_reg = 0,
  1419. .parents = &((int32_t []) {
  1420. CLK_IOPLL,
  1421. CLK_DUMMY_PARENT,
  1422. CLK_RPLL,
  1423. CLK_DPLL_TO_LPD,
  1424. CLK_NA_PARENT
  1425. }),
  1426. .nodes = &gem_ref_ungated_nodes,
  1427. .num_nodes = ARRAY_SIZE(gem_ref_ungated_nodes),
  1428. },
  1429. [CLK_GEM3_REF_UNGATED] = {
  1430. .name = "gem3_ref_ung",
  1431. .control_reg = CRL_APB_GEM3_REF_CTRL,
  1432. .status_reg = 0,
  1433. .parents = &((int32_t []) {
  1434. CLK_IOPLL,
  1435. CLK_DUMMY_PARENT,
  1436. CLK_RPLL,
  1437. CLK_DPLL_TO_LPD,
  1438. CLK_NA_PARENT
  1439. }),
  1440. .nodes = &gem_ref_ungated_nodes,
  1441. .num_nodes = ARRAY_SIZE(gem_ref_ungated_nodes),
  1442. },
  1443. [CLK_GEM0_REF] = {
  1444. .name = "gem0_ref",
  1445. .control_reg = IOU_SLCR_GEM_CLK_CTRL,
  1446. .status_reg = 0,
  1447. .parents = &((int32_t []) {
  1448. CLK_GEM0_REF_UNGATED |
  1449. (PARENT_CLK_NODE3 << CLK_PARENTS_ID_LEN),
  1450. EXT_CLK_GEM0_TX_EMIO | CLK_EXTERNAL_PARENT,
  1451. CLK_NA_PARENT
  1452. }),
  1453. .nodes = &gem0_ref_nodes,
  1454. .num_nodes = ARRAY_SIZE(gem0_ref_nodes),
  1455. },
  1456. [CLK_GEM1_REF] = {
  1457. .name = "gem1_ref",
  1458. .control_reg = IOU_SLCR_GEM_CLK_CTRL,
  1459. .status_reg = 0,
  1460. .parents = &((int32_t []) {
  1461. CLK_GEM1_REF_UNGATED |
  1462. (PARENT_CLK_NODE3 << CLK_PARENTS_ID_LEN),
  1463. EXT_CLK_GEM1_TX_EMIO | CLK_EXTERNAL_PARENT,
  1464. CLK_NA_PARENT
  1465. }),
  1466. .nodes = &gem1_ref_nodes,
  1467. .num_nodes = ARRAY_SIZE(gem1_ref_nodes),
  1468. },
  1469. [CLK_GEM2_REF] = {
  1470. .name = "gem2_ref",
  1471. .control_reg = IOU_SLCR_GEM_CLK_CTRL,
  1472. .status_reg = 0,
  1473. .parents = &((int32_t []) {
  1474. CLK_GEM2_REF_UNGATED |
  1475. (PARENT_CLK_NODE3 << CLK_PARENTS_ID_LEN),
  1476. EXT_CLK_GEM2_TX_EMIO | CLK_EXTERNAL_PARENT,
  1477. CLK_NA_PARENT
  1478. }),
  1479. .nodes = &gem2_ref_nodes,
  1480. .num_nodes = ARRAY_SIZE(gem2_ref_nodes),
  1481. },
  1482. [CLK_GEM3_REF] = {
  1483. .name = "gem3_ref",
  1484. .control_reg = IOU_SLCR_GEM_CLK_CTRL,
  1485. .status_reg = 0,
  1486. .parents = &((int32_t []) {
  1487. CLK_GEM3_REF_UNGATED |
  1488. (PARENT_CLK_NODE3 << CLK_PARENTS_ID_LEN),
  1489. EXT_CLK_GEM3_TX_EMIO | CLK_EXTERNAL_PARENT,
  1490. CLK_NA_PARENT
  1491. }),
  1492. .nodes = &gem3_ref_nodes,
  1493. .num_nodes = ARRAY_SIZE(gem3_ref_nodes),
  1494. },
  1495. [CLK_USB0_BUS_REF] = {
  1496. .name = "usb0_bus_ref",
  1497. .control_reg = CRL_APB_USB0_BUS_REF_CTRL,
  1498. .status_reg = 0,
  1499. .parents = &((int32_t []) {
  1500. CLK_IOPLL,
  1501. CLK_DUMMY_PARENT,
  1502. CLK_RPLL,
  1503. CLK_DPLL_TO_LPD,
  1504. CLK_NA_PARENT
  1505. }),
  1506. .nodes = &usb_nodes,
  1507. .num_nodes = ARRAY_SIZE(usb_nodes),
  1508. },
  1509. [CLK_USB1_BUS_REF] = {
  1510. .name = "usb1_bus_ref",
  1511. .control_reg = CRL_APB_USB1_BUS_REF_CTRL,
  1512. .status_reg = 0,
  1513. .parents = &((int32_t []) {
  1514. CLK_IOPLL,
  1515. CLK_DUMMY_PARENT,
  1516. CLK_RPLL,
  1517. CLK_DPLL_TO_LPD,
  1518. CLK_NA_PARENT
  1519. }),
  1520. .nodes = &usb_nodes,
  1521. .num_nodes = ARRAY_SIZE(usb_nodes),
  1522. },
  1523. [CLK_USB3_DUAL_REF] = {
  1524. .name = "usb3_dual_ref",
  1525. .control_reg = CRL_APB_USB3_DUAL_REF_CTRL,
  1526. .status_reg = 0,
  1527. .parents = &((int32_t []) {
  1528. CLK_IOPLL,
  1529. CLK_DUMMY_PARENT,
  1530. CLK_RPLL,
  1531. CLK_DPLL_TO_LPD,
  1532. CLK_NA_PARENT
  1533. }),
  1534. .nodes = &usb_nodes,
  1535. .num_nodes = ARRAY_SIZE(usb_nodes),
  1536. },
  1537. [CLK_QSPI_REF] = {
  1538. .name = "qspi_ref",
  1539. .control_reg = CRL_APB_QSPI_REF_CTRL,
  1540. .status_reg = 0,
  1541. .parents = &((int32_t []) {
  1542. CLK_IOPLL,
  1543. CLK_DUMMY_PARENT,
  1544. CLK_RPLL,
  1545. CLK_DPLL_TO_LPD,
  1546. CLK_NA_PARENT
  1547. }),
  1548. .nodes = &generic_mux_div_div_gate_nodes,
  1549. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1550. },
  1551. [CLK_SDIO0_REF] = {
  1552. .name = "sdio0_ref",
  1553. .control_reg = CRL_APB_SDIO0_REF_CTRL,
  1554. .status_reg = 0,
  1555. .parents = &((int32_t []) {
  1556. CLK_IOPLL,
  1557. CLK_DUMMY_PARENT,
  1558. CLK_RPLL,
  1559. CLK_VPLL_TO_LPD,
  1560. CLK_NA_PARENT
  1561. }),
  1562. .nodes = &generic_mux_div_div_gate_nodes,
  1563. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1564. },
  1565. [CLK_SDIO1_REF] = {
  1566. .name = "sdio1_ref",
  1567. .control_reg = CRL_APB_SDIO1_REF_CTRL,
  1568. .status_reg = 0,
  1569. .parents = &((int32_t []) {
  1570. CLK_IOPLL,
  1571. CLK_DUMMY_PARENT,
  1572. CLK_RPLL,
  1573. CLK_VPLL_TO_LPD,
  1574. CLK_NA_PARENT
  1575. }),
  1576. .nodes = &generic_mux_div_div_gate_nodes,
  1577. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1578. },
  1579. [CLK_UART0_REF] = {
  1580. .name = "uart0_ref",
  1581. .control_reg = CRL_APB_UART0_REF_CTRL,
  1582. .status_reg = 0,
  1583. .parents = &((int32_t []) {
  1584. CLK_IOPLL,
  1585. CLK_DUMMY_PARENT,
  1586. CLK_RPLL,
  1587. CLK_DPLL_TO_LPD,
  1588. CLK_NA_PARENT
  1589. }),
  1590. .nodes = &generic_mux_div_div_gate_nodes,
  1591. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1592. },
  1593. [CLK_UART1_REF] = {
  1594. .name = "uart1_ref",
  1595. .control_reg = CRL_APB_UART1_REF_CTRL,
  1596. .status_reg = 0,
  1597. .parents = &((int32_t []) {
  1598. CLK_IOPLL,
  1599. CLK_DUMMY_PARENT,
  1600. CLK_RPLL,
  1601. CLK_DPLL_TO_LPD,
  1602. CLK_NA_PARENT
  1603. }),
  1604. .nodes = &generic_mux_div_div_gate_nodes,
  1605. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1606. },
  1607. [CLK_SPI0_REF] = {
  1608. .name = "spi0_ref",
  1609. .control_reg = CRL_APB_SPI0_REF_CTRL,
  1610. .status_reg = 0,
  1611. .parents = &((int32_t []) {
  1612. CLK_IOPLL,
  1613. CLK_DUMMY_PARENT,
  1614. CLK_RPLL,
  1615. CLK_DPLL_TO_LPD,
  1616. CLK_NA_PARENT
  1617. }),
  1618. .nodes = &generic_mux_div_div_gate_nodes,
  1619. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1620. },
  1621. [CLK_SPI1_REF] = {
  1622. .name = "spi1_ref",
  1623. .control_reg = CRL_APB_SPI1_REF_CTRL,
  1624. .status_reg = 0,
  1625. .parents = &((int32_t []) {
  1626. CLK_IOPLL,
  1627. CLK_DUMMY_PARENT,
  1628. CLK_RPLL,
  1629. CLK_DPLL_TO_LPD,
  1630. CLK_NA_PARENT
  1631. }),
  1632. .nodes = &generic_mux_div_div_gate_nodes,
  1633. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1634. },
  1635. [CLK_CAN0_REF] = {
  1636. .name = "can0_ref",
  1637. .control_reg = CRL_APB_CAN0_REF_CTRL,
  1638. .status_reg = 0,
  1639. .parents = &((int32_t []) {
  1640. CLK_IOPLL,
  1641. CLK_DUMMY_PARENT,
  1642. CLK_RPLL,
  1643. CLK_DPLL_TO_LPD,
  1644. CLK_NA_PARENT
  1645. }),
  1646. .nodes = &generic_mux_div_div_gate_nodes,
  1647. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1648. },
  1649. [CLK_CAN1_REF] = {
  1650. .name = "can1_ref",
  1651. .control_reg = CRL_APB_CAN1_REF_CTRL,
  1652. .status_reg = 0,
  1653. .parents = &((int32_t []) {
  1654. CLK_IOPLL,
  1655. CLK_DUMMY_PARENT,
  1656. CLK_RPLL,
  1657. CLK_DPLL_TO_LPD,
  1658. CLK_NA_PARENT
  1659. }),
  1660. .nodes = &generic_mux_div_div_gate_nodes,
  1661. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1662. },
  1663. [CLK_NAND_REF] = {
  1664. .name = "nand_ref",
  1665. .control_reg = CRL_APB_NAND_REF_CTRL,
  1666. .status_reg = 0,
  1667. .parents = &((int32_t []) {
  1668. CLK_IOPLL,
  1669. CLK_DUMMY_PARENT,
  1670. CLK_RPLL,
  1671. CLK_DPLL_TO_LPD,
  1672. CLK_NA_PARENT
  1673. }),
  1674. .nodes = &generic_mux_div_div_gate_nodes,
  1675. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1676. },
  1677. [CLK_GEM_TSU_REF] = {
  1678. .name = "gem_tsu_ref",
  1679. .control_reg = CRL_APB_GEM_TSU_REF_CTRL,
  1680. .status_reg = 0,
  1681. .parents = &((int32_t []) {
  1682. CLK_IOPLL,
  1683. CLK_DUMMY_PARENT,
  1684. CLK_RPLL,
  1685. CLK_DPLL_TO_LPD,
  1686. CLK_NA_PARENT
  1687. }),
  1688. .nodes = &generic_mux_div_div_gate_nodes,
  1689. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1690. },
  1691. [CLK_DLL_REF] = {
  1692. .name = "dll_ref",
  1693. .control_reg = CRL_APB_DLL_REF_CTRL,
  1694. .status_reg = 0,
  1695. .parents = &((int32_t []) {
  1696. CLK_IOPLL,
  1697. CLK_RPLL,
  1698. CLK_NA_PARENT
  1699. }),
  1700. .nodes = &dll_ref_nodes,
  1701. .num_nodes = ARRAY_SIZE(dll_ref_nodes),
  1702. },
  1703. [CLK_ADMA_REF] = {
  1704. .name = "adma_ref",
  1705. .control_reg = CRL_APB_ADMA_REF_CTRL,
  1706. .status_reg = 0,
  1707. .parents = &((int32_t []) {
  1708. CLK_RPLL,
  1709. CLK_DUMMY_PARENT,
  1710. CLK_IOPLL,
  1711. CLK_DPLL_TO_LPD,
  1712. CLK_NA_PARENT
  1713. }),
  1714. .nodes = &generic_mux_div_gate_nodes,
  1715. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1716. },
  1717. [CLK_DBG_LPD] = {
  1718. .name = "dbg_lpd",
  1719. .control_reg = CRL_APB_DBG_LPD_CTRL,
  1720. .status_reg = 0,
  1721. .parents = &((int32_t []) {
  1722. CLK_RPLL,
  1723. CLK_DUMMY_PARENT,
  1724. CLK_IOPLL,
  1725. CLK_DPLL_TO_LPD,
  1726. CLK_NA_PARENT
  1727. }),
  1728. .nodes = &generic_mux_div_gate_nodes,
  1729. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1730. },
  1731. [CLK_CPU_R5] = {
  1732. .name = "cpu_r5",
  1733. .control_reg = CRL_APB_CPU_R5_CTRL,
  1734. .status_reg = 0,
  1735. .parents = &((int32_t []) {
  1736. CLK_RPLL,
  1737. CLK_DUMMY_PARENT,
  1738. CLK_IOPLL,
  1739. CLK_DPLL_TO_LPD,
  1740. CLK_NA_PARENT
  1741. }),
  1742. .nodes = &generic_mux_div_unused_gate_nodes,
  1743. .num_nodes = ARRAY_SIZE(generic_mux_div_unused_gate_nodes),
  1744. },
  1745. [CLK_CSU_PLL] = {
  1746. .name = "csu_pll",
  1747. .control_reg = CRL_APB_CSU_PLL_CTRL,
  1748. .status_reg = 0,
  1749. .parents = &((int32_t []) {
  1750. CLK_IOPLL,
  1751. CLK_DUMMY_PARENT,
  1752. CLK_RPLL,
  1753. CLK_DPLL_TO_LPD,
  1754. CLK_NA_PARENT
  1755. }),
  1756. .nodes = &generic_mux_div_gate_nodes,
  1757. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1758. },
  1759. [CLK_PCAP] = {
  1760. .name = "pcap",
  1761. .control_reg = CRL_APB_PCAP_CTRL,
  1762. .status_reg = 0,
  1763. .parents = &((int32_t []) {
  1764. CLK_IOPLL,
  1765. CLK_DUMMY_PARENT,
  1766. CLK_RPLL,
  1767. CLK_DPLL_TO_LPD,
  1768. CLK_NA_PARENT
  1769. }),
  1770. .nodes = &generic_mux_div_gate_nodes,
  1771. .num_nodes = ARRAY_SIZE(generic_mux_div_gate_nodes),
  1772. },
  1773. [CLK_LPD_LSBUS] = {
  1774. .name = "lpd_lsbus",
  1775. .control_reg = CRL_APB_LPD_LSBUS_CTRL,
  1776. .status_reg = 0,
  1777. .parents = &((int32_t []) {
  1778. CLK_RPLL,
  1779. CLK_DUMMY_PARENT,
  1780. CLK_IOPLL,
  1781. CLK_DPLL_TO_LPD,
  1782. CLK_NA_PARENT
  1783. }),
  1784. .nodes = &generic_mux_div_unused_gate_nodes,
  1785. .num_nodes = ARRAY_SIZE(generic_mux_div_unused_gate_nodes),
  1786. },
  1787. [CLK_LPD_SWITCH] = {
  1788. .name = "lpd_switch",
  1789. .control_reg = CRL_APB_LPD_SWITCH_CTRL,
  1790. .status_reg = 0,
  1791. .parents = &((int32_t []) {
  1792. CLK_RPLL,
  1793. CLK_DUMMY_PARENT,
  1794. CLK_IOPLL,
  1795. CLK_DPLL_TO_LPD,
  1796. CLK_NA_PARENT
  1797. }),
  1798. .nodes = &generic_mux_div_unused_gate_nodes,
  1799. .num_nodes = ARRAY_SIZE(generic_mux_div_unused_gate_nodes),
  1800. },
  1801. [CLK_I2C0_REF] = {
  1802. .name = "i2c0_ref",
  1803. .control_reg = CRL_APB_I2C0_REF_CTRL,
  1804. .status_reg = 0,
  1805. .parents = &((int32_t []) {
  1806. CLK_IOPLL,
  1807. CLK_DUMMY_PARENT,
  1808. CLK_RPLL,
  1809. CLK_DPLL_TO_LPD,
  1810. CLK_NA_PARENT
  1811. }),
  1812. .nodes = &generic_mux_div_div_gate_nodes,
  1813. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1814. },
  1815. [CLK_I2C1_REF] = {
  1816. .name = "i2c1_ref",
  1817. .control_reg = CRL_APB_I2C1_REF_CTRL,
  1818. .status_reg = 0,
  1819. .parents = &((int32_t []) {
  1820. CLK_IOPLL,
  1821. CLK_DUMMY_PARENT,
  1822. CLK_RPLL,
  1823. CLK_DPLL_TO_LPD,
  1824. CLK_NA_PARENT
  1825. }),
  1826. .nodes = &generic_mux_div_div_gate_nodes,
  1827. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1828. },
  1829. [CLK_TIMESTAMP_REF] = {
  1830. .name = "timestamp_ref",
  1831. .control_reg = CRL_APB_TIMESTAMP_REF_CTRL,
  1832. .status_reg = 0,
  1833. .parents = &((int32_t []) {
  1834. CLK_IOPLL,
  1835. CLK_DUMMY_PARENT,
  1836. CLK_RPLL,
  1837. CLK_DPLL_TO_LPD,
  1838. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1839. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1840. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1841. EXT_CLK_PSS_REF | CLK_EXTERNAL_PARENT,
  1842. CLK_NA_PARENT
  1843. }),
  1844. .nodes = &timestamp_ref_nodes,
  1845. .num_nodes = ARRAY_SIZE(timestamp_ref_nodes),
  1846. },
  1847. [CLK_PL0_REF] = {
  1848. .name = "pl0_ref",
  1849. .control_reg = CRL_APB_PL0_REF_CTRL,
  1850. .status_reg = 0,
  1851. .parents = &((int32_t []) {
  1852. CLK_IOPLL,
  1853. CLK_DUMMY_PARENT,
  1854. CLK_RPLL,
  1855. CLK_DPLL_TO_LPD,
  1856. CLK_NA_PARENT
  1857. }),
  1858. .nodes = &pl_nodes,
  1859. .num_nodes = ARRAY_SIZE(pl_nodes),
  1860. },
  1861. [CLK_PL1_REF] = {
  1862. .name = "pl1_ref",
  1863. .control_reg = CRL_APB_PL1_REF_CTRL,
  1864. .status_reg = 0,
  1865. .parents = &((int32_t []) {
  1866. CLK_IOPLL,
  1867. CLK_DUMMY_PARENT,
  1868. CLK_RPLL,
  1869. CLK_DPLL_TO_LPD,
  1870. CLK_NA_PARENT
  1871. }),
  1872. .nodes = &pl_nodes,
  1873. .num_nodes = ARRAY_SIZE(pl_nodes),
  1874. },
  1875. [CLK_PL2_REF] = {
  1876. .name = "pl2_ref",
  1877. .control_reg = CRL_APB_PL2_REF_CTRL,
  1878. .status_reg = 0,
  1879. .parents = &((int32_t []) {
  1880. CLK_IOPLL,
  1881. CLK_DUMMY_PARENT,
  1882. CLK_RPLL,
  1883. CLK_DPLL_TO_LPD,
  1884. CLK_NA_PARENT
  1885. }),
  1886. .nodes = &pl_nodes,
  1887. .num_nodes = ARRAY_SIZE(pl_nodes),
  1888. },
  1889. [CLK_PL3_REF] = {
  1890. .name = "pl3_ref",
  1891. .control_reg = CRL_APB_PL3_REF_CTRL,
  1892. .status_reg = 0,
  1893. .parents = &((int32_t []) {
  1894. CLK_IOPLL,
  1895. CLK_DUMMY_PARENT,
  1896. CLK_RPLL,
  1897. CLK_DPLL_TO_LPD,
  1898. CLK_NA_PARENT
  1899. }),
  1900. .nodes = &pl_nodes,
  1901. .num_nodes = ARRAY_SIZE(pl_nodes),
  1902. },
  1903. [CLK_AMS_REF] = {
  1904. .name = "ams_ref",
  1905. .control_reg = CRL_APB_AMS_REF_CTRL,
  1906. .status_reg = 0,
  1907. .parents = &((int32_t []) {
  1908. CLK_RPLL,
  1909. CLK_DUMMY_PARENT,
  1910. CLK_IOPLL,
  1911. CLK_DPLL_TO_LPD,
  1912. CLK_NA_PARENT
  1913. }),
  1914. .nodes = &generic_mux_div_div_gate_nodes,
  1915. .num_nodes = ARRAY_SIZE(generic_mux_div_div_gate_nodes),
  1916. },
  1917. [CLK_IOPLL_TO_FPD] = {
  1918. .name = "iopll_to_fpd",
  1919. .control_reg = CRL_APB_IOPLL_TO_FPD_CTRL,
  1920. .status_reg = 0,
  1921. .parents = &((int32_t []) {CLK_IOPLL, CLK_NA_PARENT}),
  1922. .nodes = &generic_domain_crossing_nodes,
  1923. .num_nodes = ARRAY_SIZE(generic_domain_crossing_nodes),
  1924. },
  1925. [CLK_RPLL_TO_FPD] = {
  1926. .name = "rpll_to_fpd",
  1927. .control_reg = CRL_APB_RPLL_TO_FPD_CTRL,
  1928. .status_reg = 0,
  1929. .parents = &((int32_t []) {CLK_RPLL, CLK_NA_PARENT}),
  1930. .nodes = &rpll_to_fpd_nodes,
  1931. .num_nodes = ARRAY_SIZE(rpll_to_fpd_nodes),
  1932. },
  1933. [CLK_APLL_TO_LPD] = {
  1934. .name = "apll_to_lpd",
  1935. .control_reg = CRF_APB_APLL_TO_LPD_CTRL,
  1936. .status_reg = 0,
  1937. .parents = &((int32_t []) {CLK_APLL, CLK_NA_PARENT}),
  1938. .nodes = &generic_domain_crossing_nodes,
  1939. .num_nodes = ARRAY_SIZE(generic_domain_crossing_nodes),
  1940. },
  1941. [CLK_DPLL_TO_LPD] = {
  1942. .name = "dpll_to_lpd",
  1943. .control_reg = CRF_APB_DPLL_TO_LPD_CTRL,
  1944. .status_reg = 0,
  1945. .parents = &((int32_t []) {CLK_DPLL, CLK_NA_PARENT}),
  1946. .nodes = &generic_domain_crossing_nodes,
  1947. .num_nodes = ARRAY_SIZE(generic_domain_crossing_nodes),
  1948. },
  1949. [CLK_VPLL_TO_LPD] = {
  1950. .name = "vpll_to_lpd",
  1951. .control_reg = CRF_APB_VPLL_TO_LPD_CTRL,
  1952. .status_reg = 0,
  1953. .parents = &((int32_t []) {CLK_VPLL, CLK_NA_PARENT}),
  1954. .nodes = &generic_domain_crossing_nodes,
  1955. .num_nodes = ARRAY_SIZE(generic_domain_crossing_nodes),
  1956. },
  1957. [CLK_GEM0_TX] = {
  1958. .name = "gem0_tx",
  1959. .control_reg = CRL_APB_GEM0_REF_CTRL,
  1960. .status_reg = 0,
  1961. .parents = &((int32_t []) {
  1962. CLK_GEM0_REF,
  1963. CLK_NA_PARENT
  1964. }),
  1965. .nodes = &gem_tx_nodes,
  1966. .num_nodes = ARRAY_SIZE(gem_tx_nodes),
  1967. },
  1968. [CLK_GEM1_TX] = {
  1969. .name = "gem1_tx",
  1970. .control_reg = CRL_APB_GEM1_REF_CTRL,
  1971. .status_reg = 0,
  1972. .parents = &((int32_t []) {
  1973. CLK_GEM1_REF,
  1974. CLK_NA_PARENT
  1975. }),
  1976. .nodes = &gem_tx_nodes,
  1977. .num_nodes = ARRAY_SIZE(gem_tx_nodes),
  1978. },
  1979. [CLK_GEM2_TX] = {
  1980. .name = "gem2_tx",
  1981. .control_reg = CRL_APB_GEM2_REF_CTRL,
  1982. .status_reg = 0,
  1983. .parents = &((int32_t []) {
  1984. CLK_GEM2_REF,
  1985. CLK_NA_PARENT
  1986. }),
  1987. .nodes = &gem_tx_nodes,
  1988. .num_nodes = ARRAY_SIZE(gem_tx_nodes),
  1989. },
  1990. [CLK_GEM3_TX] = {
  1991. .name = "gem3_tx",
  1992. .control_reg = CRL_APB_GEM3_REF_CTRL,
  1993. .status_reg = 0,
  1994. .parents = &((int32_t []) {
  1995. CLK_GEM3_REF,
  1996. CLK_NA_PARENT
  1997. }),
  1998. .nodes = &gem_tx_nodes,
  1999. .num_nodes = ARRAY_SIZE(gem_tx_nodes),
  2000. },
  2001. [CLK_GEM0_RX] = {
  2002. .name = "gem0_rx",
  2003. .control_reg = CRL_APB_GEM0_REF_CTRL,
  2004. .status_reg = 0,
  2005. .parents = &((int32_t []) {
  2006. EXT_CLK_GEM0_RX_EMIO | CLK_EXTERNAL_PARENT,
  2007. CLK_NA_PARENT
  2008. }),
  2009. .nodes = &gem_rx_nodes,
  2010. .num_nodes = ARRAY_SIZE(gem_rx_nodes),
  2011. },
  2012. [CLK_GEM1_RX] = {
  2013. .name = "gem1_rx",
  2014. .control_reg = CRL_APB_GEM1_REF_CTRL,
  2015. .status_reg = 0,
  2016. .parents = &((int32_t []) {
  2017. EXT_CLK_GEM1_RX_EMIO | CLK_EXTERNAL_PARENT,
  2018. CLK_NA_PARENT
  2019. }),
  2020. .nodes = &gem_rx_nodes,
  2021. .num_nodes = ARRAY_SIZE(gem_rx_nodes),
  2022. },
  2023. [CLK_GEM2_RX] = {
  2024. .name = "gem2_rx",
  2025. .control_reg = CRL_APB_GEM2_REF_CTRL,
  2026. .status_reg = 0,
  2027. .parents = &((int32_t []) {
  2028. EXT_CLK_GEM2_RX_EMIO | CLK_EXTERNAL_PARENT,
  2029. CLK_NA_PARENT
  2030. }),
  2031. .nodes = &gem_rx_nodes,
  2032. .num_nodes = ARRAY_SIZE(gem_rx_nodes),
  2033. },
  2034. [CLK_GEM3_RX] = {
  2035. .name = "gem3_rx",
  2036. .control_reg = CRL_APB_GEM3_REF_CTRL,
  2037. .status_reg = 0,
  2038. .parents = &((int32_t []) {
  2039. EXT_CLK_GEM3_RX_EMIO | CLK_EXTERNAL_PARENT,
  2040. CLK_NA_PARENT
  2041. }),
  2042. .nodes = &gem_rx_nodes,
  2043. .num_nodes = ARRAY_SIZE(gem_rx_nodes),
  2044. },
  2045. [CLK_ACPU_HALF] = {
  2046. .name = "acpu_half",
  2047. .control_reg = CRF_APB_ACPU_CTRL,
  2048. .status_reg = 0,
  2049. .parents = &((int32_t []) {
  2050. (CLK_ACPU | (PARENT_CLK_NODE2 << CLK_PARENTS_ID_LEN)),
  2051. CLK_NA_PARENT
  2052. }),
  2053. .nodes = &acpu_half_nodes,
  2054. .num_nodes = ARRAY_SIZE(acpu_half_nodes),
  2055. },
  2056. [CLK_FPD_WDT] = {
  2057. .name = "fpd_wdt",
  2058. .control_reg = FPD_SLCR_WDT_CLK_SEL,
  2059. .status_reg = 0,
  2060. .parents = &((int32_t []) {
  2061. CLK_TOPSW_LSBUS,
  2062. EXT_CLK_SWDT0 | CLK_EXTERNAL_PARENT,
  2063. CLK_NA_PARENT
  2064. }),
  2065. .nodes = &wdt_nodes,
  2066. .num_nodes = ARRAY_SIZE(wdt_nodes),
  2067. },
  2068. [CLK_GPU_PP0_REF] = {
  2069. .name = "gpu_pp0_ref",
  2070. .control_reg = CRF_APB_GPU_REF_CTRL,
  2071. .status_reg = 0,
  2072. .parents = &((int32_t []) {
  2073. (CLK_GPU_REF | (PARENT_CLK_NODE2 << CLK_PARENTS_ID_LEN)),
  2074. CLK_NA_PARENT
  2075. }),
  2076. .nodes = &gpu_pp0_nodes,
  2077. .num_nodes = ARRAY_SIZE(gpu_pp0_nodes),
  2078. },
  2079. [CLK_GPU_PP1_REF] = {
  2080. .name = "gpu_pp1_ref",
  2081. .control_reg = CRF_APB_GPU_REF_CTRL,
  2082. .status_reg = 0,
  2083. .parents = &((int32_t []) {
  2084. (CLK_GPU_REF | (PARENT_CLK_NODE2 << CLK_PARENTS_ID_LEN)),
  2085. CLK_NA_PARENT
  2086. }),
  2087. .nodes = &gpu_pp1_nodes,
  2088. .num_nodes = ARRAY_SIZE(gpu_pp1_nodes),
  2089. },
  2090. [CLK_GEM_TSU] = {
  2091. .name = "gem_tsu",
  2092. .control_reg = IOU_SLCR_GEM_CLK_CTRL,
  2093. .status_reg = 0,
  2094. .parents = &((int32_t []) {
  2095. CLK_GEM_TSU_REF,
  2096. CLK_GEM_TSU_REF,
  2097. EXT_CLK_MIO26 | CLK_EXTERNAL_PARENT,
  2098. EXT_CLK_MIO50_OR_MIO51 | CLK_EXTERNAL_PARENT,
  2099. CLK_NA_PARENT
  2100. }),
  2101. .nodes = &gem_tsu_nodes,
  2102. .num_nodes = ARRAY_SIZE(gem_tsu_nodes),
  2103. },
  2104. [CLK_CPU_R5_CORE] = {
  2105. .name = "cpu_r5_core",
  2106. .control_reg = CRL_APB_CPU_R5_CTRL,
  2107. .status_reg = 0,
  2108. .parents = &((int32_t []) {
  2109. (CLK_CPU_R5 | (PARENT_CLK_NODE2 << CLK_PARENTS_ID_LEN)),
  2110. CLK_DUMMY_PARENT,
  2111. CLK_NA_PARENT
  2112. }),
  2113. .nodes = &cpu_r5_core_nodes,
  2114. .num_nodes = ARRAY_SIZE(cpu_r5_core_nodes),
  2115. },
  2116. [CLK_CAN0_MIO] = {
  2117. .name = "can0_mio",
  2118. .control_reg = IOU_SLCR_CAN_MIO_CTRL,
  2119. .status_reg = 0,
  2120. .parents = &can_mio_parents,
  2121. .nodes = &can0_mio_nodes,
  2122. .num_nodes = ARRAY_SIZE(can0_mio_nodes),
  2123. },
  2124. [CLK_CAN1_MIO] = {
  2125. .name = "can1_mio",
  2126. .control_reg = IOU_SLCR_CAN_MIO_CTRL,
  2127. .status_reg = 0,
  2128. .parents = &can_mio_parents,
  2129. .nodes = &can1_mio_nodes,
  2130. .num_nodes = ARRAY_SIZE(can1_mio_nodes),
  2131. },
  2132. [CLK_CAN0] = {
  2133. .name = "can0",
  2134. .control_reg = IOU_SLCR_CAN_MIO_CTRL,
  2135. .status_reg = 0,
  2136. .parents = &((int32_t []) {
  2137. CLK_CAN0_REF,
  2138. CLK_CAN0_MIO,
  2139. CLK_NA_PARENT
  2140. }),
  2141. .nodes = &can0_nodes,
  2142. .num_nodes = ARRAY_SIZE(can0_nodes),
  2143. },
  2144. [CLK_CAN1] = {
  2145. .name = "can1",
  2146. .control_reg = IOU_SLCR_CAN_MIO_CTRL,
  2147. .status_reg = 0,
  2148. .parents = &((int32_t []) {
  2149. CLK_CAN1_REF,
  2150. CLK_CAN1_MIO,
  2151. CLK_NA_PARENT
  2152. }),
  2153. .nodes = &can1_nodes,
  2154. .num_nodes = ARRAY_SIZE(can1_nodes),
  2155. },
  2156. [CLK_LPD_WDT] = {
  2157. .name = "lpd_wdt",
  2158. .control_reg = IOU_SLCR_WDT_CLK_SEL,
  2159. .status_reg = 0,
  2160. .parents = &((int32_t []) {
  2161. CLK_LPD_LSBUS,
  2162. EXT_CLK_SWDT1 | CLK_EXTERNAL_PARENT,
  2163. CLK_NA_PARENT
  2164. }),
  2165. .nodes = &wdt_nodes,
  2166. .num_nodes = ARRAY_SIZE(wdt_nodes),
  2167. },
  2168. };
  2169. static struct pm_ext_clock ext_clocks[] = {
  2170. [EXT_CLK_INDEX(EXT_CLK_PSS_REF)] = {
  2171. .name = "pss_ref_clk",
  2172. },
  2173. [EXT_CLK_INDEX(EXT_CLK_VIDEO)] = {
  2174. .name = "video_clk",
  2175. },
  2176. [EXT_CLK_INDEX(EXT_CLK_PSS_ALT_REF)] = {
  2177. .name = "pss_alt_ref_clk",
  2178. },
  2179. [EXT_CLK_INDEX(EXT_CLK_AUX_REF)] = {
  2180. .name = "aux_ref_clk",
  2181. },
  2182. [EXT_CLK_INDEX(EXT_CLK_GT_CRX_REF)] = {
  2183. .name = "video_clk",
  2184. },
  2185. [EXT_CLK_INDEX(EXT_CLK_SWDT0)] = {
  2186. .name = "swdt0_ext_clk",
  2187. },
  2188. [EXT_CLK_INDEX(EXT_CLK_SWDT1)] = {
  2189. .name = "swdt1_ext_clk",
  2190. },
  2191. [EXT_CLK_INDEX(EXT_CLK_GEM0_TX_EMIO)] = {
  2192. .name = "gem0_tx_ext",
  2193. },
  2194. [EXT_CLK_INDEX(EXT_CLK_GEM1_TX_EMIO)] = {
  2195. .name = "gem1_tx_ext",
  2196. },
  2197. [EXT_CLK_INDEX(EXT_CLK_GEM2_TX_EMIO)] = {
  2198. .name = "gem2_tx_ext",
  2199. },
  2200. [EXT_CLK_INDEX(EXT_CLK_GEM3_TX_EMIO)] = {
  2201. .name = "gem3_tx_ext",
  2202. },
  2203. [EXT_CLK_INDEX(EXT_CLK_GEM0_RX_EMIO)] = {
  2204. .name = "gem0_rx_ext",
  2205. },
  2206. [EXT_CLK_INDEX(EXT_CLK_GEM1_RX_EMIO)] = {
  2207. .name = "gem1_rx_ext",
  2208. },
  2209. [EXT_CLK_INDEX(EXT_CLK_GEM2_RX_EMIO)] = {
  2210. .name = "gem2_rx_ext",
  2211. },
  2212. [EXT_CLK_INDEX(EXT_CLK_GEM3_RX_EMIO)] = {
  2213. .name = "gem3_rx_ext",
  2214. },
  2215. [EXT_CLK_INDEX(EXT_CLK_MIO50_OR_MIO51)] = {
  2216. .name = "mio_clk_50_51",
  2217. },
  2218. EXT_CLK_MIO_DATA(0),
  2219. EXT_CLK_MIO_DATA(1),
  2220. EXT_CLK_MIO_DATA(2),
  2221. EXT_CLK_MIO_DATA(3),
  2222. EXT_CLK_MIO_DATA(4),
  2223. EXT_CLK_MIO_DATA(5),
  2224. EXT_CLK_MIO_DATA(6),
  2225. EXT_CLK_MIO_DATA(7),
  2226. EXT_CLK_MIO_DATA(8),
  2227. EXT_CLK_MIO_DATA(9),
  2228. EXT_CLK_MIO_DATA(10),
  2229. EXT_CLK_MIO_DATA(11),
  2230. EXT_CLK_MIO_DATA(12),
  2231. EXT_CLK_MIO_DATA(13),
  2232. EXT_CLK_MIO_DATA(14),
  2233. EXT_CLK_MIO_DATA(15),
  2234. EXT_CLK_MIO_DATA(16),
  2235. EXT_CLK_MIO_DATA(17),
  2236. EXT_CLK_MIO_DATA(18),
  2237. EXT_CLK_MIO_DATA(19),
  2238. EXT_CLK_MIO_DATA(20),
  2239. EXT_CLK_MIO_DATA(21),
  2240. EXT_CLK_MIO_DATA(22),
  2241. EXT_CLK_MIO_DATA(23),
  2242. EXT_CLK_MIO_DATA(24),
  2243. EXT_CLK_MIO_DATA(25),
  2244. EXT_CLK_MIO_DATA(26),
  2245. EXT_CLK_MIO_DATA(27),
  2246. EXT_CLK_MIO_DATA(28),
  2247. EXT_CLK_MIO_DATA(29),
  2248. EXT_CLK_MIO_DATA(30),
  2249. EXT_CLK_MIO_DATA(31),
  2250. EXT_CLK_MIO_DATA(32),
  2251. EXT_CLK_MIO_DATA(33),
  2252. EXT_CLK_MIO_DATA(34),
  2253. EXT_CLK_MIO_DATA(35),
  2254. EXT_CLK_MIO_DATA(36),
  2255. EXT_CLK_MIO_DATA(37),
  2256. EXT_CLK_MIO_DATA(38),
  2257. EXT_CLK_MIO_DATA(39),
  2258. EXT_CLK_MIO_DATA(40),
  2259. EXT_CLK_MIO_DATA(41),
  2260. EXT_CLK_MIO_DATA(42),
  2261. EXT_CLK_MIO_DATA(43),
  2262. EXT_CLK_MIO_DATA(44),
  2263. EXT_CLK_MIO_DATA(45),
  2264. EXT_CLK_MIO_DATA(46),
  2265. EXT_CLK_MIO_DATA(47),
  2266. EXT_CLK_MIO_DATA(48),
  2267. EXT_CLK_MIO_DATA(49),
  2268. EXT_CLK_MIO_DATA(50),
  2269. EXT_CLK_MIO_DATA(51),
  2270. EXT_CLK_MIO_DATA(52),
  2271. EXT_CLK_MIO_DATA(53),
  2272. EXT_CLK_MIO_DATA(54),
  2273. EXT_CLK_MIO_DATA(55),
  2274. EXT_CLK_MIO_DATA(56),
  2275. EXT_CLK_MIO_DATA(57),
  2276. EXT_CLK_MIO_DATA(58),
  2277. EXT_CLK_MIO_DATA(59),
  2278. EXT_CLK_MIO_DATA(60),
  2279. EXT_CLK_MIO_DATA(61),
  2280. EXT_CLK_MIO_DATA(62),
  2281. EXT_CLK_MIO_DATA(63),
  2282. EXT_CLK_MIO_DATA(64),
  2283. EXT_CLK_MIO_DATA(65),
  2284. EXT_CLK_MIO_DATA(66),
  2285. EXT_CLK_MIO_DATA(67),
  2286. EXT_CLK_MIO_DATA(68),
  2287. EXT_CLK_MIO_DATA(69),
  2288. EXT_CLK_MIO_DATA(70),
  2289. EXT_CLK_MIO_DATA(71),
  2290. EXT_CLK_MIO_DATA(72),
  2291. EXT_CLK_MIO_DATA(73),
  2292. EXT_CLK_MIO_DATA(74),
  2293. EXT_CLK_MIO_DATA(75),
  2294. EXT_CLK_MIO_DATA(76),
  2295. EXT_CLK_MIO_DATA(77),
  2296. };
  2297. /* Array of clock which are invalid for this variant */
  2298. static uint32_t pm_clk_invalid_list[] = {CLK_USB0, CLK_USB1, CLK_CSU_SPB,
  2299. CLK_ACPU_FULL,
  2300. CLK_ACPU_HALF,
  2301. CLK_APLL_TO_LPD,
  2302. CLK_DBG_FPD,
  2303. CLK_DBG_LPD,
  2304. CLK_DBG_TRACE,
  2305. CLK_DBG_TSTMP,
  2306. CLK_DDR_REF,
  2307. CLK_TOPSW_MAIN,
  2308. CLK_GTGREF0_REF,
  2309. CLK_LPD_SWITCH,
  2310. CLK_CPU_R5,
  2311. CLK_CPU_R5_CORE,
  2312. CLK_CSU_SPB,
  2313. CLK_CSU_PLL,
  2314. CLK_PCAP,
  2315. CLK_IOU_SWITCH,
  2316. CLK_DLL_REF,
  2317. CLK_TIMESTAMP_REF,
  2318. };
  2319. /**
  2320. * pm_clock_valid - Check if clock is valid or not.
  2321. * @clock_id: Id of the clock to be queried.
  2322. *
  2323. * This function is used to check if given clock is valid
  2324. * or not for the chip variant.
  2325. *
  2326. * List of invalid clocks are maintained in array list for
  2327. * different variants.
  2328. *
  2329. * Return: Returns 1 if clock is valid else 0.
  2330. *
  2331. */
  2332. static bool pm_clock_valid(uint32_t clock_id)
  2333. {
  2334. unsigned int i;
  2335. for (i = 0U; i < ARRAY_SIZE(pm_clk_invalid_list); i++)
  2336. if (pm_clk_invalid_list[i] == clock_id)
  2337. return 0;
  2338. return 1;
  2339. }
  2340. /**
  2341. * pm_clock_type - Get clock's type.
  2342. * @clock_id: Id of the clock to be queried.
  2343. *
  2344. * This function is used to check type of clock (OUTPUT/EXTERNAL).
  2345. *
  2346. * Return: Returns type of clock (OUTPUT/EXTERNAL).
  2347. *
  2348. */
  2349. static uint32_t pm_clock_type(uint32_t clock_id)
  2350. {
  2351. return (clock_id < CLK_MAX_OUTPUT_CLK) ?
  2352. CLK_TYPE_OUTPUT : CLK_TYPE_EXTERNAL;
  2353. }
  2354. /**
  2355. * pm_api_clock_get_num_clocks() - PM call to request number of clocks.
  2356. * @nclocks: Number of clocks.
  2357. *
  2358. * This function is used by master to get number of clocks.
  2359. *
  2360. * Return: Returns success.
  2361. *
  2362. */
  2363. enum pm_ret_status pm_api_clock_get_num_clocks(uint32_t *nclocks)
  2364. {
  2365. *nclocks = CLK_MAX;
  2366. return PM_RET_SUCCESS;
  2367. }
  2368. /**
  2369. * pm_api_clock_get_name() - PM call to request a clock's name.
  2370. * @clock_id: Clock ID.
  2371. * @name: Name of clock (max 16 bytes).
  2372. *
  2373. * This function is used by master to get nmae of clock specified
  2374. * by given clock ID.
  2375. *
  2376. */
  2377. void pm_api_clock_get_name(uint32_t clock_id, char *name)
  2378. {
  2379. if (clock_id == CLK_MAX) {
  2380. (void)memcpy(name, END_OF_CLK, ((sizeof(END_OF_CLK) > CLK_NAME_LEN) ?
  2381. CLK_NAME_LEN : sizeof(END_OF_CLK)));
  2382. } else if ((clock_id > CLK_MAX) || (!pm_clock_valid(clock_id))) {
  2383. (void)memset(name, 0, CLK_NAME_LEN);
  2384. } else if (clock_id < CLK_MAX_OUTPUT_CLK) {
  2385. (void)memcpy(name, clocks[clock_id].name, CLK_NAME_LEN);
  2386. } else {
  2387. (void)memcpy(name, ext_clocks[clock_id - CLK_MAX_OUTPUT_CLK].name,
  2388. CLK_NAME_LEN);
  2389. }
  2390. }
  2391. /**
  2392. * pm_api_clock_get_topology() - PM call to request a clock's topology.
  2393. * @clock_id: Clock ID.
  2394. * @index: Topology index for next toplogy node.
  2395. * @topology: Buffer to store nodes in topology and flags.
  2396. *
  2397. * This function is used by master to get topology information for the
  2398. * clock specified by given clock ID. Each response would return 3
  2399. * topology nodes. To get next nodes, caller needs to call this API with
  2400. * index of next node. Index starts from 0.
  2401. *
  2402. * Return: Returns status, either success or error+reason.
  2403. *
  2404. */
  2405. enum pm_ret_status pm_api_clock_get_topology(uint32_t clock_id,
  2406. uint32_t index,
  2407. uint32_t *topology)
  2408. {
  2409. const struct pm_clock_node *clock_nodes;
  2410. uint8_t num_nodes;
  2411. uint32_t i;
  2412. uint16_t typeflags;
  2413. if (!pm_clock_valid(clock_id)) {
  2414. return PM_RET_ERROR_ARGS;
  2415. }
  2416. if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
  2417. return PM_RET_ERROR_NOTSUPPORTED;
  2418. }
  2419. (void)memset(topology, 0, CLK_TOPOLOGY_PAYLOAD_LEN);
  2420. clock_nodes = *clocks[clock_id].nodes;
  2421. num_nodes = clocks[clock_id].num_nodes;
  2422. /* Skip parent till index */
  2423. if (index >= num_nodes) {
  2424. return PM_RET_SUCCESS;
  2425. }
  2426. for (i = 0; i < 3U; i++) {
  2427. if ((index + i) == num_nodes) {
  2428. break;
  2429. }
  2430. topology[i] = clock_nodes[index + i].type;
  2431. topology[i] |= clock_nodes[index + i].clkflags <<
  2432. CLK_CLKFLAGS_SHIFT;
  2433. typeflags = clock_nodes[index + i].typeflags;
  2434. topology[i] |= (typeflags & CLK_TYPEFLAGS_BITS_MASK) <<
  2435. CLK_TYPEFLAGS_SHIFT;
  2436. topology[i] |= (typeflags & CLK_TYPEFLAGS2_BITS_MASK) >>
  2437. (CLK_TYPEFLAGS_BITS - CLK_TYPEFLAGS2_SHIFT);
  2438. }
  2439. return PM_RET_SUCCESS;
  2440. }
  2441. /**
  2442. * pm_api_clock_get_fixedfactor_params() - PM call to request a clock's fixed
  2443. * factor parameters for fixed clock.
  2444. * @clock_id: Clock ID.
  2445. * @mul: Multiplication value.
  2446. * @div: Divisor value.
  2447. *
  2448. * This function is used by master to get fixed factor parameers for the
  2449. * fixed clock. This API is application only for the fixed clock.
  2450. *
  2451. * Return: Returns status, either success or error+reason.
  2452. *
  2453. */
  2454. enum pm_ret_status pm_api_clock_get_fixedfactor_params(uint32_t clock_id,
  2455. uint32_t *mul,
  2456. uint32_t *div)
  2457. {
  2458. const struct pm_clock_node *clock_nodes;
  2459. uint8_t num_nodes;
  2460. uint32_t type, i;
  2461. if (!pm_clock_valid(clock_id)) {
  2462. return PM_RET_ERROR_ARGS;
  2463. }
  2464. if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
  2465. return PM_RET_ERROR_NOTSUPPORTED;
  2466. }
  2467. clock_nodes = *clocks[clock_id].nodes;
  2468. num_nodes = clocks[clock_id].num_nodes;
  2469. for (i = 0; i < num_nodes; i++) {
  2470. type = clock_nodes[i].type;
  2471. if (type == TYPE_FIXEDFACTOR) {
  2472. *mul = clock_nodes[i].mult;
  2473. *div = clock_nodes[i].div;
  2474. break;
  2475. }
  2476. }
  2477. /* Clock is not fixed clock */
  2478. if (i == num_nodes) {
  2479. return PM_RET_ERROR_ARGS;
  2480. }
  2481. return PM_RET_SUCCESS;
  2482. }
  2483. /**
  2484. * pm_api_clock_get_parents() - PM call to request a clock's first 3 parents.
  2485. * @clock_id: Clock ID.
  2486. * @index: Index of next parent.
  2487. * @parents: Parents of the given clock.
  2488. *
  2489. * This function is used by master to get clock's parents information.
  2490. * This API will return 3 parents with a single response. To get other
  2491. * parents, master should call same API in loop with new parent index
  2492. * till error is returned.
  2493. *
  2494. * E.g First call should have index 0 which will return parents 0, 1 and
  2495. * 2. Next call, index should be 3 which will return parent 3,4 and 5 and
  2496. * so on.
  2497. *
  2498. * Return: Returns status, either success or error+reason.
  2499. *
  2500. */
  2501. enum pm_ret_status pm_api_clock_get_parents(uint32_t clock_id,
  2502. uint32_t index,
  2503. uint32_t *parents)
  2504. {
  2505. uint32_t i;
  2506. const int32_t *clk_parents;
  2507. if (!pm_clock_valid(clock_id)) {
  2508. return PM_RET_ERROR_ARGS;
  2509. }
  2510. if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
  2511. return PM_RET_ERROR_NOTSUPPORTED;
  2512. }
  2513. clk_parents = *clocks[clock_id].parents;
  2514. if (clk_parents == NULL) {
  2515. return PM_RET_ERROR_ARGS;
  2516. }
  2517. (void)memset(parents, 0, CLK_PARENTS_PAYLOAD_LEN);
  2518. /* Skip parent till index */
  2519. for (i = 0; i < index; i++) {
  2520. if (clk_parents[i] == CLK_NA_PARENT) {
  2521. return PM_RET_SUCCESS;
  2522. }
  2523. }
  2524. for (i = 0; i < 3U; i++) {
  2525. parents[i] = clk_parents[index + i];
  2526. if (clk_parents[index + i] == CLK_NA_PARENT) {
  2527. break;
  2528. }
  2529. }
  2530. return PM_RET_SUCCESS;
  2531. }
  2532. /**
  2533. * pm_api_clock_get_attributes() - PM call to request a clock's attributes.
  2534. * @clock_id: Clock ID.
  2535. * @attr: Clock attributes.
  2536. *
  2537. * This function is used by master to get clock's attributes
  2538. * (e.g. valid, clock type, etc).
  2539. *
  2540. * Return: Returns status, either success or error+reason.
  2541. *
  2542. */
  2543. enum pm_ret_status pm_api_clock_get_attributes(uint32_t clock_id,
  2544. uint32_t *attr)
  2545. {
  2546. if (clock_id >= CLK_MAX) {
  2547. return PM_RET_ERROR_ARGS;
  2548. }
  2549. /* Clock valid bit */
  2550. *attr = pm_clock_valid(clock_id);
  2551. /* Clock type (Output/External) */
  2552. *attr |= (pm_clock_type(clock_id) << CLK_TYPE_SHIFT);
  2553. return PM_RET_SUCCESS;
  2554. }
  2555. /**
  2556. * pm_api_clock_get_max_divisor - PM call to get max divisor.
  2557. * @clock_id: Clock ID.
  2558. * @div_type: Divisor Type (TYPE_DIV1 or TYPE_DIV2).
  2559. * @max_div: Maximum supported divisor.
  2560. *
  2561. * This function is used by master to get maximum supported value.
  2562. *
  2563. * Return: Returns status, either success or error+reason.
  2564. *
  2565. */
  2566. enum pm_ret_status pm_api_clock_get_max_divisor(enum clock_id clock_id,
  2567. uint8_t div_type,
  2568. uint32_t *max_div)
  2569. {
  2570. uint32_t i;
  2571. const struct pm_clock_node *nodes;
  2572. if (clock_id >= CLK_MAX_OUTPUT_CLK) {
  2573. return PM_RET_ERROR_ARGS;
  2574. }
  2575. nodes = *clocks[clock_id].nodes;
  2576. for (i = 0; i < clocks[clock_id].num_nodes; i++) {
  2577. if (nodes[i].type == div_type) {
  2578. if ((CLK_DIVIDER_POWER_OF_TWO &
  2579. nodes[i].typeflags) != 0U) {
  2580. *max_div = (1U << (BIT(nodes[i].width) - 1U));
  2581. } else {
  2582. *max_div = BIT(nodes[i].width) - 1U;
  2583. }
  2584. return PM_RET_SUCCESS;
  2585. }
  2586. }
  2587. return PM_RET_ERROR_ARGS;
  2588. }
  2589. /**
  2590. * struct pm_pll - PLL related data required to map IOCTL-based PLL control.
  2591. * implemented by linux to system-level EEMI APIs.
  2592. * @nid: PLL node ID.
  2593. * @cid: PLL clock ID.
  2594. * @pre_src: Pre-source PLL clock ID.
  2595. * @post_src: Post-source PLL clock ID.
  2596. * @div2: DIV2 PLL clock ID.
  2597. * @bypass: PLL output clock ID that maps to bypass select output.
  2598. * @mode: PLL mode currently set via IOCTL (PLL_FRAC_MODE/PLL_INT_MODE).
  2599. *
  2600. */
  2601. struct pm_pll {
  2602. const enum pm_node_id nid;
  2603. const enum clock_id cid;
  2604. const enum clock_id pre_src;
  2605. const enum clock_id post_src;
  2606. const enum clock_id div2;
  2607. const enum clock_id bypass;
  2608. uint8_t mode;
  2609. };
  2610. static struct pm_pll pm_plls[] = {
  2611. {
  2612. .nid = NODE_IOPLL,
  2613. .cid = CLK_IOPLL_INT,
  2614. .pre_src = CLK_IOPLL_PRE_SRC,
  2615. .post_src = CLK_IOPLL_POST_SRC,
  2616. .div2 = CLK_IOPLL_INT_MUX,
  2617. .bypass = CLK_IOPLL,
  2618. }, {
  2619. .nid = NODE_RPLL,
  2620. .cid = CLK_RPLL_INT,
  2621. .pre_src = CLK_RPLL_PRE_SRC,
  2622. .post_src = CLK_RPLL_POST_SRC,
  2623. .div2 = CLK_RPLL_INT_MUX,
  2624. .bypass = CLK_RPLL,
  2625. }, {
  2626. .nid = NODE_APLL,
  2627. .cid = CLK_APLL_INT,
  2628. .pre_src = CLK_APLL_PRE_SRC,
  2629. .post_src = CLK_APLL_POST_SRC,
  2630. .div2 = CLK_APLL_INT_MUX,
  2631. .bypass = CLK_APLL,
  2632. }, {
  2633. .nid = NODE_VPLL,
  2634. .cid = CLK_VPLL_INT,
  2635. .pre_src = CLK_VPLL_PRE_SRC,
  2636. .post_src = CLK_VPLL_POST_SRC,
  2637. .div2 = CLK_VPLL_INT_MUX,
  2638. .bypass = CLK_VPLL,
  2639. }, {
  2640. .nid = NODE_DPLL,
  2641. .cid = CLK_DPLL_INT,
  2642. .pre_src = CLK_DPLL_PRE_SRC,
  2643. .post_src = CLK_DPLL_POST_SRC,
  2644. .div2 = CLK_DPLL_INT_MUX,
  2645. .bypass = CLK_DPLL,
  2646. },
  2647. };
  2648. /**
  2649. * pm_clock_get_pll() - Get PLL structure by PLL clock ID.
  2650. * @clock_id: Clock ID of the target PLL.
  2651. *
  2652. * Return: Pointer to PLL structure if found, NULL otherwise.
  2653. *
  2654. */
  2655. struct pm_pll *pm_clock_get_pll(enum clock_id clock_id)
  2656. {
  2657. uint32_t i;
  2658. for (i = 0; i < ARRAY_SIZE(pm_plls); i++) {
  2659. if (pm_plls[i].cid == clock_id) {
  2660. return &pm_plls[i];
  2661. }
  2662. }
  2663. return NULL;
  2664. }
  2665. /**
  2666. * pm_clock_get_pll_node_id() - Get PLL node ID by PLL clock ID.
  2667. * @clock_id: Clock ID of the target PLL.
  2668. * @node_id: Location to store node ID of the target PLL.
  2669. *
  2670. * Return: PM_RET_SUCCESS if node ID is found, PM_RET_ERROR_ARGS otherwise.
  2671. *
  2672. */
  2673. enum pm_ret_status pm_clock_get_pll_node_id(enum clock_id clock_id,
  2674. enum pm_node_id *node_id)
  2675. {
  2676. const struct pm_pll *pll = pm_clock_get_pll(clock_id);
  2677. if (pll != NULL) {
  2678. *node_id = pll->nid;
  2679. return PM_RET_SUCCESS;
  2680. }
  2681. return PM_RET_ERROR_ARGS;
  2682. }
  2683. /**
  2684. * pm_clock_get_pll_by_related_clk() - Get PLL structure by PLL-related clock
  2685. * ID.
  2686. * @clock_id: Clock ID.
  2687. *
  2688. * Return: Pointer to PLL structure if found, NULL otherwise.
  2689. *
  2690. */
  2691. struct pm_pll *pm_clock_get_pll_by_related_clk(enum clock_id clock_id)
  2692. {
  2693. uint32_t i;
  2694. for (i = 0; i < ARRAY_SIZE(pm_plls); i++) {
  2695. if ((pm_plls[i].pre_src == clock_id) ||
  2696. (pm_plls[i].post_src == clock_id) ||
  2697. (pm_plls[i].div2 == clock_id) ||
  2698. (pm_plls[i].bypass == clock_id)) {
  2699. return &pm_plls[i];
  2700. }
  2701. }
  2702. return NULL;
  2703. }
  2704. /**
  2705. * pm_clock_pll_enable() - "Enable" the PLL clock (lock the PLL).
  2706. * @pll: PLL to be locked.
  2707. *
  2708. * This function is used to map IOCTL/linux-based PLL handling to system-level
  2709. * EEMI APIs.
  2710. *
  2711. * Return: Error if the argument is not valid or status as returned by PMU.
  2712. *
  2713. */
  2714. enum pm_ret_status pm_clock_pll_enable(struct pm_pll *pll)
  2715. {
  2716. if (pll == NULL) {
  2717. return PM_RET_ERROR_ARGS;
  2718. }
  2719. /* Set the PLL mode according to the buffered mode value */
  2720. if (pll->mode == PLL_FRAC_MODE) {
  2721. return pm_pll_set_mode(pll->nid, PM_PLL_MODE_FRACTIONAL);
  2722. }
  2723. return pm_pll_set_mode(pll->nid, PM_PLL_MODE_INTEGER);
  2724. }
  2725. /**
  2726. * pm_clock_pll_disable - "Disable" the PLL clock (bypass/reset the PLL).
  2727. * @pll: PLL to be bypassed/reset.
  2728. *
  2729. * This function is used to map IOCTL/linux-based PLL handling to system-level
  2730. * EEMI APIs.
  2731. *
  2732. * Return: Error if the argument is not valid or status as returned by PMU.
  2733. *
  2734. */
  2735. enum pm_ret_status pm_clock_pll_disable(struct pm_pll *pll)
  2736. {
  2737. if (pll == NULL) {
  2738. return PM_RET_ERROR_ARGS;
  2739. }
  2740. return pm_pll_set_mode(pll->nid, PM_PLL_MODE_RESET);
  2741. }
  2742. /**
  2743. * pm_clock_pll_get_state - Get state of the PLL.
  2744. * @pll: Pointer to the target PLL structure.
  2745. * @state: Location to store the state: 1/0 ("Enabled"/"Disabled").
  2746. *
  2747. * "Enable" actually means that the PLL is locked and its bypass is deasserted,
  2748. * "Disable" means that it is bypassed.
  2749. *
  2750. * Return: PM_RET_ERROR_ARGS error if the argument is not valid, success if
  2751. * returned state value is valid or an error if returned by PMU.
  2752. */
  2753. enum pm_ret_status pm_clock_pll_get_state(struct pm_pll *pll,
  2754. uint32_t *state)
  2755. {
  2756. enum pm_ret_status status;
  2757. enum pm_pll_mode mode;
  2758. if ((pll == NULL) || (state == NULL)) {
  2759. return PM_RET_ERROR_ARGS;
  2760. }
  2761. status = pm_pll_get_mode(pll->nid, &mode);
  2762. if (status != PM_RET_SUCCESS) {
  2763. return status;
  2764. }
  2765. if (mode == PM_PLL_MODE_RESET) {
  2766. *state = 0;
  2767. } else {
  2768. *state = 1;
  2769. }
  2770. return PM_RET_SUCCESS;
  2771. }
  2772. /**
  2773. * pm_clock_pll_set_parent - Set the clock parent for PLL-related clock id.
  2774. * @pll: Target PLL structure.
  2775. * @clock_id: Id of the clock.
  2776. * @parent_index: parent index (=mux select value).
  2777. *
  2778. * The whole clock-tree implementation relies on the fact that parent indexes
  2779. * match to the multiplexer select values. This function has to rely on that
  2780. * assumption as well => parent_index is actually the mux select value.
  2781. *
  2782. * Return: Returns status, either success or error+reason.
  2783. *
  2784. */
  2785. enum pm_ret_status pm_clock_pll_set_parent(struct pm_pll *pll,
  2786. enum clock_id clock_id,
  2787. uint32_t parent_index)
  2788. {
  2789. if (pll == NULL) {
  2790. return PM_RET_ERROR_ARGS;
  2791. }
  2792. if (pll->pre_src == clock_id) {
  2793. return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_PRE_SRC,
  2794. parent_index);
  2795. }
  2796. if (pll->post_src == clock_id) {
  2797. return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_POST_SRC,
  2798. parent_index);
  2799. }
  2800. if (pll->div2 == clock_id) {
  2801. return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_DIV2,
  2802. parent_index);
  2803. }
  2804. return PM_RET_ERROR_ARGS;
  2805. }
  2806. /**
  2807. * pm_clock_pll_get_parent - Get mux select value of PLL-related clock parent.
  2808. * @pll: Target PLL structure.
  2809. * @clock_id: Id of the clock.
  2810. * @parent_index: parent index (=mux select value).
  2811. *
  2812. * This function is used by master to get parent index for PLL-related clock.
  2813. *
  2814. * Return: Returns status, either success or error+reason.
  2815. *
  2816. */
  2817. enum pm_ret_status pm_clock_pll_get_parent(struct pm_pll *pll,
  2818. enum clock_id clock_id,
  2819. uint32_t *parent_index)
  2820. {
  2821. if (pll == NULL) {
  2822. return PM_RET_ERROR_ARGS;
  2823. }
  2824. if (pll->pre_src == clock_id) {
  2825. return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_PRE_SRC,
  2826. parent_index);
  2827. }
  2828. if (pll->post_src == clock_id) {
  2829. return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_POST_SRC,
  2830. parent_index);
  2831. }
  2832. if (pll->div2 == clock_id) {
  2833. return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_DIV2,
  2834. parent_index);
  2835. }
  2836. if (pll->bypass == clock_id) {
  2837. *parent_index = 0;
  2838. return PM_RET_SUCCESS;
  2839. }
  2840. return PM_RET_ERROR_ARGS;
  2841. }
  2842. /**
  2843. * pm_clock_set_pll_mode() - Set PLL mode.
  2844. * @clock_id: PLL clock id.
  2845. * @mode: Mode fractional/integer.
  2846. *
  2847. * This function buffers/saves the PLL mode that is set.
  2848. *
  2849. * Return: Success if mode is buffered or error if an argument is invalid.
  2850. *
  2851. */
  2852. enum pm_ret_status pm_clock_set_pll_mode(enum clock_id clock_id,
  2853. uint32_t mode)
  2854. {
  2855. struct pm_pll *pll = pm_clock_get_pll(clock_id);
  2856. if ((pll == NULL) || ((mode != PLL_FRAC_MODE) && (mode != PLL_INT_MODE))) {
  2857. return PM_RET_ERROR_ARGS;
  2858. }
  2859. pll->mode = mode;
  2860. return PM_RET_SUCCESS;
  2861. }
  2862. /**
  2863. * pm_clock_get_pll_mode() - Get PLL mode.
  2864. * @clock_id: PLL clock id.
  2865. * @mode: Location to store the mode (fractional/integer).
  2866. *
  2867. * This function returns buffered PLL mode.
  2868. *
  2869. * Return: Success if mode is stored or error if an argument is invalid.
  2870. *
  2871. */
  2872. enum pm_ret_status pm_clock_get_pll_mode(enum clock_id clock_id,
  2873. uint32_t *mode)
  2874. {
  2875. const struct pm_pll *pll = pm_clock_get_pll(clock_id);
  2876. if ((pll == NULL) || (mode == NULL)) {
  2877. return PM_RET_ERROR_ARGS;
  2878. }
  2879. *mode = pll->mode;
  2880. return PM_RET_SUCCESS;
  2881. }
  2882. /**
  2883. * pm_clock_id_is_valid() - Check if given clock ID is valid.
  2884. * @clock_id: ID of the clock to be checked.
  2885. *
  2886. * Return: Returns success if clock_id is valid, otherwise an error.
  2887. *
  2888. */
  2889. enum pm_ret_status pm_clock_id_is_valid(uint32_t clock_id)
  2890. {
  2891. if (!pm_clock_valid(clock_id)) {
  2892. return PM_RET_ERROR_ARGS;
  2893. }
  2894. if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
  2895. return PM_RET_ERROR_NOTSUPPORTED;
  2896. }
  2897. return PM_RET_SUCCESS;
  2898. }
  2899. /**
  2900. * pm_clock_has_div() - Check if the clock has divider with given ID.
  2901. * @clock_id: Clock ID.
  2902. * @div_id: Divider ID.
  2903. *
  2904. * Return: True(1)=clock has the divider, false(0)=otherwise.
  2905. *
  2906. */
  2907. uint8_t pm_clock_has_div(uint32_t clock_id, enum pm_clock_div_id div_id)
  2908. {
  2909. uint32_t i;
  2910. const struct pm_clock_node *nodes;
  2911. if (clock_id >= CLK_MAX_OUTPUT_CLK) {
  2912. return 0;
  2913. }
  2914. nodes = *clocks[clock_id].nodes;
  2915. for (i = 0; i < clocks[clock_id].num_nodes; i++) {
  2916. if (nodes[i].type == TYPE_DIV1) {
  2917. if (div_id == PM_CLOCK_DIV0_ID)
  2918. return 1;
  2919. } else if (nodes[i].type == TYPE_DIV2) {
  2920. if (div_id == PM_CLOCK_DIV1_ID)
  2921. return 1;
  2922. } else {
  2923. /* To fix the misra 15.7 warning */
  2924. }
  2925. }
  2926. return 0;
  2927. }