gpucc-sm4450.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/module.h>
  7. #include <linux/mod_devicetable.h>
  8. #include <linux/of.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/regmap.h>
  11. #include <dt-bindings/clock/qcom,sm4450-gpucc.h>
  12. #include "clk-alpha-pll.h"
  13. #include "clk-branch.h"
  14. #include "clk-pll.h"
  15. #include "clk-rcg.h"
  16. #include "clk-regmap.h"
  17. #include "clk-regmap-divider.h"
  18. #include "common.h"
  19. #include "gdsc.h"
  20. #include "reset.h"
  21. enum {
  22. DT_BI_TCXO,
  23. DT_GPLL0_OUT_MAIN,
  24. DT_GPLL0_OUT_MAIN_DIV,
  25. };
  26. enum {
  27. P_BI_TCXO,
  28. P_GPLL0_OUT_MAIN,
  29. P_GPLL0_OUT_MAIN_DIV,
  30. P_GPU_CC_PLL0_OUT_EVEN,
  31. P_GPU_CC_PLL0_OUT_MAIN,
  32. P_GPU_CC_PLL0_OUT_ODD,
  33. P_GPU_CC_PLL1_OUT_EVEN,
  34. P_GPU_CC_PLL1_OUT_MAIN,
  35. P_GPU_CC_PLL1_OUT_ODD,
  36. };
  37. static const struct pll_vco lucid_evo_vco[] = {
  38. { 249600000, 2020000000, 0 },
  39. };
  40. /* 680.0 MHz Configuration */
  41. static const struct alpha_pll_config gpu_cc_pll0_config = {
  42. .l = 0x23,
  43. .alpha = 0x6aaa,
  44. .config_ctl_val = 0x20485699,
  45. .config_ctl_hi_val = 0x00182261,
  46. .config_ctl_hi1_val = 0x32aa299c,
  47. .user_ctl_val = 0x00000000,
  48. .user_ctl_hi_val = 0x00000805,
  49. };
  50. static struct clk_alpha_pll gpu_cc_pll0 = {
  51. .offset = 0x0,
  52. .vco_table = lucid_evo_vco,
  53. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  54. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  55. .clkr = {
  56. .hw.init = &(const struct clk_init_data) {
  57. .name = "gpu_cc_pll0",
  58. .parent_data = &(const struct clk_parent_data) {
  59. .index = DT_BI_TCXO,
  60. },
  61. .num_parents = 1,
  62. .ops = &clk_alpha_pll_lucid_evo_ops,
  63. },
  64. },
  65. };
  66. /* 500.0 MHz Configuration */
  67. static const struct alpha_pll_config gpu_cc_pll1_config = {
  68. .l = 0x1a,
  69. .alpha = 0xaaa,
  70. .config_ctl_val = 0x20485699,
  71. .config_ctl_hi_val = 0x00182261,
  72. .config_ctl_hi1_val = 0x32aa299c,
  73. .user_ctl_val = 0x00000000,
  74. .user_ctl_hi_val = 0x00000805,
  75. };
  76. static struct clk_alpha_pll gpu_cc_pll1 = {
  77. .offset = 0x1000,
  78. .vco_table = lucid_evo_vco,
  79. .num_vco = ARRAY_SIZE(lucid_evo_vco),
  80. .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_EVO],
  81. .clkr = {
  82. .hw.init = &(const struct clk_init_data) {
  83. .name = "gpu_cc_pll1",
  84. .parent_data = &(const struct clk_parent_data) {
  85. .index = DT_BI_TCXO,
  86. },
  87. .num_parents = 1,
  88. .ops = &clk_alpha_pll_lucid_evo_ops,
  89. },
  90. },
  91. };
  92. static const struct parent_map gpu_cc_parent_map_0[] = {
  93. { P_BI_TCXO, 0 },
  94. { P_GPLL0_OUT_MAIN, 5 },
  95. { P_GPLL0_OUT_MAIN_DIV, 6 },
  96. };
  97. static const struct clk_parent_data gpu_cc_parent_data_0[] = {
  98. { .index = DT_BI_TCXO },
  99. { .index = DT_GPLL0_OUT_MAIN },
  100. { .index = DT_GPLL0_OUT_MAIN_DIV },
  101. };
  102. static const struct parent_map gpu_cc_parent_map_1[] = {
  103. { P_BI_TCXO, 0 },
  104. { P_GPU_CC_PLL0_OUT_MAIN, 1 },
  105. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  106. { P_GPLL0_OUT_MAIN, 5 },
  107. { P_GPLL0_OUT_MAIN_DIV, 6 },
  108. };
  109. static const struct clk_parent_data gpu_cc_parent_data_1[] = {
  110. { .index = DT_BI_TCXO },
  111. { .hw = &gpu_cc_pll0.clkr.hw },
  112. { .hw = &gpu_cc_pll1.clkr.hw },
  113. { .index = DT_GPLL0_OUT_MAIN },
  114. { .index = DT_GPLL0_OUT_MAIN_DIV },
  115. };
  116. static const struct parent_map gpu_cc_parent_map_2[] = {
  117. { P_BI_TCXO, 0 },
  118. { P_GPU_CC_PLL0_OUT_EVEN, 1 },
  119. { P_GPU_CC_PLL0_OUT_ODD, 2 },
  120. { P_GPU_CC_PLL1_OUT_EVEN, 3 },
  121. { P_GPU_CC_PLL1_OUT_ODD, 4 },
  122. { P_GPLL0_OUT_MAIN, 5 },
  123. };
  124. static const struct clk_parent_data gpu_cc_parent_data_2[] = {
  125. { .index = DT_BI_TCXO },
  126. { .hw = &gpu_cc_pll0.clkr.hw },
  127. { .hw = &gpu_cc_pll0.clkr.hw },
  128. { .hw = &gpu_cc_pll1.clkr.hw },
  129. { .hw = &gpu_cc_pll1.clkr.hw },
  130. { .index = DT_GPLL0_OUT_MAIN },
  131. };
  132. static const struct parent_map gpu_cc_parent_map_3[] = {
  133. { P_BI_TCXO, 0 },
  134. { P_GPU_CC_PLL1_OUT_MAIN, 3 },
  135. { P_GPLL0_OUT_MAIN, 5 },
  136. { P_GPLL0_OUT_MAIN_DIV, 6 },
  137. };
  138. static const struct clk_parent_data gpu_cc_parent_data_3[] = {
  139. { .index = DT_BI_TCXO },
  140. { .hw = &gpu_cc_pll1.clkr.hw },
  141. { .index = DT_GPLL0_OUT_MAIN },
  142. { .index = DT_GPLL0_OUT_MAIN_DIV },
  143. };
  144. static const struct parent_map gpu_cc_parent_map_4[] = {
  145. { P_BI_TCXO, 0 },
  146. };
  147. static const struct clk_parent_data gpu_cc_parent_data_4[] = {
  148. { .index = DT_BI_TCXO },
  149. };
  150. static const struct freq_tbl ftbl_gpu_cc_ff_clk_src[] = {
  151. F(200000000, P_GPLL0_OUT_MAIN_DIV, 1.5, 0, 0),
  152. { }
  153. };
  154. static struct clk_rcg2 gpu_cc_ff_clk_src = {
  155. .cmd_rcgr = 0x9474,
  156. .mnd_width = 0,
  157. .hid_width = 5,
  158. .parent_map = gpu_cc_parent_map_0,
  159. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  160. .clkr.hw.init = &(const struct clk_init_data) {
  161. .name = "gpu_cc_ff_clk_src",
  162. .parent_data = gpu_cc_parent_data_0,
  163. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
  164. .flags = CLK_SET_RATE_PARENT,
  165. .ops = &clk_rcg2_shared_ops,
  166. },
  167. };
  168. static struct clk_rcg2 gpu_cc_gmu_clk_src = {
  169. .cmd_rcgr = 0x9318,
  170. .mnd_width = 0,
  171. .hid_width = 5,
  172. .parent_map = gpu_cc_parent_map_1,
  173. .freq_tbl = ftbl_gpu_cc_ff_clk_src,
  174. .clkr.hw.init = &(const struct clk_init_data) {
  175. .name = "gpu_cc_gmu_clk_src",
  176. .parent_data = gpu_cc_parent_data_1,
  177. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1),
  178. .flags = CLK_SET_RATE_PARENT,
  179. .ops = &clk_rcg2_shared_ops,
  180. },
  181. };
  182. static const struct freq_tbl ftbl_gpu_cc_gx_gfx3d_clk_src[] = {
  183. F(340000000, P_GPU_CC_PLL0_OUT_EVEN, 2, 0, 0),
  184. F(500000000, P_GPU_CC_PLL0_OUT_EVEN, 2, 0, 0),
  185. F(605000000, P_GPU_CC_PLL0_OUT_EVEN, 2, 0, 0),
  186. F(765000000, P_GPU_CC_PLL0_OUT_EVEN, 2, 0, 0),
  187. F(850000000, P_GPU_CC_PLL0_OUT_EVEN, 2, 0, 0),
  188. F(955000000, P_GPU_CC_PLL0_OUT_EVEN, 2, 0, 0),
  189. F(1010000000, P_GPU_CC_PLL0_OUT_EVEN, 2, 0, 0),
  190. { }
  191. };
  192. static struct clk_rcg2 gpu_cc_gx_gfx3d_clk_src = {
  193. .cmd_rcgr = 0x9070,
  194. .mnd_width = 0,
  195. .hid_width = 5,
  196. .parent_map = gpu_cc_parent_map_2,
  197. .freq_tbl = ftbl_gpu_cc_gx_gfx3d_clk_src,
  198. .clkr.hw.init = &(const struct clk_init_data) {
  199. .name = "gpu_cc_gx_gfx3d_clk_src",
  200. .parent_data = gpu_cc_parent_data_2,
  201. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_2),
  202. .flags = CLK_SET_RATE_PARENT,
  203. .ops = &clk_rcg2_shared_ops,
  204. },
  205. };
  206. static const struct freq_tbl ftbl_gpu_cc_hub_clk_src[] = {
  207. F(150000000, P_GPLL0_OUT_MAIN_DIV, 2, 0, 0),
  208. { }
  209. };
  210. static struct clk_rcg2 gpu_cc_hub_clk_src = {
  211. .cmd_rcgr = 0x93ec,
  212. .mnd_width = 0,
  213. .hid_width = 5,
  214. .parent_map = gpu_cc_parent_map_3,
  215. .freq_tbl = ftbl_gpu_cc_hub_clk_src,
  216. .clkr.hw.init = &(const struct clk_init_data) {
  217. .name = "gpu_cc_hub_clk_src",
  218. .parent_data = gpu_cc_parent_data_3,
  219. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_3),
  220. .flags = CLK_SET_RATE_PARENT,
  221. .ops = &clk_rcg2_shared_ops,
  222. },
  223. };
  224. static const struct freq_tbl ftbl_gpu_cc_xo_clk_src[] = {
  225. F(19200000, P_BI_TCXO, 1, 0, 0),
  226. { }
  227. };
  228. static struct clk_rcg2 gpu_cc_xo_clk_src = {
  229. .cmd_rcgr = 0x9010,
  230. .mnd_width = 0,
  231. .hid_width = 5,
  232. .parent_map = gpu_cc_parent_map_4,
  233. .freq_tbl = ftbl_gpu_cc_xo_clk_src,
  234. .clkr.hw.init = &(const struct clk_init_data) {
  235. .name = "gpu_cc_xo_clk_src",
  236. .parent_data = gpu_cc_parent_data_4,
  237. .num_parents = ARRAY_SIZE(gpu_cc_parent_data_4),
  238. .flags = CLK_SET_RATE_PARENT,
  239. .ops = &clk_rcg2_shared_ops,
  240. },
  241. };
  242. static struct clk_regmap_div gpu_cc_demet_div_clk_src = {
  243. .reg = 0x9054,
  244. .shift = 0,
  245. .width = 4,
  246. .clkr.hw.init = &(const struct clk_init_data) {
  247. .name = "gpu_cc_demet_div_clk_src",
  248. .parent_hws = (const struct clk_hw*[]) {
  249. &gpu_cc_xo_clk_src.clkr.hw,
  250. },
  251. .num_parents = 1,
  252. .flags = CLK_SET_RATE_PARENT,
  253. .ops = &clk_regmap_div_ro_ops,
  254. },
  255. };
  256. static struct clk_regmap_div gpu_cc_hub_ahb_div_clk_src = {
  257. .reg = 0x9430,
  258. .shift = 0,
  259. .width = 4,
  260. .clkr.hw.init = &(const struct clk_init_data) {
  261. .name = "gpu_cc_hub_ahb_div_clk_src",
  262. .parent_hws = (const struct clk_hw*[]) {
  263. &gpu_cc_hub_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_cx_int_div_clk_src = {
  271. .reg = 0x942c,
  272. .shift = 0,
  273. .width = 4,
  274. .clkr.hw.init = &(const struct clk_init_data) {
  275. .name = "gpu_cc_hub_cx_int_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_xo_div_clk_src = {
  285. .reg = 0x9050,
  286. .shift = 0,
  287. .width = 4,
  288. .clkr.hw.init = &(const struct clk_init_data) {
  289. .name = "gpu_cc_xo_div_clk_src",
  290. .parent_hws = (const struct clk_hw*[]) {
  291. &gpu_cc_xo_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,
  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_ff_clk = {
  333. .halt_reg = 0x914c,
  334. .halt_check = BRANCH_HALT,
  335. .clkr = {
  336. .enable_reg = 0x914c,
  337. .enable_mask = BIT(0),
  338. .hw.init = &(const struct clk_init_data) {
  339. .name = "gpu_cc_cx_ff_clk",
  340. .parent_hws = (const struct clk_hw*[]) {
  341. &gpu_cc_ff_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_gfx3d_clk = {
  350. .halt_reg = 0x919c,
  351. .halt_check = BRANCH_HALT,
  352. .clkr = {
  353. .enable_reg = 0x919c,
  354. .enable_mask = BIT(0),
  355. .hw.init = &(const struct clk_init_data) {
  356. .name = "gpu_cc_cx_gfx3d_clk",
  357. .parent_hws = (const struct clk_hw*[]) {
  358. &gpu_cc_gx_gfx3d_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_gfx3d_slv_clk = {
  367. .halt_reg = 0x91a0,
  368. .halt_check = BRANCH_HALT,
  369. .clkr = {
  370. .enable_reg = 0x91a0,
  371. .enable_mask = BIT(0),
  372. .hw.init = &(const struct clk_init_data) {
  373. .name = "gpu_cc_cx_gfx3d_slv_clk",
  374. .parent_hws = (const struct clk_hw*[]) {
  375. &gpu_cc_gx_gfx3d_clk_src.clkr.hw,
  376. },
  377. .num_parents = 1,
  378. .flags = CLK_SET_RATE_PARENT,
  379. .ops = &clk_branch2_ops,
  380. },
  381. },
  382. };
  383. static struct clk_branch gpu_cc_cx_gmu_clk = {
  384. .halt_reg = 0x913c,
  385. .halt_check = BRANCH_HALT,
  386. .clkr = {
  387. .enable_reg = 0x913c,
  388. .enable_mask = BIT(0),
  389. .hw.init = &(const struct clk_init_data) {
  390. .name = "gpu_cc_cx_gmu_clk",
  391. .parent_hws = (const struct clk_hw*[]) {
  392. &gpu_cc_gmu_clk_src.clkr.hw,
  393. },
  394. .num_parents = 1,
  395. .flags = CLK_SET_RATE_PARENT,
  396. .ops = &clk_branch2_aon_ops,
  397. },
  398. },
  399. };
  400. static struct clk_branch gpu_cc_cx_snoc_dvm_clk = {
  401. .halt_reg = 0x9130,
  402. .halt_check = BRANCH_HALT,
  403. .clkr = {
  404. .enable_reg = 0x9130,
  405. .enable_mask = BIT(0),
  406. .hw.init = &(const struct clk_init_data) {
  407. .name = "gpu_cc_cx_snoc_dvm_clk",
  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_SET_RATE_PARENT,
  425. .ops = &clk_branch2_ops,
  426. },
  427. },
  428. };
  429. static struct clk_branch gpu_cc_freq_measure_clk = {
  430. .halt_reg = 0x9008,
  431. .halt_check = BRANCH_HALT,
  432. .clkr = {
  433. .enable_reg = 0x9008,
  434. .enable_mask = BIT(0),
  435. .hw.init = &(const struct clk_init_data) {
  436. .name = "gpu_cc_freq_measure_clk",
  437. .parent_hws = (const struct clk_hw*[]) {
  438. &gpu_cc_xo_div_clk_src.clkr.hw,
  439. },
  440. .num_parents = 1,
  441. .flags = CLK_SET_RATE_PARENT,
  442. .ops = &clk_branch2_ops,
  443. },
  444. },
  445. };
  446. static struct clk_branch gpu_cc_gx_cxo_clk = {
  447. .halt_reg = 0x90b8,
  448. .halt_check = BRANCH_HALT,
  449. .clkr = {
  450. .enable_reg = 0x90b8,
  451. .enable_mask = BIT(0),
  452. .hw.init = &(const struct clk_init_data) {
  453. .name = "gpu_cc_gx_cxo_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_gx_ff_clk = {
  464. .halt_reg = 0x90c0,
  465. .halt_check = BRANCH_HALT,
  466. .clkr = {
  467. .enable_reg = 0x90c0,
  468. .enable_mask = BIT(0),
  469. .hw.init = &(const struct clk_init_data) {
  470. .name = "gpu_cc_gx_ff_clk",
  471. .parent_hws = (const struct clk_hw*[]) {
  472. &gpu_cc_ff_clk_src.clkr.hw,
  473. },
  474. .num_parents = 1,
  475. .flags = CLK_SET_RATE_PARENT,
  476. .ops = &clk_branch2_ops,
  477. },
  478. },
  479. };
  480. static struct clk_branch gpu_cc_gx_gfx3d_clk = {
  481. .halt_reg = 0x90a8,
  482. .halt_check = BRANCH_HALT,
  483. .clkr = {
  484. .enable_reg = 0x90a8,
  485. .enable_mask = BIT(0),
  486. .hw.init = &(const struct clk_init_data) {
  487. .name = "gpu_cc_gx_gfx3d_clk",
  488. .parent_hws = (const struct clk_hw*[]) {
  489. &gpu_cc_gx_gfx3d_clk_src.clkr.hw,
  490. },
  491. .num_parents = 1,
  492. .flags = CLK_SET_RATE_PARENT,
  493. .ops = &clk_branch2_ops,
  494. },
  495. },
  496. };
  497. static struct clk_branch gpu_cc_gx_gfx3d_rdvm_clk = {
  498. .halt_reg = 0x90c8,
  499. .halt_check = BRANCH_HALT,
  500. .clkr = {
  501. .enable_reg = 0x90c8,
  502. .enable_mask = BIT(0),
  503. .hw.init = &(const struct clk_init_data) {
  504. .name = "gpu_cc_gx_gfx3d_rdvm_clk",
  505. .parent_hws = (const struct clk_hw*[]) {
  506. &gpu_cc_gx_gfx3d_clk_src.clkr.hw,
  507. },
  508. .num_parents = 1,
  509. .flags = CLK_SET_RATE_PARENT,
  510. .ops = &clk_branch2_ops,
  511. },
  512. },
  513. };
  514. static struct clk_branch gpu_cc_gx_gmu_clk = {
  515. .halt_reg = 0x90bc,
  516. .halt_check = BRANCH_HALT,
  517. .clkr = {
  518. .enable_reg = 0x90bc,
  519. .enable_mask = BIT(0),
  520. .hw.init = &(const struct clk_init_data) {
  521. .name = "gpu_cc_gx_gmu_clk",
  522. .parent_hws = (const struct clk_hw*[]) {
  523. &gpu_cc_gmu_clk_src.clkr.hw,
  524. },
  525. .num_parents = 1,
  526. .flags = CLK_SET_RATE_PARENT,
  527. .ops = &clk_branch2_ops,
  528. },
  529. },
  530. };
  531. static struct clk_branch gpu_cc_gx_vsense_clk = {
  532. .halt_reg = 0x90b0,
  533. .halt_check = BRANCH_HALT,
  534. .clkr = {
  535. .enable_reg = 0x90b0,
  536. .enable_mask = BIT(0),
  537. .hw.init = &(const struct clk_init_data) {
  538. .name = "gpu_cc_gx_vsense_clk",
  539. .ops = &clk_branch2_ops,
  540. },
  541. },
  542. };
  543. static struct clk_branch gpu_cc_hub_aon_clk = {
  544. .halt_reg = 0x93e8,
  545. .halt_check = BRANCH_HALT,
  546. .clkr = {
  547. .enable_reg = 0x93e8,
  548. .enable_mask = BIT(0),
  549. .hw.init = &(const struct clk_init_data) {
  550. .name = "gpu_cc_hub_aon_clk",
  551. .parent_hws = (const struct clk_hw*[]) {
  552. &gpu_cc_hub_clk_src.clkr.hw,
  553. },
  554. .num_parents = 1,
  555. .flags = CLK_SET_RATE_PARENT,
  556. .ops = &clk_branch2_aon_ops,
  557. },
  558. },
  559. };
  560. static struct clk_branch gpu_cc_hub_cx_int_clk = {
  561. .halt_reg = 0x9148,
  562. .halt_check = BRANCH_HALT,
  563. .clkr = {
  564. .enable_reg = 0x9148,
  565. .enable_mask = BIT(0),
  566. .hw.init = &(const struct clk_init_data) {
  567. .name = "gpu_cc_hub_cx_int_clk",
  568. .parent_hws = (const struct clk_hw*[]) {
  569. &gpu_cc_hub_cx_int_div_clk_src.clkr.hw,
  570. },
  571. .num_parents = 1,
  572. .flags = CLK_SET_RATE_PARENT,
  573. .ops = &clk_branch2_aon_ops,
  574. },
  575. },
  576. };
  577. static struct clk_branch gpu_cc_memnoc_gfx_clk = {
  578. .halt_reg = 0x9150,
  579. .halt_check = BRANCH_HALT,
  580. .clkr = {
  581. .enable_reg = 0x9150,
  582. .enable_mask = BIT(0),
  583. .hw.init = &(const struct clk_init_data) {
  584. .name = "gpu_cc_memnoc_gfx_clk",
  585. .ops = &clk_branch2_ops,
  586. },
  587. },
  588. };
  589. static struct clk_branch gpu_cc_mnd1x_0_gfx3d_clk = {
  590. .halt_reg = 0x9288,
  591. .halt_check = BRANCH_HALT,
  592. .clkr = {
  593. .enable_reg = 0x9288,
  594. .enable_mask = BIT(0),
  595. .hw.init = &(const struct clk_init_data) {
  596. .name = "gpu_cc_mnd1x_0_gfx3d_clk",
  597. .parent_hws = (const struct clk_hw*[]) {
  598. &gpu_cc_gx_gfx3d_clk_src.clkr.hw,
  599. },
  600. .num_parents = 1,
  601. .flags = CLK_SET_RATE_PARENT,
  602. .ops = &clk_branch2_ops,
  603. },
  604. },
  605. };
  606. static struct clk_branch gpu_cc_sleep_clk = {
  607. .halt_reg = 0x9134,
  608. .halt_check = BRANCH_HALT,
  609. .clkr = {
  610. .enable_reg = 0x9134,
  611. .enable_mask = BIT(0),
  612. .hw.init = &(const struct clk_init_data) {
  613. .name = "gpu_cc_sleep_clk",
  614. .ops = &clk_branch2_ops,
  615. },
  616. },
  617. };
  618. static struct gdsc gpu_cc_cx_gdsc = {
  619. .gdscr = 0x9108,
  620. .gds_hw_ctrl = 0x953c,
  621. .clk_dis_wait_val = 8,
  622. .pd = {
  623. .name = "gpu_cx_gdsc",
  624. },
  625. .pwrsts = PWRSTS_OFF_ON,
  626. .flags = VOTABLE | RETAIN_FF_ENABLE,
  627. };
  628. static struct gdsc gpu_cc_gx_gdsc = {
  629. .gdscr = 0x905c,
  630. .clamp_io_ctrl = 0x9504,
  631. .resets = (unsigned int []){ GPU_CC_GX_BCR,
  632. GPU_CC_ACD_BCR,
  633. GPU_CC_GX_ACD_IROOT_BCR },
  634. .reset_count = 3,
  635. .pd = {
  636. .name = "gpu_gx_gdsc",
  637. .power_on = gdsc_gx_do_nothing_enable,
  638. },
  639. .pwrsts = PWRSTS_OFF_ON,
  640. .flags = CLAMP_IO | AON_RESET | SW_RESET | POLL_CFG_GDSCR,
  641. };
  642. static struct clk_regmap *gpu_cc_sm4450_clocks[] = {
  643. [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
  644. [GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr,
  645. [GPU_CC_CX_FF_CLK] = &gpu_cc_cx_ff_clk.clkr,
  646. [GPU_CC_CX_GFX3D_CLK] = &gpu_cc_cx_gfx3d_clk.clkr,
  647. [GPU_CC_CX_GFX3D_SLV_CLK] = &gpu_cc_cx_gfx3d_slv_clk.clkr,
  648. [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
  649. [GPU_CC_CX_SNOC_DVM_CLK] = &gpu_cc_cx_snoc_dvm_clk.clkr,
  650. [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
  651. [GPU_CC_DEMET_DIV_CLK_SRC] = &gpu_cc_demet_div_clk_src.clkr,
  652. [GPU_CC_FF_CLK_SRC] = &gpu_cc_ff_clk_src.clkr,
  653. [GPU_CC_FREQ_MEASURE_CLK] = &gpu_cc_freq_measure_clk.clkr,
  654. [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
  655. [GPU_CC_GX_CXO_CLK] = &gpu_cc_gx_cxo_clk.clkr,
  656. [GPU_CC_GX_FF_CLK] = &gpu_cc_gx_ff_clk.clkr,
  657. [GPU_CC_GX_GFX3D_CLK] = &gpu_cc_gx_gfx3d_clk.clkr,
  658. [GPU_CC_GX_GFX3D_CLK_SRC] = &gpu_cc_gx_gfx3d_clk_src.clkr,
  659. [GPU_CC_GX_GFX3D_RDVM_CLK] = &gpu_cc_gx_gfx3d_rdvm_clk.clkr,
  660. [GPU_CC_GX_GMU_CLK] = &gpu_cc_gx_gmu_clk.clkr,
  661. [GPU_CC_GX_VSENSE_CLK] = &gpu_cc_gx_vsense_clk.clkr,
  662. [GPU_CC_HUB_AHB_DIV_CLK_SRC] = &gpu_cc_hub_ahb_div_clk_src.clkr,
  663. [GPU_CC_HUB_AON_CLK] = &gpu_cc_hub_aon_clk.clkr,
  664. [GPU_CC_HUB_CLK_SRC] = &gpu_cc_hub_clk_src.clkr,
  665. [GPU_CC_HUB_CX_INT_CLK] = &gpu_cc_hub_cx_int_clk.clkr,
  666. [GPU_CC_HUB_CX_INT_DIV_CLK_SRC] = &gpu_cc_hub_cx_int_div_clk_src.clkr,
  667. [GPU_CC_MEMNOC_GFX_CLK] = &gpu_cc_memnoc_gfx_clk.clkr,
  668. [GPU_CC_MND1X_0_GFX3D_CLK] = &gpu_cc_mnd1x_0_gfx3d_clk.clkr,
  669. [GPU_CC_PLL0] = &gpu_cc_pll0.clkr,
  670. [GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
  671. [GPU_CC_SLEEP_CLK] = &gpu_cc_sleep_clk.clkr,
  672. [GPU_CC_XO_CLK_SRC] = &gpu_cc_xo_clk_src.clkr,
  673. [GPU_CC_XO_DIV_CLK_SRC] = &gpu_cc_xo_div_clk_src.clkr,
  674. };
  675. static struct gdsc *gpu_cc_sm4450_gdscs[] = {
  676. [GPU_CC_CX_GDSC] = &gpu_cc_cx_gdsc,
  677. [GPU_CC_GX_GDSC] = &gpu_cc_gx_gdsc,
  678. };
  679. static const struct qcom_reset_map gpu_cc_sm4450_resets[] = {
  680. [GPU_CC_CB_BCR] = { 0x93a0 },
  681. [GPU_CC_CX_BCR] = { 0x9104 },
  682. [GPU_CC_GX_BCR] = { 0x9058 },
  683. [GPU_CC_FAST_HUB_BCR] = { 0x93e4 },
  684. [GPU_CC_ACD_BCR] = { 0x9358 },
  685. [GPU_CC_FF_BCR] = { 0x9470 },
  686. [GPU_CC_GFX3D_AON_BCR] = { 0x9198 },
  687. [GPU_CC_GMU_BCR] = { 0x9314 },
  688. [GPU_CC_RBCPR_BCR] = { 0x91e0 },
  689. [GPU_CC_XO_BCR] = { 0x9000 },
  690. [GPU_CC_GX_ACD_IROOT_BCR] = { 0x958c },
  691. };
  692. static const struct regmap_config gpu_cc_sm4450_regmap_config = {
  693. .reg_bits = 32,
  694. .reg_stride = 4,
  695. .val_bits = 32,
  696. .max_register = 0x95c0,
  697. .fast_io = true,
  698. };
  699. static const struct qcom_cc_desc gpu_cc_sm4450_desc = {
  700. .config = &gpu_cc_sm4450_regmap_config,
  701. .clks = gpu_cc_sm4450_clocks,
  702. .num_clks = ARRAY_SIZE(gpu_cc_sm4450_clocks),
  703. .resets = gpu_cc_sm4450_resets,
  704. .num_resets = ARRAY_SIZE(gpu_cc_sm4450_resets),
  705. .gdscs = gpu_cc_sm4450_gdscs,
  706. .num_gdscs = ARRAY_SIZE(gpu_cc_sm4450_gdscs),
  707. };
  708. static const struct of_device_id gpu_cc_sm4450_match_table[] = {
  709. { .compatible = "qcom,sm4450-gpucc" },
  710. { }
  711. };
  712. MODULE_DEVICE_TABLE(of, gpu_cc_sm4450_match_table);
  713. static int gpu_cc_sm4450_probe(struct platform_device *pdev)
  714. {
  715. struct regmap *regmap;
  716. regmap = qcom_cc_map(pdev, &gpu_cc_sm4450_desc);
  717. if (IS_ERR(regmap))
  718. return PTR_ERR(regmap);
  719. clk_lucid_evo_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config);
  720. clk_lucid_evo_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
  721. /* Keep some clocks always enabled */
  722. qcom_branch_set_clk_en(regmap, 0x93a4); /* GPU_CC_CB_CLK */
  723. qcom_branch_set_clk_en(regmap, 0x9004); /* GPU_CC_CXO_AON_CLK */
  724. qcom_branch_set_clk_en(regmap, 0x900c); /* GPU_CC_DEMET_CLK */
  725. return qcom_cc_really_probe(&pdev->dev, &gpu_cc_sm4450_desc, regmap);
  726. }
  727. static struct platform_driver gpu_cc_sm4450_driver = {
  728. .probe = gpu_cc_sm4450_probe,
  729. .driver = {
  730. .name = "gpucc-sm4450",
  731. .of_match_table = gpu_cc_sm4450_match_table,
  732. },
  733. };
  734. module_platform_driver(gpu_cc_sm4450_driver);
  735. MODULE_DESCRIPTION("QTI GPUCC SM4450 Driver");
  736. MODULE_LICENSE("GPL");