gcc-ipq4019.c 45 KB

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