gpucc-kalama.c 17 KB

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