Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
Deepak Katragadda | 9abd794 | 2017-06-13 14:20:09 -0700 | [diff] [blame] | 14 | #define pr_fmt(fmt) "clk: %s: " fmt, __func__ |
| 15 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/bitops.h> |
| 18 | #include <linux/err.h> |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/of.h> |
| 22 | #include <linux/of_device.h> |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/clk-provider.h> |
| 25 | #include <linux/regmap.h> |
| 26 | #include <linux/reset-controller.h> |
| 27 | |
| 28 | #include <dt-bindings/clock/qcom,dispcc-sdm845.h> |
| 29 | |
| 30 | #include "common.h" |
| 31 | #include "clk-regmap.h" |
| 32 | #include "clk-pll.h" |
| 33 | #include "clk-rcg.h" |
| 34 | #include "clk-branch.h" |
| 35 | #include "reset.h" |
| 36 | #include "clk-alpha-pll.h" |
| 37 | #include "vdd-level-sdm845.h" |
| 38 | #include "clk-regmap-divider.h" |
| 39 | |
| 40 | #define DISP_CC_MISC_CMD 0x8000 |
| 41 | |
| 42 | #define F(f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) } |
| 43 | #define F_SLEW(f, s, h, m, n, src_freq) { (f), (s), (2 * (h) - 1), (m), (n), \ |
| 44 | (src_freq) } |
| 45 | |
| 46 | static DEFINE_VDD_REGULATORS(vdd_cx, VDD_CX_NUM, 1, vdd_corner); |
| 47 | |
| 48 | enum { |
| 49 | P_BI_TCXO, |
| 50 | P_CORE_BI_PLL_TEST_SE, |
| 51 | P_DISP_CC_PLL0_OUT_MAIN, |
| 52 | P_DP_PHY_PLL_LINK_CLK, |
| 53 | P_DP_PHY_PLL_VCO_DIV_CLK, |
| 54 | P_DSI0_PHY_PLL_OUT_BYTECLK, |
| 55 | P_DSI0_PHY_PLL_OUT_DSICLK, |
| 56 | P_DSI1_PHY_PLL_OUT_BYTECLK, |
| 57 | P_DSI1_PHY_PLL_OUT_DSICLK, |
| 58 | P_GPLL0_OUT_MAIN, |
| 59 | P_GPLL0_OUT_MAIN_DIV, |
| 60 | }; |
| 61 | |
| 62 | static const struct parent_map disp_cc_parent_map_0[] = { |
| 63 | { P_BI_TCXO, 0 }, |
| 64 | { P_DSI0_PHY_PLL_OUT_BYTECLK, 1 }, |
| 65 | { P_DSI1_PHY_PLL_OUT_BYTECLK, 2 }, |
| 66 | { P_CORE_BI_PLL_TEST_SE, 7 }, |
| 67 | }; |
| 68 | |
| 69 | static const char * const disp_cc_parent_names_0[] = { |
| 70 | "bi_tcxo", |
| 71 | "dsi0_phy_pll_out_byteclk", |
| 72 | "dsi1_phy_pll_out_byteclk", |
| 73 | "core_bi_pll_test_se", |
| 74 | }; |
| 75 | |
| 76 | static const struct parent_map disp_cc_parent_map_1[] = { |
| 77 | { P_BI_TCXO, 0 }, |
| 78 | { P_DP_PHY_PLL_LINK_CLK, 1 }, |
| 79 | { P_DP_PHY_PLL_VCO_DIV_CLK, 2 }, |
| 80 | { P_CORE_BI_PLL_TEST_SE, 7 }, |
| 81 | }; |
| 82 | |
| 83 | static const char * const disp_cc_parent_names_1[] = { |
| 84 | "bi_tcxo", |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 85 | "dp_link_clk_divsel_ten", |
| 86 | "dp_vco_divided_clk_src_mux", |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 87 | "core_bi_pll_test_se", |
| 88 | }; |
| 89 | |
| 90 | static const struct parent_map disp_cc_parent_map_2[] = { |
| 91 | { P_BI_TCXO, 0 }, |
| 92 | { P_CORE_BI_PLL_TEST_SE, 7 }, |
| 93 | }; |
| 94 | |
| 95 | static const char * const disp_cc_parent_names_2[] = { |
| 96 | "bi_tcxo", |
| 97 | "core_bi_pll_test_se", |
| 98 | }; |
| 99 | |
| 100 | static const struct parent_map disp_cc_parent_map_3[] = { |
| 101 | { P_BI_TCXO, 0 }, |
| 102 | { P_DISP_CC_PLL0_OUT_MAIN, 1 }, |
| 103 | { P_GPLL0_OUT_MAIN, 4 }, |
| 104 | { P_GPLL0_OUT_MAIN_DIV, 5 }, |
| 105 | { P_CORE_BI_PLL_TEST_SE, 7 }, |
| 106 | }; |
| 107 | |
| 108 | static const char * const disp_cc_parent_names_3[] = { |
| 109 | "bi_tcxo", |
| 110 | "disp_cc_pll0", |
Deepak Katragadda | d012b4d | 2017-04-10 12:03:37 -0700 | [diff] [blame] | 111 | "gcc_disp_gpll0_clk_src", |
| 112 | "gcc_disp_gpll0_div_clk_src", |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 113 | "core_bi_pll_test_se", |
| 114 | }; |
| 115 | |
| 116 | static const struct parent_map disp_cc_parent_map_4[] = { |
| 117 | { P_BI_TCXO, 0 }, |
| 118 | { P_DSI0_PHY_PLL_OUT_DSICLK, 1 }, |
| 119 | { P_DSI1_PHY_PLL_OUT_DSICLK, 2 }, |
| 120 | { P_CORE_BI_PLL_TEST_SE, 7 }, |
| 121 | }; |
| 122 | |
| 123 | static const char * const disp_cc_parent_names_4[] = { |
| 124 | "bi_tcxo", |
| 125 | "dsi0_phy_pll_out_dsiclk", |
| 126 | "dsi1_phy_pll_out_dsiclk", |
| 127 | "core_bi_pll_test_se", |
| 128 | }; |
| 129 | |
| 130 | static struct pll_vco fabia_vco[] = { |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 131 | { 249600000, 2000000000, 0 }, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 132 | { 125000000, 1000000000, 1 }, |
| 133 | }; |
| 134 | |
| 135 | static const struct pll_config disp_cc_pll0_config = { |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 136 | .l = 0x15, |
| 137 | .frac = 0x7c00, |
| 138 | }; |
| 139 | |
| 140 | static const struct pll_config disp_cc_pll0_config_v2 = { |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 141 | .l = 0x2c, |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 142 | .frac = 0xcaaa, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | static struct clk_alpha_pll disp_cc_pll0 = { |
| 146 | .offset = 0x0, |
| 147 | .vco_table = fabia_vco, |
| 148 | .num_vco = ARRAY_SIZE(fabia_vco), |
| 149 | .type = FABIA_PLL, |
| 150 | .clkr = { |
| 151 | .hw.init = &(struct clk_init_data){ |
| 152 | .name = "disp_cc_pll0", |
| 153 | .parent_names = (const char *[]){ "bi_tcxo" }, |
| 154 | .num_parents = 1, |
| 155 | .ops = &clk_fabia_pll_ops, |
Deepak Katragadda | d04d2ca | 2017-03-30 11:03:20 -0700 | [diff] [blame] | 156 | VDD_CX_FMAX_MAP4( |
| 157 | MIN, 615000000, |
| 158 | LOW, 1066000000, |
| 159 | LOW_L1, 1600000000, |
| 160 | NOMINAL, 2000000000), |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 161 | }, |
| 162 | }, |
| 163 | }; |
| 164 | |
| 165 | static struct clk_rcg2 disp_cc_mdss_byte0_clk_src = { |
| 166 | .cmd_rcgr = 0x20d0, |
| 167 | .mnd_width = 0, |
| 168 | .hid_width = 5, |
| 169 | .parent_map = disp_cc_parent_map_0, |
| 170 | .clkr.hw.init = &(struct clk_init_data){ |
| 171 | .name = "disp_cc_mdss_byte0_clk_src", |
| 172 | .parent_names = disp_cc_parent_names_0, |
| 173 | .num_parents = 4, |
| 174 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 175 | .ops = &clk_byte2_ops, |
| 176 | VDD_CX_FMAX_MAP5( |
| 177 | MIN, 19200000, |
| 178 | LOWER, 150000000, |
| 179 | LOW, 240000000, |
| 180 | LOW_L1, 262500000, |
| 181 | NOMINAL, 358000000), |
| 182 | }, |
| 183 | }; |
| 184 | |
| 185 | static struct clk_rcg2 disp_cc_mdss_byte1_clk_src = { |
| 186 | .cmd_rcgr = 0x20ec, |
| 187 | .mnd_width = 0, |
| 188 | .hid_width = 5, |
| 189 | .parent_map = disp_cc_parent_map_0, |
| 190 | .clkr.hw.init = &(struct clk_init_data){ |
| 191 | .name = "disp_cc_mdss_byte1_clk_src", |
| 192 | .parent_names = disp_cc_parent_names_0, |
| 193 | .num_parents = 4, |
| 194 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 195 | .ops = &clk_byte2_ops, |
| 196 | VDD_CX_FMAX_MAP5( |
| 197 | MIN, 19200000, |
| 198 | LOWER, 150000000, |
| 199 | LOW, 240000000, |
| 200 | LOW_L1, 262500000, |
| 201 | NOMINAL, 358000000), |
| 202 | }, |
| 203 | }; |
| 204 | |
| 205 | static const struct freq_tbl ftbl_disp_cc_mdss_dp_aux_clk_src[] = { |
| 206 | F(19200000, P_BI_TCXO, 1, 0, 0), |
| 207 | { } |
| 208 | }; |
| 209 | |
| 210 | static struct clk_rcg2 disp_cc_mdss_dp_aux_clk_src = { |
| 211 | .cmd_rcgr = 0x219c, |
| 212 | .mnd_width = 0, |
| 213 | .hid_width = 5, |
| 214 | .parent_map = disp_cc_parent_map_2, |
| 215 | .freq_tbl = ftbl_disp_cc_mdss_dp_aux_clk_src, |
| 216 | .clkr.hw.init = &(struct clk_init_data){ |
| 217 | .name = "disp_cc_mdss_dp_aux_clk_src", |
| 218 | .parent_names = disp_cc_parent_names_2, |
| 219 | .num_parents = 2, |
| 220 | .flags = CLK_SET_RATE_PARENT, |
| 221 | .ops = &clk_rcg2_ops, |
| 222 | VDD_CX_FMAX_MAP1( |
| 223 | MIN, 19200000), |
| 224 | }, |
| 225 | }; |
| 226 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 227 | static const struct freq_tbl ftbl_disp_cc_mdss_dp_crypto_clk_src[] = { |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 228 | F( 108000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0), |
| 229 | F( 180000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0), |
| 230 | F( 360000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0), |
| 231 | F( 540000, P_DP_PHY_PLL_LINK_CLK, 3, 0, 0), |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 232 | { } |
| 233 | }; |
| 234 | |
| 235 | static struct clk_rcg2 disp_cc_mdss_dp_crypto_clk_src = { |
| 236 | .cmd_rcgr = 0x2154, |
| 237 | .mnd_width = 0, |
| 238 | .hid_width = 5, |
| 239 | .parent_map = disp_cc_parent_map_1, |
| 240 | .freq_tbl = ftbl_disp_cc_mdss_dp_crypto_clk_src, |
| 241 | .clkr.hw.init = &(struct clk_init_data){ |
| 242 | .name = "disp_cc_mdss_dp_crypto_clk_src", |
| 243 | .parent_names = disp_cc_parent_names_1, |
| 244 | .num_parents = 4, |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 245 | .flags = CLK_GET_RATE_NOCACHE, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 246 | .ops = &clk_rcg2_ops, |
| 247 | VDD_CX_FMAX_MAP5( |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 248 | MIN, 12800, |
| 249 | LOWER, 108000, |
| 250 | LOW, 180000, |
| 251 | LOW_L1, 360000, |
| 252 | NOMINAL, 540000), |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 253 | }, |
| 254 | }; |
| 255 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 256 | static const struct freq_tbl ftbl_disp_cc_mdss_dp_link_clk_src[] = { |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 257 | F( 162000, P_DP_PHY_PLL_LINK_CLK, 1, 0, 0), |
| 258 | F( 270000, P_DP_PHY_PLL_LINK_CLK, 1, 0, 0), |
| 259 | F( 540000, P_DP_PHY_PLL_LINK_CLK, 1, 0, 0), |
| 260 | F( 810000, P_DP_PHY_PLL_LINK_CLK, 1, 0, 0), |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 261 | { } |
| 262 | }; |
| 263 | |
| 264 | static struct clk_rcg2 disp_cc_mdss_dp_link_clk_src = { |
| 265 | .cmd_rcgr = 0x2138, |
| 266 | .mnd_width = 0, |
| 267 | .hid_width = 5, |
| 268 | .parent_map = disp_cc_parent_map_1, |
| 269 | .freq_tbl = ftbl_disp_cc_mdss_dp_link_clk_src, |
| 270 | .clkr.hw.init = &(struct clk_init_data){ |
| 271 | .name = "disp_cc_mdss_dp_link_clk_src", |
| 272 | .parent_names = disp_cc_parent_names_1, |
| 273 | .num_parents = 4, |
| 274 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 275 | .ops = &clk_rcg2_ops, |
| 276 | VDD_CX_FMAX_MAP5( |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 277 | MIN, 19200, |
| 278 | LOWER, 162000, |
| 279 | LOW, 270000, |
| 280 | LOW_L1, 540000, |
| 281 | NOMINAL, 810000), |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 282 | }, |
| 283 | }; |
| 284 | |
| 285 | static struct clk_rcg2 disp_cc_mdss_dp_pixel1_clk_src = { |
| 286 | .cmd_rcgr = 0x2184, |
| 287 | .mnd_width = 16, |
| 288 | .hid_width = 5, |
| 289 | .parent_map = disp_cc_parent_map_1, |
| 290 | .clkr.hw.init = &(struct clk_init_data){ |
| 291 | .name = "disp_cc_mdss_dp_pixel1_clk_src", |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 292 | .parent_names = disp_cc_parent_names_1, |
| 293 | .num_parents = 4, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 294 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 295 | .ops = &clk_dp_ops, |
| 296 | VDD_CX_FMAX_MAP4( |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 297 | MIN, 19200, |
| 298 | LOWER, 202500, |
| 299 | LOW, 296735, |
| 300 | LOW_L1, 675000), |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 301 | }, |
| 302 | }; |
| 303 | |
| 304 | static struct clk_rcg2 disp_cc_mdss_dp_pixel_clk_src = { |
| 305 | .cmd_rcgr = 0x216c, |
| 306 | .mnd_width = 16, |
| 307 | .hid_width = 5, |
| 308 | .parent_map = disp_cc_parent_map_1, |
| 309 | .clkr.hw.init = &(struct clk_init_data){ |
| 310 | .name = "disp_cc_mdss_dp_pixel_clk_src", |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 311 | .parent_names = disp_cc_parent_names_1, |
| 312 | .num_parents = 4, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 313 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 314 | .ops = &clk_dp_ops, |
| 315 | VDD_CX_FMAX_MAP4( |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 316 | MIN, 19200, |
| 317 | LOWER, 202500, |
| 318 | LOW, 296735, |
| 319 | LOW_L1, 675000), |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 320 | }, |
| 321 | }; |
| 322 | |
| 323 | static const struct freq_tbl ftbl_disp_cc_mdss_esc0_clk_src[] = { |
| 324 | F(19200000, P_BI_TCXO, 1, 0, 0), |
| 325 | { } |
| 326 | }; |
| 327 | |
| 328 | static struct clk_rcg2 disp_cc_mdss_esc0_clk_src = { |
| 329 | .cmd_rcgr = 0x2108, |
| 330 | .mnd_width = 0, |
| 331 | .hid_width = 5, |
| 332 | .parent_map = disp_cc_parent_map_0, |
| 333 | .freq_tbl = ftbl_disp_cc_mdss_esc0_clk_src, |
| 334 | .clkr.hw.init = &(struct clk_init_data){ |
| 335 | .name = "disp_cc_mdss_esc0_clk_src", |
| 336 | .parent_names = disp_cc_parent_names_0, |
| 337 | .num_parents = 4, |
| 338 | .flags = CLK_SET_RATE_PARENT, |
| 339 | .ops = &clk_rcg2_ops, |
| 340 | VDD_CX_FMAX_MAP1( |
| 341 | MIN, 19200000), |
| 342 | }, |
| 343 | }; |
| 344 | |
| 345 | static struct clk_rcg2 disp_cc_mdss_esc1_clk_src = { |
| 346 | .cmd_rcgr = 0x2120, |
| 347 | .mnd_width = 0, |
| 348 | .hid_width = 5, |
| 349 | .parent_map = disp_cc_parent_map_0, |
| 350 | .freq_tbl = ftbl_disp_cc_mdss_esc0_clk_src, |
| 351 | .clkr.hw.init = &(struct clk_init_data){ |
| 352 | .name = "disp_cc_mdss_esc1_clk_src", |
| 353 | .parent_names = disp_cc_parent_names_0, |
| 354 | .num_parents = 4, |
| 355 | .flags = CLK_SET_RATE_PARENT, |
| 356 | .ops = &clk_rcg2_ops, |
| 357 | VDD_CX_FMAX_MAP1( |
| 358 | MIN, 19200000), |
| 359 | }, |
| 360 | }; |
| 361 | |
| 362 | static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src[] = { |
| 363 | F(19200000, P_BI_TCXO, 1, 0, 0), |
| 364 | F(85714286, P_GPLL0_OUT_MAIN, 7, 0, 0), |
| 365 | F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0), |
| 366 | F(150000000, P_GPLL0_OUT_MAIN, 4, 0, 0), |
| 367 | F(165000000, P_DISP_CC_PLL0_OUT_MAIN, 2.5, 0, 0), |
| 368 | F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0), |
| 369 | F(275000000, P_DISP_CC_PLL0_OUT_MAIN, 1.5, 0, 0), |
| 370 | F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0), |
| 371 | F(412500000, P_DISP_CC_PLL0_OUT_MAIN, 1, 0, 0), |
| 372 | { } |
| 373 | }; |
| 374 | |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 375 | static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src_sdm845_v2[] = { |
| 376 | F(19200000, P_BI_TCXO, 1, 0, 0), |
| 377 | F(85714286, P_GPLL0_OUT_MAIN, 7, 0, 0), |
| 378 | F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0), |
| 379 | F(150000000, P_GPLL0_OUT_MAIN, 4, 0, 0), |
| 380 | F(171428571, P_GPLL0_OUT_MAIN, 3.5, 0, 0), |
| 381 | F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0), |
| 382 | F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0), |
| 383 | F(344000000, P_DISP_CC_PLL0_OUT_MAIN, 2.5, 0, 0), |
| 384 | F(430000000, P_DISP_CC_PLL0_OUT_MAIN, 2, 0, 0), |
| 385 | { } |
| 386 | }; |
| 387 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 388 | static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = { |
| 389 | .cmd_rcgr = 0x2088, |
| 390 | .mnd_width = 0, |
| 391 | .hid_width = 5, |
| 392 | .parent_map = disp_cc_parent_map_3, |
| 393 | .freq_tbl = ftbl_disp_cc_mdss_mdp_clk_src, |
| 394 | .enable_safe_config = true, |
| 395 | .clkr.hw.init = &(struct clk_init_data){ |
| 396 | .name = "disp_cc_mdss_mdp_clk_src", |
| 397 | .parent_names = disp_cc_parent_names_3, |
| 398 | .num_parents = 5, |
| 399 | .flags = CLK_SET_RATE_PARENT, |
| 400 | .ops = &clk_rcg2_ops, |
| 401 | VDD_CX_FMAX_MAP4( |
| 402 | MIN, 19200000, |
| 403 | LOWER, 165000000, |
| 404 | LOW, 300000000, |
| 405 | NOMINAL, 412500000), |
| 406 | }, |
| 407 | }; |
| 408 | |
| 409 | static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = { |
| 410 | .cmd_rcgr = 0x2058, |
| 411 | .mnd_width = 8, |
| 412 | .hid_width = 5, |
| 413 | .parent_map = disp_cc_parent_map_4, |
| 414 | .clkr.hw.init = &(struct clk_init_data){ |
| 415 | .name = "disp_cc_mdss_pclk0_clk_src", |
| 416 | .parent_names = disp_cc_parent_names_4, |
| 417 | .num_parents = 4, |
| 418 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 419 | .ops = &clk_pixel_ops, |
| 420 | VDD_CX_FMAX_MAP5( |
| 421 | MIN, 19200000, |
| 422 | LOWER, 184000000, |
| 423 | LOW, 295000000, |
| 424 | LOW_L1, 350000000, |
| 425 | NOMINAL, 571428571), |
| 426 | }, |
| 427 | }; |
| 428 | |
| 429 | static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = { |
| 430 | .cmd_rcgr = 0x2070, |
| 431 | .mnd_width = 8, |
| 432 | .hid_width = 5, |
| 433 | .parent_map = disp_cc_parent_map_4, |
| 434 | .clkr.hw.init = &(struct clk_init_data){ |
| 435 | .name = "disp_cc_mdss_pclk1_clk_src", |
| 436 | .parent_names = disp_cc_parent_names_4, |
| 437 | .num_parents = 4, |
| 438 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 439 | .ops = &clk_pixel_ops, |
| 440 | VDD_CX_FMAX_MAP5( |
| 441 | MIN, 19200000, |
| 442 | LOWER, 184000000, |
| 443 | LOW, 295000000, |
| 444 | LOW_L1, 350000000, |
| 445 | NOMINAL, 571428571), |
| 446 | }, |
| 447 | }; |
| 448 | |
| 449 | static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src[] = { |
| 450 | F(19200000, P_BI_TCXO, 1, 0, 0), |
| 451 | F(165000000, P_DISP_CC_PLL0_OUT_MAIN, 2.5, 0, 0), |
| 452 | F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0), |
| 453 | F(412500000, P_DISP_CC_PLL0_OUT_MAIN, 1, 0, 0), |
| 454 | { } |
| 455 | }; |
| 456 | |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 457 | static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src_sdm845_v2[] = { |
| 458 | F(19200000, P_BI_TCXO, 1, 0, 0), |
| 459 | F(171428571, P_GPLL0_OUT_MAIN, 3.5, 0, 0), |
| 460 | F(300000000, P_GPLL0_OUT_MAIN, 2, 0, 0), |
| 461 | F(344000000, P_DISP_CC_PLL0_OUT_MAIN, 2.5, 0, 0), |
| 462 | F(430000000, P_DISP_CC_PLL0_OUT_MAIN, 2, 0, 0), |
| 463 | { } |
| 464 | }; |
| 465 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 466 | static struct clk_rcg2 disp_cc_mdss_rot_clk_src = { |
| 467 | .cmd_rcgr = 0x20a0, |
| 468 | .mnd_width = 0, |
| 469 | .hid_width = 5, |
| 470 | .parent_map = disp_cc_parent_map_3, |
| 471 | .freq_tbl = ftbl_disp_cc_mdss_rot_clk_src, |
| 472 | .enable_safe_config = true, |
| 473 | .clkr.hw.init = &(struct clk_init_data){ |
| 474 | .name = "disp_cc_mdss_rot_clk_src", |
| 475 | .parent_names = disp_cc_parent_names_3, |
| 476 | .num_parents = 5, |
| 477 | .flags = CLK_SET_RATE_PARENT, |
| 478 | .ops = &clk_rcg2_ops, |
| 479 | VDD_CX_FMAX_MAP4( |
| 480 | MIN, 19200000, |
| 481 | LOWER, 165000000, |
| 482 | LOW, 300000000, |
| 483 | NOMINAL, 412500000), |
| 484 | }, |
| 485 | }; |
| 486 | |
| 487 | static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = { |
| 488 | .cmd_rcgr = 0x20b8, |
| 489 | .mnd_width = 0, |
| 490 | .hid_width = 5, |
| 491 | .parent_map = disp_cc_parent_map_2, |
| 492 | .freq_tbl = ftbl_disp_cc_mdss_esc0_clk_src, |
| 493 | .clkr.hw.init = &(struct clk_init_data){ |
| 494 | .name = "disp_cc_mdss_vsync_clk_src", |
| 495 | .parent_names = disp_cc_parent_names_2, |
| 496 | .num_parents = 2, |
| 497 | .flags = CLK_SET_RATE_PARENT, |
| 498 | .ops = &clk_rcg2_ops, |
| 499 | VDD_CX_FMAX_MAP1( |
| 500 | MIN, 19200000), |
| 501 | }, |
| 502 | }; |
| 503 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 504 | static struct clk_branch disp_cc_mdss_ahb_clk = { |
| 505 | .halt_reg = 0x4004, |
| 506 | .halt_check = BRANCH_HALT, |
| 507 | .clkr = { |
| 508 | .enable_reg = 0x4004, |
| 509 | .enable_mask = BIT(0), |
| 510 | .hw.init = &(struct clk_init_data){ |
| 511 | .name = "disp_cc_mdss_ahb_clk", |
| 512 | .ops = &clk_branch2_ops, |
| 513 | }, |
| 514 | }, |
| 515 | }; |
| 516 | |
| 517 | static struct clk_branch disp_cc_mdss_axi_clk = { |
| 518 | .halt_reg = 0x4008, |
| 519 | .halt_check = BRANCH_HALT, |
| 520 | .clkr = { |
| 521 | .enable_reg = 0x4008, |
| 522 | .enable_mask = BIT(0), |
| 523 | .hw.init = &(struct clk_init_data){ |
| 524 | .name = "disp_cc_mdss_axi_clk", |
| 525 | .ops = &clk_branch2_ops, |
| 526 | }, |
| 527 | }, |
| 528 | }; |
| 529 | |
| 530 | static struct clk_branch disp_cc_mdss_byte0_clk = { |
| 531 | .halt_reg = 0x2028, |
| 532 | .halt_check = BRANCH_HALT, |
| 533 | .clkr = { |
| 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_names = (const char *[]){ |
| 539 | "disp_cc_mdss_byte0_clk_src", |
| 540 | }, |
| 541 | .num_parents = 1, |
| 542 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 543 | .ops = &clk_branch2_ops, |
| 544 | }, |
| 545 | }, |
| 546 | }; |
| 547 | |
| 548 | static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = { |
| 549 | .reg = 0x20e8, |
| 550 | .shift = 0, |
| 551 | .width = 2, |
| 552 | .clkr = { |
| 553 | .hw.init = &(struct clk_init_data){ |
| 554 | .name = "disp_cc_mdss_byte0_div_clk_src", |
| 555 | .parent_names = (const char *[]){ |
| 556 | "disp_cc_mdss_byte0_clk_src", |
| 557 | }, |
| 558 | .num_parents = 1, |
Deepak Katragadda | 638c12e | 2017-04-20 14:56:53 -0700 | [diff] [blame] | 559 | .flags = CLK_GET_RATE_NOCACHE, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 560 | .ops = &clk_regmap_div_ops, |
| 561 | }, |
| 562 | }, |
| 563 | }; |
| 564 | |
| 565 | static struct clk_branch disp_cc_mdss_byte0_intf_clk = { |
| 566 | .halt_reg = 0x202c, |
| 567 | .halt_check = BRANCH_HALT, |
| 568 | .clkr = { |
| 569 | .enable_reg = 0x202c, |
| 570 | .enable_mask = BIT(0), |
| 571 | .hw.init = &(struct clk_init_data){ |
| 572 | .name = "disp_cc_mdss_byte0_intf_clk", |
| 573 | .parent_names = (const char *[]){ |
| 574 | "disp_cc_mdss_byte0_div_clk_src", |
| 575 | }, |
| 576 | .num_parents = 1, |
| 577 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 578 | .ops = &clk_branch2_ops, |
| 579 | }, |
| 580 | }, |
| 581 | }; |
| 582 | |
| 583 | static struct clk_branch disp_cc_mdss_byte1_clk = { |
| 584 | .halt_reg = 0x2030, |
| 585 | .halt_check = BRANCH_HALT, |
| 586 | .clkr = { |
| 587 | .enable_reg = 0x2030, |
| 588 | .enable_mask = BIT(0), |
| 589 | .hw.init = &(struct clk_init_data){ |
| 590 | .name = "disp_cc_mdss_byte1_clk", |
| 591 | .parent_names = (const char *[]){ |
| 592 | "disp_cc_mdss_byte1_clk_src", |
| 593 | }, |
| 594 | .num_parents = 1, |
| 595 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 596 | .ops = &clk_branch2_ops, |
| 597 | }, |
| 598 | }, |
| 599 | }; |
| 600 | |
| 601 | static struct clk_regmap_div disp_cc_mdss_byte1_div_clk_src = { |
| 602 | .reg = 0x2104, |
| 603 | .shift = 0, |
| 604 | .width = 2, |
| 605 | .clkr = { |
| 606 | .hw.init = &(struct clk_init_data){ |
| 607 | .name = "disp_cc_mdss_byte1_div_clk_src", |
| 608 | .parent_names = (const char *[]){ |
| 609 | "disp_cc_mdss_byte1_clk_src", |
| 610 | }, |
| 611 | .num_parents = 1, |
Deepak Katragadda | 638c12e | 2017-04-20 14:56:53 -0700 | [diff] [blame] | 612 | .flags = CLK_GET_RATE_NOCACHE, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 613 | .ops = &clk_regmap_div_ops, |
| 614 | }, |
| 615 | }, |
| 616 | }; |
| 617 | |
| 618 | static struct clk_branch disp_cc_mdss_byte1_intf_clk = { |
| 619 | .halt_reg = 0x2034, |
| 620 | .halt_check = BRANCH_HALT, |
| 621 | .clkr = { |
| 622 | .enable_reg = 0x2034, |
| 623 | .enable_mask = BIT(0), |
| 624 | .hw.init = &(struct clk_init_data){ |
| 625 | .name = "disp_cc_mdss_byte1_intf_clk", |
| 626 | .parent_names = (const char *[]){ |
| 627 | "disp_cc_mdss_byte1_div_clk_src", |
| 628 | }, |
| 629 | .num_parents = 1, |
| 630 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 631 | .ops = &clk_branch2_ops, |
| 632 | }, |
| 633 | }, |
| 634 | }; |
| 635 | |
| 636 | static struct clk_branch disp_cc_mdss_dp_aux_clk = { |
| 637 | .halt_reg = 0x2054, |
| 638 | .halt_check = BRANCH_HALT, |
| 639 | .clkr = { |
| 640 | .enable_reg = 0x2054, |
| 641 | .enable_mask = BIT(0), |
| 642 | .hw.init = &(struct clk_init_data){ |
| 643 | .name = "disp_cc_mdss_dp_aux_clk", |
| 644 | .parent_names = (const char *[]){ |
| 645 | "disp_cc_mdss_dp_aux_clk_src", |
| 646 | }, |
| 647 | .num_parents = 1, |
| 648 | .flags = CLK_SET_RATE_PARENT, |
| 649 | .ops = &clk_branch2_ops, |
| 650 | }, |
| 651 | }, |
| 652 | }; |
| 653 | |
| 654 | static struct clk_branch disp_cc_mdss_dp_crypto_clk = { |
| 655 | .halt_reg = 0x2048, |
| 656 | .halt_check = BRANCH_HALT, |
| 657 | .clkr = { |
| 658 | .enable_reg = 0x2048, |
| 659 | .enable_mask = BIT(0), |
| 660 | .hw.init = &(struct clk_init_data){ |
| 661 | .name = "disp_cc_mdss_dp_crypto_clk", |
| 662 | .parent_names = (const char *[]){ |
| 663 | "disp_cc_mdss_dp_crypto_clk_src", |
| 664 | }, |
| 665 | .num_parents = 1, |
| 666 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 667 | .ops = &clk_branch2_ops, |
| 668 | }, |
| 669 | }, |
| 670 | }; |
| 671 | |
| 672 | static struct clk_branch disp_cc_mdss_dp_link_clk = { |
| 673 | .halt_reg = 0x2040, |
| 674 | .halt_check = BRANCH_HALT, |
| 675 | .clkr = { |
| 676 | .enable_reg = 0x2040, |
| 677 | .enable_mask = BIT(0), |
| 678 | .hw.init = &(struct clk_init_data){ |
| 679 | .name = "disp_cc_mdss_dp_link_clk", |
| 680 | .parent_names = (const char *[]){ |
| 681 | "disp_cc_mdss_dp_link_clk_src", |
| 682 | }, |
| 683 | .num_parents = 1, |
| 684 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 685 | .ops = &clk_branch2_ops, |
| 686 | }, |
| 687 | }, |
| 688 | }; |
| 689 | |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 690 | /* reset state of disp_cc_mdss_dp_link_div_clk_src divider is 0x3 (div 4) */ |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 691 | static struct clk_branch disp_cc_mdss_dp_link_intf_clk = { |
| 692 | .halt_reg = 0x2044, |
| 693 | .halt_check = BRANCH_HALT, |
| 694 | .clkr = { |
| 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_names = (const char *[]){ |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 700 | "disp_cc_mdss_dp_link_clk_src", |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 701 | }, |
| 702 | .num_parents = 1, |
Padmanabhan Komanduru | 3fadf2a | 2017-05-02 15:29:35 -0700 | [diff] [blame] | 703 | .flags = CLK_GET_RATE_NOCACHE, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 704 | .ops = &clk_branch2_ops, |
| 705 | }, |
| 706 | }, |
| 707 | }; |
| 708 | |
| 709 | static struct clk_branch disp_cc_mdss_dp_pixel1_clk = { |
| 710 | .halt_reg = 0x2050, |
| 711 | .halt_check = BRANCH_HALT, |
| 712 | .clkr = { |
| 713 | .enable_reg = 0x2050, |
| 714 | .enable_mask = BIT(0), |
| 715 | .hw.init = &(struct clk_init_data){ |
| 716 | .name = "disp_cc_mdss_dp_pixel1_clk", |
| 717 | .parent_names = (const char *[]){ |
| 718 | "disp_cc_mdss_dp_pixel1_clk_src", |
| 719 | }, |
| 720 | .num_parents = 1, |
| 721 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 722 | .ops = &clk_branch2_ops, |
| 723 | }, |
| 724 | }, |
| 725 | }; |
| 726 | |
| 727 | static struct clk_branch disp_cc_mdss_dp_pixel_clk = { |
| 728 | .halt_reg = 0x204c, |
| 729 | .halt_check = BRANCH_HALT, |
| 730 | .clkr = { |
| 731 | .enable_reg = 0x204c, |
| 732 | .enable_mask = BIT(0), |
| 733 | .hw.init = &(struct clk_init_data){ |
| 734 | .name = "disp_cc_mdss_dp_pixel_clk", |
| 735 | .parent_names = (const char *[]){ |
| 736 | "disp_cc_mdss_dp_pixel_clk_src", |
| 737 | }, |
| 738 | .num_parents = 1, |
| 739 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 740 | .ops = &clk_branch2_ops, |
| 741 | }, |
| 742 | }, |
| 743 | }; |
| 744 | |
| 745 | static struct clk_branch disp_cc_mdss_esc0_clk = { |
| 746 | .halt_reg = 0x2038, |
| 747 | .halt_check = BRANCH_HALT, |
| 748 | .clkr = { |
| 749 | .enable_reg = 0x2038, |
| 750 | .enable_mask = BIT(0), |
| 751 | .hw.init = &(struct clk_init_data){ |
| 752 | .name = "disp_cc_mdss_esc0_clk", |
| 753 | .parent_names = (const char *[]){ |
| 754 | "disp_cc_mdss_esc0_clk_src", |
| 755 | }, |
| 756 | .num_parents = 1, |
| 757 | .flags = CLK_SET_RATE_PARENT, |
| 758 | .ops = &clk_branch2_ops, |
| 759 | }, |
| 760 | }, |
| 761 | }; |
| 762 | |
| 763 | static struct clk_branch disp_cc_mdss_esc1_clk = { |
| 764 | .halt_reg = 0x203c, |
| 765 | .halt_check = BRANCH_HALT, |
| 766 | .clkr = { |
| 767 | .enable_reg = 0x203c, |
| 768 | .enable_mask = BIT(0), |
| 769 | .hw.init = &(struct clk_init_data){ |
| 770 | .name = "disp_cc_mdss_esc1_clk", |
| 771 | .parent_names = (const char *[]){ |
| 772 | "disp_cc_mdss_esc1_clk_src", |
| 773 | }, |
| 774 | .num_parents = 1, |
| 775 | .flags = CLK_SET_RATE_PARENT, |
| 776 | .ops = &clk_branch2_ops, |
| 777 | }, |
| 778 | }, |
| 779 | }; |
| 780 | |
| 781 | static struct clk_branch disp_cc_mdss_mdp_clk = { |
| 782 | .halt_reg = 0x200c, |
| 783 | .halt_check = BRANCH_HALT, |
| 784 | .clkr = { |
| 785 | .enable_reg = 0x200c, |
| 786 | .enable_mask = BIT(0), |
| 787 | .hw.init = &(struct clk_init_data){ |
| 788 | .name = "disp_cc_mdss_mdp_clk", |
| 789 | .parent_names = (const char *[]){ |
| 790 | "disp_cc_mdss_mdp_clk_src", |
| 791 | }, |
| 792 | .num_parents = 1, |
| 793 | .flags = CLK_SET_RATE_PARENT, |
| 794 | .ops = &clk_branch2_ops, |
| 795 | }, |
| 796 | }, |
| 797 | }; |
| 798 | |
| 799 | static struct clk_branch disp_cc_mdss_mdp_lut_clk = { |
| 800 | .halt_reg = 0x201c, |
| 801 | .halt_check = BRANCH_HALT, |
| 802 | .clkr = { |
| 803 | .enable_reg = 0x201c, |
| 804 | .enable_mask = BIT(0), |
| 805 | .hw.init = &(struct clk_init_data){ |
| 806 | .name = "disp_cc_mdss_mdp_lut_clk", |
| 807 | .parent_names = (const char *[]){ |
| 808 | "disp_cc_mdss_mdp_clk_src", |
| 809 | }, |
| 810 | .num_parents = 1, |
| 811 | .ops = &clk_branch2_ops, |
| 812 | }, |
| 813 | }, |
| 814 | }; |
| 815 | |
| 816 | static struct clk_branch disp_cc_mdss_pclk0_clk = { |
| 817 | .halt_reg = 0x2004, |
| 818 | .halt_check = BRANCH_HALT, |
| 819 | .clkr = { |
| 820 | .enable_reg = 0x2004, |
| 821 | .enable_mask = BIT(0), |
| 822 | .hw.init = &(struct clk_init_data){ |
| 823 | .name = "disp_cc_mdss_pclk0_clk", |
| 824 | .parent_names = (const char *[]){ |
| 825 | "disp_cc_mdss_pclk0_clk_src", |
| 826 | }, |
| 827 | .num_parents = 1, |
| 828 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 829 | .ops = &clk_branch2_ops, |
| 830 | }, |
| 831 | }, |
| 832 | }; |
| 833 | |
| 834 | static struct clk_branch disp_cc_mdss_pclk1_clk = { |
| 835 | .halt_reg = 0x2008, |
| 836 | .halt_check = BRANCH_HALT, |
| 837 | .clkr = { |
| 838 | .enable_reg = 0x2008, |
| 839 | .enable_mask = BIT(0), |
| 840 | .hw.init = &(struct clk_init_data){ |
| 841 | .name = "disp_cc_mdss_pclk1_clk", |
| 842 | .parent_names = (const char *[]){ |
| 843 | "disp_cc_mdss_pclk1_clk_src", |
| 844 | }, |
| 845 | .num_parents = 1, |
| 846 | .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, |
| 847 | .ops = &clk_branch2_ops, |
| 848 | }, |
| 849 | }, |
| 850 | }; |
| 851 | |
| 852 | static struct clk_branch disp_cc_mdss_qdss_at_clk = { |
| 853 | .halt_reg = 0x4010, |
| 854 | .halt_check = BRANCH_HALT, |
| 855 | .clkr = { |
| 856 | .enable_reg = 0x4010, |
| 857 | .enable_mask = BIT(0), |
| 858 | .hw.init = &(struct clk_init_data){ |
| 859 | .name = "disp_cc_mdss_qdss_at_clk", |
| 860 | .ops = &clk_branch2_ops, |
| 861 | }, |
| 862 | }, |
| 863 | }; |
| 864 | |
| 865 | static struct clk_branch disp_cc_mdss_qdss_tsctr_div8_clk = { |
| 866 | .halt_reg = 0x4014, |
| 867 | .halt_check = BRANCH_HALT, |
| 868 | .clkr = { |
| 869 | .enable_reg = 0x4014, |
| 870 | .enable_mask = BIT(0), |
| 871 | .hw.init = &(struct clk_init_data){ |
| 872 | .name = "disp_cc_mdss_qdss_tsctr_div8_clk", |
| 873 | .ops = &clk_branch2_ops, |
| 874 | }, |
| 875 | }, |
| 876 | }; |
| 877 | |
| 878 | static struct clk_branch disp_cc_mdss_rot_clk = { |
| 879 | .halt_reg = 0x2014, |
| 880 | .halt_check = BRANCH_HALT, |
| 881 | .clkr = { |
| 882 | .enable_reg = 0x2014, |
| 883 | .enable_mask = BIT(0), |
| 884 | .hw.init = &(struct clk_init_data){ |
| 885 | .name = "disp_cc_mdss_rot_clk", |
| 886 | .parent_names = (const char *[]){ |
| 887 | "disp_cc_mdss_rot_clk_src", |
| 888 | }, |
| 889 | .num_parents = 1, |
| 890 | .flags = CLK_SET_RATE_PARENT, |
| 891 | .ops = &clk_branch2_ops, |
| 892 | }, |
| 893 | }, |
| 894 | }; |
| 895 | |
| 896 | static struct clk_branch disp_cc_mdss_rscc_ahb_clk = { |
| 897 | .halt_reg = 0x5004, |
| 898 | .halt_check = BRANCH_HALT, |
| 899 | .clkr = { |
| 900 | .enable_reg = 0x5004, |
| 901 | .enable_mask = BIT(0), |
| 902 | .hw.init = &(struct clk_init_data){ |
| 903 | .name = "disp_cc_mdss_rscc_ahb_clk", |
| 904 | .ops = &clk_branch2_ops, |
| 905 | }, |
| 906 | }, |
| 907 | }; |
| 908 | |
| 909 | static struct clk_branch disp_cc_mdss_rscc_vsync_clk = { |
| 910 | .halt_reg = 0x5008, |
| 911 | .halt_check = BRANCH_HALT, |
| 912 | .clkr = { |
| 913 | .enable_reg = 0x5008, |
| 914 | .enable_mask = BIT(0), |
| 915 | .hw.init = &(struct clk_init_data){ |
| 916 | .name = "disp_cc_mdss_rscc_vsync_clk", |
| 917 | .parent_names = (const char *[]){ |
| 918 | "disp_cc_mdss_vsync_clk_src", |
| 919 | }, |
| 920 | .num_parents = 1, |
| 921 | .flags = CLK_SET_RATE_PARENT, |
| 922 | .ops = &clk_branch2_ops, |
| 923 | }, |
| 924 | }, |
| 925 | }; |
| 926 | |
| 927 | static struct clk_branch disp_cc_mdss_vsync_clk = { |
| 928 | .halt_reg = 0x2024, |
| 929 | .halt_check = BRANCH_HALT, |
| 930 | .clkr = { |
| 931 | .enable_reg = 0x2024, |
| 932 | .enable_mask = BIT(0), |
| 933 | .hw.init = &(struct clk_init_data){ |
| 934 | .name = "disp_cc_mdss_vsync_clk", |
| 935 | .parent_names = (const char *[]){ |
| 936 | "disp_cc_mdss_vsync_clk_src", |
| 937 | }, |
| 938 | .num_parents = 1, |
| 939 | .flags = CLK_SET_RATE_PARENT, |
| 940 | .ops = &clk_branch2_ops, |
| 941 | }, |
| 942 | }, |
| 943 | }; |
| 944 | |
| 945 | static struct clk_regmap *disp_cc_sdm845_clocks[] = { |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 946 | [DISP_CC_MDSS_AHB_CLK] = &disp_cc_mdss_ahb_clk.clkr, |
| 947 | [DISP_CC_MDSS_AXI_CLK] = &disp_cc_mdss_axi_clk.clkr, |
| 948 | [DISP_CC_MDSS_BYTE0_CLK] = &disp_cc_mdss_byte0_clk.clkr, |
| 949 | [DISP_CC_MDSS_BYTE0_CLK_SRC] = &disp_cc_mdss_byte0_clk_src.clkr, |
| 950 | [DISP_CC_MDSS_BYTE0_INTF_CLK] = &disp_cc_mdss_byte0_intf_clk.clkr, |
| 951 | [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC] = |
| 952 | &disp_cc_mdss_byte0_div_clk_src.clkr, |
| 953 | [DISP_CC_MDSS_BYTE1_CLK] = &disp_cc_mdss_byte1_clk.clkr, |
| 954 | [DISP_CC_MDSS_BYTE1_CLK_SRC] = &disp_cc_mdss_byte1_clk_src.clkr, |
| 955 | [DISP_CC_MDSS_BYTE1_INTF_CLK] = &disp_cc_mdss_byte1_intf_clk.clkr, |
| 956 | [DISP_CC_MDSS_BYTE1_DIV_CLK_SRC] = |
| 957 | &disp_cc_mdss_byte1_div_clk_src.clkr, |
| 958 | [DISP_CC_MDSS_DP_AUX_CLK] = &disp_cc_mdss_dp_aux_clk.clkr, |
| 959 | [DISP_CC_MDSS_DP_AUX_CLK_SRC] = &disp_cc_mdss_dp_aux_clk_src.clkr, |
| 960 | [DISP_CC_MDSS_DP_CRYPTO_CLK] = &disp_cc_mdss_dp_crypto_clk.clkr, |
| 961 | [DISP_CC_MDSS_DP_CRYPTO_CLK_SRC] = |
| 962 | &disp_cc_mdss_dp_crypto_clk_src.clkr, |
| 963 | [DISP_CC_MDSS_DP_LINK_CLK] = &disp_cc_mdss_dp_link_clk.clkr, |
| 964 | [DISP_CC_MDSS_DP_LINK_CLK_SRC] = &disp_cc_mdss_dp_link_clk_src.clkr, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 965 | [DISP_CC_MDSS_DP_LINK_INTF_CLK] = &disp_cc_mdss_dp_link_intf_clk.clkr, |
| 966 | [DISP_CC_MDSS_DP_PIXEL1_CLK] = &disp_cc_mdss_dp_pixel1_clk.clkr, |
| 967 | [DISP_CC_MDSS_DP_PIXEL1_CLK_SRC] = |
| 968 | &disp_cc_mdss_dp_pixel1_clk_src.clkr, |
| 969 | [DISP_CC_MDSS_DP_PIXEL_CLK] = &disp_cc_mdss_dp_pixel_clk.clkr, |
| 970 | [DISP_CC_MDSS_DP_PIXEL_CLK_SRC] = &disp_cc_mdss_dp_pixel_clk_src.clkr, |
| 971 | [DISP_CC_MDSS_ESC0_CLK] = &disp_cc_mdss_esc0_clk.clkr, |
| 972 | [DISP_CC_MDSS_ESC0_CLK_SRC] = &disp_cc_mdss_esc0_clk_src.clkr, |
| 973 | [DISP_CC_MDSS_ESC1_CLK] = &disp_cc_mdss_esc1_clk.clkr, |
| 974 | [DISP_CC_MDSS_ESC1_CLK_SRC] = &disp_cc_mdss_esc1_clk_src.clkr, |
| 975 | [DISP_CC_MDSS_MDP_CLK] = &disp_cc_mdss_mdp_clk.clkr, |
| 976 | [DISP_CC_MDSS_MDP_CLK_SRC] = &disp_cc_mdss_mdp_clk_src.clkr, |
| 977 | [DISP_CC_MDSS_MDP_LUT_CLK] = &disp_cc_mdss_mdp_lut_clk.clkr, |
| 978 | [DISP_CC_MDSS_PCLK0_CLK] = &disp_cc_mdss_pclk0_clk.clkr, |
| 979 | [DISP_CC_MDSS_PCLK0_CLK_SRC] = &disp_cc_mdss_pclk0_clk_src.clkr, |
| 980 | [DISP_CC_MDSS_PCLK1_CLK] = &disp_cc_mdss_pclk1_clk.clkr, |
| 981 | [DISP_CC_MDSS_PCLK1_CLK_SRC] = &disp_cc_mdss_pclk1_clk_src.clkr, |
| 982 | [DISP_CC_MDSS_QDSS_AT_CLK] = &disp_cc_mdss_qdss_at_clk.clkr, |
| 983 | [DISP_CC_MDSS_QDSS_TSCTR_DIV8_CLK] = |
| 984 | &disp_cc_mdss_qdss_tsctr_div8_clk.clkr, |
| 985 | [DISP_CC_MDSS_ROT_CLK] = &disp_cc_mdss_rot_clk.clkr, |
| 986 | [DISP_CC_MDSS_ROT_CLK_SRC] = &disp_cc_mdss_rot_clk_src.clkr, |
| 987 | [DISP_CC_MDSS_RSCC_AHB_CLK] = &disp_cc_mdss_rscc_ahb_clk.clkr, |
| 988 | [DISP_CC_MDSS_RSCC_VSYNC_CLK] = &disp_cc_mdss_rscc_vsync_clk.clkr, |
| 989 | [DISP_CC_MDSS_VSYNC_CLK] = &disp_cc_mdss_vsync_clk.clkr, |
| 990 | [DISP_CC_MDSS_VSYNC_CLK_SRC] = &disp_cc_mdss_vsync_clk_src.clkr, |
| 991 | [DISP_CC_PLL0] = &disp_cc_pll0.clkr, |
| 992 | }; |
| 993 | |
| 994 | static const struct qcom_reset_map disp_cc_sdm845_resets[] = { |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 995 | [DISP_CC_MDSS_RSCC_BCR] = { 0x5000 }, |
| 996 | }; |
| 997 | |
| 998 | static const struct regmap_config disp_cc_sdm845_regmap_config = { |
| 999 | .reg_bits = 32, |
| 1000 | .reg_stride = 4, |
| 1001 | .val_bits = 32, |
| 1002 | .max_register = 0x10000, |
| 1003 | .fast_io = true, |
| 1004 | }; |
| 1005 | |
| 1006 | static const struct qcom_cc_desc disp_cc_sdm845_desc = { |
| 1007 | .config = &disp_cc_sdm845_regmap_config, |
| 1008 | .clks = disp_cc_sdm845_clocks, |
| 1009 | .num_clks = ARRAY_SIZE(disp_cc_sdm845_clocks), |
| 1010 | .resets = disp_cc_sdm845_resets, |
| 1011 | .num_resets = ARRAY_SIZE(disp_cc_sdm845_resets), |
| 1012 | }; |
| 1013 | |
| 1014 | static const struct of_device_id disp_cc_sdm845_match_table[] = { |
| 1015 | { .compatible = "qcom,dispcc-sdm845" }, |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 1016 | { .compatible = "qcom,dispcc-sdm845-v2" }, |
Deepak Katragadda | 443bd8d | 2017-08-28 22:30:19 +0530 | [diff] [blame] | 1017 | { .compatible = "qcom,dispcc-sdm670" }, |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 1018 | { } |
| 1019 | }; |
| 1020 | MODULE_DEVICE_TABLE(of, disp_cc_sdm845_match_table); |
| 1021 | |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 1022 | static void disp_cc_sdm845_fixup_sdm845v2(struct regmap *regmap) |
| 1023 | { |
| 1024 | clk_fabia_pll_configure(&disp_cc_pll0, regmap, |
| 1025 | &disp_cc_pll0_config_v2); |
| 1026 | disp_cc_mdss_byte0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = |
| 1027 | 180000000; |
| 1028 | disp_cc_mdss_byte0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = |
| 1029 | 275000000; |
| 1030 | disp_cc_mdss_byte0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] = |
| 1031 | 358000000; |
| 1032 | disp_cc_mdss_byte1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = |
| 1033 | 180000000; |
| 1034 | disp_cc_mdss_byte1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = |
| 1035 | 275000000; |
| 1036 | disp_cc_mdss_byte1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] = |
| 1037 | 358000000; |
| 1038 | disp_cc_mdss_dp_pixel1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = |
| 1039 | 337500000; |
| 1040 | disp_cc_mdss_dp_pixel_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = |
| 1041 | 337500000; |
| 1042 | disp_cc_mdss_mdp_clk_src.freq_tbl = |
| 1043 | ftbl_disp_cc_mdss_mdp_clk_src_sdm845_v2; |
| 1044 | disp_cc_mdss_mdp_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = |
| 1045 | 171428571; |
| 1046 | disp_cc_mdss_mdp_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] = |
| 1047 | 344000000; |
| 1048 | disp_cc_mdss_mdp_clk_src.clkr.hw.init->rate_max[VDD_CX_NOMINAL] = |
| 1049 | 430000000; |
| 1050 | disp_cc_mdss_pclk0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = |
| 1051 | 280000000; |
| 1052 | disp_cc_mdss_pclk0_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = |
| 1053 | 430000000; |
| 1054 | disp_cc_mdss_pclk1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = |
| 1055 | 280000000; |
| 1056 | disp_cc_mdss_pclk1_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW] = |
| 1057 | 430000000; |
| 1058 | disp_cc_mdss_rot_clk_src.freq_tbl = |
| 1059 | ftbl_disp_cc_mdss_rot_clk_src_sdm845_v2; |
| 1060 | disp_cc_mdss_rot_clk_src.clkr.hw.init->rate_max[VDD_CX_LOWER] = |
| 1061 | 171428571; |
| 1062 | disp_cc_mdss_rot_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] = |
| 1063 | 344000000; |
| 1064 | disp_cc_mdss_rot_clk_src.clkr.hw.init->rate_max[VDD_CX_NOMINAL] = |
| 1065 | 430000000; |
| 1066 | } |
| 1067 | |
Deepak Katragadda | 443bd8d | 2017-08-28 22:30:19 +0530 | [diff] [blame] | 1068 | static void disp_cc_sdm845_fixup_sdm670(struct regmap *regmap) |
| 1069 | { |
| 1070 | disp_cc_sdm845_fixup_sdm845v2(regmap); |
| 1071 | } |
| 1072 | |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 1073 | static int disp_cc_sdm845_fixup(struct platform_device *pdev, |
| 1074 | struct regmap *regmap) |
| 1075 | { |
| 1076 | const char *compat = NULL; |
| 1077 | int compatlen = 0; |
| 1078 | |
| 1079 | compat = of_get_property(pdev->dev.of_node, "compatible", &compatlen); |
| 1080 | if (!compat || (compatlen <= 0)) |
| 1081 | return -EINVAL; |
| 1082 | |
| 1083 | if (!strcmp(compat, "qcom,dispcc-sdm845-v2")) |
| 1084 | disp_cc_sdm845_fixup_sdm845v2(regmap); |
Deepak Katragadda | 443bd8d | 2017-08-28 22:30:19 +0530 | [diff] [blame] | 1085 | else if (!strcmp(compat, "qcom,dispcc-sdm670")) |
| 1086 | disp_cc_sdm845_fixup_sdm670(regmap); |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 1087 | |
| 1088 | return 0; |
| 1089 | } |
| 1090 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 1091 | static int disp_cc_sdm845_probe(struct platform_device *pdev) |
| 1092 | { |
| 1093 | struct regmap *regmap; |
| 1094 | int ret = 0; |
| 1095 | |
| 1096 | regmap = qcom_cc_map(pdev, &disp_cc_sdm845_desc); |
| 1097 | if (IS_ERR(regmap)) { |
| 1098 | pr_err("Failed to map the Display CC registers\n"); |
| 1099 | return PTR_ERR(regmap); |
| 1100 | } |
| 1101 | |
| 1102 | vdd_cx.regulator[0] = devm_regulator_get(&pdev->dev, "vdd_cx"); |
| 1103 | if (IS_ERR(vdd_cx.regulator[0])) { |
| 1104 | if (!(PTR_ERR(vdd_cx.regulator[0]) == -EPROBE_DEFER)) |
| 1105 | dev_err(&pdev->dev, |
| 1106 | "Unable to get vdd_cx regulator\n"); |
| 1107 | return PTR_ERR(vdd_cx.regulator[0]); |
| 1108 | } |
| 1109 | |
| 1110 | clk_fabia_pll_configure(&disp_cc_pll0, regmap, &disp_cc_pll0_config); |
| 1111 | |
| 1112 | /* Enable clock gating for DSI and MDP clocks */ |
| 1113 | regmap_update_bits(regmap, DISP_CC_MISC_CMD, 0x7f0, 0x7f0); |
| 1114 | |
Deepak Katragadda | 6c846e3 | 2017-06-07 14:09:49 -0700 | [diff] [blame] | 1115 | ret = disp_cc_sdm845_fixup(pdev, regmap); |
| 1116 | if (ret) |
| 1117 | return ret; |
| 1118 | |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 1119 | ret = qcom_cc_really_probe(pdev, &disp_cc_sdm845_desc, regmap); |
| 1120 | if (ret) { |
| 1121 | dev_err(&pdev->dev, "Failed to register Display CC clocks\n"); |
| 1122 | return ret; |
| 1123 | } |
| 1124 | |
| 1125 | dev_info(&pdev->dev, "Registered Display CC clocks\n"); |
| 1126 | return ret; |
| 1127 | } |
| 1128 | |
| 1129 | static struct platform_driver disp_cc_sdm845_driver = { |
| 1130 | .probe = disp_cc_sdm845_probe, |
| 1131 | .driver = { |
| 1132 | .name = "disp_cc-sdm845", |
| 1133 | .of_match_table = disp_cc_sdm845_match_table, |
| 1134 | }, |
| 1135 | }; |
| 1136 | |
| 1137 | static int __init disp_cc_sdm845_init(void) |
| 1138 | { |
| 1139 | return platform_driver_register(&disp_cc_sdm845_driver); |
| 1140 | } |
Deepak Katragadda | ef44e10 | 2017-06-21 10:30:46 -0700 | [diff] [blame] | 1141 | subsys_initcall(disp_cc_sdm845_init); |
Deepak Katragadda | 24ee246 | 2016-12-16 14:26:38 -0800 | [diff] [blame] | 1142 | |
| 1143 | static void __exit disp_cc_sdm845_exit(void) |
| 1144 | { |
| 1145 | platform_driver_unregister(&disp_cc_sdm845_driver); |
| 1146 | } |
| 1147 | module_exit(disp_cc_sdm845_exit); |
| 1148 | |
| 1149 | MODULE_DESCRIPTION("QTI DISP_CC SDM845 Driver"); |
| 1150 | MODULE_LICENSE("GPL v2"); |
| 1151 | MODULE_ALIAS("platform:disp_cc-sdm845"); |