gpucc-sm8350.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022, Linaro Limited
  5. * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
  6. */
  7. #include <linux/clk.h>
  8. #include <linux/err.h>
  9. #include <linux/kernel.h>
  10. #include <linux/mod_devicetable.h>
  11. #include <linux/module.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/regmap.h>
  14. #include <dt-bindings/clock/qcom,gpucc-sm8350.h>
  15. #include "clk-alpha-pll.h"
  16. #include "clk-branch.h"
  17. #include "clk-pll.h"
  18. #include "clk-rcg.h"
  19. #include "clk-regmap.h"
  20. #include "common.h"
  21. #include "clk-regmap-mux.h"
  22. #include "clk-regmap-divider.h"
  23. #include "gdsc.h"
  24. #include "reset.h"
  25. enum {
  26. P_BI_TCXO,
  27. P_GPLL0_OUT_MAIN,
  28. P_GPLL0_OUT_MAIN_DIV,
  29. P_GPU_CC_PLL0_OUT_MAIN,
  30. P_GPU_CC_PLL1_OUT_MAIN,
  31. };
  32. static const struct pll_vco lucid_5lpe_vco[] = {
  33. { 249600000, 1750000000, 0 },
  34. };
  35. static const struct alpha_pll_config gpu_cc_pll0_config = {
  36. .l = 0x18,
  37. .alpha = 0x6000,
  38. .config_ctl_val = 0x20485699,
  39. .config_ctl_hi_val = 0x00002261,
  40. .config_ctl_hi1_val = 0x2a9a699c,
  41. .test_ctl_val = 0x00000000,
  42. .test_ctl_hi_val = 0x00000000,
  43. .test_ctl_hi1_val = 0x01800000,
  44. .user_ctl_val = 0x00000000,
  45. .user_ctl_hi_val = 0x00000805,
  46. .user_ctl_hi1_val = 0x00000000,
  47. };
  48. static const struct clk_parent_data gpu_cc_parent = {
  49. .fw_name = "bi_tcxo",
  50. };
  51. static struct clk_alpha_pll gpu_cc_pll0 = {
  52. .offset = 0x0,
  53. .vco_table = lucid_5lpe_vco,
  54. .num_vco = ARRAY_SIZE(lucid_5lpe_vco),
  55. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  56. .clkr = {
  57. .hw.init = &(const struct clk_init_data){
  58. .name = "gpu_cc_pll0",
  59. .parent_data = &gpu_cc_parent,
  60. .num_parents = 1,
  61. .ops = &clk_alpha_pll_lucid_5lpe_ops,
  62. },
  63. },
  64. };
  65. static const struct alpha_pll_config gpu_cc_pll1_config = {
  66. .l = 0x1a,
  67. .alpha = 0xaaa,
  68. .config_ctl_val = 0x20485699,
  69. .config_ctl_hi_val = 0x00002261,
  70. .config_ctl_hi1_val = 0x2a9a699c,
  71. .test_ctl_val = 0x00000000,
  72. .test_ctl_hi_val = 0x00000000,
  73. .test_ctl_hi1_val = 0x01800000,
  74. .user_ctl_val = 0x00000000,
  75. .user_ctl_hi_val = 0x00000805,
  76. .user_ctl_hi1_val = 0x00000000,
  77. };
  78. static struct clk_alpha_pll gpu_cc_pll1 = {
  79. .offset = 0x100,
  80. .vco_table = lucid_5lpe_vco,
  81. .num_vco = ARRAY_SIZE(lucid_5lpe_vco),
  82. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
  83. .clkr = {
  84. .hw.init = &(struct clk_init_data){
  85. .name = "gpu_cc_pll1",
  86. .parent_data = &gpu_cc_parent,
  87. .num_parents = 1,
  88. .ops = &clk_alpha_pll_lucid_5lpe_ops,
  89. },
  90. },
  91. };
  92. static const struct parent_map gpu_cc_parent_map_0[] = {
  93. { P_BI_TCXO, 0 },
  94. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  95. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  96. { P_GPLL0_OUT_MAIN, 5 },
  97. { P_GPLL0_OUT_MAIN_DIV, 6 },
  98. };
  99. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  100. { .fw_name = "bi_tcxo" },
  101. { .hw = &gpu_cc_pll0.clkr.hw },
  102. { .hw = &gpu_cc_pll1.clkr.hw },
  103. { .fw_name = "gcc_gpu_gpll0_clk_src" },
  104. { .fw_name = "gcc_gpu_gpll0_div_clk_src" },
  105. };
  106. static const struct parent_map gpu_cc_parent_map_1[] = {
  107. { P_BI_TCXO, 0 },
  108. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  109. { P_GPLL0_OUT_MAIN, 5 },
  110. { P_GPLL0_OUT_MAIN_DIV, 6 },
  111. };
  112. static const struct clk_parent_data gpu_cc_parent_data_1[] = {
  113. { .fw_name = "bi_tcxo" },
  114. { .hw = &gpu_cc_pll1.clkr.hw },
  115. { .fw_name = "gcc_gpu_gpll0_clk_src" },
  116. { .fw_name = "gcc_gpu_gpll0_div_clk_src" },
  117. };
  118. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  119. F(19200000, P_BI_TCXO, 1, 0, 0),
  120. F(200000000, P_GPLL0_OUT_MAIN_DIV, 1.5, 0, 0),
  121. F(500000000, P_GPU_CC_PLL1_OUT_MAIN, 1, 0, 0),
  122. { }
  123. };
  124. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  125. .cmd_rcgr = 0x1120,
  126. .mnd_width = 0,
  127. .hid_width = 5,
  128. .parent_map = gpu_cc_parent_map_0,
  129. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  130. .clkr.hw.init = &(struct clk_init_data){
  131. .name = "gpu_cc_gmu_clk_src",
  132. .parent_data = gpu_cc_parent_data_0,
  133. .num_parents = ARRAY_SIZE(gpu_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_gpu_cc_hub_clk_src[] = {
  139. F(150000000, P_GPLL0_OUT_MAIN_DIV, 2, 0, 0),
  140. F(240000000, P_GPLL0_OUT_MAIN, 2.5, 0, 0),
  141. F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0),
  142. { }
  143. };
  144. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  145. .cmd_rcgr = 0x117c,
  146. .mnd_width = 0,
  147. .hid_width = 5,
  148. .parent_map = gpu_cc_parent_map_1,
  149. .freq_tbl = ftbl_gpu_cc_hub_clk_src,
  150. .clkr.hw.init = &(struct clk_init_data){
  151. .name = "gpu_cc_hub_clk_src",
  152. .parent_data = gpu_cc_parent_data_1,
  153. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  154. .flags = CLK_SET_RATE_PARENT,
  155. .ops = &clk_rcg2_shared_ops,
  156. },
  157. };
  158. static struct clk_regmap_div gpu_cc_hub_ahb_div_clk_src = {
  159. .reg = 0x11c0,
  160. .shift = 0,
  161. .width = 4,
  162. .clkr.hw.init = &(struct clk_init_data) {
  163. .name = "gpu_cc_hub_ahb_div_clk_src",
  164. .parent_hws = (const struct clk_hw*[]){
  165. &gpu_cc_hub_clk_src.clkr.hw,
  166. },
  167. .num_parents = 1,
  168. .flags = CLK_SET_RATE_PARENT,
  169. .ops = &clk_regmap_div_ro_ops,
  170. },
  171. };
  172. static struct clk_regmap_div gpu_cc_hub_cx_int_div_clk_src = {
  173. .reg = 0x11bc,
  174. .shift = 0,
  175. .width = 4,
  176. .clkr.hw.init = &(struct clk_init_data) {
  177. .name = "gpu_cc_hub_cx_int_div_clk_src",
  178. .parent_hws = (const struct clk_hw*[]){
  179. &gpu_cc_hub_clk_src.clkr.hw,
  180. },
  181. .num_parents = 1,
  182. .flags = CLK_SET_RATE_PARENT,
  183. .ops = &clk_regmap_div_ro_ops,
  184. },
  185. };
  186. static struct clk_branch gpu_cc_ahb_clk = {
  187. .halt_reg = 0x1078,
  188. .halt_check = BRANCH_HALT_DELAY,
  189. .clkr = {
  190. .enable_reg = 0x1078,
  191. .enable_mask = BIT(0),
  192. .hw.init = &(struct clk_init_data){
  193. .name = "gpu_cc_ahb_clk",
  194. .parent_hws = (const struct clk_hw*[]){
  195. &gpu_cc_hub_ahb_div_clk_src.clkr.hw,
  196. },
  197. .num_parents = 1,
  198. .flags = CLK_SET_RATE_PARENT,
  199. .ops = &clk_branch2_ops,
  200. },
  201. },
  202. };
  203. static struct clk_branch gpu_cc_cb_clk = {
  204. .halt_reg = 0x1170,
  205. .halt_check = BRANCH_HALT,
  206. .clkr = {
  207. .enable_reg = 0x1170,
  208. .enable_mask = BIT(0),
  209. .hw.init = &(struct clk_init_data){
  210. .name = "gpu_cc_cb_clk",
  211. .ops = &clk_branch2_ops,
  212. },
  213. },
  214. };
  215. static struct clk_branch gpu_cc_crc_ahb_clk = {
  216. .halt_reg = 0x107c,
  217. .halt_check = BRANCH_HALT_VOTED,
  218. .clkr = {
  219. .enable_reg = 0x107c,
  220. .enable_mask = BIT(0),
  221. .hw.init = &(struct clk_init_data){
  222. .name = "gpu_cc_crc_ahb_clk",
  223. .parent_hws = (const struct clk_hw*[]){
  224. &gpu_cc_hub_ahb_div_clk_src.clkr.hw,
  225. },
  226. .num_parents = 1,
  227. .flags = CLK_SET_RATE_PARENT,
  228. .ops = &clk_branch2_ops,
  229. },
  230. },
  231. };
  232. static struct clk_branch gpu_cc_cx_apb_clk = {
  233. .halt_reg = 0x1088,
  234. .halt_check = BRANCH_HALT_VOTED,
  235. .clkr = {
  236. .enable_reg = 0x1088,
  237. .enable_mask = BIT(0),
  238. .hw.init = &(struct clk_init_data){
  239. .name = "gpu_cc_cx_apb_clk",
  240. .ops = &clk_branch2_ops,
  241. },
  242. },
  243. };
  244. static struct clk_branch gpu_cc_cx_gmu_clk = {
  245. .halt_reg = 0x1098,
  246. .halt_check = BRANCH_HALT,
  247. .clkr = {
  248. .enable_reg = 0x1098,
  249. .enable_mask = BIT(0),
  250. .hw.init = &(struct clk_init_data){
  251. .name = "gpu_cc_cx_gmu_clk",
  252. .parent_hws = (const struct clk_hw*[]){
  253. &gpu_cc_gmu_clk_src.clkr.hw,
  254. },
  255. .num_parents = 1,
  256. .flags = CLK_SET_RATE_PARENT,
  257. .ops = &clk_branch2_aon_ops,
  258. },
  259. },
  260. };
  261. static struct clk_branch gpu_cc_cx_qdss_at_clk = {
  262. .halt_reg = 0x1080,
  263. .halt_check = BRANCH_HALT_VOTED,
  264. .clkr = {
  265. .enable_reg = 0x1080,
  266. .enable_mask = BIT(0),
  267. .hw.init = &(struct clk_init_data){
  268. .name = "gpu_cc_cx_qdss_at_clk",
  269. .ops = &clk_branch2_ops,
  270. },
  271. },
  272. };
  273. static struct clk_branch gpu_cc_cx_qdss_trig_clk = {
  274. .halt_reg = 0x1094,
  275. .halt_check = BRANCH_HALT_VOTED,
  276. .clkr = {
  277. .enable_reg = 0x1094,
  278. .enable_mask = BIT(0),
  279. .hw.init = &(struct clk_init_data){
  280. .name = "gpu_cc_cx_qdss_trig_clk",
  281. .ops = &clk_branch2_ops,
  282. },
  283. },
  284. };
  285. static struct clk_branch gpu_cc_cx_qdss_tsctr_clk = {
  286. .halt_reg = 0x1084,
  287. .halt_check = BRANCH_HALT_VOTED,
  288. .clkr = {
  289. .enable_reg = 0x1084,
  290. .enable_mask = BIT(0),
  291. .hw.init = &(struct clk_init_data){
  292. .name = "gpu_cc_cx_qdss_tsctr_clk",
  293. .ops = &clk_branch2_ops,
  294. },
  295. },
  296. };
  297. static struct clk_branch gpu_cc_cx_snoc_dvm_clk = {
  298. .halt_reg = 0x108c,
  299. .halt_check = BRANCH_HALT_VOTED,
  300. .clkr = {
  301. .enable_reg = 0x108c,
  302. .enable_mask = BIT(0),
  303. .hw.init = &(struct clk_init_data){
  304. .name = "gpu_cc_cx_snoc_dvm_clk",
  305. .ops = &clk_branch2_ops,
  306. },
  307. },
  308. };
  309. static struct clk_branch gpu_cc_cxo_aon_clk = {
  310. .halt_reg = 0x1004,
  311. .halt_check = BRANCH_HALT_VOTED,
  312. .clkr = {
  313. .enable_reg = 0x1004,
  314. .enable_mask = BIT(0),
  315. .hw.init = &(struct clk_init_data){
  316. .name = "gpu_cc_cxo_aon_clk",
  317. .ops = &clk_branch2_ops,
  318. },
  319. },
  320. };
  321. static struct clk_branch gpu_cc_cxo_clk = {
  322. .halt_reg = 0x109c,
  323. .halt_check = BRANCH_HALT,
  324. .clkr = {
  325. .enable_reg = 0x109c,
  326. .enable_mask = BIT(0),
  327. .hw.init = &(struct clk_init_data){
  328. .name = "gpu_cc_cxo_clk",
  329. .ops = &clk_branch2_ops,
  330. },
  331. },
  332. };
  333. static struct clk_branch gpu_cc_freq_measure_clk = {
  334. .halt_reg = 0x120c,
  335. .halt_check = BRANCH_HALT,
  336. .clkr = {
  337. .enable_reg = 0x120c,
  338. .enable_mask = BIT(0),
  339. .hw.init = &(struct clk_init_data){
  340. .name = "gpu_cc_freq_measure_clk",
  341. .ops = &clk_branch2_ops,
  342. },
  343. },
  344. };
  345. static struct clk_branch gpu_cc_gx_gmu_clk = {
  346. .halt_reg = 0x1064,
  347. .halt_check = BRANCH_HALT,
  348. .clkr = {
  349. .enable_reg = 0x1064,
  350. .enable_mask = BIT(0),
  351. .hw.init = &(struct clk_init_data){
  352. .name = "gpu_cc_gx_gmu_clk",
  353. .parent_hws = (const struct clk_hw*[]){
  354. &gpu_cc_gmu_clk_src.clkr.hw,
  355. },
  356. .num_parents = 1,
  357. .flags = CLK_SET_RATE_PARENT,
  358. .ops = &clk_branch2_ops,
  359. },
  360. },
  361. };
  362. static struct clk_branch gpu_cc_gx_qdss_tsctr_clk = {
  363. .halt_reg = 0x105c,
  364. .halt_check = BRANCH_HALT_VOTED,
  365. .clkr = {
  366. .enable_reg = 0x105c,
  367. .enable_mask = BIT(0),
  368. .hw.init = &(struct clk_init_data){
  369. .name = "gpu_cc_gx_qdss_tsctr_clk",
  370. .ops = &clk_branch2_ops,
  371. },
  372. },
  373. };
  374. static struct clk_branch gpu_cc_gx_vsense_clk = {
  375. .halt_reg = 0x1058,
  376. .halt_check = BRANCH_HALT_VOTED,
  377. .clkr = {
  378. .enable_reg = 0x1058,
  379. .enable_mask = BIT(0),
  380. .hw.init = &(struct clk_init_data){
  381. .name = "gpu_cc_gx_vsense_clk",
  382. .ops = &clk_branch2_ops,
  383. },
  384. },
  385. };
  386. static struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
  387. .halt_reg = 0x5000,
  388. .halt_check = BRANCH_HALT_VOTED,
  389. .clkr = {
  390. .enable_reg = 0x5000,
  391. .enable_mask = BIT(0),
  392. .hw.init = &(struct clk_init_data){
  393. .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
  394. .ops = &clk_branch2_ops,
  395. },
  396. },
  397. };
  398. static struct clk_branch gpu_cc_hub_aon_clk = {
  399. .halt_reg = 0x1178,
  400. .halt_check = BRANCH_HALT,
  401. .clkr = {
  402. .enable_reg = 0x1178,
  403. .enable_mask = BIT(0),
  404. .hw.init = &(struct clk_init_data){
  405. .name = "gpu_cc_hub_aon_clk",
  406. .parent_hws = (const struct clk_hw*[]){
  407. &gpu_cc_hub_clk_src.clkr.hw,
  408. },
  409. .num_parents = 1,
  410. .flags = CLK_SET_RATE_PARENT,
  411. .ops = &clk_branch2_aon_ops,
  412. },
  413. },
  414. };
  415. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  416. .halt_reg = 0x1204,
  417. .halt_check = BRANCH_HALT,
  418. .clkr = {
  419. .enable_reg = 0x1204,
  420. .enable_mask = BIT(0),
  421. .hw.init = &(struct clk_init_data){
  422. .name = "gpu_cc_hub_cx_int_clk",
  423. .parent_hws = (const struct clk_hw*[]){
  424. &gpu_cc_hub_cx_int_div_clk_src.clkr.hw,
  425. },
  426. .num_parents = 1,
  427. .flags = CLK_SET_RATE_PARENT,
  428. .ops = &clk_branch2_aon_ops,
  429. },
  430. },
  431. };
  432. static struct clk_branch gpu_cc_mnd1x_0_gfx3d_clk = {
  433. .halt_reg = 0x802c,
  434. .halt_check = BRANCH_HALT,
  435. .clkr = {
  436. .enable_reg = 0x802c,
  437. .enable_mask = BIT(0),
  438. .hw.init = &(struct clk_init_data){
  439. .name = "gpu_cc_mnd1x_0_gfx3d_clk",
  440. .ops = &clk_branch2_ops,
  441. },
  442. },
  443. };
  444. static struct clk_branch gpu_cc_mnd1x_1_gfx3d_clk = {
  445. .halt_reg = 0x8030,
  446. .halt_check = BRANCH_HALT,
  447. .clkr = {
  448. .enable_reg = 0x8030,
  449. .enable_mask = BIT(0),
  450. .hw.init = &(struct clk_init_data){
  451. .name = "gpu_cc_mnd1x_1_gfx3d_clk",
  452. .ops = &clk_branch2_ops,
  453. },
  454. },
  455. };
  456. static struct clk_branch gpu_cc_sleep_clk = {
  457. .halt_reg = 0x1090,
  458. .halt_check = BRANCH_HALT_VOTED,
  459. .clkr = {
  460. .enable_reg = 0x1090,
  461. .enable_mask = BIT(0),
  462. .hw.init = &(struct clk_init_data){
  463. .name = "gpu_cc_sleep_clk",
  464. .ops = &clk_branch2_ops,
  465. },
  466. },
  467. };
  468. static struct gdsc gpu_cx_gdsc = {
  469. .gdscr = 0x106c,
  470. .gds_hw_ctrl = 0x1540,
  471. .pd = {
  472. .name = "gpu_cx_gdsc",
  473. },
  474. .pwrsts = PWRSTS_OFF_ON,
  475. .flags = VOTABLE,
  476. };
  477. static struct gdsc gpu_gx_gdsc = {
  478. .gdscr = 0x100c,
  479. .clamp_io_ctrl = 0x1508,
  480. .pd = {
  481. .name = "gpu_gx_gdsc",
  482. .power_on = gdsc_gx_do_nothing_enable,
  483. },
  484. .pwrsts = PWRSTS_OFF_ON,
  485. .flags = CLAMP_IO | AON_RESET | POLL_CFG_GDSCR,
  486. };
  487. static struct clk_regmap *gpu_cc_sm8350_clocks[] = {
  488. [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
  489. [GPU_CC_CB_CLK] = &gpu_cc_cb_clk.clkr,
  490. [GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr,
  491. [GPU_CC_CX_APB_CLK] = &gpu_cc_cx_apb_clk.clkr,
  492. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  493. [GPU_CC_CX_QDSS_AT_CLK] = &gpu_cc_cx_qdss_at_clk.clkr,
  494. [GPU_CC_CX_QDSS_TRIG_CLK] = &gpu_cc_cx_qdss_trig_clk.clkr,
  495. [GPU_CC_CX_QDSS_TSCTR_CLK] = &gpu_cc_cx_qdss_tsctr_clk.clkr,
  496. [GPU_CC_CX_SNOC_DVM_CLK] = &gpu_cc_cx_snoc_dvm_clk.clkr,
  497. [GPU_CC_CXO_AON_CLK] = &gpu_cc_cxo_aon_clk.clkr,
  498. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  499. [GPU_CC_FREQ_MEASURE_CLK] = &gpu_cc_freq_measure_clk.clkr,
  500. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  501. [GPU_CC_GX_GMU_CLK] = &gpu_cc_gx_gmu_clk.clkr,
  502. [GPU_CC_GX_QDSS_TSCTR_CLK] = &gpu_cc_gx_qdss_tsctr_clk.clkr,
  503. [GPU_CC_GX_VSENSE_CLK] = &gpu_cc_gx_vsense_clk.clkr,
  504. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  505. [GPU_CC_HUB_AHB_DIV_CLK_SRC] = &gpu_cc_hub_ahb_div_clk_src.clkr,
  506. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  507. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  508. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  509. [GPU_CC_HUB_CX_INT_DIV_CLK_SRC] = &gpu_cc_hub_cx_int_div_clk_src.clkr,
  510. [GPU_CC_MND1X_0_GFX3D_CLK] = &gpu_cc_mnd1x_0_gfx3d_clk.clkr,
  511. [GPU_CC_MND1X_1_GFX3D_CLK] = &gpu_cc_mnd1x_1_gfx3d_clk.clkr,
  512. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  513. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  514. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  515. };
  516. static const struct qcom_reset_map gpu_cc_sm8350_resets[] = {
  517. [GPUCC_GPU_CC_ACD_BCR] = { 0x1160 },
  518. [GPUCC_GPU_CC_CB_BCR] = { 0x116c },
  519. [GPUCC_GPU_CC_CX_BCR] = { 0x1068 },
  520. [GPUCC_GPU_CC_FAST_HUB_BCR] = { 0x1174 },
  521. [GPUCC_GPU_CC_GFX3D_AON_BCR] = { 0x10a0 },
  522. [GPUCC_GPU_CC_GMU_BCR] = { 0x111c },
  523. [GPUCC_GPU_CC_GX_BCR] = { 0x1008 },
  524. [GPUCC_GPU_CC_XO_BCR] = { 0x1000 },
  525. };
  526. static struct gdsc *gpu_cc_sm8350_gdscs[] = {
  527. [GPU_CX_GDSC] = &gpu_cx_gdsc,
  528. [GPU_GX_GDSC] = &gpu_gx_gdsc,
  529. };
  530. static const struct regmap_config gpu_cc_sm8350_regmap_config = {
  531. .reg_bits = 32,
  532. .reg_stride = 4,
  533. .val_bits = 32,
  534. .max_register = 0x8030,
  535. .fast_io = true,
  536. };
  537. static const struct qcom_cc_desc gpu_cc_sm8350_desc = {
  538. .config = &gpu_cc_sm8350_regmap_config,
  539. .clks = gpu_cc_sm8350_clocks,
  540. .num_clks = ARRAY_SIZE(gpu_cc_sm8350_clocks),
  541. .resets = gpu_cc_sm8350_resets,
  542. .num_resets = ARRAY_SIZE(gpu_cc_sm8350_resets),
  543. .gdscs = gpu_cc_sm8350_gdscs,
  544. .num_gdscs = ARRAY_SIZE(gpu_cc_sm8350_gdscs),
  545. };
  546. static int gpu_cc_sm8350_probe(struct platform_device *pdev)
  547. {
  548. struct regmap *regmap;
  549. regmap = qcom_cc_map(pdev, &gpu_cc_sm8350_desc);
  550. if (IS_ERR(regmap)) {
  551. dev_err(&pdev->dev, "Failed to map gpu cc registers\n");
  552. return PTR_ERR(regmap);
  553. }
  554. clk_lucid_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  555. clk_lucid_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
  556. return qcom_cc_really_probe(&pdev->dev, &gpu_cc_sm8350_desc, regmap);
  557. }
  558. static const struct of_device_id gpu_cc_sm8350_match_table[] = {
  559. { .compatible = "qcom,sm8350-gpucc" },
  560. { }
  561. };
  562. MODULE_DEVICE_TABLE(of, gpu_cc_sm8350_match_table);
  563. static struct platform_driver gpu_cc_sm8350_driver = {
  564. .probe = gpu_cc_sm8350_probe,
  565. .driver = {
  566. .name = "sm8350-gpucc",
  567. .of_match_table = gpu_cc_sm8350_match_table,
  568. },
  569. };
  570. module_platform_driver(gpu_cc_sm8350_driver);
  571. MODULE_DESCRIPTION("QTI GPU_CC SM8350 Driver");
  572. MODULE_LICENSE("GPL v2");