dispcc-sm4450.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/module.h>
  7. #include <linux/mod_devicetable.h>
  8. #include <linux/of.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/regmap.h>
  11. #include <dt-bindings/clock/qcom,sm4450-dispcc.h>
  12. #include "clk-alpha-pll.h"
  13. #include "clk-branch.h"
  14. #include "clk-pll.h"
  15. #include "clk-rcg.h"
  16. #include "clk-regmap.h"
  17. #include "clk-regmap-divider.h"
  18. #include "common.h"
  19. #include "gdsc.h"
  20. #include "reset.h"
  21. enum {
  22. DT_BI_TCXO,
  23. DT_BI_TCXO_AO,
  24. DT_AHB_CLK,
  25. DT_SLEEP_CLK,
  26. DT_DSI0_PHY_PLL_OUT_BYTECLK,
  27. DT_DSI0_PHY_PLL_OUT_DSICLK,
  28. };
  29. enum {
  30. P_BI_TCXO,
  31. P_DISP_CC_PLL0_OUT_MAIN,
  32. P_DISP_CC_PLL1_OUT_EVEN,
  33. P_DISP_CC_PLL1_OUT_MAIN,
  34. P_DSI0_PHY_PLL_OUT_BYTECLK,
  35. P_DSI0_PHY_PLL_OUT_DSICLK,
  36. P_SLEEP_CLK,
  37. };
  38. static const struct pll_vco lucid_evo_vco[] = {
  39. { 249600000, 2020000000, 0 },
  40. };
  41. /* 600.0 MHz Configuration */
  42. static const struct alpha_pll_config disp_cc_pll0_config = {
  43. .l = 0x1f,
  44. .alpha = 0x4000,
  45. .config_ctl_val = 0x20485699,
  46. .config_ctl_hi_val = 0x00182261,
  47. .config_ctl_hi1_val = 0x32aa299c,
  48. .user_ctl_val = 0x00000000,
  49. .user_ctl_hi_val = 0x00000805,
  50. };
  51. static struct clk_alpha_pll disp_cc_pll0 = {
  52. .offset = 0x0,
  53. .vco_table = lucid_evo_vco,
  54. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  55. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  56. .clkr = {
  57. .hw.init = &(const struct clk_init_data) {
  58. .name = "disp_cc_pll0",
  59. .parent_data = &(const struct clk_parent_data) {
  60. .index = DT_BI_TCXO,
  61. },
  62. .num_parents = 1,
  63. .ops = &clk_alpha_pll_lucid_evo_ops,
  64. },
  65. },
  66. };
  67. static struct clk_alpha_pll disp_cc_pll1 = {
  68. .offset = 0x1000,
  69. .vco_table = lucid_evo_vco,
  70. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  71. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  72. .clkr = {
  73. .hw.init = &(const struct clk_init_data) {
  74. .name = "disp_cc_pll1",
  75. .parent_data = &(const struct clk_parent_data) {
  76. .index = DT_BI_TCXO,
  77. },
  78. .num_parents = 1,
  79. .ops = &clk_alpha_pll_lucid_evo_ops,
  80. },
  81. },
  82. };
  83. static const struct parent_map disp_cc_parent_map_0[] = {
  84. { P_BI_TCXO, 0 },
  85. { P_DSI0_PHY_PLL_OUT_DSICLK, 1 },
  86. { P_DSI0_PHY_PLL_OUT_BYTECLK, 2 },
  87. };
  88. static const struct clk_parent_data disp_cc_parent_data_0[] = {
  89. { .index = DT_BI_TCXO },
  90. { .index = DT_DSI0_PHY_PLL_OUT_DSICLK },
  91. { .index = DT_DSI0_PHY_PLL_OUT_BYTECLK },
  92. };
  93. static const struct parent_map disp_cc_parent_map_1[] = {
  94. { P_BI_TCXO, 0 },
  95. { P_DISP_CC_PLL0_OUT_MAIN, 1 },
  96. { P_DISP_CC_PLL1_OUT_MAIN, 4 },
  97. { P_DISP_CC_PLL1_OUT_EVEN, 6 },
  98. };
  99. static const struct clk_parent_data disp_cc_parent_data_1[] = {
  100. { .index = DT_BI_TCXO },
  101. { .hw = &disp_cc_pll0.clkr.hw },
  102. { .hw = &disp_cc_pll1.clkr.hw },
  103. { .hw = &disp_cc_pll1.clkr.hw },
  104. };
  105. static const struct parent_map disp_cc_parent_map_2[] = {
  106. { P_BI_TCXO, 0 },
  107. };
  108. static const struct clk_parent_data disp_cc_parent_data_2[] = {
  109. { .index = DT_BI_TCXO },
  110. };
  111. static const struct clk_parent_data disp_cc_parent_data_2_ao[] = {
  112. { .index = DT_BI_TCXO_AO },
  113. };
  114. static const struct parent_map disp_cc_parent_map_3[] = {
  115. { P_BI_TCXO, 0 },
  116. { P_DISP_CC_PLL1_OUT_MAIN, 4 },
  117. { P_DISP_CC_PLL1_OUT_EVEN, 6 },
  118. };
  119. static const struct clk_parent_data disp_cc_parent_data_3[] = {
  120. { .index = DT_BI_TCXO },
  121. { .hw = &disp_cc_pll1.clkr.hw },
  122. { .hw = &disp_cc_pll1.clkr.hw },
  123. };
  124. static const struct parent_map disp_cc_parent_map_4[] = {
  125. { P_BI_TCXO, 0 },
  126. { P_DSI0_PHY_PLL_OUT_BYTECLK, 2 },
  127. };
  128. static const struct clk_parent_data disp_cc_parent_data_4[] = {
  129. { .index = DT_BI_TCXO },
  130. { .index = DT_DSI0_PHY_PLL_OUT_BYTECLK },
  131. };
  132. static const struct parent_map disp_cc_parent_map_5[] = {
  133. { P_SLEEP_CLK, 0 },
  134. };
  135. static const struct clk_parent_data disp_cc_parent_data_5[] = {
  136. { .index = DT_SLEEP_CLK },
  137. };
  138. static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = {
  139. F(19200000, P_BI_TCXO, 1, 0, 0),
  140. F(37500000, P_DISP_CC_PLL1_OUT_MAIN, 16, 0, 0),
  141. F(75000000, P_DISP_CC_PLL1_OUT_MAIN, 8, 0, 0),
  142. { }
  143. };
  144. static struct clk_rcg2 disp_cc_mdss_ahb_clk_src = {
  145. .cmd_rcgr = 0x82a4,
  146. .mnd_width = 0,
  147. .hid_width = 5,
  148. .parent_map = disp_cc_parent_map_3,
  149. .freq_tbl = ftbl_disp_cc_mdss_ahb_clk_src,
  150. .clkr.hw.init = &(const struct clk_init_data) {
  151. .name = "disp_cc_mdss_ahb_clk_src",
  152. .parent_data = disp_cc_parent_data_3,
  153. .num_parents = ARRAY_SIZE(disp_cc_parent_data_3),
  154. .flags = CLK_SET_RATE_PARENT,
  155. .ops = &clk_rcg2_shared_ops,
  156. },
  157. };
  158. static const struct freq_tbl ftbl_disp_cc_mdss_byte0_clk_src[] = {
  159. F(19200000, P_BI_TCXO, 1, 0, 0),
  160. { }
  161. };
  162. static struct clk_rcg2 disp_cc_mdss_byte0_clk_src = {
  163. .cmd_rcgr = 0x80f8,
  164. .mnd_width = 0,
  165. .hid_width = 5,
  166. .parent_map = disp_cc_parent_map_0,
  167. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  168. .clkr.hw.init = &(const struct clk_init_data) {
  169. .name = "disp_cc_mdss_byte0_clk_src",
  170. .parent_data = disp_cc_parent_data_0,
  171. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  172. .flags = CLK_SET_RATE_PARENT,
  173. .ops = &clk_byte2_ops,
  174. },
  175. };
  176. static struct clk_rcg2 disp_cc_mdss_esc0_clk_src = {
  177. .cmd_rcgr = 0x8114,
  178. .mnd_width = 0,
  179. .hid_width = 5,
  180. .parent_map = disp_cc_parent_map_4,
  181. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  182. .clkr.hw.init = &(const struct clk_init_data) {
  183. .name = "disp_cc_mdss_esc0_clk_src",
  184. .parent_data = disp_cc_parent_data_4,
  185. .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
  186. .flags = CLK_SET_RATE_PARENT,
  187. .ops = &clk_rcg2_shared_ops,
  188. },
  189. };
  190. static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src[] = {
  191. F(200000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  192. F(325000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  193. F(380000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  194. F(506000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  195. F(608000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
  196. { }
  197. };
  198. static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = {
  199. .cmd_rcgr = 0x80b0,
  200. .mnd_width = 0,
  201. .hid_width = 5,
  202. .parent_map = disp_cc_parent_map_1,
  203. .freq_tbl = ftbl_disp_cc_mdss_mdp_clk_src,
  204. .clkr.hw.init = &(const struct clk_init_data) {
  205. .name = "disp_cc_mdss_mdp_clk_src",
  206. .parent_data = disp_cc_parent_data_1,
  207. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  208. .flags = CLK_SET_RATE_PARENT,
  209. .ops = &clk_rcg2_shared_ops,
  210. },
  211. };
  212. static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = {
  213. .cmd_rcgr = 0x8098,
  214. .mnd_width = 8,
  215. .hid_width = 5,
  216. .parent_map = disp_cc_parent_map_0,
  217. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  218. .clkr.hw.init = &(const struct clk_init_data) {
  219. .name = "disp_cc_mdss_pclk0_clk_src",
  220. .parent_data = disp_cc_parent_data_0,
  221. .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
  222. .flags = CLK_SET_RATE_PARENT,
  223. .ops = &clk_pixel_ops,
  224. },
  225. };
  226. static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src[] = {
  227. F(200000000, P_DISP_CC_PLL1_OUT_MAIN, 3, 0, 0),
  228. F(300000000, P_DISP_CC_PLL1_OUT_MAIN, 2, 0, 0),
  229. { }
  230. };
  231. static struct clk_rcg2 disp_cc_mdss_rot_clk_src = {
  232. .cmd_rcgr = 0x80c8,
  233. .mnd_width = 0,
  234. .hid_width = 5,
  235. .parent_map = disp_cc_parent_map_1,
  236. .freq_tbl = ftbl_disp_cc_mdss_rot_clk_src,
  237. .clkr.hw.init = &(const struct clk_init_data) {
  238. .name = "disp_cc_mdss_rot_clk_src",
  239. .parent_data = disp_cc_parent_data_1,
  240. .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
  241. .flags = CLK_SET_RATE_PARENT,
  242. .ops = &clk_rcg2_shared_ops,
  243. },
  244. };
  245. static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = {
  246. .cmd_rcgr = 0x80e0,
  247. .mnd_width = 0,
  248. .hid_width = 5,
  249. .parent_map = disp_cc_parent_map_2,
  250. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  251. .clkr.hw.init = &(const struct clk_init_data) {
  252. .name = "disp_cc_mdss_vsync_clk_src",
  253. .parent_data = disp_cc_parent_data_2,
  254. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
  255. .flags = CLK_SET_RATE_PARENT,
  256. .ops = &clk_rcg2_shared_ops,
  257. },
  258. };
  259. static const struct freq_tbl ftbl_disp_cc_sleep_clk_src[] = {
  260. F(32000, P_SLEEP_CLK, 1, 0, 0),
  261. { }
  262. };
  263. static struct clk_rcg2 disp_cc_sleep_clk_src = {
  264. .cmd_rcgr = 0xe058,
  265. .mnd_width = 0,
  266. .hid_width = 5,
  267. .parent_map = disp_cc_parent_map_5,
  268. .freq_tbl = ftbl_disp_cc_sleep_clk_src,
  269. .clkr.hw.init = &(const struct clk_init_data) {
  270. .name = "disp_cc_sleep_clk_src",
  271. .parent_data = disp_cc_parent_data_5,
  272. .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
  273. .flags = CLK_SET_RATE_PARENT,
  274. .ops = &clk_rcg2_shared_ops,
  275. },
  276. };
  277. static struct clk_rcg2 disp_cc_xo_clk_src = {
  278. .cmd_rcgr = 0xe03c,
  279. .mnd_width = 0,
  280. .hid_width = 5,
  281. .parent_map = disp_cc_parent_map_2,
  282. .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
  283. .clkr.hw.init = &(const struct clk_init_data) {
  284. .name = "disp_cc_xo_clk_src",
  285. .parent_data = disp_cc_parent_data_2_ao,
  286. .num_parents = ARRAY_SIZE(disp_cc_parent_data_2_ao),
  287. .flags = CLK_SET_RATE_PARENT,
  288. .ops = &clk_rcg2_shared_ops,
  289. },
  290. };
  291. static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = {
  292. .reg = 0x8110,
  293. .shift = 0,
  294. .width = 4,
  295. .clkr.hw.init = &(const struct clk_init_data) {
  296. .name = "disp_cc_mdss_byte0_div_clk_src",
  297. .parent_hws = (const struct clk_hw*[]) {
  298. &disp_cc_mdss_byte0_clk_src.clkr.hw,
  299. },
  300. .num_parents = 1,
  301. .flags = CLK_SET_RATE_PARENT,
  302. .ops = &clk_regmap_div_ops,
  303. },
  304. };
  305. static struct clk_branch disp_cc_mdss_ahb1_clk = {
  306. .halt_reg = 0xa020,
  307. .halt_check = BRANCH_HALT,
  308. .clkr = {
  309. .enable_reg = 0xa020,
  310. .enable_mask = BIT(0),
  311. .hw.init = &(const struct clk_init_data) {
  312. .name = "disp_cc_mdss_ahb1_clk",
  313. .parent_hws = (const struct clk_hw*[]) {
  314. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  315. },
  316. .num_parents = 1,
  317. .flags = CLK_SET_RATE_PARENT,
  318. .ops = &clk_branch2_ops,
  319. },
  320. },
  321. };
  322. static struct clk_branch disp_cc_mdss_ahb_clk = {
  323. .halt_reg = 0x8094,
  324. .halt_check = BRANCH_HALT,
  325. .clkr = {
  326. .enable_reg = 0x8094,
  327. .enable_mask = BIT(0),
  328. .hw.init = &(const struct clk_init_data) {
  329. .name = "disp_cc_mdss_ahb_clk",
  330. .parent_hws = (const struct clk_hw*[]) {
  331. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  332. },
  333. .num_parents = 1,
  334. .flags = CLK_SET_RATE_PARENT,
  335. .ops = &clk_branch2_ops,
  336. },
  337. },
  338. };
  339. static struct clk_branch disp_cc_mdss_byte0_clk = {
  340. .halt_reg = 0x8024,
  341. .halt_check = BRANCH_HALT,
  342. .clkr = {
  343. .enable_reg = 0x8024,
  344. .enable_mask = BIT(0),
  345. .hw.init = &(const struct clk_init_data) {
  346. .name = "disp_cc_mdss_byte0_clk",
  347. .parent_hws = (const struct clk_hw*[]) {
  348. &disp_cc_mdss_byte0_clk_src.clkr.hw,
  349. },
  350. .num_parents = 1,
  351. .flags = CLK_SET_RATE_PARENT,
  352. .ops = &clk_branch2_ops,
  353. },
  354. },
  355. };
  356. static struct clk_branch disp_cc_mdss_byte0_intf_clk = {
  357. .halt_reg = 0x8028,
  358. .halt_check = BRANCH_HALT,
  359. .clkr = {
  360. .enable_reg = 0x8028,
  361. .enable_mask = BIT(0),
  362. .hw.init = &(const struct clk_init_data) {
  363. .name = "disp_cc_mdss_byte0_intf_clk",
  364. .parent_hws = (const struct clk_hw*[]) {
  365. &disp_cc_mdss_byte0_div_clk_src.clkr.hw,
  366. },
  367. .num_parents = 1,
  368. .flags = CLK_SET_RATE_PARENT,
  369. .ops = &clk_branch2_ops,
  370. },
  371. },
  372. };
  373. static struct clk_branch disp_cc_mdss_esc0_clk = {
  374. .halt_reg = 0x802c,
  375. .halt_check = BRANCH_HALT,
  376. .clkr = {
  377. .enable_reg = 0x802c,
  378. .enable_mask = BIT(0),
  379. .hw.init = &(const struct clk_init_data) {
  380. .name = "disp_cc_mdss_esc0_clk",
  381. .parent_hws = (const struct clk_hw*[]) {
  382. &disp_cc_mdss_esc0_clk_src.clkr.hw,
  383. },
  384. .num_parents = 1,
  385. .flags = CLK_SET_RATE_PARENT,
  386. .ops = &clk_branch2_ops,
  387. },
  388. },
  389. };
  390. static struct clk_branch disp_cc_mdss_mdp1_clk = {
  391. .halt_reg = 0xa004,
  392. .halt_check = BRANCH_HALT,
  393. .clkr = {
  394. .enable_reg = 0xa004,
  395. .enable_mask = BIT(0),
  396. .hw.init = &(const struct clk_init_data) {
  397. .name = "disp_cc_mdss_mdp1_clk",
  398. .parent_hws = (const struct clk_hw*[]) {
  399. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  400. },
  401. .num_parents = 1,
  402. .flags = CLK_SET_RATE_PARENT,
  403. .ops = &clk_branch2_ops,
  404. },
  405. },
  406. };
  407. static struct clk_branch disp_cc_mdss_mdp_clk = {
  408. .halt_reg = 0x8008,
  409. .halt_check = BRANCH_HALT,
  410. .clkr = {
  411. .enable_reg = 0x8008,
  412. .enable_mask = BIT(0),
  413. .hw.init = &(const struct clk_init_data) {
  414. .name = "disp_cc_mdss_mdp_clk",
  415. .parent_hws = (const struct clk_hw*[]) {
  416. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  417. },
  418. .num_parents = 1,
  419. .flags = CLK_SET_RATE_PARENT,
  420. .ops = &clk_branch2_ops,
  421. },
  422. },
  423. };
  424. static struct clk_branch disp_cc_mdss_mdp_lut1_clk = {
  425. .halt_reg = 0xa014,
  426. .halt_check = BRANCH_HALT,
  427. .clkr = {
  428. .enable_reg = 0xa014,
  429. .enable_mask = BIT(0),
  430. .hw.init = &(const struct clk_init_data) {
  431. .name = "disp_cc_mdss_mdp_lut1_clk",
  432. .parent_hws = (const struct clk_hw*[]) {
  433. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  434. },
  435. .num_parents = 1,
  436. .flags = CLK_SET_RATE_PARENT,
  437. .ops = &clk_branch2_ops,
  438. },
  439. },
  440. };
  441. static struct clk_branch disp_cc_mdss_mdp_lut_clk = {
  442. .halt_reg = 0x8018,
  443. .halt_check = BRANCH_HALT_VOTED,
  444. .clkr = {
  445. .enable_reg = 0x8018,
  446. .enable_mask = BIT(0),
  447. .hw.init = &(const struct clk_init_data) {
  448. .name = "disp_cc_mdss_mdp_lut_clk",
  449. .parent_hws = (const struct clk_hw*[]) {
  450. &disp_cc_mdss_mdp_clk_src.clkr.hw,
  451. },
  452. .num_parents = 1,
  453. .flags = CLK_SET_RATE_PARENT,
  454. .ops = &clk_branch2_ops,
  455. },
  456. },
  457. };
  458. static struct clk_branch disp_cc_mdss_non_gdsc_ahb_clk = {
  459. .halt_reg = 0xc004,
  460. .halt_check = BRANCH_HALT_VOTED,
  461. .clkr = {
  462. .enable_reg = 0xc004,
  463. .enable_mask = BIT(0),
  464. .hw.init = &(const struct clk_init_data) {
  465. .name = "disp_cc_mdss_non_gdsc_ahb_clk",
  466. .parent_hws = (const struct clk_hw*[]) {
  467. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  468. },
  469. .num_parents = 1,
  470. .flags = CLK_SET_RATE_PARENT,
  471. .ops = &clk_branch2_ops,
  472. },
  473. },
  474. };
  475. static struct clk_branch disp_cc_mdss_pclk0_clk = {
  476. .halt_reg = 0x8004,
  477. .halt_check = BRANCH_HALT,
  478. .clkr = {
  479. .enable_reg = 0x8004,
  480. .enable_mask = BIT(0),
  481. .hw.init = &(const struct clk_init_data) {
  482. .name = "disp_cc_mdss_pclk0_clk",
  483. .parent_hws = (const struct clk_hw*[]) {
  484. &disp_cc_mdss_pclk0_clk_src.clkr.hw,
  485. },
  486. .num_parents = 1,
  487. .flags = CLK_SET_RATE_PARENT,
  488. .ops = &clk_branch2_ops,
  489. },
  490. },
  491. };
  492. static struct clk_branch disp_cc_mdss_rot1_clk = {
  493. .halt_reg = 0xa00c,
  494. .halt_check = BRANCH_HALT,
  495. .clkr = {
  496. .enable_reg = 0xa00c,
  497. .enable_mask = BIT(0),
  498. .hw.init = &(const struct clk_init_data) {
  499. .name = "disp_cc_mdss_rot1_clk",
  500. .parent_hws = (const struct clk_hw*[]) {
  501. &disp_cc_mdss_rot_clk_src.clkr.hw,
  502. },
  503. .num_parents = 1,
  504. .flags = CLK_SET_RATE_PARENT,
  505. .ops = &clk_branch2_ops,
  506. },
  507. },
  508. };
  509. static struct clk_branch disp_cc_mdss_rot_clk = {
  510. .halt_reg = 0x8010,
  511. .halt_check = BRANCH_HALT,
  512. .clkr = {
  513. .enable_reg = 0x8010,
  514. .enable_mask = BIT(0),
  515. .hw.init = &(const struct clk_init_data) {
  516. .name = "disp_cc_mdss_rot_clk",
  517. .parent_hws = (const struct clk_hw*[]) {
  518. &disp_cc_mdss_rot_clk_src.clkr.hw,
  519. },
  520. .num_parents = 1,
  521. .flags = CLK_SET_RATE_PARENT,
  522. .ops = &clk_branch2_ops,
  523. },
  524. },
  525. };
  526. static struct clk_branch disp_cc_mdss_rscc_ahb_clk = {
  527. .halt_reg = 0xc00c,
  528. .halt_check = BRANCH_HALT,
  529. .clkr = {
  530. .enable_reg = 0xc00c,
  531. .enable_mask = BIT(0),
  532. .hw.init = &(const struct clk_init_data) {
  533. .name = "disp_cc_mdss_rscc_ahb_clk",
  534. .parent_hws = (const struct clk_hw*[]) {
  535. &disp_cc_mdss_ahb_clk_src.clkr.hw,
  536. },
  537. .num_parents = 1,
  538. .flags = CLK_SET_RATE_PARENT,
  539. .ops = &clk_branch2_ops,
  540. },
  541. },
  542. };
  543. static struct clk_branch disp_cc_mdss_rscc_vsync_clk = {
  544. .halt_reg = 0xc008,
  545. .halt_check = BRANCH_HALT,
  546. .clkr = {
  547. .enable_reg = 0xc008,
  548. .enable_mask = BIT(0),
  549. .hw.init = &(const struct clk_init_data) {
  550. .name = "disp_cc_mdss_rscc_vsync_clk",
  551. .parent_hws = (const struct clk_hw*[]) {
  552. &disp_cc_mdss_vsync_clk_src.clkr.hw,
  553. },
  554. .num_parents = 1,
  555. .flags = CLK_SET_RATE_PARENT,
  556. .ops = &clk_branch2_ops,
  557. },
  558. },
  559. };
  560. static struct clk_branch disp_cc_mdss_vsync1_clk = {
  561. .halt_reg = 0xa01c,
  562. .halt_check = BRANCH_HALT,
  563. .clkr = {
  564. .enable_reg = 0xa01c,
  565. .enable_mask = BIT(0),
  566. .hw.init = &(const struct clk_init_data) {
  567. .name = "disp_cc_mdss_vsync1_clk",
  568. .parent_hws = (const struct clk_hw*[]) {
  569. &disp_cc_mdss_vsync_clk_src.clkr.hw,
  570. },
  571. .num_parents = 1,
  572. .flags = CLK_SET_RATE_PARENT,
  573. .ops = &clk_branch2_ops,
  574. },
  575. },
  576. };
  577. static struct clk_branch disp_cc_mdss_vsync_clk = {
  578. .halt_reg = 0x8020,
  579. .halt_check = BRANCH_HALT,
  580. .clkr = {
  581. .enable_reg = 0x8020,
  582. .enable_mask = BIT(0),
  583. .hw.init = &(const struct clk_init_data) {
  584. .name = "disp_cc_mdss_vsync_clk",
  585. .parent_hws = (const struct clk_hw*[]) {
  586. &disp_cc_mdss_vsync_clk_src.clkr.hw,
  587. },
  588. .num_parents = 1,
  589. .flags = CLK_SET_RATE_PARENT,
  590. .ops = &clk_branch2_ops,
  591. },
  592. },
  593. };
  594. static struct gdsc disp_cc_mdss_core_gdsc = {
  595. .gdscr = 0x9000,
  596. .en_rest_wait_val = 0x2,
  597. .en_few_wait_val = 0x2,
  598. .clk_dis_wait_val = 0xf,
  599. .pd = {
  600. .name = "disp_cc_mdss_core_gdsc",
  601. },
  602. .pwrsts = PWRSTS_OFF_ON,
  603. .flags = HW_CTRL | POLL_CFG_GDSCR | RETAIN_FF_ENABLE,
  604. };
  605. static struct gdsc disp_cc_mdss_core_int2_gdsc = {
  606. .gdscr = 0xb000,
  607. .en_rest_wait_val = 0x2,
  608. .en_few_wait_val = 0x2,
  609. .clk_dis_wait_val = 0xf,
  610. .pd = {
  611. .name = "disp_cc_mdss_core_int2_gdsc",
  612. },
  613. .pwrsts = PWRSTS_OFF_ON,
  614. .flags = HW_CTRL | POLL_CFG_GDSCR | RETAIN_FF_ENABLE,
  615. };
  616. static struct clk_regmap *disp_cc_sm4450_clocks[] = {
  617. [DISP_CC_MDSS_AHB1_CLK] = &disp_cc_mdss_ahb1_clk.clkr,
  618. [DISP_CC_MDSS_AHB_CLK] = &disp_cc_mdss_ahb_clk.clkr,
  619. [DISP_CC_MDSS_AHB_CLK_SRC] = &disp_cc_mdss_ahb_clk_src.clkr,
  620. [DISP_CC_MDSS_BYTE0_CLK] = &disp_cc_mdss_byte0_clk.clkr,
  621. [DISP_CC_MDSS_BYTE0_CLK_SRC] = &disp_cc_mdss_byte0_clk_src.clkr,
  622. [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC] = &disp_cc_mdss_byte0_div_clk_src.clkr,
  623. [DISP_CC_MDSS_BYTE0_INTF_CLK] = &disp_cc_mdss_byte0_intf_clk.clkr,
  624. [DISP_CC_MDSS_ESC0_CLK] = &disp_cc_mdss_esc0_clk.clkr,
  625. [DISP_CC_MDSS_ESC0_CLK_SRC] = &disp_cc_mdss_esc0_clk_src.clkr,
  626. [DISP_CC_MDSS_MDP1_CLK] = &disp_cc_mdss_mdp1_clk.clkr,
  627. [DISP_CC_MDSS_MDP_CLK] = &disp_cc_mdss_mdp_clk.clkr,
  628. [DISP_CC_MDSS_MDP_CLK_SRC] = &disp_cc_mdss_mdp_clk_src.clkr,
  629. [DISP_CC_MDSS_MDP_LUT1_CLK] = &disp_cc_mdss_mdp_lut1_clk.clkr,
  630. [DISP_CC_MDSS_MDP_LUT_CLK] = &disp_cc_mdss_mdp_lut_clk.clkr,
  631. [DISP_CC_MDSS_NON_GDSC_AHB_CLK] = &disp_cc_mdss_non_gdsc_ahb_clk.clkr,
  632. [DISP_CC_MDSS_PCLK0_CLK] = &disp_cc_mdss_pclk0_clk.clkr,
  633. [DISP_CC_MDSS_PCLK0_CLK_SRC] = &disp_cc_mdss_pclk0_clk_src.clkr,
  634. [DISP_CC_MDSS_ROT1_CLK] = &disp_cc_mdss_rot1_clk.clkr,
  635. [DISP_CC_MDSS_ROT_CLK] = &disp_cc_mdss_rot_clk.clkr,
  636. [DISP_CC_MDSS_ROT_CLK_SRC] = &disp_cc_mdss_rot_clk_src.clkr,
  637. [DISP_CC_MDSS_RSCC_AHB_CLK] = &disp_cc_mdss_rscc_ahb_clk.clkr,
  638. [DISP_CC_MDSS_RSCC_VSYNC_CLK] = &disp_cc_mdss_rscc_vsync_clk.clkr,
  639. [DISP_CC_MDSS_VSYNC1_CLK] = &disp_cc_mdss_vsync1_clk.clkr,
  640. [DISP_CC_MDSS_VSYNC_CLK] = &disp_cc_mdss_vsync_clk.clkr,
  641. [DISP_CC_MDSS_VSYNC_CLK_SRC] = &disp_cc_mdss_vsync_clk_src.clkr,
  642. [DISP_CC_PLL0] = &disp_cc_pll0.clkr,
  643. [DISP_CC_PLL1] = &disp_cc_pll1.clkr,
  644. [DISP_CC_SLEEP_CLK_SRC] = &disp_cc_sleep_clk_src.clkr,
  645. [DISP_CC_XO_CLK_SRC] = &disp_cc_xo_clk_src.clkr,
  646. };
  647. static struct gdsc *disp_cc_sm4450_gdscs[] = {
  648. [DISP_CC_MDSS_CORE_GDSC] = &disp_cc_mdss_core_gdsc,
  649. [DISP_CC_MDSS_CORE_INT2_GDSC] = &disp_cc_mdss_core_int2_gdsc,
  650. };
  651. static const struct qcom_reset_map disp_cc_sm4450_resets[] = {
  652. [DISP_CC_MDSS_CORE_BCR] = { 0x8000 },
  653. [DISP_CC_MDSS_CORE_INT2_BCR] = { 0xa000 },
  654. [DISP_CC_MDSS_RSCC_BCR] = { 0xc000 },
  655. };
  656. static const struct regmap_config disp_cc_sm4450_regmap_config = {
  657. .reg_bits = 32,
  658. .reg_stride = 4,
  659. .val_bits = 32,
  660. .max_register = 0x11008,
  661. .fast_io = true,
  662. };
  663. static struct qcom_cc_desc disp_cc_sm4450_desc = {
  664. .config = &disp_cc_sm4450_regmap_config,
  665. .clks = disp_cc_sm4450_clocks,
  666. .num_clks = ARRAY_SIZE(disp_cc_sm4450_clocks),
  667. .resets = disp_cc_sm4450_resets,
  668. .num_resets = ARRAY_SIZE(disp_cc_sm4450_resets),
  669. .gdscs = disp_cc_sm4450_gdscs,
  670. .num_gdscs = ARRAY_SIZE(disp_cc_sm4450_gdscs),
  671. };
  672. static const struct of_device_id disp_cc_sm4450_match_table[] = {
  673. { .compatible = "qcom,sm4450-dispcc" },
  674. { }
  675. };
  676. MODULE_DEVICE_TABLE(of, disp_cc_sm4450_match_table);
  677. static int disp_cc_sm4450_probe(struct platform_device *pdev)
  678. {
  679. struct regmap *regmap;
  680. regmap = qcom_cc_map(pdev, &disp_cc_sm4450_desc);
  681. if (IS_ERR(regmap))
  682. return PTR_ERR(regmap);
  683. clk_lucid_evo_pll_configure(&disp_cc_pll0, regmap, &disp_cc_pll0_config);
  684. clk_lucid_evo_pll_configure(&disp_cc_pll1, regmap, &disp_cc_pll0_config);
  685. /* Keep some clocks always enabled */
  686. qcom_branch_set_clk_en(regmap, 0xe070); /* DISP_CC_SLEEP_CLK */
  687. qcom_branch_set_clk_en(regmap, 0xe054); /* DISP_CC_XO_CLK */
  688. return qcom_cc_really_probe(&pdev->dev, &disp_cc_sm4450_desc, regmap);
  689. }
  690. static struct platform_driver disp_cc_sm4450_driver = {
  691. .probe = disp_cc_sm4450_probe,
  692. .driver = {
  693. .name = "dispcc-sm4450",
  694. .of_match_table = disp_cc_sm4450_match_table,
  695. },
  696. };
  697. module_platform_driver(disp_cc_sm4450_driver);
  698. MODULE_DESCRIPTION("QTI DISPCC SM4450 Driver");
  699. MODULE_LICENSE("GPL");