gcc-ipq4019.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015 The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/err.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/module.h>
  9. #include <linux/of.h>
  10. #include <linux/clk-provider.h>
  11. #include <linux/regmap.h>
  12. #include <linux/reset-controller.h>
  13. #include <linux/math64.h>
  14. #include <linux/delay.h>
  15. #include <linux/clk.h>
  16. #include <dt-bindings/clock/qcom,gcc-ipq4019.h>
  17. #include "common.h"
  18. #include "clk-regmap.h"
  19. #include "clk-rcg.h"
  20. #include "clk-branch.h"
  21. #include "reset.h"
  22. #include "clk-regmap-divider.h"
  23. #define to_clk_regmap_div(_hw) container_of(to_clk_regmap(_hw),\
  24. struct clk_regmap_div, clkr)
  25. #define to_clk_fepll(_hw) container_of(to_clk_regmap_div(_hw),\
  26. struct clk_fepll, cdiv)
  27. enum {
  28. P_XO,
  29. P_FEPLL200,
  30. P_FEPLL500,
  31. P_DDRPLL,
  32. P_FEPLLWCSS2G,
  33. P_FEPLLWCSS5G,
  34. P_FEPLL125DLY,
  35. P_DDRPLLAPSS,
  36. };
  37. /*
  38. * struct clk_fepll_vco - vco feedback divider corresponds for FEPLL clocks
  39. * @fdbkdiv_shift: lowest bit for FDBKDIV
  40. * @fdbkdiv_width: number of bits in FDBKDIV
  41. * @refclkdiv_shift: lowest bit for REFCLKDIV
  42. * @refclkdiv_width: number of bits in REFCLKDIV
  43. * @reg: PLL_DIV register address
  44. */
  45. struct clk_fepll_vco {
  46. u32 fdbkdiv_shift;
  47. u32 fdbkdiv_width;
  48. u32 refclkdiv_shift;
  49. u32 refclkdiv_width;
  50. u32 reg;
  51. };
  52. /*
  53. * struct clk_fepll - clk divider corresponds to FEPLL clocks
  54. * @fixed_div: fixed divider value if divider is fixed
  55. * @parent_map: map from software's parent index to hardware's src_sel field
  56. * @cdiv: divider values for PLL_DIV
  57. * @pll_vco: vco feedback divider
  58. * @div_table: mapping for actual divider value to register divider value
  59. * in case of non fixed divider
  60. * @freq_tbl: frequency table
  61. */
  62. struct clk_fepll {
  63. u32 fixed_div;
  64. const u8 *parent_map;
  65. struct clk_regmap_div cdiv;
  66. const struct clk_fepll_vco *pll_vco;
  67. const struct clk_div_table *div_table;
  68. const struct freq_tbl *freq_tbl;
  69. };
  70. /*
  71. * Contains index for safe clock during APSS freq change.
  72. * fepll500 is being used as safe clock so initialize it
  73. * with its index in parents list gcc_xo_ddr_500_200.
  74. */
  75. static const int gcc_ipq4019_cpu_safe_parent = 2;
  76. /* Calculates the VCO rate for FEPLL. */
  77. static u64 clk_fepll_vco_calc_rate(struct clk_fepll *pll_div,
  78. unsigned long parent_rate)
  79. {
  80. const struct clk_fepll_vco *pll_vco = pll_div->pll_vco;
  81. u32 fdbkdiv, refclkdiv, cdiv;
  82. u64 vco;
  83. regmap_read(pll_div->cdiv.clkr.regmap, pll_vco->reg, &cdiv);
  84. refclkdiv = (cdiv >> pll_vco->refclkdiv_shift) &
  85. (BIT(pll_vco->refclkdiv_width) - 1);
  86. fdbkdiv = (cdiv >> pll_vco->fdbkdiv_shift) &
  87. (BIT(pll_vco->fdbkdiv_width) - 1);
  88. vco = parent_rate / refclkdiv;
  89. vco *= 2;
  90. vco *= fdbkdiv;
  91. return vco;
  92. }
  93. static const struct clk_fepll_vco gcc_apss_ddrpll_vco = {
  94. .fdbkdiv_shift = 16,
  95. .fdbkdiv_width = 8,
  96. .refclkdiv_shift = 24,
  97. .refclkdiv_width = 5,
  98. .reg = 0x2e020,
  99. };
  100. static const struct clk_fepll_vco gcc_fepll_vco = {
  101. .fdbkdiv_shift = 16,
  102. .fdbkdiv_width = 8,
  103. .refclkdiv_shift = 24,
  104. .refclkdiv_width = 5,
  105. .reg = 0x2f020,
  106. };
  107. /*
  108. * Round rate function for APSS CPU PLL Clock divider.
  109. * It looks up the frequency table and returns the next higher frequency
  110. * supported in hardware.
  111. */
  112. static int clk_cpu_div_determine_rate(struct clk_hw *hw,
  113. struct clk_rate_request *req)
  114. {
  115. struct clk_fepll *pll = to_clk_fepll(hw);
  116. struct clk_hw *p_hw;
  117. const struct freq_tbl *f;
  118. f = qcom_find_freq(pll->freq_tbl, req->rate);
  119. if (!f)
  120. return -EINVAL;
  121. p_hw = clk_hw_get_parent_by_index(hw, f->src);
  122. req->best_parent_rate = clk_hw_get_rate(p_hw);
  123. req->rate = f->freq;
  124. return 0;
  125. };
  126. /*
  127. * Clock set rate function for APSS CPU PLL Clock divider.
  128. * It looks up the frequency table and updates the PLL divider to corresponding
  129. * divider value.
  130. */
  131. static int clk_cpu_div_set_rate(struct clk_hw *hw, unsigned long rate,
  132. unsigned long parent_rate)
  133. {
  134. struct clk_fepll *pll = to_clk_fepll(hw);
  135. const struct freq_tbl *f;
  136. u32 mask;
  137. f = qcom_find_freq(pll->freq_tbl, rate);
  138. if (!f)
  139. return -EINVAL;
  140. mask = (BIT(pll->cdiv.width) - 1) << pll->cdiv.shift;
  141. regmap_update_bits(pll->cdiv.clkr.regmap,
  142. pll->cdiv.reg, mask,
  143. f->pre_div << pll->cdiv.shift);
  144. /*
  145. * There is no status bit which can be checked for successful CPU
  146. * divider update operation so using delay for the same.
  147. */
  148. udelay(1);
  149. return 0;
  150. };
  151. /*
  152. * Clock frequency calculation function for APSS CPU PLL Clock divider.
  153. * This clock divider is nonlinear so this function calculates the actual
  154. * divider and returns the output frequency by dividing VCO Frequency
  155. * with this actual divider value.
  156. */
  157. static unsigned long
  158. clk_cpu_div_recalc_rate(struct clk_hw *hw,
  159. unsigned long parent_rate)
  160. {
  161. struct clk_fepll *pll = to_clk_fepll(hw);
  162. u32 cdiv, pre_div;
  163. u64 rate;
  164. regmap_read(pll->cdiv.clkr.regmap, pll->cdiv.reg, &cdiv);
  165. cdiv = (cdiv >> pll->cdiv.shift) & (BIT(pll->cdiv.width) - 1);
  166. /*
  167. * Some dividers have value in 0.5 fraction so multiply both VCO
  168. * frequency(parent_rate) and pre_div with 2 to make integer
  169. * calculation.
  170. */
  171. if (cdiv > 10)
  172. pre_div = (cdiv + 1) * 2;
  173. else
  174. pre_div = cdiv + 12;
  175. rate = clk_fepll_vco_calc_rate(pll, parent_rate) * 2;
  176. do_div(rate, pre_div);
  177. return rate;
  178. };
  179. static const struct clk_ops clk_regmap_cpu_div_ops = {
  180. .determine_rate = clk_cpu_div_determine_rate,
  181. .set_rate = clk_cpu_div_set_rate,
  182. .recalc_rate = clk_cpu_div_recalc_rate,
  183. };
  184. static const struct freq_tbl ftbl_apss_ddr_pll[] = {
  185. { 384000000, P_XO, 0xd, 0, 0 },
  186. { 413000000, P_XO, 0xc, 0, 0 },
  187. { 448000000, P_XO, 0xb, 0, 0 },
  188. { 488000000, P_XO, 0xa, 0, 0 },
  189. { 512000000, P_XO, 0x9, 0, 0 },
  190. { 537000000, P_XO, 0x8, 0, 0 },
  191. { 565000000, P_XO, 0x7, 0, 0 },
  192. { 597000000, P_XO, 0x6, 0, 0 },
  193. { 632000000, P_XO, 0x5, 0, 0 },
  194. { 672000000, P_XO, 0x4, 0, 0 },
  195. { 716000000, P_XO, 0x3, 0, 0 },
  196. { 768000000, P_XO, 0x2, 0, 0 },
  197. { 823000000, P_XO, 0x1, 0, 0 },
  198. { 896000000, P_XO, 0x0, 0, 0 },
  199. { }
  200. };
  201. static struct clk_fepll gcc_apss_cpu_plldiv_clk = {
  202. .cdiv.reg = 0x2e020,
  203. .cdiv.shift = 4,
  204. .cdiv.width = 4,
  205. .cdiv.clkr = {
  206. .enable_reg = 0x2e000,
  207. .enable_mask = BIT(0),
  208. .hw.init = &(struct clk_init_data){
  209. .name = "ddrpllapss",
  210. .parent_data = &(const struct clk_parent_data){
  211. .fw_name = "xo",
  212. .name = "xo",
  213. },
  214. .num_parents = 1,
  215. .ops = &clk_regmap_cpu_div_ops,
  216. },
  217. },
  218. .freq_tbl = ftbl_apss_ddr_pll,
  219. .pll_vco = &gcc_apss_ddrpll_vco,
  220. };
  221. /* Calculates the rate for PLL divider.
  222. * If the divider value is not fixed then it gets the actual divider value
  223. * from divider table. Then, it calculate the clock rate by dividing the
  224. * parent rate with actual divider value.
  225. */
  226. static unsigned long
  227. clk_regmap_clk_div_recalc_rate(struct clk_hw *hw,
  228. unsigned long parent_rate)
  229. {
  230. struct clk_fepll *pll = to_clk_fepll(hw);
  231. u32 cdiv, pre_div = 1;
  232. u64 rate;
  233. const struct clk_div_table *clkt;
  234. if (pll->fixed_div) {
  235. pre_div = pll->fixed_div;
  236. } else {
  237. regmap_read(pll->cdiv.clkr.regmap, pll->cdiv.reg, &cdiv);
  238. cdiv = (cdiv >> pll->cdiv.shift) & (BIT(pll->cdiv.width) - 1);
  239. for (clkt = pll->div_table; clkt->div; clkt++) {
  240. if (clkt->val == cdiv)
  241. pre_div = clkt->div;
  242. }
  243. }
  244. rate = clk_fepll_vco_calc_rate(pll, parent_rate);
  245. do_div(rate, pre_div);
  246. return rate;
  247. };
  248. static const struct clk_ops clk_fepll_div_ops = {
  249. .recalc_rate = clk_regmap_clk_div_recalc_rate,
  250. };
  251. static struct clk_fepll gcc_apss_sdcc_clk = {
  252. .fixed_div = 28,
  253. .cdiv.clkr = {
  254. .hw.init = &(struct clk_init_data){
  255. .name = "ddrpllsdcc",
  256. .parent_data = &(const struct clk_parent_data){
  257. .fw_name = "xo",
  258. .name = "xo",
  259. },
  260. .num_parents = 1,
  261. .ops = &clk_fepll_div_ops,
  262. },
  263. },
  264. .pll_vco = &gcc_apss_ddrpll_vco,
  265. };
  266. static struct clk_fepll gcc_fepll125_clk = {
  267. .fixed_div = 32,
  268. .cdiv.clkr = {
  269. .hw.init = &(struct clk_init_data){
  270. .name = "fepll125",
  271. .parent_data = &(const struct clk_parent_data){
  272. .fw_name = "xo",
  273. .name = "xo",
  274. },
  275. .num_parents = 1,
  276. .ops = &clk_fepll_div_ops,
  277. },
  278. },
  279. .pll_vco = &gcc_fepll_vco,
  280. };
  281. static struct clk_fepll gcc_fepll125dly_clk = {
  282. .fixed_div = 32,
  283. .cdiv.clkr = {
  284. .hw.init = &(struct clk_init_data){
  285. .name = "fepll125dly",
  286. .parent_data = &(const struct clk_parent_data){
  287. .fw_name = "xo",
  288. .name = "xo",
  289. },
  290. .num_parents = 1,
  291. .ops = &clk_fepll_div_ops,
  292. },
  293. },
  294. .pll_vco = &gcc_fepll_vco,
  295. };
  296. static struct clk_fepll gcc_fepll200_clk = {
  297. .fixed_div = 20,
  298. .cdiv.clkr = {
  299. .hw.init = &(struct clk_init_data){
  300. .name = "fepll200",
  301. .parent_data = &(const struct clk_parent_data){
  302. .fw_name = "xo",
  303. .name = "xo",
  304. },
  305. .num_parents = 1,
  306. .ops = &clk_fepll_div_ops,
  307. },
  308. },
  309. .pll_vco = &gcc_fepll_vco,
  310. };
  311. static struct clk_fepll gcc_fepll500_clk = {
  312. .fixed_div = 8,
  313. .cdiv.clkr = {
  314. .hw.init = &(struct clk_init_data){
  315. .name = "fepll500",
  316. .parent_data = &(const struct clk_parent_data){
  317. .fw_name = "xo",
  318. .name = "xo",
  319. },
  320. .num_parents = 1,
  321. .ops = &clk_fepll_div_ops,
  322. },
  323. },
  324. .pll_vco = &gcc_fepll_vco,
  325. };
  326. static const struct clk_div_table fepllwcss_clk_div_table[] = {
  327. { 0, 15 },
  328. { 1, 16 },
  329. { 2, 18 },
  330. { 3, 20 },
  331. { },
  332. };
  333. static struct clk_fepll gcc_fepllwcss2g_clk = {
  334. .cdiv.reg = 0x2f020,
  335. .cdiv.shift = 8,
  336. .cdiv.width = 2,
  337. .cdiv.clkr = {
  338. .hw.init = &(struct clk_init_data){
  339. .name = "fepllwcss2g",
  340. .parent_data = &(const struct clk_parent_data){
  341. .fw_name = "xo",
  342. .name = "xo",
  343. },
  344. .num_parents = 1,
  345. .ops = &clk_fepll_div_ops,
  346. },
  347. },
  348. .div_table = fepllwcss_clk_div_table,
  349. .pll_vco = &gcc_fepll_vco,
  350. };
  351. static struct clk_fepll gcc_fepllwcss5g_clk = {
  352. .cdiv.reg = 0x2f020,
  353. .cdiv.shift = 12,
  354. .cdiv.width = 2,
  355. .cdiv.clkr = {
  356. .hw.init = &(struct clk_init_data){
  357. .name = "fepllwcss5g",
  358. .parent_data = &(const struct clk_parent_data){
  359. .fw_name = "xo",
  360. .name = "xo",
  361. },
  362. .num_parents = 1,
  363. .ops = &clk_fepll_div_ops,
  364. },
  365. },
  366. .div_table = fepllwcss_clk_div_table,
  367. .pll_vco = &gcc_fepll_vco,
  368. };
  369. static struct parent_map gcc_xo_200_500_map[] = {
  370. { P_XO, 0 },
  371. { P_FEPLL200, 1 },
  372. { P_FEPLL500, 2 },
  373. };
  374. static const struct clk_parent_data gcc_xo_200_500[] = {
  375. { .fw_name = "xo", .name = "xo" },
  376. { .hw = &gcc_fepll200_clk.cdiv.clkr.hw },
  377. { .hw = &gcc_fepll500_clk.cdiv.clkr.hw },
  378. };
  379. static const struct freq_tbl ftbl_gcc_pcnoc_ahb_clk[] = {
  380. F(48000000, P_XO, 1, 0, 0),
  381. F(100000000, P_FEPLL200, 2, 0, 0),
  382. { }
  383. };
  384. static struct clk_rcg2 gcc_pcnoc_ahb_clk_src = {
  385. .cmd_rcgr = 0x21024,
  386. .hid_width = 5,
  387. .parent_map = gcc_xo_200_500_map,
  388. .freq_tbl = ftbl_gcc_pcnoc_ahb_clk,
  389. .clkr.hw.init = &(struct clk_init_data){
  390. .name = "gcc_pcnoc_ahb_clk_src",
  391. .parent_data = gcc_xo_200_500,
  392. .num_parents = ARRAY_SIZE(gcc_xo_200_500),
  393. .ops = &clk_rcg2_ops,
  394. },
  395. };
  396. static struct clk_branch pcnoc_clk_src = {
  397. .halt_reg = 0x21030,
  398. .clkr = {
  399. .enable_reg = 0x21030,
  400. .enable_mask = BIT(0),
  401. .hw.init = &(struct clk_init_data){
  402. .name = "pcnoc_clk_src",
  403. .parent_hws = (const struct clk_hw *[]){
  404. &gcc_pcnoc_ahb_clk_src.clkr.hw },
  405. .num_parents = 1,
  406. .ops = &clk_branch2_ops,
  407. .flags = CLK_SET_RATE_PARENT |
  408. CLK_IS_CRITICAL,
  409. },
  410. },
  411. };
  412. static struct parent_map gcc_xo_200_map[] = {
  413. { P_XO, 0 },
  414. { P_FEPLL200, 1 },
  415. };
  416. static const struct clk_parent_data gcc_xo_200[] = {
  417. { .fw_name = "xo", .name = "xo" },
  418. { .hw = &gcc_fepll200_clk.cdiv.clkr.hw },
  419. };
  420. static const struct freq_tbl ftbl_gcc_audio_pwm_clk[] = {
  421. F(48000000, P_XO, 1, 0, 0),
  422. F(200000000, P_FEPLL200, 1, 0, 0),
  423. { }
  424. };
  425. static struct clk_rcg2 audio_clk_src = {
  426. .cmd_rcgr = 0x1b000,
  427. .hid_width = 5,
  428. .parent_map = gcc_xo_200_map,
  429. .freq_tbl = ftbl_gcc_audio_pwm_clk,
  430. .clkr.hw.init = &(struct clk_init_data){
  431. .name = "audio_clk_src",
  432. .parent_data = gcc_xo_200,
  433. .num_parents = ARRAY_SIZE(gcc_xo_200),
  434. .ops = &clk_rcg2_ops,
  435. },
  436. };
  437. static struct clk_branch gcc_audio_ahb_clk = {
  438. .halt_reg = 0x1b010,
  439. .clkr = {
  440. .enable_reg = 0x1b010,
  441. .enable_mask = BIT(0),
  442. .hw.init = &(struct clk_init_data){
  443. .name = "gcc_audio_ahb_clk",
  444. .parent_hws = (const struct clk_hw *[]){
  445. &pcnoc_clk_src.clkr.hw },
  446. .flags = CLK_SET_RATE_PARENT,
  447. .num_parents = 1,
  448. .ops = &clk_branch2_ops,
  449. },
  450. },
  451. };
  452. static struct clk_branch gcc_audio_pwm_clk = {
  453. .halt_reg = 0x1b00C,
  454. .clkr = {
  455. .enable_reg = 0x1b00C,
  456. .enable_mask = BIT(0),
  457. .hw.init = &(struct clk_init_data){
  458. .name = "gcc_audio_pwm_clk",
  459. .parent_hws = (const struct clk_hw *[]){
  460. &audio_clk_src.clkr.hw },
  461. .flags = CLK_SET_RATE_PARENT,
  462. .num_parents = 1,
  463. .ops = &clk_branch2_ops,
  464. },
  465. },
  466. };
  467. static const struct freq_tbl ftbl_gcc_blsp1_qup1_2_i2c_apps_clk[] = {
  468. F(19050000, P_FEPLL200, 10.5, 1, 1),
  469. { }
  470. };
  471. static struct clk_rcg2 blsp1_qup1_i2c_apps_clk_src = {
  472. .cmd_rcgr = 0x200c,
  473. .hid_width = 5,
  474. .parent_map = gcc_xo_200_map,
  475. .freq_tbl = ftbl_gcc_blsp1_qup1_2_i2c_apps_clk,
  476. .clkr.hw.init = &(struct clk_init_data){
  477. .name = "blsp1_qup1_i2c_apps_clk_src",
  478. .parent_data = gcc_xo_200,
  479. .num_parents = ARRAY_SIZE(gcc_xo_200),
  480. .ops = &clk_rcg2_ops,
  481. },
  482. };
  483. static struct clk_branch gcc_blsp1_qup1_i2c_apps_clk = {
  484. .halt_reg = 0x2008,
  485. .clkr = {
  486. .enable_reg = 0x2008,
  487. .enable_mask = BIT(0),
  488. .hw.init = &(struct clk_init_data){
  489. .name = "gcc_blsp1_qup1_i2c_apps_clk",
  490. .parent_hws = (const struct clk_hw *[]){
  491. &blsp1_qup1_i2c_apps_clk_src.clkr.hw },
  492. .num_parents = 1,
  493. .ops = &clk_branch2_ops,
  494. .flags = CLK_SET_RATE_PARENT,
  495. },
  496. },
  497. };
  498. static struct clk_rcg2 blsp1_qup2_i2c_apps_clk_src = {
  499. .cmd_rcgr = 0x3000,
  500. .hid_width = 5,
  501. .parent_map = gcc_xo_200_map,
  502. .freq_tbl = ftbl_gcc_blsp1_qup1_2_i2c_apps_clk,
  503. .clkr.hw.init = &(struct clk_init_data){
  504. .name = "blsp1_qup2_i2c_apps_clk_src",
  505. .parent_data = gcc_xo_200,
  506. .num_parents = ARRAY_SIZE(gcc_xo_200),
  507. .ops = &clk_rcg2_ops,
  508. },
  509. };
  510. static struct clk_branch gcc_blsp1_qup2_i2c_apps_clk = {
  511. .halt_reg = 0x3010,
  512. .clkr = {
  513. .enable_reg = 0x3010,
  514. .enable_mask = BIT(0),
  515. .hw.init = &(struct clk_init_data){
  516. .name = "gcc_blsp1_qup2_i2c_apps_clk",
  517. .parent_hws = (const struct clk_hw *[]){
  518. &blsp1_qup2_i2c_apps_clk_src.clkr.hw },
  519. .num_parents = 1,
  520. .ops = &clk_branch2_ops,
  521. .flags = CLK_SET_RATE_PARENT,
  522. },
  523. },
  524. };
  525. static struct parent_map gcc_xo_200_spi_map[] = {
  526. { P_XO, 0 },
  527. { P_FEPLL200, 2 },
  528. };
  529. static const struct clk_parent_data gcc_xo_200_spi[] = {
  530. { .fw_name = "xo", .name = "xo" },
  531. { .hw = &gcc_fepll200_clk.cdiv.clkr.hw },
  532. };
  533. static const struct freq_tbl ftbl_gcc_blsp1_qup1_2_spi_apps_clk[] = {
  534. F(960000, P_XO, 12, 1, 4),
  535. F(4800000, P_XO, 1, 1, 10),
  536. F(9600000, P_XO, 1, 1, 5),
  537. F(15000000, P_XO, 1, 1, 3),
  538. F(19200000, P_XO, 1, 2, 5),
  539. F(24000000, P_XO, 1, 1, 2),
  540. F(48000000, P_XO, 1, 0, 0),
  541. { }
  542. };
  543. static struct clk_rcg2 blsp1_qup1_spi_apps_clk_src = {
  544. .cmd_rcgr = 0x2024,
  545. .mnd_width = 8,
  546. .hid_width = 5,
  547. .parent_map = gcc_xo_200_spi_map,
  548. .freq_tbl = ftbl_gcc_blsp1_qup1_2_spi_apps_clk,
  549. .clkr.hw.init = &(struct clk_init_data){
  550. .name = "blsp1_qup1_spi_apps_clk_src",
  551. .parent_data = gcc_xo_200_spi,
  552. .num_parents = ARRAY_SIZE(gcc_xo_200_spi),
  553. .ops = &clk_rcg2_ops,
  554. },
  555. };
  556. static struct clk_branch gcc_blsp1_qup1_spi_apps_clk = {
  557. .halt_reg = 0x2004,
  558. .clkr = {
  559. .enable_reg = 0x2004,
  560. .enable_mask = BIT(0),
  561. .hw.init = &(struct clk_init_data){
  562. .name = "gcc_blsp1_qup1_spi_apps_clk",
  563. .parent_hws = (const struct clk_hw *[]){
  564. &blsp1_qup1_spi_apps_clk_src.clkr.hw },
  565. .num_parents = 1,
  566. .ops = &clk_branch2_ops,
  567. .flags = CLK_SET_RATE_PARENT,
  568. },
  569. },
  570. };
  571. static struct clk_rcg2 blsp1_qup2_spi_apps_clk_src = {
  572. .cmd_rcgr = 0x3014,
  573. .mnd_width = 8,
  574. .hid_width = 5,
  575. .freq_tbl = ftbl_gcc_blsp1_qup1_2_spi_apps_clk,
  576. .parent_map = gcc_xo_200_spi_map,
  577. .clkr.hw.init = &(struct clk_init_data){
  578. .name = "blsp1_qup2_spi_apps_clk_src",
  579. .parent_data = gcc_xo_200_spi,
  580. .num_parents = ARRAY_SIZE(gcc_xo_200_spi),
  581. .ops = &clk_rcg2_ops,
  582. },
  583. };
  584. static struct clk_branch gcc_blsp1_qup2_spi_apps_clk = {
  585. .halt_reg = 0x300c,
  586. .clkr = {
  587. .enable_reg = 0x300c,
  588. .enable_mask = BIT(0),
  589. .hw.init = &(struct clk_init_data){
  590. .name = "gcc_blsp1_qup2_spi_apps_clk",
  591. .parent_hws = (const struct clk_hw *[]){
  592. &blsp1_qup2_spi_apps_clk_src.clkr.hw },
  593. .num_parents = 1,
  594. .ops = &clk_branch2_ops,
  595. .flags = CLK_SET_RATE_PARENT,
  596. },
  597. },
  598. };
  599. static const struct freq_tbl ftbl_gcc_blsp1_uart1_2_apps_clk[] = {
  600. F(1843200, P_FEPLL200, 1, 144, 15625),
  601. F(3686400, P_FEPLL200, 1, 288, 15625),
  602. F(7372800, P_FEPLL200, 1, 576, 15625),
  603. F(14745600, P_FEPLL200, 1, 1152, 15625),
  604. F(16000000, P_FEPLL200, 1, 2, 25),
  605. F(24000000, P_XO, 1, 1, 2),
  606. F(32000000, P_FEPLL200, 1, 4, 25),
  607. F(40000000, P_FEPLL200, 1, 1, 5),
  608. F(46400000, P_FEPLL200, 1, 29, 125),
  609. F(48000000, P_XO, 1, 0, 0),
  610. { }
  611. };
  612. static struct clk_rcg2 blsp1_uart1_apps_clk_src = {
  613. .cmd_rcgr = 0x2044,
  614. .mnd_width = 16,
  615. .hid_width = 5,
  616. .freq_tbl = ftbl_gcc_blsp1_uart1_2_apps_clk,
  617. .parent_map = gcc_xo_200_spi_map,
  618. .clkr.hw.init = &(struct clk_init_data){
  619. .name = "blsp1_uart1_apps_clk_src",
  620. .parent_data = gcc_xo_200_spi,
  621. .num_parents = ARRAY_SIZE(gcc_xo_200_spi),
  622. .ops = &clk_rcg2_ops,
  623. },
  624. };
  625. static struct clk_branch gcc_blsp1_uart1_apps_clk = {
  626. .halt_reg = 0x203c,
  627. .clkr = {
  628. .enable_reg = 0x203c,
  629. .enable_mask = BIT(0),
  630. .hw.init = &(struct clk_init_data){
  631. .name = "gcc_blsp1_uart1_apps_clk",
  632. .parent_hws = (const struct clk_hw *[]){
  633. &blsp1_uart1_apps_clk_src.clkr.hw },
  634. .flags = CLK_SET_RATE_PARENT,
  635. .num_parents = 1,
  636. .ops = &clk_branch2_ops,
  637. },
  638. },
  639. };
  640. static struct clk_rcg2 blsp1_uart2_apps_clk_src = {
  641. .cmd_rcgr = 0x3034,
  642. .mnd_width = 16,
  643. .hid_width = 5,
  644. .freq_tbl = ftbl_gcc_blsp1_uart1_2_apps_clk,
  645. .parent_map = gcc_xo_200_spi_map,
  646. .clkr.hw.init = &(struct clk_init_data){
  647. .name = "blsp1_uart2_apps_clk_src",
  648. .parent_data = gcc_xo_200_spi,
  649. .num_parents = ARRAY_SIZE(gcc_xo_200_spi),
  650. .ops = &clk_rcg2_ops,
  651. },
  652. };
  653. static struct clk_branch gcc_blsp1_uart2_apps_clk = {
  654. .halt_reg = 0x302c,
  655. .clkr = {
  656. .enable_reg = 0x302c,
  657. .enable_mask = BIT(0),
  658. .hw.init = &(struct clk_init_data){
  659. .name = "gcc_blsp1_uart2_apps_clk",
  660. .parent_hws = (const struct clk_hw *[]){
  661. &blsp1_uart2_apps_clk_src.clkr.hw },
  662. .num_parents = 1,
  663. .ops = &clk_branch2_ops,
  664. .flags = CLK_SET_RATE_PARENT,
  665. },
  666. },
  667. };
  668. static const struct freq_tbl ftbl_gcc_gp_clk[] = {
  669. F(1250000, P_FEPLL200, 1, 16, 0),
  670. F(2500000, P_FEPLL200, 1, 8, 0),
  671. F(5000000, P_FEPLL200, 1, 4, 0),
  672. { }
  673. };
  674. static struct clk_rcg2 gp1_clk_src = {
  675. .cmd_rcgr = 0x8004,
  676. .mnd_width = 8,
  677. .hid_width = 5,
  678. .freq_tbl = ftbl_gcc_gp_clk,
  679. .parent_map = gcc_xo_200_map,
  680. .clkr.hw.init = &(struct clk_init_data){
  681. .name = "gp1_clk_src",
  682. .parent_data = gcc_xo_200,
  683. .num_parents = ARRAY_SIZE(gcc_xo_200),
  684. .ops = &clk_rcg2_ops,
  685. },
  686. };
  687. static struct clk_branch gcc_gp1_clk = {
  688. .halt_reg = 0x8000,
  689. .clkr = {
  690. .enable_reg = 0x8000,
  691. .enable_mask = BIT(0),
  692. .hw.init = &(struct clk_init_data){
  693. .name = "gcc_gp1_clk",
  694. .parent_hws = (const struct clk_hw *[]){
  695. &gp1_clk_src.clkr.hw },
  696. .num_parents = 1,
  697. .ops = &clk_branch2_ops,
  698. .flags = CLK_SET_RATE_PARENT,
  699. },
  700. },
  701. };
  702. static struct clk_rcg2 gp2_clk_src = {
  703. .cmd_rcgr = 0x9004,
  704. .mnd_width = 8,
  705. .hid_width = 5,
  706. .freq_tbl = ftbl_gcc_gp_clk,
  707. .parent_map = gcc_xo_200_map,
  708. .clkr.hw.init = &(struct clk_init_data){
  709. .name = "gp2_clk_src",
  710. .parent_data = gcc_xo_200,
  711. .num_parents = ARRAY_SIZE(gcc_xo_200),
  712. .ops = &clk_rcg2_ops,
  713. },
  714. };
  715. static struct clk_branch gcc_gp2_clk = {
  716. .halt_reg = 0x9000,
  717. .clkr = {
  718. .enable_reg = 0x9000,
  719. .enable_mask = BIT(0),
  720. .hw.init = &(struct clk_init_data){
  721. .name = "gcc_gp2_clk",
  722. .parent_hws = (const struct clk_hw *[]){
  723. &gp2_clk_src.clkr.hw },
  724. .num_parents = 1,
  725. .ops = &clk_branch2_ops,
  726. .flags = CLK_SET_RATE_PARENT,
  727. },
  728. },
  729. };
  730. static struct clk_rcg2 gp3_clk_src = {
  731. .cmd_rcgr = 0xa004,
  732. .mnd_width = 8,
  733. .hid_width = 5,
  734. .freq_tbl = ftbl_gcc_gp_clk,
  735. .parent_map = gcc_xo_200_map,
  736. .clkr.hw.init = &(struct clk_init_data){
  737. .name = "gp3_clk_src",
  738. .parent_data = gcc_xo_200,
  739. .num_parents = ARRAY_SIZE(gcc_xo_200),
  740. .ops = &clk_rcg2_ops,
  741. },
  742. };
  743. static struct clk_branch gcc_gp3_clk = {
  744. .halt_reg = 0xa000,
  745. .clkr = {
  746. .enable_reg = 0xa000,
  747. .enable_mask = BIT(0),
  748. .hw.init = &(struct clk_init_data){
  749. .name = "gcc_gp3_clk",
  750. .parent_hws = (const struct clk_hw *[]){
  751. &gp3_clk_src.clkr.hw },
  752. .num_parents = 1,
  753. .ops = &clk_branch2_ops,
  754. .flags = CLK_SET_RATE_PARENT,
  755. },
  756. },
  757. };
  758. static struct parent_map gcc_xo_sdcc1_500_map[] = {
  759. { P_XO, 0 },
  760. { P_DDRPLL, 1 },
  761. { P_FEPLL500, 2 },
  762. };
  763. static const struct clk_parent_data gcc_xo_sdcc1_500[] = {
  764. { .fw_name = "xo", .name = "xo" },
  765. { .hw = &gcc_apss_sdcc_clk.cdiv.clkr.hw },
  766. { .hw = &gcc_fepll500_clk.cdiv.clkr.hw },
  767. };
  768. static const struct freq_tbl ftbl_gcc_sdcc1_apps_clk[] = {
  769. F(144000, P_XO, 1, 3, 240),
  770. F(400000, P_XO, 1, 1, 0),
  771. F(20000000, P_FEPLL500, 1, 1, 25),
  772. F(25000000, P_FEPLL500, 1, 1, 20),
  773. F(50000000, P_FEPLL500, 1, 1, 10),
  774. F(100000000, P_FEPLL500, 1, 1, 5),
  775. F(192000000, P_DDRPLL, 1, 0, 0),
  776. { }
  777. };
  778. static struct clk_rcg2 sdcc1_apps_clk_src = {
  779. .cmd_rcgr = 0x18004,
  780. .hid_width = 5,
  781. .freq_tbl = ftbl_gcc_sdcc1_apps_clk,
  782. .parent_map = gcc_xo_sdcc1_500_map,
  783. .clkr.hw.init = &(struct clk_init_data){
  784. .name = "sdcc1_apps_clk_src",
  785. .parent_data = gcc_xo_sdcc1_500,
  786. .num_parents = ARRAY_SIZE(gcc_xo_sdcc1_500),
  787. .ops = &clk_rcg2_ops,
  788. .flags = CLK_SET_RATE_PARENT,
  789. },
  790. };
  791. static const struct freq_tbl ftbl_gcc_apps_clk[] = {
  792. F(48000000, P_XO, 1, 0, 0),
  793. F(200000000, P_FEPLL200, 1, 0, 0),
  794. F(384000000, P_DDRPLLAPSS, 1, 0, 0),
  795. F(413000000, P_DDRPLLAPSS, 1, 0, 0),
  796. F(448000000, P_DDRPLLAPSS, 1, 0, 0),
  797. F(488000000, P_DDRPLLAPSS, 1, 0, 0),
  798. F(500000000, P_FEPLL500, 1, 0, 0),
  799. F(512000000, P_DDRPLLAPSS, 1, 0, 0),
  800. F(537000000, P_DDRPLLAPSS, 1, 0, 0),
  801. F(565000000, P_DDRPLLAPSS, 1, 0, 0),
  802. F(597000000, P_DDRPLLAPSS, 1, 0, 0),
  803. F(632000000, P_DDRPLLAPSS, 1, 0, 0),
  804. F(672000000, P_DDRPLLAPSS, 1, 0, 0),
  805. F(716000000, P_DDRPLLAPSS, 1, 0, 0),
  806. { }
  807. };
  808. static struct parent_map gcc_xo_ddr_500_200_map[] = {
  809. { P_XO, 0 },
  810. { P_FEPLL200, 3 },
  811. { P_FEPLL500, 2 },
  812. { P_DDRPLLAPSS, 1 },
  813. };
  814. static const struct clk_parent_data gcc_xo_ddr_500_200[] = {
  815. { .fw_name = "xo", .name = "xo" },
  816. { .hw = &gcc_fepll200_clk.cdiv.clkr.hw },
  817. { .hw = &gcc_fepll500_clk.cdiv.clkr.hw },
  818. { .hw = &gcc_apss_cpu_plldiv_clk.cdiv.clkr.hw },
  819. };
  820. static struct clk_rcg2 apps_clk_src = {
  821. .cmd_rcgr = 0x1900c,
  822. .hid_width = 5,
  823. .freq_tbl = ftbl_gcc_apps_clk,
  824. .parent_map = gcc_xo_ddr_500_200_map,
  825. .clkr.hw.init = &(struct clk_init_data){
  826. .name = "apps_clk_src",
  827. .parent_data = gcc_xo_ddr_500_200,
  828. .num_parents = ARRAY_SIZE(gcc_xo_ddr_500_200),
  829. .ops = &clk_rcg2_ops,
  830. .flags = CLK_SET_RATE_PARENT,
  831. },
  832. };
  833. static const struct freq_tbl ftbl_gcc_apps_ahb_clk[] = {
  834. F(48000000, P_XO, 1, 0, 0),
  835. F(100000000, P_FEPLL200, 2, 0, 0),
  836. { }
  837. };
  838. static struct clk_rcg2 apps_ahb_clk_src = {
  839. .cmd_rcgr = 0x19014,
  840. .hid_width = 5,
  841. .parent_map = gcc_xo_200_500_map,
  842. .freq_tbl = ftbl_gcc_apps_ahb_clk,
  843. .clkr.hw.init = &(struct clk_init_data){
  844. .name = "apps_ahb_clk_src",
  845. .parent_data = gcc_xo_200_500,
  846. .num_parents = ARRAY_SIZE(gcc_xo_200_500),
  847. .ops = &clk_rcg2_ops,
  848. },
  849. };
  850. static struct clk_branch gcc_apss_ahb_clk = {
  851. .halt_reg = 0x19004,
  852. .halt_check = BRANCH_HALT_VOTED,
  853. .clkr = {
  854. .enable_reg = 0x6000,
  855. .enable_mask = BIT(14),
  856. .hw.init = &(struct clk_init_data){
  857. .name = "gcc_apss_ahb_clk",
  858. .parent_hws = (const struct clk_hw *[]){
  859. &apps_ahb_clk_src.clkr.hw },
  860. .num_parents = 1,
  861. .ops = &clk_branch2_ops,
  862. .flags = CLK_SET_RATE_PARENT,
  863. },
  864. },
  865. };
  866. static struct clk_branch gcc_blsp1_ahb_clk = {
  867. .halt_reg = 0x1008,
  868. .halt_check = BRANCH_HALT_VOTED,
  869. .clkr = {
  870. .enable_reg = 0x6000,
  871. .enable_mask = BIT(10),
  872. .hw.init = &(struct clk_init_data){
  873. .name = "gcc_blsp1_ahb_clk",
  874. .parent_hws = (const struct clk_hw *[]){
  875. &pcnoc_clk_src.clkr.hw },
  876. .num_parents = 1,
  877. .ops = &clk_branch2_ops,
  878. },
  879. },
  880. };
  881. static struct clk_branch gcc_dcd_xo_clk = {
  882. .halt_reg = 0x2103c,
  883. .clkr = {
  884. .enable_reg = 0x2103c,
  885. .enable_mask = BIT(0),
  886. .hw.init = &(struct clk_init_data){
  887. .name = "gcc_dcd_xo_clk",
  888. .parent_data = &(const struct clk_parent_data){
  889. .fw_name = "xo",
  890. .name = "xo",
  891. },
  892. .num_parents = 1,
  893. .ops = &clk_branch2_ops,
  894. },
  895. },
  896. };
  897. static struct clk_branch gcc_boot_rom_ahb_clk = {
  898. .halt_reg = 0x1300c,
  899. .clkr = {
  900. .enable_reg = 0x1300c,
  901. .enable_mask = BIT(0),
  902. .hw.init = &(struct clk_init_data){
  903. .name = "gcc_boot_rom_ahb_clk",
  904. .parent_hws = (const struct clk_hw *[]){
  905. &pcnoc_clk_src.clkr.hw },
  906. .num_parents = 1,
  907. .ops = &clk_branch2_ops,
  908. .flags = CLK_SET_RATE_PARENT,
  909. },
  910. },
  911. };
  912. static struct clk_branch gcc_crypto_ahb_clk = {
  913. .halt_reg = 0x16024,
  914. .halt_check = BRANCH_HALT_VOTED,
  915. .clkr = {
  916. .enable_reg = 0x6000,
  917. .enable_mask = BIT(0),
  918. .hw.init = &(struct clk_init_data){
  919. .name = "gcc_crypto_ahb_clk",
  920. .parent_hws = (const struct clk_hw *[]){
  921. &pcnoc_clk_src.clkr.hw },
  922. .num_parents = 1,
  923. .ops = &clk_branch2_ops,
  924. },
  925. },
  926. };
  927. static struct clk_branch gcc_crypto_axi_clk = {
  928. .halt_reg = 0x16020,
  929. .halt_check = BRANCH_HALT_VOTED,
  930. .clkr = {
  931. .enable_reg = 0x6000,
  932. .enable_mask = BIT(1),
  933. .hw.init = &(struct clk_init_data){
  934. .name = "gcc_crypto_axi_clk",
  935. .parent_hws = (const struct clk_hw *[]){
  936. &gcc_fepll125_clk.cdiv.clkr.hw },
  937. .num_parents = 1,
  938. .ops = &clk_branch2_ops,
  939. },
  940. },
  941. };
  942. static struct clk_branch gcc_crypto_clk = {
  943. .halt_reg = 0x1601c,
  944. .halt_check = BRANCH_HALT_VOTED,
  945. .clkr = {
  946. .enable_reg = 0x6000,
  947. .enable_mask = BIT(2),
  948. .hw.init = &(struct clk_init_data){
  949. .name = "gcc_crypto_clk",
  950. .parent_hws = (const struct clk_hw *[]){
  951. &gcc_fepll125_clk.cdiv.clkr.hw },
  952. .num_parents = 1,
  953. .ops = &clk_branch2_ops,
  954. },
  955. },
  956. };
  957. static struct parent_map gcc_xo_125_dly_map[] = {
  958. { P_XO, 0 },
  959. { P_FEPLL125DLY, 1 },
  960. };
  961. static const struct clk_parent_data gcc_xo_125_dly[] = {
  962. { .fw_name = "xo", .name = "xo" },
  963. { .hw = &gcc_fepll125dly_clk.cdiv.clkr.hw },
  964. };
  965. static const struct freq_tbl ftbl_gcc_fephy_dly_clk[] = {
  966. F(125000000, P_FEPLL125DLY, 1, 0, 0),
  967. { }
  968. };
  969. static struct clk_rcg2 fephy_125m_dly_clk_src = {
  970. .cmd_rcgr = 0x12000,
  971. .hid_width = 5,
  972. .parent_map = gcc_xo_125_dly_map,
  973. .freq_tbl = ftbl_gcc_fephy_dly_clk,
  974. .clkr.hw.init = &(struct clk_init_data){
  975. .name = "fephy_125m_dly_clk_src",
  976. .parent_data = gcc_xo_125_dly,
  977. .num_parents = ARRAY_SIZE(gcc_xo_125_dly),
  978. .ops = &clk_rcg2_ops,
  979. },
  980. };
  981. static struct clk_branch gcc_ess_clk = {
  982. .halt_reg = 0x12010,
  983. .clkr = {
  984. .enable_reg = 0x12010,
  985. .enable_mask = BIT(0),
  986. .hw.init = &(struct clk_init_data){
  987. .name = "gcc_ess_clk",
  988. .parent_hws = (const struct clk_hw *[]){
  989. &fephy_125m_dly_clk_src.clkr.hw },
  990. .num_parents = 1,
  991. .ops = &clk_branch2_ops,
  992. .flags = CLK_SET_RATE_PARENT,
  993. },
  994. },
  995. };
  996. static struct clk_branch gcc_imem_axi_clk = {
  997. .halt_reg = 0xe004,
  998. .halt_check = BRANCH_HALT_VOTED,
  999. .clkr = {
  1000. .enable_reg = 0x6000,
  1001. .enable_mask = BIT(17),
  1002. .hw.init = &(struct clk_init_data){
  1003. .name = "gcc_imem_axi_clk",
  1004. .parent_hws = (const struct clk_hw *[]){
  1005. &gcc_fepll200_clk.cdiv.clkr.hw },
  1006. .num_parents = 1,
  1007. .ops = &clk_branch2_ops,
  1008. },
  1009. },
  1010. };
  1011. static struct clk_branch gcc_imem_cfg_ahb_clk = {
  1012. .halt_reg = 0xe008,
  1013. .clkr = {
  1014. .enable_reg = 0xe008,
  1015. .enable_mask = BIT(0),
  1016. .hw.init = &(struct clk_init_data){
  1017. .name = "gcc_imem_cfg_ahb_clk",
  1018. .parent_hws = (const struct clk_hw *[]){
  1019. &pcnoc_clk_src.clkr.hw },
  1020. .num_parents = 1,
  1021. .ops = &clk_branch2_ops,
  1022. },
  1023. },
  1024. };
  1025. static struct clk_branch gcc_pcie_ahb_clk = {
  1026. .halt_reg = 0x1d00c,
  1027. .clkr = {
  1028. .enable_reg = 0x1d00c,
  1029. .enable_mask = BIT(0),
  1030. .hw.init = &(struct clk_init_data){
  1031. .name = "gcc_pcie_ahb_clk",
  1032. .parent_hws = (const struct clk_hw *[]){
  1033. &pcnoc_clk_src.clkr.hw },
  1034. .num_parents = 1,
  1035. .ops = &clk_branch2_ops,
  1036. },
  1037. },
  1038. };
  1039. static struct clk_branch gcc_pcie_axi_m_clk = {
  1040. .halt_reg = 0x1d004,
  1041. .clkr = {
  1042. .enable_reg = 0x1d004,
  1043. .enable_mask = BIT(0),
  1044. .hw.init = &(struct clk_init_data){
  1045. .name = "gcc_pcie_axi_m_clk",
  1046. .parent_hws = (const struct clk_hw *[]){
  1047. &gcc_fepll200_clk.cdiv.clkr.hw },
  1048. .num_parents = 1,
  1049. .ops = &clk_branch2_ops,
  1050. },
  1051. },
  1052. };
  1053. static struct clk_branch gcc_pcie_axi_s_clk = {
  1054. .halt_reg = 0x1d008,
  1055. .clkr = {
  1056. .enable_reg = 0x1d008,
  1057. .enable_mask = BIT(0),
  1058. .hw.init = &(struct clk_init_data){
  1059. .name = "gcc_pcie_axi_s_clk",
  1060. .parent_hws = (const struct clk_hw *[]){
  1061. &gcc_fepll200_clk.cdiv.clkr.hw },
  1062. .num_parents = 1,
  1063. .ops = &clk_branch2_ops,
  1064. },
  1065. },
  1066. };
  1067. static struct clk_branch gcc_prng_ahb_clk = {
  1068. .halt_reg = 0x13004,
  1069. .halt_check = BRANCH_HALT_VOTED,
  1070. .clkr = {
  1071. .enable_reg = 0x6000,
  1072. .enable_mask = BIT(8),
  1073. .hw.init = &(struct clk_init_data){
  1074. .name = "gcc_prng_ahb_clk",
  1075. .parent_hws = (const struct clk_hw *[]){
  1076. &pcnoc_clk_src.clkr.hw },
  1077. .num_parents = 1,
  1078. .ops = &clk_branch2_ops,
  1079. },
  1080. },
  1081. };
  1082. static struct clk_branch gcc_qpic_ahb_clk = {
  1083. .halt_reg = 0x1c008,
  1084. .clkr = {
  1085. .enable_reg = 0x1c008,
  1086. .enable_mask = BIT(0),
  1087. .hw.init = &(struct clk_init_data){
  1088. .name = "gcc_qpic_ahb_clk",
  1089. .parent_hws = (const struct clk_hw *[]){
  1090. &pcnoc_clk_src.clkr.hw },
  1091. .num_parents = 1,
  1092. .ops = &clk_branch2_ops,
  1093. },
  1094. },
  1095. };
  1096. static struct clk_branch gcc_qpic_clk = {
  1097. .halt_reg = 0x1c004,
  1098. .clkr = {
  1099. .enable_reg = 0x1c004,
  1100. .enable_mask = BIT(0),
  1101. .hw.init = &(struct clk_init_data){
  1102. .name = "gcc_qpic_clk",
  1103. .parent_hws = (const struct clk_hw *[]){
  1104. &pcnoc_clk_src.clkr.hw },
  1105. .num_parents = 1,
  1106. .ops = &clk_branch2_ops,
  1107. },
  1108. },
  1109. };
  1110. static struct clk_branch gcc_sdcc1_ahb_clk = {
  1111. .halt_reg = 0x18010,
  1112. .clkr = {
  1113. .enable_reg = 0x18010,
  1114. .enable_mask = BIT(0),
  1115. .hw.init = &(struct clk_init_data){
  1116. .name = "gcc_sdcc1_ahb_clk",
  1117. .parent_hws = (const struct clk_hw *[]){
  1118. &pcnoc_clk_src.clkr.hw },
  1119. .num_parents = 1,
  1120. .ops = &clk_branch2_ops,
  1121. },
  1122. },
  1123. };
  1124. static struct clk_branch gcc_sdcc1_apps_clk = {
  1125. .halt_reg = 0x1800c,
  1126. .clkr = {
  1127. .enable_reg = 0x1800c,
  1128. .enable_mask = BIT(0),
  1129. .hw.init = &(struct clk_init_data){
  1130. .name = "gcc_sdcc1_apps_clk",
  1131. .parent_hws = (const struct clk_hw *[]){
  1132. &sdcc1_apps_clk_src.clkr.hw },
  1133. .num_parents = 1,
  1134. .ops = &clk_branch2_ops,
  1135. .flags = CLK_SET_RATE_PARENT,
  1136. },
  1137. },
  1138. };
  1139. static struct clk_branch gcc_tlmm_ahb_clk = {
  1140. .halt_reg = 0x5004,
  1141. .halt_check = BRANCH_HALT_VOTED,
  1142. .clkr = {
  1143. .enable_reg = 0x6000,
  1144. .enable_mask = BIT(5),
  1145. .hw.init = &(struct clk_init_data){
  1146. .name = "gcc_tlmm_ahb_clk",
  1147. .parent_hws = (const struct clk_hw *[]){
  1148. &pcnoc_clk_src.clkr.hw },
  1149. .num_parents = 1,
  1150. .ops = &clk_branch2_ops,
  1151. },
  1152. },
  1153. };
  1154. static struct clk_branch gcc_usb2_master_clk = {
  1155. .halt_reg = 0x1e00c,
  1156. .clkr = {
  1157. .enable_reg = 0x1e00c,
  1158. .enable_mask = BIT(0),
  1159. .hw.init = &(struct clk_init_data){
  1160. .name = "gcc_usb2_master_clk",
  1161. .parent_hws = (const struct clk_hw *[]){
  1162. &pcnoc_clk_src.clkr.hw },
  1163. .num_parents = 1,
  1164. .ops = &clk_branch2_ops,
  1165. },
  1166. },
  1167. };
  1168. static struct clk_branch gcc_usb2_sleep_clk = {
  1169. .halt_reg = 0x1e010,
  1170. .clkr = {
  1171. .enable_reg = 0x1e010,
  1172. .enable_mask = BIT(0),
  1173. .hw.init = &(struct clk_init_data){
  1174. .name = "gcc_usb2_sleep_clk",
  1175. .parent_data = &(const struct clk_parent_data){
  1176. .fw_name = "sleep_clk",
  1177. .name = "gcc_sleep_clk_src",
  1178. },
  1179. .num_parents = 1,
  1180. .ops = &clk_branch2_ops,
  1181. },
  1182. },
  1183. };
  1184. static const struct freq_tbl ftbl_gcc_usb30_mock_utmi_clk[] = {
  1185. F(2000000, P_FEPLL200, 10, 0, 0),
  1186. { }
  1187. };
  1188. static struct clk_rcg2 usb30_mock_utmi_clk_src = {
  1189. .cmd_rcgr = 0x1e000,
  1190. .hid_width = 5,
  1191. .parent_map = gcc_xo_200_map,
  1192. .freq_tbl = ftbl_gcc_usb30_mock_utmi_clk,
  1193. .clkr.hw.init = &(struct clk_init_data){
  1194. .name = "usb30_mock_utmi_clk_src",
  1195. .parent_data = gcc_xo_200,
  1196. .num_parents = ARRAY_SIZE(gcc_xo_200),
  1197. .ops = &clk_rcg2_ops,
  1198. },
  1199. };
  1200. static struct clk_branch gcc_usb2_mock_utmi_clk = {
  1201. .halt_reg = 0x1e014,
  1202. .clkr = {
  1203. .enable_reg = 0x1e014,
  1204. .enable_mask = BIT(0),
  1205. .hw.init = &(struct clk_init_data){
  1206. .name = "gcc_usb2_mock_utmi_clk",
  1207. .parent_hws = (const struct clk_hw *[]){
  1208. &usb30_mock_utmi_clk_src.clkr.hw },
  1209. .num_parents = 1,
  1210. .ops = &clk_branch2_ops,
  1211. .flags = CLK_SET_RATE_PARENT,
  1212. },
  1213. },
  1214. };
  1215. static struct clk_branch gcc_usb3_master_clk = {
  1216. .halt_reg = 0x1e028,
  1217. .clkr = {
  1218. .enable_reg = 0x1e028,
  1219. .enable_mask = BIT(0),
  1220. .hw.init = &(struct clk_init_data){
  1221. .name = "gcc_usb3_master_clk",
  1222. .parent_hws = (const struct clk_hw *[]){
  1223. &gcc_fepll125_clk.cdiv.clkr.hw },
  1224. .num_parents = 1,
  1225. .ops = &clk_branch2_ops,
  1226. },
  1227. },
  1228. };
  1229. static struct clk_branch gcc_usb3_sleep_clk = {
  1230. .halt_reg = 0x1e02C,
  1231. .clkr = {
  1232. .enable_reg = 0x1e02C,
  1233. .enable_mask = BIT(0),
  1234. .hw.init = &(struct clk_init_data){
  1235. .name = "gcc_usb3_sleep_clk",
  1236. .parent_data = &(const struct clk_parent_data){
  1237. .fw_name = "sleep_clk",
  1238. .name = "gcc_sleep_clk_src",
  1239. },
  1240. .num_parents = 1,
  1241. .ops = &clk_branch2_ops,
  1242. },
  1243. },
  1244. };
  1245. static struct clk_branch gcc_usb3_mock_utmi_clk = {
  1246. .halt_reg = 0x1e030,
  1247. .clkr = {
  1248. .enable_reg = 0x1e030,
  1249. .enable_mask = BIT(0),
  1250. .hw.init = &(struct clk_init_data){
  1251. .name = "gcc_usb3_mock_utmi_clk",
  1252. .parent_hws = (const struct clk_hw *[]){
  1253. &usb30_mock_utmi_clk_src.clkr.hw },
  1254. .num_parents = 1,
  1255. .ops = &clk_branch2_ops,
  1256. .flags = CLK_SET_RATE_PARENT,
  1257. },
  1258. },
  1259. };
  1260. static struct parent_map gcc_xo_wcss2g_map[] = {
  1261. { P_XO, 0 },
  1262. { P_FEPLLWCSS2G, 1 },
  1263. };
  1264. static const struct clk_parent_data gcc_xo_wcss2g[] = {
  1265. { .fw_name = "xo", .name = "xo" },
  1266. { .hw = &gcc_fepllwcss2g_clk.cdiv.clkr.hw },
  1267. };
  1268. static const struct freq_tbl ftbl_gcc_wcss2g_clk[] = {
  1269. F(48000000, P_XO, 1, 0, 0),
  1270. F(250000000, P_FEPLLWCSS2G, 1, 0, 0),
  1271. { }
  1272. };
  1273. static struct clk_rcg2 wcss2g_clk_src = {
  1274. .cmd_rcgr = 0x1f000,
  1275. .hid_width = 5,
  1276. .freq_tbl = ftbl_gcc_wcss2g_clk,
  1277. .parent_map = gcc_xo_wcss2g_map,
  1278. .clkr.hw.init = &(struct clk_init_data){
  1279. .name = "wcss2g_clk_src",
  1280. .parent_data = gcc_xo_wcss2g,
  1281. .num_parents = ARRAY_SIZE(gcc_xo_wcss2g),
  1282. .ops = &clk_rcg2_ops,
  1283. .flags = CLK_SET_RATE_PARENT,
  1284. },
  1285. };
  1286. static struct clk_branch gcc_wcss2g_clk = {
  1287. .halt_reg = 0x1f00C,
  1288. .clkr = {
  1289. .enable_reg = 0x1f00C,
  1290. .enable_mask = BIT(0),
  1291. .hw.init = &(struct clk_init_data){
  1292. .name = "gcc_wcss2g_clk",
  1293. .parent_hws = (const struct clk_hw *[]){
  1294. &wcss2g_clk_src.clkr.hw },
  1295. .num_parents = 1,
  1296. .ops = &clk_branch2_ops,
  1297. .flags = CLK_SET_RATE_PARENT,
  1298. },
  1299. },
  1300. };
  1301. static struct clk_branch gcc_wcss2g_ref_clk = {
  1302. .halt_reg = 0x1f00C,
  1303. .clkr = {
  1304. .enable_reg = 0x1f00C,
  1305. .enable_mask = BIT(0),
  1306. .hw.init = &(struct clk_init_data){
  1307. .name = "gcc_wcss2g_ref_clk",
  1308. .parent_data = &(const struct clk_parent_data){
  1309. .fw_name = "xo",
  1310. .name = "xo",
  1311. },
  1312. .num_parents = 1,
  1313. .ops = &clk_branch2_ops,
  1314. .flags = CLK_SET_RATE_PARENT,
  1315. },
  1316. },
  1317. };
  1318. static struct clk_branch gcc_wcss2g_rtc_clk = {
  1319. .halt_reg = 0x1f010,
  1320. .clkr = {
  1321. .enable_reg = 0x1f010,
  1322. .enable_mask = BIT(0),
  1323. .hw.init = &(struct clk_init_data){
  1324. .name = "gcc_wcss2g_rtc_clk",
  1325. .parent_data = &(const struct clk_parent_data){
  1326. .fw_name = "sleep_clk",
  1327. .name = "gcc_sleep_clk_src",
  1328. },
  1329. .num_parents = 1,
  1330. .ops = &clk_branch2_ops,
  1331. },
  1332. },
  1333. };
  1334. static struct parent_map gcc_xo_wcss5g_map[] = {
  1335. { P_XO, 0 },
  1336. { P_FEPLLWCSS5G, 1 },
  1337. };
  1338. static const struct clk_parent_data gcc_xo_wcss5g[] = {
  1339. { .fw_name = "xo", .name = "xo" },
  1340. { .hw = &gcc_fepllwcss5g_clk.cdiv.clkr.hw },
  1341. };
  1342. static const struct freq_tbl ftbl_gcc_wcss5g_clk[] = {
  1343. F(48000000, P_XO, 1, 0, 0),
  1344. F(250000000, P_FEPLLWCSS5G, 1, 0, 0),
  1345. { }
  1346. };
  1347. static struct clk_rcg2 wcss5g_clk_src = {
  1348. .cmd_rcgr = 0x20000,
  1349. .hid_width = 5,
  1350. .parent_map = gcc_xo_wcss5g_map,
  1351. .freq_tbl = ftbl_gcc_wcss5g_clk,
  1352. .clkr.hw.init = &(struct clk_init_data){
  1353. .name = "wcss5g_clk_src",
  1354. .parent_data = gcc_xo_wcss5g,
  1355. .num_parents = ARRAY_SIZE(gcc_xo_wcss5g),
  1356. .ops = &clk_rcg2_ops,
  1357. },
  1358. };
  1359. static struct clk_branch gcc_wcss5g_clk = {
  1360. .halt_reg = 0x2000c,
  1361. .clkr = {
  1362. .enable_reg = 0x2000c,
  1363. .enable_mask = BIT(0),
  1364. .hw.init = &(struct clk_init_data){
  1365. .name = "gcc_wcss5g_clk",
  1366. .parent_hws = (const struct clk_hw *[]){
  1367. &wcss5g_clk_src.clkr.hw },
  1368. .num_parents = 1,
  1369. .ops = &clk_branch2_ops,
  1370. .flags = CLK_SET_RATE_PARENT,
  1371. },
  1372. },
  1373. };
  1374. static struct clk_branch gcc_wcss5g_ref_clk = {
  1375. .halt_reg = 0x2000c,
  1376. .clkr = {
  1377. .enable_reg = 0x2000c,
  1378. .enable_mask = BIT(0),
  1379. .hw.init = &(struct clk_init_data){
  1380. .name = "gcc_wcss5g_ref_clk",
  1381. .parent_data = &(const struct clk_parent_data){
  1382. .fw_name = "xo",
  1383. .name = "xo",
  1384. },
  1385. .num_parents = 1,
  1386. .ops = &clk_branch2_ops,
  1387. .flags = CLK_SET_RATE_PARENT,
  1388. },
  1389. },
  1390. };
  1391. static struct clk_branch gcc_wcss5g_rtc_clk = {
  1392. .halt_reg = 0x20010,
  1393. .clkr = {
  1394. .enable_reg = 0x20010,
  1395. .enable_mask = BIT(0),
  1396. .hw.init = &(struct clk_init_data){
  1397. .name = "gcc_wcss5g_rtc_clk",
  1398. .parent_data = &(const struct clk_parent_data){
  1399. .fw_name = "sleep_clk",
  1400. .name = "gcc_sleep_clk_src",
  1401. },
  1402. .num_parents = 1,
  1403. .ops = &clk_branch2_ops,
  1404. .flags = CLK_SET_RATE_PARENT,
  1405. },
  1406. },
  1407. };
  1408. static struct clk_regmap *gcc_ipq4019_clocks[] = {
  1409. [AUDIO_CLK_SRC] = &audio_clk_src.clkr,
  1410. [BLSP1_QUP1_I2C_APPS_CLK_SRC] = &blsp1_qup1_i2c_apps_clk_src.clkr,
  1411. [BLSP1_QUP1_SPI_APPS_CLK_SRC] = &blsp1_qup1_spi_apps_clk_src.clkr,
  1412. [BLSP1_QUP2_I2C_APPS_CLK_SRC] = &blsp1_qup2_i2c_apps_clk_src.clkr,
  1413. [BLSP1_QUP2_SPI_APPS_CLK_SRC] = &blsp1_qup2_spi_apps_clk_src.clkr,
  1414. [BLSP1_UART1_APPS_CLK_SRC] = &blsp1_uart1_apps_clk_src.clkr,
  1415. [BLSP1_UART2_APPS_CLK_SRC] = &blsp1_uart2_apps_clk_src.clkr,
  1416. [GCC_USB3_MOCK_UTMI_CLK_SRC] = &usb30_mock_utmi_clk_src.clkr,
  1417. [GCC_APPS_CLK_SRC] = &apps_clk_src.clkr,
  1418. [GCC_APPS_AHB_CLK_SRC] = &apps_ahb_clk_src.clkr,
  1419. [GP1_CLK_SRC] = &gp1_clk_src.clkr,
  1420. [GP2_CLK_SRC] = &gp2_clk_src.clkr,
  1421. [GP3_CLK_SRC] = &gp3_clk_src.clkr,
  1422. [SDCC1_APPS_CLK_SRC] = &sdcc1_apps_clk_src.clkr,
  1423. [FEPHY_125M_DLY_CLK_SRC] = &fephy_125m_dly_clk_src.clkr,
  1424. [WCSS2G_CLK_SRC] = &wcss2g_clk_src.clkr,
  1425. [WCSS5G_CLK_SRC] = &wcss5g_clk_src.clkr,
  1426. [GCC_APSS_AHB_CLK] = &gcc_apss_ahb_clk.clkr,
  1427. [GCC_AUDIO_AHB_CLK] = &gcc_audio_ahb_clk.clkr,
  1428. [GCC_AUDIO_PWM_CLK] = &gcc_audio_pwm_clk.clkr,
  1429. [GCC_BLSP1_AHB_CLK] = &gcc_blsp1_ahb_clk.clkr,
  1430. [GCC_BLSP1_QUP1_I2C_APPS_CLK] = &gcc_blsp1_qup1_i2c_apps_clk.clkr,
  1431. [GCC_BLSP1_QUP1_SPI_APPS_CLK] = &gcc_blsp1_qup1_spi_apps_clk.clkr,
  1432. [GCC_BLSP1_QUP2_I2C_APPS_CLK] = &gcc_blsp1_qup2_i2c_apps_clk.clkr,
  1433. [GCC_BLSP1_QUP2_SPI_APPS_CLK] = &gcc_blsp1_qup2_spi_apps_clk.clkr,
  1434. [GCC_BLSP1_UART1_APPS_CLK] = &gcc_blsp1_uart1_apps_clk.clkr,
  1435. [GCC_BLSP1_UART2_APPS_CLK] = &gcc_blsp1_uart2_apps_clk.clkr,
  1436. [GCC_DCD_XO_CLK] = &gcc_dcd_xo_clk.clkr,
  1437. [GCC_GP1_CLK] = &gcc_gp1_clk.clkr,
  1438. [GCC_GP2_CLK] = &gcc_gp2_clk.clkr,
  1439. [GCC_GP3_CLK] = &gcc_gp3_clk.clkr,
  1440. [GCC_BOOT_ROM_AHB_CLK] = &gcc_boot_rom_ahb_clk.clkr,
  1441. [GCC_CRYPTO_AHB_CLK] = &gcc_crypto_ahb_clk.clkr,
  1442. [GCC_CRYPTO_AXI_CLK] = &gcc_crypto_axi_clk.clkr,
  1443. [GCC_CRYPTO_CLK] = &gcc_crypto_clk.clkr,
  1444. [GCC_ESS_CLK] = &gcc_ess_clk.clkr,
  1445. [GCC_IMEM_AXI_CLK] = &gcc_imem_axi_clk.clkr,
  1446. [GCC_IMEM_CFG_AHB_CLK] = &gcc_imem_cfg_ahb_clk.clkr,
  1447. [GCC_PCIE_AHB_CLK] = &gcc_pcie_ahb_clk.clkr,
  1448. [GCC_PCIE_AXI_M_CLK] = &gcc_pcie_axi_m_clk.clkr,
  1449. [GCC_PCIE_AXI_S_CLK] = &gcc_pcie_axi_s_clk.clkr,
  1450. [GCC_PRNG_AHB_CLK] = &gcc_prng_ahb_clk.clkr,
  1451. [GCC_QPIC_AHB_CLK] = &gcc_qpic_ahb_clk.clkr,
  1452. [GCC_QPIC_CLK] = &gcc_qpic_clk.clkr,
  1453. [GCC_SDCC1_AHB_CLK] = &gcc_sdcc1_ahb_clk.clkr,
  1454. [GCC_SDCC1_APPS_CLK] = &gcc_sdcc1_apps_clk.clkr,
  1455. [GCC_TLMM_AHB_CLK] = &gcc_tlmm_ahb_clk.clkr,
  1456. [GCC_USB2_MASTER_CLK] = &gcc_usb2_master_clk.clkr,
  1457. [GCC_USB2_SLEEP_CLK] = &gcc_usb2_sleep_clk.clkr,
  1458. [GCC_USB2_MOCK_UTMI_CLK] = &gcc_usb2_mock_utmi_clk.clkr,
  1459. [GCC_USB3_MASTER_CLK] = &gcc_usb3_master_clk.clkr,
  1460. [GCC_USB3_SLEEP_CLK] = &gcc_usb3_sleep_clk.clkr,
  1461. [GCC_USB3_MOCK_UTMI_CLK] = &gcc_usb3_mock_utmi_clk.clkr,
  1462. [GCC_WCSS2G_CLK] = &gcc_wcss2g_clk.clkr,
  1463. [GCC_WCSS2G_REF_CLK] = &gcc_wcss2g_ref_clk.clkr,
  1464. [GCC_WCSS2G_RTC_CLK] = &gcc_wcss2g_rtc_clk.clkr,
  1465. [GCC_WCSS5G_CLK] = &gcc_wcss5g_clk.clkr,
  1466. [GCC_WCSS5G_REF_CLK] = &gcc_wcss5g_ref_clk.clkr,
  1467. [GCC_WCSS5G_RTC_CLK] = &gcc_wcss5g_rtc_clk.clkr,
  1468. [GCC_SDCC_PLLDIV_CLK] = &gcc_apss_sdcc_clk.cdiv.clkr,
  1469. [GCC_FEPLL125_CLK] = &gcc_fepll125_clk.cdiv.clkr,
  1470. [GCC_FEPLL125DLY_CLK] = &gcc_fepll125dly_clk.cdiv.clkr,
  1471. [GCC_FEPLL200_CLK] = &gcc_fepll200_clk.cdiv.clkr,
  1472. [GCC_FEPLL500_CLK] = &gcc_fepll500_clk.cdiv.clkr,
  1473. [GCC_FEPLL_WCSS2G_CLK] = &gcc_fepllwcss2g_clk.cdiv.clkr,
  1474. [GCC_FEPLL_WCSS5G_CLK] = &gcc_fepllwcss5g_clk.cdiv.clkr,
  1475. [GCC_APSS_CPU_PLLDIV_CLK] = &gcc_apss_cpu_plldiv_clk.cdiv.clkr,
  1476. [GCC_PCNOC_AHB_CLK_SRC] = &gcc_pcnoc_ahb_clk_src.clkr,
  1477. [GCC_PCNOC_AHB_CLK] = &pcnoc_clk_src.clkr,
  1478. };
  1479. static const struct qcom_reset_map gcc_ipq4019_resets[] = {
  1480. [WIFI0_CPU_INIT_RESET] = { 0x1f008, 5 },
  1481. [WIFI0_RADIO_SRIF_RESET] = { 0x1f008, 4 },
  1482. [WIFI0_RADIO_WARM_RESET] = { 0x1f008, 3 },
  1483. [WIFI0_RADIO_COLD_RESET] = { 0x1f008, 2 },
  1484. [WIFI0_CORE_WARM_RESET] = { 0x1f008, 1 },
  1485. [WIFI0_CORE_COLD_RESET] = { 0x1f008, 0 },
  1486. [WIFI1_CPU_INIT_RESET] = { 0x20008, 5 },
  1487. [WIFI1_RADIO_SRIF_RESET] = { 0x20008, 4 },
  1488. [WIFI1_RADIO_WARM_RESET] = { 0x20008, 3 },
  1489. [WIFI1_RADIO_COLD_RESET] = { 0x20008, 2 },
  1490. [WIFI1_CORE_WARM_RESET] = { 0x20008, 1 },
  1491. [WIFI1_CORE_COLD_RESET] = { 0x20008, 0 },
  1492. [USB3_UNIPHY_PHY_ARES] = { 0x1e038, 5 },
  1493. [USB3_HSPHY_POR_ARES] = { 0x1e038, 4 },
  1494. [USB3_HSPHY_S_ARES] = { 0x1e038, 2 },
  1495. [USB2_HSPHY_POR_ARES] = { 0x1e01c, 4 },
  1496. [USB2_HSPHY_S_ARES] = { 0x1e01c, 2 },
  1497. [PCIE_PHY_AHB_ARES] = { 0x1d010, 11 },
  1498. [PCIE_AHB_ARES] = { 0x1d010, 10 },
  1499. [PCIE_PWR_ARES] = { 0x1d010, 9 },
  1500. [PCIE_PIPE_STICKY_ARES] = { 0x1d010, 8 },
  1501. [PCIE_AXI_M_STICKY_ARES] = { 0x1d010, 7 },
  1502. [PCIE_PHY_ARES] = { 0x1d010, 6 },
  1503. [PCIE_PARF_XPU_ARES] = { 0x1d010, 5 },
  1504. [PCIE_AXI_S_XPU_ARES] = { 0x1d010, 4 },
  1505. [PCIE_AXI_M_VMIDMT_ARES] = { 0x1d010, 3 },
  1506. [PCIE_PIPE_ARES] = { 0x1d010, 2 },
  1507. [PCIE_AXI_S_ARES] = { 0x1d010, 1 },
  1508. [PCIE_AXI_M_ARES] = { 0x1d010, 0 },
  1509. [ESS_RESET] = { 0x12008, 0},
  1510. [GCC_BLSP1_BCR] = {0x01000, 0},
  1511. [GCC_BLSP1_QUP1_BCR] = {0x02000, 0},
  1512. [GCC_BLSP1_UART1_BCR] = {0x02038, 0},
  1513. [GCC_BLSP1_QUP2_BCR] = {0x03008, 0},
  1514. [GCC_BLSP1_UART2_BCR] = {0x03028, 0},
  1515. [GCC_BIMC_BCR] = {0x04000, 0},
  1516. [GCC_TLMM_BCR] = {0x05000, 0},
  1517. [GCC_IMEM_BCR] = {0x0E000, 0},
  1518. [GCC_ESS_BCR] = {0x12008, 0},
  1519. [GCC_PRNG_BCR] = {0x13000, 0},
  1520. [GCC_BOOT_ROM_BCR] = {0x13008, 0},
  1521. [GCC_CRYPTO_BCR] = {0x16000, 0},
  1522. [GCC_SDCC1_BCR] = {0x18000, 0},
  1523. [GCC_SEC_CTRL_BCR] = {0x1A000, 0},
  1524. [GCC_AUDIO_BCR] = {0x1B008, 0},
  1525. [GCC_QPIC_BCR] = {0x1C000, 0},
  1526. [GCC_PCIE_BCR] = {0x1D000, 0},
  1527. [GCC_USB2_BCR] = {0x1E008, 0},
  1528. [GCC_USB2_PHY_BCR] = {0x1E018, 0},
  1529. [GCC_USB3_BCR] = {0x1E024, 0},
  1530. [GCC_USB3_PHY_BCR] = {0x1E034, 0},
  1531. [GCC_SYSTEM_NOC_BCR] = {0x21000, 0},
  1532. [GCC_PCNOC_BCR] = {0x2102C, 0},
  1533. [GCC_DCD_BCR] = {0x21038, 0},
  1534. [GCC_SNOC_BUS_TIMEOUT0_BCR] = {0x21064, 0},
  1535. [GCC_SNOC_BUS_TIMEOUT1_BCR] = {0x2106C, 0},
  1536. [GCC_SNOC_BUS_TIMEOUT2_BCR] = {0x21074, 0},
  1537. [GCC_SNOC_BUS_TIMEOUT3_BCR] = {0x2107C, 0},
  1538. [GCC_PCNOC_BUS_TIMEOUT0_BCR] = {0x21084, 0},
  1539. [GCC_PCNOC_BUS_TIMEOUT1_BCR] = {0x2108C, 0},
  1540. [GCC_PCNOC_BUS_TIMEOUT2_BCR] = {0x21094, 0},
  1541. [GCC_PCNOC_BUS_TIMEOUT3_BCR] = {0x2109C, 0},
  1542. [GCC_PCNOC_BUS_TIMEOUT4_BCR] = {0x210A4, 0},
  1543. [GCC_PCNOC_BUS_TIMEOUT5_BCR] = {0x210AC, 0},
  1544. [GCC_PCNOC_BUS_TIMEOUT6_BCR] = {0x210B4, 0},
  1545. [GCC_PCNOC_BUS_TIMEOUT7_BCR] = {0x210BC, 0},
  1546. [GCC_PCNOC_BUS_TIMEOUT8_BCR] = {0x210C4, 0},
  1547. [GCC_PCNOC_BUS_TIMEOUT9_BCR] = {0x210CC, 0},
  1548. [GCC_TCSR_BCR] = {0x22000, 0},
  1549. [GCC_MPM_BCR] = {0x24000, 0},
  1550. [GCC_SPDM_BCR] = {0x25000, 0},
  1551. [ESS_MAC1_ARES] = {0x1200C, 0},
  1552. [ESS_MAC2_ARES] = {0x1200C, 1},
  1553. [ESS_MAC3_ARES] = {0x1200C, 2},
  1554. [ESS_MAC4_ARES] = {0x1200C, 3},
  1555. [ESS_MAC5_ARES] = {0x1200C, 4},
  1556. [ESS_PSGMII_ARES] = {0x1200C, 5},
  1557. };
  1558. static const struct regmap_config gcc_ipq4019_regmap_config = {
  1559. .reg_bits = 32,
  1560. .reg_stride = 4,
  1561. .val_bits = 32,
  1562. .max_register = 0x2ffff,
  1563. .fast_io = true,
  1564. };
  1565. static const struct qcom_cc_desc gcc_ipq4019_desc = {
  1566. .config = &gcc_ipq4019_regmap_config,
  1567. .clks = gcc_ipq4019_clocks,
  1568. .num_clks = ARRAY_SIZE(gcc_ipq4019_clocks),
  1569. .resets = gcc_ipq4019_resets,
  1570. .num_resets = ARRAY_SIZE(gcc_ipq4019_resets),
  1571. };
  1572. static const struct of_device_id gcc_ipq4019_match_table[] = {
  1573. { .compatible = "qcom,gcc-ipq4019" },
  1574. { }
  1575. };
  1576. MODULE_DEVICE_TABLE(of, gcc_ipq4019_match_table);
  1577. static int
  1578. gcc_ipq4019_cpu_clk_notifier_fn(struct notifier_block *nb,
  1579. unsigned long action, void *data)
  1580. {
  1581. int err = 0;
  1582. if (action == PRE_RATE_CHANGE)
  1583. err = clk_rcg2_ops.set_parent(&apps_clk_src.clkr.hw,
  1584. gcc_ipq4019_cpu_safe_parent);
  1585. return notifier_from_errno(err);
  1586. }
  1587. static struct notifier_block gcc_ipq4019_cpu_clk_notifier = {
  1588. .notifier_call = gcc_ipq4019_cpu_clk_notifier_fn,
  1589. };
  1590. static int gcc_ipq4019_probe(struct platform_device *pdev)
  1591. {
  1592. int err;
  1593. err = qcom_cc_probe(pdev, &gcc_ipq4019_desc);
  1594. if (err)
  1595. return err;
  1596. return devm_clk_notifier_register(&pdev->dev, apps_clk_src.clkr.hw.clk,
  1597. &gcc_ipq4019_cpu_clk_notifier);
  1598. }
  1599. static struct platform_driver gcc_ipq4019_driver = {
  1600. .probe = gcc_ipq4019_probe,
  1601. .driver = {
  1602. .name = "qcom,gcc-ipq4019",
  1603. .of_match_table = gcc_ipq4019_match_table,
  1604. },
  1605. };
  1606. static int __init gcc_ipq4019_init(void)
  1607. {
  1608. return platform_driver_register(&gcc_ipq4019_driver);
  1609. }
  1610. core_initcall(gcc_ipq4019_init);
  1611. static void __exit gcc_ipq4019_exit(void)
  1612. {
  1613. platform_driver_unregister(&gcc_ipq4019_driver);
  1614. }
  1615. module_exit(gcc_ipq4019_exit);
  1616. MODULE_ALIAS("platform:gcc-ipq4019");
  1617. MODULE_LICENSE("GPL v2");
  1618. MODULE_DESCRIPTION("QCOM GCC IPQ4019 driver");