gpucc-sm8350.c 15 KB

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