dispcc-sm8250.c 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2018-2020, 2022, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/clk-provider.h>
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/regmap.h>
  10. #include <linux/reset-controller.h>
  11. #include <linux/pm_runtime.h>
  12. #include <dt-bindings/clock/qcom,dispcc-sm8250.h>
  13. #include "clk-alpha-pll.h"
  14. #include "clk-branch.h"
  15. #include "clk-rcg.h"
  16. #include "clk-regmap-divider.h"
  17. #include "common.h"
  18. #include "gdsc.h"
  19. #include "reset.h"
  20. #include "clk-pm.h"
  21. #include "vdd-level.h"
  22. static DEFINE_VDD_REGULATORS(vdd_mm, VDD_HIGH + 1, 1, vdd_corner);
  23. static struct clk_vdd_class *disp_cc_sm8250_regulators[] = {
  24. &vdd_mm,
  25. };
  26. enum {
  27. P_BI_TCXO,
  28. P_DISP_CC_PLL0_OUT_MAIN,
  29. P_DISP_CC_PLL1_OUT_EVEN,
  30. P_DISP_CC_PLL1_OUT_MAIN,
  31. P_DP_PHY_PLL_LINK_CLK,
  32. P_DP_PHY_PLL_VCO_DIV_CLK,
  33. P_DPTX1_PHY_PLL_LINK_CLK,
  34. P_DPTX1_PHY_PLL_VCO_DIV_CLK,
  35. P_DPTX2_PHY_PLL_LINK_CLK,
  36. P_DPTX2_PHY_PLL_VCO_DIV_CLK,
  37. P_DSI0_PHY_PLL_OUT_BYTECLK,
  38. P_DSI0_PHY_PLL_OUT_DSICLK,
  39. P_DSI1_PHY_PLL_OUT_BYTECLK,
  40. P_DSI1_PHY_PLL_OUT_DSICLK,
  41. P_EDP_PHY_PLL_LINK_CLK,
  42. P_EDP_PHY_PLL_VCO_DIV_CLK,
  43. P_SLEEP_CLK,
  44. };
  45. static const struct pll_vco lucid_vco[] = {
  46. { 249600000, 2000000000, 0 },
  47. };
  48. static struct pll_vco lucid_5lpe_vco[] = {
  49. { 249600000, 1750000000, 0 },
  50. };
  51. static struct alpha_pll_config disp_cc_pll0_config = {
  52. .l = 0x47,
  53. .cal_l = 0x44,
  54. .alpha = 0xE000,
  55. .config_ctl_val = 0x20485699,
  56. .config_ctl_hi_val = 0x00002261,
  57. .config_ctl_hi1_val = 0x329A699C,
  58. .user_ctl_val = 0x00000000,
  59. .user_ctl_hi_val = 0x00000805,
  60. .user_ctl_hi1_val = 0x00000000,
  61. };
  62. static struct clk_init_data disp_cc_pll0_init = {
  63. .name = "disp_cc_pll0",
  64. .parent_data = &(const struct clk_parent_data){
  65. .fw_name = "bi_tcxo",
  66. },
  67. .num_parents = 1,
  68. .ops = &clk_alpha_pll_lucid_ops,
  69. };
  70. static struct clk_alpha_pll disp_cc_pll0 = {
  71. .offset = 0x0,
  72. .vco_table = lucid_vco,
  73. .num_vco = ARRAY_SIZE(lucid_vco),
  74. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  75. .config = &disp_cc_pll0_config,
  76. .clkr.hw.init = &disp_cc_pll0_init,
  77. .clkr.vdd_data = {
  78. .vdd_class = &vdd_mm,
  79. .num_rate_max = VDD_NUM,
  80. .rate_max = (unsigned long[VDD_NUM]) {
  81. [VDD_MIN] = 615000000,
  82. [VDD_LOW] = 1066000000,
  83. [VDD_LOW_L1] = 1500000000,
  84. [VDD_NOMINAL] = 1750000000,
  85. [VDD_HIGH] = 2000000000},
  86. },
  87. };
  88. static struct alpha_pll_config disp_cc_pll1_config = {
  89. .l = 0x1F,
  90. .cal_l = 0x44,
  91. .alpha = 0x4000,
  92. .config_ctl_val = 0x20485699,
  93. .config_ctl_hi_val = 0x00002261,
  94. .config_ctl_hi1_val = 0x329A699C,
  95. .user_ctl_val = 0x00000000,
  96. .user_ctl_hi_val = 0x00000805,
  97. .user_ctl_hi1_val = 0x00000000,
  98. };
  99. static struct clk_init_data disp_cc_pll1_init = {
  100. .name = "disp_cc_pll1",
  101. .parent_data = &(const struct clk_parent_data){
  102. .fw_name = "bi_tcxo",
  103. },
  104. .num_parents = 1,
  105. .ops = &clk_alpha_pll_lucid_ops,
  106. };
  107. static struct clk_alpha_pll disp_cc_pll1 = {
  108. .offset = 0x1000,
  109. .vco_table = lucid_vco,
  110. .num_vco = ARRAY_SIZE(lucid_vco),
  111. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  112. .config = &disp_cc_pll1_config,
  113. .clkr.hw.init = &disp_cc_pll1_init,
  114. .clkr.vdd_data = {
  115. .vdd_class = &vdd_mm,
  116. .num_rate_max = VDD_NUM,
  117. .rate_max = (unsigned long[VDD_NUM]) {
  118. [VDD_MIN] = 615000000,
  119. [VDD_LOW] = 1066000000,
  120. [VDD_LOW_L1] = 1500000000,
  121. [VDD_NOMINAL] = 1750000000,
  122. [VDD_HIGH] = 2000000000},
  123. },
  124. };
  125. static const struct parent_map disp_cc_parent_map_0[] = {
  126. { P_BI_TCXO, 0 },
  127. { P_DP_PHY_PLL_LINK_CLK, 1 },
  128. { P_DP_PHY_PLL_VCO_DIV_CLK, 2 },
  129. { P_DPTX1_PHY_PLL_LINK_CLK, 3 },
  130. { P_DPTX1_PHY_PLL_VCO_DIV_CLK, 4 },
  131. { P_DPTX2_PHY_PLL_LINK_CLK, 5 },
  132. { P_DPTX2_PHY_PLL_VCO_DIV_CLK, 6 },
  133. };
  134. static const struct clk_parent_data disp_cc_parent_data_0[] = {
  135. { .fw_name = "bi_tcxo" },
  136. { .fw_name = "dp_phy_pll_link_clk", .name = "dp_phy_pll_link_clk" },
  137. { .fw_name = "dp_phy_pll_vco_div_clk", .name = "dp_phy_pll_vco_div_clk" },
  138. { .fw_name = "dptx1_phy_pll_link_clk", .name = "dptx1_phy_pll_link_clk" },
  139. { .fw_name = "dptx1_phy_pll_vco_div_clk", .name = "dptx1_phy_pll_vco_div_clk" },
  140. { .fw_name = "dptx2_phy_pll_link_clk", .name = "dptx2_phy_pll_link_clk" },
  141. { .fw_name = "dptx2_phy_pll_vco_div_clk", .name = "dptx2_phy_pll_vco_div_clk" },
  142. };
  143. static const struct parent_map disp_cc_parent_map_1[] = {
  144. { P_BI_TCXO, 0 },
  145. };
  146. static const struct clk_parent_data disp_cc_parent_data_1[] = {
  147. { .fw_name = "bi_tcxo" },
  148. };
  149. static const struct clk_parent_data disp_cc_parent_data_1_ao[] = {
  150. { .fw_name = "bi_tcxo_ao" },
  151. };
  152. static const struct parent_map disp_cc_parent_map_2[] = {
  153. { P_BI_TCXO, 0 },
  154. { P_DSI0_PHY_PLL_OUT_BYTECLK, 1 },
  155. { P_DSI1_PHY_PLL_OUT_BYTECLK, 2 },
  156. };
  157. static const struct clk_parent_data disp_cc_parent_data_2[] = {
  158. { .fw_name = "bi_tcxo" },
  159. { .fw_name = "dsi0_phy_pll_out_byteclk", .name = "dsi0_phy_pll_out_byteclk" },
  160. { .fw_name = "dsi1_phy_pll_out_byteclk", .name = "dsi1_phy_pll_out_byteclk" },
  161. };
  162. static const struct parent_map disp_cc_parent_map_3[] = {
  163. { P_BI_TCXO, 0 },
  164. { P_DISP_CC_PLL1_OUT_MAIN, 4 },
  165. { P_DISP_CC_PLL1_OUT_EVEN, 5 },
  166. };
  167. static const struct clk_parent_data disp_cc_parent_data_3[] = {
  168. { .fw_name = "bi_tcxo" },
  169. { .hw = &disp_cc_pll1.clkr.hw },
  170. { .hw = &disp_cc_pll1.clkr.hw },
  171. };
  172. static const struct parent_map disp_cc_parent_map_4[] = {
  173. { P_BI_TCXO, 0 },
  174. { P_EDP_PHY_PLL_LINK_CLK, 1 },
  175. { P_EDP_PHY_PLL_VCO_DIV_CLK, 2},
  176. };
  177. static const struct clk_parent_data disp_cc_parent_data_4[] = {
  178. { .fw_name = "bi_tcxo" },
  179. { .fw_name = "edp_phy_pll_link_clk", .name = "edp_phy_pll_link_clk" },
  180. { .fw_name = "edp_phy_pll_vco_div_clk", .name = "edp_phy_pll_vco_div_clk" },
  181. };
  182. static const struct parent_map disp_cc_parent_map_4_sc8180x[] = {
  183. { P_BI_TCXO, 0 },
  184. { P_EDP_PHY_PLL_LINK_CLK, 1 },
  185. { P_EDP_PHY_PLL_VCO_DIV_CLK, 2 },
  186. { P_DP_PHY_PLL_VCO_DIV_CLK, 3 },
  187. { P_DPTX1_PHY_PLL_VCO_DIV_CLK, 4 },
  188. { P_DPTX2_PHY_PLL_VCO_DIV_CLK, 6 },
  189. };
  190. static const struct clk_parent_data disp_cc_parent_data_4_sc8180x[] = {
  191. { .fw_name = "bi_tcxo" },
  192. { .fw_name = "edp_phy_pll_link_clk", .name = "edp_phy_pll_link_clk" },
  193. { .fw_name = "edp_phy_pll_vco_div_clk", .name = "edp_phy_pll_vco_div_clk" },
  194. { .fw_name = "dp_phy_pll_vco_div_clk", .name = "dp_phy_pll_vco_div_clk" },
  195. { .fw_name = "dptx1_phy_pll_vco_div_clk", .name = "dptx1_phy_pll_vco_div_clk" },
  196. { .fw_name = "dptx2_phy_pll_vco_div_clk", .name = "dptx2_phy_pll_vco_div_clk" },
  197. };
  198. static const struct parent_map disp_cc_parent_map_5[] = {
  199. { P_BI_TCXO, 0 },
  200. { P_DISP_CC_PLL0_OUT_MAIN, 1 },
  201. { P_DISP_CC_PLL1_OUT_MAIN, 4 },
  202. };
  203. static const struct clk_parent_data disp_cc_parent_data_5[] = {
  204. { .fw_name = "bi_tcxo" },
  205. { .hw = &disp_cc_pll0.clkr.hw },
  206. { .hw = &disp_cc_pll1.clkr.hw },
  207. };
  208. static const struct parent_map disp_cc_parent_map_6[] = {
  209. { P_BI_TCXO, 0 },
  210. { P_DSI0_PHY_PLL_OUT_DSICLK, 1 },
  211. { P_DSI1_PHY_PLL_OUT_DSICLK, 2 },
  212. };
  213. static const struct clk_parent_data disp_cc_parent_data_6[] = {
  214. { .fw_name = "bi_tcxo" },
  215. { .fw_name = "dsi0_phy_pll_out_dsiclk", .name = "dsi0_phy_pll_out_dsiclk" },
  216. { .fw_name = "dsi1_phy_pll_out_dsiclk", .name = "dsi1_phy_pll_out_dsiclk" },
  217. };
  218. static const struct parent_map disp_cc_parent_map_7[] = {
  219. { P_SLEEP_CLK, 0 },
  220. };
  221. static const struct clk_parent_data disp_cc_parent_data_7[] = {
  222. { .fw_name = "sleep_clk", .name = "sleep_clk" },
  223. };
  224. static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = {
  225. F(19200000, P_BI_TCXO, 1, 0, 0),
  226. F(37500000, P_DISP_CC_PLL1_OUT_MAIN, 16, 0, 0),
  227. F(75000000, P_DISP_CC_PLL1_OUT_MAIN, 8, 0, 0),
  228. { }
  229. };
  230. static struct clk_rcg2 disp_cc_mdss_ahb_clk_src = {
  231. .cmd_rcgr = 0x22bc,
  232. .mnd_width = 0,
  233. .hid_width = 5,
  234. .parent_map = disp_cc_parent_map_3,
  235. .freq_tbl = ftbl_disp_cc_mdss_ahb_clk_src,
  236. .enable_safe_config = true,
  237. .clkr.hw.init = &(const struct clk_init_data){
  238. .name = "disp_cc_mdss_ahb_clk_src",
  239. .parent_data = disp_cc_parent_data_3,
  240. .num_parents = ARRAY_SIZE(disp_cc_parent_data_3),
  241. .flags = CLK_SET_RATE_PARENT,
  242. .ops = &clk_rcg2_ops,
  243. },
  244. .clkr.vdd_data = {
  245. .vdd_class = &vdd_mm,
  246. .num_rate_max = VDD_NUM,
  247. .rate_max = (unsigned long[VDD_NUM]) {
  248. [VDD_MIN] = 19200000,
  249. [VDD_LOW] = 37500000,
  250. [VDD_NOMINAL] = 75000000},
  251. },
  252. };
  253. static const struct freq_tbl ftbl_disp_cc_mdss_byte0_clk_src[] = {
  254. F(19200000, P_BI_TCXO, 1, 0, 0),
  255. { }
  256. };
  257. static struct clk_rcg2 disp_cc_mdss_byte0_clk_src = {
  258. .cmd_rcgr = 0x2110,
  259. .mnd_width = 0,
  260. .hid_width = 5,
  261. .parent_map = disp_cc_parent_map_2,
  262. .clkr.hw.init = &(const struct clk_init_data){
  263. .name = "disp_cc_mdss_byte0_clk_src",
  264. .parent_data = disp_cc_parent_data_2,
  265. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  266. .flags = CLK_SET_RATE_PARENT,
  267. .ops = &clk_byte2_ops,
  268. },
  269. .clkr.vdd_data = {
  270. .vdd_class = &vdd_mm,
  271. .num_rate_max = VDD_NUM,
  272. .rate_max = (unsigned long[VDD_NUM]) {
  273. [VDD_MIN] = 19200000,
  274. [VDD_LOWER] = 187500000,
  275. [VDD_LOW] = 300000000,
  276. [VDD_LOW_L1] = 358000000},
  277. },
  278. };
  279. static struct clk_rcg2 disp_cc_mdss_byte1_clk_src = {
  280. .cmd_rcgr = 0x212c,
  281. .mnd_width = 0,
  282. .hid_width = 5,
  283. .parent_map = disp_cc_parent_map_2,
  284. .clkr.hw.init = &(const struct clk_init_data){
  285. .name = "disp_cc_mdss_byte1_clk_src",
  286. .parent_data = disp_cc_parent_data_2,
  287. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  288. .flags = CLK_SET_RATE_PARENT,
  289. .ops = &clk_byte2_ops,
  290. },
  291. .clkr.vdd_data = {
  292. .vdd_class = &vdd_mm,
  293. .num_rate_max = VDD_NUM,
  294. .rate_max = (unsigned long[VDD_NUM]) {
  295. [VDD_MIN] = 19200000,
  296. [VDD_LOWER] = 187500000,
  297. [VDD_LOW] = 300000000,
  298. [VDD_LOW_L1] = 358000000},
  299. },
  300. };
  301. static struct clk_rcg2 disp_cc_mdss_dp_aux1_clk_src = {
  302. .cmd_rcgr = 0x2240,
  303. .mnd_width = 0,
  304. .hid_width = 5,
  305. .parent_map = disp_cc_parent_map_1,
  306. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  307. .clkr.hw.init = &(const struct clk_init_data){
  308. .name = "disp_cc_mdss_dp_aux1_clk_src",
  309. .parent_data = disp_cc_parent_data_1,
  310. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  311. .flags = CLK_SET_RATE_PARENT,
  312. .ops = &clk_rcg2_ops,
  313. },
  314. .clkr.vdd_data = {
  315. .vdd_class = &vdd_mm,
  316. .num_rate_max = VDD_NUM,
  317. .rate_max = (unsigned long[VDD_NUM]) {
  318. [VDD_MIN] = 19200000},
  319. },
  320. };
  321. static struct clk_rcg2 disp_cc_mdss_dp_aux_clk_src = {
  322. .cmd_rcgr = 0x21dc,
  323. .mnd_width = 0,
  324. .hid_width = 5,
  325. .parent_map = disp_cc_parent_map_1,
  326. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  327. .clkr.hw.init = &(const struct clk_init_data){
  328. .name = "disp_cc_mdss_dp_aux_clk_src",
  329. .parent_data = disp_cc_parent_data_1,
  330. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  331. .flags = CLK_SET_RATE_PARENT,
  332. .ops = &clk_rcg2_ops,
  333. },
  334. .clkr.vdd_data = {
  335. .vdd_class = &vdd_mm,
  336. .num_rate_max = VDD_NUM,
  337. .rate_max = (unsigned long[VDD_NUM]) {
  338. [VDD_MIN] = 19200000},
  339. },
  340. };
  341. static const struct freq_tbl ftbl_disp_cc_mdss_dp_crypto1_clk_src[] = {
  342. F(108000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  343. F(180000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  344. F(360000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  345. F(540000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  346. { }
  347. };
  348. static const struct freq_tbl
  349. ftbl_disp_cc_mdss_dp_crypto1_clk_src_sc8180x[] = {
  350. F(108000, P_DPTX1_PHY_PLL_LINK_CLK, 3, 0, 0),
  351. F(180000, P_DPTX1_PHY_PLL_LINK_CLK, 3, 0, 0),
  352. F(360000, P_DPTX1_PHY_PLL_LINK_CLK, 3, 0, 0),
  353. F(540000, P_DPTX1_PHY_PLL_LINK_CLK, 3, 0, 0),
  354. { }
  355. };
  356. static struct clk_rcg2 disp_cc_mdss_dp_crypto1_clk_src = {
  357. .cmd_rcgr = 0x2228,
  358. .mnd_width = 0,
  359. .hid_width = 5,
  360. .parent_map = disp_cc_parent_map_0,
  361. .freq_tbl = ftbl_disp_cc_mdss_dp_crypto1_clk_src,
  362. .clkr.hw.init = &(struct clk_init_data){
  363. .name = "disp_cc_mdss_dp_crypto1_clk_src",
  364. .parent_data = disp_cc_parent_data_0,
  365. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  366. .flags = CLK_SET_RATE_PARENT,
  367. .ops = &clk_rcg2_ops,
  368. },
  369. .clkr.vdd_data = {
  370. .vdd_class = &vdd_mm,
  371. .num_rate_max = VDD_NUM,
  372. .rate_max = (unsigned long[VDD_NUM]) {
  373. [VDD_MIN] = 12800,
  374. [VDD_LOWER] = 180000,
  375. [VDD_LOW_L1] = 360000,
  376. [VDD_NOMINAL] = 540000},
  377. },
  378. };
  379. static const struct freq_tbl
  380. ftbl_disp_cc_mdss_dp_crypto_clk_src_sc8180x[] = {
  381. F(108000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  382. F(180000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  383. F(360000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  384. F(540000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0),
  385. { }
  386. };
  387. static struct clk_rcg2 disp_cc_mdss_dp_crypto_clk_src = {
  388. .cmd_rcgr = 0x2194,
  389. .mnd_width = 0,
  390. .hid_width = 5,
  391. .parent_map = disp_cc_parent_map_0,
  392. .freq_tbl = ftbl_disp_cc_mdss_dp_crypto1_clk_src,
  393. .clkr.hw.init = &(struct clk_init_data){
  394. .name = "disp_cc_mdss_dp_crypto_clk_src",
  395. .parent_data = disp_cc_parent_data_0,
  396. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  397. .flags = CLK_SET_RATE_PARENT,
  398. .ops = &clk_rcg2_ops,
  399. },
  400. .clkr.vdd_data = {
  401. .vdd_class = &vdd_mm,
  402. .num_rate_max = VDD_NUM,
  403. .rate_max = (unsigned long[VDD_NUM]) {
  404. [VDD_MIN] = 12800,
  405. [VDD_LOWER] = 180000,
  406. [VDD_LOW_L1] = 360000,
  407. [VDD_NOMINAL] = 540000},
  408. },
  409. };
  410. static struct clk_rcg2 disp_cc_mdss_dp_link1_clk_src = {
  411. .cmd_rcgr = 0x220c,
  412. .mnd_width = 0,
  413. .hid_width = 5,
  414. .parent_map = disp_cc_parent_map_0,
  415. .clkr.hw.init = &(const struct clk_init_data){
  416. .name = "disp_cc_mdss_dp_link1_clk_src",
  417. .parent_data = disp_cc_parent_data_0,
  418. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  419. .ops = &clk_byte2_ops,
  420. },
  421. .clkr.vdd_data = {
  422. .vdd_class = &vdd_mm,
  423. .num_rate_max = VDD_NUM,
  424. .rate_max = (unsigned long[VDD_NUM]) {
  425. [VDD_MIN] = 19200,
  426. [VDD_LOWER] = 270000,
  427. [VDD_LOW_L1] = 540000,
  428. [VDD_NOMINAL] = 810000},
  429. },
  430. };
  431. static struct clk_rcg2 disp_cc_mdss_dp_link_clk_src = {
  432. .cmd_rcgr = 0x2178,
  433. .mnd_width = 0,
  434. .hid_width = 5,
  435. .parent_map = disp_cc_parent_map_0,
  436. .clkr.hw.init = &(const struct clk_init_data){
  437. .name = "disp_cc_mdss_dp_link_clk_src",
  438. .parent_data = disp_cc_parent_data_0,
  439. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  440. .ops = &clk_byte2_ops,
  441. },
  442. .clkr.vdd_data = {
  443. .vdd_class = &vdd_mm,
  444. .num_rate_max = VDD_NUM,
  445. .rate_max = (unsigned long[VDD_NUM]) {
  446. [VDD_MIN] = 19200,
  447. [VDD_LOWER] = 270000,
  448. [VDD_LOW_L1] = 540000,
  449. [VDD_NOMINAL] = 810000},
  450. },
  451. };
  452. static struct clk_rcg2 disp_cc_mdss_dp_pixel1_clk_src = {
  453. .cmd_rcgr = 0x21c4,
  454. .mnd_width = 16,
  455. .hid_width = 5,
  456. .parent_map = disp_cc_parent_map_0,
  457. .clkr.hw.init = &(const struct clk_init_data){
  458. .name = "disp_cc_mdss_dp_pixel1_clk_src",
  459. .parent_data = disp_cc_parent_data_0,
  460. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  461. .ops = &clk_dp_ops,
  462. },
  463. .clkr.vdd_data = {
  464. .vdd_class = &vdd_mm,
  465. .num_rate_max = VDD_NUM,
  466. .rate_max = (unsigned long[VDD_NUM]) {
  467. [VDD_MIN] = 19200,
  468. [VDD_LOWER] = 337500,
  469. [VDD_NOMINAL] = 675000},
  470. },
  471. };
  472. static struct clk_rcg2 disp_cc_mdss_dp_pixel2_clk_src = {
  473. .cmd_rcgr = 0x21f4,
  474. .mnd_width = 16,
  475. .hid_width = 5,
  476. .parent_map = disp_cc_parent_map_0,
  477. .clkr.hw.init = &(const struct clk_init_data){
  478. .name = "disp_cc_mdss_dp_pixel2_clk_src",
  479. .parent_data = disp_cc_parent_data_0,
  480. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  481. .flags = CLK_SET_RATE_PARENT,
  482. .ops = &clk_dp_ops,
  483. },
  484. .clkr.vdd_data = {
  485. .vdd_class = &vdd_mm,
  486. .num_rate_max = VDD_NUM,
  487. .rate_max = (unsigned long[VDD_NUM]) {
  488. [VDD_MIN] = 19200,
  489. [VDD_LOWER] = 337500,
  490. [VDD_NOMINAL] = 675000},
  491. },
  492. };
  493. static struct clk_rcg2 disp_cc_mdss_dp_pixel_clk_src = {
  494. .cmd_rcgr = 0x21ac,
  495. .mnd_width = 16,
  496. .hid_width = 5,
  497. .parent_map = disp_cc_parent_map_0,
  498. .clkr.hw.init = &(const struct clk_init_data){
  499. .name = "disp_cc_mdss_dp_pixel_clk_src",
  500. .parent_data = disp_cc_parent_data_0,
  501. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  502. .ops = &clk_dp_ops,
  503. },
  504. .clkr.vdd_data = {
  505. .vdd_class = &vdd_mm,
  506. .num_rate_max = VDD_NUM,
  507. .rate_max = (unsigned long[VDD_NUM]) {
  508. [VDD_MIN] = 19200,
  509. [VDD_LOWER] = 337500,
  510. [VDD_NOMINAL] = 675000},
  511. },
  512. };
  513. static struct clk_rcg2 disp_cc_mdss_edp_aux_clk_src = {
  514. .cmd_rcgr = 0x228c,
  515. .mnd_width = 0,
  516. .hid_width = 5,
  517. .parent_map = disp_cc_parent_map_1,
  518. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  519. .clkr.hw.init = &(const struct clk_init_data){
  520. .name = "disp_cc_mdss_edp_aux_clk_src",
  521. .parent_data = disp_cc_parent_data_1,
  522. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  523. .flags = CLK_SET_RATE_PARENT,
  524. .ops = &clk_rcg2_ops,
  525. },
  526. .clkr.vdd_data = {
  527. .vdd_class = &vdd_mm,
  528. .num_rate_max = VDD_NUM,
  529. .rate_max = (unsigned long[VDD_NUM]) {
  530. [VDD_MIN] = 19200000},
  531. },
  532. };
  533. static struct clk_rcg2 disp_cc_mdss_edp_gtc_clk_src = {
  534. .cmd_rcgr = 0x22a4,
  535. .mnd_width = 0,
  536. .hid_width = 5,
  537. .parent_map = disp_cc_parent_map_3,
  538. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  539. .clkr.hw.init = &(const struct clk_init_data){
  540. .name = "disp_cc_mdss_edp_gtc_clk_src",
  541. .parent_data = disp_cc_parent_data_3,
  542. .num_parents = ARRAY_SIZE(disp_cc_parent_data_3),
  543. .flags = CLK_SET_RATE_PARENT,
  544. .ops = &clk_rcg2_ops,
  545. },
  546. .clkr.vdd_data = {
  547. .vdd_class = &vdd_mm,
  548. .num_rate_max = VDD_NUM,
  549. .rate_max = (unsigned long[VDD_NUM]) {
  550. [VDD_MIN] = 19200000},
  551. },
  552. };
  553. static struct clk_rcg2 disp_cc_mdss_edp_link_clk_src = {
  554. .cmd_rcgr = 0x2270,
  555. .mnd_width = 0,
  556. .hid_width = 5,
  557. .parent_map = disp_cc_parent_map_4,
  558. .clkr.hw.init = &(const struct clk_init_data){
  559. .name = "disp_cc_mdss_edp_link_clk_src",
  560. .parent_data = disp_cc_parent_data_4,
  561. .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
  562. .flags = CLK_SET_RATE_PARENT,
  563. .ops = &clk_byte2_ops,
  564. },
  565. .clkr.vdd_data = {
  566. .vdd_class = &vdd_mm,
  567. .num_rate_max = VDD_NUM,
  568. .rate_max = (unsigned long[VDD_NUM]) {
  569. [VDD_MIN] = 19200000,
  570. [VDD_LOWER] = 270000000,
  571. [VDD_LOW] = 594000000,
  572. [VDD_NOMINAL] = 810000000},
  573. },
  574. };
  575. static struct clk_rcg2 disp_cc_mdss_edp_pixel_clk_src = {
  576. .cmd_rcgr = 0x2258,
  577. .mnd_width = 16,
  578. .hid_width = 5,
  579. .parent_map = disp_cc_parent_map_4,
  580. .clkr.hw.init = &(const struct clk_init_data){
  581. .name = "disp_cc_mdss_edp_pixel_clk_src",
  582. .parent_data = disp_cc_parent_data_4,
  583. .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
  584. .ops = &clk_dp_ops,
  585. },
  586. .clkr.vdd_data = {
  587. .vdd_class = &vdd_mm,
  588. .num_rate_max = VDD_NUM,
  589. .rate_max = (unsigned long[VDD_NUM]) {
  590. [VDD_MIN] = 19200000,
  591. [VDD_LOWER] = 337500000,
  592. [VDD_LOW] = 371250000,
  593. [VDD_NOMINAL] = 675000000},
  594. },
  595. };
  596. static struct clk_init_data disp_cc_mdss_edp_pixel_clk_src_sc8180x = {
  597. .name = "disp_cc_mdss_edp_pixel_clk_src",
  598. .parent_data = disp_cc_parent_data_4_sc8180x,
  599. .num_parents = ARRAY_SIZE(disp_cc_parent_data_4_sc8180x),
  600. .ops = &clk_dp_ops,
  601. };
  602. static struct clk_branch disp_cc_mdss_dp_crypto1_clk = {
  603. .halt_reg = 0x2064,
  604. .halt_check = BRANCH_HALT,
  605. .clkr = {
  606. .enable_reg = 0x2064,
  607. .enable_mask = BIT(0),
  608. .hw.init = &(struct clk_init_data){
  609. .name = "disp_cc_mdss_dp_crypto1_clk",
  610. .parent_hws = (const struct clk_hw*[]){
  611. &disp_cc_mdss_dp_crypto1_clk_src.clkr.hw,
  612. },
  613. .num_parents = 1,
  614. .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
  615. .ops = &clk_branch2_ops,
  616. },
  617. },
  618. };
  619. static struct clk_branch disp_cc_mdss_dp_crypto_clk = {
  620. .halt_reg = 0x2048,
  621. .halt_check = BRANCH_HALT,
  622. .clkr = {
  623. .enable_reg = 0x2048,
  624. .enable_mask = BIT(0),
  625. .hw.init = &(struct clk_init_data){
  626. .name = "disp_cc_mdss_dp_crypto_clk",
  627. .parent_hws = (const struct clk_hw*[]){
  628. &disp_cc_mdss_dp_crypto_clk_src.clkr.hw,
  629. },
  630. .num_parents = 1,
  631. .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
  632. .ops = &clk_branch2_ops,
  633. },
  634. },
  635. };
  636. static struct clk_branch disp_cc_mdss_edp_aux_clk = {
  637. .halt_reg = 0x2078,
  638. .halt_check = BRANCH_HALT,
  639. .clkr = {
  640. .enable_reg = 0x2078,
  641. .enable_mask = BIT(0),
  642. .hw.init = &(const struct clk_init_data){
  643. .name = "disp_cc_mdss_edp_aux_clk",
  644. .parent_hws = (const struct clk_hw*[]){
  645. &disp_cc_mdss_edp_aux_clk_src.clkr.hw,
  646. },
  647. .num_parents = 1,
  648. .flags = CLK_SET_RATE_PARENT,
  649. .ops = &clk_branch2_ops,
  650. },
  651. },
  652. };
  653. static struct clk_branch disp_cc_mdss_edp_gtc_clk = {
  654. .halt_reg = 0x207c,
  655. .halt_check = BRANCH_HALT,
  656. .clkr = {
  657. .enable_reg = 0x207c,
  658. .enable_mask = BIT(0),
  659. .hw.init = &(const struct clk_init_data){
  660. .name = "disp_cc_mdss_edp_gtc_clk",
  661. .parent_hws = (const struct clk_hw*[]){
  662. &disp_cc_mdss_edp_gtc_clk_src.clkr.hw,
  663. },
  664. .num_parents = 1,
  665. .flags = CLK_SET_RATE_PARENT,
  666. .ops = &clk_branch2_ops,
  667. },
  668. },
  669. };
  670. static struct clk_branch disp_cc_mdss_edp_link_clk = {
  671. .halt_reg = 0x2070,
  672. .halt_check = BRANCH_HALT,
  673. .clkr = {
  674. .enable_reg = 0x2070,
  675. .enable_mask = BIT(0),
  676. .hw.init = &(const struct clk_init_data){
  677. .name = "disp_cc_mdss_edp_link_clk",
  678. .parent_hws = (const struct clk_hw*[]){
  679. &disp_cc_mdss_edp_link_clk_src.clkr.hw,
  680. },
  681. .num_parents = 1,
  682. .flags = CLK_SET_RATE_PARENT,
  683. .ops = &clk_branch2_ops,
  684. },
  685. },
  686. };
  687. static struct clk_regmap_div disp_cc_mdss_edp_link_div_clk_src = {
  688. .reg = 0x2288,
  689. .shift = 0,
  690. .width = 2,
  691. .clkr.hw.init = &(const struct clk_init_data) {
  692. .name = "disp_cc_mdss_edp_link_div_clk_src",
  693. .parent_hws = (const struct clk_hw*[]){
  694. &disp_cc_mdss_edp_link_clk_src.clkr.hw,
  695. },
  696. .num_parents = 1,
  697. .flags = CLK_SET_RATE_PARENT,
  698. .ops = &clk_regmap_div_ro_ops,
  699. },
  700. };
  701. static struct clk_branch disp_cc_mdss_edp_link_intf_clk = {
  702. .halt_reg = 0x2074,
  703. .halt_check = BRANCH_HALT,
  704. .clkr = {
  705. .enable_reg = 0x2074,
  706. .enable_mask = BIT(0),
  707. .hw.init = &(const struct clk_init_data){
  708. .name = "disp_cc_mdss_edp_link_intf_clk",
  709. .parent_hws = (const struct clk_hw*[]){
  710. &disp_cc_mdss_edp_link_div_clk_src.clkr.hw,
  711. },
  712. .num_parents = 1,
  713. .flags = CLK_GET_RATE_NOCACHE,
  714. .ops = &clk_branch2_ops,
  715. },
  716. },
  717. };
  718. static struct clk_branch disp_cc_mdss_edp_pixel_clk = {
  719. .halt_reg = 0x206c,
  720. .halt_check = BRANCH_HALT,
  721. .clkr = {
  722. .enable_reg = 0x206c,
  723. .enable_mask = BIT(0),
  724. .hw.init = &(const struct clk_init_data){
  725. .name = "disp_cc_mdss_edp_pixel_clk",
  726. .parent_hws = (const struct clk_hw*[]){
  727. &disp_cc_mdss_edp_pixel_clk_src.clkr.hw,
  728. },
  729. .num_parents = 1,
  730. .flags = CLK_SET_RATE_PARENT,
  731. .ops = &clk_branch2_ops,
  732. },
  733. },
  734. };
  735. static struct clk_rcg2 disp_cc_mdss_esc0_clk_src = {
  736. .cmd_rcgr = 0x2148,
  737. .mnd_width = 0,
  738. .hid_width = 5,
  739. .parent_map = disp_cc_parent_map_2,
  740. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  741. .clkr.hw.init = &(const struct clk_init_data){
  742. .name = "disp_cc_mdss_esc0_clk_src",
  743. .parent_data = disp_cc_parent_data_2,
  744. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  745. .flags = CLK_SET_RATE_PARENT,
  746. .ops = &clk_rcg2_ops,
  747. },
  748. .clkr.vdd_data = {
  749. .vdd_class = &vdd_mm,
  750. .num_rate_max = VDD_NUM,
  751. .rate_max = (unsigned long[VDD_NUM]) {
  752. [VDD_MIN] = 19200000},
  753. },
  754. };
  755. static struct clk_rcg2 disp_cc_mdss_esc1_clk_src = {
  756. .cmd_rcgr = 0x2160,
  757. .mnd_width = 0,
  758. .hid_width = 5,
  759. .parent_map = disp_cc_parent_map_2,
  760. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  761. .clkr.hw.init = &(const struct clk_init_data){
  762. .name = "disp_cc_mdss_esc1_clk_src",
  763. .parent_data = disp_cc_parent_data_2,
  764. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  765. .flags = CLK_SET_RATE_PARENT,
  766. .ops = &clk_rcg2_ops,
  767. },
  768. .clkr.vdd_data = {
  769. .vdd_class = &vdd_mm,
  770. .num_rate_max = VDD_NUM,
  771. .rate_max = (unsigned long[VDD_NUM]) {
  772. [VDD_MIN] = 19200000},
  773. },
  774. };
  775. static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src[] = {
  776. F(19200000, P_BI_TCXO, 1, 0, 0),
  777. F(85714286, P_DISP_CC_PLL1_OUT_MAIN, 7, 0, 0),
  778. F(100000000, P_DISP_CC_PLL1_OUT_MAIN, 6, 0, 0),
  779. F(150000000, P_DISP_CC_PLL1_OUT_MAIN, 4, 0, 0),
  780. F(200000000, P_DISP_CC_PLL1_OUT_MAIN, 3, 0, 0),
  781. F(300000000, P_DISP_CC_PLL1_OUT_MAIN, 2, 0, 0),
  782. F(345000000, P_DISP_CC_PLL0_OUT_MAIN, 4, 0, 0),
  783. F(460000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  784. { }
  785. };
  786. static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = {
  787. .cmd_rcgr = 0x20c8,
  788. .mnd_width = 0,
  789. .hid_width = 5,
  790. .parent_map = disp_cc_parent_map_5,
  791. .freq_tbl = ftbl_disp_cc_mdss_mdp_clk_src,
  792. .enable_safe_config = true,
  793. .clkr.hw.init = &(const struct clk_init_data){
  794. .name = "disp_cc_mdss_mdp_clk_src",
  795. .parent_data = disp_cc_parent_data_5,
  796. .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
  797. .flags = CLK_SET_RATE_PARENT,
  798. .ops = &clk_rcg2_ops,
  799. },
  800. .clkr.vdd_data = {
  801. .vdd_class = &vdd_mm,
  802. .num_rate_max = VDD_NUM,
  803. .rate_max = (unsigned long[VDD_NUM]) {
  804. [VDD_MIN] = 19200000,
  805. [VDD_LOWER] = 200000000,
  806. [VDD_LOW] = 300000000,
  807. [VDD_LOW_L1] = 345000000,
  808. [VDD_NOMINAL] = 460000000},
  809. },
  810. };
  811. static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = {
  812. .cmd_rcgr = 0x2098,
  813. .mnd_width = 8,
  814. .hid_width = 5,
  815. .parent_map = disp_cc_parent_map_6,
  816. .clkr.hw.init = &(const struct clk_init_data){
  817. .name = "disp_cc_mdss_pclk0_clk_src",
  818. .parent_data = disp_cc_parent_data_6,
  819. .num_parents = ARRAY_SIZE(disp_cc_parent_data_6),
  820. .flags = CLK_SET_RATE_PARENT,
  821. .ops = &clk_pixel_ops,
  822. },
  823. .clkr.vdd_data = {
  824. .vdd_class = &vdd_mm,
  825. .num_rate_max = VDD_NUM,
  826. .rate_max = (unsigned long[VDD_NUM]) {
  827. [VDD_MIN] = 19200000,
  828. [VDD_LOWER] = 300000000,
  829. [VDD_LOW] = 525000000,
  830. [VDD_LOW_L1] = 625000000},
  831. },
  832. };
  833. static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = {
  834. .cmd_rcgr = 0x20b0,
  835. .mnd_width = 8,
  836. .hid_width = 5,
  837. .parent_map = disp_cc_parent_map_6,
  838. .clkr.hw.init = &(const struct clk_init_data){
  839. .name = "disp_cc_mdss_pclk1_clk_src",
  840. .parent_data = disp_cc_parent_data_6,
  841. .num_parents = ARRAY_SIZE(disp_cc_parent_data_6),
  842. .flags = CLK_SET_RATE_PARENT,
  843. .ops = &clk_pixel_ops,
  844. },
  845. .clkr.vdd_data = {
  846. .vdd_class = &vdd_mm,
  847. .num_rate_max = VDD_NUM,
  848. .rate_max = (unsigned long[VDD_NUM]) {
  849. [VDD_MIN] = 19200000,
  850. [VDD_LOWER] = 300000000,
  851. [VDD_LOW] = 525000000,
  852. [VDD_LOW_L1] = 625000000},
  853. },
  854. };
  855. static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src[] = {
  856. F(19200000, P_BI_TCXO, 1, 0, 0),
  857. F(171428571, P_DISP_CC_PLL1_OUT_MAIN, 3.5, 0, 0),
  858. F(200000000, P_DISP_CC_PLL1_OUT_MAIN, 3, 0, 0),
  859. F(300000000, P_DISP_CC_PLL1_OUT_MAIN, 2, 0, 0),
  860. F(345000000, P_DISP_CC_PLL0_OUT_MAIN, 4, 0, 0),
  861. F(460000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  862. { }
  863. };
  864. static struct clk_rcg2 disp_cc_mdss_rot_clk_src = {
  865. .cmd_rcgr = 0x20e0,
  866. .mnd_width = 0,
  867. .hid_width = 5,
  868. .parent_map = disp_cc_parent_map_5,
  869. .freq_tbl = ftbl_disp_cc_mdss_rot_clk_src,
  870. .enable_safe_config = true,
  871. .clkr.hw.init = &(const struct clk_init_data){
  872. .name = "disp_cc_mdss_rot_clk_src",
  873. .parent_data = disp_cc_parent_data_5,
  874. .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
  875. .flags = CLK_SET_RATE_PARENT,
  876. .ops = &clk_rcg2_ops,
  877. },
  878. .clkr.vdd_data = {
  879. .vdd_class = &vdd_mm,
  880. .num_rate_max = VDD_NUM,
  881. .rate_max = (unsigned long[VDD_NUM]) {
  882. [VDD_MIN] = 19200000,
  883. [VDD_LOWER] = 171428571,
  884. [VDD_LOW] = 300000000,
  885. [VDD_LOW_L1] = 345000000,
  886. [VDD_NOMINAL] = 460000000},
  887. },
  888. };
  889. static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = {
  890. .cmd_rcgr = 0x20f8,
  891. .mnd_width = 0,
  892. .hid_width = 5,
  893. .parent_map = disp_cc_parent_map_1,
  894. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  895. .clkr.hw.init = &(const struct clk_init_data){
  896. .name = "disp_cc_mdss_vsync_clk_src",
  897. .parent_data = disp_cc_parent_data_1,
  898. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  899. .flags = CLK_SET_RATE_PARENT,
  900. .ops = &clk_rcg2_ops,
  901. },
  902. .clkr.vdd_data = {
  903. .vdd_class = &vdd_mm,
  904. .num_rate_max = VDD_NUM,
  905. .rate_max = (unsigned long[VDD_NUM]) {
  906. [VDD_MIN] = 19200000},
  907. },
  908. };
  909. static const struct freq_tbl ftbl_disp_cc_sleep_clk_src[] = {
  910. F(32000, P_SLEEP_CLK, 1, 0, 0),
  911. { }
  912. };
  913. static struct clk_rcg2 disp_cc_sleep_clk_src = {
  914. .cmd_rcgr = 0x6060,
  915. .mnd_width = 0,
  916. .hid_width = 5,
  917. .parent_map = disp_cc_parent_map_7,
  918. .freq_tbl = ftbl_disp_cc_sleep_clk_src,
  919. .clkr.hw.init = &(const struct clk_init_data){
  920. .name = "disp_cc_sleep_clk_src",
  921. .parent_data = disp_cc_parent_data_7,
  922. .num_parents = ARRAY_SIZE(disp_cc_parent_data_7),
  923. .ops = &clk_rcg2_ops,
  924. },
  925. .clkr.vdd_data = {
  926. .vdd_class = &vdd_mm,
  927. .num_rate_max = VDD_NUM,
  928. .rate_max = (unsigned long[VDD_NUM]) {
  929. [VDD_MIN] = 32000},
  930. },
  931. };
  932. static struct clk_rcg2 disp_cc_xo_clk_src = {
  933. .cmd_rcgr = 0x6044,
  934. .mnd_width = 0,
  935. .hid_width = 5,
  936. .parent_map = disp_cc_parent_map_1,
  937. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  938. .clkr.hw.init = &(const struct clk_init_data){
  939. .name = "disp_cc_xo_clk_src",
  940. .parent_data = disp_cc_parent_data_1_ao,
  941. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1_ao),
  942. .ops = &clk_rcg2_ops,
  943. },
  944. };
  945. static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = {
  946. .reg = 0x2128,
  947. .shift = 0,
  948. .width = 2,
  949. .clkr.hw.init = &(const struct clk_init_data) {
  950. .name = "disp_cc_mdss_byte0_div_clk_src",
  951. .parent_hws = (const struct clk_hw*[]){
  952. &disp_cc_mdss_byte0_clk_src.clkr.hw,
  953. },
  954. .num_parents = 1,
  955. .ops = &clk_regmap_div_ops,
  956. },
  957. };
  958. static struct clk_regmap_div disp_cc_mdss_byte1_div_clk_src = {
  959. .reg = 0x2144,
  960. .shift = 0,
  961. .width = 2,
  962. .clkr.hw.init = &(const struct clk_init_data) {
  963. .name = "disp_cc_mdss_byte1_div_clk_src",
  964. .parent_hws = (const struct clk_hw*[]){
  965. &disp_cc_mdss_byte1_clk_src.clkr.hw,
  966. },
  967. .num_parents = 1,
  968. .ops = &clk_regmap_div_ops,
  969. },
  970. };
  971. static struct clk_regmap_div disp_cc_mdss_dp_link1_div_clk_src = {
  972. .reg = 0x2224,
  973. .shift = 0,
  974. .width = 2,
  975. .clkr.hw.init = &(const struct clk_init_data) {
  976. .name = "disp_cc_mdss_dp_link1_div_clk_src",
  977. .parent_hws = (const struct clk_hw*[]){
  978. &disp_cc_mdss_dp_link1_clk_src.clkr.hw,
  979. },
  980. .num_parents = 1,
  981. .ops = &clk_regmap_div_ro_ops,
  982. },
  983. };
  984. static struct clk_regmap_div disp_cc_mdss_dp_link_div_clk_src = {
  985. .reg = 0x2190,
  986. .shift = 0,
  987. .width = 2,
  988. .clkr.hw.init = &(const struct clk_init_data) {
  989. .name = "disp_cc_mdss_dp_link_div_clk_src",
  990. .parent_hws = (const struct clk_hw*[]){
  991. &disp_cc_mdss_dp_link_clk_src.clkr.hw,
  992. },
  993. .num_parents = 1,
  994. .ops = &clk_regmap_div_ro_ops,
  995. },
  996. };
  997. /* CLK_DONT_HOLD_STATE flag is needed due to sync_state */
  998. static struct clk_branch disp_cc_mdss_ahb_clk = {
  999. .halt_reg = 0x2080,
  1000. .halt_check = BRANCH_HALT,
  1001. .clkr = {
  1002. .enable_reg = 0x2080,
  1003. .enable_mask = BIT(0),
  1004. .hw.init = &(const struct clk_init_data){
  1005. .name = "disp_cc_mdss_ahb_clk",
  1006. .parent_hws = (const struct clk_hw*[]){
  1007. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  1008. },
  1009. .num_parents = 1,
  1010. .flags = CLK_SET_RATE_PARENT | CLK_DONT_HOLD_STATE,
  1011. .ops = &clk_branch2_ops,
  1012. },
  1013. },
  1014. };
  1015. static struct clk_branch disp_cc_mdss_byte0_clk = {
  1016. .halt_reg = 0x2028,
  1017. .halt_check = BRANCH_HALT,
  1018. .clkr = {
  1019. .enable_reg = 0x2028,
  1020. .enable_mask = BIT(0),
  1021. .hw.init = &(const struct clk_init_data){
  1022. .name = "disp_cc_mdss_byte0_clk",
  1023. .parent_hws = (const struct clk_hw*[]){
  1024. &disp_cc_mdss_byte0_clk_src.clkr.hw,
  1025. },
  1026. .num_parents = 1,
  1027. .flags = CLK_SET_RATE_PARENT,
  1028. .ops = &clk_branch2_ops,
  1029. },
  1030. },
  1031. };
  1032. static struct clk_branch disp_cc_mdss_byte0_intf_clk = {
  1033. .halt_reg = 0x202c,
  1034. .halt_check = BRANCH_HALT,
  1035. .clkr = {
  1036. .enable_reg = 0x202c,
  1037. .enable_mask = BIT(0),
  1038. .hw.init = &(const struct clk_init_data){
  1039. .name = "disp_cc_mdss_byte0_intf_clk",
  1040. .parent_hws = (const struct clk_hw*[]){
  1041. &disp_cc_mdss_byte0_div_clk_src.clkr.hw,
  1042. },
  1043. .num_parents = 1,
  1044. .flags = CLK_SET_RATE_PARENT,
  1045. .ops = &clk_branch2_ops,
  1046. },
  1047. },
  1048. };
  1049. static struct clk_branch disp_cc_mdss_byte1_clk = {
  1050. .halt_reg = 0x2030,
  1051. .halt_check = BRANCH_HALT,
  1052. .clkr = {
  1053. .enable_reg = 0x2030,
  1054. .enable_mask = BIT(0),
  1055. .hw.init = &(const struct clk_init_data){
  1056. .name = "disp_cc_mdss_byte1_clk",
  1057. .parent_hws = (const struct clk_hw*[]){
  1058. &disp_cc_mdss_byte1_clk_src.clkr.hw,
  1059. },
  1060. .num_parents = 1,
  1061. .flags = CLK_SET_RATE_PARENT,
  1062. .ops = &clk_branch2_ops,
  1063. },
  1064. },
  1065. };
  1066. static struct clk_branch disp_cc_mdss_byte1_intf_clk = {
  1067. .halt_reg = 0x2034,
  1068. .halt_check = BRANCH_HALT,
  1069. .clkr = {
  1070. .enable_reg = 0x2034,
  1071. .enable_mask = BIT(0),
  1072. .hw.init = &(const struct clk_init_data){
  1073. .name = "disp_cc_mdss_byte1_intf_clk",
  1074. .parent_hws = (const struct clk_hw*[]){
  1075. &disp_cc_mdss_byte1_div_clk_src.clkr.hw,
  1076. },
  1077. .num_parents = 1,
  1078. .flags = CLK_SET_RATE_PARENT,
  1079. .ops = &clk_branch2_ops,
  1080. },
  1081. },
  1082. };
  1083. static struct clk_branch disp_cc_mdss_dp_aux1_clk = {
  1084. .halt_reg = 0x2068,
  1085. .halt_check = BRANCH_HALT,
  1086. .clkr = {
  1087. .enable_reg = 0x2068,
  1088. .enable_mask = BIT(0),
  1089. .hw.init = &(const struct clk_init_data){
  1090. .name = "disp_cc_mdss_dp_aux1_clk",
  1091. .parent_hws = (const struct clk_hw*[]){
  1092. &disp_cc_mdss_dp_aux1_clk_src.clkr.hw,
  1093. },
  1094. .num_parents = 1,
  1095. .flags = CLK_SET_RATE_PARENT,
  1096. .ops = &clk_branch2_ops,
  1097. },
  1098. },
  1099. };
  1100. static struct clk_branch disp_cc_mdss_dp_aux_clk = {
  1101. .halt_reg = 0x2054,
  1102. .halt_check = BRANCH_HALT,
  1103. .clkr = {
  1104. .enable_reg = 0x2054,
  1105. .enable_mask = BIT(0),
  1106. .hw.init = &(const struct clk_init_data){
  1107. .name = "disp_cc_mdss_dp_aux_clk",
  1108. .parent_hws = (const struct clk_hw*[]){
  1109. &disp_cc_mdss_dp_aux_clk_src.clkr.hw,
  1110. },
  1111. .num_parents = 1,
  1112. .flags = CLK_SET_RATE_PARENT,
  1113. .ops = &clk_branch2_ops,
  1114. },
  1115. },
  1116. };
  1117. static struct clk_branch disp_cc_mdss_dp_link1_clk = {
  1118. .halt_reg = 0x205c,
  1119. .halt_check = BRANCH_HALT,
  1120. .clkr = {
  1121. .enable_reg = 0x205c,
  1122. .enable_mask = BIT(0),
  1123. .hw.init = &(const struct clk_init_data){
  1124. .name = "disp_cc_mdss_dp_link1_clk",
  1125. .parent_hws = (const struct clk_hw*[]){
  1126. &disp_cc_mdss_dp_link1_clk_src.clkr.hw,
  1127. },
  1128. .num_parents = 1,
  1129. .flags = CLK_SET_RATE_PARENT,
  1130. .ops = &clk_branch2_ops,
  1131. },
  1132. },
  1133. };
  1134. static struct clk_branch disp_cc_mdss_dp_link1_intf_clk = {
  1135. .halt_reg = 0x2060,
  1136. .halt_check = BRANCH_HALT,
  1137. .clkr = {
  1138. .enable_reg = 0x2060,
  1139. .enable_mask = BIT(0),
  1140. .hw.init = &(const struct clk_init_data){
  1141. .name = "disp_cc_mdss_dp_link1_intf_clk",
  1142. .parent_hws = (const struct clk_hw*[]){
  1143. &disp_cc_mdss_dp_link1_div_clk_src.clkr.hw,
  1144. },
  1145. .num_parents = 1,
  1146. .flags = CLK_SET_RATE_PARENT,
  1147. .ops = &clk_branch2_ops,
  1148. },
  1149. },
  1150. };
  1151. static struct clk_branch disp_cc_mdss_dp_link_clk = {
  1152. .halt_reg = 0x2040,
  1153. .halt_check = BRANCH_HALT,
  1154. .clkr = {
  1155. .enable_reg = 0x2040,
  1156. .enable_mask = BIT(0),
  1157. .hw.init = &(const struct clk_init_data){
  1158. .name = "disp_cc_mdss_dp_link_clk",
  1159. .parent_hws = (const struct clk_hw*[]){
  1160. &disp_cc_mdss_dp_link_clk_src.clkr.hw,
  1161. },
  1162. .num_parents = 1,
  1163. .flags = CLK_SET_RATE_PARENT,
  1164. .ops = &clk_branch2_ops,
  1165. },
  1166. },
  1167. };
  1168. static struct clk_branch disp_cc_mdss_dp_link_intf_clk = {
  1169. .halt_reg = 0x2044,
  1170. .halt_check = BRANCH_HALT,
  1171. .clkr = {
  1172. .enable_reg = 0x2044,
  1173. .enable_mask = BIT(0),
  1174. .hw.init = &(const struct clk_init_data){
  1175. .name = "disp_cc_mdss_dp_link_intf_clk",
  1176. .parent_hws = (const struct clk_hw*[]){
  1177. &disp_cc_mdss_dp_link_div_clk_src.clkr.hw,
  1178. },
  1179. .num_parents = 1,
  1180. .flags = CLK_SET_RATE_PARENT,
  1181. .ops = &clk_branch2_ops,
  1182. },
  1183. },
  1184. };
  1185. static struct clk_branch disp_cc_mdss_dp_pixel1_clk = {
  1186. .halt_reg = 0x2050,
  1187. .halt_check = BRANCH_HALT,
  1188. .clkr = {
  1189. .enable_reg = 0x2050,
  1190. .enable_mask = BIT(0),
  1191. .hw.init = &(const struct clk_init_data){
  1192. .name = "disp_cc_mdss_dp_pixel1_clk",
  1193. .parent_hws = (const struct clk_hw*[]){
  1194. &disp_cc_mdss_dp_pixel1_clk_src.clkr.hw,
  1195. },
  1196. .num_parents = 1,
  1197. .flags = CLK_SET_RATE_PARENT,
  1198. .ops = &clk_branch2_ops,
  1199. },
  1200. },
  1201. };
  1202. static struct clk_branch disp_cc_mdss_dp_pixel2_clk = {
  1203. .halt_reg = 0x2058,
  1204. .halt_check = BRANCH_HALT,
  1205. .clkr = {
  1206. .enable_reg = 0x2058,
  1207. .enable_mask = BIT(0),
  1208. .hw.init = &(const struct clk_init_data){
  1209. .name = "disp_cc_mdss_dp_pixel2_clk",
  1210. .parent_hws = (const struct clk_hw*[]){
  1211. &disp_cc_mdss_dp_pixel2_clk_src.clkr.hw,
  1212. },
  1213. .num_parents = 1,
  1214. .flags = CLK_SET_RATE_PARENT,
  1215. .ops = &clk_branch2_ops,
  1216. },
  1217. },
  1218. };
  1219. static struct clk_branch disp_cc_mdss_dp_pixel_clk = {
  1220. .halt_reg = 0x204c,
  1221. .halt_check = BRANCH_HALT,
  1222. .clkr = {
  1223. .enable_reg = 0x204c,
  1224. .enable_mask = BIT(0),
  1225. .hw.init = &(const struct clk_init_data){
  1226. .name = "disp_cc_mdss_dp_pixel_clk",
  1227. .parent_hws = (const struct clk_hw*[]){
  1228. &disp_cc_mdss_dp_pixel_clk_src.clkr.hw,
  1229. },
  1230. .num_parents = 1,
  1231. .flags = CLK_SET_RATE_PARENT,
  1232. .ops = &clk_branch2_ops,
  1233. },
  1234. },
  1235. };
  1236. static struct clk_branch disp_cc_mdss_esc0_clk = {
  1237. .halt_reg = 0x2038,
  1238. .halt_check = BRANCH_HALT,
  1239. .clkr = {
  1240. .enable_reg = 0x2038,
  1241. .enable_mask = BIT(0),
  1242. .hw.init = &(const struct clk_init_data){
  1243. .name = "disp_cc_mdss_esc0_clk",
  1244. .parent_hws = (const struct clk_hw*[]){
  1245. &disp_cc_mdss_esc0_clk_src.clkr.hw,
  1246. },
  1247. .num_parents = 1,
  1248. .flags = CLK_SET_RATE_PARENT,
  1249. .ops = &clk_branch2_ops,
  1250. },
  1251. },
  1252. };
  1253. static struct clk_branch disp_cc_mdss_esc1_clk = {
  1254. .halt_reg = 0x203c,
  1255. .halt_check = BRANCH_HALT,
  1256. .clkr = {
  1257. .enable_reg = 0x203c,
  1258. .enable_mask = BIT(0),
  1259. .hw.init = &(const struct clk_init_data){
  1260. .name = "disp_cc_mdss_esc1_clk",
  1261. .parent_hws = (const struct clk_hw*[]){
  1262. &disp_cc_mdss_esc1_clk_src.clkr.hw,
  1263. },
  1264. .num_parents = 1,
  1265. .flags = CLK_SET_RATE_PARENT,
  1266. .ops = &clk_branch2_ops,
  1267. },
  1268. },
  1269. };
  1270. /* CLK_DONT_HOLD_STATE flag is needed due to sync_state */
  1271. static struct clk_branch disp_cc_mdss_mdp_clk = {
  1272. .halt_reg = 0x200c,
  1273. .halt_check = BRANCH_HALT,
  1274. .clkr = {
  1275. .enable_reg = 0x200c,
  1276. .enable_mask = BIT(0),
  1277. .hw.init = &(const struct clk_init_data){
  1278. .name = "disp_cc_mdss_mdp_clk",
  1279. .parent_hws = (const struct clk_hw*[]){
  1280. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  1281. },
  1282. .num_parents = 1,
  1283. .flags = CLK_SET_RATE_PARENT | CLK_DONT_HOLD_STATE,
  1284. .ops = &clk_branch2_ops,
  1285. },
  1286. },
  1287. };
  1288. static struct clk_branch disp_cc_mdss_mdp_lut_clk = {
  1289. .halt_reg = 0x201c,
  1290. .halt_check = BRANCH_HALT_VOTED,
  1291. .clkr = {
  1292. .enable_reg = 0x201c,
  1293. .enable_mask = BIT(0),
  1294. .hw.init = &(const struct clk_init_data){
  1295. .name = "disp_cc_mdss_mdp_lut_clk",
  1296. .parent_hws = (const struct clk_hw*[]){
  1297. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  1298. },
  1299. .num_parents = 1,
  1300. .flags = CLK_SET_RATE_PARENT,
  1301. .ops = &clk_branch2_ops,
  1302. },
  1303. },
  1304. };
  1305. /* CLK_DONT_HOLD_STATE flag is needed due to sync_state */
  1306. static struct clk_branch disp_cc_mdss_non_gdsc_ahb_clk = {
  1307. .halt_reg = 0x4004,
  1308. .halt_check = BRANCH_HALT_VOTED,
  1309. .clkr = {
  1310. .enable_reg = 0x4004,
  1311. .enable_mask = BIT(0),
  1312. .hw.init = &(const struct clk_init_data){
  1313. .name = "disp_cc_mdss_non_gdsc_ahb_clk",
  1314. .parent_hws = (const struct clk_hw*[]){
  1315. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  1316. },
  1317. .num_parents = 1,
  1318. .flags = CLK_SET_RATE_PARENT | CLK_DONT_HOLD_STATE,
  1319. .ops = &clk_branch2_ops,
  1320. },
  1321. },
  1322. };
  1323. static struct clk_branch disp_cc_mdss_pclk0_clk = {
  1324. .halt_reg = 0x2004,
  1325. .halt_check = BRANCH_HALT,
  1326. .clkr = {
  1327. .enable_reg = 0x2004,
  1328. .enable_mask = BIT(0),
  1329. .hw.init = &(const struct clk_init_data){
  1330. .name = "disp_cc_mdss_pclk0_clk",
  1331. .parent_hws = (const struct clk_hw*[]){
  1332. &disp_cc_mdss_pclk0_clk_src.clkr.hw,
  1333. },
  1334. .num_parents = 1,
  1335. .flags = CLK_SET_RATE_PARENT,
  1336. .ops = &clk_branch2_ops,
  1337. },
  1338. },
  1339. };
  1340. static struct clk_branch disp_cc_mdss_pclk1_clk = {
  1341. .halt_reg = 0x2008,
  1342. .halt_check = BRANCH_HALT,
  1343. .clkr = {
  1344. .enable_reg = 0x2008,
  1345. .enable_mask = BIT(0),
  1346. .hw.init = &(const struct clk_init_data){
  1347. .name = "disp_cc_mdss_pclk1_clk",
  1348. .parent_hws = (const struct clk_hw*[]){
  1349. &disp_cc_mdss_pclk1_clk_src.clkr.hw,
  1350. },
  1351. .num_parents = 1,
  1352. .flags = CLK_SET_RATE_PARENT,
  1353. .ops = &clk_branch2_ops,
  1354. },
  1355. },
  1356. };
  1357. static struct clk_branch disp_cc_mdss_rot_clk = {
  1358. .halt_reg = 0x2014,
  1359. .halt_check = BRANCH_HALT,
  1360. .clkr = {
  1361. .enable_reg = 0x2014,
  1362. .enable_mask = BIT(0),
  1363. .hw.init = &(const struct clk_init_data){
  1364. .name = "disp_cc_mdss_rot_clk",
  1365. .parent_hws = (const struct clk_hw*[]){
  1366. &disp_cc_mdss_rot_clk_src.clkr.hw,
  1367. },
  1368. .num_parents = 1,
  1369. .flags = CLK_SET_RATE_PARENT,
  1370. .ops = &clk_branch2_ops,
  1371. },
  1372. },
  1373. };
  1374. /* CLK_DONT_HOLD_STATE flag is needed due to sync_state */
  1375. static struct clk_branch disp_cc_mdss_rscc_ahb_clk = {
  1376. .halt_reg = 0x400c,
  1377. .halt_check = BRANCH_HALT,
  1378. .clkr = {
  1379. .enable_reg = 0x400c,
  1380. .enable_mask = BIT(0),
  1381. .hw.init = &(const struct clk_init_data){
  1382. .name = "disp_cc_mdss_rscc_ahb_clk",
  1383. .parent_hws = (const struct clk_hw*[]){
  1384. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  1385. },
  1386. .num_parents = 1,
  1387. .flags = CLK_SET_RATE_PARENT | CLK_DONT_HOLD_STATE,
  1388. .ops = &clk_branch2_ops,
  1389. },
  1390. },
  1391. };
  1392. static struct clk_branch disp_cc_mdss_rscc_vsync_clk = {
  1393. .halt_reg = 0x4008,
  1394. .halt_check = BRANCH_HALT,
  1395. .clkr = {
  1396. .enable_reg = 0x4008,
  1397. .enable_mask = BIT(0),
  1398. .hw.init = &(const struct clk_init_data){
  1399. .name = "disp_cc_mdss_rscc_vsync_clk",
  1400. .parent_hws = (const struct clk_hw*[]){
  1401. &disp_cc_mdss_vsync_clk_src.clkr.hw,
  1402. },
  1403. .num_parents = 1,
  1404. .flags = CLK_SET_RATE_PARENT,
  1405. .ops = &clk_branch2_ops,
  1406. },
  1407. },
  1408. };
  1409. static struct clk_branch disp_cc_mdss_vsync_clk = {
  1410. .halt_reg = 0x2024,
  1411. .halt_check = BRANCH_HALT,
  1412. .clkr = {
  1413. .enable_reg = 0x2024,
  1414. .enable_mask = BIT(0),
  1415. .hw.init = &(const struct clk_init_data){
  1416. .name = "disp_cc_mdss_vsync_clk",
  1417. .parent_hws = (const struct clk_hw*[]){
  1418. &disp_cc_mdss_vsync_clk_src.clkr.hw,
  1419. },
  1420. .num_parents = 1,
  1421. .flags = CLK_SET_RATE_PARENT,
  1422. .ops = &clk_branch2_ops,
  1423. },
  1424. },
  1425. };
  1426. static struct clk_branch disp_cc_sleep_clk = {
  1427. .halt_reg = 0x6078,
  1428. .halt_check = BRANCH_HALT,
  1429. .clkr = {
  1430. .enable_reg = 0x6078,
  1431. .enable_mask = BIT(0),
  1432. .hw.init = &(const struct clk_init_data){
  1433. .name = "disp_cc_sleep_clk",
  1434. .parent_hws = (const struct clk_hw*[]){
  1435. &disp_cc_sleep_clk_src.clkr.hw,
  1436. },
  1437. .num_parents = 1,
  1438. .flags = CLK_SET_RATE_PARENT,
  1439. .ops = &clk_branch2_ops,
  1440. },
  1441. },
  1442. };
  1443. static struct gdsc mdss_gdsc = {
  1444. .gdscr = 0x3000,
  1445. .en_rest_wait_val = 0x2,
  1446. .en_few_wait_val = 0x2,
  1447. .clk_dis_wait_val = 0xf,
  1448. .pd = {
  1449. .name = "mdss_gdsc",
  1450. },
  1451. .pwrsts = PWRSTS_OFF_ON,
  1452. .flags = 0,
  1453. .supply = "mmcx",
  1454. };
  1455. static struct critical_clk_offset critical_clk_list[] = {
  1456. { .offset = 0x8000, .mask = BIT(4) },
  1457. { .offset = 0x605c, .mask = BIT(0) },
  1458. };
  1459. static struct clk_regmap *disp_cc_sm8250_clocks[] = {
  1460. [DISP_CC_MDSS_AHB_CLK] = &disp_cc_mdss_ahb_clk.clkr,
  1461. [DISP_CC_MDSS_AHB_CLK_SRC] = &disp_cc_mdss_ahb_clk_src.clkr,
  1462. [DISP_CC_MDSS_BYTE0_CLK] = &disp_cc_mdss_byte0_clk.clkr,
  1463. [DISP_CC_MDSS_BYTE0_CLK_SRC] = &disp_cc_mdss_byte0_clk_src.clkr,
  1464. [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC] = &disp_cc_mdss_byte0_div_clk_src.clkr,
  1465. [DISP_CC_MDSS_BYTE0_INTF_CLK] = &disp_cc_mdss_byte0_intf_clk.clkr,
  1466. [DISP_CC_MDSS_BYTE1_CLK] = &disp_cc_mdss_byte1_clk.clkr,
  1467. [DISP_CC_MDSS_BYTE1_CLK_SRC] = &disp_cc_mdss_byte1_clk_src.clkr,
  1468. [DISP_CC_MDSS_BYTE1_DIV_CLK_SRC] = &disp_cc_mdss_byte1_div_clk_src.clkr,
  1469. [DISP_CC_MDSS_BYTE1_INTF_CLK] = &disp_cc_mdss_byte1_intf_clk.clkr,
  1470. [DISP_CC_MDSS_DP_AUX1_CLK] = &disp_cc_mdss_dp_aux1_clk.clkr,
  1471. [DISP_CC_MDSS_DP_AUX1_CLK_SRC] = &disp_cc_mdss_dp_aux1_clk_src.clkr,
  1472. [DISP_CC_MDSS_DP_AUX_CLK] = &disp_cc_mdss_dp_aux_clk.clkr,
  1473. [DISP_CC_MDSS_DP_AUX_CLK_SRC] = &disp_cc_mdss_dp_aux_clk_src.clkr,
  1474. [DISP_CC_MDSS_DP_LINK1_CLK] = &disp_cc_mdss_dp_link1_clk.clkr,
  1475. [DISP_CC_MDSS_DP_LINK1_CLK_SRC] = &disp_cc_mdss_dp_link1_clk_src.clkr,
  1476. [DISP_CC_MDSS_DP_LINK1_DIV_CLK_SRC] = &disp_cc_mdss_dp_link1_div_clk_src.clkr,
  1477. [DISP_CC_MDSS_DP_LINK1_INTF_CLK] = &disp_cc_mdss_dp_link1_intf_clk.clkr,
  1478. [DISP_CC_MDSS_DP_LINK_CLK] = &disp_cc_mdss_dp_link_clk.clkr,
  1479. [DISP_CC_MDSS_DP_LINK_CLK_SRC] = &disp_cc_mdss_dp_link_clk_src.clkr,
  1480. [DISP_CC_MDSS_DP_LINK_DIV_CLK_SRC] = &disp_cc_mdss_dp_link_div_clk_src.clkr,
  1481. [DISP_CC_MDSS_DP_LINK_INTF_CLK] = &disp_cc_mdss_dp_link_intf_clk.clkr,
  1482. [DISP_CC_MDSS_DP_PIXEL1_CLK] = &disp_cc_mdss_dp_pixel1_clk.clkr,
  1483. [DISP_CC_MDSS_DP_PIXEL1_CLK_SRC] = &disp_cc_mdss_dp_pixel1_clk_src.clkr,
  1484. [DISP_CC_MDSS_DP_PIXEL2_CLK] = &disp_cc_mdss_dp_pixel2_clk.clkr,
  1485. [DISP_CC_MDSS_DP_PIXEL2_CLK_SRC] = &disp_cc_mdss_dp_pixel2_clk_src.clkr,
  1486. [DISP_CC_MDSS_DP_PIXEL_CLK] = &disp_cc_mdss_dp_pixel_clk.clkr,
  1487. [DISP_CC_MDSS_DP_PIXEL_CLK_SRC] = &disp_cc_mdss_dp_pixel_clk_src.clkr,
  1488. [DISP_CC_MDSS_EDP_AUX_CLK] = &disp_cc_mdss_edp_aux_clk.clkr,
  1489. [DISP_CC_MDSS_EDP_AUX_CLK_SRC] = &disp_cc_mdss_edp_aux_clk_src.clkr,
  1490. [DISP_CC_MDSS_EDP_GTC_CLK] = &disp_cc_mdss_edp_gtc_clk.clkr,
  1491. [DISP_CC_MDSS_EDP_GTC_CLK_SRC] = &disp_cc_mdss_edp_gtc_clk_src.clkr,
  1492. [DISP_CC_MDSS_EDP_LINK_CLK] = &disp_cc_mdss_edp_link_clk.clkr,
  1493. [DISP_CC_MDSS_EDP_LINK_CLK_SRC] = &disp_cc_mdss_edp_link_clk_src.clkr,
  1494. [DISP_CC_MDSS_EDP_LINK_DIV_CLK_SRC] = &disp_cc_mdss_edp_link_div_clk_src.clkr,
  1495. [DISP_CC_MDSS_EDP_LINK_INTF_CLK] = &disp_cc_mdss_edp_link_intf_clk.clkr,
  1496. [DISP_CC_MDSS_EDP_PIXEL_CLK] = &disp_cc_mdss_edp_pixel_clk.clkr,
  1497. [DISP_CC_MDSS_EDP_PIXEL_CLK_SRC] = &disp_cc_mdss_edp_pixel_clk_src.clkr,
  1498. [DISP_CC_MDSS_ESC0_CLK] = &disp_cc_mdss_esc0_clk.clkr,
  1499. [DISP_CC_MDSS_ESC0_CLK_SRC] = &disp_cc_mdss_esc0_clk_src.clkr,
  1500. [DISP_CC_MDSS_ESC1_CLK] = &disp_cc_mdss_esc1_clk.clkr,
  1501. [DISP_CC_MDSS_ESC1_CLK_SRC] = &disp_cc_mdss_esc1_clk_src.clkr,
  1502. [DISP_CC_MDSS_MDP_CLK] = &disp_cc_mdss_mdp_clk.clkr,
  1503. [DISP_CC_MDSS_MDP_CLK_SRC] = &disp_cc_mdss_mdp_clk_src.clkr,
  1504. [DISP_CC_MDSS_MDP_LUT_CLK] = &disp_cc_mdss_mdp_lut_clk.clkr,
  1505. [DISP_CC_MDSS_NON_GDSC_AHB_CLK] = &disp_cc_mdss_non_gdsc_ahb_clk.clkr,
  1506. [DISP_CC_MDSS_PCLK0_CLK] = &disp_cc_mdss_pclk0_clk.clkr,
  1507. [DISP_CC_MDSS_PCLK0_CLK_SRC] = &disp_cc_mdss_pclk0_clk_src.clkr,
  1508. [DISP_CC_MDSS_PCLK1_CLK] = &disp_cc_mdss_pclk1_clk.clkr,
  1509. [DISP_CC_MDSS_PCLK1_CLK_SRC] = &disp_cc_mdss_pclk1_clk_src.clkr,
  1510. [DISP_CC_MDSS_ROT_CLK] = &disp_cc_mdss_rot_clk.clkr,
  1511. [DISP_CC_MDSS_ROT_CLK_SRC] = &disp_cc_mdss_rot_clk_src.clkr,
  1512. [DISP_CC_MDSS_RSCC_AHB_CLK] = &disp_cc_mdss_rscc_ahb_clk.clkr,
  1513. [DISP_CC_MDSS_RSCC_VSYNC_CLK] = &disp_cc_mdss_rscc_vsync_clk.clkr,
  1514. [DISP_CC_MDSS_VSYNC_CLK] = &disp_cc_mdss_vsync_clk.clkr,
  1515. [DISP_CC_MDSS_VSYNC_CLK_SRC] = &disp_cc_mdss_vsync_clk_src.clkr,
  1516. [DISP_CC_PLL0] = &disp_cc_pll0.clkr,
  1517. [DISP_CC_PLL1] = &disp_cc_pll1.clkr,
  1518. [DISP_CC_SLEEP_CLK] = &disp_cc_sleep_clk.clkr,
  1519. [DISP_CC_SLEEP_CLK_SRC] = &disp_cc_sleep_clk_src.clkr,
  1520. [DISP_CC_XO_CLK_SRC] = &disp_cc_xo_clk_src.clkr,
  1521. };
  1522. static const struct qcom_reset_map disp_cc_sm8250_resets[] = {
  1523. [DISP_CC_MDSS_CORE_BCR] = { 0x2000 },
  1524. [DISP_CC_MDSS_RSCC_BCR] = { 0x4000 },
  1525. };
  1526. static struct gdsc *disp_cc_sm8250_gdscs[] = {
  1527. [MDSS_GDSC] = &mdss_gdsc,
  1528. };
  1529. static const struct regmap_config disp_cc_sm8250_regmap_config = {
  1530. .reg_bits = 32,
  1531. .reg_stride = 4,
  1532. .val_bits = 32,
  1533. .max_register = 0x10000,
  1534. .fast_io = true,
  1535. };
  1536. static struct qcom_cc_desc disp_cc_sm8250_desc = {
  1537. .config = &disp_cc_sm8250_regmap_config,
  1538. .clks = disp_cc_sm8250_clocks,
  1539. .num_clks = ARRAY_SIZE(disp_cc_sm8250_clocks),
  1540. .clk_regulators = disp_cc_sm8250_regulators,
  1541. .num_clk_regulators = ARRAY_SIZE(disp_cc_sm8250_regulators),
  1542. .resets = disp_cc_sm8250_resets,
  1543. .num_resets = ARRAY_SIZE(disp_cc_sm8250_resets),
  1544. .gdscs = disp_cc_sm8250_gdscs,
  1545. .num_gdscs = ARRAY_SIZE(disp_cc_sm8250_gdscs),
  1546. .critical_clk_en = critical_clk_list,
  1547. .num_critical_clk = ARRAY_SIZE(critical_clk_list),
  1548. };
  1549. static const struct of_device_id disp_cc_sm8250_match_table[] = {
  1550. { .compatible = "qcom,sc8180x-dispcc" },
  1551. { .compatible = "qcom,sm8150-dispcc" },
  1552. { .compatible = "qcom,sm8250-dispcc" },
  1553. { .compatible = "qcom,sm8350-dispcc" },
  1554. { }
  1555. };
  1556. MODULE_DEVICE_TABLE(of, disp_cc_sm8250_match_table);
  1557. static int disp_cc_sm8250_fixup(struct platform_device *pdev,
  1558. struct regmap *regmap)
  1559. {
  1560. /* note: trion == lucid, except for the prepare() op */
  1561. BUILD_BUG_ON(CLK_ALPHA_PLL_TYPE_TRION != CLK_ALPHA_PLL_TYPE_LUCID);
  1562. if (of_device_is_compatible(pdev->dev.of_node, "qcom,sc8180x-dispcc") ||
  1563. of_device_is_compatible(pdev->dev.of_node, "qcom,sm8150-dispcc")) {
  1564. disp_cc_pll0_config.config_ctl_hi_val = 0x00002267;
  1565. disp_cc_pll0_config.config_ctl_hi1_val = 0x00000024;
  1566. disp_cc_pll0_config.user_ctl_hi1_val = 0x000000D0;
  1567. disp_cc_pll0_init.ops = &clk_alpha_pll_trion_ops;
  1568. disp_cc_pll1_config.config_ctl_hi_val = 0x00002267;
  1569. disp_cc_pll1_config.config_ctl_hi1_val = 0x00000024;
  1570. disp_cc_pll1_config.user_ctl_hi1_val = 0x000000D0;
  1571. disp_cc_pll1_init.ops = &clk_alpha_pll_trion_ops;
  1572. disp_cc_sm8250_clocks[DISP_CC_MDSS_DP_CRYPTO1_CLK] =
  1573. &disp_cc_mdss_dp_crypto1_clk.clkr;
  1574. disp_cc_sm8250_clocks[DISP_CC_MDSS_DP_CRYPTO1_CLK_SRC] =
  1575. &disp_cc_mdss_dp_crypto1_clk_src.clkr;
  1576. disp_cc_sm8250_clocks[DISP_CC_MDSS_DP_CRYPTO_CLK] =
  1577. &disp_cc_mdss_dp_crypto_clk.clkr;
  1578. disp_cc_sm8250_clocks[DISP_CC_MDSS_DP_CRYPTO_CLK_SRC] =
  1579. &disp_cc_mdss_dp_crypto_clk_src.clkr;
  1580. }
  1581. if (of_device_is_compatible(pdev->dev.of_node, "qcom,sc8180x-dispcc")) {
  1582. disp_cc_mdss_dp_pixel1_clk_src.clkr.vdd_data.rate_max[VDD_LOW_L1] = 337500;
  1583. disp_cc_mdss_dp_pixel1_clk_src.clkr.vdd_data.rate_max[VDD_NOMINAL] = 675000;
  1584. disp_cc_mdss_dp_pixel2_clk_src.clkr.vdd_data.rate_max[VDD_LOW_L1] = 337500;
  1585. disp_cc_mdss_dp_pixel2_clk_src.clkr.vdd_data.rate_max[VDD_NOMINAL] = 675000;
  1586. disp_cc_mdss_dp_pixel_clk_src.clkr.vdd_data.rate_max[VDD_LOW_L1] = 337500;
  1587. disp_cc_mdss_dp_pixel_clk_src.clkr.vdd_data.rate_max[VDD_NOMINAL] = 675000;
  1588. disp_cc_mdss_dp_crypto_clk_src.freq_tbl =
  1589. ftbl_disp_cc_mdss_dp_crypto_clk_src_sc8180x;
  1590. disp_cc_mdss_dp_crypto1_clk_src.freq_tbl =
  1591. ftbl_disp_cc_mdss_dp_crypto1_clk_src_sc8180x;
  1592. disp_cc_mdss_edp_link_clk_src.clkr.vdd_data.rate_max[VDD_MIN] = 19200;
  1593. disp_cc_mdss_edp_link_clk_src.clkr.vdd_data.rate_max[VDD_LOWER] = 270000;
  1594. disp_cc_mdss_edp_link_clk_src.clkr.vdd_data.rate_max[VDD_LOW_L1] = 594000;
  1595. disp_cc_mdss_edp_link_clk_src.clkr.vdd_data.rate_max[VDD_NOMINAL] = 810000;
  1596. disp_cc_mdss_edp_pixel_clk_src.parent_map = disp_cc_parent_map_4_sc8180x;
  1597. disp_cc_mdss_edp_pixel_clk_src.clkr.hw.init =
  1598. &disp_cc_mdss_edp_pixel_clk_src_sc8180x;
  1599. disp_cc_mdss_edp_pixel_clk_src.clkr.vdd_data.rate_max[VDD_MIN] = 19200;
  1600. disp_cc_mdss_edp_pixel_clk_src.clkr.vdd_data.rate_max[VDD_LOWER] = 337500;
  1601. disp_cc_mdss_edp_pixel_clk_src.clkr.vdd_data.rate_max[VDD_LOW_L1] = 371500;
  1602. disp_cc_mdss_edp_pixel_clk_src.clkr.vdd_data.rate_max[VDD_NOMINAL] = 675000;
  1603. } else if (of_device_is_compatible(pdev->dev.of_node, "qcom,sm8350-dispcc")) {
  1604. static struct clk_rcg2 * const rcgs[] = {
  1605. &disp_cc_mdss_byte0_clk_src,
  1606. &disp_cc_mdss_byte1_clk_src,
  1607. &disp_cc_mdss_dp_aux1_clk_src,
  1608. &disp_cc_mdss_dp_aux_clk_src,
  1609. &disp_cc_mdss_dp_link1_clk_src,
  1610. &disp_cc_mdss_dp_link_clk_src,
  1611. &disp_cc_mdss_dp_pixel1_clk_src,
  1612. &disp_cc_mdss_dp_pixel2_clk_src,
  1613. &disp_cc_mdss_dp_pixel_clk_src,
  1614. &disp_cc_mdss_esc0_clk_src,
  1615. &disp_cc_mdss_mdp_clk_src,
  1616. &disp_cc_mdss_pclk0_clk_src,
  1617. &disp_cc_mdss_pclk1_clk_src,
  1618. &disp_cc_mdss_rot_clk_src,
  1619. &disp_cc_mdss_vsync_clk_src,
  1620. };
  1621. static struct clk_regmap_div * const divs[] = {
  1622. &disp_cc_mdss_byte0_div_clk_src,
  1623. &disp_cc_mdss_byte1_div_clk_src,
  1624. &disp_cc_mdss_dp_link1_div_clk_src,
  1625. &disp_cc_mdss_dp_link_div_clk_src,
  1626. };
  1627. unsigned int i;
  1628. static bool offset_applied;
  1629. /*
  1630. * note: trion == lucid, except for the prepare() op
  1631. * only apply the offsets once (in case of deferred probe)
  1632. */
  1633. if (!offset_applied) {
  1634. for (i = 0; i < ARRAY_SIZE(rcgs); i++)
  1635. rcgs[i]->cmd_rcgr -= 4;
  1636. for (i = 0; i < ARRAY_SIZE(divs); i++) {
  1637. divs[i]->reg -= 4;
  1638. divs[i]->width = 4;
  1639. }
  1640. disp_cc_mdss_ahb_clk.halt_reg -= 4;
  1641. disp_cc_mdss_ahb_clk.clkr.enable_reg -= 4;
  1642. offset_applied = true;
  1643. }
  1644. disp_cc_mdss_ahb_clk_src.cmd_rcgr = 0x22a0;
  1645. disp_cc_pll0_config.config_ctl_hi1_val = 0x2a9a699c;
  1646. disp_cc_pll0_config.test_ctl_hi1_val = 0x01800000;
  1647. disp_cc_pll0_init.ops = &clk_alpha_pll_lucid_5lpe_ops;
  1648. disp_cc_pll0.vco_table = lucid_5lpe_vco;
  1649. disp_cc_pll1_config.config_ctl_hi1_val = 0x2a9a699c;
  1650. disp_cc_pll1_config.test_ctl_hi1_val = 0x01800000;
  1651. disp_cc_pll1_init.ops = &clk_alpha_pll_lucid_5lpe_ops;
  1652. disp_cc_pll1.vco_table = lucid_5lpe_vco;
  1653. }
  1654. return 0;
  1655. }
  1656. static int disp_cc_sm8250_probe(struct platform_device *pdev)
  1657. {
  1658. struct regmap *regmap;
  1659. int ret;
  1660. regmap = qcom_cc_map(pdev, &disp_cc_sm8250_desc);
  1661. if (IS_ERR(regmap))
  1662. return PTR_ERR(regmap);
  1663. ret = disp_cc_sm8250_fixup(pdev, regmap);
  1664. if (ret)
  1665. return ret;
  1666. clk_lucid_pll_configure(&disp_cc_pll0, regmap, disp_cc_pll0.config);
  1667. clk_lucid_pll_configure(&disp_cc_pll1, regmap, disp_cc_pll1.config);
  1668. /* Enable clock gating for MDP clocks */
  1669. regmap_update_bits(regmap, 0x8000, 0x10, 0x10);
  1670. /*
  1671. *Keep clocks always enabled
  1672. * disp_cc_xo_clk
  1673. */
  1674. regmap_update_bits(regmap, 0x605c, BIT(0), BIT(0));
  1675. ret = qcom_cc_really_probe(pdev, &disp_cc_sm8250_desc, regmap);
  1676. if (ret) {
  1677. dev_err(&pdev->dev, "Failed to register DISP CC clocks\n");
  1678. return ret;
  1679. }
  1680. ret = register_qcom_clks_pm(pdev, false, &disp_cc_sm8250_desc);
  1681. if (ret)
  1682. dev_err(&pdev->dev, "Failed to register for pm ops\n");
  1683. pm_runtime_put_sync(&pdev->dev);
  1684. dev_info(&pdev->dev, "Registered DISP CC clocks\n");
  1685. return ret;
  1686. }
  1687. static void disp_cc_sm8250_sync_state(struct device *dev)
  1688. {
  1689. qcom_cc_sync_state(dev, &disp_cc_sm8250_desc);
  1690. }
  1691. static struct platform_driver disp_cc_sm8250_driver = {
  1692. .probe = disp_cc_sm8250_probe,
  1693. .driver = {
  1694. .name = "disp_cc-sm8250",
  1695. .of_match_table = disp_cc_sm8250_match_table,
  1696. .sync_state = disp_cc_sm8250_sync_state,
  1697. },
  1698. };
  1699. static int __init disp_cc_sm8250_init(void)
  1700. {
  1701. return platform_driver_register(&disp_cc_sm8250_driver);
  1702. }
  1703. subsys_initcall(disp_cc_sm8250_init);
  1704. static void __exit disp_cc_sm8250_exit(void)
  1705. {
  1706. platform_driver_unregister(&disp_cc_sm8250_driver);
  1707. }
  1708. module_exit(disp_cc_sm8250_exit);
  1709. MODULE_DESCRIPTION("QTI DISPCC SM8250 Driver");
  1710. MODULE_LICENSE("GPL v2");