Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2018-2020, 2022, The Linux Foundation. All rights reserved.
0004  */
0005 
0006 #include <linux/clk-provider.h>
0007 #include <linux/module.h>
0008 #include <linux/platform_device.h>
0009 #include <linux/pm_runtime.h>
0010 #include <linux/regmap.h>
0011 #include <linux/reset-controller.h>
0012 
0013 #include <dt-bindings/clock/qcom,dispcc-sm8250.h>
0014 
0015 #include "clk-alpha-pll.h"
0016 #include "clk-branch.h"
0017 #include "clk-rcg.h"
0018 #include "clk-regmap-divider.h"
0019 #include "common.h"
0020 #include "gdsc.h"
0021 #include "reset.h"
0022 
0023 enum {
0024     P_BI_TCXO,
0025     P_DISP_CC_PLL0_OUT_MAIN,
0026     P_DISP_CC_PLL1_OUT_EVEN,
0027     P_DISP_CC_PLL1_OUT_MAIN,
0028     P_DP_PHY_PLL_LINK_CLK,
0029     P_DP_PHY_PLL_VCO_DIV_CLK,
0030     P_DPTX1_PHY_PLL_LINK_CLK,
0031     P_DPTX1_PHY_PLL_VCO_DIV_CLK,
0032     P_DPTX2_PHY_PLL_LINK_CLK,
0033     P_DPTX2_PHY_PLL_VCO_DIV_CLK,
0034     P_EDP_PHY_PLL_LINK_CLK,
0035     P_EDP_PHY_PLL_VCO_DIV_CLK,
0036     P_DSI0_PHY_PLL_OUT_BYTECLK,
0037     P_DSI0_PHY_PLL_OUT_DSICLK,
0038     P_DSI1_PHY_PLL_OUT_BYTECLK,
0039     P_DSI1_PHY_PLL_OUT_DSICLK,
0040 };
0041 
0042 static struct pll_vco vco_table[] = {
0043     { 249600000, 2000000000, 0 },
0044 };
0045 
0046 static struct pll_vco lucid_5lpe_vco[] = {
0047     { 249600000, 1750000000, 0 },
0048 };
0049 
0050 static struct alpha_pll_config disp_cc_pll0_config = {
0051     .l = 0x47,
0052     .alpha = 0xE000,
0053     .config_ctl_val = 0x20485699,
0054     .config_ctl_hi_val = 0x00002261,
0055     .config_ctl_hi1_val = 0x329A699C,
0056     .user_ctl_val = 0x00000000,
0057     .user_ctl_hi_val = 0x00000805,
0058     .user_ctl_hi1_val = 0x00000000,
0059 };
0060 
0061 static struct clk_init_data disp_cc_pll0_init = {
0062     .name = "disp_cc_pll0",
0063     .parent_data = &(const struct clk_parent_data){
0064         .fw_name = "bi_tcxo",
0065     },
0066     .num_parents = 1,
0067     .ops = &clk_alpha_pll_lucid_ops,
0068 };
0069 
0070 static struct clk_alpha_pll disp_cc_pll0 = {
0071     .offset = 0x0,
0072     .vco_table = vco_table,
0073     .num_vco = ARRAY_SIZE(vco_table),
0074     .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
0075     .clkr.hw.init = &disp_cc_pll0_init
0076 };
0077 
0078 static struct alpha_pll_config disp_cc_pll1_config = {
0079     .l = 0x1F,
0080     .alpha = 0x4000,
0081     .config_ctl_val = 0x20485699,
0082     .config_ctl_hi_val = 0x00002261,
0083     .config_ctl_hi1_val = 0x329A699C,
0084     .user_ctl_val = 0x00000000,
0085     .user_ctl_hi_val = 0x00000805,
0086     .user_ctl_hi1_val = 0x00000000,
0087 };
0088 
0089 static struct clk_init_data disp_cc_pll1_init = {
0090     .name = "disp_cc_pll1",
0091     .parent_data = &(const struct clk_parent_data){
0092         .fw_name = "bi_tcxo",
0093     },
0094     .num_parents = 1,
0095     .ops = &clk_alpha_pll_lucid_ops,
0096 };
0097 
0098 static struct clk_alpha_pll disp_cc_pll1 = {
0099     .offset = 0x1000,
0100     .vco_table = vco_table,
0101     .num_vco = ARRAY_SIZE(vco_table),
0102     .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
0103     .clkr.hw.init = &disp_cc_pll1_init
0104 };
0105 
0106 static const struct parent_map disp_cc_parent_map_0[] = {
0107     { P_BI_TCXO, 0 },
0108     { P_DP_PHY_PLL_LINK_CLK, 1 },
0109     { P_DP_PHY_PLL_VCO_DIV_CLK, 2 },
0110     { P_DPTX1_PHY_PLL_LINK_CLK, 3 },
0111     { P_DPTX1_PHY_PLL_VCO_DIV_CLK, 4 },
0112     { P_DPTX2_PHY_PLL_LINK_CLK, 5 },
0113     { P_DPTX2_PHY_PLL_VCO_DIV_CLK, 6 },
0114 };
0115 
0116 static const struct clk_parent_data disp_cc_parent_data_0[] = {
0117     { .fw_name = "bi_tcxo" },
0118     { .fw_name = "dp_phy_pll_link_clk" },
0119     { .fw_name = "dp_phy_pll_vco_div_clk" },
0120     { .fw_name = "dptx1_phy_pll_link_clk" },
0121     { .fw_name = "dptx1_phy_pll_vco_div_clk" },
0122     { .fw_name = "dptx2_phy_pll_link_clk" },
0123     { .fw_name = "dptx2_phy_pll_vco_div_clk" },
0124 };
0125 
0126 static const struct parent_map disp_cc_parent_map_1[] = {
0127     { P_BI_TCXO, 0 },
0128 };
0129 
0130 static const struct clk_parent_data disp_cc_parent_data_1[] = {
0131     { .fw_name = "bi_tcxo" },
0132 };
0133 
0134 static const struct parent_map disp_cc_parent_map_2[] = {
0135     { P_BI_TCXO, 0 },
0136     { P_DSI0_PHY_PLL_OUT_BYTECLK, 1 },
0137     { P_DSI1_PHY_PLL_OUT_BYTECLK, 2 },
0138 };
0139 
0140 static const struct clk_parent_data disp_cc_parent_data_2[] = {
0141     { .fw_name = "bi_tcxo" },
0142     { .fw_name = "dsi0_phy_pll_out_byteclk" },
0143     { .fw_name = "dsi1_phy_pll_out_byteclk" },
0144 };
0145 
0146 static const struct parent_map disp_cc_parent_map_3[] = {
0147     { P_BI_TCXO, 0 },
0148     { P_DISP_CC_PLL1_OUT_MAIN, 4 },
0149 };
0150 
0151 static const struct clk_parent_data disp_cc_parent_data_3[] = {
0152     { .fw_name = "bi_tcxo" },
0153     { .hw = &disp_cc_pll1.clkr.hw },
0154 };
0155 
0156 static const struct parent_map disp_cc_parent_map_4[] = {
0157     { P_BI_TCXO, 0 },
0158     { P_EDP_PHY_PLL_LINK_CLK, 1 },
0159     { P_EDP_PHY_PLL_VCO_DIV_CLK, 2},
0160 };
0161 
0162 static const struct clk_parent_data disp_cc_parent_data_4[] = {
0163     { .fw_name = "bi_tcxo" },
0164     { .fw_name = "edp_phy_pll_link_clk" },
0165     { .fw_name = "edp_phy_pll_vco_div_clk" },
0166 };
0167 
0168 static const struct parent_map disp_cc_parent_map_5[] = {
0169     { P_BI_TCXO, 0 },
0170     { P_DISP_CC_PLL0_OUT_MAIN, 1 },
0171     { P_DISP_CC_PLL1_OUT_MAIN, 4 },
0172 };
0173 
0174 static const struct clk_parent_data disp_cc_parent_data_5[] = {
0175     { .fw_name = "bi_tcxo" },
0176     { .hw = &disp_cc_pll0.clkr.hw },
0177     { .hw = &disp_cc_pll1.clkr.hw },
0178 };
0179 
0180 static const struct parent_map disp_cc_parent_map_6[] = {
0181     { P_BI_TCXO, 0 },
0182     { P_DSI0_PHY_PLL_OUT_DSICLK, 1 },
0183     { P_DSI1_PHY_PLL_OUT_DSICLK, 2 },
0184 };
0185 
0186 static const struct clk_parent_data disp_cc_parent_data_6[] = {
0187     { .fw_name = "bi_tcxo" },
0188     { .fw_name = "dsi0_phy_pll_out_dsiclk" },
0189     { .fw_name = "dsi1_phy_pll_out_dsiclk" },
0190 };
0191 
0192 static const struct parent_map disp_cc_parent_map_7[] = {
0193     { P_BI_TCXO, 0 },
0194     { P_DISP_CC_PLL1_OUT_MAIN, 4 },
0195     /* { P_DISP_CC_PLL1_OUT_EVEN, 5 }, */
0196 };
0197 
0198 static const struct clk_parent_data disp_cc_parent_data_7[] = {
0199     { .fw_name = "bi_tcxo" },
0200     { .hw = &disp_cc_pll1.clkr.hw },
0201     /* { .hw = &disp_cc_pll1_out_even.clkr.hw }, */
0202 };
0203 
0204 static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = {
0205     F(19200000, P_BI_TCXO, 1, 0, 0),
0206     F(37500000, P_DISP_CC_PLL1_OUT_MAIN, 16, 0, 0),
0207     F(75000000, P_DISP_CC_PLL1_OUT_MAIN, 8, 0, 0),
0208     { }
0209 };
0210 
0211 static struct clk_rcg2 disp_cc_mdss_ahb_clk_src = {
0212     .cmd_rcgr = 0x22bc,
0213     .mnd_width = 0,
0214     .hid_width = 5,
0215     .parent_map = disp_cc_parent_map_3,
0216     .freq_tbl = ftbl_disp_cc_mdss_ahb_clk_src,
0217     .clkr.hw.init = &(struct clk_init_data){
0218         .name = "disp_cc_mdss_ahb_clk_src",
0219         .parent_data = disp_cc_parent_data_3,
0220         .num_parents = ARRAY_SIZE(disp_cc_parent_data_3),
0221         .flags = CLK_SET_RATE_PARENT,
0222         .ops = &clk_rcg2_shared_ops,
0223     },
0224 };
0225 
0226 static const struct freq_tbl ftbl_disp_cc_mdss_byte0_clk_src[] = {
0227     F(19200000, P_BI_TCXO, 1, 0, 0),
0228     { }
0229 };
0230 
0231 static struct clk_rcg2 disp_cc_mdss_byte0_clk_src = {
0232     .cmd_rcgr = 0x2110,
0233     .mnd_width = 0,
0234     .hid_width = 5,
0235     .parent_map = disp_cc_parent_map_2,
0236     .clkr.hw.init = &(struct clk_init_data){
0237         .name = "disp_cc_mdss_byte0_clk_src",
0238         .parent_data = disp_cc_parent_data_2,
0239         .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
0240         .flags = CLK_SET_RATE_PARENT,
0241         .ops = &clk_byte2_ops,
0242     },
0243 };
0244 
0245 static struct clk_rcg2 disp_cc_mdss_byte1_clk_src = {
0246     .cmd_rcgr = 0x212c,
0247     .mnd_width = 0,
0248     .hid_width = 5,
0249     .parent_map = disp_cc_parent_map_2,
0250     .clkr.hw.init = &(struct clk_init_data){
0251         .name = "disp_cc_mdss_byte1_clk_src",
0252         .parent_data = disp_cc_parent_data_2,
0253         .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
0254         .flags = CLK_SET_RATE_PARENT,
0255         .ops = &clk_byte2_ops,
0256     },
0257 };
0258 
0259 static struct clk_rcg2 disp_cc_mdss_dp_aux1_clk_src = {
0260     .cmd_rcgr = 0x2240,
0261     .mnd_width = 0,
0262     .hid_width = 5,
0263     .parent_map = disp_cc_parent_map_1,
0264     .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
0265     .clkr.hw.init = &(struct clk_init_data){
0266         .name = "disp_cc_mdss_dp_aux1_clk_src",
0267         .parent_data = disp_cc_parent_data_1,
0268         .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
0269         .flags = CLK_SET_RATE_PARENT,
0270         .ops = &clk_rcg2_ops,
0271     },
0272 };
0273 
0274 static struct clk_rcg2 disp_cc_mdss_dp_aux_clk_src = {
0275     .cmd_rcgr = 0x21dc,
0276     .mnd_width = 0,
0277     .hid_width = 5,
0278     .parent_map = disp_cc_parent_map_1,
0279     .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
0280     .clkr.hw.init = &(struct clk_init_data){
0281         .name = "disp_cc_mdss_dp_aux_clk_src",
0282         .parent_data = disp_cc_parent_data_1,
0283         .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
0284         .flags = CLK_SET_RATE_PARENT,
0285         .ops = &clk_rcg2_ops,
0286     },
0287 };
0288 
0289 static struct clk_rcg2 disp_cc_mdss_dp_link1_clk_src = {
0290     .cmd_rcgr = 0x220c,
0291     .mnd_width = 0,
0292     .hid_width = 5,
0293     .parent_map = disp_cc_parent_map_0,
0294     .clkr.hw.init = &(struct clk_init_data){
0295         .name = "disp_cc_mdss_dp_link1_clk_src",
0296         .parent_data = disp_cc_parent_data_0,
0297         .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
0298         .ops = &clk_byte2_ops,
0299     },
0300 };
0301 
0302 static struct clk_rcg2 disp_cc_mdss_dp_link_clk_src = {
0303     .cmd_rcgr = 0x2178,
0304     .mnd_width = 0,
0305     .hid_width = 5,
0306     .parent_map = disp_cc_parent_map_0,
0307     .clkr.hw.init = &(struct clk_init_data){
0308         .name = "disp_cc_mdss_dp_link_clk_src",
0309         .parent_data = disp_cc_parent_data_0,
0310         .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
0311         .ops = &clk_byte2_ops,
0312     },
0313 };
0314 
0315 static struct clk_rcg2 disp_cc_mdss_dp_pixel1_clk_src = {
0316     .cmd_rcgr = 0x21c4,
0317     .mnd_width = 16,
0318     .hid_width = 5,
0319     .parent_map = disp_cc_parent_map_0,
0320     .clkr.hw.init = &(struct clk_init_data){
0321         .name = "disp_cc_mdss_dp_pixel1_clk_src",
0322         .parent_data = disp_cc_parent_data_0,
0323         .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
0324         .ops = &clk_dp_ops,
0325     },
0326 };
0327 
0328 static struct clk_rcg2 disp_cc_mdss_dp_pixel2_clk_src = {
0329     .cmd_rcgr = 0x21f4,
0330     .mnd_width = 16,
0331     .hid_width = 5,
0332     .parent_map = disp_cc_parent_map_0,
0333     .clkr.hw.init = &(struct clk_init_data){
0334         .name = "disp_cc_mdss_dp_pixel2_clk_src",
0335         .parent_data = disp_cc_parent_data_0,
0336         .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
0337         .ops = &clk_dp_ops,
0338     },
0339 };
0340 
0341 static struct clk_rcg2 disp_cc_mdss_dp_pixel_clk_src = {
0342     .cmd_rcgr = 0x21ac,
0343     .mnd_width = 16,
0344     .hid_width = 5,
0345     .parent_map = disp_cc_parent_map_0,
0346     .clkr.hw.init = &(struct clk_init_data){
0347         .name = "disp_cc_mdss_dp_pixel_clk_src",
0348         .parent_data = disp_cc_parent_data_0,
0349         .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
0350         .ops = &clk_dp_ops,
0351     },
0352 };
0353 
0354 static struct clk_rcg2 disp_cc_mdss_edp_aux_clk_src = {
0355     .cmd_rcgr = 0x228c,
0356     .mnd_width = 0,
0357     .hid_width = 5,
0358     .parent_map = disp_cc_parent_map_1,
0359     .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
0360     .clkr.hw.init = &(struct clk_init_data){
0361         .name = "disp_cc_mdss_edp_aux_clk_src",
0362         .parent_data = disp_cc_parent_data_1,
0363         .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
0364         .flags = CLK_SET_RATE_PARENT,
0365         .ops = &clk_rcg2_ops,
0366     },
0367 };
0368 
0369 static struct clk_rcg2 disp_cc_mdss_edp_gtc_clk_src = {
0370     .cmd_rcgr = 0x22a4,
0371     .mnd_width = 0,
0372     .hid_width = 5,
0373     .parent_map = disp_cc_parent_map_7,
0374     .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
0375     .clkr.hw.init = &(struct clk_init_data){
0376         .name = "disp_cc_mdss_edp_gtc_clk_src",
0377         .parent_data = disp_cc_parent_data_7,
0378         .num_parents = ARRAY_SIZE(disp_cc_parent_data_7),
0379         .flags = CLK_SET_RATE_PARENT,
0380         .ops = &clk_rcg2_ops,
0381     },
0382 };
0383 
0384 static struct clk_rcg2 disp_cc_mdss_edp_link_clk_src = {
0385     .cmd_rcgr = 0x2270,
0386     .mnd_width = 0,
0387     .hid_width = 5,
0388     .parent_map = disp_cc_parent_map_4,
0389     .clkr.hw.init = &(struct clk_init_data){
0390         .name = "disp_cc_mdss_edp_link_clk_src",
0391         .parent_data = disp_cc_parent_data_4,
0392         .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
0393         .flags = CLK_SET_RATE_PARENT,
0394         .ops = &clk_byte2_ops,
0395     },
0396 };
0397 
0398 static struct clk_rcg2 disp_cc_mdss_edp_pixel_clk_src = {
0399     .cmd_rcgr = 0x2258,
0400     .mnd_width = 16,
0401     .hid_width = 5,
0402     .parent_map = disp_cc_parent_map_4,
0403     .clkr.hw.init = &(struct clk_init_data){
0404         .name = "disp_cc_mdss_edp_pixel_clk_src",
0405         .parent_data = disp_cc_parent_data_4,
0406         .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
0407         .ops = &clk_dp_ops,
0408     },
0409 };
0410 
0411 static struct clk_branch disp_cc_mdss_edp_aux_clk = {
0412     .halt_reg = 0x2078,
0413     .halt_check = BRANCH_HALT,
0414     .clkr = {
0415         .enable_reg = 0x2078,
0416         .enable_mask = BIT(0),
0417         .hw.init = &(struct clk_init_data){
0418             .name = "disp_cc_mdss_edp_aux_clk",
0419             .parent_hws = (const struct clk_hw*[]){
0420                 &disp_cc_mdss_edp_aux_clk_src.clkr.hw,
0421             },
0422             .num_parents = 1,
0423             .flags = CLK_SET_RATE_PARENT,
0424             .ops = &clk_branch2_ops,
0425         },
0426     },
0427 };
0428 
0429 static struct clk_branch disp_cc_mdss_edp_gtc_clk = {
0430     .halt_reg = 0x207c,
0431     .halt_check = BRANCH_HALT,
0432     .clkr = {
0433         .enable_reg = 0x207c,
0434         .enable_mask = BIT(0),
0435         .hw.init = &(struct clk_init_data){
0436             .name = "disp_cc_mdss_edp_gtc_clk",
0437             .parent_hws = (const struct clk_hw*[]){
0438                 &disp_cc_mdss_edp_gtc_clk_src.clkr.hw,
0439             },
0440             .num_parents = 1,
0441             .flags = CLK_SET_RATE_PARENT,
0442             .ops = &clk_branch2_ops,
0443         },
0444     },
0445 };
0446 
0447 static struct clk_branch disp_cc_mdss_edp_link_clk = {
0448     .halt_reg = 0x2070,
0449     .halt_check = BRANCH_HALT,
0450     .clkr = {
0451         .enable_reg = 0x2070,
0452         .enable_mask = BIT(0),
0453         .hw.init = &(struct clk_init_data){
0454             .name = "disp_cc_mdss_edp_link_clk",
0455             .parent_hws = (const struct clk_hw*[]){
0456                 &disp_cc_mdss_edp_link_clk_src.clkr.hw,
0457             },
0458             .num_parents = 1,
0459             .flags = CLK_SET_RATE_PARENT,
0460             .ops = &clk_branch2_ops,
0461         },
0462     },
0463 };
0464 
0465 static struct clk_branch disp_cc_mdss_edp_link_intf_clk = {
0466     .halt_reg = 0x2074,
0467     .halt_check = BRANCH_HALT,
0468     .clkr = {
0469         .enable_reg = 0x2074,
0470         .enable_mask = BIT(0),
0471         .hw.init = &(struct clk_init_data){
0472             .name = "disp_cc_mdss_edp_link_intf_clk",
0473             .parent_hws = (const struct clk_hw*[]){
0474                 &disp_cc_mdss_edp_link_clk_src.clkr.hw,
0475             },
0476             .num_parents = 1,
0477             .flags = CLK_GET_RATE_NOCACHE,
0478             .ops = &clk_branch2_ops,
0479         },
0480     },
0481 };
0482 
0483 static struct clk_branch disp_cc_mdss_edp_pixel_clk = {
0484     .halt_reg = 0x206c,
0485     .halt_check = BRANCH_HALT,
0486     .clkr = {
0487         .enable_reg = 0x206c,
0488         .enable_mask = BIT(0),
0489         .hw.init = &(struct clk_init_data){
0490             .name = "disp_cc_mdss_edp_pixel_clk",
0491             .parent_hws = (const struct clk_hw*[]){
0492                 &disp_cc_mdss_edp_pixel_clk_src.clkr.hw,
0493             },
0494             .num_parents = 1,
0495             .flags = CLK_SET_RATE_PARENT,
0496             .ops = &clk_branch2_ops,
0497         },
0498     },
0499 };
0500 
0501 static struct clk_rcg2 disp_cc_mdss_esc0_clk_src = {
0502     .cmd_rcgr = 0x2148,
0503     .mnd_width = 0,
0504     .hid_width = 5,
0505     .parent_map = disp_cc_parent_map_2,
0506     .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
0507     .clkr.hw.init = &(struct clk_init_data){
0508         .name = "disp_cc_mdss_esc0_clk_src",
0509         .parent_data = disp_cc_parent_data_2,
0510         .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
0511         .flags = CLK_SET_RATE_PARENT,
0512         .ops = &clk_rcg2_ops,
0513     },
0514 };
0515 
0516 static struct clk_rcg2 disp_cc_mdss_esc1_clk_src = {
0517     .cmd_rcgr = 0x2160,
0518     .mnd_width = 0,
0519     .hid_width = 5,
0520     .parent_map = disp_cc_parent_map_2,
0521     .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
0522     .clkr.hw.init = &(struct clk_init_data){
0523         .name = "disp_cc_mdss_esc1_clk_src",
0524         .parent_data = disp_cc_parent_data_2,
0525         .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
0526         .flags = CLK_SET_RATE_PARENT,
0527         .ops = &clk_rcg2_ops,
0528     },
0529 };
0530 
0531 static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src[] = {
0532     F(19200000, P_BI_TCXO, 1, 0, 0),
0533     F(85714286, P_DISP_CC_PLL1_OUT_MAIN, 7, 0, 0),
0534     F(100000000, P_DISP_CC_PLL1_OUT_MAIN, 6, 0, 0),
0535     F(150000000, P_DISP_CC_PLL1_OUT_MAIN, 4, 0, 0),
0536     F(200000000, P_DISP_CC_PLL1_OUT_MAIN, 3, 0, 0),
0537     F(300000000, P_DISP_CC_PLL1_OUT_MAIN, 2, 0, 0),
0538     F(345000000, P_DISP_CC_PLL0_OUT_MAIN, 4, 0, 0),
0539     F(460000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
0540     { }
0541 };
0542 
0543 static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = {
0544     .cmd_rcgr = 0x20c8,
0545     .mnd_width = 0,
0546     .hid_width = 5,
0547     .parent_map = disp_cc_parent_map_5,
0548     .freq_tbl = ftbl_disp_cc_mdss_mdp_clk_src,
0549     .clkr.hw.init = &(struct clk_init_data){
0550         .name = "disp_cc_mdss_mdp_clk_src",
0551         .parent_data = disp_cc_parent_data_5,
0552         .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
0553         .flags = CLK_SET_RATE_PARENT,
0554         .ops = &clk_rcg2_shared_ops,
0555     },
0556 };
0557 
0558 static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = {
0559     .cmd_rcgr = 0x2098,
0560     .mnd_width = 8,
0561     .hid_width = 5,
0562     .parent_map = disp_cc_parent_map_6,
0563     .clkr.hw.init = &(struct clk_init_data){
0564         .name = "disp_cc_mdss_pclk0_clk_src",
0565         .parent_data = disp_cc_parent_data_6,
0566         .num_parents = ARRAY_SIZE(disp_cc_parent_data_6),
0567         .flags = CLK_SET_RATE_PARENT,
0568         .ops = &clk_pixel_ops,
0569     },
0570 };
0571 
0572 static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = {
0573     .cmd_rcgr = 0x20b0,
0574     .mnd_width = 8,
0575     .hid_width = 5,
0576     .parent_map = disp_cc_parent_map_6,
0577     .clkr.hw.init = &(struct clk_init_data){
0578         .name = "disp_cc_mdss_pclk1_clk_src",
0579         .parent_data = disp_cc_parent_data_6,
0580         .num_parents = ARRAY_SIZE(disp_cc_parent_data_6),
0581         .flags = CLK_SET_RATE_PARENT,
0582         .ops = &clk_pixel_ops,
0583     },
0584 };
0585 
0586 static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src[] = {
0587     F(19200000, P_BI_TCXO, 1, 0, 0),
0588     F(200000000, P_DISP_CC_PLL1_OUT_MAIN, 3, 0, 0),
0589     F(300000000, P_DISP_CC_PLL1_OUT_MAIN, 2, 0, 0),
0590     F(345000000, P_DISP_CC_PLL0_OUT_MAIN, 4, 0, 0),
0591     F(460000000, P_DISP_CC_PLL0_OUT_MAIN, 3, 0, 0),
0592     { }
0593 };
0594 
0595 static struct clk_rcg2 disp_cc_mdss_rot_clk_src = {
0596     .cmd_rcgr = 0x20e0,
0597     .mnd_width = 0,
0598     .hid_width = 5,
0599     .parent_map = disp_cc_parent_map_5,
0600     .freq_tbl = ftbl_disp_cc_mdss_rot_clk_src,
0601     .clkr.hw.init = &(struct clk_init_data){
0602         .name = "disp_cc_mdss_rot_clk_src",
0603         .parent_data = disp_cc_parent_data_5,
0604         .num_parents = ARRAY_SIZE(disp_cc_parent_data_5),
0605         .flags = CLK_SET_RATE_PARENT,
0606         .ops = &clk_rcg2_shared_ops,
0607     },
0608 };
0609 
0610 static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = {
0611     .cmd_rcgr = 0x20f8,
0612     .mnd_width = 0,
0613     .hid_width = 5,
0614     .parent_map = disp_cc_parent_map_1,
0615     .freq_tbl = ftbl_disp_cc_mdss_byte0_clk_src,
0616     .clkr.hw.init = &(struct clk_init_data){
0617         .name = "disp_cc_mdss_vsync_clk_src",
0618         .parent_data = disp_cc_parent_data_1,
0619         .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
0620         .flags = CLK_SET_RATE_PARENT,
0621         .ops = &clk_rcg2_ops,
0622     },
0623 };
0624 
0625 static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = {
0626     .reg = 0x2128,
0627     .shift = 0,
0628     .width = 2,
0629     .clkr.hw.init = &(struct clk_init_data) {
0630         .name = "disp_cc_mdss_byte0_div_clk_src",
0631         .parent_hws = (const struct clk_hw*[]){
0632             &disp_cc_mdss_byte0_clk_src.clkr.hw,
0633         },
0634         .num_parents = 1,
0635         .ops = &clk_regmap_div_ops,
0636     },
0637 };
0638 
0639 
0640 static struct clk_regmap_div disp_cc_mdss_byte1_div_clk_src = {
0641     .reg = 0x2144,
0642     .shift = 0,
0643     .width = 2,
0644     .clkr.hw.init = &(struct clk_init_data) {
0645         .name = "disp_cc_mdss_byte1_div_clk_src",
0646         .parent_hws = (const struct clk_hw*[]){
0647             &disp_cc_mdss_byte1_clk_src.clkr.hw,
0648         },
0649         .num_parents = 1,
0650         .ops = &clk_regmap_div_ops,
0651     },
0652 };
0653 
0654 
0655 static struct clk_regmap_div disp_cc_mdss_dp_link1_div_clk_src = {
0656     .reg = 0x2224,
0657     .shift = 0,
0658     .width = 2,
0659     .clkr.hw.init = &(struct clk_init_data) {
0660         .name = "disp_cc_mdss_dp_link1_div_clk_src",
0661         .parent_hws = (const struct clk_hw*[]){
0662             &disp_cc_mdss_dp_link1_clk_src.clkr.hw,
0663         },
0664         .num_parents = 1,
0665         .ops = &clk_regmap_div_ro_ops,
0666     },
0667 };
0668 
0669 
0670 static struct clk_regmap_div disp_cc_mdss_dp_link_div_clk_src = {
0671     .reg = 0x2190,
0672     .shift = 0,
0673     .width = 2,
0674     .clkr.hw.init = &(struct clk_init_data) {
0675         .name = "disp_cc_mdss_dp_link_div_clk_src",
0676         .parent_hws = (const struct clk_hw*[]){
0677             &disp_cc_mdss_dp_link_clk_src.clkr.hw,
0678         },
0679         .num_parents = 1,
0680         .ops = &clk_regmap_div_ro_ops,
0681     },
0682 };
0683 
0684 static struct clk_branch disp_cc_mdss_ahb_clk = {
0685     .halt_reg = 0x2080,
0686     .halt_check = BRANCH_HALT,
0687     .clkr = {
0688         .enable_reg = 0x2080,
0689         .enable_mask = BIT(0),
0690         .hw.init = &(struct clk_init_data){
0691             .name = "disp_cc_mdss_ahb_clk",
0692             .parent_hws = (const struct clk_hw*[]){
0693                 &disp_cc_mdss_ahb_clk_src.clkr.hw,
0694             },
0695             .num_parents = 1,
0696             .flags = CLK_SET_RATE_PARENT,
0697             .ops = &clk_branch2_ops,
0698         },
0699     },
0700 };
0701 
0702 static struct clk_branch disp_cc_mdss_byte0_clk = {
0703     .halt_reg = 0x2028,
0704     .halt_check = BRANCH_HALT,
0705     .clkr = {
0706         .enable_reg = 0x2028,
0707         .enable_mask = BIT(0),
0708         .hw.init = &(struct clk_init_data){
0709             .name = "disp_cc_mdss_byte0_clk",
0710             .parent_hws = (const struct clk_hw*[]){
0711                 &disp_cc_mdss_byte0_clk_src.clkr.hw,
0712             },
0713             .num_parents = 1,
0714             .flags = CLK_SET_RATE_PARENT,
0715             .ops = &clk_branch2_ops,
0716         },
0717     },
0718 };
0719 
0720 static struct clk_branch disp_cc_mdss_byte0_intf_clk = {
0721     .halt_reg = 0x202c,
0722     .halt_check = BRANCH_HALT,
0723     .clkr = {
0724         .enable_reg = 0x202c,
0725         .enable_mask = BIT(0),
0726         .hw.init = &(struct clk_init_data){
0727             .name = "disp_cc_mdss_byte0_intf_clk",
0728             .parent_hws = (const struct clk_hw*[]){
0729                 &disp_cc_mdss_byte0_div_clk_src.clkr.hw,
0730             },
0731             .num_parents = 1,
0732             .flags = CLK_SET_RATE_PARENT,
0733             .ops = &clk_branch2_ops,
0734         },
0735     },
0736 };
0737 
0738 static struct clk_branch disp_cc_mdss_byte1_clk = {
0739     .halt_reg = 0x2030,
0740     .halt_check = BRANCH_HALT,
0741     .clkr = {
0742         .enable_reg = 0x2030,
0743         .enable_mask = BIT(0),
0744         .hw.init = &(struct clk_init_data){
0745             .name = "disp_cc_mdss_byte1_clk",
0746             .parent_hws = (const struct clk_hw*[]){
0747                 &disp_cc_mdss_byte1_clk_src.clkr.hw,
0748             },
0749             .num_parents = 1,
0750             .flags = CLK_SET_RATE_PARENT,
0751             .ops = &clk_branch2_ops,
0752         },
0753     },
0754 };
0755 
0756 static struct clk_branch disp_cc_mdss_byte1_intf_clk = {
0757     .halt_reg = 0x2034,
0758     .halt_check = BRANCH_HALT,
0759     .clkr = {
0760         .enable_reg = 0x2034,
0761         .enable_mask = BIT(0),
0762         .hw.init = &(struct clk_init_data){
0763             .name = "disp_cc_mdss_byte1_intf_clk",
0764             .parent_hws = (const struct clk_hw*[]){
0765                 &disp_cc_mdss_byte1_div_clk_src.clkr.hw,
0766             },
0767             .num_parents = 1,
0768             .flags = CLK_SET_RATE_PARENT,
0769             .ops = &clk_branch2_ops,
0770         },
0771     },
0772 };
0773 
0774 static struct clk_branch disp_cc_mdss_dp_aux1_clk = {
0775     .halt_reg = 0x2068,
0776     .halt_check = BRANCH_HALT,
0777     .clkr = {
0778         .enable_reg = 0x2068,
0779         .enable_mask = BIT(0),
0780         .hw.init = &(struct clk_init_data){
0781             .name = "disp_cc_mdss_dp_aux1_clk",
0782             .parent_hws = (const struct clk_hw*[]){
0783                 &disp_cc_mdss_dp_aux1_clk_src.clkr.hw,
0784             },
0785             .num_parents = 1,
0786             .flags = CLK_SET_RATE_PARENT,
0787             .ops = &clk_branch2_ops,
0788         },
0789     },
0790 };
0791 
0792 static struct clk_branch disp_cc_mdss_dp_aux_clk = {
0793     .halt_reg = 0x2054,
0794     .halt_check = BRANCH_HALT,
0795     .clkr = {
0796         .enable_reg = 0x2054,
0797         .enable_mask = BIT(0),
0798         .hw.init = &(struct clk_init_data){
0799             .name = "disp_cc_mdss_dp_aux_clk",
0800             .parent_hws = (const struct clk_hw*[]){
0801                 &disp_cc_mdss_dp_aux_clk_src.clkr.hw,
0802             },
0803             .num_parents = 1,
0804             .flags = CLK_SET_RATE_PARENT,
0805             .ops = &clk_branch2_ops,
0806         },
0807     },
0808 };
0809 
0810 static struct clk_branch disp_cc_mdss_dp_link1_clk = {
0811     .halt_reg = 0x205c,
0812     .halt_check = BRANCH_HALT,
0813     .clkr = {
0814         .enable_reg = 0x205c,
0815         .enable_mask = BIT(0),
0816         .hw.init = &(struct clk_init_data){
0817             .name = "disp_cc_mdss_dp_link1_clk",
0818             .parent_hws = (const struct clk_hw*[]){
0819                 &disp_cc_mdss_dp_link1_clk_src.clkr.hw,
0820             },
0821             .num_parents = 1,
0822             .flags = CLK_SET_RATE_PARENT,
0823             .ops = &clk_branch2_ops,
0824         },
0825     },
0826 };
0827 
0828 static struct clk_branch disp_cc_mdss_dp_link1_intf_clk = {
0829     .halt_reg = 0x2060,
0830     .halt_check = BRANCH_HALT,
0831     .clkr = {
0832         .enable_reg = 0x2060,
0833         .enable_mask = BIT(0),
0834         .hw.init = &(struct clk_init_data){
0835             .name = "disp_cc_mdss_dp_link1_intf_clk",
0836             .parent_hws = (const struct clk_hw*[]){
0837                 &disp_cc_mdss_dp_link1_div_clk_src.clkr.hw,
0838             },
0839             .num_parents = 1,
0840             .ops = &clk_branch2_ops,
0841         },
0842     },
0843 };
0844 
0845 static struct clk_branch disp_cc_mdss_dp_link_clk = {
0846     .halt_reg = 0x2040,
0847     .halt_check = BRANCH_HALT,
0848     .clkr = {
0849         .enable_reg = 0x2040,
0850         .enable_mask = BIT(0),
0851         .hw.init = &(struct clk_init_data){
0852             .name = "disp_cc_mdss_dp_link_clk",
0853             .parent_hws = (const struct clk_hw*[]){
0854                 &disp_cc_mdss_dp_link_clk_src.clkr.hw,
0855             },
0856             .num_parents = 1,
0857             .flags = CLK_SET_RATE_PARENT,
0858             .ops = &clk_branch2_ops,
0859         },
0860     },
0861 };
0862 
0863 static struct clk_branch disp_cc_mdss_dp_link_intf_clk = {
0864     .halt_reg = 0x2044,
0865     .halt_check = BRANCH_HALT,
0866     .clkr = {
0867         .enable_reg = 0x2044,
0868         .enable_mask = BIT(0),
0869         .hw.init = &(struct clk_init_data){
0870             .name = "disp_cc_mdss_dp_link_intf_clk",
0871             .parent_hws = (const struct clk_hw*[]){
0872                 &disp_cc_mdss_dp_link_div_clk_src.clkr.hw,
0873             },
0874             .num_parents = 1,
0875             .ops = &clk_branch2_ops,
0876         },
0877     },
0878 };
0879 
0880 static struct clk_branch disp_cc_mdss_dp_pixel1_clk = {
0881     .halt_reg = 0x2050,
0882     .halt_check = BRANCH_HALT,
0883     .clkr = {
0884         .enable_reg = 0x2050,
0885         .enable_mask = BIT(0),
0886         .hw.init = &(struct clk_init_data){
0887             .name = "disp_cc_mdss_dp_pixel1_clk",
0888             .parent_hws = (const struct clk_hw*[]){
0889                 &disp_cc_mdss_dp_pixel1_clk_src.clkr.hw,
0890             },
0891             .num_parents = 1,
0892             .flags = CLK_SET_RATE_PARENT,
0893             .ops = &clk_branch2_ops,
0894         },
0895     },
0896 };
0897 
0898 static struct clk_branch disp_cc_mdss_dp_pixel2_clk = {
0899     .halt_reg = 0x2058,
0900     .halt_check = BRANCH_HALT,
0901     .clkr = {
0902         .enable_reg = 0x2058,
0903         .enable_mask = BIT(0),
0904         .hw.init = &(struct clk_init_data){
0905             .name = "disp_cc_mdss_dp_pixel2_clk",
0906             .parent_hws = (const struct clk_hw*[]){
0907                 &disp_cc_mdss_dp_pixel2_clk_src.clkr.hw,
0908             },
0909             .num_parents = 1,
0910             .flags = CLK_SET_RATE_PARENT,
0911             .ops = &clk_branch2_ops,
0912         },
0913     },
0914 };
0915 
0916 static struct clk_branch disp_cc_mdss_dp_pixel_clk = {
0917     .halt_reg = 0x204c,
0918     .halt_check = BRANCH_HALT,
0919     .clkr = {
0920         .enable_reg = 0x204c,
0921         .enable_mask = BIT(0),
0922         .hw.init = &(struct clk_init_data){
0923             .name = "disp_cc_mdss_dp_pixel_clk",
0924             .parent_hws = (const struct clk_hw*[]){
0925                 &disp_cc_mdss_dp_pixel_clk_src.clkr.hw,
0926             },
0927             .num_parents = 1,
0928             .flags = CLK_SET_RATE_PARENT,
0929             .ops = &clk_branch2_ops,
0930         },
0931     },
0932 };
0933 
0934 static struct clk_branch disp_cc_mdss_esc0_clk = {
0935     .halt_reg = 0x2038,
0936     .halt_check = BRANCH_HALT,
0937     .clkr = {
0938         .enable_reg = 0x2038,
0939         .enable_mask = BIT(0),
0940         .hw.init = &(struct clk_init_data){
0941             .name = "disp_cc_mdss_esc0_clk",
0942             .parent_hws = (const struct clk_hw*[]){
0943                 &disp_cc_mdss_esc0_clk_src.clkr.hw,
0944             },
0945             .num_parents = 1,
0946             .flags = CLK_SET_RATE_PARENT,
0947             .ops = &clk_branch2_ops,
0948         },
0949     },
0950 };
0951 
0952 static struct clk_branch disp_cc_mdss_esc1_clk = {
0953     .halt_reg = 0x203c,
0954     .halt_check = BRANCH_HALT,
0955     .clkr = {
0956         .enable_reg = 0x203c,
0957         .enable_mask = BIT(0),
0958         .hw.init = &(struct clk_init_data){
0959             .name = "disp_cc_mdss_esc1_clk",
0960             .parent_hws = (const struct clk_hw*[]){
0961                 &disp_cc_mdss_esc1_clk_src.clkr.hw,
0962             },
0963             .num_parents = 1,
0964             .flags = CLK_SET_RATE_PARENT,
0965             .ops = &clk_branch2_ops,
0966         },
0967     },
0968 };
0969 
0970 static struct clk_branch disp_cc_mdss_mdp_clk = {
0971     .halt_reg = 0x200c,
0972     .halt_check = BRANCH_HALT,
0973     .clkr = {
0974         .enable_reg = 0x200c,
0975         .enable_mask = BIT(0),
0976         .hw.init = &(struct clk_init_data){
0977             .name = "disp_cc_mdss_mdp_clk",
0978             .parent_hws = (const struct clk_hw*[]){
0979                 &disp_cc_mdss_mdp_clk_src.clkr.hw,
0980             },
0981             .num_parents = 1,
0982             .flags = CLK_SET_RATE_PARENT,
0983             .ops = &clk_branch2_ops,
0984         },
0985     },
0986 };
0987 
0988 static struct clk_branch disp_cc_mdss_mdp_lut_clk = {
0989     .halt_reg = 0x201c,
0990     .halt_check = BRANCH_VOTED,
0991     .clkr = {
0992         .enable_reg = 0x201c,
0993         .enable_mask = BIT(0),
0994         .hw.init = &(struct clk_init_data){
0995             .name = "disp_cc_mdss_mdp_lut_clk",
0996             .parent_hws = (const struct clk_hw*[]){
0997                 &disp_cc_mdss_mdp_clk_src.clkr.hw,
0998             },
0999             .num_parents = 1,
1000             .ops = &clk_branch2_ops,
1001         },
1002     },
1003 };
1004 
1005 static struct clk_branch disp_cc_mdss_non_gdsc_ahb_clk = {
1006     .halt_reg = 0x4004,
1007     .halt_check = BRANCH_VOTED,
1008     .clkr = {
1009         .enable_reg = 0x4004,
1010         .enable_mask = BIT(0),
1011         .hw.init = &(struct clk_init_data){
1012             .name = "disp_cc_mdss_non_gdsc_ahb_clk",
1013             .parent_hws = (const struct clk_hw*[]){
1014                 &disp_cc_mdss_ahb_clk_src.clkr.hw,
1015             },
1016             .num_parents = 1,
1017             .flags = CLK_SET_RATE_PARENT,
1018             .ops = &clk_branch2_ops,
1019         },
1020     },
1021 };
1022 
1023 static struct clk_branch disp_cc_mdss_pclk0_clk = {
1024     .halt_reg = 0x2004,
1025     .halt_check = BRANCH_HALT,
1026     .clkr = {
1027         .enable_reg = 0x2004,
1028         .enable_mask = BIT(0),
1029         .hw.init = &(struct clk_init_data){
1030             .name = "disp_cc_mdss_pclk0_clk",
1031             .parent_hws = (const struct clk_hw*[]){
1032                 &disp_cc_mdss_pclk0_clk_src.clkr.hw,
1033             },
1034             .num_parents = 1,
1035             .flags = CLK_SET_RATE_PARENT,
1036             .ops = &clk_branch2_ops,
1037         },
1038     },
1039 };
1040 
1041 static struct clk_branch disp_cc_mdss_pclk1_clk = {
1042     .halt_reg = 0x2008,
1043     .halt_check = BRANCH_HALT,
1044     .clkr = {
1045         .enable_reg = 0x2008,
1046         .enable_mask = BIT(0),
1047         .hw.init = &(struct clk_init_data){
1048             .name = "disp_cc_mdss_pclk1_clk",
1049             .parent_hws = (const struct clk_hw*[]){
1050                 &disp_cc_mdss_pclk1_clk_src.clkr.hw,
1051             },
1052             .num_parents = 1,
1053             .flags = CLK_SET_RATE_PARENT,
1054             .ops = &clk_branch2_ops,
1055         },
1056     },
1057 };
1058 
1059 static struct clk_branch disp_cc_mdss_rot_clk = {
1060     .halt_reg = 0x2014,
1061     .halt_check = BRANCH_HALT,
1062     .clkr = {
1063         .enable_reg = 0x2014,
1064         .enable_mask = BIT(0),
1065         .hw.init = &(struct clk_init_data){
1066             .name = "disp_cc_mdss_rot_clk",
1067             .parent_hws = (const struct clk_hw*[]){
1068                 &disp_cc_mdss_rot_clk_src.clkr.hw,
1069             },
1070             .num_parents = 1,
1071             .flags = CLK_SET_RATE_PARENT,
1072             .ops = &clk_branch2_ops,
1073         },
1074     },
1075 };
1076 
1077 static struct clk_branch disp_cc_mdss_rscc_ahb_clk = {
1078     .halt_reg = 0x400c,
1079     .halt_check = BRANCH_HALT,
1080     .clkr = {
1081         .enable_reg = 0x400c,
1082         .enable_mask = BIT(0),
1083         .hw.init = &(struct clk_init_data){
1084             .name = "disp_cc_mdss_rscc_ahb_clk",
1085             .parent_hws = (const struct clk_hw*[]){
1086                 &disp_cc_mdss_ahb_clk_src.clkr.hw,
1087             },
1088             .num_parents = 1,
1089             .flags = CLK_SET_RATE_PARENT,
1090             .ops = &clk_branch2_ops,
1091         },
1092     },
1093 };
1094 
1095 static struct clk_branch disp_cc_mdss_rscc_vsync_clk = {
1096     .halt_reg = 0x4008,
1097     .halt_check = BRANCH_HALT,
1098     .clkr = {
1099         .enable_reg = 0x4008,
1100         .enable_mask = BIT(0),
1101         .hw.init = &(struct clk_init_data){
1102             .name = "disp_cc_mdss_rscc_vsync_clk",
1103             .parent_hws = (const struct clk_hw*[]){
1104                 &disp_cc_mdss_vsync_clk_src.clkr.hw,
1105             },
1106             .num_parents = 1,
1107             .flags = CLK_SET_RATE_PARENT,
1108             .ops = &clk_branch2_ops,
1109         },
1110     },
1111 };
1112 
1113 static struct clk_branch disp_cc_mdss_vsync_clk = {
1114     .halt_reg = 0x2024,
1115     .halt_check = BRANCH_HALT,
1116     .clkr = {
1117         .enable_reg = 0x2024,
1118         .enable_mask = BIT(0),
1119         .hw.init = &(struct clk_init_data){
1120             .name = "disp_cc_mdss_vsync_clk",
1121             .parent_hws = (const struct clk_hw*[]){
1122                 &disp_cc_mdss_vsync_clk_src.clkr.hw,
1123             },
1124             .num_parents = 1,
1125             .flags = CLK_SET_RATE_PARENT,
1126             .ops = &clk_branch2_ops,
1127         },
1128     },
1129 };
1130 
1131 static struct gdsc mdss_gdsc = {
1132     .gdscr = 0x3000,
1133     .en_rest_wait_val = 0x2,
1134     .en_few_wait_val = 0x2,
1135     .clk_dis_wait_val = 0xf,
1136     .pd = {
1137         .name = "mdss_gdsc",
1138     },
1139     .pwrsts = PWRSTS_OFF_ON,
1140     .flags = HW_CTRL,
1141 };
1142 
1143 static struct clk_regmap *disp_cc_sm8250_clocks[] = {
1144     [DISP_CC_MDSS_AHB_CLK] = &disp_cc_mdss_ahb_clk.clkr,
1145     [DISP_CC_MDSS_AHB_CLK_SRC] = &disp_cc_mdss_ahb_clk_src.clkr,
1146     [DISP_CC_MDSS_BYTE0_CLK] = &disp_cc_mdss_byte0_clk.clkr,
1147     [DISP_CC_MDSS_BYTE0_CLK_SRC] = &disp_cc_mdss_byte0_clk_src.clkr,
1148     [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC] = &disp_cc_mdss_byte0_div_clk_src.clkr,
1149     [DISP_CC_MDSS_BYTE0_INTF_CLK] = &disp_cc_mdss_byte0_intf_clk.clkr,
1150     [DISP_CC_MDSS_BYTE1_CLK] = &disp_cc_mdss_byte1_clk.clkr,
1151     [DISP_CC_MDSS_BYTE1_CLK_SRC] = &disp_cc_mdss_byte1_clk_src.clkr,
1152     [DISP_CC_MDSS_BYTE1_DIV_CLK_SRC] = &disp_cc_mdss_byte1_div_clk_src.clkr,
1153     [DISP_CC_MDSS_BYTE1_INTF_CLK] = &disp_cc_mdss_byte1_intf_clk.clkr,
1154     [DISP_CC_MDSS_DP_AUX1_CLK] = &disp_cc_mdss_dp_aux1_clk.clkr,
1155     [DISP_CC_MDSS_DP_AUX1_CLK_SRC] = &disp_cc_mdss_dp_aux1_clk_src.clkr,
1156     [DISP_CC_MDSS_DP_AUX_CLK] = &disp_cc_mdss_dp_aux_clk.clkr,
1157     [DISP_CC_MDSS_DP_AUX_CLK_SRC] = &disp_cc_mdss_dp_aux_clk_src.clkr,
1158     [DISP_CC_MDSS_DP_LINK1_CLK] = &disp_cc_mdss_dp_link1_clk.clkr,
1159     [DISP_CC_MDSS_DP_LINK1_CLK_SRC] = &disp_cc_mdss_dp_link1_clk_src.clkr,
1160     [DISP_CC_MDSS_DP_LINK1_DIV_CLK_SRC] = &disp_cc_mdss_dp_link1_div_clk_src.clkr,
1161     [DISP_CC_MDSS_DP_LINK1_INTF_CLK] = &disp_cc_mdss_dp_link1_intf_clk.clkr,
1162     [DISP_CC_MDSS_DP_LINK_CLK] = &disp_cc_mdss_dp_link_clk.clkr,
1163     [DISP_CC_MDSS_DP_LINK_CLK_SRC] = &disp_cc_mdss_dp_link_clk_src.clkr,
1164     [DISP_CC_MDSS_DP_LINK_DIV_CLK_SRC] = &disp_cc_mdss_dp_link_div_clk_src.clkr,
1165     [DISP_CC_MDSS_DP_LINK_INTF_CLK] = &disp_cc_mdss_dp_link_intf_clk.clkr,
1166     [DISP_CC_MDSS_DP_PIXEL1_CLK] = &disp_cc_mdss_dp_pixel1_clk.clkr,
1167     [DISP_CC_MDSS_DP_PIXEL1_CLK_SRC] = &disp_cc_mdss_dp_pixel1_clk_src.clkr,
1168     [DISP_CC_MDSS_DP_PIXEL2_CLK] = &disp_cc_mdss_dp_pixel2_clk.clkr,
1169     [DISP_CC_MDSS_DP_PIXEL2_CLK_SRC] = &disp_cc_mdss_dp_pixel2_clk_src.clkr,
1170     [DISP_CC_MDSS_DP_PIXEL_CLK] = &disp_cc_mdss_dp_pixel_clk.clkr,
1171     [DISP_CC_MDSS_DP_PIXEL_CLK_SRC] = &disp_cc_mdss_dp_pixel_clk_src.clkr,
1172     [DISP_CC_MDSS_EDP_AUX_CLK] = &disp_cc_mdss_edp_aux_clk.clkr,
1173     [DISP_CC_MDSS_EDP_AUX_CLK_SRC] = &disp_cc_mdss_edp_aux_clk_src.clkr,
1174     [DISP_CC_MDSS_EDP_GTC_CLK] = &disp_cc_mdss_edp_gtc_clk.clkr,
1175     [DISP_CC_MDSS_EDP_GTC_CLK_SRC] = &disp_cc_mdss_edp_gtc_clk_src.clkr,
1176     [DISP_CC_MDSS_EDP_LINK_CLK] = &disp_cc_mdss_edp_link_clk.clkr,
1177     [DISP_CC_MDSS_EDP_LINK_CLK_SRC] = &disp_cc_mdss_edp_link_clk_src.clkr,
1178     [DISP_CC_MDSS_EDP_LINK_INTF_CLK] = &disp_cc_mdss_edp_link_intf_clk.clkr,
1179     [DISP_CC_MDSS_EDP_PIXEL_CLK] = &disp_cc_mdss_edp_pixel_clk.clkr,
1180     [DISP_CC_MDSS_EDP_PIXEL_CLK_SRC] = &disp_cc_mdss_edp_pixel_clk_src.clkr,
1181     [DISP_CC_MDSS_ESC0_CLK] = &disp_cc_mdss_esc0_clk.clkr,
1182     [DISP_CC_MDSS_ESC0_CLK_SRC] = &disp_cc_mdss_esc0_clk_src.clkr,
1183     [DISP_CC_MDSS_ESC1_CLK] = &disp_cc_mdss_esc1_clk.clkr,
1184     [DISP_CC_MDSS_ESC1_CLK_SRC] = &disp_cc_mdss_esc1_clk_src.clkr,
1185     [DISP_CC_MDSS_MDP_CLK] = &disp_cc_mdss_mdp_clk.clkr,
1186     [DISP_CC_MDSS_MDP_CLK_SRC] = &disp_cc_mdss_mdp_clk_src.clkr,
1187     [DISP_CC_MDSS_MDP_LUT_CLK] = &disp_cc_mdss_mdp_lut_clk.clkr,
1188     [DISP_CC_MDSS_NON_GDSC_AHB_CLK] = &disp_cc_mdss_non_gdsc_ahb_clk.clkr,
1189     [DISP_CC_MDSS_PCLK0_CLK] = &disp_cc_mdss_pclk0_clk.clkr,
1190     [DISP_CC_MDSS_PCLK0_CLK_SRC] = &disp_cc_mdss_pclk0_clk_src.clkr,
1191     [DISP_CC_MDSS_PCLK1_CLK] = &disp_cc_mdss_pclk1_clk.clkr,
1192     [DISP_CC_MDSS_PCLK1_CLK_SRC] = &disp_cc_mdss_pclk1_clk_src.clkr,
1193     [DISP_CC_MDSS_ROT_CLK] = &disp_cc_mdss_rot_clk.clkr,
1194     [DISP_CC_MDSS_ROT_CLK_SRC] = &disp_cc_mdss_rot_clk_src.clkr,
1195     [DISP_CC_MDSS_RSCC_AHB_CLK] = &disp_cc_mdss_rscc_ahb_clk.clkr,
1196     [DISP_CC_MDSS_RSCC_VSYNC_CLK] = &disp_cc_mdss_rscc_vsync_clk.clkr,
1197     [DISP_CC_MDSS_VSYNC_CLK] = &disp_cc_mdss_vsync_clk.clkr,
1198     [DISP_CC_MDSS_VSYNC_CLK_SRC] = &disp_cc_mdss_vsync_clk_src.clkr,
1199     [DISP_CC_PLL0] = &disp_cc_pll0.clkr,
1200     [DISP_CC_PLL1] = &disp_cc_pll1.clkr,
1201 };
1202 
1203 static const struct qcom_reset_map disp_cc_sm8250_resets[] = {
1204     [DISP_CC_MDSS_CORE_BCR] = { 0x2000 },
1205     [DISP_CC_MDSS_RSCC_BCR] = { 0x4000 },
1206 };
1207 
1208 static struct gdsc *disp_cc_sm8250_gdscs[] = {
1209     [MDSS_GDSC] = &mdss_gdsc,
1210 };
1211 
1212 static const struct regmap_config disp_cc_sm8250_regmap_config = {
1213     .reg_bits   = 32,
1214     .reg_stride = 4,
1215     .val_bits   = 32,
1216     .max_register   = 0x10000,
1217     .fast_io    = true,
1218 };
1219 
1220 static const struct qcom_cc_desc disp_cc_sm8250_desc = {
1221     .config = &disp_cc_sm8250_regmap_config,
1222     .clks = disp_cc_sm8250_clocks,
1223     .num_clks = ARRAY_SIZE(disp_cc_sm8250_clocks),
1224     .resets = disp_cc_sm8250_resets,
1225     .num_resets = ARRAY_SIZE(disp_cc_sm8250_resets),
1226     .gdscs = disp_cc_sm8250_gdscs,
1227     .num_gdscs = ARRAY_SIZE(disp_cc_sm8250_gdscs),
1228 };
1229 
1230 static const struct of_device_id disp_cc_sm8250_match_table[] = {
1231     { .compatible = "qcom,sc8180x-dispcc" },
1232     { .compatible = "qcom,sm8150-dispcc" },
1233     { .compatible = "qcom,sm8250-dispcc" },
1234     { .compatible = "qcom,sm8350-dispcc" },
1235     { }
1236 };
1237 MODULE_DEVICE_TABLE(of, disp_cc_sm8250_match_table);
1238 
1239 static void disp_cc_sm8250_pm_runtime_disable(void *data)
1240 {
1241     pm_runtime_disable(data);
1242 }
1243 
1244 static int disp_cc_sm8250_probe(struct platform_device *pdev)
1245 {
1246     struct regmap *regmap;
1247     int ret;
1248 
1249     pm_runtime_enable(&pdev->dev);
1250 
1251     ret = devm_add_action_or_reset(&pdev->dev, disp_cc_sm8250_pm_runtime_disable, &pdev->dev);
1252     if (ret)
1253         return ret;
1254 
1255     ret = pm_runtime_resume_and_get(&pdev->dev);
1256     if (ret)
1257         return ret;
1258 
1259     regmap = qcom_cc_map(pdev, &disp_cc_sm8250_desc);
1260     if (IS_ERR(regmap)) {
1261         pm_runtime_put(&pdev->dev);
1262         return PTR_ERR(regmap);
1263     }
1264 
1265     /* Apply differences for SM8150 and SM8350 */
1266     BUILD_BUG_ON(CLK_ALPHA_PLL_TYPE_TRION != CLK_ALPHA_PLL_TYPE_LUCID);
1267     if (of_device_is_compatible(pdev->dev.of_node, "qcom,sc8180x-dispcc") ||
1268         of_device_is_compatible(pdev->dev.of_node, "qcom,sm8150-dispcc")) {
1269         disp_cc_pll0_config.config_ctl_hi_val = 0x00002267;
1270         disp_cc_pll0_config.config_ctl_hi1_val = 0x00000024;
1271         disp_cc_pll0_config.user_ctl_hi1_val = 0x000000D0;
1272         disp_cc_pll0_init.ops = &clk_alpha_pll_trion_ops;
1273         disp_cc_pll1_config.config_ctl_hi_val = 0x00002267;
1274         disp_cc_pll1_config.config_ctl_hi1_val = 0x00000024;
1275         disp_cc_pll1_config.user_ctl_hi1_val = 0x000000D0;
1276         disp_cc_pll1_init.ops = &clk_alpha_pll_trion_ops;
1277     } else if (of_device_is_compatible(pdev->dev.of_node, "qcom,sm8350-dispcc")) {
1278         static struct clk_rcg2 * const rcgs[] = {
1279             &disp_cc_mdss_byte0_clk_src,
1280             &disp_cc_mdss_byte1_clk_src,
1281             &disp_cc_mdss_dp_aux1_clk_src,
1282             &disp_cc_mdss_dp_aux_clk_src,
1283             &disp_cc_mdss_dp_link1_clk_src,
1284             &disp_cc_mdss_dp_link_clk_src,
1285             &disp_cc_mdss_dp_pixel1_clk_src,
1286             &disp_cc_mdss_dp_pixel2_clk_src,
1287             &disp_cc_mdss_dp_pixel_clk_src,
1288             &disp_cc_mdss_esc0_clk_src,
1289             &disp_cc_mdss_mdp_clk_src,
1290             &disp_cc_mdss_pclk0_clk_src,
1291             &disp_cc_mdss_pclk1_clk_src,
1292             &disp_cc_mdss_rot_clk_src,
1293             &disp_cc_mdss_vsync_clk_src,
1294         };
1295         static struct clk_regmap_div * const divs[] = {
1296             &disp_cc_mdss_byte0_div_clk_src,
1297             &disp_cc_mdss_byte1_div_clk_src,
1298             &disp_cc_mdss_dp_link1_div_clk_src,
1299             &disp_cc_mdss_dp_link_div_clk_src,
1300         };
1301         unsigned int i;
1302         static bool offset_applied;
1303 
1304         /*
1305          * note: trion == lucid, except for the prepare() op
1306          * only apply the offsets once (in case of deferred probe)
1307          */
1308         if (!offset_applied) {
1309             for (i = 0; i < ARRAY_SIZE(rcgs); i++)
1310                 rcgs[i]->cmd_rcgr -= 4;
1311 
1312             for (i = 0; i < ARRAY_SIZE(divs); i++) {
1313                 divs[i]->reg -= 4;
1314                 divs[i]->width = 4;
1315             }
1316 
1317             disp_cc_mdss_ahb_clk.halt_reg -= 4;
1318             disp_cc_mdss_ahb_clk.clkr.enable_reg -= 4;
1319 
1320             offset_applied = true;
1321         }
1322 
1323         disp_cc_mdss_ahb_clk_src.cmd_rcgr = 0x22a0;
1324 
1325         disp_cc_pll0_config.config_ctl_hi1_val = 0x2a9a699c;
1326         disp_cc_pll0_config.test_ctl_hi1_val = 0x01800000;
1327         disp_cc_pll0_init.ops = &clk_alpha_pll_lucid_5lpe_ops;
1328         disp_cc_pll0.vco_table = lucid_5lpe_vco;
1329         disp_cc_pll1_config.config_ctl_hi1_val = 0x2a9a699c;
1330         disp_cc_pll1_config.test_ctl_hi1_val = 0x01800000;
1331         disp_cc_pll1_init.ops = &clk_alpha_pll_lucid_5lpe_ops;
1332         disp_cc_pll1.vco_table = lucid_5lpe_vco;
1333     }
1334 
1335     clk_lucid_pll_configure(&disp_cc_pll0, regmap, &disp_cc_pll0_config);
1336     clk_lucid_pll_configure(&disp_cc_pll1, regmap, &disp_cc_pll1_config);
1337 
1338     /* Enable clock gating for MDP clocks */
1339     regmap_update_bits(regmap, 0x8000, 0x10, 0x10);
1340 
1341     /* DISP_CC_XO_CLK always-on */
1342     regmap_update_bits(regmap, 0x605c, BIT(0), BIT(0));
1343 
1344     ret = qcom_cc_really_probe(pdev, &disp_cc_sm8250_desc, regmap);
1345 
1346     pm_runtime_put(&pdev->dev);
1347 
1348     return ret;
1349 }
1350 
1351 static struct platform_driver disp_cc_sm8250_driver = {
1352     .probe = disp_cc_sm8250_probe,
1353     .driver = {
1354         .name = "disp_cc-sm8250",
1355         .of_match_table = disp_cc_sm8250_match_table,
1356     },
1357 };
1358 
1359 static int __init disp_cc_sm8250_init(void)
1360 {
1361     return platform_driver_register(&disp_cc_sm8250_driver);
1362 }
1363 subsys_initcall(disp_cc_sm8250_init);
1364 
1365 static void __exit disp_cc_sm8250_exit(void)
1366 {
1367     platform_driver_unregister(&disp_cc_sm8250_driver);
1368 }
1369 module_exit(disp_cc_sm8250_exit);
1370 
1371 MODULE_DESCRIPTION("QTI DISPCC SM8250 Driver");
1372 MODULE_LICENSE("GPL v2");