gpucc-sm8650.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved
  4. * Copyright (c) 2023, Linaro Limited
  5. */
  6. #include <linux/clk-provider.h>
  7. #include <linux/mod_devicetable.h>
  8. #include <linux/module.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/regmap.h>
  11. #include <dt-bindings/clock/qcom,sm8650-gpucc.h>
  12. #include <dt-bindings/reset/qcom,sm8650-gpucc.h>
  13. #include "clk-alpha-pll.h"
  14. #include "clk-branch.h"
  15. #include "clk-rcg.h"
  16. #include "clk-regmap.h"
  17. #include "clk-regmap-divider.h"
  18. #include "clk-regmap-mux.h"
  19. #include "clk-regmap-phy-mux.h"
  20. #include "gdsc.h"
  21. #include "reset.h"
  22. enum {
  23. DT_BI_TCXO,
  24. DT_GPLL0_OUT_MAIN,
  25. DT_GPLL0_OUT_MAIN_DIV,
  26. };
  27. enum {
  28. P_BI_TCXO,
  29. P_GPLL0_OUT_MAIN,
  30. P_GPLL0_OUT_MAIN_DIV,
  31. P_GPU_CC_PLL0_OUT_MAIN,
  32. P_GPU_CC_PLL1_OUT_MAIN,
  33. };
  34. static const struct pll_vco lucid_ole_vco[] = {
  35. { 249600000, 2100000000, 0 },
  36. };
  37. static const struct alpha_pll_config gpu_cc_pll0_config = {
  38. .l = 0x20,
  39. .alpha = 0x4aaa,
  40. .config_ctl_val = 0x20485699,
  41. .config_ctl_hi_val = 0x00182261,
  42. .config_ctl_hi1_val = 0x82aa299c,
  43. .test_ctl_val = 0x00000000,
  44. .test_ctl_hi_val = 0x00000003,
  45. .test_ctl_hi1_val = 0x00009000,
  46. .test_ctl_hi2_val = 0x00000034,
  47. .user_ctl_val = 0x00000000,
  48. .user_ctl_hi_val = 0x00000005,
  49. };
  50. static struct clk_alpha_pll gpu_cc_pll0 = {
  51. .offset = 0x0,
  52. .vco_table = lucid_ole_vco,
  53. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  54. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  55. .clkr = {
  56. .hw.init = &(struct clk_init_data){
  57. .name = "gpu_cc_pll0",
  58. .parent_data = &(const struct clk_parent_data){
  59. .index = DT_BI_TCXO,
  60. },
  61. .num_parents = 1,
  62. .ops = &clk_alpha_pll_lucid_evo_ops,
  63. },
  64. },
  65. };
  66. static const struct alpha_pll_config gpu_cc_pll1_config = {
  67. .l = 0x1b,
  68. .alpha = 0x1555,
  69. .config_ctl_val = 0x20485699,
  70. .config_ctl_hi_val = 0x00182261,
  71. .config_ctl_hi1_val = 0x82aa299c,
  72. .test_ctl_val = 0x00000000,
  73. .test_ctl_hi_val = 0x00000003,
  74. .test_ctl_hi1_val = 0x00009000,
  75. .test_ctl_hi2_val = 0x00000034,
  76. .user_ctl_val = 0x00000000,
  77. .user_ctl_hi_val = 0x00000005,
  78. };
  79. static struct clk_alpha_pll gpu_cc_pll1 = {
  80. .offset = 0x1000,
  81. .vco_table = lucid_ole_vco,
  82. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  83. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  84. .clkr = {
  85. .hw.init = &(struct clk_init_data){
  86. .name = "gpu_cc_pll1",
  87. .parent_data = &(const struct clk_parent_data){
  88. .index = DT_BI_TCXO,
  89. },
  90. .num_parents = 1,
  91. .ops = &clk_alpha_pll_lucid_evo_ops,
  92. },
  93. },
  94. };
  95. static const struct parent_map gpu_cc_parent_map_0[] = {
  96. { P_BI_TCXO, 0 },
  97. { P_GPLL0_OUT_MAIN, 5 },
  98. { P_GPLL0_OUT_MAIN_DIV, 6 },
  99. };
  100. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  101. { .index = DT_BI_TCXO },
  102. { .index = DT_GPLL0_OUT_MAIN },
  103. { .index = DT_GPLL0_OUT_MAIN_DIV },
  104. };
  105. static const struct parent_map gpu_cc_parent_map_1[] = {
  106. { P_BI_TCXO, 0 },
  107. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  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. { .index = DT_BI_TCXO },
  114. { .hw = &gpu_cc_pll0.clkr.hw },
  115. { .hw = &gpu_cc_pll1.clkr.hw },
  116. { .index = DT_GPLL0_OUT_MAIN },
  117. { .index = DT_GPLL0_OUT_MAIN_DIV },
  118. };
  119. static const struct parent_map gpu_cc_parent_map_2[] = {
  120. { P_BI_TCXO, 0 },
  121. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  122. { P_GPLL0_OUT_MAIN, 5 },
  123. { P_GPLL0_OUT_MAIN_DIV, 6 },
  124. };
  125. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  126. { .index = DT_BI_TCXO },
  127. { .hw = &gpu_cc_pll1.clkr.hw },
  128. { .index = DT_GPLL0_OUT_MAIN },
  129. { .index = DT_GPLL0_OUT_MAIN_DIV },
  130. };
  131. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  132. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  133. { }
  134. };
  135. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  136. .cmd_rcgr = 0x9474,
  137. .mnd_width = 0,
  138. .hid_width = 5,
  139. .parent_map = gpu_cc_parent_map_0,
  140. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  141. .hw_clk_ctrl = true,
  142. .clkr.hw.init = &(struct clk_init_data){
  143. .name = "gpu_cc_ff_clk_src",
  144. .parent_data = gpu_cc_parent_data_0,
  145. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  146. .flags = CLK_SET_RATE_PARENT,
  147. .ops = &clk_rcg2_shared_ops,
  148. },
  149. };
  150. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  151. F(19200000, P_BI_TCXO, 1, 0, 0),
  152. F(260000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  153. F(625000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  154. { }
  155. };
  156. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  157. .cmd_rcgr = 0x9318,
  158. .mnd_width = 0,
  159. .hid_width = 5,
  160. .parent_map = gpu_cc_parent_map_1,
  161. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  162. .hw_clk_ctrl = true,
  163. .clkr.hw.init = &(struct clk_init_data){
  164. .name = "gpu_cc_gmu_clk_src",
  165. .parent_data = gpu_cc_parent_data_1,
  166. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  167. .flags = CLK_SET_RATE_PARENT,
  168. .ops = &clk_rcg2_shared_ops,
  169. },
  170. };
  171. static const struct freq_tbl ftbl_gpu_cc_hub_clk_src[] = {
  172. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  173. F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0),
  174. { }
  175. };
  176. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  177. .cmd_rcgr = 0x93ec,
  178. .mnd_width = 0,
  179. .hid_width = 5,
  180. .parent_map = gpu_cc_parent_map_2,
  181. .freq_tbl = ftbl_gpu_cc_hub_clk_src,
  182. .hw_clk_ctrl = true,
  183. .clkr.hw.init = &(struct clk_init_data){
  184. .name = "gpu_cc_hub_clk_src",
  185. .parent_data = gpu_cc_parent_data_2,
  186. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_2),
  187. .flags = CLK_SET_RATE_PARENT,
  188. .ops = &clk_rcg2_shared_ops,
  189. },
  190. };
  191. static struct clk_regmap_div gpu_cc_hub_div_clk_src = {
  192. .reg = 0x942c,
  193. .shift = 0,
  194. .width = 4,
  195. .clkr.hw.init = &(const struct clk_init_data) {
  196. .name = "gpu_cc_hub_div_clk_src",
  197. .parent_hws = (const struct clk_hw*[]){
  198. &gpu_cc_hub_clk_src.clkr.hw,
  199. },
  200. .num_parents = 1,
  201. .flags = CLK_SET_RATE_PARENT,
  202. .ops = &clk_regmap_div_ro_ops,
  203. },
  204. };
  205. static struct clk_branch gpu_cc_ahb_clk = {
  206. .halt_reg = 0x911c,
  207. .halt_check = BRANCH_HALT_DELAY,
  208. .clkr = {
  209. .enable_reg = 0x911c,
  210. .enable_mask = BIT(0),
  211. .hw.init = &(struct clk_init_data){
  212. .name = "gpu_cc_ahb_clk",
  213. .parent_hws = (const struct clk_hw*[]){
  214. &gpu_cc_hub_div_clk_src.clkr.hw,
  215. },
  216. .num_parents = 1,
  217. .flags = CLK_SET_RATE_PARENT,
  218. .ops = &clk_branch2_ops,
  219. },
  220. },
  221. };
  222. static struct clk_branch gpu_cc_crc_ahb_clk = {
  223. .halt_reg = 0x9120,
  224. .halt_check = BRANCH_HALT_VOTED,
  225. .clkr = {
  226. .enable_reg = 0x9120,
  227. .enable_mask = BIT(0),
  228. .hw.init = &(struct clk_init_data){
  229. .name = "gpu_cc_crc_ahb_clk",
  230. .parent_hws = (const struct clk_hw*[]){
  231. &gpu_cc_hub_clk_src.clkr.hw,
  232. },
  233. .num_parents = 1,
  234. .flags = CLK_SET_RATE_PARENT,
  235. .ops = &clk_branch2_ops,
  236. },
  237. },
  238. };
  239. static struct clk_branch gpu_cc_cx_accu_shift_clk = {
  240. .halt_reg = 0x9160,
  241. .halt_check = BRANCH_HALT_VOTED,
  242. .clkr = {
  243. .enable_reg = 0x9160,
  244. .enable_mask = BIT(0),
  245. .hw.init = &(const struct clk_init_data){
  246. .name = "gpu_cc_cx_accu_shift_clk",
  247. .ops = &clk_branch2_ops,
  248. },
  249. },
  250. };
  251. static struct clk_branch gpu_cc_cx_ff_clk = {
  252. .halt_reg = 0x914c,
  253. .halt_check = BRANCH_HALT,
  254. .clkr = {
  255. .enable_reg = 0x914c,
  256. .enable_mask = BIT(0),
  257. .hw.init = &(struct clk_init_data){
  258. .name = "gpu_cc_cx_ff_clk",
  259. .parent_hws = (const struct clk_hw*[]){
  260. &gpu_cc_ff_clk_src.clkr.hw,
  261. },
  262. .num_parents = 1,
  263. .flags = CLK_SET_RATE_PARENT,
  264. .ops = &clk_branch2_ops,
  265. },
  266. },
  267. };
  268. static struct clk_branch gpu_cc_cx_gmu_clk = {
  269. .halt_reg = 0x913c,
  270. .halt_check = BRANCH_HALT_VOTED,
  271. .clkr = {
  272. .enable_reg = 0x913c,
  273. .enable_mask = BIT(0),
  274. .hw.init = &(struct clk_init_data){
  275. .name = "gpu_cc_cx_gmu_clk",
  276. .parent_hws = (const struct clk_hw*[]){
  277. &gpu_cc_gmu_clk_src.clkr.hw,
  278. },
  279. .num_parents = 1,
  280. .flags = CLK_SET_RATE_PARENT,
  281. .ops = &clk_branch2_aon_ops,
  282. },
  283. },
  284. };
  285. static struct clk_branch gpu_cc_cxo_aon_clk = {
  286. .halt_reg = 0x9004,
  287. .halt_check = BRANCH_HALT_VOTED,
  288. .clkr = {
  289. .enable_reg = 0x9004,
  290. .enable_mask = BIT(0),
  291. .hw.init = &(struct clk_init_data){
  292. .name = "gpu_cc_cxo_aon_clk",
  293. .ops = &clk_branch2_ops,
  294. },
  295. },
  296. };
  297. static struct clk_branch gpu_cc_cxo_clk = {
  298. .halt_reg = 0x9144,
  299. .halt_check = BRANCH_HALT,
  300. .clkr = {
  301. .enable_reg = 0x9144,
  302. .enable_mask = BIT(0),
  303. .hw.init = &(struct clk_init_data){
  304. .name = "gpu_cc_cxo_clk",
  305. .ops = &clk_branch2_ops,
  306. },
  307. },
  308. };
  309. static struct clk_branch gpu_cc_demet_clk = {
  310. .halt_reg = 0x900c,
  311. .halt_check = BRANCH_HALT,
  312. .clkr = {
  313. .enable_reg = 0x900c,
  314. .enable_mask = BIT(0),
  315. .hw.init = &(struct clk_init_data){
  316. .name = "gpu_cc_demet_clk",
  317. .ops = &clk_branch2_aon_ops,
  318. },
  319. },
  320. };
  321. static struct clk_branch gpu_cc_freq_measure_clk = {
  322. .halt_reg = 0x9008,
  323. .halt_check = BRANCH_HALT,
  324. .clkr = {
  325. .enable_reg = 0x9008,
  326. .enable_mask = BIT(0),
  327. .hw.init = &(struct clk_init_data){
  328. .name = "gpu_cc_freq_measure_clk",
  329. .ops = &clk_branch2_ops,
  330. },
  331. },
  332. };
  333. static struct clk_branch gpu_cc_gx_gfx3d_clk = {
  334. .halt_reg = 0x90a8,
  335. .halt_check = BRANCH_HALT,
  336. .clkr = {
  337. .enable_reg = 0x90a8,
  338. .enable_mask = BIT(0),
  339. .hw.init = &(struct clk_init_data){
  340. .name = "gpu_cc_gx_gfx3d_clk",
  341. .ops = &clk_branch2_ops,
  342. },
  343. },
  344. };
  345. static struct clk_branch gpu_cc_gx_gfx3d_rdvm_clk = {
  346. .halt_reg = 0x90c8,
  347. .halt_check = BRANCH_HALT,
  348. .clkr = {
  349. .enable_reg = 0x90c8,
  350. .enable_mask = BIT(0),
  351. .hw.init = &(struct clk_init_data){
  352. .name = "gpu_cc_gx_gfx3d_rdvm_clk",
  353. .ops = &clk_branch2_ops,
  354. },
  355. },
  356. };
  357. static struct clk_branch gpu_cc_gx_gmu_clk = {
  358. .halt_reg = 0x90bc,
  359. .halt_check = BRANCH_HALT,
  360. .clkr = {
  361. .enable_reg = 0x90bc,
  362. .enable_mask = BIT(0),
  363. .hw.init = &(struct clk_init_data){
  364. .name = "gpu_cc_gx_gmu_clk",
  365. .parent_hws = (const struct clk_hw*[]){
  366. &gpu_cc_gmu_clk_src.clkr.hw,
  367. },
  368. .num_parents = 1,
  369. .flags = CLK_SET_RATE_PARENT,
  370. .ops = &clk_branch2_ops,
  371. },
  372. },
  373. };
  374. static struct clk_branch gpu_cc_gx_vsense_clk = {
  375. .halt_reg = 0x90b0,
  376. .halt_check = BRANCH_HALT_VOTED,
  377. .clkr = {
  378. .enable_reg = 0x90b0,
  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_gx_accu_shift_clk = {
  387. .halt_reg = 0x90d0,
  388. .halt_check = BRANCH_HALT_VOTED,
  389. .clkr = {
  390. .enable_reg = 0x90d0,
  391. .enable_mask = BIT(0),
  392. .hw.init = &(const struct clk_init_data){
  393. .name = "gpu_cc_gx_accu_shift_clk",
  394. .ops = &clk_branch2_ops,
  395. },
  396. },
  397. };
  398. static struct clk_branch gpu_cc_gx_ff_clk = {
  399. .halt_reg = 0x90c0,
  400. .halt_check = BRANCH_HALT,
  401. .clkr = {
  402. .enable_reg = 0x90c0,
  403. .enable_mask = BIT(0),
  404. .hw.init = &(const struct clk_init_data){
  405. .name = "gpu_cc_gx_ff_clk",
  406. .parent_hws = (const struct clk_hw*[]){
  407. &gpu_cc_ff_clk_src.clkr.hw,
  408. },
  409. .num_parents = 1,
  410. .flags = CLK_SET_RATE_PARENT,
  411. .ops = &clk_branch2_ops,
  412. },
  413. },
  414. };
  415. static struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
  416. .halt_reg = 0x7000,
  417. .halt_check = BRANCH_HALT_VOTED,
  418. .clkr = {
  419. .enable_reg = 0x7000,
  420. .enable_mask = BIT(0),
  421. .hw.init = &(struct clk_init_data){
  422. .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
  423. .ops = &clk_branch2_ops,
  424. },
  425. },
  426. };
  427. static struct clk_branch gpu_cc_hub_aon_clk = {
  428. .halt_reg = 0x93e8,
  429. .halt_check = BRANCH_HALT_VOTED,
  430. .clkr = {
  431. .enable_reg = 0x93e8,
  432. .enable_mask = BIT(0),
  433. .hw.init = &(struct clk_init_data){
  434. .name = "gpu_cc_hub_aon_clk",
  435. .parent_hws = (const struct clk_hw*[]){
  436. &gpu_cc_hub_clk_src.clkr.hw,
  437. },
  438. .num_parents = 1,
  439. .flags = CLK_SET_RATE_PARENT,
  440. .ops = &clk_branch2_aon_ops,
  441. },
  442. },
  443. };
  444. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  445. .halt_reg = 0x9148,
  446. .halt_check = BRANCH_HALT_VOTED,
  447. .clkr = {
  448. .enable_reg = 0x9148,
  449. .enable_mask = BIT(0),
  450. .hw.init = &(struct clk_init_data){
  451. .name = "gpu_cc_hub_cx_int_clk",
  452. .parent_hws = (const struct clk_hw*[]){
  453. &gpu_cc_hub_clk_src.clkr.hw,
  454. },
  455. .num_parents = 1,
  456. .flags = CLK_SET_RATE_PARENT,
  457. .ops = &clk_branch2_aon_ops,
  458. },
  459. },
  460. };
  461. static struct clk_branch gpu_cc_memnoc_gfx_clk = {
  462. .halt_reg = 0x9150,
  463. .halt_check = BRANCH_HALT_VOTED,
  464. .clkr = {
  465. .enable_reg = 0x9150,
  466. .enable_mask = BIT(0),
  467. .hw.init = &(struct clk_init_data){
  468. .name = "gpu_cc_memnoc_gfx_clk",
  469. .ops = &clk_branch2_ops,
  470. },
  471. },
  472. };
  473. static struct clk_branch gpu_cc_sleep_clk = {
  474. .halt_reg = 0x9134,
  475. .halt_check = BRANCH_HALT_VOTED,
  476. .clkr = {
  477. .enable_reg = 0x9134,
  478. .enable_mask = BIT(0),
  479. .hw.init = &(struct clk_init_data){
  480. .name = "gpu_cc_sleep_clk",
  481. .ops = &clk_branch2_ops,
  482. },
  483. },
  484. };
  485. static struct clk_branch gpu_cc_dpm_clk = {
  486. .halt_reg = 0x9164,
  487. .halt_check = BRANCH_HALT,
  488. .clkr = {
  489. .enable_reg = 0x9164,
  490. .enable_mask = BIT(0),
  491. .hw.init = &(const struct clk_init_data){
  492. .name = "gpu_cc_dpm_clk",
  493. .ops = &clk_branch2_ops,
  494. },
  495. },
  496. };
  497. static struct gdsc gpu_cx_gdsc = {
  498. .gdscr = 0x9108,
  499. .gds_hw_ctrl = 0x9168,
  500. .clk_dis_wait_val = 8,
  501. .pd = {
  502. .name = "gpu_cx_gdsc",
  503. },
  504. .pwrsts = PWRSTS_OFF_ON,
  505. .flags = VOTABLE | RETAIN_FF_ENABLE,
  506. };
  507. static struct gdsc gpu_gx_gdsc = {
  508. .gdscr = 0x905c,
  509. .clamp_io_ctrl = 0x9504,
  510. .resets = (unsigned int []){ GPUCC_GPU_CC_GX_BCR,
  511. GPUCC_GPU_CC_ACD_BCR,
  512. GPUCC_GPU_CC_GX_ACD_IROOT_BCR },
  513. .reset_count = 3,
  514. .pd = {
  515. .name = "gpu_gx_gdsc",
  516. .power_on = gdsc_gx_do_nothing_enable,
  517. },
  518. .pwrsts = PWRSTS_OFF_ON,
  519. .flags = CLAMP_IO | AON_RESET | SW_RESET | POLL_CFG_GDSCR,
  520. };
  521. static struct clk_regmap *gpu_cc_sm8650_clocks[] = {
  522. [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
  523. [GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr,
  524. [GPU_CC_CX_ACCU_SHIFT_CLK] = &gpu_cc_cx_accu_shift_clk.clkr,
  525. [GPU_CC_CX_FF_CLK] = &gpu_cc_cx_ff_clk.clkr,
  526. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  527. [GPU_CC_CXO_AON_CLK] = &gpu_cc_cxo_aon_clk.clkr,
  528. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  529. [GPU_CC_DEMET_CLK] = &gpu_cc_demet_clk.clkr,
  530. [GPU_CC_DPM_CLK] = &gpu_cc_dpm_clk.clkr,
  531. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  532. [GPU_CC_FREQ_MEASURE_CLK] = &gpu_cc_freq_measure_clk.clkr,
  533. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  534. [GPU_CC_GX_ACCU_SHIFT_CLK] = &gpu_cc_gx_accu_shift_clk.clkr,
  535. [GPU_CC_GX_FF_CLK] = &gpu_cc_gx_ff_clk.clkr,
  536. [GPU_CC_GX_GFX3D_CLK] = &gpu_cc_gx_gfx3d_clk.clkr,
  537. [GPU_CC_GX_GFX3D_RDVM_CLK] = &gpu_cc_gx_gfx3d_rdvm_clk.clkr,
  538. [GPU_CC_GX_GMU_CLK] = &gpu_cc_gx_gmu_clk.clkr,
  539. [GPU_CC_GX_VSENSE_CLK] = &gpu_cc_gx_vsense_clk.clkr,
  540. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  541. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  542. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  543. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  544. [GPU_CC_HUB_DIV_CLK_SRC] = &gpu_cc_hub_div_clk_src.clkr,
  545. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  546. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  547. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  548. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  549. };
  550. static const struct qcom_reset_map gpu_cc_sm8650_resets[] = {
  551. [GPUCC_GPU_CC_XO_BCR] = { 0x9000 },
  552. [GPUCC_GPU_CC_GX_BCR] = { 0x9058 },
  553. [GPUCC_GPU_CC_CX_BCR] = { 0x9104 },
  554. [GPUCC_GPU_CC_GFX3D_AON_BCR] = { 0x9198 },
  555. [GPUCC_GPU_CC_ACD_BCR] = { 0x9358 },
  556. [GPUCC_GPU_CC_FAST_HUB_BCR] = { 0x93e4 },
  557. [GPUCC_GPU_CC_FF_BCR] = { 0x9470 },
  558. [GPUCC_GPU_CC_GMU_BCR] = { 0x9314 },
  559. [GPUCC_GPU_CC_GX_ACD_IROOT_BCR] = { 0x958c },
  560. };
  561. static struct gdsc *gpu_cc_sm8650_gdscs[] = {
  562. [GPU_CX_GDSC] = &gpu_cx_gdsc,
  563. [GPU_GX_GDSC] = &gpu_gx_gdsc,
  564. };
  565. static const struct regmap_config gpu_cc_sm8650_regmap_config = {
  566. .reg_bits = 32,
  567. .reg_stride = 4,
  568. .val_bits = 32,
  569. .max_register = 0xa000,
  570. .fast_io = true,
  571. };
  572. static const struct qcom_cc_desc gpu_cc_sm8650_desc = {
  573. .config = &gpu_cc_sm8650_regmap_config,
  574. .clks = gpu_cc_sm8650_clocks,
  575. .num_clks = ARRAY_SIZE(gpu_cc_sm8650_clocks),
  576. .resets = gpu_cc_sm8650_resets,
  577. .num_resets = ARRAY_SIZE(gpu_cc_sm8650_resets),
  578. .gdscs = gpu_cc_sm8650_gdscs,
  579. .num_gdscs = ARRAY_SIZE(gpu_cc_sm8650_gdscs),
  580. };
  581. static const struct of_device_id gpu_cc_sm8650_match_table[] = {
  582. { .compatible = "qcom,sm8650-gpucc" },
  583. { }
  584. };
  585. MODULE_DEVICE_TABLE(of, gpu_cc_sm8650_match_table);
  586. static int gpu_cc_sm8650_probe(struct platform_device *pdev)
  587. {
  588. struct regmap *regmap;
  589. regmap = qcom_cc_map(pdev, &gpu_cc_sm8650_desc);
  590. if (IS_ERR(regmap))
  591. return PTR_ERR(regmap);
  592. clk_lucid_ole_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  593. clk_lucid_ole_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
  594. return qcom_cc_really_probe(&pdev->dev, &gpu_cc_sm8650_desc, regmap);
  595. }
  596. static struct platform_driver gpu_cc_sm8650_driver = {
  597. .probe = gpu_cc_sm8650_probe,
  598. .driver = {
  599. .name = "sm8650-gpucc",
  600. .of_match_table = gpu_cc_sm8650_match_table,
  601. },
  602. };
  603. module_platform_driver(gpu_cc_sm8650_driver);
  604. MODULE_DESCRIPTION("QTI GPU_CC SM8650 Driver");
  605. MODULE_LICENSE("GPL");