gpucc-niobe.c 16 KB

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