videocc-sa8775p.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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/pm_runtime.h>
  11. #include <linux/regmap.h>
  12. #include <dt-bindings/clock/qcom,sa8775p-videocc.h>
  13. #include "clk-alpha-pll.h"
  14. #include "clk-branch.h"
  15. #include "clk-pll.h"
  16. #include "clk-rcg.h"
  17. #include "clk-regmap.h"
  18. #include "clk-regmap-divider.h"
  19. #include "clk-regmap-mux.h"
  20. #include "common.h"
  21. #include "gdsc.h"
  22. #include "reset.h"
  23. enum {
  24. DT_IFACE,
  25. DT_BI_TCXO,
  26. DT_BI_TCXO_AO,
  27. DT_SLEEP_CLK,
  28. };
  29. enum {
  30. P_BI_TCXO,
  31. P_BI_TCXO_AO,
  32. P_SLEEP_CLK,
  33. P_VIDEO_PLL0_OUT_MAIN,
  34. P_VIDEO_PLL1_OUT_MAIN,
  35. };
  36. static const struct pll_vco lucid_evo_vco[] = {
  37. { 249600000, 2020000000, 0 },
  38. };
  39. static const struct alpha_pll_config video_pll0_config = {
  40. .l = 0x39,
  41. .alpha = 0x3000,
  42. .config_ctl_val = 0x20485699,
  43. .config_ctl_hi_val = 0x00182261,
  44. .config_ctl_hi1_val = 0x32aa299c,
  45. .user_ctl_val = 0x00000000,
  46. .user_ctl_hi_val = 0x00400805,
  47. };
  48. static struct clk_alpha_pll video_pll0 = {
  49. .offset = 0x0,
  50. .vco_table = lucid_evo_vco,
  51. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  52. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  53. .clkr = {
  54. .hw.init = &(const struct clk_init_data) {
  55. .name = "video_pll0",
  56. .parent_data = &(const struct clk_parent_data) {
  57. .index = DT_BI_TCXO,
  58. },
  59. .num_parents = 1,
  60. .ops = &clk_alpha_pll_lucid_evo_ops,
  61. },
  62. },
  63. };
  64. static const struct alpha_pll_config video_pll1_config = {
  65. .l = 0x39,
  66. .alpha = 0x3000,
  67. .config_ctl_val = 0x20485699,
  68. .config_ctl_hi_val = 0x00182261,
  69. .config_ctl_hi1_val = 0x32aa299c,
  70. .user_ctl_val = 0x00000000,
  71. .user_ctl_hi_val = 0x00400805,
  72. };
  73. static struct clk_alpha_pll video_pll1 = {
  74. .offset = 0x1000,
  75. .vco_table = lucid_evo_vco,
  76. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  77. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  78. .clkr = {
  79. .hw.init = &(const struct clk_init_data) {
  80. .name = "video_pll1",
  81. .parent_data = &(const struct clk_parent_data) {
  82. .index = DT_BI_TCXO,
  83. },
  84. .num_parents = 1,
  85. .ops = &clk_alpha_pll_lucid_evo_ops,
  86. },
  87. },
  88. };
  89. static const struct parent_map video_cc_parent_map_0_ao[] = {
  90. { P_BI_TCXO_AO, 0 },
  91. };
  92. static const struct clk_parent_data video_cc_parent_data_0_ao[] = {
  93. { .index = DT_BI_TCXO_AO },
  94. };
  95. static const struct parent_map video_cc_parent_map_1[] = {
  96. { P_BI_TCXO, 0 },
  97. { P_VIDEO_PLL0_OUT_MAIN, 1 },
  98. };
  99. static const struct clk_parent_data video_cc_parent_data_1[] = {
  100. { .index = DT_BI_TCXO },
  101. { .hw = &video_pll0.clkr.hw },
  102. };
  103. static const struct parent_map video_cc_parent_map_2[] = {
  104. { P_BI_TCXO, 0 },
  105. { P_VIDEO_PLL1_OUT_MAIN, 1 },
  106. };
  107. static const struct clk_parent_data video_cc_parent_data_2[] = {
  108. { .index = DT_BI_TCXO },
  109. { .hw = &video_pll1.clkr.hw },
  110. };
  111. static const struct parent_map video_cc_parent_map_3[] = {
  112. { P_SLEEP_CLK, 0 },
  113. };
  114. static const struct clk_parent_data video_cc_parent_data_3[] = {
  115. { .index = DT_SLEEP_CLK },
  116. };
  117. static const struct freq_tbl ftbl_video_cc_ahb_clk_src[] = {
  118. F(19200000, P_BI_TCXO_AO, 1, 0, 0),
  119. { }
  120. };
  121. static struct clk_rcg2 video_cc_ahb_clk_src = {
  122. .cmd_rcgr = 0x8030,
  123. .mnd_width = 0,
  124. .hid_width = 5,
  125. .parent_map = video_cc_parent_map_0_ao,
  126. .freq_tbl = ftbl_video_cc_ahb_clk_src,
  127. .clkr.hw.init = &(const struct clk_init_data) {
  128. .name = "video_cc_ahb_clk_src",
  129. .parent_data = video_cc_parent_data_0_ao,
  130. .num_parents = ARRAY_SIZE(video_cc_parent_data_0_ao),
  131. .flags = CLK_SET_RATE_PARENT,
  132. .ops = &clk_rcg2_shared_ops,
  133. },
  134. };
  135. static const struct freq_tbl ftbl_video_cc_mvs0_clk_src[] = {
  136. F(1098000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  137. F(1332000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  138. F(1599000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  139. F(1680000000, P_VIDEO_PLL0_OUT_MAIN, 1, 0, 0),
  140. { }
  141. };
  142. static struct clk_rcg2 video_cc_mvs0_clk_src = {
  143. .cmd_rcgr = 0x8000,
  144. .mnd_width = 0,
  145. .hid_width = 5,
  146. .parent_map = video_cc_parent_map_1,
  147. .freq_tbl = ftbl_video_cc_mvs0_clk_src,
  148. .clkr.hw.init = &(const struct clk_init_data) {
  149. .name = "video_cc_mvs0_clk_src",
  150. .parent_data = video_cc_parent_data_1,
  151. .num_parents = ARRAY_SIZE(video_cc_parent_data_1),
  152. .flags = CLK_SET_RATE_PARENT,
  153. .ops = &clk_rcg2_shared_ops,
  154. },
  155. };
  156. static const struct freq_tbl ftbl_video_cc_mvs1_clk_src[] = {
  157. F(1098000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  158. F(1332000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  159. F(1600000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  160. F(1800000000, P_VIDEO_PLL1_OUT_MAIN, 1, 0, 0),
  161. { }
  162. };
  163. static struct clk_rcg2 video_cc_mvs1_clk_src = {
  164. .cmd_rcgr = 0x8018,
  165. .mnd_width = 0,
  166. .hid_width = 5,
  167. .parent_map = video_cc_parent_map_2,
  168. .freq_tbl = ftbl_video_cc_mvs1_clk_src,
  169. .clkr.hw.init = &(const struct clk_init_data) {
  170. .name = "video_cc_mvs1_clk_src",
  171. .parent_data = video_cc_parent_data_2,
  172. .num_parents = ARRAY_SIZE(video_cc_parent_data_2),
  173. .flags = CLK_SET_RATE_PARENT,
  174. .ops = &clk_rcg2_shared_ops,
  175. },
  176. };
  177. static const struct freq_tbl ftbl_video_cc_sleep_clk_src[] = {
  178. F(32000, P_SLEEP_CLK, 1, 0, 0),
  179. { }
  180. };
  181. static struct clk_rcg2 video_cc_sleep_clk_src = {
  182. .cmd_rcgr = 0x812c,
  183. .mnd_width = 0,
  184. .hid_width = 5,
  185. .parent_map = video_cc_parent_map_3,
  186. .freq_tbl = ftbl_video_cc_sleep_clk_src,
  187. .clkr.hw.init = &(const struct clk_init_data) {
  188. .name = "video_cc_sleep_clk_src",
  189. .parent_data = video_cc_parent_data_3,
  190. .num_parents = ARRAY_SIZE(video_cc_parent_data_3),
  191. .flags = CLK_SET_RATE_PARENT,
  192. .ops = &clk_rcg2_shared_ops,
  193. },
  194. };
  195. static struct clk_rcg2 video_cc_xo_clk_src = {
  196. .cmd_rcgr = 0x8110,
  197. .mnd_width = 0,
  198. .hid_width = 5,
  199. .parent_map = video_cc_parent_map_0_ao,
  200. .freq_tbl = ftbl_video_cc_ahb_clk_src,
  201. .clkr.hw.init = &(const struct clk_init_data) {
  202. .name = "video_cc_xo_clk_src",
  203. .parent_data = video_cc_parent_data_0_ao,
  204. .num_parents = ARRAY_SIZE(video_cc_parent_data_0_ao),
  205. .flags = CLK_SET_RATE_PARENT,
  206. .ops = &clk_rcg2_shared_ops,
  207. },
  208. };
  209. static struct clk_regmap_div video_cc_mvs0_div_clk_src = {
  210. .reg = 0x80b8,
  211. .shift = 0,
  212. .width = 4,
  213. .clkr.hw.init = &(const struct clk_init_data) {
  214. .name = "video_cc_mvs0_div_clk_src",
  215. .parent_hws = (const struct clk_hw*[]) {
  216. &video_cc_mvs0_clk_src.clkr.hw,
  217. },
  218. .num_parents = 1,
  219. .flags = CLK_SET_RATE_PARENT,
  220. .ops = &clk_regmap_div_ro_ops,
  221. },
  222. };
  223. static struct clk_regmap_div video_cc_mvs0c_div2_div_clk_src = {
  224. .reg = 0x806c,
  225. .shift = 0,
  226. .width = 4,
  227. .clkr.hw.init = &(const struct clk_init_data) {
  228. .name = "video_cc_mvs0c_div2_div_clk_src",
  229. .parent_hws = (const struct clk_hw*[]) {
  230. &video_cc_mvs0_clk_src.clkr.hw,
  231. },
  232. .num_parents = 1,
  233. .flags = CLK_SET_RATE_PARENT,
  234. .ops = &clk_regmap_div_ro_ops,
  235. },
  236. };
  237. static struct clk_regmap_div video_cc_mvs1_div_clk_src = {
  238. .reg = 0x80dc,
  239. .shift = 0,
  240. .width = 4,
  241. .clkr.hw.init = &(const struct clk_init_data) {
  242. .name = "video_cc_mvs1_div_clk_src",
  243. .parent_hws = (const struct clk_hw*[]) {
  244. &video_cc_mvs1_clk_src.clkr.hw,
  245. },
  246. .num_parents = 1,
  247. .flags = CLK_SET_RATE_PARENT,
  248. .ops = &clk_regmap_div_ro_ops,
  249. },
  250. };
  251. static struct clk_regmap_div video_cc_mvs1c_div2_div_clk_src = {
  252. .reg = 0x8094,
  253. .shift = 0,
  254. .width = 4,
  255. .clkr.hw.init = &(const struct clk_init_data) {
  256. .name = "video_cc_mvs1c_div2_div_clk_src",
  257. .parent_hws = (const struct clk_hw*[]) {
  258. &video_cc_mvs1_clk_src.clkr.hw,
  259. },
  260. .num_parents = 1,
  261. .flags = CLK_SET_RATE_PARENT,
  262. .ops = &clk_regmap_div_ro_ops,
  263. },
  264. };
  265. static struct clk_regmap_div video_cc_sm_div_clk_src = {
  266. .reg = 0x8108,
  267. .shift = 0,
  268. .width = 4,
  269. .clkr.hw.init = &(const struct clk_init_data) {
  270. .name = "video_cc_sm_div_clk_src",
  271. .ops = &clk_regmap_div_ro_ops,
  272. },
  273. };
  274. static struct clk_branch video_cc_mvs0_clk = {
  275. .halt_reg = 0x80b0,
  276. .halt_check = BRANCH_HALT_VOTED,
  277. .hwcg_reg = 0x80b0,
  278. .hwcg_bit = 1,
  279. .clkr = {
  280. .enable_reg = 0x80b0,
  281. .enable_mask = BIT(0),
  282. .hw.init = &(const struct clk_init_data) {
  283. .name = "video_cc_mvs0_clk",
  284. .parent_hws = (const struct clk_hw*[]) {
  285. &video_cc_mvs0_div_clk_src.clkr.hw,
  286. },
  287. .num_parents = 1,
  288. .flags = CLK_SET_RATE_PARENT,
  289. .ops = &clk_branch2_ops,
  290. },
  291. },
  292. };
  293. static struct clk_branch video_cc_mvs0c_clk = {
  294. .halt_reg = 0x8064,
  295. .halt_check = BRANCH_HALT,
  296. .clkr = {
  297. .enable_reg = 0x8064,
  298. .enable_mask = BIT(0),
  299. .hw.init = &(const struct clk_init_data) {
  300. .name = "video_cc_mvs0c_clk",
  301. .parent_hws = (const struct clk_hw*[]) {
  302. &video_cc_mvs0c_div2_div_clk_src.clkr.hw,
  303. },
  304. .num_parents = 1,
  305. .flags = CLK_SET_RATE_PARENT,
  306. .ops = &clk_branch2_ops,
  307. },
  308. },
  309. };
  310. static struct clk_branch video_cc_mvs1_clk = {
  311. .halt_reg = 0x80d4,
  312. .halt_check = BRANCH_HALT_VOTED,
  313. .hwcg_reg = 0x80d4,
  314. .hwcg_bit = 1,
  315. .clkr = {
  316. .enable_reg = 0x80d4,
  317. .enable_mask = BIT(0),
  318. .hw.init = &(const struct clk_init_data) {
  319. .name = "video_cc_mvs1_clk",
  320. .parent_hws = (const struct clk_hw*[]) {
  321. &video_cc_mvs1_div_clk_src.clkr.hw,
  322. },
  323. .num_parents = 1,
  324. .flags = CLK_SET_RATE_PARENT,
  325. .ops = &clk_branch2_ops,
  326. },
  327. },
  328. };
  329. static struct clk_branch video_cc_mvs1c_clk = {
  330. .halt_reg = 0x808c,
  331. .halt_check = BRANCH_HALT,
  332. .clkr = {
  333. .enable_reg = 0x808c,
  334. .enable_mask = BIT(0),
  335. .hw.init = &(const struct clk_init_data) {
  336. .name = "video_cc_mvs1c_clk",
  337. .parent_hws = (const struct clk_hw*[]) {
  338. &video_cc_mvs1c_div2_div_clk_src.clkr.hw,
  339. },
  340. .num_parents = 1,
  341. .flags = CLK_SET_RATE_PARENT,
  342. .ops = &clk_branch2_ops,
  343. },
  344. },
  345. };
  346. static struct clk_branch video_cc_pll_lock_monitor_clk = {
  347. .halt_reg = 0x9000,
  348. .halt_check = BRANCH_HALT,
  349. .clkr = {
  350. .enable_reg = 0x9000,
  351. .enable_mask = BIT(0),
  352. .hw.init = &(const struct clk_init_data) {
  353. .name = "video_cc_pll_lock_monitor_clk",
  354. .parent_hws = (const struct clk_hw*[]) {
  355. &video_cc_xo_clk_src.clkr.hw,
  356. },
  357. .num_parents = 1,
  358. .flags = CLK_SET_RATE_PARENT,
  359. .ops = &clk_branch2_ops,
  360. },
  361. },
  362. };
  363. static struct clk_branch video_cc_sm_obs_clk = {
  364. .halt_reg = 0x810c,
  365. .halt_check = BRANCH_HALT_SKIP,
  366. .clkr = {
  367. .enable_reg = 0x810c,
  368. .enable_mask = BIT(0),
  369. .hw.init = &(const struct clk_init_data) {
  370. .name = "video_cc_sm_obs_clk",
  371. .parent_hws = (const struct clk_hw*[]) {
  372. &video_cc_sm_div_clk_src.clkr.hw,
  373. },
  374. .num_parents = 1,
  375. .flags = CLK_SET_RATE_PARENT,
  376. .ops = &clk_branch2_ops,
  377. },
  378. },
  379. };
  380. static struct gdsc video_cc_mvs0c_gdsc = {
  381. .gdscr = 0x804c,
  382. .en_rest_wait_val = 0x2,
  383. .en_few_wait_val = 0x2,
  384. .clk_dis_wait_val = 0x6,
  385. .pd = {
  386. .name = "video_cc_mvs0c_gdsc",
  387. },
  388. .pwrsts = PWRSTS_OFF_ON,
  389. .flags = RETAIN_FF_ENABLE | POLL_CFG_GDSCR,
  390. };
  391. static struct gdsc video_cc_mvs0_gdsc = {
  392. .gdscr = 0x809c,
  393. .en_rest_wait_val = 0x2,
  394. .en_few_wait_val = 0x2,
  395. .clk_dis_wait_val = 0x6,
  396. .pd = {
  397. .name = "video_cc_mvs0_gdsc",
  398. },
  399. .pwrsts = PWRSTS_OFF_ON,
  400. .parent = &video_cc_mvs0c_gdsc.pd,
  401. .flags = RETAIN_FF_ENABLE | POLL_CFG_GDSCR | HW_CTRL_TRIGGER,
  402. };
  403. static struct gdsc video_cc_mvs1c_gdsc = {
  404. .gdscr = 0x8074,
  405. .en_rest_wait_val = 0x2,
  406. .en_few_wait_val = 0x2,
  407. .clk_dis_wait_val = 0x6,
  408. .pd = {
  409. .name = "video_cc_mvs1c_gdsc",
  410. },
  411. .pwrsts = PWRSTS_OFF_ON,
  412. .flags = RETAIN_FF_ENABLE | POLL_CFG_GDSCR,
  413. };
  414. static struct gdsc video_cc_mvs1_gdsc = {
  415. .gdscr = 0x80c0,
  416. .en_rest_wait_val = 0x2,
  417. .en_few_wait_val = 0x2,
  418. .clk_dis_wait_val = 0x6,
  419. .pd = {
  420. .name = "video_cc_mvs1_gdsc",
  421. },
  422. .pwrsts = PWRSTS_OFF_ON,
  423. .parent = &video_cc_mvs1c_gdsc.pd,
  424. .flags = RETAIN_FF_ENABLE | POLL_CFG_GDSCR | HW_CTRL_TRIGGER,
  425. };
  426. static struct clk_regmap *video_cc_sa8775p_clocks[] = {
  427. [VIDEO_CC_AHB_CLK_SRC] = &video_cc_ahb_clk_src.clkr,
  428. [VIDEO_CC_MVS0_CLK] = &video_cc_mvs0_clk.clkr,
  429. [VIDEO_CC_MVS0_CLK_SRC] = &video_cc_mvs0_clk_src.clkr,
  430. [VIDEO_CC_MVS0_DIV_CLK_SRC] = &video_cc_mvs0_div_clk_src.clkr,
  431. [VIDEO_CC_MVS0C_CLK] = &video_cc_mvs0c_clk.clkr,
  432. [VIDEO_CC_MVS0C_DIV2_DIV_CLK_SRC] = &video_cc_mvs0c_div2_div_clk_src.clkr,
  433. [VIDEO_CC_MVS1_CLK] = &video_cc_mvs1_clk.clkr,
  434. [VIDEO_CC_MVS1_CLK_SRC] = &video_cc_mvs1_clk_src.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_PLL_LOCK_MONITOR_CLK] = &video_cc_pll_lock_monitor_clk.clkr,
  439. [VIDEO_CC_SLEEP_CLK_SRC] = &video_cc_sleep_clk_src.clkr,
  440. [VIDEO_CC_SM_DIV_CLK_SRC] = &video_cc_sm_div_clk_src.clkr,
  441. [VIDEO_CC_SM_OBS_CLK] = &video_cc_sm_obs_clk.clkr,
  442. [VIDEO_CC_XO_CLK_SRC] = &video_cc_xo_clk_src.clkr,
  443. [VIDEO_PLL0] = &video_pll0.clkr,
  444. [VIDEO_PLL1] = &video_pll1.clkr,
  445. };
  446. static struct gdsc *video_cc_sa8775p_gdscs[] = {
  447. [VIDEO_CC_MVS0_GDSC] = &video_cc_mvs0_gdsc,
  448. [VIDEO_CC_MVS0C_GDSC] = &video_cc_mvs0c_gdsc,
  449. [VIDEO_CC_MVS1_GDSC] = &video_cc_mvs1_gdsc,
  450. [VIDEO_CC_MVS1C_GDSC] = &video_cc_mvs1c_gdsc,
  451. };
  452. static const struct qcom_reset_map video_cc_sa8775p_resets[] = {
  453. [VIDEO_CC_INTERFACE_BCR] = { 0x80e8 },
  454. [VIDEO_CC_MVS0_BCR] = { 0x8098 },
  455. [VIDEO_CC_MVS0C_CLK_ARES] = { 0x8064, 2 },
  456. [VIDEO_CC_MVS0C_BCR] = { 0x8048 },
  457. [VIDEO_CC_MVS1_BCR] = { 0x80bc },
  458. [VIDEO_CC_MVS1C_CLK_ARES] = { 0x808c, 2 },
  459. [VIDEO_CC_MVS1C_BCR] = { 0x8070 },
  460. };
  461. static const struct regmap_config video_cc_sa8775p_regmap_config = {
  462. .reg_bits = 32,
  463. .reg_stride = 4,
  464. .val_bits = 32,
  465. .max_register = 0xb000,
  466. .fast_io = true,
  467. };
  468. static const struct qcom_cc_desc video_cc_sa8775p_desc = {
  469. .config = &video_cc_sa8775p_regmap_config,
  470. .clks = video_cc_sa8775p_clocks,
  471. .num_clks = ARRAY_SIZE(video_cc_sa8775p_clocks),
  472. .resets = video_cc_sa8775p_resets,
  473. .num_resets = ARRAY_SIZE(video_cc_sa8775p_resets),
  474. .gdscs = video_cc_sa8775p_gdscs,
  475. .num_gdscs = ARRAY_SIZE(video_cc_sa8775p_gdscs),
  476. };
  477. static const struct of_device_id video_cc_sa8775p_match_table[] = {
  478. { .compatible = "qcom,qcs8300-videocc" },
  479. { .compatible = "qcom,sa8775p-videocc" },
  480. { }
  481. };
  482. MODULE_DEVICE_TABLE(of, video_cc_sa8775p_match_table);
  483. static int video_cc_sa8775p_probe(struct platform_device *pdev)
  484. {
  485. struct regmap *regmap;
  486. int ret;
  487. ret = devm_pm_runtime_enable(&pdev->dev);
  488. if (ret)
  489. return ret;
  490. ret = pm_runtime_resume_and_get(&pdev->dev);
  491. if (ret)
  492. return ret;
  493. regmap = qcom_cc_map(pdev, &video_cc_sa8775p_desc);
  494. if (IS_ERR(regmap)) {
  495. pm_runtime_put(&pdev->dev);
  496. return PTR_ERR(regmap);
  497. }
  498. clk_lucid_evo_pll_configure(&video_pll0, regmap, &video_pll0_config);
  499. clk_lucid_evo_pll_configure(&video_pll1, regmap, &video_pll1_config);
  500. /*
  501. * Set mvs0c clock divider to div-3 to make the mvs0 and
  502. * mvs0c clocks to run at the same frequency on QCS8300
  503. */
  504. if (of_device_is_compatible(pdev->dev.of_node, "qcom,qcs8300-videocc"))
  505. regmap_write(regmap, video_cc_mvs0c_div2_div_clk_src.reg, 2);
  506. /* Keep some clocks always enabled */
  507. qcom_branch_set_clk_en(regmap, 0x80ec); /* VIDEO_CC_AHB_CLK */
  508. qcom_branch_set_clk_en(regmap, 0x8144); /* VIDEO_CC_SLEEP_CLK */
  509. qcom_branch_set_clk_en(regmap, 0x8128); /* VIDEO_CC_XO_CLK */
  510. ret = qcom_cc_really_probe(&pdev->dev, &video_cc_sa8775p_desc, regmap);
  511. pm_runtime_put(&pdev->dev);
  512. return ret;
  513. }
  514. static struct platform_driver video_cc_sa8775p_driver = {
  515. .probe = video_cc_sa8775p_probe,
  516. .driver = {
  517. .name = "videocc-sa8775p",
  518. .of_match_table = video_cc_sa8775p_match_table,
  519. },
  520. };
  521. module_platform_driver(video_cc_sa8775p_driver);
  522. MODULE_DESCRIPTION("QTI VIDEOCC SA8775P Driver");
  523. MODULE_LICENSE("GPL");