gpucc-anorak.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2022-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-anorak.h>
  12. #include "clk-alpha-pll.h"
  13. #include "clk-branch.h"
  14. #include "clk-rcg.h"
  15. #include "common.h"
  16. #include "clk-regmap-divider.h"
  17. #include "clk-regmap-mux.h"
  18. #include "reset.h"
  19. #include "vdd-level.h"
  20. static DEFINE_VDD_REGULATORS(vdd_cx, VDD_HIGH_L1 + 1, 1, vdd_corner);
  21. static DEFINE_VDD_REGULATORS(vdd_mxa, VDD_HIGH_L1 + 1, 1, vdd_corner);
  22. static DEFINE_VDD_REGULATORS(vdd_mxc, VDD_HIGH + 1, 1, vdd_corner);
  23. static struct clk_vdd_class *gpu_cc_anorak_regulators[] = {
  24. &vdd_cx,
  25. &vdd_mxa,
  26. &vdd_mxc,
  27. };
  28. static struct clk_vdd_class *gpu_cc_anorak_regulators_1[] = {
  29. &vdd_cx,
  30. &vdd_mxa,
  31. };
  32. enum {
  33. P_BI_TCXO,
  34. P_GPLL0_OUT_MAIN,
  35. P_GPLL0_OUT_MAIN_DIV,
  36. P_GPU_CC_PLL0_OUT_MAIN,
  37. P_GPU_CC_PLL1_OUT_MAIN,
  38. };
  39. static struct pll_vco lucid_evo_vco[] = {
  40. { 249600000, 2000000000, 0 },
  41. };
  42. /* 570MHz Configuration */
  43. static const struct alpha_pll_config gpu_cc_pll0_config = {
  44. .l = 0x1D,
  45. .cal_l = 0x44,
  46. .alpha = 0xB000,
  47. .config_ctl_val = 0x20485699,
  48. .config_ctl_hi_val = 0x00182261,
  49. .config_ctl_hi1_val = 0x32AA299C,
  50. .user_ctl_val = 0x00000001,
  51. .user_ctl_hi_val = 0x00000805,
  52. };
  53. static struct clk_alpha_pll gpu_cc_pll0 = {
  54. .offset = 0x0,
  55. .vco_table = lucid_evo_vco,
  56. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  57. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  58. .clkr = {
  59. .hw.init = &(const struct clk_init_data){
  60. .name = "gpu_cc_pll0",
  61. .parent_data = &(const struct clk_parent_data){
  62. .fw_name = "bi_tcxo",
  63. },
  64. .num_parents = 1,
  65. .ops = &clk_alpha_pll_lucid_evo_ops,
  66. },
  67. .vdd_data = {
  68. .vdd_class = &vdd_mxc,
  69. .num_rate_max = VDD_NUM,
  70. .rate_max = (unsigned long[VDD_NUM]) {
  71. [VDD_LOWER_D1] = 500000000,
  72. [VDD_LOWER] = 615000000,
  73. [VDD_LOW] = 1066000000,
  74. [VDD_LOW_L1] = 1500000000,
  75. [VDD_NOMINAL] = 1800000000,
  76. [VDD_HIGH] = 2000000000},
  77. },
  78. },
  79. };
  80. /* 440MHz Configuration */
  81. static const struct alpha_pll_config gpu_cc_pll1_config = {
  82. .l = 0x16,
  83. .cal_l = 0x44,
  84. .alpha = 0xEAAA,
  85. .config_ctl_val = 0x20485699,
  86. .config_ctl_hi_val = 0x00182261,
  87. .config_ctl_hi1_val = 0x32AA299C,
  88. .user_ctl_val = 0x00000001,
  89. .user_ctl_hi_val = 0x00000805,
  90. };
  91. static struct clk_alpha_pll gpu_cc_pll1 = {
  92. .offset = 0x1000,
  93. .vco_table = lucid_evo_vco,
  94. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  95. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  96. .clkr = {
  97. .hw.init = &(const struct clk_init_data){
  98. .name = "gpu_cc_pll1",
  99. .parent_data = &(const struct clk_parent_data){
  100. .fw_name = "bi_tcxo",
  101. },
  102. .num_parents = 1,
  103. .ops = &clk_alpha_pll_lucid_evo_ops,
  104. },
  105. .vdd_data = {
  106. .vdd_class = &vdd_mxa,
  107. .num_rate_max = VDD_NUM,
  108. .rate_max = (unsigned long[VDD_NUM]) {
  109. [VDD_LOWER_D1] = 500000000,
  110. [VDD_LOWER] = 615000000,
  111. [VDD_LOW] = 1066000000,
  112. [VDD_LOW_L1] = 1500000000,
  113. [VDD_NOMINAL] = 1800000000,
  114. [VDD_HIGH] = 2000000000},
  115. },
  116. },
  117. };
  118. static const struct parent_map gpu_cc_parent_map_0[] = {
  119. { P_BI_TCXO, 0 },
  120. { P_GPLL0_OUT_MAIN, 5 },
  121. { P_GPLL0_OUT_MAIN_DIV, 6 },
  122. };
  123. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  124. { .fw_name = "bi_tcxo" },
  125. { .fw_name = "gpll0_out_main" },
  126. { .fw_name = "gpll0_out_main_div" },
  127. };
  128. static const struct parent_map gpu_cc_parent_map_1[] = {
  129. { P_BI_TCXO, 0 },
  130. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  131. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  132. { P_GPLL0_OUT_MAIN, 5 },
  133. { P_GPLL0_OUT_MAIN_DIV, 6 },
  134. };
  135. static const struct clk_parent_data gpu_cc_parent_data_1[] = {
  136. { .fw_name = "bi_tcxo" },
  137. { .hw = &gpu_cc_pll0.clkr.hw },
  138. { .hw = &gpu_cc_pll1.clkr.hw },
  139. { .fw_name = "gpll0_out_main" },
  140. { .fw_name = "gpll0_out_main_div" },
  141. };
  142. static const struct parent_map gpu_cc_parent_map_2[] = {
  143. { P_BI_TCXO, 0 },
  144. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  145. { P_GPLL0_OUT_MAIN, 5 },
  146. { P_GPLL0_OUT_MAIN_DIV, 6 },
  147. };
  148. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  149. { .fw_name = "bi_tcxo" },
  150. { .hw = &gpu_cc_pll1.clkr.hw },
  151. { .fw_name = "gpll0_out_main" },
  152. { .fw_name = "gpll0_out_main_div" },
  153. };
  154. static const struct parent_map gpu_cc_parent_map_3[] = {
  155. { P_BI_TCXO, 0 },
  156. };
  157. static const struct clk_parent_data gpu_cc_parent_data_3[] = {
  158. { .fw_name = "bi_tcxo" },
  159. };
  160. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  161. F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
  162. { }
  163. };
  164. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  165. .cmd_rcgr = 0x9474,
  166. .mnd_width = 0,
  167. .hid_width = 5,
  168. .parent_map = gpu_cc_parent_map_0,
  169. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  170. .enable_safe_config = true,
  171. .clkr.hw.init = &(const struct clk_init_data){
  172. .name = "gpu_cc_ff_clk_src",
  173. .parent_data = gpu_cc_parent_data_0,
  174. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  175. .ops = &clk_rcg2_ops,
  176. },
  177. .clkr.vdd_data = {
  178. .vdd_class = &vdd_cx,
  179. .num_rate_max = VDD_NUM,
  180. .rate_max = (unsigned long[VDD_NUM]) {
  181. [VDD_LOWER_D1] = 200000000},
  182. },
  183. };
  184. static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
  185. F(220000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  186. F(550000000, P_GPU_CC_PLL1_OUT_MAIN, 2, 0, 0),
  187. { }
  188. };
  189. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  190. .cmd_rcgr = 0x9318,
  191. .mnd_width = 0,
  192. .hid_width = 5,
  193. .parent_map = gpu_cc_parent_map_1,
  194. .freq_tbl = ftbl_gpu_cc_gmu_clk_src,
  195. .enable_safe_config = true,
  196. .clkr.hw.init = &(const struct clk_init_data){
  197. .name = "gpu_cc_gmu_clk_src",
  198. .parent_data = gpu_cc_parent_data_1,
  199. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  200. .flags = CLK_SET_RATE_PARENT,
  201. .ops = &clk_rcg2_ops,
  202. },
  203. .clkr.vdd_data = {
  204. .vdd_classes = gpu_cc_anorak_regulators_1,
  205. .num_vdd_classes = ARRAY_SIZE(gpu_cc_anorak_regulators_1),
  206. .num_rate_max = VDD_NUM,
  207. .rate_max = (unsigned long[VDD_NUM]) {
  208. [VDD_LOWER_D1] = 220000000,
  209. [VDD_LOW] = 550000000},
  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_ff_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_LOWER_D1] = 200000000},
  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_LOWER_D1] = 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_xo_div_clk_src = {
  271. .reg = 0x9050,
  272. .shift = 0,
  273. .width = 4,
  274. .clkr.hw.init = &(const struct clk_init_data) {
  275. .name = "gpu_cc_xo_div_clk_src",
  276. .parent_hws = (const struct clk_hw*[]){
  277. &gpu_cc_xo_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_branch gpu_cc_ahb_clk = {
  285. .halt_reg = 0x911c,
  286. .halt_check = BRANCH_HALT_DELAY,
  287. .clkr = {
  288. .enable_reg = 0x911c,
  289. .enable_mask = BIT(0),
  290. .hw.init = &(const struct clk_init_data){
  291. .name = "gpu_cc_ahb_clk",
  292. .parent_hws = (const struct clk_hw*[]){
  293. &gpu_cc_hub_clk_src.clkr.hw,
  294. },
  295. .num_parents = 1,
  296. .flags = CLK_SET_RATE_PARENT,
  297. .ops = &clk_branch2_ops,
  298. },
  299. },
  300. };
  301. static struct clk_branch gpu_cc_crc_ahb_clk = {
  302. .halt_reg = 0x9120,
  303. .halt_check = BRANCH_HALT_VOTED,
  304. .clkr = {
  305. .enable_reg = 0x9120,
  306. .enable_mask = BIT(0),
  307. .hw.init = &(const struct clk_init_data){
  308. .name = "gpu_cc_crc_ahb_clk",
  309. .parent_hws = (const struct clk_hw*[]){
  310. &gpu_cc_hub_clk_src.clkr.hw,
  311. },
  312. .num_parents = 1,
  313. .flags = CLK_SET_RATE_PARENT,
  314. .ops = &clk_branch2_ops,
  315. },
  316. },
  317. };
  318. static struct clk_branch gpu_cc_cx_ff_clk = {
  319. .halt_reg = 0x914c,
  320. .halt_check = BRANCH_HALT,
  321. .clkr = {
  322. .enable_reg = 0x914c,
  323. .enable_mask = BIT(0),
  324. .hw.init = &(const struct clk_init_data){
  325. .name = "gpu_cc_cx_ff_clk",
  326. .parent_hws = (const struct clk_hw*[]){
  327. &gpu_cc_ff_clk_src.clkr.hw,
  328. },
  329. .num_parents = 1,
  330. .flags = CLK_SET_RATE_PARENT,
  331. .ops = &clk_branch2_ops,
  332. },
  333. },
  334. };
  335. static struct clk_branch gpu_cc_cx_gmu_clk = {
  336. .halt_reg = 0x913c,
  337. .halt_check = BRANCH_HALT_VOTED,
  338. .clkr = {
  339. .enable_reg = 0x913c,
  340. .enable_mask = BIT(0),
  341. .hw.init = &(const struct clk_init_data){
  342. .name = "gpu_cc_cx_gmu_clk",
  343. .parent_hws = (const struct clk_hw*[]){
  344. &gpu_cc_gmu_clk_src.clkr.hw,
  345. },
  346. .num_parents = 1,
  347. .flags = CLK_SET_RATE_PARENT | CLK_DONT_HOLD_STATE,
  348. .ops = &clk_branch2_ops,
  349. },
  350. },
  351. };
  352. static struct clk_branch gpu_cc_cxo_aon_clk = {
  353. .halt_reg = 0x9004,
  354. .halt_check = BRANCH_HALT_VOTED,
  355. .clkr = {
  356. .enable_reg = 0x9004,
  357. .enable_mask = BIT(0),
  358. .hw.init = &(const struct clk_init_data){
  359. .name = "gpu_cc_cxo_aon_clk",
  360. .parent_hws = (const struct clk_hw*[]){
  361. &gpu_cc_xo_clk_src.clkr.hw,
  362. },
  363. .num_parents = 1,
  364. .flags = CLK_SET_RATE_PARENT,
  365. .ops = &clk_branch2_ops,
  366. },
  367. },
  368. };
  369. static struct clk_branch gpu_cc_cxo_clk = {
  370. .halt_reg = 0x9144,
  371. .halt_check = BRANCH_HALT,
  372. .clkr = {
  373. .enable_reg = 0x9144,
  374. .enable_mask = BIT(0),
  375. .hw.init = &(const struct clk_init_data){
  376. .name = "gpu_cc_cxo_clk",
  377. .parent_hws = (const struct clk_hw*[]){
  378. &gpu_cc_xo_clk_src.clkr.hw,
  379. },
  380. .num_parents = 1,
  381. .flags = CLK_SET_RATE_PARENT | CLK_DONT_HOLD_STATE,
  382. .ops = &clk_branch2_ops,
  383. },
  384. },
  385. };
  386. static struct clk_branch gpu_cc_demet_clk = {
  387. .halt_reg = 0x900c,
  388. .halt_check = BRANCH_HALT,
  389. .clkr = {
  390. .enable_reg = 0x900c,
  391. .enable_mask = BIT(0),
  392. .hw.init = &(const struct clk_init_data){
  393. .name = "gpu_cc_demet_clk",
  394. .parent_hws = (const struct clk_hw*[]){
  395. &gpu_cc_demet_div_clk_src.clkr.hw,
  396. },
  397. .num_parents = 1,
  398. .flags = CLK_SET_RATE_PARENT,
  399. .ops = &clk_branch2_aon_ops,
  400. },
  401. },
  402. };
  403. static struct clk_branch gpu_cc_freq_measure_clk = {
  404. .halt_reg = 0x9008,
  405. .halt_check = BRANCH_HALT,
  406. .clkr = {
  407. .enable_reg = 0x9008,
  408. .enable_mask = BIT(0),
  409. .hw.init = &(const struct clk_init_data){
  410. .name = "gpu_cc_freq_measure_clk",
  411. .parent_hws = (const struct clk_hw*[]){
  412. &gpu_cc_xo_div_clk_src.clkr.hw,
  413. },
  414. .num_parents = 1,
  415. .flags = CLK_SET_RATE_PARENT,
  416. .ops = &clk_branch2_ops,
  417. },
  418. },
  419. };
  420. static struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
  421. .halt_reg = 0x7000,
  422. .halt_check = BRANCH_HALT_VOTED,
  423. .clkr = {
  424. .enable_reg = 0x7000,
  425. .enable_mask = BIT(0),
  426. .hw.init = &(struct clk_init_data){
  427. .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
  428. .ops = &clk_branch2_ops,
  429. },
  430. },
  431. };
  432. static struct clk_branch gpu_cc_hub_aon_clk = {
  433. .halt_reg = 0x93e8,
  434. .halt_check = BRANCH_HALT,
  435. .clkr = {
  436. .enable_reg = 0x93e8,
  437. .enable_mask = BIT(0),
  438. .hw.init = &(const struct clk_init_data){
  439. .name = "gpu_cc_hub_aon_clk",
  440. .parent_hws = (const struct clk_hw*[]){
  441. &gpu_cc_hub_clk_src.clkr.hw,
  442. },
  443. .num_parents = 1,
  444. .flags = CLK_SET_RATE_PARENT,
  445. .ops = &clk_branch2_aon_ops,
  446. },
  447. },
  448. };
  449. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  450. .halt_reg = 0x9148,
  451. .halt_check = BRANCH_HALT_VOTED,
  452. .clkr = {
  453. .enable_reg = 0x9148,
  454. .enable_mask = BIT(0),
  455. .hw.init = &(const struct clk_init_data){
  456. .name = "gpu_cc_hub_cx_int_clk",
  457. .parent_hws = (const struct clk_hw*[]){
  458. &gpu_cc_hub_clk_src.clkr.hw,
  459. },
  460. .num_parents = 1,
  461. .flags = CLK_SET_RATE_PARENT | CLK_DONT_HOLD_STATE,
  462. .ops = &clk_branch2_ops,
  463. },
  464. },
  465. };
  466. static struct clk_branch gpu_cc_memnoc_gfx_clk = {
  467. .halt_reg = 0x9150,
  468. .halt_check = BRANCH_HALT_VOTED,
  469. .clkr = {
  470. .enable_reg = 0x9150,
  471. .enable_mask = BIT(0),
  472. .hw.init = &(const struct clk_init_data){
  473. .name = "gpu_cc_memnoc_gfx_clk",
  474. .ops = &clk_branch2_ops,
  475. },
  476. },
  477. };
  478. static struct clk_branch gpu_cc_mnd1x_0_gfx3d_clk = {
  479. .halt_reg = 0x9288,
  480. .halt_check = BRANCH_HALT_SKIP,
  481. .clkr = {
  482. .enable_reg = 0x9288,
  483. .enable_mask = BIT(0),
  484. .hw.init = &(const struct clk_init_data){
  485. .name = "gpu_cc_mnd1x_0_gfx3d_clk",
  486. .ops = &clk_branch2_ops,
  487. },
  488. },
  489. };
  490. static struct clk_branch gpu_cc_mnd1x_1_gfx3d_clk = {
  491. .halt_reg = 0x928c,
  492. .halt_check = BRANCH_HALT_SKIP,
  493. .clkr = {
  494. .enable_reg = 0x928c,
  495. .enable_mask = BIT(0),
  496. .hw.init = &(const struct clk_init_data){
  497. .name = "gpu_cc_mnd1x_1_gfx3d_clk",
  498. .ops = &clk_branch2_ops,
  499. },
  500. },
  501. };
  502. static struct clk_branch gpu_cc_sleep_clk = {
  503. .halt_reg = 0x9134,
  504. .halt_check = BRANCH_HALT_VOTED,
  505. .clkr = {
  506. .enable_reg = 0x9134,
  507. .enable_mask = BIT(0),
  508. .hw.init = &(const struct clk_init_data){
  509. .name = "gpu_cc_sleep_clk",
  510. .ops = &clk_branch2_ops,
  511. },
  512. },
  513. };
  514. static struct clk_regmap *gpu_cc_anorak_clocks[] = {
  515. [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
  516. [GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr,
  517. [GPU_CC_CX_FF_CLK] = &gpu_cc_cx_ff_clk.clkr,
  518. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  519. [GPU_CC_CXO_AON_CLK] = &gpu_cc_cxo_aon_clk.clkr,
  520. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  521. [GPU_CC_DEMET_CLK] = &gpu_cc_demet_clk.clkr,
  522. [GPU_CC_DEMET_DIV_CLK_SRC] = &gpu_cc_demet_div_clk_src.clkr,
  523. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  524. [GPU_CC_FREQ_MEASURE_CLK] = &gpu_cc_freq_measure_clk.clkr,
  525. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  526. [GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
  527. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  528. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  529. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  530. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  531. [GPU_CC_MND1X_0_GFX3D_CLK] = &gpu_cc_mnd1x_0_gfx3d_clk.clkr,
  532. [GPU_CC_MND1X_1_GFX3D_CLK] = &gpu_cc_mnd1x_1_gfx3d_clk.clkr,
  533. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  534. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  535. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  536. [GPU_CC_XO_CLK_SRC] = &gpu_cc_xo_clk_src.clkr,
  537. [GPU_CC_XO_DIV_CLK_SRC] = &gpu_cc_xo_div_clk_src.clkr,
  538. };
  539. static const struct qcom_reset_map gpu_cc_anorak_resets[] = {
  540. [GPUCC_GPU_CC_ACD_BCR] = { 0x9358 },
  541. [GPUCC_GPU_CC_CX_BCR] = { 0x9104 },
  542. [GPUCC_GPU_CC_FAST_HUB_BCR] = { 0x93e4 },
  543. [GPUCC_GPU_CC_FF_BCR] = { 0x9470 },
  544. [GPUCC_GPU_CC_GFX3D_AON_BCR] = { 0x9198 },
  545. [GPUCC_GPU_CC_GMU_BCR] = { 0x9314 },
  546. [GPUCC_GPU_CC_GX_BCR] = { 0x9058 },
  547. [GPUCC_GPU_CC_RBCPR_BCR] = { 0x91e0 },
  548. [GPUCC_GPU_CC_XO_BCR] = { 0x9000 },
  549. [GPUCC_GPU_CC_FREQUENCY_LIMITER_IRQ_CLEAR] = { 0x9538, 0 },
  550. };
  551. static const struct regmap_config gpu_cc_anorak_regmap_config = {
  552. .reg_bits = 32,
  553. .reg_stride = 4,
  554. .val_bits = 32,
  555. .max_register = 0x9988,
  556. .fast_io = true,
  557. };
  558. static const struct qcom_cc_desc gpu_cc_anorak_desc = {
  559. .config = &gpu_cc_anorak_regmap_config,
  560. .clks = gpu_cc_anorak_clocks,
  561. .num_clks = ARRAY_SIZE(gpu_cc_anorak_clocks),
  562. .resets = gpu_cc_anorak_resets,
  563. .num_resets = ARRAY_SIZE(gpu_cc_anorak_resets),
  564. .clk_regulators = gpu_cc_anorak_regulators,
  565. .num_clk_regulators = ARRAY_SIZE(gpu_cc_anorak_regulators),
  566. };
  567. static const struct of_device_id gpu_cc_anorak_match_table[] = {
  568. { .compatible = "qcom,anorak-gpucc" },
  569. { }
  570. };
  571. MODULE_DEVICE_TABLE(of, gpu_cc_anorak_match_table);
  572. static int gpu_cc_anorak_probe(struct platform_device *pdev)
  573. {
  574. struct regmap *regmap;
  575. int ret;
  576. regmap = qcom_cc_map(pdev, &gpu_cc_anorak_desc);
  577. if (IS_ERR(regmap))
  578. return PTR_ERR(regmap);
  579. clk_lucid_evo_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  580. clk_lucid_evo_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
  581. regmap_write(regmap, 0x9534, 0x0);
  582. ret = qcom_cc_really_probe(pdev, &gpu_cc_anorak_desc, regmap);
  583. if (ret) {
  584. dev_err(&pdev->dev, "Failed to register GPU CC clocks\n");
  585. return ret;
  586. }
  587. dev_info(&pdev->dev, "Registered GPU CC clocks\n");
  588. return ret;
  589. }
  590. static void gpu_cc_anorak_sync_state(struct device *dev)
  591. {
  592. qcom_cc_sync_state(dev, &gpu_cc_anorak_desc);
  593. }
  594. static struct platform_driver gpu_cc_anorak_driver = {
  595. .probe = gpu_cc_anorak_probe,
  596. .driver = {
  597. .name = "gpu_cc-anorak",
  598. .of_match_table = gpu_cc_anorak_match_table,
  599. .sync_state = gpu_cc_anorak_sync_state,
  600. },
  601. };
  602. static int __init gpu_cc_anorak_init(void)
  603. {
  604. return platform_driver_register(&gpu_cc_anorak_driver);
  605. }
  606. subsys_initcall(gpu_cc_anorak_init);
  607. static void __exit gpu_cc_anorak_exit(void)
  608. {
  609. platform_driver_unregister(&gpu_cc_anorak_driver);
  610. }
  611. module_exit(gpu_cc_anorak_exit);
  612. MODULE_DESCRIPTION("QTI GPU_CC ANORAK Driver");
  613. MODULE_LICENSE("GPL");