gpucc-volcano.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2023-2024, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/clk-provider.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-volcano.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 "clk-regmap-divider.h"
  20. #include "clk-regmap-mux.h"
  21. #include "common.h"
  22. #include "reset.h"
  23. #include "vdd-level.h"
  24. static DEFINE_VDD_REGULATORS(vdd_cx, VDD_LOW_L1 + 1, 1, vdd_corner);
  25. static DEFINE_VDD_REGULATORS(vdd_gfx, VDD_LOWER + 1, 1, vdd_corner);
  26. static DEFINE_VDD_REGULATORS(vdd_mx, VDD_LOW_L1 + 1, 1, vdd_corner);
  27. static struct clk_vdd_class *gpu_cc_volcano_regulators[] = {
  28. &vdd_cx,
  29. &vdd_gfx,
  30. &vdd_mx,
  31. };
  32. static struct clk_vdd_class *gpu_cc_volcano_regulators_cx_mx[] = {
  33. &vdd_cx,
  34. &vdd_mx,
  35. };
  36. enum {
  37. P_BI_TCXO,
  38. P_GPLL0_OUT_MAIN,
  39. P_GPLL0_OUT_MAIN_DIV,
  40. P_GPU_CC_PLL0_OUT_EVEN,
  41. P_GPU_CC_PLL0_OUT_MAIN,
  42. P_GPU_CC_PLL0_OUT_ODD,
  43. };
  44. static const struct pll_vco lucid_ole_vco[] = {
  45. { 249600000, 2300000000, 0 },
  46. };
  47. /* 700.0 MHz Configuration */
  48. static const struct alpha_pll_config gpu_cc_pll0_config = {
  49. .l = 0x24,
  50. .cal_l = 0x44,
  51. .cal_l_ringosc = 0x44,
  52. .alpha = 0x7555,
  53. .config_ctl_val = 0x20485699,
  54. .config_ctl_hi_val = 0x00182261,
  55. .config_ctl_hi1_val = 0x82aa299c,
  56. .test_ctl_val = 0x00000000,
  57. .test_ctl_hi_val = 0x00000003,
  58. .test_ctl_hi1_val = 0x00009000,
  59. .test_ctl_hi2_val = 0x00000034,
  60. .user_ctl_val = 0x00000400,
  61. .user_ctl_hi_val = 0x00000005,
  62. };
  63. static struct clk_alpha_pll gpu_cc_pll0 = {
  64. .offset = 0x0,
  65. .vco_table = lucid_ole_vco,
  66. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  67. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  68. .clkr = {
  69. .hw.init = &(const struct clk_init_data) {
  70. .name = "gpu_cc_pll0",
  71. .parent_data = &(const struct clk_parent_data) {
  72. .fw_name = "bi_tcxo",
  73. },
  74. .num_parents = 1,
  75. .ops = &clk_alpha_pll_lucid_ole_ops,
  76. },
  77. .vdd_data = {
  78. .vdd_class = &vdd_mx,
  79. .num_rate_max = VDD_NUM,
  80. .rate_max = (unsigned long[VDD_NUM]) {
  81. [VDD_LOWER_D1] = 615000000,
  82. [VDD_LOW] = 1100000000,
  83. [VDD_LOW_L1] = 1600000000,
  84. [VDD_NOMINAL] = 2000000000,
  85. [VDD_HIGH_L1] = 2300000000},
  86. },
  87. },
  88. };
  89. static const struct clk_div_table post_div_table_gpu_cc_pll0_out_even[] = {
  90. { 0x1, 2 },
  91. { }
  92. };
  93. static struct clk_alpha_pll_postdiv gpu_cc_pll0_out_even = {
  94. .offset = 0x0,
  95. .post_div_shift = 10,
  96. .post_div_table = post_div_table_gpu_cc_pll0_out_even,
  97. .num_post_div = ARRAY_SIZE(post_div_table_gpu_cc_pll0_out_even),
  98. .width = 4,
  99. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  100. .clkr.hw.init = &(const struct clk_init_data) {
  101. .name = "gpu_cc_pll0_out_even",
  102. .parent_hws = (const struct clk_hw*[]) {
  103. &gpu_cc_pll0.clkr.hw,
  104. },
  105. .num_parents = 1,
  106. .flags = CLK_SET_RATE_PARENT,
  107. .ops = &clk_alpha_pll_postdiv_lucid_ole_ops,
  108. },
  109. };
  110. static const struct parent_map gpu_cc_parent_map_0[] = {
  111. { P_BI_TCXO, 0 },
  112. { P_GPLL0_OUT_MAIN, 5 },
  113. { P_GPLL0_OUT_MAIN_DIV, 6 },
  114. };
  115. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  116. { .fw_name = "bi_tcxo" },
  117. { .fw_name = "gpll0_out_main" },
  118. { .fw_name = "gpll0_out_main_div" },
  119. };
  120. static const struct parent_map gpu_cc_parent_map_1[] = {
  121. { P_BI_TCXO, 0 },
  122. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  123. { P_GPU_CC_PLL0_OUT_EVEN, 2 },
  124. { P_GPU_CC_PLL0_OUT_ODD, 3 },
  125. { P_GPLL0_OUT_MAIN, 5 },
  126. { P_GPLL0_OUT_MAIN_DIV, 6 },
  127. };
  128. static const struct clk_parent_data gpu_cc_parent_data_1[] = {
  129. { .fw_name = "bi_tcxo" },
  130. { .hw = &gpu_cc_pll0.clkr.hw },
  131. { .hw = &gpu_cc_pll0_out_even.clkr.hw },
  132. { .hw = &gpu_cc_pll0.clkr.hw },
  133. { .fw_name = "gpll0_out_main" },
  134. { .fw_name = "gpll0_out_main_div" },
  135. };
  136. static const struct parent_map gpu_cc_parent_map_2[] = {
  137. { P_BI_TCXO, 0 },
  138. };
  139. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  140. { .fw_name = "bi_tcxo" },
  141. };
  142. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  143. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  144. { }
  145. };
  146. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  147. .cmd_rcgr = 0x9474,
  148. .mnd_width = 0,
  149. .hid_width = 5,
  150. .parent_map = gpu_cc_parent_map_0,
  151. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  152. .enable_safe_config = true,
  153. .flags = HW_CLK_CTRL_MODE,
  154. .clkr.hw.init = &(const struct clk_init_data) {
  155. .name = "gpu_cc_ff_clk_src",
  156. .parent_data = gpu_cc_parent_data_0,
  157. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  158. .flags = CLK_SET_RATE_PARENT,
  159. .ops = &clk_rcg2_ops,
  160. },
  161. .clkr.vdd_data = {
  162. .vdd_classes = gpu_cc_volcano_regulators,
  163. .num_vdd_classes = ARRAY_SIZE(gpu_cc_volcano_regulators),
  164. .num_rate_max = VDD_NUM,
  165. .rate_max = (unsigned long[VDD_NUM]) {
  166. [VDD_LOWER] = 200000000},
  167. },
  168. };
  169. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  170. F(19200000, P_BI_TCXO, 1, 0, 0),
  171. F(350000000, P_GPU_CC_PLL0_OUT_EVEN, 1, 0, 0),
  172. F(650000000, P_GPU_CC_PLL0_OUT_EVEN, 1, 0, 0),
  173. F(687500000, P_GPU_CC_PLL0_OUT_EVEN, 1, 0, 0),
  174. { }
  175. };
  176. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  177. .cmd_rcgr = 0x9318,
  178. .mnd_width = 0,
  179. .hid_width = 5,
  180. .parent_map = gpu_cc_parent_map_1,
  181. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  182. .enable_safe_config = true,
  183. .flags = HW_CLK_CTRL_MODE,
  184. .clkr.hw.init = &(const struct clk_init_data) {
  185. .name = "gpu_cc_gmu_clk_src",
  186. .parent_data = gpu_cc_parent_data_1,
  187. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  188. .flags = CLK_SET_RATE_PARENT,
  189. .ops = &clk_rcg2_ops,
  190. },
  191. .clkr.vdd_data = {
  192. .vdd_classes = gpu_cc_volcano_regulators_cx_mx,
  193. .num_vdd_classes = ARRAY_SIZE(gpu_cc_volcano_regulators_cx_mx),
  194. .num_rate_max = VDD_NUM,
  195. .rate_max = (unsigned long[VDD_NUM]) {
  196. [VDD_LOWER] = 350000000,
  197. [VDD_LOW] = 650000000,
  198. [VDD_LOW_L1] = 687500000},
  199. },
  200. };
  201. static const struct freq_tbl ftbl_gpu_cc_hub_clk_src[] = {
  202. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  203. F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0),
  204. F(400000000, P_GPLL0_OUT_MAIN, 1.5, 0, 0),
  205. { }
  206. };
  207. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  208. .cmd_rcgr = 0x93ec,
  209. .mnd_width = 0,
  210. .hid_width = 5,
  211. .parent_map = gpu_cc_parent_map_1,
  212. .freq_tbl = ftbl_gpu_cc_hub_clk_src,
  213. .enable_safe_config = true,
  214. .flags = HW_CLK_CTRL_MODE,
  215. .clkr.hw.init = &(const struct clk_init_data) {
  216. .name = "gpu_cc_hub_clk_src",
  217. .parent_data = gpu_cc_parent_data_1,
  218. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  219. .flags = CLK_SET_RATE_PARENT,
  220. .ops = &clk_rcg2_ops,
  221. },
  222. .clkr.vdd_data = {
  223. .vdd_class = &vdd_cx,
  224. .num_rate_max = VDD_NUM,
  225. .rate_max = (unsigned long[VDD_NUM]) {
  226. [VDD_LOWER] = 200000000,
  227. [VDD_LOW] = 300000000,
  228. [VDD_LOW_L1] = 400000000},
  229. },
  230. };
  231. static struct clk_regmap_div gpu_cc_hub_div_clk_src = {
  232. .reg = 0x942c,
  233. .shift = 0,
  234. .width = 4,
  235. .clkr.hw.init = &(const struct clk_init_data) {
  236. .name = "gpu_cc_hub_div_clk_src",
  237. .parent_hws = (const struct clk_hw*[]) {
  238. &gpu_cc_hub_clk_src.clkr.hw,
  239. },
  240. .num_parents = 1,
  241. .flags = CLK_SET_RATE_PARENT,
  242. .ops = &clk_regmap_div_ro_ops,
  243. },
  244. };
  245. static struct clk_branch gpu_cc_ahb_clk = {
  246. .halt_reg = 0x90bc,
  247. .halt_check = BRANCH_HALT_DELAY,
  248. .clkr = {
  249. .enable_reg = 0x90bc,
  250. .enable_mask = BIT(0),
  251. .hw.init = &(const struct clk_init_data) {
  252. .name = "gpu_cc_ahb_clk",
  253. .parent_hws = (const struct clk_hw*[]) {
  254. &gpu_cc_hub_div_clk_src.clkr.hw,
  255. },
  256. .num_parents = 1,
  257. .flags = CLK_SET_RATE_PARENT,
  258. .ops = &clk_branch2_ops,
  259. },
  260. },
  261. };
  262. static struct clk_branch gpu_cc_cx_accu_shift_clk = {
  263. .halt_reg = 0x910c,
  264. .halt_check = BRANCH_HALT_VOTED,
  265. .clkr = {
  266. .enable_reg = 0x910c,
  267. .enable_mask = BIT(0),
  268. .hw.init = &(const struct clk_init_data) {
  269. .name = "gpu_cc_cx_accu_shift_clk",
  270. .ops = &clk_branch2_ops,
  271. },
  272. },
  273. };
  274. static struct clk_branch gpu_cc_cx_ff_clk = {
  275. .halt_reg = 0x90ec,
  276. .halt_check = BRANCH_HALT,
  277. .clkr = {
  278. .enable_reg = 0x90ec,
  279. .enable_mask = BIT(0),
  280. .hw.init = &(const struct clk_init_data) {
  281. .name = "gpu_cc_cx_ff_clk",
  282. .parent_hws = (const struct clk_hw*[]) {
  283. &gpu_cc_ff_clk_src.clkr.hw,
  284. },
  285. .num_parents = 1,
  286. .flags = CLK_SET_RATE_PARENT,
  287. .ops = &clk_branch2_ops,
  288. },
  289. },
  290. };
  291. static struct clk_branch gpu_cc_cx_gmu_clk = {
  292. .halt_reg = 0x90d4,
  293. .halt_check = BRANCH_HALT_VOTED,
  294. .clkr = {
  295. .enable_reg = 0x90d4,
  296. .enable_mask = BIT(0),
  297. .hw.init = &(const struct clk_init_data) {
  298. .name = "gpu_cc_cx_gmu_clk",
  299. .parent_hws = (const struct clk_hw*[]) {
  300. &gpu_cc_gmu_clk_src.clkr.hw,
  301. },
  302. .num_parents = 1,
  303. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  304. .ops = &clk_branch2_aon_ops,
  305. },
  306. },
  307. };
  308. static struct clk_branch gpu_cc_cxo_clk = {
  309. .halt_reg = 0x90e4,
  310. .halt_check = BRANCH_HALT,
  311. .clkr = {
  312. .enable_reg = 0x90e4,
  313. .enable_mask = BIT(0),
  314. .hw.init = &(const struct clk_init_data) {
  315. .name = "gpu_cc_cxo_clk",
  316. .flags = CLK_DONT_HOLD_STATE,
  317. .ops = &clk_branch2_ops,
  318. },
  319. },
  320. };
  321. static struct clk_branch gpu_cc_dpm_clk = {
  322. .halt_reg = 0x9110,
  323. .halt_check = BRANCH_HALT,
  324. .clkr = {
  325. .enable_reg = 0x9110,
  326. .enable_mask = BIT(0),
  327. .hw.init = &(const struct clk_init_data) {
  328. .name = "gpu_cc_dpm_clk",
  329. .ops = &clk_branch2_ops,
  330. },
  331. },
  332. };
  333. static struct clk_branch gpu_cc_freq_measure_clk = {
  334. .halt_reg = 0x900c,
  335. .halt_check = BRANCH_HALT,
  336. .clkr = {
  337. .enable_reg = 0x900c,
  338. .enable_mask = BIT(0),
  339. .hw.init = &(const 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_accu_shift_clk = {
  346. .halt_reg = 0x9070,
  347. .halt_check = BRANCH_HALT_VOTED,
  348. .clkr = {
  349. .enable_reg = 0x9070,
  350. .enable_mask = BIT(0),
  351. .hw.init = &(const struct clk_init_data) {
  352. .name = "gpu_cc_gx_accu_shift_clk",
  353. .ops = &clk_branch2_ops,
  354. },
  355. },
  356. };
  357. static struct clk_branch gpu_cc_gx_acd_ahb_ff_clk = {
  358. .halt_reg = 0x9068,
  359. .halt_check = BRANCH_HALT,
  360. .clkr = {
  361. .enable_reg = 0x9068,
  362. .enable_mask = BIT(0),
  363. .hw.init = &(const struct clk_init_data) {
  364. .name = "gpu_cc_gx_acd_ahb_ff_clk",
  365. .parent_hws = (const struct clk_hw*[]) {
  366. &gpu_cc_ff_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_gmu_clk = {
  375. .halt_reg = 0x9060,
  376. .halt_check = BRANCH_HALT,
  377. .clkr = {
  378. .enable_reg = 0x9060,
  379. .enable_mask = BIT(0),
  380. .hw.init = &(const struct clk_init_data) {
  381. .name = "gpu_cc_gx_gmu_clk",
  382. .parent_hws = (const struct clk_hw*[]) {
  383. &gpu_cc_gmu_clk_src.clkr.hw,
  384. },
  385. .num_parents = 1,
  386. .flags = CLK_SET_RATE_PARENT,
  387. .ops = &clk_branch2_ops,
  388. },
  389. },
  390. };
  391. static struct clk_branch gpu_cc_gx_rcg_ahb_ff_clk = {
  392. .halt_reg = 0x906c,
  393. .halt_check = BRANCH_HALT_VOTED,
  394. .clkr = {
  395. .enable_reg = 0x906c,
  396. .enable_mask = BIT(0),
  397. .hw.init = &(const struct clk_init_data) {
  398. .name = "gpu_cc_gx_rcg_ahb_ff_clk",
  399. .parent_hws = (const struct clk_hw*[]) {
  400. &gpu_cc_ff_clk_src.clkr.hw,
  401. },
  402. .num_parents = 1,
  403. .flags = CLK_SET_RATE_PARENT,
  404. .ops = &clk_branch2_ops,
  405. },
  406. },
  407. };
  408. static struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
  409. .halt_reg = 0x7000,
  410. .halt_check = BRANCH_HALT_VOTED,
  411. .clkr = {
  412. .enable_reg = 0x7000,
  413. .enable_mask = BIT(0),
  414. .hw.init = &(const struct clk_init_data) {
  415. .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
  416. .ops = &clk_branch2_ops,
  417. },
  418. },
  419. };
  420. static struct clk_branch gpu_cc_hub_aon_clk = {
  421. .halt_reg = 0x93e8,
  422. .halt_check = BRANCH_HALT_VOTED,
  423. .clkr = {
  424. .enable_reg = 0x93e8,
  425. .enable_mask = BIT(0),
  426. .hw.init = &(const struct clk_init_data) {
  427. .name = "gpu_cc_hub_aon_clk",
  428. .parent_hws = (const struct clk_hw*[]) {
  429. &gpu_cc_hub_clk_src.clkr.hw,
  430. },
  431. .num_parents = 1,
  432. .flags = CLK_SET_RATE_PARENT,
  433. .ops = &clk_branch2_aon_ops,
  434. },
  435. },
  436. };
  437. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  438. .halt_reg = 0x90e8,
  439. .halt_check = BRANCH_HALT_VOTED,
  440. .clkr = {
  441. .enable_reg = 0x90e8,
  442. .enable_mask = BIT(0),
  443. .hw.init = &(const struct clk_init_data) {
  444. .name = "gpu_cc_hub_cx_int_clk",
  445. .parent_hws = (const struct clk_hw*[]) {
  446. &gpu_cc_hub_clk_src.clkr.hw,
  447. },
  448. .num_parents = 1,
  449. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  450. .ops = &clk_branch2_aon_ops,
  451. },
  452. },
  453. };
  454. static struct clk_branch gpu_cc_memnoc_gfx_clk = {
  455. .halt_reg = 0x90f4,
  456. .halt_check = BRANCH_HALT_VOTED,
  457. .clkr = {
  458. .enable_reg = 0x90f4,
  459. .enable_mask = BIT(0),
  460. .hw.init = &(const struct clk_init_data) {
  461. .name = "gpu_cc_memnoc_gfx_clk",
  462. .ops = &clk_branch2_ops,
  463. },
  464. },
  465. };
  466. static struct clk_regmap *gpu_cc_volcano_clocks[] = {
  467. [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
  468. [GPU_CC_CX_ACCU_SHIFT_CLK] = &gpu_cc_cx_accu_shift_clk.clkr,
  469. [GPU_CC_CX_FF_CLK] = &gpu_cc_cx_ff_clk.clkr,
  470. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  471. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  472. [GPU_CC_DPM_CLK] = &gpu_cc_dpm_clk.clkr,
  473. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  474. [GPU_CC_FREQ_MEASURE_CLK] = &gpu_cc_freq_measure_clk.clkr,
  475. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  476. [GPU_CC_GX_ACCU_SHIFT_CLK] = &gpu_cc_gx_accu_shift_clk.clkr,
  477. [GPU_CC_GX_ACD_AHB_FF_CLK] = &gpu_cc_gx_acd_ahb_ff_clk.clkr,
  478. [GPU_CC_GX_GMU_CLK] = &gpu_cc_gx_gmu_clk.clkr,
  479. [GPU_CC_GX_RCG_AHB_FF_CLK] = &gpu_cc_gx_rcg_ahb_ff_clk.clkr,
  480. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  481. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  482. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  483. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  484. [GPU_CC_HUB_DIV_CLK_SRC] = &gpu_cc_hub_div_clk_src.clkr,
  485. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  486. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  487. [GPU_CC_PLL0_OUT_EVEN] = &gpu_cc_pll0_out_even.clkr,
  488. };
  489. static const struct qcom_reset_map gpu_cc_volcano_resets[] = {
  490. [GPU_CC_CB_BCR] = { 0x93a0 },
  491. [GPU_CC_CX_BCR] = { 0x907c },
  492. [GPU_CC_FAST_HUB_BCR] = { 0x93e4 },
  493. [GPU_CC_FF_BCR] = { 0x9470 },
  494. [GPU_CC_GMU_BCR] = { 0x9314 },
  495. [GPU_CC_GX_BCR] = { 0x905c },
  496. [GPU_CC_RBCPR_BCR] = { 0x91e0 },
  497. [GPU_CC_XO_BCR] = { 0x9000 },
  498. };
  499. static const struct regmap_config gpu_cc_volcano_regmap_config = {
  500. .reg_bits = 32,
  501. .reg_stride = 4,
  502. .val_bits = 32,
  503. .max_register = 0x95e8,
  504. .fast_io = true,
  505. };
  506. static const struct qcom_cc_desc gpu_cc_volcano_desc = {
  507. .config = &gpu_cc_volcano_regmap_config,
  508. .clks = gpu_cc_volcano_clocks,
  509. .num_clks = ARRAY_SIZE(gpu_cc_volcano_clocks),
  510. .resets = gpu_cc_volcano_resets,
  511. .num_resets = ARRAY_SIZE(gpu_cc_volcano_resets),
  512. .clk_regulators = gpu_cc_volcano_regulators,
  513. .num_clk_regulators = ARRAY_SIZE(gpu_cc_volcano_regulators),
  514. };
  515. static const struct of_device_id gpu_cc_volcano_match_table[] = {
  516. { .compatible = "qcom,volcano-gpucc" },
  517. { }
  518. };
  519. MODULE_DEVICE_TABLE(of, gpu_cc_volcano_match_table);
  520. static int gpu_cc_volcano_probe(struct platform_device *pdev)
  521. {
  522. struct regmap *regmap;
  523. int ret;
  524. regmap = qcom_cc_map(pdev, &gpu_cc_volcano_desc);
  525. if (IS_ERR(regmap))
  526. return PTR_ERR(regmap);
  527. clk_lucid_ole_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  528. /*
  529. * Keep clocks always enabled:
  530. * gpu_cc_cb_clk
  531. * gpu_cc_cxo_aon_clk
  532. * gpu_cc_demet_clk
  533. * gpu_cc_gx_ahb_ff_clk
  534. * gpu_cc_rscc_hub_aon_clk
  535. * gpu_cc_rscc_xo_aon_clk
  536. * gpu_cc_sleep_clk
  537. */
  538. regmap_update_bits(regmap, 0x93a4, BIT(0), BIT(0));
  539. regmap_update_bits(regmap, 0x9008, BIT(0), BIT(0));
  540. regmap_update_bits(regmap, 0x9010, BIT(0), BIT(0));
  541. regmap_update_bits(regmap, 0x9064, BIT(0), BIT(0));
  542. regmap_update_bits(regmap, 0x93a8, BIT(0), BIT(0));
  543. regmap_update_bits(regmap, 0x9004, BIT(0), BIT(0));
  544. regmap_update_bits(regmap, 0x90cc, BIT(0), BIT(0));
  545. ret = qcom_cc_really_probe(pdev, &gpu_cc_volcano_desc, regmap);
  546. if (ret) {
  547. dev_err(&pdev->dev, "Failed to register GPU CC clocks\n");
  548. return ret;
  549. }
  550. dev_info(&pdev->dev, "Registered GPU CC clocks\n");
  551. return ret;
  552. }
  553. static void gpu_cc_volcano_sync_state(struct device *dev)
  554. {
  555. qcom_cc_sync_state(dev, &gpu_cc_volcano_desc);
  556. }
  557. static struct platform_driver gpu_cc_volcano_driver = {
  558. .probe = gpu_cc_volcano_probe,
  559. .driver = {
  560. .name = "gpu_cc-volcano",
  561. .of_match_table = gpu_cc_volcano_match_table,
  562. .sync_state = gpu_cc_volcano_sync_state,
  563. },
  564. };
  565. static int __init gpu_cc_volcano_init(void)
  566. {
  567. return platform_driver_register(&gpu_cc_volcano_driver);
  568. }
  569. subsys_initcall(gpu_cc_volcano_init);
  570. static void __exit gpu_cc_volcano_exit(void)
  571. {
  572. platform_driver_unregister(&gpu_cc_volcano_driver);
  573. }
  574. module_exit(gpu_cc_volcano_exit);
  575. MODULE_DESCRIPTION("QTI GPU_CC VOLCANO Driver");
  576. MODULE_LICENSE("GPL");