gcc-ipq4019.c 42 KB

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