dispcc-sm8250.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2018-2020, 2022, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/module.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/pm_runtime.h>
  9. #include <linux/regmap.h>
  10. #include <linux/reset-controller.h>
  11. #include <dt-bindings/clock/qcom,dispcc-sm8250.h>
  12. #include "clk-alpha-pll.h"
  13. #include "clk-branch.h"
  14. #include "clk-rcg.h"
  15. #include "clk-regmap-divider.h"
  16. #include "common.h"
  17. #include "gdsc.h"
  18. #include "reset.h"
  19. enum {
  20. P_BI_TCXO,
  21. P_DISP_CC_PLL0_OUT_MAIN,
  22. P_DISP_CC_PLL1_OUT_EVEN,
  23. P_DISP_CC_PLL1_OUT_MAIN,
  24. P_DP_PHY_PLL_LINK_CLK,
  25. P_DP_PHY_PLL_VCO_DIV_CLK,
  26. P_DPTX1_PHY_PLL_LINK_CLK,
  27. P_DPTX1_PHY_PLL_VCO_DIV_CLK,
  28. P_DPTX2_PHY_PLL_LINK_CLK,
  29. P_DPTX2_PHY_PLL_VCO_DIV_CLK,
  30. P_EDP_PHY_PLL_LINK_CLK,
  31. P_EDP_PHY_PLL_VCO_DIV_CLK,
  32. P_DSI0_PHY_PLL_OUT_BYTECLK,
  33. P_DSI0_PHY_PLL_OUT_DSICLK,
  34. P_DSI1_PHY_PLL_OUT_BYTECLK,
  35. P_DSI1_PHY_PLL_OUT_DSICLK,
  36. };
  37. static const struct pll_vco vco_table[] = {
  38. { 249600000, 2000000000, 0 },
  39. };
  40. static const struct pll_vco lucid_5lpe_vco[] = {
  41. { 249600000, 1750000000, 0 },
  42. };
  43. static struct alpha_pll_config disp_cc_pll0_config = {
  44. .l = 0x47,
  45. .alpha = 0xE000,
  46. .config_ctl_val = 0x20485699,
  47. .config_ctl_hi_val = 0x00002261,
  48. .config_ctl_hi1_val = 0x329A699C,
  49. .user_ctl_val = 0x00000000,
  50. .user_ctl_hi_val = 0x00000805,
  51. .user_ctl_hi1_val = 0x00000000,
  52. };
  53. static struct clk_init_data disp_cc_pll0_init = {
  54. .name = "disp_cc_pll0",
  55. .parent_data = &(const struct clk_parent_data){
  56. .fw_name = "bi_tcxo",
  57. },
  58. .num_parents = 1,
  59. .ops = &clk_alpha_pll_lucid_ops,
  60. };
  61. static struct clk_alpha_pll disp_cc_pll0 = {
  62. .offset = 0x0,
  63. .vco_table = vco_table,
  64. .num_vco = ARRAY_SIZE(vco_table),
  65. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  66. .clkr.hw.init = &disp_cc_pll0_init
  67. };
  68. static struct alpha_pll_config disp_cc_pll1_config = {
  69. .l = 0x1F,
  70. .alpha = 0x4000,
  71. .config_ctl_val = 0x20485699,
  72. .config_ctl_hi_val = 0x00002261,
  73. .config_ctl_hi1_val = 0x329A699C,
  74. .user_ctl_val = 0x00000000,
  75. .user_ctl_hi_val = 0x00000805,
  76. .user_ctl_hi1_val = 0x00000000,
  77. };
  78. static struct clk_init_data disp_cc_pll1_init = {
  79. .name = "disp_cc_pll1",
  80. .parent_data = &(const struct clk_parent_data){
  81. .fw_name = "bi_tcxo",
  82. },
  83. .num_parents = 1,
  84. .ops = &clk_alpha_pll_lucid_ops,
  85. };
  86. static struct clk_alpha_pll disp_cc_pll1 = {
  87. .offset = 0x1000,
  88. .vco_table = vco_table,
  89. .num_vco = ARRAY_SIZE(vco_table),
  90. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  91. .clkr.hw.init = &disp_cc_pll1_init
  92. };
  93. static const struct parent_map disp_cc_parent_map_0[] = {
  94. { P_BI_TCXO, 0 },
  95. { P_DP_PHY_PLL_LINK_CLK, 1 },
  96. { P_DP_PHY_PLL_VCO_DIV_CLK, 2 },
  97. { P_DPTX1_PHY_PLL_LINK_CLK, 3 },
  98. { P_DPTX1_PHY_PLL_VCO_DIV_CLK, 4 },
  99. { P_DPTX2_PHY_PLL_LINK_CLK, 5 },
  100. { P_DPTX2_PHY_PLL_VCO_DIV_CLK, 6 },
  101. };
  102. static const struct clk_parent_data disp_cc_parent_data_0[] = {
  103. { .fw_name = "bi_tcxo" },
  104. { .fw_name = "dp_phy_pll_link_clk" },
  105. { .fw_name = "dp_phy_pll_vco_div_clk" },
  106. { .fw_name = "dptx1_phy_pll_link_clk" },
  107. { .fw_name = "dptx1_phy_pll_vco_div_clk" },
  108. { .fw_name = "dptx2_phy_pll_link_clk" },
  109. { .fw_name = "dptx2_phy_pll_vco_div_clk" },
  110. };
  111. static const struct parent_map disp_cc_parent_map_1[] = {
  112. { P_BI_TCXO, 0 },
  113. };
  114. static const struct clk_parent_data disp_cc_parent_data_1[] = {
  115. { .fw_name = "bi_tcxo" },
  116. };
  117. static const struct parent_map disp_cc_parent_map_2[] = {
  118. { P_BI_TCXO, 0 },
  119. { P_DSI0_PHY_PLL_OUT_BYTECLK, 1 },
  120. { P_DSI1_PHY_PLL_OUT_BYTECLK, 2 },
  121. };
  122. static const struct clk_parent_data disp_cc_parent_data_2[] = {
  123. { .fw_name = "bi_tcxo" },
  124. { .fw_name = "dsi0_phy_pll_out_byteclk" },
  125. { .fw_name = "dsi1_phy_pll_out_byteclk" },
  126. };
  127. static const struct parent_map disp_cc_parent_map_3[] = {
  128. { P_BI_TCXO, 0 },
  129. { P_DISP_CC_PLL1_OUT_MAIN, 4 },
  130. };
  131. static const struct clk_parent_data disp_cc_parent_data_3[] = {
  132. { .fw_name = "bi_tcxo" },
  133. { .hw = &disp_cc_pll1.clkr.hw },
  134. };
  135. static const struct parent_map disp_cc_parent_map_4[] = {
  136. { P_BI_TCXO, 0 },
  137. { P_EDP_PHY_PLL_LINK_CLK, 1 },
  138. { P_EDP_PHY_PLL_VCO_DIV_CLK, 2},
  139. };
  140. static const struct clk_parent_data disp_cc_parent_data_4[] = {
  141. { .fw_name = "bi_tcxo" },
  142. { .fw_name = "edp_phy_pll_link_clk" },
  143. { .fw_name = "edp_phy_pll_vco_div_clk" },
  144. };
  145. static const struct parent_map disp_cc_parent_map_5[] = {
  146. { P_BI_TCXO, 0 },
  147. { P_DISP_CC_PLL0_OUT_MAIN, 1 },
  148. { P_DISP_CC_PLL1_OUT_MAIN, 4 },
  149. };
  150. static const struct clk_parent_data disp_cc_parent_data_5[] = {
  151. { .fw_name = "bi_tcxo" },
  152. { .hw = &disp_cc_pll0.clkr.hw },
  153. { .hw = &disp_cc_pll1.clkr.hw },
  154. };
  155. static const struct parent_map disp_cc_parent_map_6[] = {
  156. { P_BI_TCXO, 0 },
  157. { P_DSI0_PHY_PLL_OUT_DSICLK, 1 },
  158. { P_DSI1_PHY_PLL_OUT_DSICLK, 2 },
  159. };
  160. static const struct clk_parent_data disp_cc_parent_data_6[] = {
  161. { .fw_name = "bi_tcxo" },
  162. { .fw_name = "dsi0_phy_pll_out_dsiclk" },
  163. { .fw_name = "dsi1_phy_pll_out_dsiclk" },
  164. };
  165. static const struct parent_map disp_cc_parent_map_7[] = {
  166. { P_BI_TCXO, 0 },
  167. { P_DISP_CC_PLL1_OUT_MAIN, 4 },
  168. /* { P_DISP_CC_PLL1_OUT_EVEN, 5 }, */
  169. };
  170. static const struct clk_parent_data disp_cc_parent_data_7[] = {
  171. { .fw_name = "bi_tcxo" },
  172. { .hw = &disp_cc_pll1.clkr.hw },
  173. /* { .hw = &disp_cc_pll1_out_even.clkr.hw }, */
  174. };
  175. static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = {
  176. F(19200000, P_BI_TCXO, 1, 0, 0),
  177. F(37500000, P_DISP_CC_PLL1_OUT_MAIN, 16, 0, 0),
  178. F(75000000, P_DISP_CC_PLL1_OUT_MAIN, 8, 0, 0),
  179. { }
  180. };
  181. static struct clk_rcg2 disp_cc_mdss_ahb_clk_src = {
  182. .cmd_rcgr = 0x22bc,
  183. .mnd_width = 0,
  184. .hid_width = 5,
  185. .parent_map = disp_cc_parent_map_3,
  186. .freq_tbl = ftbl_disp_cc_mdss_ahb_clk_src,
  187. .clkr.hw.init = &(const struct clk_init_data) {
  188. .name = "disp_cc_mdss_ahb_clk_src",
  189. .parent_data = disp_cc_parent_data_3,
  190. .num_parents = ARRAY_SIZE(disp_cc_parent_data_3),
  191. .flags = CLK_SET_RATE_PARENT,
  192. .ops = &clk_rcg2_shared_ops,
  193. },
  194. };
  195. static const struct freq_tbl ftbl_disp_cc_mdss_byte0_clk_src[] = {
  196. F(19200000, P_BI_TCXO, 1, 0, 0),
  197. { }
  198. };
  199. static struct clk_rcg2 disp_cc_mdss_byte0_clk_src = {
  200. .cmd_rcgr = 0x2110,
  201. .mnd_width = 0,
  202. .hid_width = 5,
  203. .parent_map = disp_cc_parent_map_2,
  204. .clkr.hw.init = &(const struct clk_init_data) {
  205. .name = "disp_cc_mdss_byte0_clk_src",
  206. .parent_data = disp_cc_parent_data_2,
  207. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  208. .flags = CLK_SET_RATE_PARENT,
  209. .ops = &clk_byte2_ops,
  210. },
  211. };
  212. static struct clk_rcg2 disp_cc_mdss_byte1_clk_src = {
  213. .cmd_rcgr = 0x212c,
  214. .mnd_width = 0,
  215. .hid_width = 5,
  216. .parent_map = disp_cc_parent_map_2,
  217. .clkr.hw.init = &(const struct clk_init_data) {
  218. .name = "disp_cc_mdss_byte1_clk_src",
  219. .parent_data = disp_cc_parent_data_2,
  220. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  221. .flags = CLK_SET_RATE_PARENT,
  222. .ops = &clk_byte2_ops,
  223. },
  224. };
  225. static struct clk_rcg2 disp_cc_mdss_dp_aux1_clk_src = {
  226. .cmd_rcgr = 0x2240,
  227. .mnd_width = 0,
  228. .hid_width = 5,
  229. .parent_map = disp_cc_parent_map_1,
  230. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  231. .clkr.hw.init = &(const struct clk_init_data) {
  232. .name = "disp_cc_mdss_dp_aux1_clk_src",
  233. .parent_data = disp_cc_parent_data_1,
  234. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  235. .flags = CLK_SET_RATE_PARENT,
  236. .ops = &clk_rcg2_ops,
  237. },
  238. };
  239. static struct clk_rcg2 disp_cc_mdss_dp_aux_clk_src = {
  240. .cmd_rcgr = 0x21dc,
  241. .mnd_width = 0,
  242. .hid_width = 5,
  243. .parent_map = disp_cc_parent_map_1,
  244. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  245. .clkr.hw.init = &(const struct clk_init_data) {
  246. .name = "disp_cc_mdss_dp_aux_clk_src",
  247. .parent_data = disp_cc_parent_data_1,
  248. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  249. .flags = CLK_SET_RATE_PARENT,
  250. .ops = &clk_rcg2_ops,
  251. },
  252. };
  253. static struct clk_rcg2 disp_cc_mdss_dp_link1_clk_src = {
  254. .cmd_rcgr = 0x220c,
  255. .mnd_width = 0,
  256. .hid_width = 5,
  257. .parent_map = disp_cc_parent_map_0,
  258. .clkr.hw.init = &(const struct clk_init_data) {
  259. .name = "disp_cc_mdss_dp_link1_clk_src",
  260. .parent_data = disp_cc_parent_data_0,
  261. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  262. .ops = &clk_byte2_ops,
  263. },
  264. };
  265. static struct clk_rcg2 disp_cc_mdss_dp_link_clk_src = {
  266. .cmd_rcgr = 0x2178,
  267. .mnd_width = 0,
  268. .hid_width = 5,
  269. .parent_map = disp_cc_parent_map_0,
  270. .clkr.hw.init = &(const struct clk_init_data) {
  271. .name = "disp_cc_mdss_dp_link_clk_src",
  272. .parent_data = disp_cc_parent_data_0,
  273. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  274. .ops = &clk_byte2_ops,
  275. },
  276. };
  277. static struct clk_rcg2 disp_cc_mdss_dp_pixel1_clk_src = {
  278. .cmd_rcgr = 0x21c4,
  279. .mnd_width = 16,
  280. .hid_width = 5,
  281. .parent_map = disp_cc_parent_map_0,
  282. .clkr.hw.init = &(const struct clk_init_data) {
  283. .name = "disp_cc_mdss_dp_pixel1_clk_src",
  284. .parent_data = disp_cc_parent_data_0,
  285. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  286. .ops = &clk_dp_ops,
  287. },
  288. };
  289. static struct clk_rcg2 disp_cc_mdss_dp_pixel2_clk_src = {
  290. .cmd_rcgr = 0x21f4,
  291. .mnd_width = 16,
  292. .hid_width = 5,
  293. .parent_map = disp_cc_parent_map_0,
  294. .clkr.hw.init = &(const struct clk_init_data) {
  295. .name = "disp_cc_mdss_dp_pixel2_clk_src",
  296. .parent_data = disp_cc_parent_data_0,
  297. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  298. .ops = &clk_dp_ops,
  299. },
  300. };
  301. static struct clk_rcg2 disp_cc_mdss_dp_pixel_clk_src = {
  302. .cmd_rcgr = 0x21ac,
  303. .mnd_width = 16,
  304. .hid_width = 5,
  305. .parent_map = disp_cc_parent_map_0,
  306. .clkr.hw.init = &(const struct clk_init_data) {
  307. .name = "disp_cc_mdss_dp_pixel_clk_src",
  308. .parent_data = disp_cc_parent_data_0,
  309. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  310. .ops = &clk_dp_ops,
  311. },
  312. };
  313. static struct clk_rcg2 disp_cc_mdss_edp_aux_clk_src = {
  314. .cmd_rcgr = 0x228c,
  315. .mnd_width = 0,
  316. .hid_width = 5,
  317. .parent_map = disp_cc_parent_map_1,
  318. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  319. .clkr.hw.init = &(const struct clk_init_data) {
  320. .name = "disp_cc_mdss_edp_aux_clk_src",
  321. .parent_data = disp_cc_parent_data_1,
  322. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  323. .flags = CLK_SET_RATE_PARENT,
  324. .ops = &clk_rcg2_ops,
  325. },
  326. };
  327. static struct clk_rcg2 disp_cc_mdss_edp_gtc_clk_src = {
  328. .cmd_rcgr = 0x22a4,
  329. .mnd_width = 0,
  330. .hid_width = 5,
  331. .parent_map = disp_cc_parent_map_7,
  332. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  333. .clkr.hw.init = &(const struct clk_init_data) {
  334. .name = "disp_cc_mdss_edp_gtc_clk_src",
  335. .parent_data = disp_cc_parent_data_7,
  336. .num_parents = ARRAY_SIZE(disp_cc_parent_data_7),
  337. .flags = CLK_SET_RATE_PARENT,
  338. .ops = &clk_rcg2_ops,
  339. },
  340. };
  341. static struct clk_rcg2 disp_cc_mdss_edp_link_clk_src = {
  342. .cmd_rcgr = 0x2270,
  343. .mnd_width = 0,
  344. .hid_width = 5,
  345. .parent_map = disp_cc_parent_map_4,
  346. .clkr.hw.init = &(const struct clk_init_data) {
  347. .name = "disp_cc_mdss_edp_link_clk_src",
  348. .parent_data = disp_cc_parent_data_4,
  349. .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
  350. .flags = CLK_SET_RATE_PARENT,
  351. .ops = &clk_byte2_ops,
  352. },
  353. };
  354. static struct clk_rcg2 disp_cc_mdss_edp_pixel_clk_src = {
  355. .cmd_rcgr = 0x2258,
  356. .mnd_width = 16,
  357. .hid_width = 5,
  358. .parent_map = disp_cc_parent_map_4,
  359. .clkr.hw.init = &(const struct clk_init_data) {
  360. .name = "disp_cc_mdss_edp_pixel_clk_src",
  361. .parent_data = disp_cc_parent_data_4,
  362. .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
  363. .ops = &clk_dp_ops,
  364. },
  365. };
  366. static struct clk_branch disp_cc_mdss_edp_aux_clk = {
  367. .halt_reg = 0x2078,
  368. .halt_check = BRANCH_HALT,
  369. .clkr = {
  370. .enable_reg = 0x2078,
  371. .enable_mask = BIT(0),
  372. .hw.init = &(const struct clk_init_data) {
  373. .name = "disp_cc_mdss_edp_aux_clk",
  374. .parent_hws = (const struct clk_hw*[]){
  375. &disp_cc_mdss_edp_aux_clk_src.clkr.hw,
  376. },
  377. .num_parents = 1,
  378. .flags = CLK_SET_RATE_PARENT,
  379. .ops = &clk_branch2_ops,
  380. },
  381. },
  382. };
  383. static struct clk_branch disp_cc_mdss_edp_gtc_clk = {
  384. .halt_reg = 0x207c,
  385. .halt_check = BRANCH_HALT,
  386. .clkr = {
  387. .enable_reg = 0x207c,
  388. .enable_mask = BIT(0),
  389. .hw.init = &(const struct clk_init_data) {
  390. .name = "disp_cc_mdss_edp_gtc_clk",
  391. .parent_hws = (const struct clk_hw*[]){
  392. &disp_cc_mdss_edp_gtc_clk_src.clkr.hw,
  393. },
  394. .num_parents = 1,
  395. .flags = CLK_SET_RATE_PARENT,
  396. .ops = &clk_branch2_ops,
  397. },
  398. },
  399. };
  400. static struct clk_branch disp_cc_mdss_edp_link_clk = {
  401. .halt_reg = 0x2070,
  402. .halt_check = BRANCH_HALT,
  403. .clkr = {
  404. .enable_reg = 0x2070,
  405. .enable_mask = BIT(0),
  406. .hw.init = &(const struct clk_init_data) {
  407. .name = "disp_cc_mdss_edp_link_clk",
  408. .parent_hws = (const struct clk_hw*[]){
  409. &disp_cc_mdss_edp_link_clk_src.clkr.hw,
  410. },
  411. .num_parents = 1,
  412. .flags = CLK_SET_RATE_PARENT,
  413. .ops = &clk_branch2_ops,
  414. },
  415. },
  416. };
  417. static struct clk_regmap_div disp_cc_mdss_edp_link_div_clk_src = {
  418. .reg = 0x2288,
  419. .shift = 0,
  420. .width = 2,
  421. .clkr.hw.init = &(const struct clk_init_data) {
  422. .name = "disp_cc_mdss_edp_link_div_clk_src",
  423. .parent_hws = (const struct clk_hw*[]){
  424. &disp_cc_mdss_edp_link_clk_src.clkr.hw,
  425. },
  426. .num_parents = 1,
  427. .ops = &clk_regmap_div_ro_ops,
  428. },
  429. };
  430. static struct clk_branch disp_cc_mdss_edp_link_intf_clk = {
  431. .halt_reg = 0x2074,
  432. .halt_check = BRANCH_HALT,
  433. .clkr = {
  434. .enable_reg = 0x2074,
  435. .enable_mask = BIT(0),
  436. .hw.init = &(const struct clk_init_data) {
  437. .name = "disp_cc_mdss_edp_link_intf_clk",
  438. .parent_hws = (const struct clk_hw*[]){
  439. &disp_cc_mdss_edp_link_div_clk_src.clkr.hw,
  440. },
  441. .num_parents = 1,
  442. .flags = CLK_GET_RATE_NOCACHE,
  443. .ops = &clk_branch2_ops,
  444. },
  445. },
  446. };
  447. static struct clk_branch disp_cc_mdss_edp_pixel_clk = {
  448. .halt_reg = 0x206c,
  449. .halt_check = BRANCH_HALT,
  450. .clkr = {
  451. .enable_reg = 0x206c,
  452. .enable_mask = BIT(0),
  453. .hw.init = &(const struct clk_init_data) {
  454. .name = "disp_cc_mdss_edp_pixel_clk",
  455. .parent_hws = (const struct clk_hw*[]){
  456. &disp_cc_mdss_edp_pixel_clk_src.clkr.hw,
  457. },
  458. .num_parents = 1,
  459. .flags = CLK_SET_RATE_PARENT,
  460. .ops = &clk_branch2_ops,
  461. },
  462. },
  463. };
  464. static struct clk_rcg2 disp_cc_mdss_esc0_clk_src = {
  465. .cmd_rcgr = 0x2148,
  466. .mnd_width = 0,
  467. .hid_width = 5,
  468. .parent_map = disp_cc_parent_map_2,
  469. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  470. .clkr.hw.init = &(const struct clk_init_data) {
  471. .name = "disp_cc_mdss_esc0_clk_src",
  472. .parent_data = disp_cc_parent_data_2,
  473. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  474. .flags = CLK_SET_RATE_PARENT,
  475. .ops = &clk_rcg2_ops,
  476. },
  477. };
  478. static struct clk_rcg2 disp_cc_mdss_esc1_clk_src = {
  479. .cmd_rcgr = 0x2160,
  480. .mnd_width = 0,
  481. .hid_width = 5,
  482. .parent_map = disp_cc_parent_map_2,
  483. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  484. .clkr.hw.init = &(const struct clk_init_data) {
  485. .name = "disp_cc_mdss_esc1_clk_src",
  486. .parent_data = disp_cc_parent_data_2,
  487. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  488. .flags = CLK_SET_RATE_PARENT,
  489. .ops = &clk_rcg2_ops,
  490. },
  491. };
  492. static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src[] = {
  493. F(19200000, P_BI_TCXO, 1, 0, 0),
  494. F(85714286, P_DISP_CC_PLL1_OUT_MAIN, 7, 0, 0),
  495. F(100000000, P_DISP_CC_PLL1_OUT_MAIN, 6, 0, 0),
  496. F(150000000, P_DISP_CC_PLL1_OUT_MAIN, 4, 0, 0),
  497. F(200000000, P_DISP_CC_PLL1_OUT_MAIN, 3, 0, 0),
  498. F(300000000, P_DISP_CC_PLL1_OUT_MAIN, 2, 0, 0),
  499. F(345000000, P_DISP_CC_PLL0_OUT_MAIN, 4, 0, 0),
  500. F(460000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  501. { }
  502. };
  503. static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = {
  504. .cmd_rcgr = 0x20c8,
  505. .mnd_width = 0,
  506. .hid_width = 5,
  507. .parent_map = disp_cc_parent_map_5,
  508. .freq_tbl = ftbl_disp_cc_mdss_mdp_clk_src,
  509. .clkr.hw.init = &(const struct clk_init_data) {
  510. .name = "disp_cc_mdss_mdp_clk_src",
  511. .parent_data = disp_cc_parent_data_5,
  512. .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
  513. .flags = CLK_SET_RATE_PARENT,
  514. .ops = &clk_rcg2_shared_ops,
  515. },
  516. };
  517. static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = {
  518. .cmd_rcgr = 0x2098,
  519. .mnd_width = 8,
  520. .hid_width = 5,
  521. .parent_map = disp_cc_parent_map_6,
  522. .clkr.hw.init = &(const struct clk_init_data) {
  523. .name = "disp_cc_mdss_pclk0_clk_src",
  524. .parent_data = disp_cc_parent_data_6,
  525. .num_parents = ARRAY_SIZE(disp_cc_parent_data_6),
  526. .flags = CLK_SET_RATE_PARENT,
  527. .ops = &clk_pixel_ops,
  528. },
  529. };
  530. static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = {
  531. .cmd_rcgr = 0x20b0,
  532. .mnd_width = 8,
  533. .hid_width = 5,
  534. .parent_map = disp_cc_parent_map_6,
  535. .clkr.hw.init = &(const struct clk_init_data) {
  536. .name = "disp_cc_mdss_pclk1_clk_src",
  537. .parent_data = disp_cc_parent_data_6,
  538. .num_parents = ARRAY_SIZE(disp_cc_parent_data_6),
  539. .flags = CLK_SET_RATE_PARENT,
  540. .ops = &clk_pixel_ops,
  541. },
  542. };
  543. static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src[] = {
  544. F(19200000, P_BI_TCXO, 1, 0, 0),
  545. F(200000000, P_DISP_CC_PLL1_OUT_MAIN, 3, 0, 0),
  546. F(300000000, P_DISP_CC_PLL1_OUT_MAIN, 2, 0, 0),
  547. F(345000000, P_DISP_CC_PLL0_OUT_MAIN, 4, 0, 0),
  548. F(460000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  549. { }
  550. };
  551. static struct clk_rcg2 disp_cc_mdss_rot_clk_src = {
  552. .cmd_rcgr = 0x20e0,
  553. .mnd_width = 0,
  554. .hid_width = 5,
  555. .parent_map = disp_cc_parent_map_5,
  556. .freq_tbl = ftbl_disp_cc_mdss_rot_clk_src,
  557. .clkr.hw.init = &(const struct clk_init_data) {
  558. .name = "disp_cc_mdss_rot_clk_src",
  559. .parent_data = disp_cc_parent_data_5,
  560. .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
  561. .flags = CLK_SET_RATE_PARENT,
  562. .ops = &clk_rcg2_shared_ops,
  563. },
  564. };
  565. static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = {
  566. .cmd_rcgr = 0x20f8,
  567. .mnd_width = 0,
  568. .hid_width = 5,
  569. .parent_map = disp_cc_parent_map_1,
  570. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  571. .clkr.hw.init = &(const struct clk_init_data) {
  572. .name = "disp_cc_mdss_vsync_clk_src",
  573. .parent_data = disp_cc_parent_data_1,
  574. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  575. .flags = CLK_SET_RATE_PARENT,
  576. .ops = &clk_rcg2_ops,
  577. },
  578. };
  579. static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = {
  580. .reg = 0x2128,
  581. .shift = 0,
  582. .width = 2,
  583. .clkr.hw.init = &(const struct clk_init_data) {
  584. .name = "disp_cc_mdss_byte0_div_clk_src",
  585. .parent_hws = (const struct clk_hw*[]){
  586. &disp_cc_mdss_byte0_clk_src.clkr.hw,
  587. },
  588. .num_parents = 1,
  589. .ops = &clk_regmap_div_ops,
  590. },
  591. };
  592. static struct clk_regmap_div disp_cc_mdss_byte1_div_clk_src = {
  593. .reg = 0x2144,
  594. .shift = 0,
  595. .width = 2,
  596. .clkr.hw.init = &(const struct clk_init_data) {
  597. .name = "disp_cc_mdss_byte1_div_clk_src",
  598. .parent_hws = (const struct clk_hw*[]){
  599. &disp_cc_mdss_byte1_clk_src.clkr.hw,
  600. },
  601. .num_parents = 1,
  602. .ops = &clk_regmap_div_ops,
  603. },
  604. };
  605. static struct clk_regmap_div disp_cc_mdss_dp_link1_div_clk_src = {
  606. .reg = 0x2224,
  607. .shift = 0,
  608. .width = 2,
  609. .clkr.hw.init = &(const struct clk_init_data) {
  610. .name = "disp_cc_mdss_dp_link1_div_clk_src",
  611. .parent_hws = (const struct clk_hw*[]){
  612. &disp_cc_mdss_dp_link1_clk_src.clkr.hw,
  613. },
  614. .num_parents = 1,
  615. .ops = &clk_regmap_div_ro_ops,
  616. },
  617. };
  618. static struct clk_regmap_div disp_cc_mdss_dp_link_div_clk_src = {
  619. .reg = 0x2190,
  620. .shift = 0,
  621. .width = 2,
  622. .clkr.hw.init = &(const struct clk_init_data) {
  623. .name = "disp_cc_mdss_dp_link_div_clk_src",
  624. .parent_hws = (const struct clk_hw*[]){
  625. &disp_cc_mdss_dp_link_clk_src.clkr.hw,
  626. },
  627. .num_parents = 1,
  628. .ops = &clk_regmap_div_ro_ops,
  629. },
  630. };
  631. static struct clk_branch disp_cc_mdss_ahb_clk = {
  632. .halt_reg = 0x2080,
  633. .halt_check = BRANCH_HALT,
  634. .clkr = {
  635. .enable_reg = 0x2080,
  636. .enable_mask = BIT(0),
  637. .hw.init = &(const struct clk_init_data) {
  638. .name = "disp_cc_mdss_ahb_clk",
  639. .parent_hws = (const struct clk_hw*[]){
  640. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  641. },
  642. .num_parents = 1,
  643. .flags = CLK_SET_RATE_PARENT,
  644. .ops = &clk_branch2_ops,
  645. },
  646. },
  647. };
  648. static struct clk_branch disp_cc_mdss_byte0_clk = {
  649. .halt_reg = 0x2028,
  650. .halt_check = BRANCH_HALT,
  651. .clkr = {
  652. .enable_reg = 0x2028,
  653. .enable_mask = BIT(0),
  654. .hw.init = &(const struct clk_init_data) {
  655. .name = "disp_cc_mdss_byte0_clk",
  656. .parent_hws = (const struct clk_hw*[]){
  657. &disp_cc_mdss_byte0_clk_src.clkr.hw,
  658. },
  659. .num_parents = 1,
  660. .flags = CLK_SET_RATE_PARENT,
  661. .ops = &clk_branch2_ops,
  662. },
  663. },
  664. };
  665. static struct clk_branch disp_cc_mdss_byte0_intf_clk = {
  666. .halt_reg = 0x202c,
  667. .halt_check = BRANCH_HALT,
  668. .clkr = {
  669. .enable_reg = 0x202c,
  670. .enable_mask = BIT(0),
  671. .hw.init = &(const struct clk_init_data) {
  672. .name = "disp_cc_mdss_byte0_intf_clk",
  673. .parent_hws = (const struct clk_hw*[]){
  674. &disp_cc_mdss_byte0_div_clk_src.clkr.hw,
  675. },
  676. .num_parents = 1,
  677. .flags = CLK_SET_RATE_PARENT,
  678. .ops = &clk_branch2_ops,
  679. },
  680. },
  681. };
  682. static struct clk_branch disp_cc_mdss_byte1_clk = {
  683. .halt_reg = 0x2030,
  684. .halt_check = BRANCH_HALT,
  685. .clkr = {
  686. .enable_reg = 0x2030,
  687. .enable_mask = BIT(0),
  688. .hw.init = &(const struct clk_init_data) {
  689. .name = "disp_cc_mdss_byte1_clk",
  690. .parent_hws = (const struct clk_hw*[]){
  691. &disp_cc_mdss_byte1_clk_src.clkr.hw,
  692. },
  693. .num_parents = 1,
  694. .flags = CLK_SET_RATE_PARENT,
  695. .ops = &clk_branch2_ops,
  696. },
  697. },
  698. };
  699. static struct clk_branch disp_cc_mdss_byte1_intf_clk = {
  700. .halt_reg = 0x2034,
  701. .halt_check = BRANCH_HALT,
  702. .clkr = {
  703. .enable_reg = 0x2034,
  704. .enable_mask = BIT(0),
  705. .hw.init = &(const struct clk_init_data) {
  706. .name = "disp_cc_mdss_byte1_intf_clk",
  707. .parent_hws = (const struct clk_hw*[]){
  708. &disp_cc_mdss_byte1_div_clk_src.clkr.hw,
  709. },
  710. .num_parents = 1,
  711. .flags = CLK_SET_RATE_PARENT,
  712. .ops = &clk_branch2_ops,
  713. },
  714. },
  715. };
  716. static struct clk_branch disp_cc_mdss_dp_aux1_clk = {
  717. .halt_reg = 0x2068,
  718. .halt_check = BRANCH_HALT,
  719. .clkr = {
  720. .enable_reg = 0x2068,
  721. .enable_mask = BIT(0),
  722. .hw.init = &(const struct clk_init_data) {
  723. .name = "disp_cc_mdss_dp_aux1_clk",
  724. .parent_hws = (const struct clk_hw*[]){
  725. &disp_cc_mdss_dp_aux1_clk_src.clkr.hw,
  726. },
  727. .num_parents = 1,
  728. .flags = CLK_SET_RATE_PARENT,
  729. .ops = &clk_branch2_ops,
  730. },
  731. },
  732. };
  733. static struct clk_branch disp_cc_mdss_dp_aux_clk = {
  734. .halt_reg = 0x2054,
  735. .halt_check = BRANCH_HALT,
  736. .clkr = {
  737. .enable_reg = 0x2054,
  738. .enable_mask = BIT(0),
  739. .hw.init = &(const struct clk_init_data) {
  740. .name = "disp_cc_mdss_dp_aux_clk",
  741. .parent_hws = (const struct clk_hw*[]){
  742. &disp_cc_mdss_dp_aux_clk_src.clkr.hw,
  743. },
  744. .num_parents = 1,
  745. .flags = CLK_SET_RATE_PARENT,
  746. .ops = &clk_branch2_ops,
  747. },
  748. },
  749. };
  750. static struct clk_branch disp_cc_mdss_dp_link1_clk = {
  751. .halt_reg = 0x205c,
  752. .halt_check = BRANCH_HALT,
  753. .clkr = {
  754. .enable_reg = 0x205c,
  755. .enable_mask = BIT(0),
  756. .hw.init = &(const struct clk_init_data) {
  757. .name = "disp_cc_mdss_dp_link1_clk",
  758. .parent_hws = (const struct clk_hw*[]){
  759. &disp_cc_mdss_dp_link1_clk_src.clkr.hw,
  760. },
  761. .num_parents = 1,
  762. .flags = CLK_SET_RATE_PARENT,
  763. .ops = &clk_branch2_ops,
  764. },
  765. },
  766. };
  767. static struct clk_branch disp_cc_mdss_dp_link1_intf_clk = {
  768. .halt_reg = 0x2060,
  769. .halt_check = BRANCH_HALT,
  770. .clkr = {
  771. .enable_reg = 0x2060,
  772. .enable_mask = BIT(0),
  773. .hw.init = &(const struct clk_init_data) {
  774. .name = "disp_cc_mdss_dp_link1_intf_clk",
  775. .parent_hws = (const struct clk_hw*[]){
  776. &disp_cc_mdss_dp_link1_div_clk_src.clkr.hw,
  777. },
  778. .num_parents = 1,
  779. .flags = CLK_SET_RATE_PARENT,
  780. .ops = &clk_branch2_ops,
  781. },
  782. },
  783. };
  784. static struct clk_branch disp_cc_mdss_dp_link_clk = {
  785. .halt_reg = 0x2040,
  786. .halt_check = BRANCH_HALT,
  787. .clkr = {
  788. .enable_reg = 0x2040,
  789. .enable_mask = BIT(0),
  790. .hw.init = &(const struct clk_init_data) {
  791. .name = "disp_cc_mdss_dp_link_clk",
  792. .parent_hws = (const struct clk_hw*[]){
  793. &disp_cc_mdss_dp_link_clk_src.clkr.hw,
  794. },
  795. .num_parents = 1,
  796. .flags = CLK_SET_RATE_PARENT,
  797. .ops = &clk_branch2_ops,
  798. },
  799. },
  800. };
  801. static struct clk_branch disp_cc_mdss_dp_link_intf_clk = {
  802. .halt_reg = 0x2044,
  803. .halt_check = BRANCH_HALT,
  804. .clkr = {
  805. .enable_reg = 0x2044,
  806. .enable_mask = BIT(0),
  807. .hw.init = &(const struct clk_init_data) {
  808. .name = "disp_cc_mdss_dp_link_intf_clk",
  809. .parent_hws = (const struct clk_hw*[]){
  810. &disp_cc_mdss_dp_link_div_clk_src.clkr.hw,
  811. },
  812. .num_parents = 1,
  813. .flags = CLK_SET_RATE_PARENT,
  814. .ops = &clk_branch2_ops,
  815. },
  816. },
  817. };
  818. static struct clk_branch disp_cc_mdss_dp_pixel1_clk = {
  819. .halt_reg = 0x2050,
  820. .halt_check = BRANCH_HALT,
  821. .clkr = {
  822. .enable_reg = 0x2050,
  823. .enable_mask = BIT(0),
  824. .hw.init = &(const struct clk_init_data) {
  825. .name = "disp_cc_mdss_dp_pixel1_clk",
  826. .parent_hws = (const struct clk_hw*[]){
  827. &disp_cc_mdss_dp_pixel1_clk_src.clkr.hw,
  828. },
  829. .num_parents = 1,
  830. .flags = CLK_SET_RATE_PARENT,
  831. .ops = &clk_branch2_ops,
  832. },
  833. },
  834. };
  835. static struct clk_branch disp_cc_mdss_dp_pixel2_clk = {
  836. .halt_reg = 0x2058,
  837. .halt_check = BRANCH_HALT,
  838. .clkr = {
  839. .enable_reg = 0x2058,
  840. .enable_mask = BIT(0),
  841. .hw.init = &(const struct clk_init_data) {
  842. .name = "disp_cc_mdss_dp_pixel2_clk",
  843. .parent_hws = (const struct clk_hw*[]){
  844. &disp_cc_mdss_dp_pixel2_clk_src.clkr.hw,
  845. },
  846. .num_parents = 1,
  847. .flags = CLK_SET_RATE_PARENT,
  848. .ops = &clk_branch2_ops,
  849. },
  850. },
  851. };
  852. static struct clk_branch disp_cc_mdss_dp_pixel_clk = {
  853. .halt_reg = 0x204c,
  854. .halt_check = BRANCH_HALT,
  855. .clkr = {
  856. .enable_reg = 0x204c,
  857. .enable_mask = BIT(0),
  858. .hw.init = &(const struct clk_init_data) {
  859. .name = "disp_cc_mdss_dp_pixel_clk",
  860. .parent_hws = (const struct clk_hw*[]){
  861. &disp_cc_mdss_dp_pixel_clk_src.clkr.hw,
  862. },
  863. .num_parents = 1,
  864. .flags = CLK_SET_RATE_PARENT,
  865. .ops = &clk_branch2_ops,
  866. },
  867. },
  868. };
  869. static struct clk_branch disp_cc_mdss_esc0_clk = {
  870. .halt_reg = 0x2038,
  871. .halt_check = BRANCH_HALT,
  872. .clkr = {
  873. .enable_reg = 0x2038,
  874. .enable_mask = BIT(0),
  875. .hw.init = &(const struct clk_init_data) {
  876. .name = "disp_cc_mdss_esc0_clk",
  877. .parent_hws = (const struct clk_hw*[]){
  878. &disp_cc_mdss_esc0_clk_src.clkr.hw,
  879. },
  880. .num_parents = 1,
  881. .flags = CLK_SET_RATE_PARENT,
  882. .ops = &clk_branch2_ops,
  883. },
  884. },
  885. };
  886. static struct clk_branch disp_cc_mdss_esc1_clk = {
  887. .halt_reg = 0x203c,
  888. .halt_check = BRANCH_HALT,
  889. .clkr = {
  890. .enable_reg = 0x203c,
  891. .enable_mask = BIT(0),
  892. .hw.init = &(const struct clk_init_data) {
  893. .name = "disp_cc_mdss_esc1_clk",
  894. .parent_hws = (const struct clk_hw*[]){
  895. &disp_cc_mdss_esc1_clk_src.clkr.hw,
  896. },
  897. .num_parents = 1,
  898. .flags = CLK_SET_RATE_PARENT,
  899. .ops = &clk_branch2_ops,
  900. },
  901. },
  902. };
  903. static struct clk_branch disp_cc_mdss_mdp_clk = {
  904. .halt_reg = 0x200c,
  905. .halt_check = BRANCH_HALT,
  906. .clkr = {
  907. .enable_reg = 0x200c,
  908. .enable_mask = BIT(0),
  909. .hw.init = &(const struct clk_init_data) {
  910. .name = "disp_cc_mdss_mdp_clk",
  911. .parent_hws = (const struct clk_hw*[]){
  912. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  913. },
  914. .num_parents = 1,
  915. .flags = CLK_SET_RATE_PARENT,
  916. .ops = &clk_branch2_ops,
  917. },
  918. },
  919. };
  920. static struct clk_branch disp_cc_mdss_mdp_lut_clk = {
  921. .halt_reg = 0x201c,
  922. .halt_check = BRANCH_VOTED,
  923. .clkr = {
  924. .enable_reg = 0x201c,
  925. .enable_mask = BIT(0),
  926. .hw.init = &(const struct clk_init_data) {
  927. .name = "disp_cc_mdss_mdp_lut_clk",
  928. .parent_hws = (const struct clk_hw*[]){
  929. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  930. },
  931. .num_parents = 1,
  932. .flags = CLK_SET_RATE_PARENT,
  933. .ops = &clk_branch2_ops,
  934. },
  935. },
  936. };
  937. static struct clk_branch disp_cc_mdss_non_gdsc_ahb_clk = {
  938. .halt_reg = 0x4004,
  939. .halt_check = BRANCH_VOTED,
  940. .clkr = {
  941. .enable_reg = 0x4004,
  942. .enable_mask = BIT(0),
  943. .hw.init = &(const struct clk_init_data) {
  944. .name = "disp_cc_mdss_non_gdsc_ahb_clk",
  945. .parent_hws = (const struct clk_hw*[]){
  946. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  947. },
  948. .num_parents = 1,
  949. .flags = CLK_SET_RATE_PARENT,
  950. .ops = &clk_branch2_ops,
  951. },
  952. },
  953. };
  954. static struct clk_branch disp_cc_mdss_pclk0_clk = {
  955. .halt_reg = 0x2004,
  956. .halt_check = BRANCH_HALT,
  957. .clkr = {
  958. .enable_reg = 0x2004,
  959. .enable_mask = BIT(0),
  960. .hw.init = &(const struct clk_init_data) {
  961. .name = "disp_cc_mdss_pclk0_clk",
  962. .parent_hws = (const struct clk_hw*[]){
  963. &disp_cc_mdss_pclk0_clk_src.clkr.hw,
  964. },
  965. .num_parents = 1,
  966. .flags = CLK_SET_RATE_PARENT,
  967. .ops = &clk_branch2_ops,
  968. },
  969. },
  970. };
  971. static struct clk_branch disp_cc_mdss_pclk1_clk = {
  972. .halt_reg = 0x2008,
  973. .halt_check = BRANCH_HALT,
  974. .clkr = {
  975. .enable_reg = 0x2008,
  976. .enable_mask = BIT(0),
  977. .hw.init = &(const struct clk_init_data) {
  978. .name = "disp_cc_mdss_pclk1_clk",
  979. .parent_hws = (const struct clk_hw*[]){
  980. &disp_cc_mdss_pclk1_clk_src.clkr.hw,
  981. },
  982. .num_parents = 1,
  983. .flags = CLK_SET_RATE_PARENT,
  984. .ops = &clk_branch2_ops,
  985. },
  986. },
  987. };
  988. static struct clk_branch disp_cc_mdss_rot_clk = {
  989. .halt_reg = 0x2014,
  990. .halt_check = BRANCH_HALT,
  991. .clkr = {
  992. .enable_reg = 0x2014,
  993. .enable_mask = BIT(0),
  994. .hw.init = &(const struct clk_init_data) {
  995. .name = "disp_cc_mdss_rot_clk",
  996. .parent_hws = (const struct clk_hw*[]){
  997. &disp_cc_mdss_rot_clk_src.clkr.hw,
  998. },
  999. .num_parents = 1,
  1000. .flags = CLK_SET_RATE_PARENT,
  1001. .ops = &clk_branch2_ops,
  1002. },
  1003. },
  1004. };
  1005. static struct clk_branch disp_cc_mdss_rscc_ahb_clk = {
  1006. .halt_reg = 0x400c,
  1007. .halt_check = BRANCH_HALT,
  1008. .clkr = {
  1009. .enable_reg = 0x400c,
  1010. .enable_mask = BIT(0),
  1011. .hw.init = &(const struct clk_init_data) {
  1012. .name = "disp_cc_mdss_rscc_ahb_clk",
  1013. .parent_hws = (const struct clk_hw*[]){
  1014. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  1015. },
  1016. .num_parents = 1,
  1017. .flags = CLK_SET_RATE_PARENT,
  1018. .ops = &clk_branch2_ops,
  1019. },
  1020. },
  1021. };
  1022. static struct clk_branch disp_cc_mdss_rscc_vsync_clk = {
  1023. .halt_reg = 0x4008,
  1024. .halt_check = BRANCH_HALT,
  1025. .clkr = {
  1026. .enable_reg = 0x4008,
  1027. .enable_mask = BIT(0),
  1028. .hw.init = &(const struct clk_init_data) {
  1029. .name = "disp_cc_mdss_rscc_vsync_clk",
  1030. .parent_hws = (const struct clk_hw*[]){
  1031. &disp_cc_mdss_vsync_clk_src.clkr.hw,
  1032. },
  1033. .num_parents = 1,
  1034. .flags = CLK_SET_RATE_PARENT,
  1035. .ops = &clk_branch2_ops,
  1036. },
  1037. },
  1038. };
  1039. static struct clk_branch disp_cc_mdss_vsync_clk = {
  1040. .halt_reg = 0x2024,
  1041. .halt_check = BRANCH_HALT,
  1042. .clkr = {
  1043. .enable_reg = 0x2024,
  1044. .enable_mask = BIT(0),
  1045. .hw.init = &(const struct clk_init_data) {
  1046. .name = "disp_cc_mdss_vsync_clk",
  1047. .parent_hws = (const struct clk_hw*[]){
  1048. &disp_cc_mdss_vsync_clk_src.clkr.hw,
  1049. },
  1050. .num_parents = 1,
  1051. .flags = CLK_SET_RATE_PARENT,
  1052. .ops = &clk_branch2_ops,
  1053. },
  1054. },
  1055. };
  1056. static struct gdsc mdss_gdsc = {
  1057. .gdscr = 0x3000,
  1058. .en_rest_wait_val = 0x2,
  1059. .en_few_wait_val = 0x2,
  1060. .clk_dis_wait_val = 0xf,
  1061. .pd = {
  1062. .name = "mdss_gdsc",
  1063. },
  1064. .pwrsts = PWRSTS_OFF_ON,
  1065. .flags = HW_CTRL | RETAIN_FF_ENABLE,
  1066. };
  1067. static struct clk_regmap *disp_cc_sm8250_clocks[] = {
  1068. [DISP_CC_MDSS_AHB_CLK] = &disp_cc_mdss_ahb_clk.clkr,
  1069. [DISP_CC_MDSS_AHB_CLK_SRC] = &disp_cc_mdss_ahb_clk_src.clkr,
  1070. [DISP_CC_MDSS_BYTE0_CLK] = &disp_cc_mdss_byte0_clk.clkr,
  1071. [DISP_CC_MDSS_BYTE0_CLK_SRC] = &disp_cc_mdss_byte0_clk_src.clkr,
  1072. [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC] = &disp_cc_mdss_byte0_div_clk_src.clkr,
  1073. [DISP_CC_MDSS_BYTE0_INTF_CLK] = &disp_cc_mdss_byte0_intf_clk.clkr,
  1074. [DISP_CC_MDSS_BYTE1_CLK] = &disp_cc_mdss_byte1_clk.clkr,
  1075. [DISP_CC_MDSS_BYTE1_CLK_SRC] = &disp_cc_mdss_byte1_clk_src.clkr,
  1076. [DISP_CC_MDSS_BYTE1_DIV_CLK_SRC] = &disp_cc_mdss_byte1_div_clk_src.clkr,
  1077. [DISP_CC_MDSS_BYTE1_INTF_CLK] = &disp_cc_mdss_byte1_intf_clk.clkr,
  1078. [DISP_CC_MDSS_DP_AUX1_CLK] = &disp_cc_mdss_dp_aux1_clk.clkr,
  1079. [DISP_CC_MDSS_DP_AUX1_CLK_SRC] = &disp_cc_mdss_dp_aux1_clk_src.clkr,
  1080. [DISP_CC_MDSS_DP_AUX_CLK] = &disp_cc_mdss_dp_aux_clk.clkr,
  1081. [DISP_CC_MDSS_DP_AUX_CLK_SRC] = &disp_cc_mdss_dp_aux_clk_src.clkr,
  1082. [DISP_CC_MDSS_DP_LINK1_CLK] = &disp_cc_mdss_dp_link1_clk.clkr,
  1083. [DISP_CC_MDSS_DP_LINK1_CLK_SRC] = &disp_cc_mdss_dp_link1_clk_src.clkr,
  1084. [DISP_CC_MDSS_DP_LINK1_DIV_CLK_SRC] = &disp_cc_mdss_dp_link1_div_clk_src.clkr,
  1085. [DISP_CC_MDSS_DP_LINK1_INTF_CLK] = &disp_cc_mdss_dp_link1_intf_clk.clkr,
  1086. [DISP_CC_MDSS_DP_LINK_CLK] = &disp_cc_mdss_dp_link_clk.clkr,
  1087. [DISP_CC_MDSS_DP_LINK_CLK_SRC] = &disp_cc_mdss_dp_link_clk_src.clkr,
  1088. [DISP_CC_MDSS_DP_LINK_DIV_CLK_SRC] = &disp_cc_mdss_dp_link_div_clk_src.clkr,
  1089. [DISP_CC_MDSS_DP_LINK_INTF_CLK] = &disp_cc_mdss_dp_link_intf_clk.clkr,
  1090. [DISP_CC_MDSS_DP_PIXEL1_CLK] = &disp_cc_mdss_dp_pixel1_clk.clkr,
  1091. [DISP_CC_MDSS_DP_PIXEL1_CLK_SRC] = &disp_cc_mdss_dp_pixel1_clk_src.clkr,
  1092. [DISP_CC_MDSS_DP_PIXEL2_CLK] = &disp_cc_mdss_dp_pixel2_clk.clkr,
  1093. [DISP_CC_MDSS_DP_PIXEL2_CLK_SRC] = &disp_cc_mdss_dp_pixel2_clk_src.clkr,
  1094. [DISP_CC_MDSS_DP_PIXEL_CLK] = &disp_cc_mdss_dp_pixel_clk.clkr,
  1095. [DISP_CC_MDSS_DP_PIXEL_CLK_SRC] = &disp_cc_mdss_dp_pixel_clk_src.clkr,
  1096. [DISP_CC_MDSS_EDP_AUX_CLK] = &disp_cc_mdss_edp_aux_clk.clkr,
  1097. [DISP_CC_MDSS_EDP_AUX_CLK_SRC] = &disp_cc_mdss_edp_aux_clk_src.clkr,
  1098. [DISP_CC_MDSS_EDP_GTC_CLK] = &disp_cc_mdss_edp_gtc_clk.clkr,
  1099. [DISP_CC_MDSS_EDP_GTC_CLK_SRC] = &disp_cc_mdss_edp_gtc_clk_src.clkr,
  1100. [DISP_CC_MDSS_EDP_LINK_CLK] = &disp_cc_mdss_edp_link_clk.clkr,
  1101. [DISP_CC_MDSS_EDP_LINK_CLK_SRC] = &disp_cc_mdss_edp_link_clk_src.clkr,
  1102. [DISP_CC_MDSS_EDP_LINK_DIV_CLK_SRC] = &disp_cc_mdss_edp_link_div_clk_src.clkr,
  1103. [DISP_CC_MDSS_EDP_LINK_INTF_CLK] = &disp_cc_mdss_edp_link_intf_clk.clkr,
  1104. [DISP_CC_MDSS_EDP_PIXEL_CLK] = &disp_cc_mdss_edp_pixel_clk.clkr,
  1105. [DISP_CC_MDSS_EDP_PIXEL_CLK_SRC] = &disp_cc_mdss_edp_pixel_clk_src.clkr,
  1106. [DISP_CC_MDSS_ESC0_CLK] = &disp_cc_mdss_esc0_clk.clkr,
  1107. [DISP_CC_MDSS_ESC0_CLK_SRC] = &disp_cc_mdss_esc0_clk_src.clkr,
  1108. [DISP_CC_MDSS_ESC1_CLK] = &disp_cc_mdss_esc1_clk.clkr,
  1109. [DISP_CC_MDSS_ESC1_CLK_SRC] = &disp_cc_mdss_esc1_clk_src.clkr,
  1110. [DISP_CC_MDSS_MDP_CLK] = &disp_cc_mdss_mdp_clk.clkr,
  1111. [DISP_CC_MDSS_MDP_CLK_SRC] = &disp_cc_mdss_mdp_clk_src.clkr,
  1112. [DISP_CC_MDSS_MDP_LUT_CLK] = &disp_cc_mdss_mdp_lut_clk.clkr,
  1113. [DISP_CC_MDSS_NON_GDSC_AHB_CLK] = &disp_cc_mdss_non_gdsc_ahb_clk.clkr,
  1114. [DISP_CC_MDSS_PCLK0_CLK] = &disp_cc_mdss_pclk0_clk.clkr,
  1115. [DISP_CC_MDSS_PCLK0_CLK_SRC] = &disp_cc_mdss_pclk0_clk_src.clkr,
  1116. [DISP_CC_MDSS_PCLK1_CLK] = &disp_cc_mdss_pclk1_clk.clkr,
  1117. [DISP_CC_MDSS_PCLK1_CLK_SRC] = &disp_cc_mdss_pclk1_clk_src.clkr,
  1118. [DISP_CC_MDSS_ROT_CLK] = &disp_cc_mdss_rot_clk.clkr,
  1119. [DISP_CC_MDSS_ROT_CLK_SRC] = &disp_cc_mdss_rot_clk_src.clkr,
  1120. [DISP_CC_MDSS_RSCC_AHB_CLK] = &disp_cc_mdss_rscc_ahb_clk.clkr,
  1121. [DISP_CC_MDSS_RSCC_VSYNC_CLK] = &disp_cc_mdss_rscc_vsync_clk.clkr,
  1122. [DISP_CC_MDSS_VSYNC_CLK] = &disp_cc_mdss_vsync_clk.clkr,
  1123. [DISP_CC_MDSS_VSYNC_CLK_SRC] = &disp_cc_mdss_vsync_clk_src.clkr,
  1124. [DISP_CC_PLL0] = &disp_cc_pll0.clkr,
  1125. [DISP_CC_PLL1] = &disp_cc_pll1.clkr,
  1126. };
  1127. static const struct qcom_reset_map disp_cc_sm8250_resets[] = {
  1128. [DISP_CC_MDSS_CORE_BCR] = { 0x2000 },
  1129. [DISP_CC_MDSS_RSCC_BCR] = { 0x4000 },
  1130. };
  1131. static struct gdsc *disp_cc_sm8250_gdscs[] = {
  1132. [MDSS_GDSC] = &mdss_gdsc,
  1133. };
  1134. static const struct regmap_config disp_cc_sm8250_regmap_config = {
  1135. .reg_bits = 32,
  1136. .reg_stride = 4,
  1137. .val_bits = 32,
  1138. .max_register = 0x10000,
  1139. .fast_io = true,
  1140. };
  1141. static const struct qcom_cc_desc disp_cc_sm8250_desc = {
  1142. .config = &disp_cc_sm8250_regmap_config,
  1143. .clks = disp_cc_sm8250_clocks,
  1144. .num_clks = ARRAY_SIZE(disp_cc_sm8250_clocks),
  1145. .resets = disp_cc_sm8250_resets,
  1146. .num_resets = ARRAY_SIZE(disp_cc_sm8250_resets),
  1147. .gdscs = disp_cc_sm8250_gdscs,
  1148. .num_gdscs = ARRAY_SIZE(disp_cc_sm8250_gdscs),
  1149. };
  1150. static const struct of_device_id disp_cc_sm8250_match_table[] = {
  1151. { .compatible = "qcom,sc8180x-dispcc" },
  1152. { .compatible = "qcom,sm8150-dispcc" },
  1153. { .compatible = "qcom,sm8250-dispcc" },
  1154. { .compatible = "qcom,sm8350-dispcc" },
  1155. { }
  1156. };
  1157. MODULE_DEVICE_TABLE(of, disp_cc_sm8250_match_table);
  1158. static int disp_cc_sm8250_probe(struct platform_device *pdev)
  1159. {
  1160. struct regmap *regmap;
  1161. int ret;
  1162. ret = devm_pm_runtime_enable(&pdev->dev);
  1163. if (ret)
  1164. return ret;
  1165. ret = pm_runtime_resume_and_get(&pdev->dev);
  1166. if (ret)
  1167. return ret;
  1168. regmap = qcom_cc_map(pdev, &disp_cc_sm8250_desc);
  1169. if (IS_ERR(regmap)) {
  1170. pm_runtime_put(&pdev->dev);
  1171. return PTR_ERR(regmap);
  1172. }
  1173. /* Apply differences for SM8150 and SM8350 */
  1174. BUILD_BUG_ON(CLK_ALPHA_PLL_TYPE_TRION != CLK_ALPHA_PLL_TYPE_LUCID);
  1175. if (of_device_is_compatible(pdev->dev.of_node, "qcom,sc8180x-dispcc") ||
  1176. of_device_is_compatible(pdev->dev.of_node, "qcom,sm8150-dispcc")) {
  1177. disp_cc_pll0_config.config_ctl_hi_val = 0x00002267;
  1178. disp_cc_pll0_config.config_ctl_hi1_val = 0x00000024;
  1179. disp_cc_pll0_config.user_ctl_hi1_val = 0x000000D0;
  1180. disp_cc_pll0_init.ops = &clk_alpha_pll_trion_ops;
  1181. disp_cc_pll1_config.config_ctl_hi_val = 0x00002267;
  1182. disp_cc_pll1_config.config_ctl_hi1_val = 0x00000024;
  1183. disp_cc_pll1_config.user_ctl_hi1_val = 0x000000D0;
  1184. disp_cc_pll1_init.ops = &clk_alpha_pll_trion_ops;
  1185. disp_cc_mdss_dp_link_intf_clk.clkr.hw.init->parent_hws[0] =
  1186. &disp_cc_mdss_dp_link_clk_src.clkr.hw;
  1187. disp_cc_mdss_dp_link1_intf_clk.clkr.hw.init->parent_hws[0] =
  1188. &disp_cc_mdss_dp_link1_clk_src.clkr.hw;
  1189. disp_cc_mdss_edp_link_intf_clk.clkr.hw.init->parent_hws[0] =
  1190. &disp_cc_mdss_edp_link_clk_src.clkr.hw;
  1191. disp_cc_sm8250_clocks[DISP_CC_MDSS_DP_LINK1_DIV_CLK_SRC] = NULL;
  1192. disp_cc_sm8250_clocks[DISP_CC_MDSS_DP_LINK_DIV_CLK_SRC] = NULL;
  1193. disp_cc_sm8250_clocks[DISP_CC_MDSS_EDP_LINK_DIV_CLK_SRC] = NULL;
  1194. } else if (of_device_is_compatible(pdev->dev.of_node, "qcom,sm8350-dispcc")) {
  1195. static struct clk_rcg2 * const rcgs[] = {
  1196. &disp_cc_mdss_byte0_clk_src,
  1197. &disp_cc_mdss_byte1_clk_src,
  1198. &disp_cc_mdss_dp_aux1_clk_src,
  1199. &disp_cc_mdss_dp_aux_clk_src,
  1200. &disp_cc_mdss_dp_link1_clk_src,
  1201. &disp_cc_mdss_dp_link_clk_src,
  1202. &disp_cc_mdss_dp_pixel1_clk_src,
  1203. &disp_cc_mdss_dp_pixel2_clk_src,
  1204. &disp_cc_mdss_dp_pixel_clk_src,
  1205. &disp_cc_mdss_edp_aux_clk_src,
  1206. &disp_cc_mdss_edp_link_clk_src,
  1207. &disp_cc_mdss_edp_pixel_clk_src,
  1208. &disp_cc_mdss_esc0_clk_src,
  1209. &disp_cc_mdss_esc1_clk_src,
  1210. &disp_cc_mdss_mdp_clk_src,
  1211. &disp_cc_mdss_pclk0_clk_src,
  1212. &disp_cc_mdss_pclk1_clk_src,
  1213. &disp_cc_mdss_rot_clk_src,
  1214. &disp_cc_mdss_vsync_clk_src,
  1215. };
  1216. static struct clk_regmap_div * const divs[] = {
  1217. &disp_cc_mdss_byte0_div_clk_src,
  1218. &disp_cc_mdss_byte1_div_clk_src,
  1219. &disp_cc_mdss_dp_link1_div_clk_src,
  1220. &disp_cc_mdss_dp_link_div_clk_src,
  1221. &disp_cc_mdss_edp_link_div_clk_src,
  1222. };
  1223. unsigned int i;
  1224. static bool offset_applied;
  1225. /*
  1226. * note: trion == lucid, except for the prepare() op
  1227. * only apply the offsets once (in case of deferred probe)
  1228. */
  1229. if (!offset_applied) {
  1230. for (i = 0; i < ARRAY_SIZE(rcgs); i++)
  1231. rcgs[i]->cmd_rcgr -= 4;
  1232. for (i = 0; i < ARRAY_SIZE(divs); i++) {
  1233. divs[i]->reg -= 4;
  1234. divs[i]->width = 4;
  1235. }
  1236. disp_cc_mdss_ahb_clk.halt_reg -= 4;
  1237. disp_cc_mdss_ahb_clk.clkr.enable_reg -= 4;
  1238. offset_applied = true;
  1239. }
  1240. disp_cc_mdss_ahb_clk_src.cmd_rcgr = 0x22a0;
  1241. disp_cc_pll0_config.config_ctl_hi1_val = 0x2a9a699c;
  1242. disp_cc_pll0_config.test_ctl_hi1_val = 0x01800000;
  1243. disp_cc_pll0_init.ops = &clk_alpha_pll_lucid_5lpe_ops;
  1244. disp_cc_pll0.vco_table = lucid_5lpe_vco;
  1245. disp_cc_pll1_config.config_ctl_hi1_val = 0x2a9a699c;
  1246. disp_cc_pll1_config.test_ctl_hi1_val = 0x01800000;
  1247. disp_cc_pll1_init.ops = &clk_alpha_pll_lucid_5lpe_ops;
  1248. disp_cc_pll1.vco_table = lucid_5lpe_vco;
  1249. disp_cc_sm8250_clocks[DISP_CC_MDSS_EDP_GTC_CLK] = NULL;
  1250. disp_cc_sm8250_clocks[DISP_CC_MDSS_EDP_GTC_CLK_SRC] = NULL;
  1251. }
  1252. if (of_device_is_compatible(pdev->dev.of_node, "qcom,sm8350-dispcc")) {
  1253. clk_lucid_5lpe_pll_configure(&disp_cc_pll0, regmap, &disp_cc_pll0_config);
  1254. clk_lucid_5lpe_pll_configure(&disp_cc_pll1, regmap, &disp_cc_pll1_config);
  1255. } else {
  1256. clk_lucid_pll_configure(&disp_cc_pll0, regmap, &disp_cc_pll0_config);
  1257. clk_lucid_pll_configure(&disp_cc_pll1, regmap, &disp_cc_pll1_config);
  1258. }
  1259. /* Enable clock gating for MDP clocks */
  1260. regmap_update_bits(regmap, 0x8000, 0x10, 0x10);
  1261. /* Keep some clocks always-on */
  1262. qcom_branch_set_clk_en(regmap, 0x605c); /* DISP_CC_XO_CLK */
  1263. ret = qcom_cc_really_probe(&pdev->dev, &disp_cc_sm8250_desc, regmap);
  1264. pm_runtime_put(&pdev->dev);
  1265. return ret;
  1266. }
  1267. static struct platform_driver disp_cc_sm8250_driver = {
  1268. .probe = disp_cc_sm8250_probe,
  1269. .driver = {
  1270. .name = "disp_cc-sm8250",
  1271. .of_match_table = disp_cc_sm8250_match_table,
  1272. },
  1273. };
  1274. module_platform_driver(disp_cc_sm8250_driver);
  1275. MODULE_DESCRIPTION("QTI DISPCC SM8250 Driver");
  1276. MODULE_LICENSE("GPL v2");