gcc-ipq4019.c 43 KB

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