1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
6 #include <linux/clk-provider.h>
7 #include <linux/module.h>
8 #include <linux/platform_device.h>
9 #include <linux/regmap.h>
10 #include <linux/reset-controller.h>
12 #include <dt-bindings/clock/qcom,dispcc-sm8250.h>
14 #include "clk-alpha-pll.h"
15 #include "clk-branch.h"
17 #include "clk-regmap-divider.h"
25 P_CORE_BI_PLL_TEST_SE
,
26 P_DISP_CC_PLL0_OUT_MAIN
,
27 P_DISP_CC_PLL1_OUT_EVEN
,
28 P_DISP_CC_PLL1_OUT_MAIN
,
29 P_DP_PHY_PLL_LINK_CLK
,
30 P_DP_PHY_PLL_VCO_DIV_CLK
,
31 P_DPTX1_PHY_PLL_LINK_CLK
,
32 P_DPTX1_PHY_PLL_VCO_DIV_CLK
,
33 P_DPTX2_PHY_PLL_LINK_CLK
,
34 P_DPTX2_PHY_PLL_VCO_DIV_CLK
,
35 P_DSI0_PHY_PLL_OUT_BYTECLK
,
36 P_DSI0_PHY_PLL_OUT_DSICLK
,
37 P_DSI1_PHY_PLL_OUT_BYTECLK
,
38 P_DSI1_PHY_PLL_OUT_DSICLK
,
39 P_EDP_PHY_PLL_LINK_CLK
,
40 P_EDP_PHY_PLL_VCO_DIV_CLK
,
43 static struct pll_vco vco_table
[] = {
44 { 249600000, 2000000000, 0 },
47 static struct alpha_pll_config disp_cc_pll0_config
= {
50 .config_ctl_val
= 0x20485699,
51 .config_ctl_hi_val
= 0x00002261,
52 .config_ctl_hi1_val
= 0x329A699C,
53 .user_ctl_val
= 0x00000000,
54 .user_ctl_hi_val
= 0x00000805,
55 .user_ctl_hi1_val
= 0x00000000,
58 static struct clk_init_data disp_cc_pll0_init
= {
59 .name
= "disp_cc_pll0",
60 .parent_data
= &(const struct clk_parent_data
){
64 .ops
= &clk_alpha_pll_lucid_ops
,
67 static struct clk_alpha_pll disp_cc_pll0
= {
69 .vco_table
= vco_table
,
70 .num_vco
= ARRAY_SIZE(vco_table
),
71 .regs
= clk_alpha_pll_regs
[CLK_ALPHA_PLL_TYPE_LUCID
],
72 .clkr
.hw
.init
= &disp_cc_pll0_init
75 static struct alpha_pll_config disp_cc_pll1_config
= {
78 .config_ctl_val
= 0x20485699,
79 .config_ctl_hi_val
= 0x00002261,
80 .config_ctl_hi1_val
= 0x329A699C,
81 .user_ctl_val
= 0x00000000,
82 .user_ctl_hi_val
= 0x00000805,
83 .user_ctl_hi1_val
= 0x00000000,
86 static struct clk_init_data disp_cc_pll1_init
= {
87 .name
= "disp_cc_pll1",
88 .parent_data
= &(const struct clk_parent_data
){
92 .ops
= &clk_alpha_pll_lucid_ops
,
95 static struct clk_alpha_pll disp_cc_pll1
= {
97 .vco_table
= vco_table
,
98 .num_vco
= ARRAY_SIZE(vco_table
),
99 .regs
= clk_alpha_pll_regs
[CLK_ALPHA_PLL_TYPE_LUCID
],
100 .clkr
.hw
.init
= &disp_cc_pll1_init
103 static const struct parent_map disp_cc_parent_map_0
[] = {
105 { P_DP_PHY_PLL_LINK_CLK
, 1 },
106 { P_DP_PHY_PLL_VCO_DIV_CLK
, 2 },
109 static const struct clk_parent_data disp_cc_parent_data_0
[] = {
110 { .fw_name
= "bi_tcxo" },
111 { .fw_name
= "dp_phy_pll_link_clk" },
112 { .fw_name
= "dp_phy_pll_vco_div_clk" },
115 static const struct parent_map disp_cc_parent_map_1
[] = {
119 static const struct clk_parent_data disp_cc_parent_data_1
[] = {
120 { .fw_name
= "bi_tcxo" },
123 static const struct parent_map disp_cc_parent_map_2
[] = {
125 { P_DSI0_PHY_PLL_OUT_BYTECLK
, 1 },
126 { P_DSI1_PHY_PLL_OUT_BYTECLK
, 2 },
129 static const struct clk_parent_data disp_cc_parent_data_2
[] = {
130 { .fw_name
= "bi_tcxo" },
131 { .fw_name
= "dsi0_phy_pll_out_byteclk" },
132 { .fw_name
= "dsi1_phy_pll_out_byteclk" },
135 static const struct parent_map disp_cc_parent_map_3
[] = {
137 { P_DISP_CC_PLL1_OUT_MAIN
, 4 },
140 static const struct clk_parent_data disp_cc_parent_data_3
[] = {
141 { .fw_name
= "bi_tcxo" },
142 { .hw
= &disp_cc_pll1
.clkr
.hw
},
145 static const struct parent_map disp_cc_parent_map_5
[] = {
147 { P_DISP_CC_PLL0_OUT_MAIN
, 1 },
148 { P_DISP_CC_PLL1_OUT_MAIN
, 4 },
151 static const struct clk_parent_data disp_cc_parent_data_5
[] = {
152 { .fw_name
= "bi_tcxo" },
153 { .hw
= &disp_cc_pll0
.clkr
.hw
},
154 { .hw
= &disp_cc_pll1
.clkr
.hw
},
157 static const struct parent_map disp_cc_parent_map_6
[] = {
159 { P_DSI0_PHY_PLL_OUT_DSICLK
, 1 },
160 { P_DSI1_PHY_PLL_OUT_DSICLK
, 2 },
163 static const struct clk_parent_data disp_cc_parent_data_6
[] = {
164 { .fw_name
= "bi_tcxo" },
165 { .fw_name
= "dsi0_phy_pll_out_dsiclk" },
166 { .fw_name
= "dsi1_phy_pll_out_dsiclk" },
169 static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src
[] = {
170 F(19200000, P_BI_TCXO
, 1, 0, 0),
171 F(37500000, P_DISP_CC_PLL1_OUT_MAIN
, 16, 0, 0),
172 F(75000000, P_DISP_CC_PLL1_OUT_MAIN
, 8, 0, 0),
176 static struct clk_rcg2 disp_cc_mdss_ahb_clk_src
= {
180 .parent_map
= disp_cc_parent_map_3
,
181 .freq_tbl
= ftbl_disp_cc_mdss_ahb_clk_src
,
182 .clkr
.hw
.init
= &(struct clk_init_data
){
183 .name
= "disp_cc_mdss_ahb_clk_src",
184 .parent_data
= disp_cc_parent_data_3
,
185 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_3
),
186 .flags
= CLK_SET_RATE_PARENT
,
187 .ops
= &clk_rcg2_shared_ops
,
191 static const struct freq_tbl ftbl_disp_cc_mdss_byte0_clk_src
[] = {
192 F(19200000, P_BI_TCXO
, 1, 0, 0),
196 static struct clk_rcg2 disp_cc_mdss_byte0_clk_src
= {
200 .parent_map
= disp_cc_parent_map_2
,
201 .clkr
.hw
.init
= &(struct clk_init_data
){
202 .name
= "disp_cc_mdss_byte0_clk_src",
203 .parent_data
= disp_cc_parent_data_2
,
204 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_2
),
205 .flags
= CLK_SET_RATE_PARENT
,
206 .ops
= &clk_byte2_ops
,
210 static struct clk_rcg2 disp_cc_mdss_byte1_clk_src
= {
214 .parent_map
= disp_cc_parent_map_2
,
215 .clkr
.hw
.init
= &(struct clk_init_data
){
216 .name
= "disp_cc_mdss_byte1_clk_src",
217 .parent_data
= disp_cc_parent_data_2
,
218 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_2
),
219 .flags
= CLK_SET_RATE_PARENT
,
220 .ops
= &clk_byte2_ops
,
224 static struct clk_rcg2 disp_cc_mdss_dp_aux1_clk_src
= {
228 .parent_map
= disp_cc_parent_map_1
,
229 .freq_tbl
= ftbl_disp_cc_mdss_byte0_clk_src
,
230 .clkr
.hw
.init
= &(struct clk_init_data
){
231 .name
= "disp_cc_mdss_dp_aux1_clk_src",
232 .parent_data
= disp_cc_parent_data_1
,
233 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_1
),
234 .flags
= CLK_SET_RATE_PARENT
,
235 .ops
= &clk_rcg2_ops
,
239 static struct clk_rcg2 disp_cc_mdss_dp_aux_clk_src
= {
243 .parent_map
= disp_cc_parent_map_1
,
244 .freq_tbl
= ftbl_disp_cc_mdss_byte0_clk_src
,
245 .clkr
.hw
.init
= &(struct clk_init_data
){
246 .name
= "disp_cc_mdss_dp_aux_clk_src",
247 .parent_data
= disp_cc_parent_data_1
,
248 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_1
),
249 .flags
= CLK_SET_RATE_PARENT
,
250 .ops
= &clk_rcg2_ops
,
254 static const struct freq_tbl ftbl_disp_cc_mdss_dp_link1_clk_src
[] = {
255 F(162000000, P_DP_PHY_PLL_LINK_CLK
, 1, 0, 0),
256 F(270000000, P_DP_PHY_PLL_LINK_CLK
, 1, 0, 0),
257 F(540000000, P_DP_PHY_PLL_LINK_CLK
, 1, 0, 0),
258 F(810000000, P_DP_PHY_PLL_LINK_CLK
, 1, 0, 0),
262 static struct clk_rcg2 disp_cc_mdss_dp_link1_clk_src
= {
266 .parent_map
= disp_cc_parent_map_0
,
267 .freq_tbl
= ftbl_disp_cc_mdss_dp_link1_clk_src
,
268 .clkr
.hw
.init
= &(struct clk_init_data
){
269 .name
= "disp_cc_mdss_dp_link1_clk_src",
270 .parent_data
= disp_cc_parent_data_0
,
271 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_0
),
272 .ops
= &clk_rcg2_ops
,
276 static struct clk_rcg2 disp_cc_mdss_dp_link_clk_src
= {
280 .parent_map
= disp_cc_parent_map_0
,
281 .freq_tbl
= ftbl_disp_cc_mdss_dp_link1_clk_src
,
282 .clkr
.hw
.init
= &(struct clk_init_data
){
283 .name
= "disp_cc_mdss_dp_link_clk_src",
284 .parent_data
= disp_cc_parent_data_0
,
285 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_0
),
286 .ops
= &clk_rcg2_ops
,
290 static struct clk_rcg2 disp_cc_mdss_dp_pixel1_clk_src
= {
294 .parent_map
= disp_cc_parent_map_0
,
295 .clkr
.hw
.init
= &(struct clk_init_data
){
296 .name
= "disp_cc_mdss_dp_pixel1_clk_src",
297 .parent_data
= disp_cc_parent_data_0
,
298 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_0
),
303 static struct clk_rcg2 disp_cc_mdss_dp_pixel2_clk_src
= {
307 .parent_map
= disp_cc_parent_map_0
,
308 .clkr
.hw
.init
= &(struct clk_init_data
){
309 .name
= "disp_cc_mdss_dp_pixel2_clk_src",
310 .parent_data
= disp_cc_parent_data_0
,
311 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_0
),
316 static struct clk_rcg2 disp_cc_mdss_dp_pixel_clk_src
= {
320 .parent_map
= disp_cc_parent_map_0
,
321 .clkr
.hw
.init
= &(struct clk_init_data
){
322 .name
= "disp_cc_mdss_dp_pixel_clk_src",
323 .parent_data
= disp_cc_parent_data_0
,
324 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_0
),
329 static struct clk_rcg2 disp_cc_mdss_esc0_clk_src
= {
333 .parent_map
= disp_cc_parent_map_2
,
334 .freq_tbl
= ftbl_disp_cc_mdss_byte0_clk_src
,
335 .clkr
.hw
.init
= &(struct clk_init_data
){
336 .name
= "disp_cc_mdss_esc0_clk_src",
337 .parent_data
= disp_cc_parent_data_2
,
338 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_2
),
339 .flags
= CLK_SET_RATE_PARENT
,
340 .ops
= &clk_rcg2_ops
,
344 static struct clk_rcg2 disp_cc_mdss_esc1_clk_src
= {
348 .parent_map
= disp_cc_parent_map_2
,
349 .freq_tbl
= ftbl_disp_cc_mdss_byte0_clk_src
,
350 .clkr
.hw
.init
= &(struct clk_init_data
){
351 .name
= "disp_cc_mdss_esc1_clk_src",
352 .parent_data
= disp_cc_parent_data_2
,
353 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_2
),
354 .flags
= CLK_SET_RATE_PARENT
,
355 .ops
= &clk_rcg2_ops
,
359 static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src
[] = {
360 F(19200000, P_BI_TCXO
, 1, 0, 0),
361 F(85714286, P_DISP_CC_PLL1_OUT_MAIN
, 7, 0, 0),
362 F(100000000, P_DISP_CC_PLL1_OUT_MAIN
, 6, 0, 0),
363 F(150000000, P_DISP_CC_PLL1_OUT_MAIN
, 4, 0, 0),
364 F(200000000, P_DISP_CC_PLL1_OUT_MAIN
, 3, 0, 0),
365 F(300000000, P_DISP_CC_PLL1_OUT_MAIN
, 2, 0, 0),
366 F(345000000, P_DISP_CC_PLL0_OUT_MAIN
, 4, 0, 0),
367 F(460000000, P_DISP_CC_PLL0_OUT_MAIN
, 3, 0, 0),
371 static struct clk_rcg2 disp_cc_mdss_mdp_clk_src
= {
375 .parent_map
= disp_cc_parent_map_5
,
376 .freq_tbl
= ftbl_disp_cc_mdss_mdp_clk_src
,
377 .clkr
.hw
.init
= &(struct clk_init_data
){
378 .name
= "disp_cc_mdss_mdp_clk_src",
379 .parent_data
= disp_cc_parent_data_5
,
380 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_5
),
381 .flags
= CLK_SET_RATE_PARENT
,
382 .ops
= &clk_rcg2_shared_ops
,
386 static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src
= {
390 .parent_map
= disp_cc_parent_map_6
,
391 .clkr
.hw
.init
= &(struct clk_init_data
){
392 .name
= "disp_cc_mdss_pclk0_clk_src",
393 .parent_data
= disp_cc_parent_data_6
,
394 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_6
),
395 .flags
= CLK_SET_RATE_PARENT
,
396 .ops
= &clk_pixel_ops
,
400 static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src
= {
404 .parent_map
= disp_cc_parent_map_6
,
405 .clkr
.hw
.init
= &(struct clk_init_data
){
406 .name
= "disp_cc_mdss_pclk1_clk_src",
407 .parent_data
= disp_cc_parent_data_6
,
408 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_6
),
409 .flags
= CLK_SET_RATE_PARENT
,
410 .ops
= &clk_pixel_ops
,
414 static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src
[] = {
415 F(19200000, P_BI_TCXO
, 1, 0, 0),
416 F(200000000, P_DISP_CC_PLL1_OUT_MAIN
, 3, 0, 0),
417 F(300000000, P_DISP_CC_PLL1_OUT_MAIN
, 2, 0, 0),
418 F(345000000, P_DISP_CC_PLL0_OUT_MAIN
, 4, 0, 0),
419 F(460000000, P_DISP_CC_PLL0_OUT_MAIN
, 3, 0, 0),
423 static struct clk_rcg2 disp_cc_mdss_rot_clk_src
= {
427 .parent_map
= disp_cc_parent_map_5
,
428 .freq_tbl
= ftbl_disp_cc_mdss_rot_clk_src
,
429 .clkr
.hw
.init
= &(struct clk_init_data
){
430 .name
= "disp_cc_mdss_rot_clk_src",
431 .parent_data
= disp_cc_parent_data_5
,
432 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_5
),
433 .flags
= CLK_SET_RATE_PARENT
,
434 .ops
= &clk_rcg2_shared_ops
,
438 static struct clk_rcg2 disp_cc_mdss_vsync_clk_src
= {
442 .parent_map
= disp_cc_parent_map_1
,
443 .freq_tbl
= ftbl_disp_cc_mdss_byte0_clk_src
,
444 .clkr
.hw
.init
= &(struct clk_init_data
){
445 .name
= "disp_cc_mdss_vsync_clk_src",
446 .parent_data
= disp_cc_parent_data_1
,
447 .num_parents
= ARRAY_SIZE(disp_cc_parent_data_1
),
448 .flags
= CLK_SET_RATE_PARENT
,
449 .ops
= &clk_rcg2_ops
,
453 static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src
= {
457 .clkr
.hw
.init
= &(struct clk_init_data
) {
458 .name
= "disp_cc_mdss_byte0_div_clk_src",
459 .parent_data
= &(const struct clk_parent_data
){
460 .hw
= &disp_cc_mdss_byte0_clk_src
.clkr
.hw
,
463 .ops
= &clk_regmap_div_ops
,
468 static struct clk_regmap_div disp_cc_mdss_byte1_div_clk_src
= {
472 .clkr
.hw
.init
= &(struct clk_init_data
) {
473 .name
= "disp_cc_mdss_byte1_div_clk_src",
474 .parent_data
= &(const struct clk_parent_data
){
475 .hw
= &disp_cc_mdss_byte1_clk_src
.clkr
.hw
,
478 .ops
= &clk_regmap_div_ops
,
483 static struct clk_regmap_div disp_cc_mdss_dp_link1_div_clk_src
= {
487 .clkr
.hw
.init
= &(struct clk_init_data
) {
488 .name
= "disp_cc_mdss_dp_link1_div_clk_src",
489 .parent_data
= &(const struct clk_parent_data
){
490 .hw
= &disp_cc_mdss_dp_link1_clk_src
.clkr
.hw
,
493 .ops
= &clk_regmap_div_ro_ops
,
498 static struct clk_regmap_div disp_cc_mdss_dp_link_div_clk_src
= {
502 .clkr
.hw
.init
= &(struct clk_init_data
) {
503 .name
= "disp_cc_mdss_dp_link_div_clk_src",
504 .parent_data
= &(const struct clk_parent_data
){
505 .hw
= &disp_cc_mdss_dp_link_clk_src
.clkr
.hw
,
508 .ops
= &clk_regmap_div_ro_ops
,
512 static struct clk_branch disp_cc_mdss_ahb_clk
= {
514 .halt_check
= BRANCH_HALT
,
516 .enable_reg
= 0x2080,
517 .enable_mask
= BIT(0),
518 .hw
.init
= &(struct clk_init_data
){
519 .name
= "disp_cc_mdss_ahb_clk",
520 .parent_data
= &(const struct clk_parent_data
){
521 .hw
= &disp_cc_mdss_ahb_clk_src
.clkr
.hw
,
524 .flags
= CLK_SET_RATE_PARENT
,
525 .ops
= &clk_branch2_ops
,
530 static struct clk_branch disp_cc_mdss_byte0_clk
= {
532 .halt_check
= BRANCH_HALT
,
534 .enable_reg
= 0x2028,
535 .enable_mask
= BIT(0),
536 .hw
.init
= &(struct clk_init_data
){
537 .name
= "disp_cc_mdss_byte0_clk",
538 .parent_data
= &(const struct clk_parent_data
){
539 .hw
= &disp_cc_mdss_byte0_clk_src
.clkr
.hw
,
542 .flags
= CLK_SET_RATE_PARENT
,
543 .ops
= &clk_branch2_ops
,
548 static struct clk_branch disp_cc_mdss_byte0_intf_clk
= {
550 .halt_check
= BRANCH_HALT
,
552 .enable_reg
= 0x202c,
553 .enable_mask
= BIT(0),
554 .hw
.init
= &(struct clk_init_data
){
555 .name
= "disp_cc_mdss_byte0_intf_clk",
556 .parent_data
= &(const struct clk_parent_data
){
557 .hw
= &disp_cc_mdss_byte0_div_clk_src
.clkr
.hw
,
560 .flags
= CLK_SET_RATE_PARENT
,
561 .ops
= &clk_branch2_ops
,
566 static struct clk_branch disp_cc_mdss_byte1_clk
= {
568 .halt_check
= BRANCH_HALT
,
570 .enable_reg
= 0x2030,
571 .enable_mask
= BIT(0),
572 .hw
.init
= &(struct clk_init_data
){
573 .name
= "disp_cc_mdss_byte1_clk",
574 .parent_data
= &(const struct clk_parent_data
){
575 .hw
= &disp_cc_mdss_byte1_clk_src
.clkr
.hw
,
578 .flags
= CLK_SET_RATE_PARENT
,
579 .ops
= &clk_branch2_ops
,
584 static struct clk_branch disp_cc_mdss_byte1_intf_clk
= {
586 .halt_check
= BRANCH_HALT
,
588 .enable_reg
= 0x2034,
589 .enable_mask
= BIT(0),
590 .hw
.init
= &(struct clk_init_data
){
591 .name
= "disp_cc_mdss_byte1_intf_clk",
592 .parent_data
= &(const struct clk_parent_data
){
593 .hw
= &disp_cc_mdss_byte1_div_clk_src
.clkr
.hw
,
596 .flags
= CLK_SET_RATE_PARENT
,
597 .ops
= &clk_branch2_ops
,
602 static struct clk_branch disp_cc_mdss_dp_aux1_clk
= {
604 .halt_check
= BRANCH_HALT
,
606 .enable_reg
= 0x2068,
607 .enable_mask
= BIT(0),
608 .hw
.init
= &(struct clk_init_data
){
609 .name
= "disp_cc_mdss_dp_aux1_clk",
610 .parent_data
= &(const struct clk_parent_data
){
611 .hw
= &disp_cc_mdss_dp_aux1_clk_src
.clkr
.hw
,
614 .flags
= CLK_SET_RATE_PARENT
,
615 .ops
= &clk_branch2_ops
,
620 static struct clk_branch disp_cc_mdss_dp_aux_clk
= {
622 .halt_check
= BRANCH_HALT
,
624 .enable_reg
= 0x2054,
625 .enable_mask
= BIT(0),
626 .hw
.init
= &(struct clk_init_data
){
627 .name
= "disp_cc_mdss_dp_aux_clk",
628 .parent_data
= &(const struct clk_parent_data
){
629 .hw
= &disp_cc_mdss_dp_aux_clk_src
.clkr
.hw
,
632 .flags
= CLK_SET_RATE_PARENT
,
633 .ops
= &clk_branch2_ops
,
638 static struct clk_branch disp_cc_mdss_dp_link1_clk
= {
640 .halt_check
= BRANCH_HALT
,
642 .enable_reg
= 0x205c,
643 .enable_mask
= BIT(0),
644 .hw
.init
= &(struct clk_init_data
){
645 .name
= "disp_cc_mdss_dp_link1_clk",
646 .parent_data
= &(const struct clk_parent_data
){
647 .hw
= &disp_cc_mdss_dp_link1_clk_src
.clkr
.hw
,
650 .flags
= CLK_SET_RATE_PARENT
,
651 .ops
= &clk_branch2_ops
,
656 static struct clk_branch disp_cc_mdss_dp_link1_intf_clk
= {
658 .halt_check
= BRANCH_HALT
,
660 .enable_reg
= 0x2060,
661 .enable_mask
= BIT(0),
662 .hw
.init
= &(struct clk_init_data
){
663 .name
= "disp_cc_mdss_dp_link1_intf_clk",
664 .parent_data
= &(const struct clk_parent_data
){
665 .hw
= &disp_cc_mdss_dp_link1_div_clk_src
.clkr
.hw
,
668 .ops
= &clk_branch2_ops
,
673 static struct clk_branch disp_cc_mdss_dp_link_clk
= {
675 .halt_check
= BRANCH_HALT
,
677 .enable_reg
= 0x2040,
678 .enable_mask
= BIT(0),
679 .hw
.init
= &(struct clk_init_data
){
680 .name
= "disp_cc_mdss_dp_link_clk",
681 .parent_data
= &(const struct clk_parent_data
){
682 .hw
= &disp_cc_mdss_dp_link_clk_src
.clkr
.hw
,
685 .flags
= CLK_SET_RATE_PARENT
,
686 .ops
= &clk_branch2_ops
,
691 static struct clk_branch disp_cc_mdss_dp_link_intf_clk
= {
693 .halt_check
= BRANCH_HALT
,
695 .enable_reg
= 0x2044,
696 .enable_mask
= BIT(0),
697 .hw
.init
= &(struct clk_init_data
){
698 .name
= "disp_cc_mdss_dp_link_intf_clk",
699 .parent_data
= &(const struct clk_parent_data
){
700 .hw
= &disp_cc_mdss_dp_link_div_clk_src
.clkr
.hw
,
703 .ops
= &clk_branch2_ops
,
708 static struct clk_branch disp_cc_mdss_dp_pixel1_clk
= {
710 .halt_check
= BRANCH_HALT
,
712 .enable_reg
= 0x2050,
713 .enable_mask
= BIT(0),
714 .hw
.init
= &(struct clk_init_data
){
715 .name
= "disp_cc_mdss_dp_pixel1_clk",
716 .parent_data
= &(const struct clk_parent_data
){
717 .hw
= &disp_cc_mdss_dp_pixel1_clk_src
.clkr
.hw
,
720 .flags
= CLK_SET_RATE_PARENT
,
721 .ops
= &clk_branch2_ops
,
726 static struct clk_branch disp_cc_mdss_dp_pixel2_clk
= {
728 .halt_check
= BRANCH_HALT
,
730 .enable_reg
= 0x2058,
731 .enable_mask
= BIT(0),
732 .hw
.init
= &(struct clk_init_data
){
733 .name
= "disp_cc_mdss_dp_pixel2_clk",
734 .parent_data
= &(const struct clk_parent_data
){
735 .hw
= &disp_cc_mdss_dp_pixel2_clk_src
.clkr
.hw
,
738 .flags
= CLK_SET_RATE_PARENT
,
739 .ops
= &clk_branch2_ops
,
744 static struct clk_branch disp_cc_mdss_dp_pixel_clk
= {
746 .halt_check
= BRANCH_HALT
,
748 .enable_reg
= 0x204c,
749 .enable_mask
= BIT(0),
750 .hw
.init
= &(struct clk_init_data
){
751 .name
= "disp_cc_mdss_dp_pixel_clk",
752 .parent_data
= &(const struct clk_parent_data
){
753 .hw
= &disp_cc_mdss_dp_pixel_clk_src
.clkr
.hw
,
756 .flags
= CLK_SET_RATE_PARENT
,
757 .ops
= &clk_branch2_ops
,
762 static struct clk_branch disp_cc_mdss_esc0_clk
= {
764 .halt_check
= BRANCH_HALT
,
766 .enable_reg
= 0x2038,
767 .enable_mask
= BIT(0),
768 .hw
.init
= &(struct clk_init_data
){
769 .name
= "disp_cc_mdss_esc0_clk",
770 .parent_data
= &(const struct clk_parent_data
){
771 .hw
= &disp_cc_mdss_esc0_clk_src
.clkr
.hw
,
774 .flags
= CLK_SET_RATE_PARENT
,
775 .ops
= &clk_branch2_ops
,
780 static struct clk_branch disp_cc_mdss_esc1_clk
= {
782 .halt_check
= BRANCH_HALT
,
784 .enable_reg
= 0x203c,
785 .enable_mask
= BIT(0),
786 .hw
.init
= &(struct clk_init_data
){
787 .name
= "disp_cc_mdss_esc1_clk",
788 .parent_data
= &(const struct clk_parent_data
){
789 .hw
= &disp_cc_mdss_esc1_clk_src
.clkr
.hw
,
792 .flags
= CLK_SET_RATE_PARENT
,
793 .ops
= &clk_branch2_ops
,
798 static struct clk_branch disp_cc_mdss_mdp_clk
= {
800 .halt_check
= BRANCH_HALT
,
802 .enable_reg
= 0x200c,
803 .enable_mask
= BIT(0),
804 .hw
.init
= &(struct clk_init_data
){
805 .name
= "disp_cc_mdss_mdp_clk",
806 .parent_data
= &(const struct clk_parent_data
){
807 .hw
= &disp_cc_mdss_mdp_clk_src
.clkr
.hw
,
810 .flags
= CLK_SET_RATE_PARENT
,
811 .ops
= &clk_branch2_ops
,
816 static struct clk_branch disp_cc_mdss_mdp_lut_clk
= {
818 .halt_check
= BRANCH_VOTED
,
820 .enable_reg
= 0x201c,
821 .enable_mask
= BIT(0),
822 .hw
.init
= &(struct clk_init_data
){
823 .name
= "disp_cc_mdss_mdp_lut_clk",
824 .parent_data
= &(const struct clk_parent_data
){
825 .hw
= &disp_cc_mdss_mdp_clk_src
.clkr
.hw
,
828 .ops
= &clk_branch2_ops
,
833 static struct clk_branch disp_cc_mdss_non_gdsc_ahb_clk
= {
835 .halt_check
= BRANCH_VOTED
,
837 .enable_reg
= 0x4004,
838 .enable_mask
= BIT(0),
839 .hw
.init
= &(struct clk_init_data
){
840 .name
= "disp_cc_mdss_non_gdsc_ahb_clk",
841 .parent_data
= &(const struct clk_parent_data
){
842 .hw
= &disp_cc_mdss_ahb_clk_src
.clkr
.hw
,
845 .flags
= CLK_SET_RATE_PARENT
,
846 .ops
= &clk_branch2_ops
,
851 static struct clk_branch disp_cc_mdss_pclk0_clk
= {
853 .halt_check
= BRANCH_HALT
,
855 .enable_reg
= 0x2004,
856 .enable_mask
= BIT(0),
857 .hw
.init
= &(struct clk_init_data
){
858 .name
= "disp_cc_mdss_pclk0_clk",
859 .parent_data
= &(const struct clk_parent_data
){
860 .hw
= &disp_cc_mdss_pclk0_clk_src
.clkr
.hw
,
863 .flags
= CLK_SET_RATE_PARENT
,
864 .ops
= &clk_branch2_ops
,
869 static struct clk_branch disp_cc_mdss_pclk1_clk
= {
871 .halt_check
= BRANCH_HALT
,
873 .enable_reg
= 0x2008,
874 .enable_mask
= BIT(0),
875 .hw
.init
= &(struct clk_init_data
){
876 .name
= "disp_cc_mdss_pclk1_clk",
877 .parent_data
= &(const struct clk_parent_data
){
878 .hw
= &disp_cc_mdss_pclk1_clk_src
.clkr
.hw
,
881 .flags
= CLK_SET_RATE_PARENT
,
882 .ops
= &clk_branch2_ops
,
887 static struct clk_branch disp_cc_mdss_rot_clk
= {
889 .halt_check
= BRANCH_HALT
,
891 .enable_reg
= 0x2014,
892 .enable_mask
= BIT(0),
893 .hw
.init
= &(struct clk_init_data
){
894 .name
= "disp_cc_mdss_rot_clk",
895 .parent_data
= &(const struct clk_parent_data
){
896 .hw
= &disp_cc_mdss_rot_clk_src
.clkr
.hw
,
899 .flags
= CLK_SET_RATE_PARENT
,
900 .ops
= &clk_branch2_ops
,
905 static struct clk_branch disp_cc_mdss_rscc_ahb_clk
= {
907 .halt_check
= BRANCH_HALT
,
909 .enable_reg
= 0x400c,
910 .enable_mask
= BIT(0),
911 .hw
.init
= &(struct clk_init_data
){
912 .name
= "disp_cc_mdss_rscc_ahb_clk",
913 .parent_data
= &(const struct clk_parent_data
){
914 .hw
= &disp_cc_mdss_ahb_clk_src
.clkr
.hw
,
917 .flags
= CLK_SET_RATE_PARENT
,
918 .ops
= &clk_branch2_ops
,
923 static struct clk_branch disp_cc_mdss_rscc_vsync_clk
= {
925 .halt_check
= BRANCH_HALT
,
927 .enable_reg
= 0x4008,
928 .enable_mask
= BIT(0),
929 .hw
.init
= &(struct clk_init_data
){
930 .name
= "disp_cc_mdss_rscc_vsync_clk",
931 .parent_data
= &(const struct clk_parent_data
){
932 .hw
= &disp_cc_mdss_vsync_clk_src
.clkr
.hw
,
935 .flags
= CLK_SET_RATE_PARENT
,
936 .ops
= &clk_branch2_ops
,
941 static struct clk_branch disp_cc_mdss_vsync_clk
= {
943 .halt_check
= BRANCH_HALT
,
945 .enable_reg
= 0x2024,
946 .enable_mask
= BIT(0),
947 .hw
.init
= &(struct clk_init_data
){
948 .name
= "disp_cc_mdss_vsync_clk",
949 .parent_data
= &(const struct clk_parent_data
){
950 .hw
= &disp_cc_mdss_vsync_clk_src
.clkr
.hw
,
953 .flags
= CLK_SET_RATE_PARENT
,
954 .ops
= &clk_branch2_ops
,
959 static struct gdsc mdss_gdsc
= {
964 .pwrsts
= PWRSTS_OFF_ON
,
969 static struct clk_regmap
*disp_cc_sm8250_clocks
[] = {
970 [DISP_CC_MDSS_AHB_CLK
] = &disp_cc_mdss_ahb_clk
.clkr
,
971 [DISP_CC_MDSS_AHB_CLK_SRC
] = &disp_cc_mdss_ahb_clk_src
.clkr
,
972 [DISP_CC_MDSS_BYTE0_CLK
] = &disp_cc_mdss_byte0_clk
.clkr
,
973 [DISP_CC_MDSS_BYTE0_CLK_SRC
] = &disp_cc_mdss_byte0_clk_src
.clkr
,
974 [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC
] = &disp_cc_mdss_byte0_div_clk_src
.clkr
,
975 [DISP_CC_MDSS_BYTE0_INTF_CLK
] = &disp_cc_mdss_byte0_intf_clk
.clkr
,
976 [DISP_CC_MDSS_BYTE1_CLK
] = &disp_cc_mdss_byte1_clk
.clkr
,
977 [DISP_CC_MDSS_BYTE1_CLK_SRC
] = &disp_cc_mdss_byte1_clk_src
.clkr
,
978 [DISP_CC_MDSS_BYTE1_DIV_CLK_SRC
] = &disp_cc_mdss_byte1_div_clk_src
.clkr
,
979 [DISP_CC_MDSS_BYTE1_INTF_CLK
] = &disp_cc_mdss_byte1_intf_clk
.clkr
,
980 [DISP_CC_MDSS_DP_AUX1_CLK
] = &disp_cc_mdss_dp_aux1_clk
.clkr
,
981 [DISP_CC_MDSS_DP_AUX1_CLK_SRC
] = &disp_cc_mdss_dp_aux1_clk_src
.clkr
,
982 [DISP_CC_MDSS_DP_AUX_CLK
] = &disp_cc_mdss_dp_aux_clk
.clkr
,
983 [DISP_CC_MDSS_DP_AUX_CLK_SRC
] = &disp_cc_mdss_dp_aux_clk_src
.clkr
,
984 [DISP_CC_MDSS_DP_LINK1_CLK
] = &disp_cc_mdss_dp_link1_clk
.clkr
,
985 [DISP_CC_MDSS_DP_LINK1_CLK_SRC
] = &disp_cc_mdss_dp_link1_clk_src
.clkr
,
986 [DISP_CC_MDSS_DP_LINK1_DIV_CLK_SRC
] = &disp_cc_mdss_dp_link1_div_clk_src
.clkr
,
987 [DISP_CC_MDSS_DP_LINK1_INTF_CLK
] = &disp_cc_mdss_dp_link1_intf_clk
.clkr
,
988 [DISP_CC_MDSS_DP_LINK_CLK
] = &disp_cc_mdss_dp_link_clk
.clkr
,
989 [DISP_CC_MDSS_DP_LINK_CLK_SRC
] = &disp_cc_mdss_dp_link_clk_src
.clkr
,
990 [DISP_CC_MDSS_DP_LINK_DIV_CLK_SRC
] = &disp_cc_mdss_dp_link_div_clk_src
.clkr
,
991 [DISP_CC_MDSS_DP_LINK_INTF_CLK
] = &disp_cc_mdss_dp_link_intf_clk
.clkr
,
992 [DISP_CC_MDSS_DP_PIXEL1_CLK
] = &disp_cc_mdss_dp_pixel1_clk
.clkr
,
993 [DISP_CC_MDSS_DP_PIXEL1_CLK_SRC
] = &disp_cc_mdss_dp_pixel1_clk_src
.clkr
,
994 [DISP_CC_MDSS_DP_PIXEL2_CLK
] = &disp_cc_mdss_dp_pixel2_clk
.clkr
,
995 [DISP_CC_MDSS_DP_PIXEL2_CLK_SRC
] = &disp_cc_mdss_dp_pixel2_clk_src
.clkr
,
996 [DISP_CC_MDSS_DP_PIXEL_CLK
] = &disp_cc_mdss_dp_pixel_clk
.clkr
,
997 [DISP_CC_MDSS_DP_PIXEL_CLK_SRC
] = &disp_cc_mdss_dp_pixel_clk_src
.clkr
,
998 [DISP_CC_MDSS_ESC0_CLK
] = &disp_cc_mdss_esc0_clk
.clkr
,
999 [DISP_CC_MDSS_ESC0_CLK_SRC
] = &disp_cc_mdss_esc0_clk_src
.clkr
,
1000 [DISP_CC_MDSS_ESC1_CLK
] = &disp_cc_mdss_esc1_clk
.clkr
,
1001 [DISP_CC_MDSS_ESC1_CLK_SRC
] = &disp_cc_mdss_esc1_clk_src
.clkr
,
1002 [DISP_CC_MDSS_MDP_CLK
] = &disp_cc_mdss_mdp_clk
.clkr
,
1003 [DISP_CC_MDSS_MDP_CLK_SRC
] = &disp_cc_mdss_mdp_clk_src
.clkr
,
1004 [DISP_CC_MDSS_MDP_LUT_CLK
] = &disp_cc_mdss_mdp_lut_clk
.clkr
,
1005 [DISP_CC_MDSS_NON_GDSC_AHB_CLK
] = &disp_cc_mdss_non_gdsc_ahb_clk
.clkr
,
1006 [DISP_CC_MDSS_PCLK0_CLK
] = &disp_cc_mdss_pclk0_clk
.clkr
,
1007 [DISP_CC_MDSS_PCLK0_CLK_SRC
] = &disp_cc_mdss_pclk0_clk_src
.clkr
,
1008 [DISP_CC_MDSS_PCLK1_CLK
] = &disp_cc_mdss_pclk1_clk
.clkr
,
1009 [DISP_CC_MDSS_PCLK1_CLK_SRC
] = &disp_cc_mdss_pclk1_clk_src
.clkr
,
1010 [DISP_CC_MDSS_ROT_CLK
] = &disp_cc_mdss_rot_clk
.clkr
,
1011 [DISP_CC_MDSS_ROT_CLK_SRC
] = &disp_cc_mdss_rot_clk_src
.clkr
,
1012 [DISP_CC_MDSS_RSCC_AHB_CLK
] = &disp_cc_mdss_rscc_ahb_clk
.clkr
,
1013 [DISP_CC_MDSS_RSCC_VSYNC_CLK
] = &disp_cc_mdss_rscc_vsync_clk
.clkr
,
1014 [DISP_CC_MDSS_VSYNC_CLK
] = &disp_cc_mdss_vsync_clk
.clkr
,
1015 [DISP_CC_MDSS_VSYNC_CLK_SRC
] = &disp_cc_mdss_vsync_clk_src
.clkr
,
1016 [DISP_CC_PLL0
] = &disp_cc_pll0
.clkr
,
1017 [DISP_CC_PLL1
] = &disp_cc_pll1
.clkr
,
1020 static const struct qcom_reset_map disp_cc_sm8250_resets
[] = {
1021 [DISP_CC_MDSS_CORE_BCR
] = { 0x2000 },
1022 [DISP_CC_MDSS_RSCC_BCR
] = { 0x4000 },
1025 static struct gdsc
*disp_cc_sm8250_gdscs
[] = {
1026 [MDSS_GDSC
] = &mdss_gdsc
,
1029 static const struct regmap_config disp_cc_sm8250_regmap_config
= {
1033 .max_register
= 0x10000,
1037 static const struct qcom_cc_desc disp_cc_sm8250_desc
= {
1038 .config
= &disp_cc_sm8250_regmap_config
,
1039 .clks
= disp_cc_sm8250_clocks
,
1040 .num_clks
= ARRAY_SIZE(disp_cc_sm8250_clocks
),
1041 .resets
= disp_cc_sm8250_resets
,
1042 .num_resets
= ARRAY_SIZE(disp_cc_sm8250_resets
),
1043 .gdscs
= disp_cc_sm8250_gdscs
,
1044 .num_gdscs
= ARRAY_SIZE(disp_cc_sm8250_gdscs
),
1047 static const struct of_device_id disp_cc_sm8250_match_table
[] = {
1048 { .compatible
= "qcom,sm8150-dispcc" },
1049 { .compatible
= "qcom,sm8250-dispcc" },
1052 MODULE_DEVICE_TABLE(of
, disp_cc_sm8250_match_table
);
1054 static int disp_cc_sm8250_probe(struct platform_device
*pdev
)
1056 struct regmap
*regmap
;
1058 regmap
= qcom_cc_map(pdev
, &disp_cc_sm8250_desc
);
1060 return PTR_ERR(regmap
);
1062 /* note: trion == lucid, except for the prepare() op */
1063 BUILD_BUG_ON(CLK_ALPHA_PLL_TYPE_TRION
!= CLK_ALPHA_PLL_TYPE_LUCID
);
1064 if (of_device_is_compatible(pdev
->dev
.of_node
, "qcom,sm8150-dispcc")) {
1065 disp_cc_pll0_config
.config_ctl_hi_val
= 0x00002267;
1066 disp_cc_pll0_config
.config_ctl_hi1_val
= 0x00000024;
1067 disp_cc_pll0_config
.user_ctl_hi1_val
= 0x000000D0;
1068 disp_cc_pll0_init
.ops
= &clk_alpha_pll_trion_ops
;
1069 disp_cc_pll1_config
.config_ctl_hi_val
= 0x00002267;
1070 disp_cc_pll1_config
.config_ctl_hi1_val
= 0x00000024;
1071 disp_cc_pll1_config
.user_ctl_hi1_val
= 0x000000D0;
1072 disp_cc_pll1_init
.ops
= &clk_alpha_pll_trion_ops
;
1075 clk_lucid_pll_configure(&disp_cc_pll0
, regmap
, &disp_cc_pll0_config
);
1076 clk_lucid_pll_configure(&disp_cc_pll1
, regmap
, &disp_cc_pll1_config
);
1078 /* Enable clock gating for MDP clocks */
1079 regmap_update_bits(regmap
, 0x8000, 0x10, 0x10);
1081 /* DISP_CC_XO_CLK always-on */
1082 regmap_update_bits(regmap
, 0x605c, BIT(0), BIT(0));
1084 return qcom_cc_really_probe(pdev
, &disp_cc_sm8250_desc
, regmap
);
1087 static struct platform_driver disp_cc_sm8250_driver
= {
1088 .probe
= disp_cc_sm8250_probe
,
1090 .name
= "disp_cc-sm8250",
1091 .of_match_table
= disp_cc_sm8250_match_table
,
1095 static int __init
disp_cc_sm8250_init(void)
1097 return platform_driver_register(&disp_cc_sm8250_driver
);
1099 subsys_initcall(disp_cc_sm8250_init
);
1101 static void __exit
disp_cc_sm8250_exit(void)
1103 platform_driver_unregister(&disp_cc_sm8250_driver
);
1105 module_exit(disp_cc_sm8250_exit
);
1107 MODULE_DESCRIPTION("QTI DISPCC SM8250 Driver");
1108 MODULE_LICENSE("GPL v2");