gcc-ipq4019.c 43 KB

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