dispcc-sm4450.c 20 KB

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