gpucc-lemans.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2021, 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-lemans.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 "vdd-level-sm8150.h"
  22. static DEFINE_VDD_REGULATORS(vdd_cx, VDD_HIGH_L1 + 1, 1, vdd_corner);
  23. static DEFINE_VDD_REGULATORS(vdd_mxa, VDD_HIGH + 1, 1, vdd_corner);
  24. static struct clk_vdd_class *gpu_cc_lemans_regulators[] = {
  25. &vdd_cx,
  26. &vdd_mxa,
  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 pll_vco lucid_evo_vco[] = {
  36. { 249600000, 2020000000, 0 },
  37. };
  38. /* 810MHz configuration */
  39. static struct alpha_pll_config gpu_cc_pll0_config = {
  40. .l = 0x2A,
  41. .cal_l = 0x44,
  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. .config = &gpu_cc_pll0_config,
  55. .clkr = {
  56. .hw.init = &(const struct clk_init_data){
  57. .name = "gpu_cc_pll0",
  58. .parent_data = &(const struct clk_parent_data){
  59. .fw_name = "bi_tcxo",
  60. },
  61. .num_parents = 1,
  62. .ops = &clk_alpha_pll_lucid_evo_ops,
  63. },
  64. .vdd_data = {
  65. .vdd_class = &vdd_mxa,
  66. .num_rate_max = VDD_NUM,
  67. .rate_max = (unsigned long[VDD_NUM]) {
  68. [VDD_LOWER_D1] = 500000000,
  69. [VDD_LOWER] = 615000000,
  70. [VDD_LOW] = 1066000000,
  71. [VDD_LOW_L1] = 1500000000,
  72. [VDD_NOMINAL] = 1800000000,
  73. [VDD_HIGH] = 2020000000},
  74. },
  75. },
  76. };
  77. /* 1000MHz configuration */
  78. static struct alpha_pll_config gpu_cc_pll1_config = {
  79. .l = 0x34,
  80. .cal_l = 0x44,
  81. .alpha = 0x1555,
  82. .config_ctl_val = 0x20485699,
  83. .config_ctl_hi_val = 0x00182261,
  84. .config_ctl_hi1_val = 0x32AA299C,
  85. .user_ctl_val = 0x00000001,
  86. .user_ctl_hi_val = 0x00400805,
  87. };
  88. static struct clk_alpha_pll gpu_cc_pll1 = {
  89. .offset = 0x1000,
  90. .vco_table = lucid_evo_vco,
  91. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  92. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  93. .config = &gpu_cc_pll1_config,
  94. .clkr = {
  95. .hw.init = &(const struct clk_init_data){
  96. .name = "gpu_cc_pll1",
  97. .parent_data = &(const struct clk_parent_data){
  98. .fw_name = "bi_tcxo",
  99. },
  100. .num_parents = 1,
  101. .ops = &clk_alpha_pll_lucid_evo_ops,
  102. },
  103. .vdd_data = {
  104. .vdd_class = &vdd_mxa,
  105. .num_rate_max = VDD_NUM,
  106. .rate_max = (unsigned long[VDD_NUM]) {
  107. [VDD_LOWER_D1] = 500000000,
  108. [VDD_LOWER] = 615000000,
  109. [VDD_LOW] = 1066000000,
  110. [VDD_LOW_L1] = 1500000000,
  111. [VDD_NOMINAL] = 1800000000,
  112. [VDD_HIGH] = 2000000000},
  113. },
  114. },
  115. };
  116. static const struct parent_map gpu_cc_parent_map_0[] = {
  117. { P_BI_TCXO, 0 },
  118. { P_GPLL0_OUT_MAIN, 5 },
  119. { P_GPLL0_OUT_MAIN_DIV, 6 },
  120. };
  121. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  122. { .fw_name = "bi_tcxo" },
  123. { .fw_name = "gpll0_out_main" },
  124. { .fw_name = "gpll0_out_main_div" },
  125. };
  126. static const struct parent_map gpu_cc_parent_map_1[] = {
  127. { P_BI_TCXO, 0 },
  128. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  129. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  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_1[] = {
  134. { .fw_name = "bi_tcxo" },
  135. { .hw = &gpu_cc_pll0.clkr.hw },
  136. { .hw = &gpu_cc_pll1.clkr.hw },
  137. { .fw_name = "gpll0_out_main" },
  138. { .fw_name = "gpll0_out_main_div" },
  139. };
  140. static const struct parent_map gpu_cc_parent_map_2[] = {
  141. { P_BI_TCXO, 0 },
  142. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  143. { P_GPLL0_OUT_MAIN, 5 },
  144. { P_GPLL0_OUT_MAIN_DIV, 6 },
  145. };
  146. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  147. { .fw_name = "bi_tcxo" },
  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_3[] = {
  153. { P_BI_TCXO, 0 },
  154. };
  155. static const struct clk_parent_data gpu_cc_parent_data_3[] = {
  156. { .fw_name = "bi_tcxo" },
  157. };
  158. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  159. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  160. { }
  161. };
  162. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  163. .cmd_rcgr = 0x9474,
  164. .mnd_width = 0,
  165. .hid_width = 5,
  166. .parent_map = gpu_cc_parent_map_0,
  167. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  168. .enable_safe_config = true,
  169. .clkr.hw.init = &(const struct clk_init_data){
  170. .name = "gpu_cc_ff_clk_src",
  171. .parent_data = gpu_cc_parent_data_0,
  172. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  173. .ops = &clk_rcg2_ops,
  174. },
  175. .clkr.vdd_data = {
  176. .vdd_class = &vdd_cx,
  177. .num_rate_max = VDD_NUM,
  178. .rate_max = (unsigned long[VDD_NUM]) {
  179. [VDD_LOW_L1] = 200000000},
  180. },
  181. };
  182. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  183. F(500000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  184. { }
  185. };
  186. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  187. .cmd_rcgr = 0x9318,
  188. .mnd_width = 0,
  189. .hid_width = 5,
  190. .parent_map = gpu_cc_parent_map_1,
  191. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  192. .enable_safe_config = true,
  193. .clkr.hw.init = &(const struct clk_init_data){
  194. .name = "gpu_cc_gmu_clk_src",
  195. .parent_data = gpu_cc_parent_data_1,
  196. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  197. .flags = CLK_SET_RATE_PARENT,
  198. .ops = &clk_rcg2_ops,
  199. },
  200. .clkr.vdd_data = {
  201. .vdd_classes = gpu_cc_lemans_regulators,
  202. .num_vdd_classes = ARRAY_SIZE(gpu_cc_lemans_regulators),
  203. .num_rate_max = VDD_NUM,
  204. .rate_max = (unsigned long[VDD_NUM]) {
  205. [VDD_LOW_L1] = 500000000},
  206. },
  207. };
  208. static const struct freq_tbl ftbl_gpu_cc_hub_clk_src[] = {
  209. F(240000000, P_GPLL0_OUT_MAIN, 2.5, 0, 0),
  210. { }
  211. };
  212. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  213. .cmd_rcgr = 0x93ec,
  214. .mnd_width = 0,
  215. .hid_width = 5,
  216. .parent_map = gpu_cc_parent_map_2,
  217. .freq_tbl = ftbl_gpu_cc_hub_clk_src,
  218. .enable_safe_config = true,
  219. .clkr.hw.init = &(const struct clk_init_data){
  220. .name = "gpu_cc_hub_clk_src",
  221. .parent_data = gpu_cc_parent_data_2,
  222. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_2),
  223. .ops = &clk_rcg2_ops,
  224. },
  225. .clkr.vdd_data = {
  226. .vdd_class = &vdd_cx,
  227. .num_rate_max = VDD_NUM,
  228. .rate_max = (unsigned long[VDD_NUM]) {
  229. [VDD_LOW_L1] = 240000000},
  230. },
  231. };
  232. static const struct freq_tbl ftbl_gpu_cc_xo_clk_src[] = {
  233. F(19200000, P_BI_TCXO, 1, 0, 0),
  234. { }
  235. };
  236. static struct clk_rcg2 gpu_cc_xo_clk_src = {
  237. .cmd_rcgr = 0x9010,
  238. .mnd_width = 0,
  239. .hid_width = 5,
  240. .parent_map = gpu_cc_parent_map_3,
  241. .freq_tbl = ftbl_gpu_cc_xo_clk_src,
  242. .enable_safe_config = true,
  243. .clkr.hw.init = &(const struct clk_init_data){
  244. .name = "gpu_cc_xo_clk_src",
  245. .parent_data = gpu_cc_parent_data_3,
  246. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_3),
  247. .ops = &clk_rcg2_ops,
  248. },
  249. .clkr.vdd_data = {
  250. .vdd_class = &vdd_cx,
  251. .num_rate_max = VDD_NUM,
  252. .rate_max = (unsigned long[VDD_NUM]) {
  253. [VDD_LOW_L1] = 19200000},
  254. },
  255. };
  256. static struct clk_regmap_div gpu_cc_demet_div_clk_src = {
  257. .reg = 0x9054,
  258. .shift = 0,
  259. .width = 4,
  260. .clkr.hw.init = &(const struct clk_init_data) {
  261. .name = "gpu_cc_demet_div_clk_src",
  262. .parent_hws = (const struct clk_hw*[]){
  263. &gpu_cc_xo_clk_src.clkr.hw,
  264. },
  265. .num_parents = 1,
  266. .flags = CLK_SET_RATE_PARENT,
  267. .ops = &clk_regmap_div_ro_ops,
  268. },
  269. };
  270. static struct clk_regmap_div gpu_cc_hub_ahb_div_clk_src = {
  271. .reg = 0x9430,
  272. .shift = 0,
  273. .width = 4,
  274. .clkr.hw.init = &(const struct clk_init_data) {
  275. .name = "gpu_cc_hub_ahb_div_clk_src",
  276. .parent_hws = (const struct clk_hw*[]){
  277. &gpu_cc_hub_clk_src.clkr.hw,
  278. },
  279. .num_parents = 1,
  280. .flags = CLK_SET_RATE_PARENT,
  281. .ops = &clk_regmap_div_ro_ops,
  282. },
  283. };
  284. static struct clk_regmap_div gpu_cc_hub_cx_int_div_clk_src = {
  285. .reg = 0x942c,
  286. .shift = 0,
  287. .width = 4,
  288. .clkr.hw.init = &(const struct clk_init_data) {
  289. .name = "gpu_cc_hub_cx_int_div_clk_src",
  290. .parent_hws = (const struct clk_hw*[]){
  291. &gpu_cc_hub_clk_src.clkr.hw,
  292. },
  293. .num_parents = 1,
  294. .flags = CLK_SET_RATE_PARENT,
  295. .ops = &clk_regmap_div_ro_ops,
  296. },
  297. };
  298. static struct clk_branch gpu_cc_ahb_clk = {
  299. .halt_reg = 0x911c,
  300. .halt_check = BRANCH_HALT_DELAY,
  301. .clkr = {
  302. .enable_reg = 0x911c,
  303. .enable_mask = BIT(0),
  304. .hw.init = &(const struct clk_init_data){
  305. .name = "gpu_cc_ahb_clk",
  306. .parent_hws = (const struct clk_hw*[]){
  307. &gpu_cc_hub_ahb_div_clk_src.clkr.hw,
  308. },
  309. .num_parents = 1,
  310. .flags = CLK_SET_RATE_PARENT,
  311. .ops = &clk_branch2_ops,
  312. },
  313. },
  314. };
  315. static struct clk_branch gpu_cc_crc_ahb_clk = {
  316. .halt_reg = 0x9120,
  317. .halt_check = BRANCH_HALT_VOTED,
  318. .clkr = {
  319. .enable_reg = 0x9120,
  320. .enable_mask = BIT(0),
  321. .hw.init = &(const struct clk_init_data){
  322. .name = "gpu_cc_crc_ahb_clk",
  323. .parent_hws = (const struct clk_hw*[]){
  324. &gpu_cc_hub_ahb_div_clk_src.clkr.hw,
  325. },
  326. .num_parents = 1,
  327. .flags = CLK_SET_RATE_PARENT,
  328. .ops = &clk_branch2_ops,
  329. },
  330. },
  331. };
  332. static struct clk_branch gpu_cc_cx_accu_shift_clk = {
  333. .halt_reg = 0x95e8,
  334. .halt_check = BRANCH_HALT,
  335. .clkr = {
  336. .enable_reg = 0x95e8,
  337. .enable_mask = BIT(0),
  338. .hw.init = &(const struct clk_init_data){
  339. .name = "gpu_cc_cx_accu_shift_clk",
  340. .parent_hws = (const struct clk_hw*[]){
  341. &gpu_cc_xo_clk_src.clkr.hw,
  342. },
  343. .num_parents = 1,
  344. .flags = CLK_SET_RATE_PARENT,
  345. .ops = &clk_branch2_ops,
  346. },
  347. },
  348. };
  349. static struct clk_branch gpu_cc_cx_ff_clk = {
  350. .halt_reg = 0x914c,
  351. .halt_check = BRANCH_HALT,
  352. .clkr = {
  353. .enable_reg = 0x914c,
  354. .enable_mask = BIT(0),
  355. .hw.init = &(const struct clk_init_data){
  356. .name = "gpu_cc_cx_ff_clk",
  357. .parent_hws = (const struct clk_hw*[]){
  358. &gpu_cc_ff_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_cx_gmu_clk = {
  367. .halt_reg = 0x913c,
  368. .halt_check = BRANCH_HALT,
  369. .clkr = {
  370. .enable_reg = 0x913c,
  371. .enable_mask = BIT(0),
  372. .hw.init = &(const struct clk_init_data){
  373. .name = "gpu_cc_cx_gmu_clk",
  374. .parent_hws = (const struct clk_hw*[]){
  375. &gpu_cc_gmu_clk_src.clkr.hw,
  376. },
  377. .num_parents = 1,
  378. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  379. .ops = &clk_branch2_aon_ops,
  380. },
  381. },
  382. };
  383. static struct clk_branch gpu_cc_cx_snoc_dvm_clk = {
  384. .halt_reg = 0x9130,
  385. .halt_check = BRANCH_HALT_VOTED,
  386. .clkr = {
  387. .enable_reg = 0x9130,
  388. .enable_mask = BIT(0),
  389. .hw.init = &(const struct clk_init_data){
  390. .name = "gpu_cc_cx_snoc_dvm_clk",
  391. .ops = &clk_branch2_ops,
  392. },
  393. },
  394. };
  395. static struct clk_branch gpu_cc_cxo_aon_clk = {
  396. .halt_reg = 0x9004,
  397. .halt_check = BRANCH_HALT_VOTED,
  398. .clkr = {
  399. .enable_reg = 0x9004,
  400. .enable_mask = BIT(0),
  401. .hw.init = &(const struct clk_init_data){
  402. .name = "gpu_cc_cxo_aon_clk",
  403. .parent_hws = (const struct clk_hw*[]){
  404. &gpu_cc_xo_clk_src.clkr.hw,
  405. },
  406. .num_parents = 1,
  407. .flags = CLK_SET_RATE_PARENT,
  408. .ops = &clk_branch2_ops,
  409. },
  410. },
  411. };
  412. static struct clk_branch gpu_cc_cxo_clk = {
  413. .halt_reg = 0x9144,
  414. .halt_check = BRANCH_HALT,
  415. .clkr = {
  416. .enable_reg = 0x9144,
  417. .enable_mask = BIT(0),
  418. .hw.init = &(const struct clk_init_data){
  419. .name = "gpu_cc_cxo_clk",
  420. .parent_hws = (const struct clk_hw*[]){
  421. &gpu_cc_xo_clk_src.clkr.hw,
  422. },
  423. .num_parents = 1,
  424. .flags = CLK_DONT_HOLD_STATE | CLK_SET_RATE_PARENT,
  425. .ops = &clk_branch2_ops,
  426. },
  427. },
  428. };
  429. static struct clk_branch gpu_cc_demet_clk = {
  430. .halt_reg = 0x900c,
  431. .halt_check = BRANCH_HALT,
  432. .clkr = {
  433. .enable_reg = 0x900c,
  434. .enable_mask = BIT(0),
  435. .hw.init = &(const struct clk_init_data){
  436. .name = "gpu_cc_demet_clk",
  437. .parent_hws = (const struct clk_hw*[]){
  438. &gpu_cc_demet_div_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_gx_accu_shift_clk = {
  447. .halt_reg = 0x95e4,
  448. .halt_check = BRANCH_HALT,
  449. .clkr = {
  450. .enable_reg = 0x95e4,
  451. .enable_mask = BIT(0),
  452. .hw.init = &(const struct clk_init_data){
  453. .name = "gpu_cc_gx_accu_shift_clk",
  454. .parent_hws = (const struct clk_hw*[]){
  455. &gpu_cc_xo_clk_src.clkr.hw,
  456. },
  457. .num_parents = 1,
  458. .flags = CLK_SET_RATE_PARENT,
  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,
  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,
  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_cx_int_div_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,
  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_lemans_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] = NULL,
  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_CX_SNOC_DVM_CLK] = &gpu_cc_cx_snoc_dvm_clk.clkr,
  540. [GPU_CC_CXO_AON_CLK] = &gpu_cc_cxo_aon_clk.clkr,
  541. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  542. [GPU_CC_DEMET_CLK] = &gpu_cc_demet_clk.clkr,
  543. [GPU_CC_DEMET_DIV_CLK_SRC] = &gpu_cc_demet_div_clk_src.clkr,
  544. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  545. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  546. [GPU_CC_GX_ACCU_SHIFT_CLK] = NULL,
  547. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  548. [GPU_CC_HUB_AHB_DIV_CLK_SRC] = &gpu_cc_hub_ahb_div_clk_src.clkr,
  549. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  550. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  551. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  552. [GPU_CC_HUB_CX_INT_DIV_CLK_SRC] = &gpu_cc_hub_cx_int_div_clk_src.clkr,
  553. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  554. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  555. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  556. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  557. [GPU_CC_XO_CLK_SRC] = &gpu_cc_xo_clk_src.clkr,
  558. };
  559. static const struct regmap_config gpu_cc_lemans_regmap_config = {
  560. .reg_bits = 32,
  561. .reg_stride = 4,
  562. .val_bits = 32,
  563. .max_register = 0x9988,
  564. .fast_io = true,
  565. };
  566. static const struct qcom_cc_desc gpu_cc_lemans_desc = {
  567. .config = &gpu_cc_lemans_regmap_config,
  568. .clks = gpu_cc_lemans_clocks,
  569. .num_clks = ARRAY_SIZE(gpu_cc_lemans_clocks),
  570. .clk_regulators = gpu_cc_lemans_regulators,
  571. .num_clk_regulators = ARRAY_SIZE(gpu_cc_lemans_regulators),
  572. };
  573. static const struct of_device_id gpu_cc_lemans_match_table[] = {
  574. { .compatible = "qcom,lemans-gpucc" },
  575. { .compatible = "qcom,monaco_auto-gpucc" },
  576. { }
  577. };
  578. MODULE_DEVICE_TABLE(of, gpu_cc_lemans_match_table);
  579. static int gpu_cc_lemans_fixup(struct platform_device *pdev, struct regmap *regmap)
  580. {
  581. if (of_device_is_compatible(pdev->dev.of_node, "qcom,monaco_auto-gpucc")) {
  582. gpu_cc_pll0_config.l = 0x31;
  583. gpu_cc_pll0_config.alpha = 0xe555;
  584. gpu_cc_lemans_clocks[GPU_CC_CX_ACCU_SHIFT_CLK] = &gpu_cc_cx_accu_shift_clk.clkr;
  585. gpu_cc_lemans_clocks[GPU_CC_GX_ACCU_SHIFT_CLK] = &gpu_cc_gx_accu_shift_clk.clkr;
  586. }
  587. return 0;
  588. }
  589. static int gpu_cc_lemans_probe(struct platform_device *pdev)
  590. {
  591. struct regmap *regmap;
  592. int ret;
  593. regmap = qcom_cc_map(pdev, &gpu_cc_lemans_desc);
  594. if (IS_ERR(regmap))
  595. return PTR_ERR(regmap);
  596. ret = gpu_cc_lemans_fixup(pdev, regmap);
  597. if (ret)
  598. return ret;
  599. clk_lucid_evo_pll_configure(&gpu_cc_pll0, regmap, gpu_cc_pll0.config);
  600. clk_lucid_evo_pll_configure(&gpu_cc_pll1, regmap, gpu_cc_pll1.config);
  601. /*
  602. * Keep the clocks always-ON
  603. * GPU_CC_CB_CLK
  604. */
  605. regmap_update_bits(regmap, 0x93a4, BIT(0), BIT(0));
  606. ret = qcom_cc_really_probe(pdev, &gpu_cc_lemans_desc, regmap);
  607. if (ret) {
  608. dev_err(&pdev->dev, "Failed to register GPU CC clocks\n");
  609. return ret;
  610. }
  611. dev_info(&pdev->dev, "Registered GPU CC clocks\n");
  612. return ret;
  613. }
  614. static void gpu_cc_lemans_sync_state(struct device *dev)
  615. {
  616. qcom_cc_sync_state(dev, &gpu_cc_lemans_desc);
  617. }
  618. static struct platform_driver gpu_cc_lemans_driver = {
  619. .probe = gpu_cc_lemans_probe,
  620. .driver = {
  621. .name = "gpu_cc-lemans",
  622. .of_match_table = gpu_cc_lemans_match_table,
  623. .sync_state = gpu_cc_lemans_sync_state,
  624. },
  625. };
  626. static int __init gpu_cc_lemans_init(void)
  627. {
  628. return platform_driver_register(&gpu_cc_lemans_driver);
  629. }
  630. subsys_initcall(gpu_cc_lemans_init);
  631. static void __exit gpu_cc_lemans_exit(void)
  632. {
  633. platform_driver_unregister(&gpu_cc_lemans_driver);
  634. }
  635. module_exit(gpu_cc_lemans_exit);
  636. MODULE_DESCRIPTION("QTI GPU_CC LEMANS Driver");
  637. MODULE_LICENSE("GPL");