videocc-niobe.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/of_device.h>
  9. #include <linux/of.h>
  10. #include <linux/regmap.h>
  11. #include <linux/pm_runtime.h>
  12. #include <dt-bindings/clock/qcom,videocc-niobe.h>
  13. #include "clk-alpha-pll.h"
  14. #include "clk-branch.h"
  15. #include "clk-rcg.h"
  16. #include "clk-regmap-divider.h"
  17. #include "clk-regmap-mux.h"
  18. #include "common.h"
  19. #include "reset.h"
  20. #include "vdd-level.h"
  21. static DEFINE_VDD_REGULATORS(vdd_mm, VDD_HIGH + 1, 1, vdd_corner);
  22. static DEFINE_VDD_REGULATORS(vdd_mxc, VDD_HIGH + 1, 1, vdd_corner);
  23. static struct clk_vdd_class *video_cc_niobe_regulators[] = {
  24. &vdd_mm,
  25. &vdd_mxc,
  26. };
  27. enum {
  28. P_BI_TCXO,
  29. P_SLEEP_CLK,
  30. P_VIDEO_CC_PLL0_OUT_MAIN,
  31. P_VIDEO_CC_PLL1_OUT_MAIN,
  32. };
  33. static const struct pll_vco lucid_ole_vco[] = {
  34. { 249600000, 2300000000, 0 },
  35. };
  36. /* 504MHz Configuration */
  37. static const struct alpha_pll_config video_cc_pll0_config = {
  38. .l = 0x1A,
  39. .cal_l = 0x44,
  40. .cal_l_ringosc = 0x44,
  41. .alpha = 0x4000,
  42. .config_ctl_val = 0x20485699,
  43. .config_ctl_hi_val = 0x00182261,
  44. .config_ctl_hi1_val = 0x82AA299C,
  45. .test_ctl_val = 0x00000000,
  46. .test_ctl_hi_val = 0x00000003,
  47. .test_ctl_hi1_val = 0x00009000,
  48. .test_ctl_hi2_val = 0x00000034,
  49. .user_ctl_val = 0x00000000,
  50. .user_ctl_hi_val = 0x00000005,
  51. };
  52. static struct clk_alpha_pll video_cc_pll0 = {
  53. .offset = 0x0,
  54. .vco_table = lucid_ole_vco,
  55. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  56. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  57. .clkr = {
  58. .hw.init = &(const struct clk_init_data) {
  59. .name = "video_cc_pll0",
  60. .parent_data = &(const struct clk_parent_data) {
  61. .fw_name = "bi_tcxo",
  62. },
  63. .num_parents = 1,
  64. .ops = &clk_alpha_pll_lucid_ole_ops,
  65. },
  66. .vdd_data = {
  67. .vdd_class = &vdd_mxc,
  68. .num_rate_max = VDD_NUM,
  69. .rate_max = (unsigned long[VDD_NUM]) {
  70. [VDD_LOWER_D1] = 615000000,
  71. [VDD_LOW] = 1100000000,
  72. [VDD_LOW_L1] = 1600000000,
  73. [VDD_NOMINAL] = 2000000000,
  74. [VDD_HIGH_L1] = 2300000000},
  75. },
  76. },
  77. };
  78. /* 840MHz Configuration */
  79. static const struct alpha_pll_config video_cc_pll1_config = {
  80. .l = 0x2B,
  81. .cal_l = 0x44,
  82. .cal_l_ringosc = 0x44,
  83. .alpha = 0xC000,
  84. .config_ctl_val = 0x20485699,
  85. .config_ctl_hi_val = 0x00182261,
  86. .config_ctl_hi1_val = 0x82AA299C,
  87. .test_ctl_val = 0x00000000,
  88. .test_ctl_hi_val = 0x00000003,
  89. .test_ctl_hi1_val = 0x00009000,
  90. .test_ctl_hi2_val = 0x00000034,
  91. .user_ctl_val = 0x00000000,
  92. .user_ctl_hi_val = 0x00000005,
  93. };
  94. static struct clk_alpha_pll video_cc_pll1 = {
  95. .offset = 0x1000,
  96. .vco_table = lucid_ole_vco,
  97. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  98. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  99. .clkr = {
  100. .hw.init = &(const struct clk_init_data) {
  101. .name = "video_cc_pll1",
  102. .parent_data = &(const struct clk_parent_data) {
  103. .fw_name = "bi_tcxo",
  104. },
  105. .num_parents = 1,
  106. .ops = &clk_alpha_pll_lucid_ole_ops,
  107. },
  108. .vdd_data = {
  109. .vdd_class = &vdd_mxc,
  110. .num_rate_max = VDD_NUM,
  111. .rate_max = (unsigned long[VDD_NUM]) {
  112. [VDD_LOWER_D1] = 615000000,
  113. [VDD_LOW] = 1100000000,
  114. [VDD_LOW_L1] = 1600000000,
  115. [VDD_NOMINAL] = 2000000000,
  116. [VDD_HIGH_L1] = 2300000000},
  117. },
  118. },
  119. };
  120. static const struct parent_map video_cc_parent_map_0[] = {
  121. { P_BI_TCXO, 0 },
  122. };
  123. static const struct clk_parent_data video_cc_parent_data_0_ao[] = {
  124. { .fw_name = "bi_tcxo_ao" },
  125. };
  126. static const struct parent_map video_cc_parent_map_1[] = {
  127. { P_BI_TCXO, 0 },
  128. { P_VIDEO_CC_PLL0_OUT_MAIN, 1 },
  129. };
  130. static const struct clk_parent_data video_cc_parent_data_1[] = {
  131. { .fw_name = "bi_tcxo" },
  132. { .hw = &video_cc_pll0.clkr.hw },
  133. };
  134. static const struct parent_map video_cc_parent_map_2[] = {
  135. { P_BI_TCXO, 0 },
  136. { P_VIDEO_CC_PLL1_OUT_MAIN, 1 },
  137. };
  138. static const struct clk_parent_data video_cc_parent_data_2[] = {
  139. { .fw_name = "bi_tcxo" },
  140. { .hw = &video_cc_pll1.clkr.hw },
  141. };
  142. static const struct parent_map video_cc_parent_map_3[] = {
  143. { P_SLEEP_CLK, 0 },
  144. };
  145. static const struct clk_parent_data video_cc_parent_data_3_ao[] = {
  146. { .fw_name = "sleep_clk" },
  147. };
  148. static const struct freq_tbl ftbl_video_cc_ahb_clk_src[] = {
  149. F(19200000, P_BI_TCXO, 1, 0, 0),
  150. { }
  151. };
  152. static struct clk_rcg2 video_cc_ahb_clk_src = {
  153. .cmd_rcgr = 0x8030,
  154. .mnd_width = 0,
  155. .hid_width = 5,
  156. .parent_map = video_cc_parent_map_0,
  157. .freq_tbl = ftbl_video_cc_ahb_clk_src,
  158. .enable_safe_config = true,
  159. .flags = HW_CLK_CTRL_MODE,
  160. .clkr.hw.init = &(const struct clk_init_data) {
  161. .name = "video_cc_ahb_clk_src",
  162. .parent_data = video_cc_parent_data_0_ao,
  163. .num_parents = ARRAY_SIZE(video_cc_parent_data_0_ao),
  164. .flags = CLK_SET_RATE_PARENT,
  165. .ops = &clk_rcg2_ops,
  166. },
  167. };
  168. static const struct freq_tbl ftbl_video_cc_mvs0_clk_src[] = {
  169. F(504000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  170. F(720000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  171. F(1014000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  172. F(1098000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  173. F(1332000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  174. F(1600000000, P_VIDEO_CC_PLL0_OUT_MAIN, 1, 0, 0),
  175. { }
  176. };
  177. static struct clk_rcg2 video_cc_mvs0_clk_src = {
  178. .cmd_rcgr = 0x8000,
  179. .mnd_width = 0,
  180. .hid_width = 5,
  181. .parent_map = video_cc_parent_map_1,
  182. .freq_tbl = ftbl_video_cc_mvs0_clk_src,
  183. .enable_safe_config = true,
  184. .flags = HW_CLK_CTRL_MODE,
  185. .clkr.hw.init = &(const struct clk_init_data) {
  186. .name = "video_cc_mvs0_clk_src",
  187. .parent_data = video_cc_parent_data_1,
  188. .num_parents = ARRAY_SIZE(video_cc_parent_data_1),
  189. .flags = CLK_SET_RATE_PARENT,
  190. .ops = &clk_rcg2_ops,
  191. },
  192. .clkr.vdd_data = {
  193. .vdd_classes = video_cc_niobe_regulators,
  194. .num_vdd_classes = ARRAY_SIZE(video_cc_niobe_regulators),
  195. .num_rate_max = VDD_NUM,
  196. .rate_max = (unsigned long[VDD_NUM]) {
  197. [VDD_LOWER_D1] = 504000000,
  198. [VDD_LOWER] = 720000000,
  199. [VDD_LOW] = 1014000000,
  200. [VDD_LOW_L1] = 1098000000,
  201. [VDD_NOMINAL] = 1332000000,
  202. [VDD_HIGH] = 1600000000},
  203. },
  204. };
  205. static const struct freq_tbl ftbl_video_cc_mvs1_clk_src[] = {
  206. F(840000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  207. F(1050000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  208. F(1350000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  209. F(1500000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  210. F(1650000000, P_VIDEO_CC_PLL1_OUT_MAIN, 1, 0, 0),
  211. { }
  212. };
  213. static struct clk_rcg2 video_cc_mvs1_clk_src = {
  214. .cmd_rcgr = 0x8018,
  215. .mnd_width = 0,
  216. .hid_width = 5,
  217. .parent_map = video_cc_parent_map_2,
  218. .freq_tbl = ftbl_video_cc_mvs1_clk_src,
  219. .enable_safe_config = true,
  220. .flags = HW_CLK_CTRL_MODE,
  221. .clkr.hw.init = &(const struct clk_init_data) {
  222. .name = "video_cc_mvs1_clk_src",
  223. .parent_data = video_cc_parent_data_2,
  224. .num_parents = ARRAY_SIZE(video_cc_parent_data_2),
  225. .flags = CLK_SET_RATE_PARENT,
  226. .ops = &clk_rcg2_ops,
  227. },
  228. .clkr.vdd_data = {
  229. .vdd_classes = video_cc_niobe_regulators,
  230. .num_vdd_classes = ARRAY_SIZE(video_cc_niobe_regulators),
  231. .num_rate_max = VDD_NUM,
  232. .rate_max = (unsigned long[VDD_NUM]) {
  233. [VDD_LOWER_D1] = 840000000,
  234. [VDD_LOWER] = 1050000000,
  235. [VDD_LOW] = 1350000000,
  236. [VDD_LOW_L1] = 1500000000,
  237. [VDD_NOMINAL] = 1650000000},
  238. },
  239. };
  240. static const struct freq_tbl ftbl_video_cc_sleep_clk_src[] = {
  241. F(32000, P_SLEEP_CLK, 1, 0, 0),
  242. { }
  243. };
  244. static struct clk_rcg2 video_cc_sleep_clk_src = {
  245. .cmd_rcgr = 0x8138,
  246. .mnd_width = 0,
  247. .hid_width = 5,
  248. .parent_map = video_cc_parent_map_3,
  249. .freq_tbl = ftbl_video_cc_sleep_clk_src,
  250. .clkr.hw.init = &(const struct clk_init_data) {
  251. .name = "video_cc_sleep_clk_src",
  252. .parent_data = video_cc_parent_data_3_ao,
  253. .num_parents = ARRAY_SIZE(video_cc_parent_data_3_ao),
  254. .flags = CLK_SET_RATE_PARENT,
  255. .ops = &clk_rcg2_ops,
  256. },
  257. };
  258. static struct clk_rcg2 video_cc_xo_clk_src = {
  259. .cmd_rcgr = 0x810c,
  260. .mnd_width = 0,
  261. .hid_width = 5,
  262. .parent_map = video_cc_parent_map_0,
  263. .freq_tbl = ftbl_video_cc_ahb_clk_src,
  264. .clkr.hw.init = &(const struct clk_init_data) {
  265. .name = "video_cc_xo_clk_src",
  266. .parent_data = video_cc_parent_data_0_ao,
  267. .num_parents = ARRAY_SIZE(video_cc_parent_data_0_ao),
  268. .flags = CLK_SET_RATE_PARENT,
  269. .ops = &clk_rcg2_ops,
  270. },
  271. };
  272. static struct clk_regmap_div video_cc_mvs0_div_clk_src = {
  273. .reg = 0x80c4,
  274. .shift = 0,
  275. .width = 4,
  276. .clkr.hw.init = &(const struct clk_init_data) {
  277. .name = "video_cc_mvs0_div_clk_src",
  278. .parent_hws = (const struct clk_hw*[]) {
  279. &video_cc_mvs0_clk_src.clkr.hw,
  280. },
  281. .num_parents = 1,
  282. .flags = CLK_SET_RATE_PARENT,
  283. .ops = &clk_regmap_div_ro_ops,
  284. },
  285. };
  286. static struct clk_regmap_div video_cc_mvs0c_div2_div_clk_src = {
  287. .reg = 0x8070,
  288. .shift = 0,
  289. .width = 4,
  290. .clkr.hw.init = &(const struct clk_init_data) {
  291. .name = "video_cc_mvs0c_div2_div_clk_src",
  292. .parent_hws = (const struct clk_hw*[]) {
  293. &video_cc_mvs0_clk_src.clkr.hw,
  294. },
  295. .num_parents = 1,
  296. .flags = CLK_SET_RATE_PARENT,
  297. .ops = &clk_regmap_div_ro_ops,
  298. },
  299. };
  300. static struct clk_regmap_div video_cc_mvs1_div_clk_src = {
  301. .reg = 0x80ec,
  302. .shift = 0,
  303. .width = 4,
  304. .clkr.hw.init = &(const struct clk_init_data) {
  305. .name = "video_cc_mvs1_div_clk_src",
  306. .parent_hws = (const struct clk_hw*[]) {
  307. &video_cc_mvs1_clk_src.clkr.hw,
  308. },
  309. .num_parents = 1,
  310. .flags = CLK_SET_RATE_PARENT,
  311. .ops = &clk_regmap_div_ro_ops,
  312. },
  313. };
  314. static struct clk_regmap_div video_cc_mvs1c_div2_div_clk_src = {
  315. .reg = 0x809c,
  316. .shift = 0,
  317. .width = 4,
  318. .clkr.hw.init = &(const struct clk_init_data) {
  319. .name = "video_cc_mvs1c_div2_div_clk_src",
  320. .parent_hws = (const struct clk_hw*[]) {
  321. &video_cc_mvs1_clk_src.clkr.hw,
  322. },
  323. .num_parents = 1,
  324. .flags = CLK_SET_RATE_PARENT,
  325. .ops = &clk_regmap_div_ro_ops,
  326. },
  327. };
  328. static struct clk_branch video_cc_mvs0_clk = {
  329. .halt_reg = 0x80b8,
  330. .halt_check = BRANCH_HALT_VOTED,
  331. .hwcg_reg = 0x80b8,
  332. .hwcg_bit = 1,
  333. .clkr = {
  334. .enable_reg = 0x80b8,
  335. .enable_mask = BIT(0),
  336. .hw.init = &(const struct clk_init_data) {
  337. .name = "video_cc_mvs0_clk",
  338. .parent_hws = (const struct clk_hw*[]) {
  339. &video_cc_mvs0_div_clk_src.clkr.hw,
  340. },
  341. .num_parents = 1,
  342. .flags = CLK_SET_RATE_PARENT,
  343. .ops = &clk_branch2_ops,
  344. },
  345. },
  346. };
  347. static struct clk_branch video_cc_mvs0_shift_clk = {
  348. .halt_reg = 0x8128,
  349. .halt_check = BRANCH_HALT_VOTED,
  350. .hwcg_reg = 0x8128,
  351. .hwcg_bit = 1,
  352. .clkr = {
  353. .enable_reg = 0x8128,
  354. .enable_mask = BIT(0),
  355. .hw.init = &(const struct clk_init_data) {
  356. .name = "video_cc_mvs0_shift_clk",
  357. .parent_hws = (const struct clk_hw*[]) {
  358. &video_cc_xo_clk_src.clkr.hw,
  359. },
  360. .num_parents = 1,
  361. .flags = CLK_SET_RATE_PARENT,
  362. .ops = &clk_branch2_ops,
  363. },
  364. },
  365. };
  366. static struct clk_branch video_cc_mvs0c_clk = {
  367. .halt_reg = 0x8064,
  368. .halt_check = BRANCH_HALT,
  369. .clkr = {
  370. .enable_reg = 0x8064,
  371. .enable_mask = BIT(0),
  372. .hw.init = &(const struct clk_init_data) {
  373. .name = "video_cc_mvs0c_clk",
  374. .parent_hws = (const struct clk_hw*[]) {
  375. &video_cc_mvs0c_div2_div_clk_src.clkr.hw,
  376. },
  377. .num_parents = 1,
  378. .flags = CLK_SET_RATE_PARENT,
  379. .ops = &clk_branch2_ops,
  380. },
  381. },
  382. };
  383. static struct clk_branch video_cc_mvs0c_shift_clk = {
  384. .halt_reg = 0x812c,
  385. .halt_check = BRANCH_HALT_VOTED,
  386. .hwcg_reg = 0x812c,
  387. .hwcg_bit = 1,
  388. .clkr = {
  389. .enable_reg = 0x812c,
  390. .enable_mask = BIT(0),
  391. .hw.init = &(const struct clk_init_data) {
  392. .name = "video_cc_mvs0c_shift_clk",
  393. .parent_hws = (const struct clk_hw*[]) {
  394. &video_cc_xo_clk_src.clkr.hw,
  395. },
  396. .num_parents = 1,
  397. .flags = CLK_SET_RATE_PARENT,
  398. .ops = &clk_branch2_ops,
  399. },
  400. },
  401. };
  402. static struct clk_branch video_cc_mvs1_clk = {
  403. .halt_reg = 0x80e0,
  404. .halt_check = BRANCH_HALT_VOTED,
  405. .hwcg_reg = 0x80e0,
  406. .hwcg_bit = 1,
  407. .clkr = {
  408. .enable_reg = 0x80e0,
  409. .enable_mask = BIT(0),
  410. .hw.init = &(const struct clk_init_data) {
  411. .name = "video_cc_mvs1_clk",
  412. .parent_hws = (const struct clk_hw*[]) {
  413. &video_cc_mvs1_div_clk_src.clkr.hw,
  414. },
  415. .num_parents = 1,
  416. .flags = CLK_SET_RATE_PARENT,
  417. .ops = &clk_branch2_ops,
  418. },
  419. },
  420. };
  421. static struct clk_branch video_cc_mvs1_shift_clk = {
  422. .halt_reg = 0x8130,
  423. .halt_check = BRANCH_HALT_VOTED,
  424. .hwcg_reg = 0x8130,
  425. .hwcg_bit = 1,
  426. .clkr = {
  427. .enable_reg = 0x8130,
  428. .enable_mask = BIT(0),
  429. .hw.init = &(const struct clk_init_data) {
  430. .name = "video_cc_mvs1_shift_clk",
  431. .parent_hws = (const struct clk_hw*[]) {
  432. &video_cc_xo_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 video_cc_mvs1c_clk = {
  441. .halt_reg = 0x8090,
  442. .halt_check = BRANCH_HALT,
  443. .clkr = {
  444. .enable_reg = 0x8090,
  445. .enable_mask = BIT(0),
  446. .hw.init = &(const struct clk_init_data) {
  447. .name = "video_cc_mvs1c_clk",
  448. .parent_hws = (const struct clk_hw*[]) {
  449. &video_cc_mvs1c_div2_div_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 video_cc_mvs1c_shift_clk = {
  458. .halt_reg = 0x8134,
  459. .halt_check = BRANCH_HALT_VOTED,
  460. .hwcg_reg = 0x8134,
  461. .hwcg_bit = 1,
  462. .clkr = {
  463. .enable_reg = 0x8134,
  464. .enable_mask = BIT(0),
  465. .hw.init = &(const struct clk_init_data) {
  466. .name = "video_cc_mvs1c_shift_clk",
  467. .parent_hws = (const struct clk_hw*[]) {
  468. &video_cc_xo_clk_src.clkr.hw,
  469. },
  470. .num_parents = 1,
  471. .flags = CLK_SET_RATE_PARENT,
  472. .ops = &clk_branch2_ops,
  473. },
  474. },
  475. };
  476. static struct clk_regmap *video_cc_niobe_clocks[] = {
  477. [VIDEO_CC_AHB_CLK_SRC] = &video_cc_ahb_clk_src.clkr,
  478. [VIDEO_CC_MVS0_CLK] = &video_cc_mvs0_clk.clkr,
  479. [VIDEO_CC_MVS0_CLK_SRC] = &video_cc_mvs0_clk_src.clkr,
  480. [VIDEO_CC_MVS0_DIV_CLK_SRC] = &video_cc_mvs0_div_clk_src.clkr,
  481. [VIDEO_CC_MVS0_SHIFT_CLK] = &video_cc_mvs0_shift_clk.clkr,
  482. [VIDEO_CC_MVS0C_CLK] = &video_cc_mvs0c_clk.clkr,
  483. [VIDEO_CC_MVS0C_DIV2_DIV_CLK_SRC] = &video_cc_mvs0c_div2_div_clk_src.clkr,
  484. [VIDEO_CC_MVS0C_SHIFT_CLK] = &video_cc_mvs0c_shift_clk.clkr,
  485. [VIDEO_CC_MVS1_CLK] = &video_cc_mvs1_clk.clkr,
  486. [VIDEO_CC_MVS1_CLK_SRC] = &video_cc_mvs1_clk_src.clkr,
  487. [VIDEO_CC_MVS1_DIV_CLK_SRC] = &video_cc_mvs1_div_clk_src.clkr,
  488. [VIDEO_CC_MVS1_SHIFT_CLK] = &video_cc_mvs1_shift_clk.clkr,
  489. [VIDEO_CC_MVS1C_CLK] = &video_cc_mvs1c_clk.clkr,
  490. [VIDEO_CC_MVS1C_DIV2_DIV_CLK_SRC] = &video_cc_mvs1c_div2_div_clk_src.clkr,
  491. [VIDEO_CC_MVS1C_SHIFT_CLK] = &video_cc_mvs1c_shift_clk.clkr,
  492. [VIDEO_CC_PLL0] = &video_cc_pll0.clkr,
  493. [VIDEO_CC_PLL1] = &video_cc_pll1.clkr,
  494. [VIDEO_CC_SLEEP_CLK_SRC] = &video_cc_sleep_clk_src.clkr,
  495. [VIDEO_CC_XO_CLK_SRC] = &video_cc_xo_clk_src.clkr,
  496. };
  497. static const struct qcom_reset_map video_cc_niobe_resets[] = {
  498. [VCODEC_VIDEO_CC_INTERFACE_BCR] = { 0x80f0 },
  499. [VCODEC_VIDEO_CC_MVS0_BCR] = { 0x80a0 },
  500. [VIDEO_CC_MVS0C_CLK_ARES] = { 0x8064, 2 },
  501. [VCODEC_VIDEO_CC_MVS0C_BCR] = { 0x8048 },
  502. [VCODEC_VIDEO_CC_MVS1_BCR] = { 0x80c8 },
  503. [VIDEO_CC_MVS1C_CLK_ARES] = { 0x8090, 2 },
  504. [VCODEC_VIDEO_CC_MVS1C_BCR] = { 0x8074 },
  505. [VIDEO_CC_XO_CLK_ARES] = { 0x8124, 2 },
  506. };
  507. static const struct regmap_config video_cc_niobe_regmap_config = {
  508. .reg_bits = 32,
  509. .reg_stride = 4,
  510. .val_bits = 32,
  511. .max_register = 0x9f54,
  512. .fast_io = true,
  513. };
  514. static struct qcom_cc_desc video_cc_niobe_desc = {
  515. .config = &video_cc_niobe_regmap_config,
  516. .clks = video_cc_niobe_clocks,
  517. .num_clks = ARRAY_SIZE(video_cc_niobe_clocks),
  518. .resets = video_cc_niobe_resets,
  519. .num_resets = ARRAY_SIZE(video_cc_niobe_resets),
  520. .clk_regulators = video_cc_niobe_regulators,
  521. .num_clk_regulators = ARRAY_SIZE(video_cc_niobe_regulators),
  522. };
  523. static const struct of_device_id video_cc_niobe_match_table[] = {
  524. { .compatible = "qcom,niobe-videocc" },
  525. { }
  526. };
  527. MODULE_DEVICE_TABLE(of, video_cc_niobe_match_table);
  528. static int video_cc_niobe_probe(struct platform_device *pdev)
  529. {
  530. struct regmap *regmap;
  531. int ret;
  532. regmap = qcom_cc_map(pdev, &video_cc_niobe_desc);
  533. if (IS_ERR(regmap))
  534. return PTR_ERR(regmap);
  535. ret = qcom_cc_runtime_init(pdev, &video_cc_niobe_desc);
  536. if (ret)
  537. return ret;
  538. ret = pm_runtime_get_sync(&pdev->dev);
  539. if (ret)
  540. return ret;
  541. clk_lucid_ole_pll_configure(&video_cc_pll0, regmap, &video_cc_pll0_config);
  542. clk_lucid_ole_pll_configure(&video_cc_pll1, regmap, &video_cc_pll1_config);
  543. /*
  544. * Keep clocks always enabled:
  545. * video_cc_ahb_clk
  546. * video_cc_sleep_clk
  547. * video_cc_xo_clk
  548. */
  549. regmap_update_bits(regmap, 0x80f4, BIT(0), BIT(0));
  550. regmap_update_bits(regmap, 0x8150, BIT(0), BIT(0));
  551. regmap_update_bits(regmap, 0x8124, BIT(0), BIT(0));
  552. ret = qcom_cc_really_probe(pdev, &video_cc_niobe_desc, regmap);
  553. if (ret) {
  554. dev_err(&pdev->dev, "Failed to register VIDEO CC clocks\n");
  555. return ret;
  556. }
  557. pm_runtime_put_sync(&pdev->dev);
  558. dev_info(&pdev->dev, "Registered VIDEO CC clocks\n");
  559. return ret;
  560. }
  561. static void video_cc_niobe_sync_state(struct device *dev)
  562. {
  563. qcom_cc_sync_state(dev, &video_cc_niobe_desc);
  564. }
  565. static const struct dev_pm_ops video_cc_niobe_pm_ops = {
  566. SET_RUNTIME_PM_OPS(qcom_cc_runtime_suspend, qcom_cc_runtime_resume, NULL)
  567. SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
  568. pm_runtime_force_resume)
  569. };
  570. static struct platform_driver video_cc_niobe_driver = {
  571. .probe = video_cc_niobe_probe,
  572. .driver = {
  573. .name = "video_cc-niobe",
  574. .of_match_table = video_cc_niobe_match_table,
  575. .sync_state = video_cc_niobe_sync_state,
  576. .pm = &video_cc_niobe_pm_ops,
  577. },
  578. };
  579. static int __init video_cc_niobe_init(void)
  580. {
  581. return platform_driver_register(&video_cc_niobe_driver);
  582. }
  583. subsys_initcall(video_cc_niobe_init);
  584. static void __exit video_cc_niobe_exit(void)
  585. {
  586. platform_driver_unregister(&video_cc_niobe_driver);
  587. }
  588. module_exit(video_cc_niobe_exit);
  589. MODULE_DESCRIPTION("QTI VIDEO_CC NIOBE Driver");
  590. MODULE_LICENSE("GPL");