Debian Codegraph @

drivers/clk/qcom/dispcc-milos.c

raw
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
4 * Copyright (c) 2025, Luca Weiss <[email protected]>
5 */
6
7 #include <linux/clk.h>
8 #include <linux/clk-provider.h>
9 #include <linux/err.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/of.h>
13 #include <linux/platform_device.h>
14 #include <linux/regmap.h>
15
16 #include <dt-bindings/clock/qcom,milos-dispcc.h>
17
18 #include "common.h"
19 #include "clk-alpha-pll.h"
20 #include "clk-branch.h"
21 #include "clk-pll.h"
22 #include "clk-rcg.h"
23 #include "clk-regmap.h"
24 #include "clk-regmap-divider.h"
25 #include "clk-regmap-mux.h"
26 #include "reset.h"
27 #include "gdsc.h"
28
29 /* Need to match the order of clocks in DT binding */
30 enum {
31 DT_BI_TCXO,
32 DT_SLEEP_CLK,
33 DT_AHB_CLK,
34 DT_GCC_DISP_GPLL0_CLK,
35 DT_DSI0_PHY_PLL_OUT_BYTECLK,
36 DT_DSI0_PHY_PLL_OUT_DSICLK,
37 DT_DP0_PHY_PLL_LINK_CLK,
38 DT_DP0_PHY_PLL_VCO_DIV_CLK,
39 };
40
41 #define DISP_CC_MISC_CMD 0xF000
42
43 enum {
44 P_BI_TCXO,
45 P_DISP_CC_PLL0_OUT_EVEN,
46 P_DISP_CC_PLL0_OUT_MAIN,
47 P_DP0_PHY_PLL_LINK_CLK,
48 P_DP0_PHY_PLL_VCO_DIV_CLK,
49 P_DSI0_PHY_PLL_OUT_BYTECLK,
50 P_DSI0_PHY_PLL_OUT_DSICLK,
51 P_GCC_DISP_GPLL0_CLK,
52 P_SLEEP_CLK,
53 };
54
55 static const struct pll_vco lucid_ole_vco[] = {
56 { 249600000, 2300000000, 0 },
57 };
58
59 /* 257.142858 MHz Configuration */
60 static const struct alpha_pll_config disp_cc_pll0_config = {
61 .l = 0xd,
62 .alpha = 0x6492,
63 .config_ctl_val = 0x20485699,
64 .config_ctl_hi_val = 0x00182261,
65 .config_ctl_hi1_val = 0x82aa299c,
66 .test_ctl_val = 0x00000000,
67 .test_ctl_hi_val = 0x00000003,
68 .test_ctl_hi1_val = 0x00009000,
69 .test_ctl_hi2_val = 0x00000034,
70 .user_ctl_val = 0x00000000,
71 .user_ctl_hi_val = 0x00000005,
72 };
73
74 static struct clk_alpha_pll disp_cc_pll0 = {
75 .offset = 0x0,
76 .config = &disp_cc_pll0_config,
77 .vco_table = lucid_ole_vco,
78 .num_vco = ARRAY_SIZE(lucid_ole_vco),
79 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE],
80 .clkr = {
81 .hw.init = &(const struct clk_init_data) {
82 .name = "disp_cc_pll0",
83 .parent_data = &(const struct clk_parent_data) {
84 .index = DT_BI_TCXO,
85 },
86 .num_parents = 1,
87 .ops = &clk_alpha_pll_lucid_evo_ops,
88 },
89 },
90 };
91
92 static const struct parent_map disp_cc_parent_map_0[] = {
93 { P_BI_TCXO, 0 },
94 };
95
96 static const struct clk_parent_data disp_cc_parent_data_0[] = {
97 { .index = DT_BI_TCXO },
98 };
99
100 static const struct parent_map disp_cc_parent_map_1[] = {
101 { P_BI_TCXO, 0 },
102 { P_DSI0_PHY_PLL_OUT_DSICLK, 1 },
103 { P_DSI0_PHY_PLL_OUT_BYTECLK, 2 },
104 };
105
106 static const struct clk_parent_data disp_cc_parent_data_1[] = {
107 { .index = DT_BI_TCXO },
108 { .index = DT_DSI0_PHY_PLL_OUT_DSICLK },
109 { .index = DT_DSI0_PHY_PLL_OUT_BYTECLK },
110 };
111
112 static const struct parent_map disp_cc_parent_map_2[] = {
113 { P_BI_TCXO, 0 },
114 { P_DP0_PHY_PLL_LINK_CLK, 1 },
115 { P_DP0_PHY_PLL_VCO_DIV_CLK, 2 },
116 };
117
118 static const struct clk_parent_data disp_cc_parent_data_2[] = {
119 { .index = DT_BI_TCXO },
120 { .index = DT_DP0_PHY_PLL_LINK_CLK },
121 { .index = DT_DP0_PHY_PLL_VCO_DIV_CLK },
122 };
123
124 static const struct parent_map disp_cc_parent_map_3[] = {
125 { P_BI_TCXO, 0 },
126 { P_GCC_DISP_GPLL0_CLK, 4 },
127 };
128
129 static const struct clk_parent_data disp_cc_parent_data_3[] = {
130 { .index = DT_BI_TCXO },
131 { .index = DT_GCC_DISP_GPLL0_CLK },
132 };
133
134 static const struct parent_map disp_cc_parent_map_4[] = {
135 { P_BI_TCXO, 0 },
136 { P_DP0_PHY_PLL_LINK_CLK, 1 },
137 };
138
139 static const struct clk_parent_data disp_cc_parent_data_4[] = {
140 { .index = DT_BI_TCXO },
141 { .index = DT_DP0_PHY_PLL_LINK_CLK },
142 };
143
144 static const struct parent_map disp_cc_parent_map_5[] = {
145 { P_BI_TCXO, 0 },
146 { P_DSI0_PHY_PLL_OUT_BYTECLK, 2 },
147 };
148
149 static const struct clk_parent_data disp_cc_parent_data_5[] = {
150 { .index = DT_BI_TCXO },
151 { .index = DT_DSI0_PHY_PLL_OUT_BYTECLK },
152 };
153
154 static const struct parent_map disp_cc_parent_map_6[] = {
155 { P_BI_TCXO, 0 },
156 { P_DISP_CC_PLL0_OUT_MAIN, 1 },
157 { P_GCC_DISP_GPLL0_CLK, 4 },
158 { P_DISP_CC_PLL0_OUT_EVEN, 6 },
159 };
160
161 static const struct clk_parent_data disp_cc_parent_data_6[] = {
162 { .index = DT_BI_TCXO },
163 { .hw = &disp_cc_pll0.clkr.hw },
164 { .index = DT_GCC_DISP_GPLL0_CLK },
165 { .hw = &disp_cc_pll0.clkr.hw },
166 };
167
168 static const struct parent_map disp_cc_parent_map_7[] = {
169 { P_SLEEP_CLK, 0 },
170 };
171
172 static const struct clk_parent_data disp_cc_parent_data_7_ao[] = {
173 { .index = DT_SLEEP_CLK },
174 };
175
176 static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = {
177 F(19200000, P_BI_TCXO, 1, 0, 0),
178 F(37500000, P_GCC_DISP_GPLL0_CLK, 8, 0, 0),
179 F(75000000, P_GCC_DISP_GPLL0_CLK, 4, 0, 0),
180 { }
181 };
182
183 static struct clk_rcg2 disp_cc_mdss_ahb_clk_src = {
184 .cmd_rcgr = 0x8130,
185 .mnd_width = 0,
186 .hid_width = 5,
187 .parent_map = disp_cc_parent_map_3,
188 .freq_tbl = ftbl_disp_cc_mdss_ahb_clk_src,
189 .clkr.hw.init = &(const struct clk_init_data) {
190 .name = "disp_cc_mdss_ahb_clk_src",
191 .parent_data = disp_cc_parent_data_3,
192 .num_parents = ARRAY_SIZE(disp_cc_parent_data_3),
193 .flags = CLK_SET_RATE_PARENT,
194 .ops = &clk_rcg2_shared_ops,
195 },
196 };
197
198 static struct clk_rcg2 disp_cc_mdss_byte0_clk_src = {
199 .cmd_rcgr = 0x8098,
200 .mnd_width = 0,
201 .hid_width = 5,
202 .parent_map = disp_cc_parent_map_1,
203 .clkr.hw.init = &(const struct clk_init_data) {
204 .name = "disp_cc_mdss_byte0_clk_src",
205 .parent_data = disp_cc_parent_data_1,
206 .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
207 .flags = CLK_SET_RATE_PARENT,
208 .ops = &clk_byte2_ops,
209 },
210 };
211
212 static const struct freq_tbl ftbl_disp_cc_mdss_dptx0_aux_clk_src[] = {
213 F(19200000, P_BI_TCXO, 1, 0, 0),
214 { }
215 };
216
217 static struct clk_rcg2 disp_cc_mdss_dptx0_aux_clk_src = {
218 .cmd_rcgr = 0x8118,
219 .mnd_width = 0,
220 .hid_width = 5,
221 .parent_map = disp_cc_parent_map_0,
222 .freq_tbl = ftbl_disp_cc_mdss_dptx0_aux_clk_src,
223 .clkr.hw.init = &(const struct clk_init_data) {
224 .name = "disp_cc_mdss_dptx0_aux_clk_src",
225 .parent_data = disp_cc_parent_data_0,
226 .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
227 .flags = CLK_SET_RATE_PARENT,
228 .ops = &clk_rcg2_ops,
229 },
230 };
231
232 static struct clk_rcg2 disp_cc_mdss_dptx0_link_clk_src = {
233 .cmd_rcgr = 0x80cc,
234 .mnd_width = 0,
235 .hid_width = 5,
236 .parent_map = disp_cc_parent_map_4,
237 .clkr.hw.init = &(const struct clk_init_data) {
238 .name = "disp_cc_mdss_dptx0_link_clk_src",
239 .parent_data = disp_cc_parent_data_4,
240 .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
241 .flags = CLK_SET_RATE_PARENT,
242 .ops = &clk_byte2_ops,
243 },
244 };
245
246 static struct clk_rcg2 disp_cc_mdss_dptx0_pixel0_clk_src = {
247 .cmd_rcgr = 0x80e8,
248 .mnd_width = 16,
249 .hid_width = 5,
250 .parent_map = disp_cc_parent_map_2,
251 .clkr.hw.init = &(const struct clk_init_data) {
252 .name = "disp_cc_mdss_dptx0_pixel0_clk_src",
253 .parent_data = disp_cc_parent_data_2,
254 .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
255 .flags = CLK_SET_RATE_PARENT,
256 .ops = &clk_dp_ops,
257 },
258 };
259
260 static struct clk_rcg2 disp_cc_mdss_dptx0_pixel1_clk_src = {
261 .cmd_rcgr = 0x8100,
262 .mnd_width = 16,
263 .hid_width = 5,
264 .parent_map = disp_cc_parent_map_2,
265 .clkr.hw.init = &(const struct clk_init_data) {
266 .name = "disp_cc_mdss_dptx0_pixel1_clk_src",
267 .parent_data = disp_cc_parent_data_2,
268 .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
269 .flags = CLK_SET_RATE_PARENT,
270 .ops = &clk_dp_ops,
271 },
272 };
273
274 static const struct freq_tbl ftbl_disp_cc_mdss_esc0_clk_src[] = {
275 F(9600000, P_BI_TCXO, 2, 0, 0),
276 F(12800000, P_BI_TCXO, 1.5, 0, 0),
277 F(19200000, P_BI_TCXO, 1, 0, 0),
278 { }
279 };
280 static struct clk_rcg2 disp_cc_mdss_esc0_clk_src = {
281 .cmd_rcgr = 0x80b4,
282 .mnd_width = 0,
283 .hid_width = 5,
284 .parent_map = disp_cc_parent_map_5,
285 .freq_tbl = ftbl_disp_cc_mdss_esc0_clk_src,
286 .clkr.hw.init = &(const struct clk_init_data) {
287 .name = "disp_cc_mdss_esc0_clk_src",
288 .parent_data = disp_cc_parent_data_5,
289 .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
290 .flags = CLK_SET_RATE_PARENT,
291 .ops = &clk_rcg2_ops,
292 },
293 };
294
295 static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src[] = {
296 F(19200000, P_BI_TCXO, 1, 0, 0),
297 F(85714286, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
298 F(100000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
299 F(200000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
300 F(342000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
301 F(402000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
302 F(535000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
303 F(600000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
304 F(630000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
305 { }
306 };
307
308 static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = {
309 .cmd_rcgr = 0x8068,
310 .mnd_width = 0,
311 .hid_width = 5,
312 .parent_map = disp_cc_parent_map_6,
313 .freq_tbl = ftbl_disp_cc_mdss_mdp_clk_src,
314 .clkr.hw.init = &(const struct clk_init_data) {
315 .name = "disp_cc_mdss_mdp_clk_src",
316 .parent_data = disp_cc_parent_data_6,
317 .num_parents = ARRAY_SIZE(disp_cc_parent_data_6),
318 .flags = CLK_SET_RATE_PARENT,
319 .ops = &clk_rcg2_shared_ops,
320 },
321 };
322
323 static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = {
324 .cmd_rcgr = 0x8050,
325 .mnd_width = 8,
326 .hid_width = 5,
327 .parent_map = disp_cc_parent_map_1,
328 .clkr.hw.init = &(const struct clk_init_data) {
329 .name = "disp_cc_mdss_pclk0_clk_src",
330 .parent_data = disp_cc_parent_data_1,
331 .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
332 .flags = CLK_SET_RATE_PARENT,
333 .ops = &clk_pixel_ops,
334 },
335 };
336
337 static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = {
338 .cmd_rcgr = 0x8080,
339 .mnd_width = 0,
340 .hid_width = 5,
341 .parent_map = disp_cc_parent_map_0,
342 .freq_tbl = ftbl_disp_cc_mdss_dptx0_aux_clk_src,
343 .clkr.hw.init = &(const struct clk_init_data) {
344 .name = "disp_cc_mdss_vsync_clk_src",
345 .parent_data = disp_cc_parent_data_0,
346 .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
347 .flags = CLK_SET_RATE_PARENT,
348 .ops = &clk_rcg2_ops,
349 },
350 };
351
352 static const struct freq_tbl ftbl_disp_cc_sleep_clk_src[] = {
353 F(32000, P_SLEEP_CLK, 1, 0, 0),
354 { }
355 };
356
357 static struct clk_rcg2 disp_cc_sleep_clk_src = {
358 .cmd_rcgr = 0xe054,
359 .mnd_width = 0,
360 .hid_width = 5,
361 .parent_map = disp_cc_parent_map_7,
362 .freq_tbl = ftbl_disp_cc_sleep_clk_src,
363 .clkr.hw.init = &(const struct clk_init_data) {
364 .name = "disp_cc_sleep_clk_src",
365 .parent_data = disp_cc_parent_data_7_ao,
366 .num_parents = ARRAY_SIZE(disp_cc_parent_data_7_ao),
367 .flags = CLK_SET_RATE_PARENT,
368 .ops = &clk_rcg2_ops,
369 },
370 };
371
372 static struct clk_rcg2 disp_cc_xo_clk_src = {
373 .cmd_rcgr = 0xe034,
374 .mnd_width = 0,
375 .hid_width = 5,
376 .parent_map = disp_cc_parent_map_0,
377 .freq_tbl = ftbl_disp_cc_mdss_dptx0_aux_clk_src,
378 .clkr.hw.init = &(const struct clk_init_data) {
379 .name = "disp_cc_xo_clk_src",
380 .parent_data = disp_cc_parent_data_0,
381 .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
382 .flags = CLK_SET_RATE_PARENT,
383 .ops = &clk_rcg2_ops,
384 },
385 };
386
387 static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = {
388 .reg = 0x80b0,
389 .shift = 0,
390 .width = 4,
391 .clkr.hw.init = &(const struct clk_init_data) {
392 .name = "disp_cc_mdss_byte0_div_clk_src",
393 .parent_hws = (const struct clk_hw*[]) {
394 &disp_cc_mdss_byte0_clk_src.clkr.hw,
395 },
396 .num_parents = 1,
397 .ops = &clk_regmap_div_ops,
398 },
399 };
400
401 static struct clk_regmap_div disp_cc_mdss_dptx0_link_div_clk_src = {
402 .reg = 0x80e4,
403 .shift = 0,
404 .width = 4,
405 .clkr.hw.init = &(const struct clk_init_data) {
406 .name = "disp_cc_mdss_dptx0_link_div_clk_src",
407 .parent_hws = (const struct clk_hw*[]) {
408 &disp_cc_mdss_dptx0_link_clk_src.clkr.hw,
409 },
410 .num_parents = 1,
411 .flags = CLK_SET_RATE_PARENT,
412 .ops = &clk_regmap_div_ro_ops,
413 },
414 };
415
416 static struct clk_branch disp_cc_mdss_accu_clk = {
417 .halt_reg = 0xe050,
418 .halt_check = BRANCH_HALT_VOTED,
419 .clkr = {
420 .enable_reg = 0xe050,
421 .enable_mask = BIT(0),
422 .hw.init = &(const struct clk_init_data) {
423 .name = "disp_cc_mdss_accu_clk",
424 .parent_hws = (const struct clk_hw*[]) {
425 &disp_cc_xo_clk_src.clkr.hw,
426 },
427 .num_parents = 1,
428 .flags = CLK_SET_RATE_PARENT,
429 .ops = &clk_branch2_ops,
430 },
431 },
432 };
433
434 static struct clk_branch disp_cc_mdss_ahb1_clk = {
435 .halt_reg = 0xa020,
436 .halt_check = BRANCH_HALT,
437 .clkr = {
438 .enable_reg = 0xa020,
439 .enable_mask = BIT(0),
440 .hw.init = &(const struct clk_init_data) {
441 .name = "disp_cc_mdss_ahb1_clk",
442 .parent_hws = (const struct clk_hw*[]) {
443 &disp_cc_mdss_ahb_clk_src.clkr.hw,
444 },
445 .num_parents = 1,
446 .flags = CLK_SET_RATE_PARENT,
447 .ops = &clk_branch2_ops,
448 },
449 },
450 };
451
452 static struct clk_branch disp_cc_mdss_ahb_clk = {
453 .halt_reg = 0x804c,
454 .halt_check = BRANCH_HALT,
455 .clkr = {
456 .enable_reg = 0x804c,
457 .enable_mask = BIT(0),
458 .hw.init = &(const struct clk_init_data) {
459 .name = "disp_cc_mdss_ahb_clk",
460 .parent_hws = (const struct clk_hw*[]) {
461 &disp_cc_mdss_ahb_clk_src.clkr.hw,
462 },
463 .num_parents = 1,
464 .flags = CLK_SET_RATE_PARENT,
465 .ops = &clk_branch2_ops,
466 },
467 },
468 };
469
470 static struct clk_branch disp_cc_mdss_byte0_clk = {
471 .halt_reg = 0x8024,
472 .halt_check = BRANCH_HALT,
473 .clkr = {
474 .enable_reg = 0x8024,
475 .enable_mask = BIT(0),
476 .hw.init = &(const struct clk_init_data) {
477 .name = "disp_cc_mdss_byte0_clk",
478 .parent_hws = (const struct clk_hw*[]) {
479 &disp_cc_mdss_byte0_clk_src.clkr.hw,
480 },
481 .num_parents = 1,
482 .flags = CLK_SET_RATE_PARENT,
483 .ops = &clk_branch2_ops,
484 },
485 },
486 };
487
488 static struct clk_branch disp_cc_mdss_byte0_intf_clk = {
489 .halt_reg = 0x8028,
490 .halt_check = BRANCH_HALT,
491 .clkr = {
492 .enable_reg = 0x8028,
493 .enable_mask = BIT(0),
494 .hw.init = &(const struct clk_init_data) {
495 .name = "disp_cc_mdss_byte0_intf_clk",
496 .parent_hws = (const struct clk_hw*[]) {
497 &disp_cc_mdss_byte0_div_clk_src.clkr.hw,
498 },
499 .num_parents = 1,
500 .flags = CLK_SET_RATE_PARENT,
501 .ops = &clk_branch2_ops,
502 },
503 },
504 };
505
506 static struct clk_branch disp_cc_mdss_dptx0_aux_clk = {
507 .halt_reg = 0x8048,
508 .halt_check = BRANCH_HALT,
509 .clkr = {
510 .enable_reg = 0x8048,
511 .enable_mask = BIT(0),
512 .hw.init = &(const struct clk_init_data) {
513 .name = "disp_cc_mdss_dptx0_aux_clk",
514 .parent_hws = (const struct clk_hw*[]) {
515 &disp_cc_mdss_dptx0_aux_clk_src.clkr.hw,
516 },
517 .num_parents = 1,
518 .flags = CLK_SET_RATE_PARENT,
519 .ops = &clk_branch2_ops,
520 },
521 },
522 };
523
524 static struct clk_branch disp_cc_mdss_dptx0_crypto_clk = {
525 .halt_reg = 0x803c,
526 .halt_check = BRANCH_HALT,
527 .clkr = {
528 .enable_reg = 0x803c,
529 .enable_mask = BIT(0),
530 .hw.init = &(const struct clk_init_data) {
531 .name = "disp_cc_mdss_dptx0_crypto_clk",
532 .parent_hws = (const struct clk_hw*[]) {
533 &disp_cc_mdss_dptx0_link_clk_src.clkr.hw,
534 },
535 .num_parents = 1,
536 .flags = CLK_SET_RATE_PARENT,
537 .ops = &clk_branch2_ops,
538 },
539 },
540 };
541
542 static struct clk_branch disp_cc_mdss_dptx0_link_clk = {
543 .halt_reg = 0x8030,
544 .halt_check = BRANCH_HALT,
545 .clkr = {
546 .enable_reg = 0x8030,
547 .enable_mask = BIT(0),
548 .hw.init = &(const struct clk_init_data) {
549 .name = "disp_cc_mdss_dptx0_link_clk",
550 .parent_hws = (const struct clk_hw*[]) {
551 &disp_cc_mdss_dptx0_link_clk_src.clkr.hw,
552 },
553 .num_parents = 1,
554 .flags = CLK_SET_RATE_PARENT,
555 .ops = &clk_branch2_ops,
556 },
557 },
558 };
559
560 static struct clk_branch disp_cc_mdss_dptx0_link_intf_clk = {
561 .halt_reg = 0x8038,
562 .halt_check = BRANCH_HALT,
563 .clkr = {
564 .enable_reg = 0x8038,
565 .enable_mask = BIT(0),
566 .hw.init = &(const struct clk_init_data) {
567 .name = "disp_cc_mdss_dptx0_link_intf_clk",
568 .parent_hws = (const struct clk_hw*[]) {
569 &disp_cc_mdss_dptx0_link_div_clk_src.clkr.hw,
570 },
571 .num_parents = 1,
572 .flags = CLK_SET_RATE_PARENT,
573 .ops = &clk_branch2_ops,
574 },
575 },
576 };
577
578 static struct clk_branch disp_cc_mdss_dptx0_pixel0_clk = {
579 .halt_reg = 0x8040,
580 .halt_check = BRANCH_HALT,
581 .clkr = {
582 .enable_reg = 0x8040,
583 .enable_mask = BIT(0),
584 .hw.init = &(const struct clk_init_data) {
585 .name = "disp_cc_mdss_dptx0_pixel0_clk",
586 .parent_hws = (const struct clk_hw*[]) {
587 &disp_cc_mdss_dptx0_pixel0_clk_src.clkr.hw,
588 },
589 .num_parents = 1,
590 .flags = CLK_SET_RATE_PARENT,
591 .ops = &clk_branch2_ops,
592 },
593 },
594 };
595
596 static struct clk_branch disp_cc_mdss_dptx0_pixel1_clk = {
597 .halt_reg = 0x8044,
598 .halt_check = BRANCH_HALT,
599 .clkr = {
600 .enable_reg = 0x8044,
601 .enable_mask = BIT(0),
602 .hw.init = &(const struct clk_init_data) {
603 .name = "disp_cc_mdss_dptx0_pixel1_clk",
604 .parent_hws = (const struct clk_hw*[]) {
605 &disp_cc_mdss_dptx0_pixel1_clk_src.clkr.hw,
606 },
607 .num_parents = 1,
608 .flags = CLK_SET_RATE_PARENT,
609 .ops = &clk_branch2_ops,
610 },
611 },
612 };
613
614 static struct clk_branch disp_cc_mdss_dptx0_usb_router_link_intf_clk = {
615 .halt_reg = 0x8034,
616 .halt_check = BRANCH_HALT,
617 .clkr = {
618 .enable_reg = 0x8034,
619 .enable_mask = BIT(0),
620 .hw.init = &(const struct clk_init_data) {
621 .name = "disp_cc_mdss_dptx0_usb_router_link_intf_clk",
622 .parent_hws = (const struct clk_hw*[]) {
623 &disp_cc_mdss_dptx0_link_div_clk_src.clkr.hw,
624 },
625 .num_parents = 1,
626 .flags = CLK_SET_RATE_PARENT,
627 .ops = &clk_branch2_ops,
628 },
629 },
630 };
631
632 static struct clk_branch disp_cc_mdss_esc0_clk = {
633 .halt_reg = 0x802c,
634 .halt_check = BRANCH_HALT,
635 .clkr = {
636 .enable_reg = 0x802c,
637 .enable_mask = BIT(0),
638 .hw.init = &(const struct clk_init_data) {
639 .name = "disp_cc_mdss_esc0_clk",
640 .parent_hws = (const struct clk_hw*[]) {
641 &disp_cc_mdss_esc0_clk_src.clkr.hw,
642 },
643 .num_parents = 1,
644 .flags = CLK_SET_RATE_PARENT,
645 .ops = &clk_branch2_ops,
646 },
647 },
648 };
649
650 static struct clk_branch disp_cc_mdss_mdp1_clk = {
651 .halt_reg = 0xa004,
652 .halt_check = BRANCH_HALT,
653 .clkr = {
654 .enable_reg = 0xa004,
655 .enable_mask = BIT(0),
656 .hw.init = &(const struct clk_init_data) {
657 .name = "disp_cc_mdss_mdp1_clk",
658 .parent_hws = (const struct clk_hw*[]) {
659 &disp_cc_mdss_mdp_clk_src.clkr.hw,
660 },
661 .num_parents = 1,
662 .flags = CLK_SET_RATE_PARENT,
663 .ops = &clk_branch2_ops,
664 },
665 },
666 };
667
668 static struct clk_branch disp_cc_mdss_mdp_clk = {
669 .halt_reg = 0x8008,
670 .halt_check = BRANCH_HALT,
671 .clkr = {
672 .enable_reg = 0x8008,
673 .enable_mask = BIT(0),
674 .hw.init = &(const struct clk_init_data) {
675 .name = "disp_cc_mdss_mdp_clk",
676 .parent_hws = (const struct clk_hw*[]) {
677 &disp_cc_mdss_mdp_clk_src.clkr.hw,
678 },
679 .num_parents = 1,
680 .flags = CLK_SET_RATE_PARENT,
681 .ops = &clk_branch2_ops,
682 },
683 },
684 };
685
686 static struct clk_branch disp_cc_mdss_mdp_lut1_clk = {
687 .halt_reg = 0xa010,
688 .halt_check = BRANCH_HALT,
689 .clkr = {
690 .enable_reg = 0xa010,
691 .enable_mask = BIT(0),
692 .hw.init = &(const struct clk_init_data) {
693 .name = "disp_cc_mdss_mdp_lut1_clk",
694 .parent_hws = (const struct clk_hw*[]) {
695 &disp_cc_mdss_mdp_clk_src.clkr.hw,
696 },
697 .num_parents = 1,
698 .flags = CLK_SET_RATE_PARENT,
699 .ops = &clk_branch2_ops,
700 },
701 },
702 };
703
704 static struct clk_branch disp_cc_mdss_mdp_lut_clk = {
705 .halt_reg = 0x8014,
706 .halt_check = BRANCH_HALT_VOTED,
707 .clkr = {
708 .enable_reg = 0x8014,
709 .enable_mask = BIT(0),
710 .hw.init = &(const struct clk_init_data) {
711 .name = "disp_cc_mdss_mdp_lut_clk",
712 .parent_hws = (const struct clk_hw*[]) {
713 &disp_cc_mdss_mdp_clk_src.clkr.hw,
714 },
715 .num_parents = 1,
716 .flags = CLK_SET_RATE_PARENT,
717 .ops = &clk_branch2_ops,
718 },
719 },
720 };
721
722 static struct clk_branch disp_cc_mdss_non_gdsc_ahb_clk = {
723 .halt_reg = 0xc004,
724 .halt_check = BRANCH_HALT_VOTED,
725 .clkr = {
726 .enable_reg = 0xc004,
727 .enable_mask = BIT(0),
728 .hw.init = &(const struct clk_init_data) {
729 .name = "disp_cc_mdss_non_gdsc_ahb_clk",
730 .parent_hws = (const struct clk_hw*[]) {
731 &disp_cc_mdss_ahb_clk_src.clkr.hw,
732 },
733 .num_parents = 1,
734 .flags = CLK_SET_RATE_PARENT,
735 .ops = &clk_branch2_ops,
736 },
737 },
738 };
739
740 static struct clk_branch disp_cc_mdss_pclk0_clk = {
741 .halt_reg = 0x8004,
742 .halt_check = BRANCH_HALT,
743 .clkr = {
744 .enable_reg = 0x8004,
745 .enable_mask = BIT(0),
746 .hw.init = &(const struct clk_init_data) {
747 .name = "disp_cc_mdss_pclk0_clk",
748 .parent_hws = (const struct clk_hw*[]) {
749 &disp_cc_mdss_pclk0_clk_src.clkr.hw,
750 },
751 .num_parents = 1,
752 .flags = CLK_SET_RATE_PARENT,
753 .ops = &clk_branch2_ops,
754 },
755 },
756 };
757
758 static struct clk_branch disp_cc_mdss_rscc_ahb_clk = {
759 .halt_reg = 0xc00c,
760 .halt_check = BRANCH_HALT,
761 .clkr = {
762 .enable_reg = 0xc00c,
763 .enable_mask = BIT(0),
764 .hw.init = &(const struct clk_init_data) {
765 .name = "disp_cc_mdss_rscc_ahb_clk",
766 .parent_hws = (const struct clk_hw*[]) {
767 &disp_cc_mdss_ahb_clk_src.clkr.hw,
768 },
769 .num_parents = 1,
770 .flags = CLK_SET_RATE_PARENT,
771 .ops = &clk_branch2_ops,
772 },
773 },
774 };
775
776 static struct clk_branch disp_cc_mdss_rscc_vsync_clk = {
777 .halt_reg = 0xc008,
778 .halt_check = BRANCH_HALT,
779 .clkr = {
780 .enable_reg = 0xc008,
781 .enable_mask = BIT(0),
782 .hw.init = &(const struct clk_init_data) {
783 .name = "disp_cc_mdss_rscc_vsync_clk",
784 .parent_hws = (const struct clk_hw*[]) {
785 &disp_cc_mdss_vsync_clk_src.clkr.hw,
786 },
787 .num_parents = 1,
788 .flags = CLK_SET_RATE_PARENT,
789 .ops = &clk_branch2_ops,
790 },
791 },
792 };
793
794 static struct clk_branch disp_cc_mdss_vsync1_clk = {
795 .halt_reg = 0xa01c,
796 .halt_check = BRANCH_HALT,
797 .clkr = {
798 .enable_reg = 0xa01c,
799 .enable_mask = BIT(0),
800 .hw.init = &(const struct clk_init_data) {
801 .name = "disp_cc_mdss_vsync1_clk",
802 .parent_hws = (const struct clk_hw*[]) {
803 &disp_cc_mdss_vsync_clk_src.clkr.hw,
804 },
805 .num_parents = 1,
806 .flags = CLK_SET_RATE_PARENT,
807 .ops = &clk_branch2_ops,
808 },
809 },
810 };
811
812 static struct clk_branch disp_cc_mdss_vsync_clk = {
813 .halt_reg = 0x8020,
814 .halt_check = BRANCH_HALT,
815 .clkr = {
816 .enable_reg = 0x8020,
817 .enable_mask = BIT(0),
818 .hw.init = &(const struct clk_init_data) {
819 .name = "disp_cc_mdss_vsync_clk",
820 .parent_hws = (const struct clk_hw*[]) {
821 &disp_cc_mdss_vsync_clk_src.clkr.hw,
822 },
823 .num_parents = 1,
824 .flags = CLK_SET_RATE_PARENT,
825 .ops = &clk_branch2_ops,
826 },
827 },
828 };
829
830 static struct gdsc disp_cc_mdss_core_gdsc = {
831 .gdscr = 0x9000,
832 .en_rest_wait_val = 0x2,
833 .en_few_wait_val = 0x2,
834 .clk_dis_wait_val = 0xf,
835 .pd = {
836 .name = "disp_cc_mdss_core_gdsc",
837 },
838 .pwrsts = PWRSTS_OFF_ON,
839 .flags = POLL_CFG_GDSCR | HW_CTRL | RETAIN_FF_ENABLE,
840 };
841
842 static struct gdsc disp_cc_mdss_core_int2_gdsc = {
843 .gdscr = 0xb000,
844 .en_rest_wait_val = 0x2,
845 .en_few_wait_val = 0x2,
846 .clk_dis_wait_val = 0xf,
847 .pd = {
848 .name = "disp_cc_mdss_core_int2_gdsc",
849 },
850 .pwrsts = PWRSTS_OFF_ON,
851 .flags = POLL_CFG_GDSCR | HW_CTRL | RETAIN_FF_ENABLE,
852 };
853
854 static struct clk_regmap *disp_cc_milos_clocks[] = {
855 [DISP_CC_MDSS_ACCU_CLK] = &disp_cc_mdss_accu_clk.clkr,
856 [DISP_CC_MDSS_AHB1_CLK] = &disp_cc_mdss_ahb1_clk.clkr,
857 [DISP_CC_MDSS_AHB_CLK] = &disp_cc_mdss_ahb_clk.clkr,
858 [DISP_CC_MDSS_AHB_CLK_SRC] = &disp_cc_mdss_ahb_clk_src.clkr,
859 [DISP_CC_MDSS_BYTE0_CLK] = &disp_cc_mdss_byte0_clk.clkr,
860 [DISP_CC_MDSS_BYTE0_CLK_SRC] = &disp_cc_mdss_byte0_clk_src.clkr,
861 [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC] = &disp_cc_mdss_byte0_div_clk_src.clkr,
862 [DISP_CC_MDSS_BYTE0_INTF_CLK] = &disp_cc_mdss_byte0_intf_clk.clkr,
863 [DISP_CC_MDSS_DPTX0_AUX_CLK] = &disp_cc_mdss_dptx0_aux_clk.clkr,
864 [DISP_CC_MDSS_DPTX0_AUX_CLK_SRC] = &disp_cc_mdss_dptx0_aux_clk_src.clkr,
865 [DISP_CC_MDSS_DPTX0_CRYPTO_CLK] = &disp_cc_mdss_dptx0_crypto_clk.clkr,
866 [DISP_CC_MDSS_DPTX0_LINK_CLK] = &disp_cc_mdss_dptx0_link_clk.clkr,
867 [DISP_CC_MDSS_DPTX0_LINK_CLK_SRC] = &disp_cc_mdss_dptx0_link_clk_src.clkr,
868 [DISP_CC_MDSS_DPTX0_LINK_DIV_CLK_SRC] = &disp_cc_mdss_dptx0_link_div_clk_src.clkr,
869 [DISP_CC_MDSS_DPTX0_LINK_INTF_CLK] = &disp_cc_mdss_dptx0_link_intf_clk.clkr,
870 [DISP_CC_MDSS_DPTX0_PIXEL0_CLK] = &disp_cc_mdss_dptx0_pixel0_clk.clkr,
871 [DISP_CC_MDSS_DPTX0_PIXEL0_CLK_SRC] = &disp_cc_mdss_dptx0_pixel0_clk_src.clkr,
872 [DISP_CC_MDSS_DPTX0_PIXEL1_CLK] = &disp_cc_mdss_dptx0_pixel1_clk.clkr,
873 [DISP_CC_MDSS_DPTX0_PIXEL1_CLK_SRC] = &disp_cc_mdss_dptx0_pixel1_clk_src.clkr,
874 [DISP_CC_MDSS_DPTX0_USB_ROUTER_LINK_INTF_CLK] =
875 &disp_cc_mdss_dptx0_usb_router_link_intf_clk.clkr,
876 [DISP_CC_MDSS_ESC0_CLK] = &disp_cc_mdss_esc0_clk.clkr,
877 [DISP_CC_MDSS_ESC0_CLK_SRC] = &disp_cc_mdss_esc0_clk_src.clkr,
878 [DISP_CC_MDSS_MDP1_CLK] = &disp_cc_mdss_mdp1_clk.clkr,
879 [DISP_CC_MDSS_MDP_CLK] = &disp_cc_mdss_mdp_clk.clkr,
880 [DISP_CC_MDSS_MDP_CLK_SRC] = &disp_cc_mdss_mdp_clk_src.clkr,
881 [DISP_CC_MDSS_MDP_LUT1_CLK] = &disp_cc_mdss_mdp_lut1_clk.clkr,
882 [DISP_CC_MDSS_MDP_LUT_CLK] = &disp_cc_mdss_mdp_lut_clk.clkr,
883 [DISP_CC_MDSS_NON_GDSC_AHB_CLK] = &disp_cc_mdss_non_gdsc_ahb_clk.clkr,
884 [DISP_CC_MDSS_PCLK0_CLK] = &disp_cc_mdss_pclk0_clk.clkr,
885 [DISP_CC_MDSS_PCLK0_CLK_SRC] = &disp_cc_mdss_pclk0_clk_src.clkr,
886 [DISP_CC_MDSS_RSCC_AHB_CLK] = &disp_cc_mdss_rscc_ahb_clk.clkr,
887 [DISP_CC_MDSS_RSCC_VSYNC_CLK] = &disp_cc_mdss_rscc_vsync_clk.clkr,
888 [DISP_CC_MDSS_VSYNC1_CLK] = &disp_cc_mdss_vsync1_clk.clkr,
889 [DISP_CC_MDSS_VSYNC_CLK] = &disp_cc_mdss_vsync_clk.clkr,
890 [DISP_CC_MDSS_VSYNC_CLK_SRC] = &disp_cc_mdss_vsync_clk_src.clkr,
891 [DISP_CC_PLL0] = &disp_cc_pll0.clkr,
892 [DISP_CC_SLEEP_CLK_SRC] = &disp_cc_sleep_clk_src.clkr,
893 [DISP_CC_XO_CLK_SRC] = &disp_cc_xo_clk_src.clkr,
894 };
895
896 static const struct qcom_reset_map disp_cc_milos_resets[] = {
897 [DISP_CC_MDSS_CORE_BCR] = { 0x8000 },
898 [DISP_CC_MDSS_CORE_INT2_BCR] = { 0xa000 },
899 [DISP_CC_MDSS_RSCC_BCR] = { 0xc000 },
900 };
901
902 static struct gdsc *disp_cc_milos_gdscs[] = {
903 [DISP_CC_MDSS_CORE_GDSC] = &disp_cc_mdss_core_gdsc,
904 [DISP_CC_MDSS_CORE_INT2_GDSC] = &disp_cc_mdss_core_int2_gdsc,
905 };
906
907 static struct clk_alpha_pll *disp_cc_milos_plls[] = {
908 &disp_cc_pll0,
909 };
910
911 static u32 disp_cc_milos_critical_cbcrs[] = {
912 0xe06c, /* DISP_CC_SLEEP_CLK */
913 0xe04c, /* DISP_CC_XO_CLK */
914 };
915
916 static const struct regmap_config disp_cc_milos_regmap_config = {
917 .reg_bits = 32,
918 .reg_stride = 4,
919 .val_bits = 32,
920 .max_register = 0x11008,
921 .fast_io = true,
922 };
923
924 static void disp_cc_milos_clk_regs_configure(struct device *dev, struct regmap *regmap)
925 {
926 /* Enable clock gating for MDP clocks */
927 regmap_update_bits(regmap, DISP_CC_MISC_CMD, 0x10, 0x10);
928 }
929
930
931 static struct qcom_cc_driver_data disp_cc_milos_driver_data = {
932 .alpha_plls = disp_cc_milos_plls,
933 .num_alpha_plls = ARRAY_SIZE(disp_cc_milos_plls),
934 .clk_cbcrs = disp_cc_milos_critical_cbcrs,
935 .num_clk_cbcrs = ARRAY_SIZE(disp_cc_milos_critical_cbcrs),
936 .clk_regs_configure = disp_cc_milos_clk_regs_configure,
937 };
938
939 static const struct qcom_cc_desc disp_cc_milos_desc = {
940 .config = &disp_cc_milos_regmap_config,
941 .clks = disp_cc_milos_clocks,
942 .num_clks = ARRAY_SIZE(disp_cc_milos_clocks),
943 .resets = disp_cc_milos_resets,
944 .num_resets = ARRAY_SIZE(disp_cc_milos_resets),
945 .gdscs = disp_cc_milos_gdscs,
946 .num_gdscs = ARRAY_SIZE(disp_cc_milos_gdscs),
947 .use_rpm = true,
948 .driver_data = &disp_cc_milos_driver_data,
949 };
950
951 static const struct of_device_id disp_cc_milos_match_table[] = {
952 { .compatible = "qcom,milos-dispcc" },
953 { }
954 };
955 MODULE_DEVICE_TABLE(of, disp_cc_milos_match_table);
956
957 static int disp_cc_milos_probe(struct platform_device *pdev)
958 {
959 return qcom_cc_probe(pdev, &disp_cc_milos_desc);
960 }
961
962 static struct platform_driver disp_cc_milos_driver = {
963 .probe = disp_cc_milos_probe,
964 .driver = {
965 .name = "disp_cc-milos",
966 .of_match_table = disp_cc_milos_match_table,
967 },
968 };
969
970 module_platform_driver(disp_cc_milos_driver);
971
972 MODULE_DESCRIPTION("QTI DISP_CC Milos Driver");
973 MODULE_LICENSE("GPL");