gpucc-sa8775p.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2021-2022, 2024, Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2023, Linaro Limited
  5. */
  6. #include <linux/clk-provider.h>
  7. #include <linux/err.h>
  8. #include <linux/kernel.h>
  9. #include <linux/mod_devicetable.h>
  10. #include <linux/module.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/regmap.h>
  13. #include <dt-bindings/clock/qcom,qcs8300-gpucc.h>
  14. #include "clk-alpha-pll.h"
  15. #include "clk-branch.h"
  16. #include "clk-rcg.h"
  17. #include "clk-regmap.h"
  18. #include "clk-regmap-divider.h"
  19. #include "common.h"
  20. #include "reset.h"
  21. #include "gdsc.h"
  22. /* Need to match the order of clocks in DT binding */
  23. enum {
  24. DT_BI_TCXO,
  25. DT_GCC_GPU_GPLL0_CLK_SRC,
  26. DT_GCC_GPU_GPLL0_DIV_CLK_SRC,
  27. };
  28. enum {
  29. P_BI_TCXO,
  30. P_GPLL0_OUT_MAIN,
  31. P_GPLL0_OUT_MAIN_DIV,
  32. P_GPU_CC_PLL0_OUT_MAIN,
  33. P_GPU_CC_PLL1_OUT_MAIN,
  34. };
  35. static const struct clk_parent_data parent_data_tcxo = { .index = DT_BI_TCXO };
  36. static const struct pll_vco lucid_evo_vco[] = {
  37. { 249600000, 2020000000, 0 },
  38. };
  39. /* 810MHz configuration */
  40. static struct alpha_pll_config gpu_cc_pll0_config = {
  41. .l = 0x2a,
  42. .alpha = 0x3000,
  43. .config_ctl_val = 0x20485699,
  44. .config_ctl_hi_val = 0x00182261,
  45. .config_ctl_hi1_val = 0x32aa299c,
  46. .user_ctl_val = 0x00000001,
  47. .user_ctl_hi_val = 0x00400805,
  48. };
  49. static struct clk_alpha_pll gpu_cc_pll0 = {
  50. .offset = 0x0,
  51. .vco_table = lucid_evo_vco,
  52. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  53. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  54. .clkr = {
  55. .hw.init = &(const struct clk_init_data){
  56. .name = "gpu_cc_pll0",
  57. .parent_data = &parent_data_tcxo,
  58. .num_parents = 1,
  59. .ops = &clk_alpha_pll_lucid_evo_ops,
  60. },
  61. },
  62. };
  63. /* 1000MHz configuration */
  64. static struct alpha_pll_config gpu_cc_pll1_config = {
  65. .l = 0x34,
  66. .alpha = 0x1555,
  67. .config_ctl_val = 0x20485699,
  68. .config_ctl_hi_val = 0x00182261,
  69. .config_ctl_hi1_val = 0x32aa299c,
  70. .user_ctl_val = 0x00000001,
  71. .user_ctl_hi_val = 0x00400805,
  72. };
  73. static struct clk_alpha_pll gpu_cc_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 = "gpu_cc_pll1",
  81. .parent_data = &parent_data_tcxo,
  82. .num_parents = 1,
  83. .ops = &clk_alpha_pll_lucid_evo_ops,
  84. },
  85. },
  86. };
  87. static const struct parent_map gpu_cc_parent_map_0[] = {
  88. { P_BI_TCXO, 0 },
  89. { P_GPLL0_OUT_MAIN, 5 },
  90. { P_GPLL0_OUT_MAIN_DIV, 6 },
  91. };
  92. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  93. { .index = DT_BI_TCXO },
  94. { .index = DT_GCC_GPU_GPLL0_CLK_SRC },
  95. { .index = DT_GCC_GPU_GPLL0_DIV_CLK_SRC },
  96. };
  97. static const struct parent_map gpu_cc_parent_map_1[] = {
  98. { P_BI_TCXO, 0 },
  99. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  100. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  101. { P_GPLL0_OUT_MAIN, 5 },
  102. { P_GPLL0_OUT_MAIN_DIV, 6 },
  103. };
  104. static const struct clk_parent_data gpu_cc_parent_data_1[] = {
  105. { .index = DT_BI_TCXO },
  106. { .hw = &gpu_cc_pll0.clkr.hw },
  107. { .hw = &gpu_cc_pll1.clkr.hw },
  108. { .index = DT_GCC_GPU_GPLL0_CLK_SRC },
  109. { .index = DT_GCC_GPU_GPLL0_DIV_CLK_SRC },
  110. };
  111. static const struct parent_map gpu_cc_parent_map_2[] = {
  112. { P_BI_TCXO, 0 },
  113. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  114. { P_GPLL0_OUT_MAIN, 5 },
  115. { P_GPLL0_OUT_MAIN_DIV, 6 },
  116. };
  117. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  118. { .index = DT_BI_TCXO },
  119. { .hw = &gpu_cc_pll1.clkr.hw },
  120. { .index = DT_GCC_GPU_GPLL0_CLK_SRC },
  121. { .index = DT_GCC_GPU_GPLL0_DIV_CLK_SRC },
  122. };
  123. static const struct parent_map gpu_cc_parent_map_3[] = {
  124. { P_BI_TCXO, 0 },
  125. };
  126. static const struct clk_parent_data gpu_cc_parent_data_3[] = {
  127. { .index = DT_BI_TCXO },
  128. };
  129. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  130. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  131. { }
  132. };
  133. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  134. .cmd_rcgr = 0x9474,
  135. .mnd_width = 0,
  136. .hid_width = 5,
  137. .parent_map = gpu_cc_parent_map_0,
  138. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  139. .clkr.hw.init = &(const struct clk_init_data){
  140. .name = "gpu_cc_ff_clk_src",
  141. .parent_data = gpu_cc_parent_data_0,
  142. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  143. .ops = &clk_rcg2_shared_ops,
  144. },
  145. };
  146. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  147. F(500000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  148. { }
  149. };
  150. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  151. .cmd_rcgr = 0x9318,
  152. .mnd_width = 0,
  153. .hid_width = 5,
  154. .parent_map = gpu_cc_parent_map_1,
  155. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  156. .clkr.hw.init = &(const struct clk_init_data){
  157. .name = "gpu_cc_gmu_clk_src",
  158. .parent_data = gpu_cc_parent_data_1,
  159. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  160. .flags = CLK_SET_RATE_PARENT,
  161. .ops = &clk_rcg2_shared_ops,
  162. },
  163. };
  164. static const struct freq_tbl ftbl_gpu_cc_hub_clk_src[] = {
  165. F(240000000, P_GPLL0_OUT_MAIN, 2.5, 0, 0),
  166. { }
  167. };
  168. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  169. .cmd_rcgr = 0x93ec,
  170. .mnd_width = 0,
  171. .hid_width = 5,
  172. .parent_map = gpu_cc_parent_map_2,
  173. .freq_tbl = ftbl_gpu_cc_hub_clk_src,
  174. .clkr.hw.init = &(const struct clk_init_data){
  175. .name = "gpu_cc_hub_clk_src",
  176. .parent_data = gpu_cc_parent_data_2,
  177. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_2),
  178. .ops = &clk_rcg2_shared_ops,
  179. },
  180. };
  181. static const struct freq_tbl ftbl_gpu_cc_xo_clk_src[] = {
  182. F(19200000, P_BI_TCXO, 1, 0, 0),
  183. { }
  184. };
  185. static struct clk_rcg2 gpu_cc_xo_clk_src = {
  186. .cmd_rcgr = 0x9010,
  187. .mnd_width = 0,
  188. .hid_width = 5,
  189. .parent_map = gpu_cc_parent_map_3,
  190. .freq_tbl = ftbl_gpu_cc_xo_clk_src,
  191. .clkr.hw.init = &(const struct clk_init_data){
  192. .name = "gpu_cc_xo_clk_src",
  193. .parent_data = gpu_cc_parent_data_3,
  194. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_3),
  195. .ops = &clk_rcg2_ops,
  196. },
  197. };
  198. static struct clk_regmap_div gpu_cc_demet_div_clk_src = {
  199. .reg = 0x9054,
  200. .shift = 0,
  201. .width = 4,
  202. .clkr.hw.init = &(const struct clk_init_data) {
  203. .name = "gpu_cc_demet_div_clk_src",
  204. .parent_hws = (const struct clk_hw*[]){
  205. &gpu_cc_xo_clk_src.clkr.hw,
  206. },
  207. .num_parents = 1,
  208. .flags = CLK_SET_RATE_PARENT,
  209. .ops = &clk_regmap_div_ro_ops,
  210. },
  211. };
  212. static struct clk_regmap_div gpu_cc_hub_ahb_div_clk_src = {
  213. .reg = 0x9430,
  214. .shift = 0,
  215. .width = 4,
  216. .clkr.hw.init = &(const struct clk_init_data) {
  217. .name = "gpu_cc_hub_ahb_div_clk_src",
  218. .parent_hws = (const struct clk_hw*[]){
  219. &gpu_cc_hub_clk_src.clkr.hw,
  220. },
  221. .num_parents = 1,
  222. .flags = CLK_SET_RATE_PARENT,
  223. .ops = &clk_regmap_div_ro_ops,
  224. },
  225. };
  226. static struct clk_regmap_div gpu_cc_hub_cx_int_div_clk_src = {
  227. .reg = 0x942c,
  228. .shift = 0,
  229. .width = 4,
  230. .clkr.hw.init = &(const struct clk_init_data) {
  231. .name = "gpu_cc_hub_cx_int_div_clk_src",
  232. .parent_hws = (const struct clk_hw*[]){
  233. &gpu_cc_hub_clk_src.clkr.hw,
  234. },
  235. .num_parents = 1,
  236. .flags = CLK_SET_RATE_PARENT,
  237. .ops = &clk_regmap_div_ro_ops,
  238. },
  239. };
  240. static struct clk_branch gpu_cc_ahb_clk = {
  241. .halt_reg = 0x911c,
  242. .halt_check = BRANCH_HALT_DELAY,
  243. .clkr = {
  244. .enable_reg = 0x911c,
  245. .enable_mask = BIT(0),
  246. .hw.init = &(const struct clk_init_data){
  247. .name = "gpu_cc_ahb_clk",
  248. .parent_hws = (const struct clk_hw*[]){
  249. &gpu_cc_hub_ahb_div_clk_src.clkr.hw,
  250. },
  251. .num_parents = 1,
  252. .flags = CLK_SET_RATE_PARENT,
  253. .ops = &clk_branch2_ops,
  254. },
  255. },
  256. };
  257. static struct clk_branch gpu_cc_cb_clk = {
  258. .halt_reg = 0x93a4,
  259. .halt_check = BRANCH_HALT,
  260. .clkr = {
  261. .enable_reg = 0x93a4,
  262. .enable_mask = BIT(0),
  263. .hw.init = &(const struct clk_init_data){
  264. .name = "gpu_cc_cb_clk",
  265. .ops = &clk_branch2_aon_ops,
  266. },
  267. },
  268. };
  269. static struct clk_branch gpu_cc_crc_ahb_clk = {
  270. .halt_reg = 0x9120,
  271. .halt_check = BRANCH_HALT_VOTED,
  272. .clkr = {
  273. .enable_reg = 0x9120,
  274. .enable_mask = BIT(0),
  275. .hw.init = &(const struct clk_init_data){
  276. .name = "gpu_cc_crc_ahb_clk",
  277. .parent_hws = (const struct clk_hw*[]){
  278. &gpu_cc_hub_ahb_div_clk_src.clkr.hw,
  279. },
  280. .num_parents = 1,
  281. .flags = CLK_SET_RATE_PARENT,
  282. .ops = &clk_branch2_ops,
  283. },
  284. },
  285. };
  286. static struct clk_branch gpu_cc_cx_accu_shift_clk = {
  287. .halt_reg = 0x95e8,
  288. .halt_check = BRANCH_HALT,
  289. .clkr = {
  290. .enable_reg = 0x95e8,
  291. .enable_mask = BIT(0),
  292. .hw.init = &(const struct clk_init_data){
  293. .name = "gpu_cc_cx_accu_shift_clk",
  294. .parent_hws = (const struct clk_hw*[]){
  295. &gpu_cc_xo_clk_src.clkr.hw,
  296. },
  297. .num_parents = 1,
  298. .flags = CLK_SET_RATE_PARENT,
  299. .ops = &clk_branch2_ops,
  300. },
  301. },
  302. };
  303. static struct clk_branch gpu_cc_cx_ff_clk = {
  304. .halt_reg = 0x914c,
  305. .halt_check = BRANCH_HALT,
  306. .clkr = {
  307. .enable_reg = 0x914c,
  308. .enable_mask = BIT(0),
  309. .hw.init = &(const struct clk_init_data){
  310. .name = "gpu_cc_cx_ff_clk",
  311. .parent_hws = (const struct clk_hw*[]){
  312. &gpu_cc_ff_clk_src.clkr.hw,
  313. },
  314. .num_parents = 1,
  315. .flags = CLK_SET_RATE_PARENT,
  316. .ops = &clk_branch2_ops,
  317. },
  318. },
  319. };
  320. static struct clk_branch gpu_cc_cx_gmu_clk = {
  321. .halt_reg = 0x913c,
  322. .halt_check = BRANCH_HALT,
  323. .clkr = {
  324. .enable_reg = 0x913c,
  325. .enable_mask = BIT(0),
  326. .hw.init = &(const struct clk_init_data){
  327. .name = "gpu_cc_cx_gmu_clk",
  328. .parent_hws = (const struct clk_hw*[]){
  329. &gpu_cc_gmu_clk_src.clkr.hw,
  330. },
  331. .num_parents = 1,
  332. .flags = CLK_SET_RATE_PARENT,
  333. .ops = &clk_branch2_aon_ops,
  334. },
  335. },
  336. };
  337. static struct clk_branch gpu_cc_cx_snoc_dvm_clk = {
  338. .halt_reg = 0x9130,
  339. .halt_check = BRANCH_HALT_VOTED,
  340. .clkr = {
  341. .enable_reg = 0x9130,
  342. .enable_mask = BIT(0),
  343. .hw.init = &(const struct clk_init_data){
  344. .name = "gpu_cc_cx_snoc_dvm_clk",
  345. .ops = &clk_branch2_ops,
  346. },
  347. },
  348. };
  349. static struct clk_branch gpu_cc_cxo_aon_clk = {
  350. .halt_reg = 0x9004,
  351. .halt_check = BRANCH_HALT_VOTED,
  352. .clkr = {
  353. .enable_reg = 0x9004,
  354. .enable_mask = BIT(0),
  355. .hw.init = &(const struct clk_init_data){
  356. .name = "gpu_cc_cxo_aon_clk",
  357. .parent_hws = (const struct clk_hw*[]){
  358. &gpu_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 gpu_cc_cxo_clk = {
  367. .halt_reg = 0x9144,
  368. .halt_check = BRANCH_HALT,
  369. .clkr = {
  370. .enable_reg = 0x9144,
  371. .enable_mask = BIT(0),
  372. .hw.init = &(const struct clk_init_data){
  373. .name = "gpu_cc_cxo_clk",
  374. .parent_hws = (const struct clk_hw*[]){
  375. &gpu_cc_xo_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 gpu_cc_demet_clk = {
  384. .halt_reg = 0x900c,
  385. .halt_check = BRANCH_HALT,
  386. .clkr = {
  387. .enable_reg = 0x900c,
  388. .enable_mask = BIT(0),
  389. .hw.init = &(const struct clk_init_data){
  390. .name = "gpu_cc_demet_clk",
  391. .parent_hws = (const struct clk_hw*[]){
  392. &gpu_cc_demet_div_clk_src.clkr.hw,
  393. },
  394. .num_parents = 1,
  395. .flags = CLK_SET_RATE_PARENT,
  396. .ops = &clk_branch2_aon_ops,
  397. },
  398. },
  399. };
  400. static struct clk_branch gpu_cc_gx_accu_shift_clk = {
  401. .halt_reg = 0x95e4,
  402. .halt_check = BRANCH_HALT,
  403. .clkr = {
  404. .enable_reg = 0x95e4,
  405. .enable_mask = BIT(0),
  406. .hw.init = &(const struct clk_init_data){
  407. .name = "gpu_cc_gx_accu_shift_clk",
  408. .parent_hws = (const struct clk_hw*[]){
  409. &gpu_cc_xo_clk_src.clkr.hw,
  410. },
  411. .num_parents = 1,
  412. .flags = CLK_SET_RATE_PARENT,
  413. .ops = &clk_branch2_ops,
  414. },
  415. },
  416. };
  417. static struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
  418. .halt_reg = 0x7000,
  419. .halt_check = BRANCH_HALT_VOTED,
  420. .clkr = {
  421. .enable_reg = 0x7000,
  422. .enable_mask = BIT(0),
  423. .hw.init = &(const struct clk_init_data){
  424. .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
  425. .ops = &clk_branch2_ops,
  426. },
  427. },
  428. };
  429. static struct clk_branch gpu_cc_hub_aon_clk = {
  430. .halt_reg = 0x93e8,
  431. .halt_check = BRANCH_HALT,
  432. .clkr = {
  433. .enable_reg = 0x93e8,
  434. .enable_mask = BIT(0),
  435. .hw.init = &(const struct clk_init_data){
  436. .name = "gpu_cc_hub_aon_clk",
  437. .parent_hws = (const struct clk_hw*[]){
  438. &gpu_cc_hub_clk_src.clkr.hw,
  439. },
  440. .num_parents = 1,
  441. .flags = CLK_SET_RATE_PARENT,
  442. .ops = &clk_branch2_aon_ops,
  443. },
  444. },
  445. };
  446. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  447. .halt_reg = 0x9148,
  448. .halt_check = BRANCH_HALT,
  449. .clkr = {
  450. .enable_reg = 0x9148,
  451. .enable_mask = BIT(0),
  452. .hw.init = &(const struct clk_init_data){
  453. .name = "gpu_cc_hub_cx_int_clk",
  454. .parent_hws = (const struct clk_hw*[]){
  455. &gpu_cc_hub_cx_int_div_clk_src.clkr.hw,
  456. },
  457. .num_parents = 1,
  458. .flags = CLK_SET_RATE_PARENT,
  459. .ops = &clk_branch2_aon_ops,
  460. },
  461. },
  462. };
  463. static struct clk_branch gpu_cc_memnoc_gfx_clk = {
  464. .halt_reg = 0x9150,
  465. .halt_check = BRANCH_HALT,
  466. .clkr = {
  467. .enable_reg = 0x9150,
  468. .enable_mask = BIT(0),
  469. .hw.init = &(const struct clk_init_data){
  470. .name = "gpu_cc_memnoc_gfx_clk",
  471. .ops = &clk_branch2_ops,
  472. },
  473. },
  474. };
  475. static struct clk_branch gpu_cc_sleep_clk = {
  476. .halt_reg = 0x9134,
  477. .halt_check = BRANCH_HALT_VOTED,
  478. .clkr = {
  479. .enable_reg = 0x9134,
  480. .enable_mask = BIT(0),
  481. .hw.init = &(const struct clk_init_data){
  482. .name = "gpu_cc_sleep_clk",
  483. .ops = &clk_branch2_ops,
  484. },
  485. },
  486. };
  487. static struct clk_regmap *gpu_cc_sa8775p_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_ACCU_SHIFT_CLK] = NULL,
  492. [GPU_CC_CX_FF_CLK] = &gpu_cc_cx_ff_clk.clkr,
  493. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  494. [GPU_CC_CX_SNOC_DVM_CLK] = &gpu_cc_cx_snoc_dvm_clk.clkr,
  495. [GPU_CC_CXO_AON_CLK] = &gpu_cc_cxo_aon_clk.clkr,
  496. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  497. [GPU_CC_DEMET_CLK] = &gpu_cc_demet_clk.clkr,
  498. [GPU_CC_DEMET_DIV_CLK_SRC] = &gpu_cc_demet_div_clk_src.clkr,
  499. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  500. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  501. [GPU_CC_GX_ACCU_SHIFT_CLK] = NULL,
  502. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  503. [GPU_CC_HUB_AHB_DIV_CLK_SRC] = &gpu_cc_hub_ahb_div_clk_src.clkr,
  504. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  505. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  506. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  507. [GPU_CC_HUB_CX_INT_DIV_CLK_SRC] = &gpu_cc_hub_cx_int_div_clk_src.clkr,
  508. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  509. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  510. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  511. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  512. [GPU_CC_XO_CLK_SRC] = &gpu_cc_xo_clk_src.clkr,
  513. };
  514. static struct gdsc cx_gdsc = {
  515. .gdscr = 0x9108,
  516. .en_rest_wait_val = 0x2,
  517. .en_few_wait_val = 0x2,
  518. .clk_dis_wait_val = 0xf,
  519. .gds_hw_ctrl = 0x953c,
  520. .pd = {
  521. .name = "cx_gdsc",
  522. },
  523. .pwrsts = PWRSTS_OFF_ON,
  524. .flags = VOTABLE | RETAIN_FF_ENABLE,
  525. };
  526. static struct gdsc gx_gdsc = {
  527. .gdscr = 0x905c,
  528. .en_rest_wait_val = 0x2,
  529. .en_few_wait_val = 0x2,
  530. .clk_dis_wait_val = 0xf,
  531. .pd = {
  532. .name = "gx_gdsc",
  533. .power_on = gdsc_gx_do_nothing_enable,
  534. },
  535. .pwrsts = PWRSTS_OFF_ON,
  536. .flags = AON_RESET | RETAIN_FF_ENABLE,
  537. };
  538. static struct gdsc *gpu_cc_sa8775p_gdscs[] = {
  539. [GPU_CC_CX_GDSC] = &cx_gdsc,
  540. [GPU_CC_GX_GDSC] = &gx_gdsc,
  541. };
  542. static const struct qcom_reset_map gpu_cc_sa8775p_resets[] = {
  543. [GPUCC_GPU_CC_ACD_BCR] = { 0x9358 },
  544. [GPUCC_GPU_CC_CB_BCR] = { 0x93a0 },
  545. [GPUCC_GPU_CC_CX_BCR] = { 0x9104 },
  546. [GPUCC_GPU_CC_FAST_HUB_BCR] = { 0x93e4 },
  547. [GPUCC_GPU_CC_FF_BCR] = { 0x9470 },
  548. [GPUCC_GPU_CC_GFX3D_AON_BCR] = { 0x9198 },
  549. [GPUCC_GPU_CC_GMU_BCR] = { 0x9314 },
  550. [GPUCC_GPU_CC_GX_BCR] = { 0x9058 },
  551. [GPUCC_GPU_CC_XO_BCR] = { 0x9000 },
  552. };
  553. static const struct regmap_config gpu_cc_sa8775p_regmap_config = {
  554. .reg_bits = 32,
  555. .reg_stride = 4,
  556. .val_bits = 32,
  557. .max_register = 0x9988,
  558. .fast_io = true,
  559. };
  560. static const struct qcom_cc_desc gpu_cc_sa8775p_desc = {
  561. .config = &gpu_cc_sa8775p_regmap_config,
  562. .clks = gpu_cc_sa8775p_clocks,
  563. .num_clks = ARRAY_SIZE(gpu_cc_sa8775p_clocks),
  564. .resets = gpu_cc_sa8775p_resets,
  565. .num_resets = ARRAY_SIZE(gpu_cc_sa8775p_resets),
  566. .gdscs = gpu_cc_sa8775p_gdscs,
  567. .num_gdscs = ARRAY_SIZE(gpu_cc_sa8775p_gdscs),
  568. };
  569. static const struct of_device_id gpu_cc_sa8775p_match_table[] = {
  570. { .compatible = "qcom,qcs8300-gpucc" },
  571. { .compatible = "qcom,sa8775p-gpucc" },
  572. { }
  573. };
  574. MODULE_DEVICE_TABLE(of, gpu_cc_sa8775p_match_table);
  575. static int gpu_cc_sa8775p_probe(struct platform_device *pdev)
  576. {
  577. struct regmap *regmap;
  578. regmap = qcom_cc_map(pdev, &gpu_cc_sa8775p_desc);
  579. if (IS_ERR(regmap))
  580. return PTR_ERR(regmap);
  581. if (of_device_is_compatible(pdev->dev.of_node, "qcom,qcs8300-gpucc")) {
  582. gpu_cc_pll0_config.l = 0x31;
  583. gpu_cc_pll0_config.alpha = 0xe555;
  584. gpu_cc_sa8775p_clocks[GPU_CC_CX_ACCU_SHIFT_CLK] = &gpu_cc_cx_accu_shift_clk.clkr;
  585. gpu_cc_sa8775p_clocks[GPU_CC_GX_ACCU_SHIFT_CLK] = &gpu_cc_gx_accu_shift_clk.clkr;
  586. }
  587. clk_lucid_evo_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  588. clk_lucid_evo_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
  589. return qcom_cc_really_probe(&pdev->dev, &gpu_cc_sa8775p_desc, regmap);
  590. }
  591. static struct platform_driver gpu_cc_sa8775p_driver = {
  592. .probe = gpu_cc_sa8775p_probe,
  593. .driver = {
  594. .name = "gpu_cc-sa8775p",
  595. .of_match_table = gpu_cc_sa8775p_match_table,
  596. },
  597. };
  598. module_platform_driver(gpu_cc_sa8775p_driver);
  599. MODULE_DESCRIPTION("SA8775P GPUCC driver");
  600. MODULE_LICENSE("GPL");