gpucc-cliffs.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/of_device.h>
  9. #include <linux/of.h>
  10. #include <linux/regmap.h>
  11. #include <dt-bindings/clock/qcom,gpucc-cliffs.h>
  12. #include "clk-alpha-pll.h"
  13. #include "clk-branch.h"
  14. #include "clk-rcg.h"
  15. #include "clk-regmap-divider.h"
  16. #include "common.h"
  17. #include "reset.h"
  18. #include "vdd-level.h"
  19. static DEFINE_VDD_REGULATORS(vdd_cx, VDD_LOW + 1, 1, vdd_corner);
  20. static DEFINE_VDD_REGULATORS(vdd_mx, VDD_LOW + 1, 1, vdd_corner);
  21. static DEFINE_VDD_REGULATORS(vdd_mxc, VDD_NOMINAL + 1, 1, vdd_corner);
  22. static struct clk_vdd_class *gpu_cc_cliffs_regulators[] = {
  23. &vdd_cx,
  24. &vdd_mx,
  25. &vdd_mxc,
  26. };
  27. static struct clk_vdd_class *gpu_cc_cliffs_regulators_1[] = {
  28. &vdd_cx,
  29. &vdd_mx,
  30. };
  31. enum {
  32. P_BI_TCXO,
  33. P_GPLL0_OUT_MAIN,
  34. P_GPLL0_OUT_MAIN_DIV,
  35. P_GPU_CC_PLL0_OUT_MAIN,
  36. P_GPU_CC_PLL1_OUT_MAIN,
  37. };
  38. static const struct pll_vco lucid_ole_vco[] = {
  39. { 249600000, 2300000000, 0 },
  40. };
  41. /* 510MHz Configuration */
  42. static const struct alpha_pll_config gpu_cc_pll0_config = {
  43. .l = 0x1a,
  44. .cal_l = 0x44,
  45. .cal_l_ringosc = 0x44,
  46. .alpha = 0x9000,
  47. .config_ctl_val = 0x20485699,
  48. .config_ctl_hi_val = 0x00182261,
  49. .config_ctl_hi1_val = 0x82aa299c,
  50. .test_ctl_val = 0x00000000,
  51. .test_ctl_hi_val = 0x00000003,
  52. .test_ctl_hi1_val = 0x00009000,
  53. .test_ctl_hi2_val = 0x00000034,
  54. .user_ctl_val = 0x00000000,
  55. .user_ctl_hi_val = 0x00000005,
  56. };
  57. static struct clk_alpha_pll gpu_cc_pll0 = {
  58. .offset = 0x0,
  59. .vco_table = lucid_ole_vco,
  60. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  61. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  62. .clkr = {
  63. .hw.init = &(const struct clk_init_data) {
  64. .name = "gpu_cc_pll0",
  65. .parent_data = &(const struct clk_parent_data) {
  66. .fw_name = "bi_tcxo",
  67. },
  68. .num_parents = 1,
  69. .ops = &clk_alpha_pll_lucid_ole_ops,
  70. },
  71. .vdd_data = {
  72. .vdd_class = &vdd_mxc,
  73. .num_rate_max = VDD_NUM,
  74. .rate_max = (unsigned long[VDD_NUM]) {
  75. [VDD_LOWER_D1] = 615000000,
  76. [VDD_LOW] = 1100000000,
  77. [VDD_LOW_L1] = 1600000000,
  78. [VDD_NOMINAL] = 2000000000,
  79. [VDD_HIGH_L1] = 2300000000},
  80. },
  81. },
  82. };
  83. /* 440MHz Configuration */
  84. static const struct alpha_pll_config gpu_cc_pll1_config = {
  85. .l = 0x16,
  86. .cal_l = 0x44,
  87. .cal_l_ringosc = 0x44,
  88. .alpha = 0xeaaa,
  89. .config_ctl_val = 0x20485699,
  90. .config_ctl_hi_val = 0x00182261,
  91. .config_ctl_hi1_val = 0x82aa299c,
  92. .test_ctl_val = 0x00000000,
  93. .test_ctl_hi_val = 0x00000003,
  94. .test_ctl_hi1_val = 0x00009000,
  95. .test_ctl_hi2_val = 0x00000034,
  96. .user_ctl_val = 0x00000000,
  97. .user_ctl_hi_val = 0x00000005,
  98. };
  99. static struct clk_alpha_pll gpu_cc_pll1 = {
  100. .offset = 0x1000,
  101. .vco_table = lucid_ole_vco,
  102. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  103. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  104. .clkr = {
  105. .hw.init = &(const struct clk_init_data) {
  106. .name = "gpu_cc_pll1",
  107. .parent_data = &(const struct clk_parent_data) {
  108. .fw_name = "bi_tcxo",
  109. },
  110. .num_parents = 1,
  111. .ops = &clk_alpha_pll_lucid_ole_ops,
  112. },
  113. .vdd_data = {
  114. .vdd_class = &vdd_mx,
  115. .num_rate_max = VDD_NUM,
  116. .rate_max = (unsigned long[VDD_NUM]) {
  117. [VDD_LOWER_D1] = 615000000,
  118. [VDD_LOW] = 1100000000,
  119. [VDD_LOW_L1] = 1600000000,
  120. [VDD_NOMINAL] = 2000000000,
  121. [VDD_HIGH_L1] = 2300000000},
  122. },
  123. },
  124. };
  125. static const struct parent_map gpu_cc_parent_map_0[] = {
  126. { P_BI_TCXO, 0 },
  127. { P_GPLL0_OUT_MAIN, 5 },
  128. { P_GPLL0_OUT_MAIN_DIV, 6 },
  129. };
  130. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  131. { .fw_name = "bi_tcxo" },
  132. { .fw_name = "gpll0_out_main" },
  133. { .fw_name = "gpll0_out_main_div" },
  134. };
  135. static const struct parent_map gpu_cc_parent_map_1[] = {
  136. { P_BI_TCXO, 0 },
  137. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  138. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  139. { P_GPLL0_OUT_MAIN, 5 },
  140. { P_GPLL0_OUT_MAIN_DIV, 6 },
  141. };
  142. static const struct clk_parent_data gpu_cc_parent_data_1[] = {
  143. { .fw_name = "bi_tcxo" },
  144. { .hw = &gpu_cc_pll0.clkr.hw },
  145. { .hw = &gpu_cc_pll1.clkr.hw },
  146. { .fw_name = "gpll0_out_main" },
  147. { .fw_name = "gpll0_out_main_div" },
  148. };
  149. static const struct parent_map gpu_cc_parent_map_2[] = {
  150. { P_BI_TCXO, 0 },
  151. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  152. { P_GPLL0_OUT_MAIN, 5 },
  153. { P_GPLL0_OUT_MAIN_DIV, 6 },
  154. };
  155. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  156. { .fw_name = "bi_tcxo" },
  157. { .hw = &gpu_cc_pll1.clkr.hw },
  158. { .fw_name = "gpll0_out_main" },
  159. { .fw_name = "gpll0_out_main_div" },
  160. };
  161. static const struct parent_map gpu_cc_parent_map_3[] = {
  162. { P_BI_TCXO, 0 },
  163. };
  164. static const struct clk_parent_data gpu_cc_parent_data_3_ao[] = {
  165. { .fw_name = "bi_tcxo_ao" },
  166. };
  167. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  168. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  169. { }
  170. };
  171. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  172. .cmd_rcgr = 0x91b8,
  173. .mnd_width = 0,
  174. .hid_width = 5,
  175. .parent_map = gpu_cc_parent_map_0,
  176. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  177. .enable_safe_config = true,
  178. .flags = HW_CLK_CTRL_MODE,
  179. .clkr.hw.init = &(const struct clk_init_data) {
  180. .name = "gpu_cc_ff_clk_src",
  181. .parent_data = gpu_cc_parent_data_0,
  182. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  183. .ops = &clk_rcg2_ops,
  184. },
  185. .clkr.vdd_data = {
  186. .vdd_class = &vdd_cx,
  187. .num_rate_max = VDD_NUM,
  188. .rate_max = (unsigned long[VDD_NUM]) {
  189. [VDD_LOWER_D1] = 200000000},
  190. },
  191. };
  192. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  193. F(19200000, P_BI_TCXO, 1, 0, 0),
  194. F(220000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  195. F(550000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  196. { }
  197. };
  198. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  199. .cmd_rcgr = 0x9168,
  200. .mnd_width = 0,
  201. .hid_width = 5,
  202. .parent_map = gpu_cc_parent_map_1,
  203. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  204. .enable_safe_config = true,
  205. .flags = HW_CLK_CTRL_MODE,
  206. .clkr.hw.init = &(const struct clk_init_data) {
  207. .name = "gpu_cc_gmu_clk_src",
  208. .parent_data = gpu_cc_parent_data_1,
  209. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  210. .flags = CLK_SET_RATE_PARENT,
  211. .ops = &clk_rcg2_ops,
  212. },
  213. .clkr.vdd_data = {
  214. .vdd_classes = gpu_cc_cliffs_regulators_1,
  215. .num_vdd_classes = ARRAY_SIZE(gpu_cc_cliffs_regulators_1),
  216. .num_rate_max = VDD_NUM,
  217. .rate_max = (unsigned long[VDD_NUM]) {
  218. [VDD_LOWER_D1] = 220000000,
  219. [VDD_LOW] = 550000000},
  220. },
  221. };
  222. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  223. .cmd_rcgr = 0x919c,
  224. .mnd_width = 0,
  225. .hid_width = 5,
  226. .parent_map = gpu_cc_parent_map_2,
  227. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  228. .enable_safe_config = true,
  229. .flags = HW_CLK_CTRL_MODE,
  230. .clkr.hw.init = &(const struct clk_init_data) {
  231. .name = "gpu_cc_hub_clk_src",
  232. .parent_data = gpu_cc_parent_data_2,
  233. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_2),
  234. .ops = &clk_rcg2_ops,
  235. },
  236. .clkr.vdd_data = {
  237. .vdd_class = &vdd_cx,
  238. .num_rate_max = VDD_NUM,
  239. .rate_max = (unsigned long[VDD_NUM]) {
  240. [VDD_LOWER_D1] = 200000000},
  241. },
  242. };
  243. static const struct freq_tbl ftbl_gpu_cc_xo_clk_src[] = {
  244. F(19200000, P_BI_TCXO, 1, 0, 0),
  245. { }
  246. };
  247. static struct clk_rcg2 gpu_cc_xo_clk_src = {
  248. .cmd_rcgr = 0x9010,
  249. .mnd_width = 0,
  250. .hid_width = 5,
  251. .parent_map = gpu_cc_parent_map_3,
  252. .freq_tbl = ftbl_gpu_cc_xo_clk_src,
  253. .enable_safe_config = true,
  254. .flags = HW_CLK_CTRL_MODE,
  255. .clkr.hw.init = &(const struct clk_init_data) {
  256. .name = "gpu_cc_xo_clk_src",
  257. .parent_data = gpu_cc_parent_data_3_ao,
  258. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_3_ao),
  259. .ops = &clk_rcg2_ops,
  260. },
  261. };
  262. static struct clk_regmap_div gpu_cc_demet_div_clk_src = {
  263. .reg = 0x902c,
  264. .shift = 0,
  265. .width = 4,
  266. .clkr.hw.init = &(const struct clk_init_data) {
  267. .name = "gpu_cc_demet_div_clk_src",
  268. .parent_hws = (const struct clk_hw*[]) {
  269. &gpu_cc_xo_clk_src.clkr.hw,
  270. },
  271. .num_parents = 1,
  272. .flags = CLK_SET_RATE_PARENT,
  273. .ops = &clk_regmap_div_ro_ops,
  274. },
  275. };
  276. static struct clk_regmap_div gpu_cc_xo_div_clk_src = {
  277. .reg = 0x9028,
  278. .shift = 0,
  279. .width = 4,
  280. .clkr.hw.init = &(const struct clk_init_data) {
  281. .name = "gpu_cc_xo_div_clk_src",
  282. .parent_hws = (const struct clk_hw*[]) {
  283. &gpu_cc_xo_clk_src.clkr.hw,
  284. },
  285. .num_parents = 1,
  286. .flags = CLK_SET_RATE_PARENT,
  287. .ops = &clk_regmap_div_ro_ops,
  288. },
  289. };
  290. static struct clk_branch gpu_cc_ahb_clk = {
  291. .halt_reg = 0x90c8,
  292. .halt_check = BRANCH_HALT_DELAY,
  293. .clkr = {
  294. .enable_reg = 0x90c8,
  295. .enable_mask = BIT(0),
  296. .hw.init = &(const struct clk_init_data) {
  297. .name = "gpu_cc_ahb_clk",
  298. .parent_hws = (const struct clk_hw*[]) {
  299. &gpu_cc_hub_clk_src.clkr.hw,
  300. },
  301. .num_parents = 1,
  302. .flags = CLK_SET_RATE_PARENT,
  303. .ops = &clk_branch2_ops,
  304. },
  305. },
  306. };
  307. static struct clk_branch gpu_cc_crc_ahb_clk = {
  308. .halt_reg = 0x90cc,
  309. .halt_check = BRANCH_HALT_VOTED,
  310. .clkr = {
  311. .enable_reg = 0x90cc,
  312. .enable_mask = BIT(0),
  313. .hw.init = &(const struct clk_init_data) {
  314. .name = "gpu_cc_crc_ahb_clk",
  315. .parent_hws = (const struct clk_hw*[]) {
  316. &gpu_cc_hub_clk_src.clkr.hw,
  317. },
  318. .num_parents = 1,
  319. .flags = CLK_SET_RATE_PARENT,
  320. .ops = &clk_branch2_ops,
  321. },
  322. },
  323. };
  324. static struct clk_branch gpu_cc_cx_accu_shift_clk = {
  325. .halt_reg = 0x9108,
  326. .halt_check = BRANCH_HALT_VOTED,
  327. .clkr = {
  328. .enable_reg = 0x9108,
  329. .enable_mask = BIT(0),
  330. .hw.init = &(const struct clk_init_data) {
  331. .name = "gpu_cc_cx_accu_shift_clk",
  332. .parent_hws = (const struct clk_hw*[]) {
  333. &gpu_cc_xo_clk_src.clkr.hw,
  334. },
  335. .num_parents = 1,
  336. .flags = CLK_SET_RATE_PARENT,
  337. .ops = &clk_branch2_ops,
  338. },
  339. },
  340. };
  341. static struct clk_branch gpu_cc_cx_ff_clk = {
  342. .halt_reg = 0x90f8,
  343. .halt_check = BRANCH_HALT,
  344. .clkr = {
  345. .enable_reg = 0x90f8,
  346. .enable_mask = BIT(0),
  347. .hw.init = &(const struct clk_init_data) {
  348. .name = "gpu_cc_cx_ff_clk",
  349. .parent_hws = (const struct clk_hw*[]) {
  350. &gpu_cc_ff_clk_src.clkr.hw,
  351. },
  352. .num_parents = 1,
  353. .flags = CLK_SET_RATE_PARENT,
  354. .ops = &clk_branch2_ops,
  355. },
  356. },
  357. };
  358. static struct clk_branch gpu_cc_cx_gmu_clk = {
  359. .halt_reg = 0x90e4,
  360. .halt_check = BRANCH_HALT_VOTED,
  361. .clkr = {
  362. .enable_reg = 0x90e4,
  363. .enable_mask = BIT(0),
  364. .hw.init = &(const struct clk_init_data) {
  365. .name = "gpu_cc_cx_gmu_clk",
  366. .parent_hws = (const struct clk_hw*[]) {
  367. &gpu_cc_gmu_clk_src.clkr.hw,
  368. },
  369. .num_parents = 1,
  370. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  371. .ops = &clk_branch2_aon_ops,
  372. },
  373. },
  374. };
  375. static struct clk_branch gpu_cc_cxo_clk = {
  376. .halt_reg = 0x90f0,
  377. .halt_check = BRANCH_HALT,
  378. .clkr = {
  379. .enable_reg = 0x90f0,
  380. .enable_mask = BIT(0),
  381. .hw.init = &(const struct clk_init_data) {
  382. .name = "gpu_cc_cxo_clk",
  383. .parent_hws = (const struct clk_hw*[]) {
  384. &gpu_cc_xo_clk_src.clkr.hw,
  385. },
  386. .num_parents = 1,
  387. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  388. .ops = &clk_branch2_ops,
  389. },
  390. },
  391. };
  392. static struct clk_branch gpu_cc_freq_measure_clk = {
  393. .halt_reg = 0x9008,
  394. .halt_check = BRANCH_HALT,
  395. .clkr = {
  396. .enable_reg = 0x9008,
  397. .enable_mask = BIT(0),
  398. .hw.init = &(const struct clk_init_data) {
  399. .name = "gpu_cc_freq_measure_clk",
  400. .parent_hws = (const struct clk_hw*[]) {
  401. &gpu_cc_xo_div_clk_src.clkr.hw,
  402. },
  403. .num_parents = 1,
  404. .flags = CLK_SET_RATE_PARENT,
  405. .ops = &clk_branch2_ops,
  406. },
  407. },
  408. };
  409. static struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
  410. .halt_reg = 0x7000,
  411. .halt_check = BRANCH_HALT_VOTED,
  412. .clkr = {
  413. .enable_reg = 0x7000,
  414. .enable_mask = BIT(0),
  415. .hw.init = &(const struct clk_init_data) {
  416. .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
  417. .ops = &clk_branch2_ops,
  418. },
  419. },
  420. };
  421. static struct clk_branch gpu_cc_hub_aon_clk = {
  422. .halt_reg = 0x9198,
  423. .halt_check = BRANCH_HALT,
  424. .clkr = {
  425. .enable_reg = 0x9198,
  426. .enable_mask = BIT(0),
  427. .hw.init = &(const struct clk_init_data) {
  428. .name = "gpu_cc_hub_aon_clk",
  429. .parent_hws = (const struct clk_hw*[]) {
  430. &gpu_cc_hub_clk_src.clkr.hw,
  431. },
  432. .num_parents = 1,
  433. .flags = CLK_SET_RATE_PARENT,
  434. .ops = &clk_branch2_aon_ops,
  435. },
  436. },
  437. };
  438. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  439. .halt_reg = 0x90f4,
  440. .halt_check = BRANCH_HALT_VOTED,
  441. .clkr = {
  442. .enable_reg = 0x90f4,
  443. .enable_mask = BIT(0),
  444. .hw.init = &(const struct clk_init_data) {
  445. .name = "gpu_cc_hub_cx_int_clk",
  446. .parent_hws = (const struct clk_hw*[]) {
  447. &gpu_cc_hub_clk_src.clkr.hw,
  448. },
  449. .num_parents = 1,
  450. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  451. .ops = &clk_branch2_aon_ops,
  452. },
  453. },
  454. };
  455. static struct clk_branch gpu_cc_memnoc_gfx_clk = {
  456. .halt_reg = 0x90fc,
  457. .halt_check = BRANCH_HALT_VOTED,
  458. .clkr = {
  459. .enable_reg = 0x90fc,
  460. .enable_mask = BIT(0),
  461. .hw.init = &(const struct clk_init_data) {
  462. .name = "gpu_cc_memnoc_gfx_clk",
  463. .ops = &clk_branch2_ops,
  464. },
  465. },
  466. };
  467. static struct clk_branch gpu_cc_mnd1x_0_gfx3d_clk = {
  468. .halt_reg = 0x9158,
  469. .halt_check = BRANCH_HALT,
  470. .clkr = {
  471. .enable_reg = 0x9158,
  472. .enable_mask = BIT(0),
  473. .hw.init = &(const struct clk_init_data) {
  474. .name = "gpu_cc_mnd1x_0_gfx3d_clk",
  475. .ops = &clk_branch2_ops,
  476. },
  477. },
  478. };
  479. static struct clk_branch gpu_cc_mnd1x_1_gfx3d_clk = {
  480. .halt_reg = 0x915c,
  481. .halt_check = BRANCH_HALT,
  482. .clkr = {
  483. .enable_reg = 0x915c,
  484. .enable_mask = BIT(0),
  485. .hw.init = &(const struct clk_init_data) {
  486. .name = "gpu_cc_mnd1x_1_gfx3d_clk",
  487. .ops = &clk_branch2_ops,
  488. },
  489. },
  490. };
  491. static struct clk_branch gpu_cc_sleep_clk = {
  492. .halt_reg = 0x90dc,
  493. .halt_check = BRANCH_HALT_VOTED,
  494. .clkr = {
  495. .enable_reg = 0x90dc,
  496. .enable_mask = BIT(0),
  497. .hw.init = &(const struct clk_init_data) {
  498. .name = "gpu_cc_sleep_clk",
  499. .ops = &clk_branch2_ops,
  500. },
  501. },
  502. };
  503. static struct clk_regmap *gpu_cc_cliffs_clocks[] = {
  504. [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
  505. [GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr,
  506. [GPU_CC_CX_ACCU_SHIFT_CLK] = &gpu_cc_cx_accu_shift_clk.clkr,
  507. [GPU_CC_CX_FF_CLK] = &gpu_cc_cx_ff_clk.clkr,
  508. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  509. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  510. [GPU_CC_DEMET_DIV_CLK_SRC] = &gpu_cc_demet_div_clk_src.clkr,
  511. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  512. [GPU_CC_FREQ_MEASURE_CLK] = &gpu_cc_freq_measure_clk.clkr,
  513. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  514. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  515. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  516. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  517. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  518. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  519. [GPU_CC_MND1X_0_GFX3D_CLK] = &gpu_cc_mnd1x_0_gfx3d_clk.clkr,
  520. [GPU_CC_MND1X_1_GFX3D_CLK] = &gpu_cc_mnd1x_1_gfx3d_clk.clkr,
  521. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  522. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  523. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  524. [GPU_CC_XO_CLK_SRC] = &gpu_cc_xo_clk_src.clkr,
  525. [GPU_CC_XO_DIV_CLK_SRC] = &gpu_cc_xo_div_clk_src.clkr,
  526. };
  527. static const struct qcom_reset_map gpu_cc_cliffs_resets[] = {
  528. [GPUCC_GPU_CC_ACD_BCR] = { 0x9180 },
  529. [GPUCC_GPU_CC_CB_BCR] = { 0x918c },
  530. [GPUCC_GPU_CC_CX_BCR] = { 0x9088 },
  531. [GPUCC_GPU_CC_FAST_HUB_BCR] = { 0x9194 },
  532. [GPUCC_GPU_CC_FF_BCR] = { 0x91b4 },
  533. [GPUCC_GPU_CC_GFX3D_AON_BCR] = { 0x910c },
  534. [GPUCC_GPU_CC_GMU_BCR] = { 0x9164 },
  535. [GPUCC_GPU_CC_GX_BCR] = { 0x9030 },
  536. [GPUCC_GPU_CC_RBCPR_BCR] = { 0x9118 },
  537. [GPUCC_GPU_CC_XO_BCR] = { 0x9000 },
  538. [GPUCC_GPU_CC_FREQUENCY_LIMITER_IRQ_CLEAR] = { 0x9538, 0 },
  539. };
  540. static const struct regmap_config gpu_cc_cliffs_regmap_config = {
  541. .reg_bits = 32,
  542. .reg_stride = 4,
  543. .val_bits = 32,
  544. .max_register = 0x9988,
  545. .fast_io = true,
  546. };
  547. static const struct qcom_cc_desc gpu_cc_cliffs_desc = {
  548. .config = &gpu_cc_cliffs_regmap_config,
  549. .clks = gpu_cc_cliffs_clocks,
  550. .num_clks = ARRAY_SIZE(gpu_cc_cliffs_clocks),
  551. .resets = gpu_cc_cliffs_resets,
  552. .num_resets = ARRAY_SIZE(gpu_cc_cliffs_resets),
  553. .clk_regulators = gpu_cc_cliffs_regulators,
  554. .num_clk_regulators = ARRAY_SIZE(gpu_cc_cliffs_regulators),
  555. };
  556. static const struct of_device_id gpu_cc_cliffs_match_table[] = {
  557. { .compatible = "qcom,cliffs-gpucc" },
  558. { }
  559. };
  560. MODULE_DEVICE_TABLE(of, gpu_cc_cliffs_match_table);
  561. static int gpu_cc_cliffs_probe(struct platform_device *pdev)
  562. {
  563. struct regmap *regmap;
  564. int ret;
  565. regmap = qcom_cc_map(pdev, &gpu_cc_cliffs_desc);
  566. if (IS_ERR(regmap))
  567. return PTR_ERR(regmap);
  568. clk_lucid_ole_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  569. clk_lucid_ole_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
  570. /*
  571. * Keep clocks always enabled:
  572. * gpu_cc_cxo_aon_clk
  573. * gpu_cc_demet_clk
  574. */
  575. regmap_update_bits(regmap, 0x9004, BIT(0), BIT(0));
  576. regmap_update_bits(regmap, 0x900c, BIT(0), BIT(0));
  577. /* Enable frequency limiter irq */
  578. regmap_write(regmap, 0x9534, 0x0);
  579. ret = qcom_cc_really_probe(pdev, &gpu_cc_cliffs_desc, regmap);
  580. if (ret) {
  581. dev_err(&pdev->dev, "Failed to register GPU CC clocks\n");
  582. return ret;
  583. }
  584. dev_info(&pdev->dev, "Registered GPU CC clocks\n");
  585. return ret;
  586. }
  587. static void gpu_cc_cliffs_sync_state(struct device *dev)
  588. {
  589. qcom_cc_sync_state(dev, &gpu_cc_cliffs_desc);
  590. }
  591. static struct platform_driver gpu_cc_cliffs_driver = {
  592. .probe = gpu_cc_cliffs_probe,
  593. .driver = {
  594. .name = "gpu_cc-cliffs",
  595. .of_match_table = gpu_cc_cliffs_match_table,
  596. .sync_state = gpu_cc_cliffs_sync_state,
  597. },
  598. };
  599. static int __init gpu_cc_cliffs_init(void)
  600. {
  601. return platform_driver_register(&gpu_cc_cliffs_driver);
  602. }
  603. subsys_initcall(gpu_cc_cliffs_init);
  604. static void __exit gpu_cc_cliffs_exit(void)
  605. {
  606. platform_driver_unregister(&gpu_cc_cliffs_driver);
  607. }
  608. module_exit(gpu_cc_cliffs_exit);
  609. MODULE_DESCRIPTION("QTI GPU_CC CLIFFS Driver");
  610. MODULE_LICENSE("GPL");