gpucc-pineapple.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2022-2023, 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-pineapple.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_HIGH + 1, 1, vdd_corner);
  25. static DEFINE_VDD_REGULATORS(vdd_mx, VDD_HIGH + 1, 1, vdd_corner);
  26. static DEFINE_VDD_REGULATORS(vdd_mxc, VDD_HIGH + 1, 1, vdd_corner);
  27. static struct clk_vdd_class *gpu_cc_pineapple_regulators[] = {
  28. &vdd_cx,
  29. &vdd_mx,
  30. &vdd_mxc,
  31. };
  32. static struct clk_vdd_class *gpu_cc_pineapple_regulators_1[] = {
  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_MAIN,
  41. P_GPU_CC_PLL1_OUT_MAIN,
  42. };
  43. static const struct pll_vco lucid_ole_vco[] = {
  44. { 249600000, 2100000000, 0 },
  45. };
  46. static const struct alpha_pll_config gpu_cc_pll0_config = {
  47. .l = 0x20,
  48. .cal_l = 0x44,
  49. .cal_l_ringosc = 0x44,
  50. .alpha = 0x4AAA,
  51. .config_ctl_val = 0x20485699,
  52. .config_ctl_hi_val = 0x00182261,
  53. .config_ctl_hi1_val = 0x82AA299C,
  54. .test_ctl_val = 0x00000000,
  55. .test_ctl_hi_val = 0x00000003,
  56. .test_ctl_hi1_val = 0x00009000,
  57. .test_ctl_hi2_val = 0x00000034,
  58. .user_ctl_val = 0x00000000,
  59. .user_ctl_hi_val = 0x00000005,
  60. };
  61. static struct clk_alpha_pll gpu_cc_pll0 = {
  62. .offset = 0x0,
  63. .vco_table = lucid_ole_vco,
  64. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  65. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  66. .clkr = {
  67. .hw.init = &(const struct clk_init_data){
  68. .name = "gpu_cc_pll0",
  69. .parent_data = &(const struct clk_parent_data){
  70. .fw_name = "bi_tcxo",
  71. },
  72. .num_parents = 1,
  73. .ops = &clk_alpha_pll_lucid_ole_ops,
  74. },
  75. .vdd_data = {
  76. .vdd_class = &vdd_mxc,
  77. .num_rate_max = VDD_NUM,
  78. .rate_max = (unsigned long[VDD_NUM]) {
  79. [VDD_LOWER_D1] = 615000000,
  80. [VDD_LOW] = 1100000000,
  81. [VDD_LOW_L1] = 1600000000,
  82. [VDD_NOMINAL] = 2000000000,
  83. [VDD_HIGH_L1] = 2100000000},
  84. },
  85. },
  86. };
  87. static const struct alpha_pll_config gpu_cc_pll1_config = {
  88. .l = 0x1B,
  89. .cal_l = 0x44,
  90. .cal_l_ringosc = 0x44,
  91. .alpha = 0x1555,
  92. .config_ctl_val = 0x20485699,
  93. .config_ctl_hi_val = 0x00182261,
  94. .config_ctl_hi1_val = 0x82AA299C,
  95. .test_ctl_val = 0x00000000,
  96. .test_ctl_hi_val = 0x00000003,
  97. .test_ctl_hi1_val = 0x00009000,
  98. .test_ctl_hi2_val = 0x00000034,
  99. .user_ctl_val = 0x00000000,
  100. .user_ctl_hi_val = 0x00000005,
  101. };
  102. static struct clk_alpha_pll gpu_cc_pll1 = {
  103. .offset = 0x1000,
  104. .vco_table = lucid_ole_vco,
  105. .num_vco = ARRAY_SIZE(lucid_ole_vco),
  106. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
  107. .clkr = {
  108. .hw.init = &(const struct clk_init_data){
  109. .name = "gpu_cc_pll1",
  110. .parent_data = &(const struct clk_parent_data){
  111. .fw_name = "bi_tcxo",
  112. },
  113. .num_parents = 1,
  114. .ops = &clk_alpha_pll_lucid_ole_ops,
  115. },
  116. .vdd_data = {
  117. .vdd_class = &vdd_mx,
  118. .num_rate_max = VDD_NUM,
  119. .rate_max = (unsigned long[VDD_NUM]) {
  120. [VDD_LOWER_D1] = 615000000,
  121. [VDD_LOW] = 1100000000,
  122. [VDD_LOW_L1] = 1600000000,
  123. [VDD_NOMINAL] = 2000000000,
  124. [VDD_HIGH_L1] = 2100000000},
  125. },
  126. },
  127. };
  128. static const struct parent_map gpu_cc_parent_map_0[] = {
  129. { P_BI_TCXO, 0 },
  130. { P_GPLL0_OUT_MAIN, 5 },
  131. { P_GPLL0_OUT_MAIN_DIV, 6 },
  132. };
  133. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  134. { .fw_name = "bi_tcxo" },
  135. { .fw_name = "gpll0_out_main" },
  136. { .fw_name = "gpll0_out_main_div" },
  137. };
  138. static const struct parent_map gpu_cc_parent_map_1[] = {
  139. { P_BI_TCXO, 0 },
  140. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  141. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  142. { P_GPLL0_OUT_MAIN, 5 },
  143. { P_GPLL0_OUT_MAIN_DIV, 6 },
  144. };
  145. static const struct clk_parent_data gpu_cc_parent_data_1[] = {
  146. { .fw_name = "bi_tcxo" },
  147. { .hw = &gpu_cc_pll0.clkr.hw },
  148. { .hw = &gpu_cc_pll1.clkr.hw },
  149. { .fw_name = "gpll0_out_main" },
  150. { .fw_name = "gpll0_out_main_div" },
  151. };
  152. static const struct parent_map gpu_cc_parent_map_2[] = {
  153. { P_BI_TCXO, 0 },
  154. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  155. { P_GPLL0_OUT_MAIN, 5 },
  156. { P_GPLL0_OUT_MAIN_DIV, 6 },
  157. };
  158. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  159. { .fw_name = "bi_tcxo" },
  160. { .hw = &gpu_cc_pll1.clkr.hw },
  161. { .fw_name = "gpll0_out_main" },
  162. { .fw_name = "gpll0_out_main_div" },
  163. };
  164. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  165. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  166. { }
  167. };
  168. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  169. .cmd_rcgr = 0x9474,
  170. .mnd_width = 0,
  171. .hid_width = 5,
  172. .parent_map = gpu_cc_parent_map_0,
  173. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  174. .enable_safe_config = true,
  175. .flags = HW_CLK_CTRL_MODE,
  176. .clkr.hw.init = &(const struct clk_init_data){
  177. .name = "gpu_cc_ff_clk_src",
  178. .parent_data = gpu_cc_parent_data_0,
  179. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  180. .flags = CLK_SET_RATE_PARENT,
  181. .ops = &clk_rcg2_ops,
  182. },
  183. .clkr.vdd_data = {
  184. .vdd_class = &vdd_cx,
  185. .num_rate_max = VDD_NUM,
  186. .rate_max = (unsigned long[VDD_NUM]) {
  187. [VDD_LOWER_D1] = 200000000},
  188. },
  189. };
  190. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  191. F(19200000, P_BI_TCXO, 1, 0, 0),
  192. F(260000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  193. F(625000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  194. { }
  195. };
  196. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  197. .cmd_rcgr = 0x9318,
  198. .mnd_width = 0,
  199. .hid_width = 5,
  200. .parent_map = gpu_cc_parent_map_1,
  201. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  202. .enable_safe_config = true,
  203. .flags = HW_CLK_CTRL_MODE,
  204. .clkr.hw.init = &(const struct clk_init_data){
  205. .name = "gpu_cc_gmu_clk_src",
  206. .parent_data = gpu_cc_parent_data_1,
  207. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  208. .flags = CLK_SET_RATE_PARENT,
  209. .ops = &clk_rcg2_ops,
  210. },
  211. .clkr.vdd_data = {
  212. .vdd_classes = gpu_cc_pineapple_regulators_1,
  213. .num_vdd_classes = ARRAY_SIZE(gpu_cc_pineapple_regulators_1),
  214. .num_rate_max = VDD_NUM,
  215. .rate_max = (unsigned long[VDD_NUM]) {
  216. [VDD_LOWER_D1] = 260000000,
  217. [VDD_LOW] = 625000000},
  218. },
  219. };
  220. static const struct freq_tbl ftbl_gpu_cc_hub_clk_src[] = {
  221. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  222. F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0),
  223. { }
  224. };
  225. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  226. .cmd_rcgr = 0x93ec,
  227. .mnd_width = 0,
  228. .hid_width = 5,
  229. .parent_map = gpu_cc_parent_map_2,
  230. .freq_tbl = ftbl_gpu_cc_hub_clk_src,
  231. .enable_safe_config = true,
  232. .flags = HW_CLK_CTRL_MODE,
  233. .clkr.hw.init = &(const struct clk_init_data){
  234. .name = "gpu_cc_hub_clk_src",
  235. .parent_data = gpu_cc_parent_data_2,
  236. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_2),
  237. .flags = CLK_SET_RATE_PARENT,
  238. .ops = &clk_rcg2_ops,
  239. },
  240. .clkr.vdd_data = {
  241. .vdd_class = &vdd_cx,
  242. .num_rate_max = VDD_NUM,
  243. .rate_max = (unsigned long[VDD_NUM]) {
  244. [VDD_LOWER_D1] = 200000000,
  245. [VDD_LOW] = 300000000,
  246. [VDD_LOW_L1] = 312500000},
  247. },
  248. };
  249. static struct clk_regmap_div gpu_cc_hub_div_clk_src = {
  250. .reg = 0x942c,
  251. .shift = 0,
  252. .width = 4,
  253. .clkr.hw.init = &(const struct clk_init_data) {
  254. .name = "gpu_cc_hub_div_clk_src",
  255. .parent_hws = (const struct clk_hw*[]){
  256. &gpu_cc_hub_clk_src.clkr.hw,
  257. },
  258. .num_parents = 1,
  259. .flags = CLK_SET_RATE_PARENT,
  260. .ops = &clk_regmap_div_ro_ops,
  261. },
  262. };
  263. static struct clk_branch gpu_cc_ahb_clk = {
  264. .halt_reg = 0x911c,
  265. .halt_check = BRANCH_HALT_DELAY,
  266. .clkr = {
  267. .enable_reg = 0x911c,
  268. .enable_mask = BIT(0),
  269. .hw.init = &(const struct clk_init_data){
  270. .name = "gpu_cc_ahb_clk",
  271. .parent_hws = (const struct clk_hw*[]){
  272. &gpu_cc_hub_div_clk_src.clkr.hw,
  273. },
  274. .num_parents = 1,
  275. .flags = CLK_SET_RATE_PARENT,
  276. .ops = &clk_branch2_ops,
  277. },
  278. },
  279. };
  280. static struct clk_branch gpu_cc_crc_ahb_clk = {
  281. .halt_reg = 0x9120,
  282. .halt_check = BRANCH_HALT_VOTED,
  283. .clkr = {
  284. .enable_reg = 0x9120,
  285. .enable_mask = BIT(0),
  286. .hw.init = &(const struct clk_init_data){
  287. .name = "gpu_cc_crc_ahb_clk",
  288. .parent_hws = (const struct clk_hw*[]){
  289. &gpu_cc_hub_div_clk_src.clkr.hw,
  290. },
  291. .num_parents = 1,
  292. .flags = CLK_SET_RATE_PARENT,
  293. .ops = &clk_branch2_ops,
  294. },
  295. },
  296. };
  297. static struct clk_branch gpu_cc_cx_accu_shift_clk = {
  298. .halt_reg = 0x9160,
  299. .halt_check = BRANCH_HALT_VOTED,
  300. .clkr = {
  301. .enable_reg = 0x9160,
  302. .enable_mask = BIT(0),
  303. .hw.init = &(const struct clk_init_data){
  304. .name = "gpu_cc_cx_accu_shift_clk",
  305. .ops = &clk_branch2_ops,
  306. },
  307. },
  308. };
  309. static struct clk_branch gpu_cc_cx_ff_clk = {
  310. .halt_reg = 0x914c,
  311. .halt_check = BRANCH_HALT,
  312. .clkr = {
  313. .enable_reg = 0x914c,
  314. .enable_mask = BIT(0),
  315. .hw.init = &(const struct clk_init_data){
  316. .name = "gpu_cc_cx_ff_clk",
  317. .parent_hws = (const struct clk_hw*[]){
  318. &gpu_cc_ff_clk_src.clkr.hw,
  319. },
  320. .num_parents = 1,
  321. .flags = CLK_SET_RATE_PARENT,
  322. .ops = &clk_branch2_ops,
  323. },
  324. },
  325. };
  326. static struct clk_branch gpu_cc_cx_gmu_clk = {
  327. .halt_reg = 0x913c,
  328. .halt_check = BRANCH_HALT_VOTED,
  329. .clkr = {
  330. .enable_reg = 0x913c,
  331. .enable_mask = BIT(0),
  332. .hw.init = &(const struct clk_init_data){
  333. .name = "gpu_cc_cx_gmu_clk",
  334. .parent_hws = (const struct clk_hw*[]){
  335. &gpu_cc_gmu_clk_src.clkr.hw,
  336. },
  337. .num_parents = 1,
  338. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  339. .ops = &clk_branch2_aon_ops,
  340. },
  341. },
  342. };
  343. static struct clk_branch gpu_cc_cxo_clk = {
  344. .halt_reg = 0x9144,
  345. .halt_check = BRANCH_HALT,
  346. .clkr = {
  347. .enable_reg = 0x9144,
  348. .enable_mask = BIT(0),
  349. .hw.init = &(const struct clk_init_data){
  350. .name = "gpu_cc_cxo_clk",
  351. .flags = CLK_DONT_HOLD_STATE,
  352. .ops = &clk_branch2_ops,
  353. },
  354. },
  355. };
  356. static struct clk_branch gpu_cc_dpm_clk = {
  357. .halt_reg = 0x9164,
  358. .halt_check = BRANCH_HALT,
  359. .clkr = {
  360. .enable_reg = 0x9164,
  361. .enable_mask = BIT(0),
  362. .hw.init = &(const struct clk_init_data){
  363. .name = "gpu_cc_dpm_clk",
  364. .ops = &clk_branch2_ops,
  365. },
  366. },
  367. };
  368. static struct clk_branch gpu_cc_freq_measure_clk = {
  369. .halt_reg = 0x9008,
  370. .halt_check = BRANCH_HALT,
  371. .clkr = {
  372. .enable_reg = 0x9008,
  373. .enable_mask = BIT(0),
  374. .hw.init = &(const struct clk_init_data){
  375. .name = "gpu_cc_freq_measure_clk",
  376. .ops = &clk_branch2_ops,
  377. },
  378. },
  379. };
  380. static struct clk_branch gpu_cc_gx_accu_shift_clk = {
  381. .halt_reg = 0x90d0,
  382. .halt_check = BRANCH_HALT_VOTED,
  383. .clkr = {
  384. .enable_reg = 0x90d0,
  385. .enable_mask = BIT(0),
  386. .hw.init = &(const struct clk_init_data){
  387. .name = "gpu_cc_gx_accu_shift_clk",
  388. .ops = &clk_branch2_ops,
  389. },
  390. },
  391. };
  392. static struct clk_branch gpu_cc_gx_ff_clk = {
  393. .halt_reg = 0x90c0,
  394. .halt_check = BRANCH_HALT,
  395. .clkr = {
  396. .enable_reg = 0x90c0,
  397. .enable_mask = BIT(0),
  398. .hw.init = &(const struct clk_init_data){
  399. .name = "gpu_cc_gx_ff_clk",
  400. .parent_hws = (const struct clk_hw*[]){
  401. &gpu_cc_ff_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_gx_gfx3d_clk = {
  410. .halt_reg = 0x90a8,
  411. .halt_check = BRANCH_HALT,
  412. .clkr = {
  413. .enable_reg = 0x90a8,
  414. .enable_mask = BIT(0),
  415. .hw.init = &(const struct clk_init_data){
  416. .name = "gpu_cc_gx_gfx3d_clk",
  417. .ops = &clk_branch2_ops,
  418. .flags = CLK_DONT_HOLD_STATE,
  419. },
  420. },
  421. };
  422. static struct clk_branch gpu_cc_gx_gfx3d_rdvm_clk = {
  423. .halt_reg = 0x90c8,
  424. .halt_check = BRANCH_HALT,
  425. .clkr = {
  426. .enable_reg = 0x90c8,
  427. .enable_mask = BIT(0),
  428. .hw.init = &(const struct clk_init_data){
  429. .name = "gpu_cc_gx_gfx3d_rdvm_clk",
  430. .ops = &clk_branch2_ops,
  431. },
  432. },
  433. };
  434. static struct clk_branch gpu_cc_gx_gmu_clk = {
  435. .halt_reg = 0x90bc,
  436. .halt_check = BRANCH_HALT,
  437. .clkr = {
  438. .enable_reg = 0x90bc,
  439. .enable_mask = BIT(0),
  440. .hw.init = &(const struct clk_init_data){
  441. .name = "gpu_cc_gx_gmu_clk",
  442. .parent_hws = (const struct clk_hw*[]){
  443. &gpu_cc_gmu_clk_src.clkr.hw,
  444. },
  445. .num_parents = 1,
  446. .flags = CLK_SET_RATE_PARENT,
  447. .ops = &clk_branch2_ops,
  448. },
  449. },
  450. };
  451. static struct clk_branch gpu_cc_gx_vsense_clk = {
  452. .halt_reg = 0x90b0,
  453. .halt_check = BRANCH_HALT_VOTED,
  454. .clkr = {
  455. .enable_reg = 0x90b0,
  456. .enable_mask = BIT(0),
  457. .hw.init = &(const struct clk_init_data){
  458. .name = "gpu_cc_gx_vsense_clk",
  459. .ops = &clk_branch2_ops,
  460. },
  461. },
  462. };
  463. static struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
  464. .halt_reg = 0x7000,
  465. .halt_check = BRANCH_HALT_VOTED,
  466. .clkr = {
  467. .enable_reg = 0x7000,
  468. .enable_mask = BIT(0),
  469. .hw.init = &(const struct clk_init_data){
  470. .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
  471. .ops = &clk_branch2_ops,
  472. },
  473. },
  474. };
  475. static struct clk_branch gpu_cc_hub_aon_clk = {
  476. .halt_reg = 0x93e8,
  477. .halt_check = BRANCH_HALT_VOTED,
  478. .clkr = {
  479. .enable_reg = 0x93e8,
  480. .enable_mask = BIT(0),
  481. .hw.init = &(const struct clk_init_data){
  482. .name = "gpu_cc_hub_aon_clk",
  483. .parent_hws = (const struct clk_hw*[]){
  484. &gpu_cc_hub_clk_src.clkr.hw,
  485. },
  486. .num_parents = 1,
  487. .flags = CLK_SET_RATE_PARENT,
  488. .ops = &clk_branch2_aon_ops,
  489. },
  490. },
  491. };
  492. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  493. .halt_reg = 0x9148,
  494. .halt_check = BRANCH_HALT_VOTED,
  495. .clkr = {
  496. .enable_reg = 0x9148,
  497. .enable_mask = BIT(0),
  498. .hw.init = &(const struct clk_init_data){
  499. .name = "gpu_cc_hub_cx_int_clk",
  500. .parent_hws = (const struct clk_hw*[]){
  501. &gpu_cc_hub_clk_src.clkr.hw,
  502. },
  503. .num_parents = 1,
  504. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  505. .ops = &clk_branch2_aon_ops,
  506. },
  507. },
  508. };
  509. static struct clk_branch gpu_cc_memnoc_gfx_clk = {
  510. .halt_reg = 0x9150,
  511. .halt_check = BRANCH_HALT_VOTED,
  512. .clkr = {
  513. .enable_reg = 0x9150,
  514. .enable_mask = BIT(0),
  515. .hw.init = &(const struct clk_init_data){
  516. .name = "gpu_cc_memnoc_gfx_clk",
  517. .ops = &clk_branch2_ops,
  518. },
  519. },
  520. };
  521. static struct clk_branch gpu_cc_sleep_clk = {
  522. .halt_reg = 0x9134,
  523. .halt_check = BRANCH_HALT_VOTED,
  524. .clkr = {
  525. .enable_reg = 0x9134,
  526. .enable_mask = BIT(0),
  527. .hw.init = &(const struct clk_init_data){
  528. .name = "gpu_cc_sleep_clk",
  529. .ops = &clk_branch2_ops,
  530. },
  531. },
  532. };
  533. static struct clk_regmap *gpu_cc_pineapple_clocks[] = {
  534. [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
  535. [GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr,
  536. [GPU_CC_CX_ACCU_SHIFT_CLK] = &gpu_cc_cx_accu_shift_clk.clkr,
  537. [GPU_CC_CX_FF_CLK] = &gpu_cc_cx_ff_clk.clkr,
  538. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  539. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  540. [GPU_CC_DPM_CLK] = &gpu_cc_dpm_clk.clkr,
  541. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  542. [GPU_CC_FREQ_MEASURE_CLK] = &gpu_cc_freq_measure_clk.clkr,
  543. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  544. [GPU_CC_GX_ACCU_SHIFT_CLK] = &gpu_cc_gx_accu_shift_clk.clkr,
  545. [GPU_CC_GX_FF_CLK] = &gpu_cc_gx_ff_clk.clkr,
  546. [GPU_CC_GX_GFX3D_CLK] = &gpu_cc_gx_gfx3d_clk.clkr,
  547. [GPU_CC_GX_GFX3D_RDVM_CLK] = &gpu_cc_gx_gfx3d_rdvm_clk.clkr,
  548. [GPU_CC_GX_GMU_CLK] = &gpu_cc_gx_gmu_clk.clkr,
  549. [GPU_CC_GX_VSENSE_CLK] = &gpu_cc_gx_vsense_clk.clkr,
  550. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  551. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  552. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  553. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  554. [GPU_CC_HUB_DIV_CLK_SRC] = &gpu_cc_hub_div_clk_src.clkr,
  555. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  556. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  557. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  558. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  559. };
  560. static const struct qcom_reset_map gpu_cc_pineapple_resets[] = {
  561. [GPUCC_GPU_CC_ACD_BCR] = { 0x9358 },
  562. [GPUCC_GPU_CC_CX_BCR] = { 0x9104 },
  563. [GPUCC_GPU_CC_FAST_HUB_BCR] = { 0x93e4 },
  564. [GPUCC_GPU_CC_FF_BCR] = { 0x9470 },
  565. [GPUCC_GPU_CC_GFX3D_AON_BCR] = { 0x9198 },
  566. [GPUCC_GPU_CC_GMU_BCR] = { 0x9314 },
  567. [GPUCC_GPU_CC_GX_BCR] = { 0x9058 },
  568. [GPUCC_GPU_CC_XO_BCR] = { 0x9000 },
  569. [GPUCC_GPU_CC_FREQUENCY_LIMITER_IRQ_CLEAR] = { 0x9538, 0 },
  570. };
  571. static const struct regmap_config gpu_cc_pineapple_regmap_config = {
  572. .reg_bits = 32,
  573. .reg_stride = 4,
  574. .val_bits = 32,
  575. .max_register = 0x95e8,
  576. .fast_io = true,
  577. };
  578. static const struct qcom_cc_desc gpu_cc_pineapple_desc = {
  579. .config = &gpu_cc_pineapple_regmap_config,
  580. .clks = gpu_cc_pineapple_clocks,
  581. .num_clks = ARRAY_SIZE(gpu_cc_pineapple_clocks),
  582. .resets = gpu_cc_pineapple_resets,
  583. .num_resets = ARRAY_SIZE(gpu_cc_pineapple_resets),
  584. .clk_regulators = gpu_cc_pineapple_regulators,
  585. .num_clk_regulators = ARRAY_SIZE(gpu_cc_pineapple_regulators),
  586. };
  587. static const struct of_device_id gpu_cc_pineapple_match_table[] = {
  588. { .compatible = "qcom,pineapple-gpucc" },
  589. { }
  590. };
  591. MODULE_DEVICE_TABLE(of, gpu_cc_pineapple_match_table);
  592. static int gpu_cc_pineapple_probe(struct platform_device *pdev)
  593. {
  594. struct regmap *regmap;
  595. int ret;
  596. regmap = qcom_cc_map(pdev, &gpu_cc_pineapple_desc);
  597. if (IS_ERR(regmap))
  598. return PTR_ERR(regmap);
  599. clk_lucid_ole_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  600. clk_lucid_ole_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
  601. /*
  602. * Keep clocks always enabled:
  603. * gpu_cc_cxo_aon_clk
  604. * gpu_cc_demet_clk
  605. */
  606. regmap_update_bits(regmap, 0x9004, BIT(0), BIT(0));
  607. regmap_update_bits(regmap, 0x900c, BIT(0), BIT(0));
  608. /* Enable frequency limiter irq */
  609. regmap_write(regmap, 0x9534, 0x0);
  610. ret = qcom_cc_really_probe(pdev, &gpu_cc_pineapple_desc, regmap);
  611. if (ret) {
  612. dev_err(&pdev->dev, "Failed to register GPU CC clocks\n");
  613. return ret;
  614. }
  615. dev_info(&pdev->dev, "Registered GPU CC clocks\n");
  616. return ret;
  617. }
  618. static void gpu_cc_pineapple_sync_state(struct device *dev)
  619. {
  620. qcom_cc_sync_state(dev, &gpu_cc_pineapple_desc);
  621. }
  622. static struct platform_driver gpu_cc_pineapple_driver = {
  623. .probe = gpu_cc_pineapple_probe,
  624. .driver = {
  625. .name = "gpu_cc-pineapple",
  626. .of_match_table = gpu_cc_pineapple_match_table,
  627. .sync_state = gpu_cc_pineapple_sync_state,
  628. },
  629. };
  630. static int __init gpu_cc_pineapple_init(void)
  631. {
  632. return platform_driver_register(&gpu_cc_pineapple_driver);
  633. }
  634. subsys_initcall(gpu_cc_pineapple_init);
  635. static void __exit gpu_cc_pineapple_exit(void)
  636. {
  637. platform_driver_unregister(&gpu_cc_pineapple_driver);
  638. }
  639. module_exit(gpu_cc_pineapple_exit);
  640. MODULE_DESCRIPTION("QTI GPU_CC PINEAPPLE Driver");
  641. MODULE_LICENSE("GPL");