videocc-sm8350.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023, Linaro Limited
  5. */
  6. #include <linux/clk-provider.h>
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/pm_clock.h>
  10. #include <linux/pm_runtime.h>
  11. #include <linux/regmap.h>
  12. #include <dt-bindings/clock/qcom,sm8350-videocc.h>
  13. #include <dt-bindings/reset/qcom,sm8350-videocc.h>
  14. #include "clk-alpha-pll.h"
  15. #include "clk-branch.h"
  16. #include "clk-rcg.h"
  17. #include "clk-regmap.h"
  18. #include "clk-regmap-divider.h"
  19. #include "common.h"
  20. #include "reset.h"
  21. #include "gdsc.h"
  22. enum {
  23. DT_BI_TCXO,
  24. DT_BI_TCXO_AO,
  25. DT_SLEEP_CLK,
  26. };
  27. enum {
  28. P_BI_TCXO,
  29. P_BI_TCXO_AO,
  30. P_SLEEP_CLK,
  31. P_VIDEO_PLL0_OUT_MAIN,
  32. P_VIDEO_PLL1_OUT_MAIN,
  33. };
  34. static const struct pll_vco lucid_5lpe_vco[] = {
  35. { 249600000, 1750000000, 0 },
  36. };
  37. static const struct pll_vco lucid_5lpe_vco_8280xp[] = {
  38. { 249600000, 1800000000, 0 },
  39. };
  40. static const struct alpha_pll_config video_pll0_config = {
  41. .l = 0x25,
  42. .alpha = 0x8000,
  43. .config_ctl_val = 0x20485699,
  44. .config_ctl_hi_val = 0x00002261,
  45. .config_ctl_hi1_val = 0x2a9a699c,
  46. .test_ctl_val = 0x00000000,
  47. .test_ctl_hi_val = 0x00000000,
  48. .test_ctl_hi1_val = 0x01800000,
  49. .user_ctl_val = 0x00000000,
  50. .user_ctl_hi_val = 0x00000805,
  51. .user_ctl_hi1_val = 0x00000000,
  52. };
  53. static struct clk_alpha_pll video_pll0 = {
  54. .offset = 0x42c,
  55. .vco_table = lucid_5lpe_vco,
  56. .num_vco = ARRAY_SIZE(lucid_5lpe_vco),
  57. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  58. .clkr = {
  59. .hw.init = &(const struct clk_init_data) {
  60. .name = "video_pll0",
  61. .parent_data = &(const struct clk_parent_data){
  62. .index = DT_BI_TCXO,
  63. },
  64. .num_parents = 1,
  65. .ops = &clk_alpha_pll_lucid_5lpe_ops,
  66. },
  67. },
  68. };
  69. static const struct alpha_pll_config video_pll1_config = {
  70. .l = 0x2b,
  71. .alpha = 0xc000,
  72. .config_ctl_val = 0x20485699,
  73. .config_ctl_hi_val = 0x00002261,
  74. .config_ctl_hi1_val = 0x2a9a699c,
  75. .test_ctl_val = 0x00000000,
  76. .test_ctl_hi_val = 0x00000000,
  77. .test_ctl_hi1_val = 0x01800000,
  78. .user_ctl_val = 0x00000000,
  79. .user_ctl_hi_val = 0x00000805,
  80. .user_ctl_hi1_val = 0x00000000,
  81. };
  82. static struct clk_alpha_pll video_pll1 = {
  83. .offset = 0x7d0,
  84. .vco_table = lucid_5lpe_vco,
  85. .num_vco = ARRAY_SIZE(lucid_5lpe_vco),
  86. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  87. .clkr = {
  88. .hw.init = &(const struct clk_init_data) {
  89. .name = "video_pll1",
  90. .parent_data = &(const struct clk_parent_data){
  91. .index = DT_BI_TCXO,
  92. },
  93. .num_parents = 1,
  94. .ops = &clk_alpha_pll_lucid_5lpe_ops,
  95. },
  96. },
  97. };
  98. static const struct parent_map video_cc_parent_map_0[] = {
  99. { P_BI_TCXO_AO, 0 },
  100. };
  101. static const struct clk_parent_data video_cc_parent_data_0[] = {
  102. { .index = DT_BI_TCXO_AO },
  103. };
  104. static const struct parent_map video_cc_parent_map_1[] = {
  105. { P_BI_TCXO, 0 },
  106. { P_VIDEO_PLL0_OUT_MAIN, 1 },
  107. };
  108. static const struct clk_parent_data video_cc_parent_data_1[] = {
  109. { .index = DT_BI_TCXO },
  110. { .hw = &video_pll0.clkr.hw },
  111. };
  112. static const struct parent_map video_cc_parent_map_2[] = {
  113. { P_BI_TCXO, 0 },
  114. { P_VIDEO_PLL1_OUT_MAIN, 1 },
  115. };
  116. static const struct clk_parent_data video_cc_parent_data_2[] = {
  117. { .index = DT_BI_TCXO },
  118. { .hw = &video_pll1.clkr.hw },
  119. };
  120. static const struct freq_tbl ftbl_video_cc_ahb_clk_src[] = {
  121. F(19200000, P_BI_TCXO, 1, 0, 0),
  122. { }
  123. };
  124. static struct clk_rcg2 video_cc_ahb_clk_src = {
  125. .cmd_rcgr = 0xbd4,
  126. .mnd_width = 0,
  127. .hid_width = 5,
  128. .parent_map = video_cc_parent_map_0,
  129. .freq_tbl = ftbl_video_cc_ahb_clk_src,
  130. .clkr.hw.init = &(const struct clk_init_data) {
  131. .name = "video_cc_ahb_clk_src",
  132. .parent_data = video_cc_parent_data_0,
  133. .num_parents = ARRAY_SIZE(video_cc_parent_data_0),
  134. .flags = CLK_SET_RATE_PARENT,
  135. .ops = &clk_rcg2_shared_ops,
  136. },
  137. };
  138. static const struct freq_tbl ftbl_video_cc_mvs0_clk_src[] = {
  139. F(720000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  140. F(1014000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  141. F(1098000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  142. F(1332000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  143. { }
  144. };
  145. static const struct freq_tbl ftbl_video_cc_mvs0_clk_src_8280xp[] = {
  146. F(720000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  147. F(1014000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  148. F(1098000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  149. F(1332000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  150. F(1599000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  151. F(1680000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  152. { }
  153. };
  154. static struct clk_rcg2 video_cc_mvs0_clk_src = {
  155. .cmd_rcgr = 0xb94,
  156. .mnd_width = 0,
  157. .hid_width = 5,
  158. .parent_map = video_cc_parent_map_1,
  159. .freq_tbl = ftbl_video_cc_mvs0_clk_src,
  160. .clkr.hw.init = &(const struct clk_init_data) {
  161. .name = "video_cc_mvs0_clk_src",
  162. .parent_data = video_cc_parent_data_1,
  163. .num_parents = ARRAY_SIZE(video_cc_parent_data_1),
  164. .flags = CLK_SET_RATE_PARENT,
  165. .ops = &clk_rcg2_shared_ops,
  166. },
  167. };
  168. static const struct freq_tbl ftbl_video_cc_mvs1_clk_src[] = {
  169. F(840000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  170. F(1098000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  171. F(1332000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  172. { }
  173. };
  174. static const struct freq_tbl ftbl_video_cc_mvs1_clk_src_8280xp[] = {
  175. F(840000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  176. F(1098000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  177. F(1332000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  178. F(1600000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  179. F(1800000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  180. { }
  181. };
  182. static struct clk_rcg2 video_cc_mvs1_clk_src = {
  183. .cmd_rcgr = 0xbb4,
  184. .mnd_width = 0,
  185. .hid_width = 5,
  186. .parent_map = video_cc_parent_map_2,
  187. .freq_tbl = ftbl_video_cc_mvs1_clk_src,
  188. .clkr.hw.init = &(const struct clk_init_data) {
  189. .name = "video_cc_mvs1_clk_src",
  190. .parent_data = video_cc_parent_data_2,
  191. .num_parents = ARRAY_SIZE(video_cc_parent_data_2),
  192. .flags = CLK_SET_RATE_PARENT,
  193. .ops = &clk_rcg2_shared_ops,
  194. },
  195. };
  196. static const struct freq_tbl ftbl_video_cc_sleep_clk_src[] = {
  197. F(32000, P_SLEEP_CLK, 1, 0, 0),
  198. { }
  199. };
  200. static struct clk_rcg2 video_cc_sleep_clk_src = {
  201. .cmd_rcgr = 0xef0,
  202. .mnd_width = 0,
  203. .hid_width = 5,
  204. .freq_tbl = ftbl_video_cc_sleep_clk_src,
  205. .clkr.hw.init = &(const struct clk_init_data) {
  206. .name = "video_cc_sleep_clk_src",
  207. .parent_data = &(const struct clk_parent_data){
  208. .index = DT_SLEEP_CLK,
  209. },
  210. .num_parents = 1,
  211. .flags = CLK_SET_RATE_PARENT,
  212. .ops = &clk_rcg2_ops,
  213. },
  214. };
  215. static struct clk_rcg2 video_cc_xo_clk_src = {
  216. .cmd_rcgr = 0xecc,
  217. .mnd_width = 0,
  218. .hid_width = 5,
  219. .parent_map = video_cc_parent_map_0,
  220. .freq_tbl = ftbl_video_cc_ahb_clk_src,
  221. .clkr.hw.init = &(const struct clk_init_data) {
  222. .name = "video_cc_xo_clk_src",
  223. .parent_data = video_cc_parent_data_0,
  224. .num_parents = ARRAY_SIZE(video_cc_parent_data_0),
  225. .flags = CLK_SET_RATE_PARENT,
  226. .ops = &clk_rcg2_ops,
  227. },
  228. };
  229. static struct clk_regmap_div video_cc_mvs0_div_clk_src = {
  230. .reg = 0xd54,
  231. .shift = 0,
  232. .width = 4,
  233. .clkr.hw.init = &(const struct clk_init_data) {
  234. .name = "video_cc_mvs0_div_clk_src",
  235. .parent_hws = (const struct clk_hw*[]){
  236. &video_cc_mvs0_clk_src.clkr.hw,
  237. },
  238. .num_parents = 1,
  239. .flags = CLK_SET_RATE_PARENT,
  240. .ops = &clk_regmap_div_ro_ops,
  241. },
  242. };
  243. static struct clk_regmap_div video_cc_mvs0c_div2_div_clk_src = {
  244. .reg = 0xc54,
  245. .shift = 0,
  246. .width = 4,
  247. .clkr.hw.init = &(const struct clk_init_data) {
  248. .name = "video_cc_mvs0c_div2_div_clk_src",
  249. .parent_hws = (const struct clk_hw*[]){
  250. &video_cc_mvs0_clk_src.clkr.hw,
  251. },
  252. .num_parents = 1,
  253. .flags = CLK_SET_RATE_PARENT,
  254. .ops = &clk_regmap_div_ro_ops,
  255. },
  256. };
  257. static struct clk_regmap_div video_cc_mvs1_div_clk_src = {
  258. .reg = 0xdd4,
  259. .shift = 0,
  260. .width = 4,
  261. .clkr.hw.init = &(const struct clk_init_data) {
  262. .name = "video_cc_mvs1_div_clk_src",
  263. .parent_hws = (const struct clk_hw*[]){
  264. &video_cc_mvs1_clk_src.clkr.hw,
  265. },
  266. .num_parents = 1,
  267. .flags = CLK_SET_RATE_PARENT,
  268. .ops = &clk_regmap_div_ro_ops,
  269. },
  270. };
  271. static struct clk_regmap_div video_cc_mvs1c_div2_div_clk_src = {
  272. .reg = 0xcf4,
  273. .shift = 0,
  274. .width = 4,
  275. .clkr.hw.init = &(const struct clk_init_data) {
  276. .name = "video_cc_mvs1c_div2_div_clk_src",
  277. .parent_hws = (const struct clk_hw*[]){
  278. &video_cc_mvs1_clk_src.clkr.hw,
  279. },
  280. .num_parents = 1,
  281. .flags = CLK_SET_RATE_PARENT,
  282. .ops = &clk_regmap_div_ro_ops,
  283. },
  284. };
  285. static struct clk_branch video_cc_mvs0_clk = {
  286. .halt_reg = 0xd34,
  287. .halt_check = BRANCH_HALT_VOTED,
  288. .hwcg_reg = 0xd34,
  289. .hwcg_bit = 1,
  290. .clkr = {
  291. .enable_reg = 0xd34,
  292. .enable_mask = BIT(0),
  293. .hw.init = &(const struct clk_init_data) {
  294. .name = "video_cc_mvs0_clk",
  295. .parent_hws = (const struct clk_hw*[]){
  296. &video_cc_mvs0_div_clk_src.clkr.hw,
  297. },
  298. .num_parents = 1,
  299. .flags = CLK_SET_RATE_PARENT,
  300. .ops = &clk_branch2_ops,
  301. },
  302. },
  303. };
  304. static struct clk_branch video_cc_mvs0c_clk = {
  305. .halt_reg = 0xc34,
  306. .halt_check = BRANCH_HALT,
  307. .clkr = {
  308. .enable_reg = 0xc34,
  309. .enable_mask = BIT(0),
  310. .hw.init = &(const struct clk_init_data) {
  311. .name = "video_cc_mvs0c_clk",
  312. .parent_hws = (const struct clk_hw*[]){
  313. &video_cc_mvs0c_div2_div_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 video_cc_mvs1_clk = {
  322. .halt_reg = 0xdb4,
  323. .halt_check = BRANCH_HALT_VOTED,
  324. .hwcg_reg = 0xdb4,
  325. .hwcg_bit = 1,
  326. .clkr = {
  327. .enable_reg = 0xdb4,
  328. .enable_mask = BIT(0),
  329. .hw.init = &(const struct clk_init_data) {
  330. .name = "video_cc_mvs1_clk",
  331. .parent_hws = (const struct clk_hw*[]){
  332. &video_cc_mvs1_div_clk_src.clkr.hw,
  333. },
  334. .num_parents = 1,
  335. .flags = CLK_SET_RATE_PARENT,
  336. .ops = &clk_branch2_ops,
  337. },
  338. },
  339. };
  340. static struct clk_branch video_cc_mvs1_div2_clk = {
  341. .halt_reg = 0xdf4,
  342. .halt_check = BRANCH_HALT_VOTED,
  343. .hwcg_reg = 0xdf4,
  344. .hwcg_bit = 1,
  345. .clkr = {
  346. .enable_reg = 0xdf4,
  347. .enable_mask = BIT(0),
  348. .hw.init = &(const struct clk_init_data) {
  349. .name = "video_cc_mvs1_div2_clk",
  350. .parent_hws = (const struct clk_hw*[]){
  351. &video_cc_mvs1c_div2_div_clk_src.clkr.hw,
  352. },
  353. .num_parents = 1,
  354. .flags = CLK_SET_RATE_PARENT,
  355. .ops = &clk_branch2_ops,
  356. },
  357. },
  358. };
  359. static struct clk_branch video_cc_mvs1c_clk = {
  360. .halt_reg = 0xcd4,
  361. .halt_check = BRANCH_HALT,
  362. .clkr = {
  363. .enable_reg = 0xcd4,
  364. .enable_mask = BIT(0),
  365. .hw.init = &(const struct clk_init_data) {
  366. .name = "video_cc_mvs1c_clk",
  367. .parent_hws = (const struct clk_hw*[]){
  368. &video_cc_mvs1c_div2_div_clk_src.clkr.hw,
  369. },
  370. .num_parents = 1,
  371. .flags = CLK_SET_RATE_PARENT,
  372. .ops = &clk_branch2_ops,
  373. },
  374. },
  375. };
  376. static struct clk_branch video_cc_sleep_clk = {
  377. .halt_reg = 0xf10,
  378. .halt_check = BRANCH_HALT,
  379. .clkr = {
  380. .enable_reg = 0xf10,
  381. .enable_mask = BIT(0),
  382. .hw.init = &(const struct clk_init_data) {
  383. .name = "video_cc_sleep_clk",
  384. .parent_hws = (const struct clk_hw*[]){
  385. &video_cc_sleep_clk_src.clkr.hw,
  386. },
  387. .num_parents = 1,
  388. .flags = CLK_SET_RATE_PARENT,
  389. .ops = &clk_branch2_ops,
  390. },
  391. },
  392. };
  393. static struct gdsc mvs0c_gdsc = {
  394. .gdscr = 0xbf8,
  395. .pd = {
  396. .name = "mvs0c_gdsc",
  397. },
  398. .flags = RETAIN_FF_ENABLE,
  399. .pwrsts = PWRSTS_OFF_ON,
  400. };
  401. static struct gdsc mvs1c_gdsc = {
  402. .gdscr = 0xc98,
  403. .pd = {
  404. .name = "mvs1c_gdsc",
  405. },
  406. .flags = RETAIN_FF_ENABLE,
  407. .pwrsts = PWRSTS_OFF_ON,
  408. };
  409. static struct gdsc mvs0_gdsc = {
  410. .gdscr = 0xd18,
  411. .pd = {
  412. .name = "mvs0_gdsc",
  413. },
  414. .flags = HW_CTRL_TRIGGER | RETAIN_FF_ENABLE,
  415. .pwrsts = PWRSTS_OFF_ON,
  416. };
  417. static struct gdsc mvs1_gdsc = {
  418. .gdscr = 0xd98,
  419. .pd = {
  420. .name = "mvs1_gdsc",
  421. },
  422. .flags = HW_CTRL_TRIGGER | RETAIN_FF_ENABLE,
  423. .pwrsts = PWRSTS_OFF_ON,
  424. };
  425. static struct clk_regmap *video_cc_sm8350_clocks[] = {
  426. [VIDEO_CC_AHB_CLK_SRC] = &video_cc_ahb_clk_src.clkr,
  427. [VIDEO_CC_MVS0_CLK] = &video_cc_mvs0_clk.clkr,
  428. [VIDEO_CC_MVS0_CLK_SRC] = &video_cc_mvs0_clk_src.clkr,
  429. [VIDEO_CC_MVS0_DIV_CLK_SRC] = &video_cc_mvs0_div_clk_src.clkr,
  430. [VIDEO_CC_MVS0C_CLK] = &video_cc_mvs0c_clk.clkr,
  431. [VIDEO_CC_MVS0C_DIV2_DIV_CLK_SRC] = &video_cc_mvs0c_div2_div_clk_src.clkr,
  432. [VIDEO_CC_MVS1_CLK] = &video_cc_mvs1_clk.clkr,
  433. [VIDEO_CC_MVS1_CLK_SRC] = &video_cc_mvs1_clk_src.clkr,
  434. [VIDEO_CC_MVS1_DIV2_CLK] = &video_cc_mvs1_div2_clk.clkr,
  435. [VIDEO_CC_MVS1_DIV_CLK_SRC] = &video_cc_mvs1_div_clk_src.clkr,
  436. [VIDEO_CC_MVS1C_CLK] = &video_cc_mvs1c_clk.clkr,
  437. [VIDEO_CC_MVS1C_DIV2_DIV_CLK_SRC] = &video_cc_mvs1c_div2_div_clk_src.clkr,
  438. [VIDEO_CC_SLEEP_CLK] = &video_cc_sleep_clk.clkr,
  439. [VIDEO_CC_SLEEP_CLK_SRC] = &video_cc_sleep_clk_src.clkr,
  440. [VIDEO_CC_XO_CLK_SRC] = &video_cc_xo_clk_src.clkr,
  441. [VIDEO_PLL0] = &video_pll0.clkr,
  442. [VIDEO_PLL1] = &video_pll1.clkr,
  443. };
  444. static const struct qcom_reset_map video_cc_sm8350_resets[] = {
  445. [VIDEO_CC_CVP_INTERFACE_BCR] = { 0xe54 },
  446. [VIDEO_CC_CVP_MVS0_BCR] = { 0xd14 },
  447. [VIDEO_CC_MVS0C_CLK_ARES] = { .reg = 0xc34, .bit = 2, .udelay = 400 },
  448. [VIDEO_CC_CVP_MVS0C_BCR] = { 0xbf4 },
  449. [VIDEO_CC_CVP_MVS1_BCR] = { 0xd94 },
  450. [VIDEO_CC_MVS1C_CLK_ARES] = { .reg = 0xcd4, .bit = 2, .udelay = 400 },
  451. [VIDEO_CC_CVP_MVS1C_BCR] = { 0xc94 },
  452. };
  453. static struct gdsc *video_cc_sm8350_gdscs[] = {
  454. [MVS0C_GDSC] = &mvs0c_gdsc,
  455. [MVS1C_GDSC] = &mvs1c_gdsc,
  456. [MVS0_GDSC] = &mvs0_gdsc,
  457. [MVS1_GDSC] = &mvs1_gdsc,
  458. };
  459. static const struct regmap_config video_cc_sm8350_regmap_config = {
  460. .reg_bits = 32,
  461. .reg_stride = 4,
  462. .val_bits = 32,
  463. .max_register = 0x10000,
  464. .fast_io = true,
  465. };
  466. static struct qcom_cc_desc video_cc_sm8350_desc = {
  467. .config = &video_cc_sm8350_regmap_config,
  468. .clks = video_cc_sm8350_clocks,
  469. .num_clks = ARRAY_SIZE(video_cc_sm8350_clocks),
  470. .resets = video_cc_sm8350_resets,
  471. .num_resets = ARRAY_SIZE(video_cc_sm8350_resets),
  472. .gdscs = video_cc_sm8350_gdscs,
  473. .num_gdscs = ARRAY_SIZE(video_cc_sm8350_gdscs),
  474. };
  475. static int video_cc_sm8350_probe(struct platform_device *pdev)
  476. {
  477. u32 video_cc_xo_clk_cbcr = 0xeec;
  478. struct regmap *regmap;
  479. int ret;
  480. ret = devm_pm_runtime_enable(&pdev->dev);
  481. if (ret)
  482. return ret;
  483. ret = pm_runtime_resume_and_get(&pdev->dev);
  484. if (ret)
  485. return ret;
  486. if (of_device_is_compatible(pdev->dev.of_node, "qcom,sc8280xp-videocc")) {
  487. video_cc_sleep_clk_src.cmd_rcgr = 0xf38;
  488. video_cc_sleep_clk.halt_reg = 0xf58;
  489. video_cc_sleep_clk.clkr.enable_reg = 0xf58;
  490. video_cc_xo_clk_src.cmd_rcgr = 0xf14;
  491. video_cc_xo_clk_cbcr = 0xf34;
  492. video_pll0.vco_table = video_pll1.vco_table = lucid_5lpe_vco_8280xp;
  493. /* No change, but assign it for completeness */
  494. video_pll0.num_vco = video_pll1.num_vco = ARRAY_SIZE(lucid_5lpe_vco_8280xp);
  495. video_cc_mvs0_clk_src.freq_tbl = ftbl_video_cc_mvs0_clk_src_8280xp;
  496. video_cc_mvs1_clk_src.freq_tbl = ftbl_video_cc_mvs1_clk_src_8280xp;
  497. }
  498. regmap = qcom_cc_map(pdev, &video_cc_sm8350_desc);
  499. if (IS_ERR(regmap)) {
  500. pm_runtime_put(&pdev->dev);
  501. return PTR_ERR(regmap);
  502. }
  503. clk_lucid_pll_configure(&video_pll0, regmap, &video_pll0_config);
  504. clk_lucid_pll_configure(&video_pll1, regmap, &video_pll1_config);
  505. /* Keep some clocks always-on */
  506. qcom_branch_set_clk_en(regmap, 0xe58); /* VIDEO_CC_AHB_CLK */
  507. qcom_branch_set_clk_en(regmap, video_cc_xo_clk_cbcr); /* VIDEO_CC_XO_CLK */
  508. ret = qcom_cc_really_probe(&pdev->dev, &video_cc_sm8350_desc, regmap);
  509. pm_runtime_put(&pdev->dev);
  510. return ret;
  511. }
  512. static const struct of_device_id video_cc_sm8350_match_table[] = {
  513. { .compatible = "qcom,sc8280xp-videocc" },
  514. { .compatible = "qcom,sm8350-videocc" },
  515. { }
  516. };
  517. MODULE_DEVICE_TABLE(of, video_cc_sm8350_match_table);
  518. static struct platform_driver video_cc_sm8350_driver = {
  519. .probe = video_cc_sm8350_probe,
  520. .driver = {
  521. .name = "sm8350-videocc",
  522. .of_match_table = video_cc_sm8350_match_table,
  523. },
  524. };
  525. module_platform_driver(video_cc_sm8350_driver);
  526. MODULE_DESCRIPTION("QTI SM8350 VIDEOCC Driver");
  527. MODULE_LICENSE("GPL");