videocc-sm8550.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2023-2024, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/mod_devicetable.h>
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/regmap.h>
  10. #include <dt-bindings/clock/qcom,sm8650-videocc.h>
  11. #include "clk-alpha-pll.h"
  12. #include "clk-branch.h"
  13. #include "clk-rcg.h"
  14. #include "clk-regmap.h"
  15. #include "clk-regmap-divider.h"
  16. #include "common.h"
  17. #include "gdsc.h"
  18. #include "reset.h"
  19. enum {
  20. DT_BI_TCXO,
  21. };
  22. enum {
  23. P_BI_TCXO,
  24. P_VIDEO_CC_PLL0_OUT_MAIN,
  25. P_VIDEO_CC_PLL1_OUT_MAIN,
  26. };
  27. static const struct pll_vco lucid_ole_vco[] = {
  28. { 249600000, 2300000000, 0 },
  29. };
  30. static struct alpha_pll_config video_cc_pll0_config = {
  31. .l = 0x25,
  32. .alpha = 0x8000,
  33. .config_ctl_val = 0x20485699,
  34. .config_ctl_hi_val = 0x00182261,
  35. .config_ctl_hi1_val = 0x82aa299c,
  36. .test_ctl_val = 0x00000000,
  37. .test_ctl_hi_val = 0x00000003,
  38. .test_ctl_hi1_val = 0x00009000,
  39. .test_ctl_hi2_val = 0x00000034,
  40. .user_ctl_val = 0x00000000,
  41. .user_ctl_hi_val = 0x00000005,
  42. };
  43. static struct clk_alpha_pll video_cc_pll0 = {
  44. .offset = 0x0,
  45. .config = &video_cc_pll0_config,
  46. .vco_table = lucid_ole_vco,
  47. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  48. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  49. .clkr = {
  50. .hw.init = &(const struct clk_init_data) {
  51. .name = "video_cc_pll0",
  52. .parent_data = &(const struct clk_parent_data) {
  53. .index = DT_BI_TCXO,
  54. },
  55. .num_parents = 1,
  56. .ops = &clk_alpha_pll_lucid_evo_ops,
  57. },
  58. },
  59. };
  60. static struct alpha_pll_config video_cc_pll1_config = {
  61. .l = 0x36,
  62. .alpha = 0xb000,
  63. .config_ctl_val = 0x20485699,
  64. .config_ctl_hi_val = 0x00182261,
  65. .config_ctl_hi1_val = 0x82aa299c,
  66. .test_ctl_val = 0x00000000,
  67. .test_ctl_hi_val = 0x00000003,
  68. .test_ctl_hi1_val = 0x00009000,
  69. .test_ctl_hi2_val = 0x00000034,
  70. .user_ctl_val = 0x00000000,
  71. .user_ctl_hi_val = 0x00000005,
  72. };
  73. static struct clk_alpha_pll video_cc_pll1 = {
  74. .offset = 0x1000,
  75. .config = &video_cc_pll1_config,
  76. .vco_table = lucid_ole_vco,
  77. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  78. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  79. .clkr = {
  80. .hw.init = &(const struct clk_init_data) {
  81. .name = "video_cc_pll1",
  82. .parent_data = &(const struct clk_parent_data) {
  83. .index = DT_BI_TCXO,
  84. },
  85. .num_parents = 1,
  86. .ops = &clk_alpha_pll_lucid_evo_ops,
  87. },
  88. },
  89. };
  90. static const struct parent_map video_cc_parent_map_0[] = {
  91. { P_BI_TCXO, 0 },
  92. { P_VIDEO_CC_PLL0_OUT_MAIN, 1 },
  93. };
  94. static const struct clk_parent_data video_cc_parent_data_0[] = {
  95. { .index = DT_BI_TCXO },
  96. { .hw = &video_cc_pll0.clkr.hw },
  97. };
  98. static const struct parent_map video_cc_parent_map_1[] = {
  99. { P_BI_TCXO, 0 },
  100. { P_VIDEO_CC_PLL1_OUT_MAIN, 1 },
  101. };
  102. static const struct clk_parent_data video_cc_parent_data_1[] = {
  103. { .index = DT_BI_TCXO },
  104. { .hw = &video_cc_pll1.clkr.hw },
  105. };
  106. static const struct parent_map video_cc_parent_map_2[] = {
  107. { P_BI_TCXO, 0 },
  108. };
  109. static const struct clk_parent_data video_cc_parent_data_2[] = {
  110. { .index = DT_BI_TCXO },
  111. };
  112. static const struct freq_tbl ftbl_video_cc_mvs0_clk_src[] = {
  113. F(720000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  114. F(1014000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  115. F(1098000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  116. F(1332000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  117. F(1600000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  118. { }
  119. };
  120. static const struct freq_tbl ftbl_video_cc_mvs0_clk_src_sm8650[] = {
  121. F(588000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  122. F(900000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  123. F(1140000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  124. F(1305000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  125. F(1440000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  126. F(1600000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  127. { }
  128. };
  129. static const struct freq_tbl ftbl_video_cc_mvs0_clk_src_x1e80100[] = {
  130. F(576000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  131. F(720000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  132. F(1014000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  133. F(1098000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  134. F(1332000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  135. F(1443000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  136. { }
  137. };
  138. static struct clk_rcg2 video_cc_mvs0_clk_src = {
  139. .cmd_rcgr = 0x8000,
  140. .mnd_width = 0,
  141. .hid_width = 5,
  142. .parent_map = video_cc_parent_map_0,
  143. .freq_tbl = ftbl_video_cc_mvs0_clk_src,
  144. .clkr.hw.init = &(const struct clk_init_data) {
  145. .name = "video_cc_mvs0_clk_src",
  146. .parent_data = video_cc_parent_data_0,
  147. .num_parents = ARRAY_SIZE(video_cc_parent_data_0),
  148. .flags = CLK_SET_RATE_PARENT,
  149. .ops = &clk_rcg2_shared_ops,
  150. },
  151. };
  152. static const struct freq_tbl ftbl_video_cc_mvs1_clk_src[] = {
  153. F(1050000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  154. F(1350000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  155. F(1500000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  156. F(1650000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  157. { }
  158. };
  159. static const struct freq_tbl ftbl_video_cc_mvs1_clk_src_sm8650[] = {
  160. F(840000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  161. F(1110000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  162. F(1350000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  163. F(1500000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  164. F(1650000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  165. { }
  166. };
  167. static const struct freq_tbl ftbl_video_cc_mvs1_clk_src_x1e80100[] = {
  168. F(840000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  169. F(1050000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  170. F(1350000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  171. F(1500000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  172. F(1650000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  173. { }
  174. };
  175. static struct clk_rcg2 video_cc_mvs1_clk_src = {
  176. .cmd_rcgr = 0x8018,
  177. .mnd_width = 0,
  178. .hid_width = 5,
  179. .parent_map = video_cc_parent_map_1,
  180. .freq_tbl = ftbl_video_cc_mvs1_clk_src,
  181. .clkr.hw.init = &(const struct clk_init_data) {
  182. .name = "video_cc_mvs1_clk_src",
  183. .parent_data = video_cc_parent_data_1,
  184. .num_parents = ARRAY_SIZE(video_cc_parent_data_1),
  185. .flags = CLK_SET_RATE_PARENT,
  186. .ops = &clk_rcg2_shared_ops,
  187. },
  188. };
  189. static const struct freq_tbl ftbl_video_cc_xo_clk_src[] = {
  190. F(19200000, P_BI_TCXO, 1, 0, 0),
  191. { }
  192. };
  193. static struct clk_rcg2 video_cc_xo_clk_src = {
  194. .cmd_rcgr = 0x810c,
  195. .mnd_width = 0,
  196. .hid_width = 5,
  197. .parent_map = video_cc_parent_map_2,
  198. .freq_tbl = ftbl_video_cc_xo_clk_src,
  199. .clkr.hw.init = &(const struct clk_init_data) {
  200. .name = "video_cc_xo_clk_src",
  201. .parent_data = video_cc_parent_data_2,
  202. .num_parents = ARRAY_SIZE(video_cc_parent_data_2),
  203. .flags = CLK_SET_RATE_PARENT,
  204. .ops = &clk_rcg2_shared_ops,
  205. },
  206. };
  207. static struct clk_regmap_div video_cc_mvs0_div_clk_src = {
  208. .reg = 0x80c4,
  209. .shift = 0,
  210. .width = 4,
  211. .clkr.hw.init = &(const struct clk_init_data) {
  212. .name = "video_cc_mvs0_div_clk_src",
  213. .parent_hws = (const struct clk_hw*[]) {
  214. &video_cc_mvs0_clk_src.clkr.hw,
  215. },
  216. .num_parents = 1,
  217. .flags = CLK_SET_RATE_PARENT,
  218. .ops = &clk_regmap_div_ro_ops,
  219. },
  220. };
  221. static struct clk_regmap_div video_cc_mvs0c_div2_div_clk_src = {
  222. .reg = 0x8070,
  223. .shift = 0,
  224. .width = 4,
  225. .clkr.hw.init = &(const struct clk_init_data) {
  226. .name = "video_cc_mvs0c_div2_div_clk_src",
  227. .parent_hws = (const struct clk_hw*[]) {
  228. &video_cc_mvs0_clk_src.clkr.hw,
  229. },
  230. .num_parents = 1,
  231. .flags = CLK_SET_RATE_PARENT,
  232. .ops = &clk_regmap_div_ro_ops,
  233. },
  234. };
  235. static struct clk_regmap_div video_cc_mvs1_div_clk_src = {
  236. .reg = 0x80ec,
  237. .shift = 0,
  238. .width = 4,
  239. .clkr.hw.init = &(const struct clk_init_data) {
  240. .name = "video_cc_mvs1_div_clk_src",
  241. .parent_hws = (const struct clk_hw*[]) {
  242. &video_cc_mvs1_clk_src.clkr.hw,
  243. },
  244. .num_parents = 1,
  245. .flags = CLK_SET_RATE_PARENT,
  246. .ops = &clk_regmap_div_ro_ops,
  247. },
  248. };
  249. static struct clk_regmap_div video_cc_mvs1c_div2_div_clk_src = {
  250. .reg = 0x809c,
  251. .shift = 0,
  252. .width = 4,
  253. .clkr.hw.init = &(const struct clk_init_data) {
  254. .name = "video_cc_mvs1c_div2_div_clk_src",
  255. .parent_hws = (const struct clk_hw*[]) {
  256. &video_cc_mvs1_clk_src.clkr.hw,
  257. },
  258. .num_parents = 1,
  259. .flags = CLK_SET_RATE_PARENT,
  260. .ops = &clk_regmap_div_ro_ops,
  261. },
  262. };
  263. static struct clk_branch video_cc_mvs0_clk = {
  264. .halt_reg = 0x80b8,
  265. .halt_check = BRANCH_HALT_SKIP,
  266. .hwcg_reg = 0x80b8,
  267. .hwcg_bit = 1,
  268. .clkr = {
  269. .enable_reg = 0x80b8,
  270. .enable_mask = BIT(0),
  271. .hw.init = &(const struct clk_init_data) {
  272. .name = "video_cc_mvs0_clk",
  273. .parent_hws = (const struct clk_hw*[]) {
  274. &video_cc_mvs0_div_clk_src.clkr.hw,
  275. },
  276. .num_parents = 1,
  277. .flags = CLK_SET_RATE_PARENT,
  278. .ops = &clk_branch2_ops,
  279. },
  280. },
  281. };
  282. static struct clk_branch video_cc_mvs0_shift_clk = {
  283. .halt_reg = 0x8128,
  284. .halt_check = BRANCH_HALT_VOTED,
  285. .hwcg_reg = 0x8128,
  286. .hwcg_bit = 1,
  287. .clkr = {
  288. .enable_reg = 0x8128,
  289. .enable_mask = BIT(0),
  290. .hw.init = &(const struct clk_init_data) {
  291. .name = "video_cc_mvs0_shift_clk",
  292. .parent_hws = (const struct clk_hw*[]) {
  293. &video_cc_xo_clk_src.clkr.hw,
  294. },
  295. .num_parents = 1,
  296. .flags = CLK_SET_RATE_PARENT,
  297. .ops = &clk_branch2_ops,
  298. },
  299. },
  300. };
  301. static struct clk_branch video_cc_mvs0c_clk = {
  302. .halt_reg = 0x8064,
  303. .halt_check = BRANCH_HALT,
  304. .clkr = {
  305. .enable_reg = 0x8064,
  306. .enable_mask = BIT(0),
  307. .hw.init = &(const struct clk_init_data) {
  308. .name = "video_cc_mvs0c_clk",
  309. .parent_hws = (const struct clk_hw*[]) {
  310. &video_cc_mvs0c_div2_div_clk_src.clkr.hw,
  311. },
  312. .num_parents = 1,
  313. .flags = CLK_SET_RATE_PARENT,
  314. .ops = &clk_branch2_ops,
  315. },
  316. },
  317. };
  318. static struct clk_branch video_cc_mvs0c_shift_clk = {
  319. .halt_reg = 0x812c,
  320. .halt_check = BRANCH_HALT_VOTED,
  321. .hwcg_reg = 0x812c,
  322. .hwcg_bit = 1,
  323. .clkr = {
  324. .enable_reg = 0x812c,
  325. .enable_mask = BIT(0),
  326. .hw.init = &(const struct clk_init_data) {
  327. .name = "video_cc_mvs0c_shift_clk",
  328. .parent_hws = (const struct clk_hw*[]) {
  329. &video_cc_xo_clk_src.clkr.hw,
  330. },
  331. .num_parents = 1,
  332. .flags = CLK_SET_RATE_PARENT,
  333. .ops = &clk_branch2_ops,
  334. },
  335. },
  336. };
  337. static struct clk_branch video_cc_mvs1_clk = {
  338. .halt_reg = 0x80e0,
  339. .halt_check = BRANCH_HALT_SKIP,
  340. .hwcg_reg = 0x80e0,
  341. .hwcg_bit = 1,
  342. .clkr = {
  343. .enable_reg = 0x80e0,
  344. .enable_mask = BIT(0),
  345. .hw.init = &(const struct clk_init_data) {
  346. .name = "video_cc_mvs1_clk",
  347. .parent_hws = (const struct clk_hw*[]) {
  348. &video_cc_mvs1_div_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 video_cc_mvs1_shift_clk = {
  357. .halt_reg = 0x8130,
  358. .halt_check = BRANCH_HALT_VOTED,
  359. .hwcg_reg = 0x8130,
  360. .hwcg_bit = 1,
  361. .clkr = {
  362. .enable_reg = 0x8130,
  363. .enable_mask = BIT(0),
  364. .hw.init = &(const struct clk_init_data) {
  365. .name = "video_cc_mvs1_shift_clk",
  366. .parent_hws = (const struct clk_hw*[]) {
  367. &video_cc_xo_clk_src.clkr.hw,
  368. },
  369. .num_parents = 1,
  370. .flags = CLK_SET_RATE_PARENT,
  371. .ops = &clk_branch2_ops,
  372. },
  373. },
  374. };
  375. static struct clk_branch video_cc_mvs1c_clk = {
  376. .halt_reg = 0x8090,
  377. .halt_check = BRANCH_HALT,
  378. .clkr = {
  379. .enable_reg = 0x8090,
  380. .enable_mask = BIT(0),
  381. .hw.init = &(const struct clk_init_data) {
  382. .name = "video_cc_mvs1c_clk",
  383. .parent_hws = (const struct clk_hw*[]) {
  384. &video_cc_mvs1c_div2_div_clk_src.clkr.hw,
  385. },
  386. .num_parents = 1,
  387. .flags = CLK_SET_RATE_PARENT,
  388. .ops = &clk_branch2_ops,
  389. },
  390. },
  391. };
  392. static struct clk_branch video_cc_mvs1c_shift_clk = {
  393. .halt_reg = 0x8134,
  394. .halt_check = BRANCH_HALT_VOTED,
  395. .hwcg_reg = 0x8134,
  396. .hwcg_bit = 1,
  397. .clkr = {
  398. .enable_reg = 0x8134,
  399. .enable_mask = BIT(0),
  400. .hw.init = &(const struct clk_init_data) {
  401. .name = "video_cc_mvs1c_shift_clk",
  402. .parent_hws = (const struct clk_hw*[]) {
  403. &video_cc_xo_clk_src.clkr.hw,
  404. },
  405. .num_parents = 1,
  406. .flags = CLK_SET_RATE_PARENT,
  407. .ops = &clk_branch2_ops,
  408. },
  409. },
  410. };
  411. static struct gdsc video_cc_mvs0c_gdsc = {
  412. .gdscr = 0x804c,
  413. .en_rest_wait_val = 0x2,
  414. .en_few_wait_val = 0x2,
  415. .clk_dis_wait_val = 0x6,
  416. .pd = {
  417. .name = "video_cc_mvs0c_gdsc",
  418. },
  419. .pwrsts = PWRSTS_OFF_ON,
  420. .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE,
  421. };
  422. static struct gdsc video_cc_mvs0_gdsc = {
  423. .gdscr = 0x80a4,
  424. .en_rest_wait_val = 0x2,
  425. .en_few_wait_val = 0x2,
  426. .clk_dis_wait_val = 0x6,
  427. .pd = {
  428. .name = "video_cc_mvs0_gdsc",
  429. },
  430. .pwrsts = PWRSTS_OFF_ON,
  431. .parent = &video_cc_mvs0c_gdsc.pd,
  432. .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE | HW_CTRL_TRIGGER,
  433. };
  434. static struct gdsc video_cc_mvs1c_gdsc = {
  435. .gdscr = 0x8078,
  436. .en_rest_wait_val = 0x2,
  437. .en_few_wait_val = 0x2,
  438. .clk_dis_wait_val = 0x6,
  439. .pd = {
  440. .name = "video_cc_mvs1c_gdsc",
  441. },
  442. .pwrsts = PWRSTS_OFF_ON,
  443. .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE,
  444. };
  445. static struct gdsc video_cc_mvs1_gdsc = {
  446. .gdscr = 0x80cc,
  447. .en_rest_wait_val = 0x2,
  448. .en_few_wait_val = 0x2,
  449. .clk_dis_wait_val = 0x6,
  450. .pd = {
  451. .name = "video_cc_mvs1_gdsc",
  452. },
  453. .pwrsts = PWRSTS_OFF_ON,
  454. .parent = &video_cc_mvs1c_gdsc.pd,
  455. .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE | HW_CTRL_TRIGGER,
  456. };
  457. static struct clk_regmap *video_cc_sm8550_clocks[] = {
  458. [VIDEO_CC_MVS0_CLK] = &video_cc_mvs0_clk.clkr,
  459. [VIDEO_CC_MVS0_CLK_SRC] = &video_cc_mvs0_clk_src.clkr,
  460. [VIDEO_CC_MVS0_DIV_CLK_SRC] = &video_cc_mvs0_div_clk_src.clkr,
  461. [VIDEO_CC_MVS0C_CLK] = &video_cc_mvs0c_clk.clkr,
  462. [VIDEO_CC_MVS0C_DIV2_DIV_CLK_SRC] = &video_cc_mvs0c_div2_div_clk_src.clkr,
  463. [VIDEO_CC_MVS1_CLK] = &video_cc_mvs1_clk.clkr,
  464. [VIDEO_CC_MVS1_CLK_SRC] = &video_cc_mvs1_clk_src.clkr,
  465. [VIDEO_CC_MVS1_DIV_CLK_SRC] = &video_cc_mvs1_div_clk_src.clkr,
  466. [VIDEO_CC_MVS1C_CLK] = &video_cc_mvs1c_clk.clkr,
  467. [VIDEO_CC_MVS1C_DIV2_DIV_CLK_SRC] = &video_cc_mvs1c_div2_div_clk_src.clkr,
  468. [VIDEO_CC_PLL0] = &video_cc_pll0.clkr,
  469. [VIDEO_CC_PLL1] = &video_cc_pll1.clkr,
  470. [VIDEO_CC_XO_CLK_SRC] = NULL,
  471. };
  472. static struct gdsc *video_cc_sm8550_gdscs[] = {
  473. [VIDEO_CC_MVS0C_GDSC] = &video_cc_mvs0c_gdsc,
  474. [VIDEO_CC_MVS0_GDSC] = &video_cc_mvs0_gdsc,
  475. [VIDEO_CC_MVS1C_GDSC] = &video_cc_mvs1c_gdsc,
  476. [VIDEO_CC_MVS1_GDSC] = &video_cc_mvs1_gdsc,
  477. };
  478. static const struct qcom_reset_map video_cc_sm8550_resets[] = {
  479. [CVP_VIDEO_CC_INTERFACE_BCR] = { 0x80f0 },
  480. [CVP_VIDEO_CC_MVS0_BCR] = { 0x80a0 },
  481. [CVP_VIDEO_CC_MVS0C_BCR] = { 0x8048 },
  482. [CVP_VIDEO_CC_MVS1_BCR] = { 0x80c8 },
  483. [CVP_VIDEO_CC_MVS1C_BCR] = { 0x8074 },
  484. [VIDEO_CC_MVS0C_CLK_ARES] = { .reg = 0x8064, .bit = 2, .udelay = 1000 },
  485. [VIDEO_CC_MVS1C_CLK_ARES] = { .reg = 0x8090, .bit = 2, .udelay = 1000 },
  486. [VIDEO_CC_XO_CLK_ARES] = { .reg = 0x8124, .bit = 2, .udelay = 100 },
  487. };
  488. static struct clk_alpha_pll *video_cc_sm8550_plls[] = {
  489. &video_cc_pll0,
  490. &video_cc_pll1,
  491. };
  492. static u32 video_cc_sm8550_critical_cbcrs[] = {
  493. 0x80f4, /* VIDEO_CC_AHB_CLK */
  494. 0x8124, /* VIDEO_CC_XO_CLK */
  495. 0x8140, /* VIDEO_CC_SLEEP_CLK */
  496. };
  497. static u32 video_cc_sm8650_critical_cbcrs[] = {
  498. 0x80f4, /* VIDEO_CC_AHB_CLK */
  499. 0x8124, /* VIDEO_CC_XO_CLK */
  500. 0x8150, /* VIDEO_CC_SLEEP_CLK */
  501. };
  502. static const struct regmap_config video_cc_sm8550_regmap_config = {
  503. .reg_bits = 32,
  504. .reg_stride = 4,
  505. .val_bits = 32,
  506. .max_register = 0x9f4c,
  507. .fast_io = true,
  508. };
  509. static struct qcom_cc_driver_data video_cc_sm8550_driver_data = {
  510. .alpha_plls = video_cc_sm8550_plls,
  511. .num_alpha_plls = ARRAY_SIZE(video_cc_sm8550_plls),
  512. .clk_cbcrs = video_cc_sm8550_critical_cbcrs,
  513. .num_clk_cbcrs = ARRAY_SIZE(video_cc_sm8550_critical_cbcrs),
  514. };
  515. static const struct qcom_cc_desc video_cc_sm8550_desc = {
  516. .config = &video_cc_sm8550_regmap_config,
  517. .clks = video_cc_sm8550_clocks,
  518. .num_clks = ARRAY_SIZE(video_cc_sm8550_clocks),
  519. .resets = video_cc_sm8550_resets,
  520. .num_resets = ARRAY_SIZE(video_cc_sm8550_resets),
  521. .gdscs = video_cc_sm8550_gdscs,
  522. .num_gdscs = ARRAY_SIZE(video_cc_sm8550_gdscs),
  523. .use_rpm = true,
  524. .driver_data = &video_cc_sm8550_driver_data,
  525. };
  526. static const struct of_device_id video_cc_sm8550_match_table[] = {
  527. { .compatible = "qcom,sm8550-videocc" },
  528. { .compatible = "qcom,sm8650-videocc" },
  529. { .compatible = "qcom,x1e80100-videocc" },
  530. { }
  531. };
  532. MODULE_DEVICE_TABLE(of, video_cc_sm8550_match_table);
  533. static int video_cc_sm8550_probe(struct platform_device *pdev)
  534. {
  535. if (of_device_is_compatible(pdev->dev.of_node, "qcom,x1e80100-videocc")) {
  536. video_cc_pll0_config.l = 0x1e;
  537. video_cc_pll0_config.alpha = 0x0000;
  538. video_cc_pll1_config.l = 0x2b;
  539. video_cc_pll1_config.alpha = 0xc000;
  540. video_cc_mvs0_clk_src.freq_tbl = ftbl_video_cc_mvs0_clk_src_x1e80100;
  541. video_cc_mvs1_clk_src.freq_tbl = ftbl_video_cc_mvs1_clk_src_x1e80100;
  542. }
  543. if (of_device_is_compatible(pdev->dev.of_node, "qcom,sm8650-videocc")) {
  544. video_cc_pll0_config.l = 0x1e;
  545. video_cc_pll0_config.alpha = 0xa000;
  546. video_cc_pll1_config.l = 0x2b;
  547. video_cc_pll1_config.alpha = 0xc000;
  548. video_cc_mvs0_clk_src.freq_tbl = ftbl_video_cc_mvs0_clk_src_sm8650;
  549. video_cc_mvs1_clk_src.freq_tbl = ftbl_video_cc_mvs1_clk_src_sm8650;
  550. video_cc_sm8550_clocks[VIDEO_CC_MVS0_SHIFT_CLK] = &video_cc_mvs0_shift_clk.clkr;
  551. video_cc_sm8550_clocks[VIDEO_CC_MVS0C_SHIFT_CLK] = &video_cc_mvs0c_shift_clk.clkr;
  552. video_cc_sm8550_clocks[VIDEO_CC_MVS1_SHIFT_CLK] = &video_cc_mvs1_shift_clk.clkr;
  553. video_cc_sm8550_clocks[VIDEO_CC_MVS1C_SHIFT_CLK] = &video_cc_mvs1c_shift_clk.clkr;
  554. video_cc_sm8550_clocks[VIDEO_CC_XO_CLK_SRC] = &video_cc_xo_clk_src.clkr;
  555. video_cc_sm8550_driver_data.clk_cbcrs = video_cc_sm8650_critical_cbcrs;
  556. video_cc_sm8550_driver_data.num_clk_cbcrs =
  557. ARRAY_SIZE(video_cc_sm8650_critical_cbcrs);
  558. }
  559. return qcom_cc_probe(pdev, &video_cc_sm8550_desc);
  560. }
  561. static struct platform_driver video_cc_sm8550_driver = {
  562. .probe = video_cc_sm8550_probe,
  563. .driver = {
  564. .name = "video_cc-sm8550",
  565. .of_match_table = video_cc_sm8550_match_table,
  566. },
  567. };
  568. module_platform_driver(video_cc_sm8550_driver);
  569. MODULE_DESCRIPTION("QTI VIDEOCC SM8550 Driver");
  570. MODULE_LICENSE("GPL");