developer | 4a79703 | 2019-12-31 11:29:20 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * MediaTek clock driver for MT8512 SoC |
| 4 | * |
| 5 | * Copyright (C) 2019 BayLibre, SAS |
| 6 | * Author: Chen Zhong <chen.zhong@mediatek.com> |
| 7 | */ |
| 8 | |
developer | 4a79703 | 2019-12-31 11:29:20 +0800 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <asm/io.h> |
| 11 | #include <dt-bindings/clock/mt8512-clk.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 12 | #include <linux/bitops.h> |
developer | 4a79703 | 2019-12-31 11:29:20 +0800 | [diff] [blame] | 13 | |
| 14 | #include "clk-mtk.h" |
| 15 | |
| 16 | #define MT8512_PLL_FMAX (3800UL * MHZ) |
| 17 | #define MT8512_PLL_FMIN (1500UL * MHZ) |
| 18 | #define MT8512_CON0_RST_BAR BIT(23) |
| 19 | |
| 20 | /* apmixedsys */ |
| 21 | #define PLL(_id, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, \ |
| 22 | _pd_shift, _pcw_reg, _pcw_shift, _pcw_chg_reg) { \ |
| 23 | .id = _id, \ |
| 24 | .reg = _reg, \ |
| 25 | .pwr_reg = _pwr_reg, \ |
| 26 | .en_mask = _en_mask, \ |
| 27 | .rst_bar_mask = MT8512_CON0_RST_BAR, \ |
| 28 | .fmax = MT8512_PLL_FMAX, \ |
| 29 | .fmin = MT8512_PLL_FMIN, \ |
| 30 | .flags = _flags, \ |
| 31 | .pcwbits = _pcwbits, \ |
| 32 | .pcwibits = 8, \ |
| 33 | .pd_reg = _pd_reg, \ |
| 34 | .pd_shift = _pd_shift, \ |
| 35 | .pcw_reg = _pcw_reg, \ |
| 36 | .pcw_shift = _pcw_shift, \ |
| 37 | .pcw_chg_reg = _pcw_chg_reg, \ |
| 38 | } |
| 39 | |
| 40 | static const struct mtk_pll_data apmixed_plls[] = { |
| 41 | PLL(CLK_APMIXED_ARMPLL, 0x030C, 0x0318, 0x00000001, |
| 42 | 0, 22, 0x0310, 24, 0x0310, 0, 0), |
| 43 | PLL(CLK_APMIXED_MAINPLL, 0x0228, 0x0234, 0x00000001, |
| 44 | HAVE_RST_BAR, 22, 0x022C, 24, 0x022C, 0, 0), |
| 45 | PLL(CLK_APMIXED_UNIVPLL2, 0x0208, 0x0214, 0x00000001, |
| 46 | HAVE_RST_BAR, 22, 0x020C, 24, 0x020C, 0, 0), |
| 47 | PLL(CLK_APMIXED_MSDCPLL, 0x0350, 0x035C, 0x00000001, |
| 48 | 0, 22, 0x0354, 24, 0x0354, 0, 0), |
| 49 | PLL(CLK_APMIXED_APLL1, 0x031C, 0x032C, 0x00000001, |
| 50 | 0, 32, 0x0320, 24, 0x0324, 0, 0x0320), |
| 51 | PLL(CLK_APMIXED_APLL2, 0x0360, 0x0370, 0x00000001, |
| 52 | 0, 32, 0x0364, 24, 0x0368, 0, 0x0364), |
| 53 | PLL(CLK_APMIXED_IPPLL, 0x0374, 0x0380, 0x00000001, |
| 54 | 0, 22, 0x0378, 24, 0x0378, 0, 0), |
| 55 | PLL(CLK_APMIXED_DSPPLL, 0x0390, 0x039C, 0x00000001, |
| 56 | 0, 22, 0x0394, 24, 0x0394, 0, 0), |
| 57 | PLL(CLK_APMIXED_TCONPLL, 0x03A0, 0x03AC, 0x00000001, |
| 58 | 0, 22, 0x03A4, 24, 0x03A4, 0, 0), |
| 59 | }; |
| 60 | |
| 61 | /* topckgen */ |
| 62 | #define FACTOR0(_id, _parent, _mult, _div) \ |
| 63 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_APMIXED) |
| 64 | |
| 65 | #define FACTOR1(_id, _parent, _mult, _div) \ |
| 66 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_TOPCKGEN) |
| 67 | |
| 68 | #define FACTOR2(_id, _parent, _mult, _div) \ |
| 69 | FACTOR(_id, _parent, _mult, _div, 0) |
| 70 | |
| 71 | static const struct mtk_fixed_clk top_fixed_clks[] = { |
| 72 | FIXED_CLK(CLK_TOP_CLK_NULL, CLK_XTAL, 26000000), |
| 73 | FIXED_CLK(CLK_TOP_CLK32K, CLK_XTAL, 32000), |
| 74 | }; |
| 75 | |
| 76 | static const struct mtk_fixed_factor top_fixed_divs[] = { |
| 77 | FACTOR0(CLK_TOP_SYSPLL1_D2, CLK_APMIXED_MAINPLL, 1, 4), |
| 78 | FACTOR0(CLK_TOP_SYSPLL1_D4, CLK_APMIXED_MAINPLL, 1, 8), |
| 79 | FACTOR0(CLK_TOP_SYSPLL1_D8, CLK_APMIXED_MAINPLL, 1, 16), |
| 80 | FACTOR0(CLK_TOP_SYSPLL1_D16, CLK_APMIXED_MAINPLL, 1, 32), |
| 81 | FACTOR0(CLK_TOP_SYSPLL_D3, CLK_APMIXED_MAINPLL, 1, 3), |
| 82 | FACTOR0(CLK_TOP_SYSPLL2_D2, CLK_APMIXED_MAINPLL, 1, 6), |
| 83 | FACTOR0(CLK_TOP_SYSPLL2_D4, CLK_APMIXED_MAINPLL, 1, 12), |
| 84 | FACTOR0(CLK_TOP_SYSPLL2_D8, CLK_APMIXED_MAINPLL, 1, 24), |
| 85 | FACTOR0(CLK_TOP_SYSPLL_D5, CLK_APMIXED_MAINPLL, 1, 5), |
| 86 | FACTOR0(CLK_TOP_SYSPLL3_D4, CLK_APMIXED_MAINPLL, 1, 20), |
| 87 | FACTOR0(CLK_TOP_SYSPLL_D7, CLK_APMIXED_MAINPLL, 1, 7), |
| 88 | FACTOR0(CLK_TOP_SYSPLL4_D2, CLK_APMIXED_MAINPLL, 1, 14), |
| 89 | FACTOR0(CLK_TOP_UNIVPLL, CLK_APMIXED_UNIVPLL2, 1, 2), |
| 90 | FACTOR1(CLK_TOP_UNIVPLL_D2, CLK_TOP_UNIVPLL, 1, 2), |
| 91 | FACTOR1(CLK_TOP_UNIVPLL1_D2, CLK_TOP_UNIVPLL, 1, 4), |
| 92 | FACTOR1(CLK_TOP_UNIVPLL1_D4, CLK_TOP_UNIVPLL, 1, 8), |
| 93 | FACTOR1(CLK_TOP_UNIVPLL1_D8, CLK_TOP_UNIVPLL, 1, 16), |
| 94 | FACTOR1(CLK_TOP_UNIVPLL_D3, CLK_TOP_UNIVPLL, 1, 3), |
| 95 | FACTOR1(CLK_TOP_UNIVPLL2_D2, CLK_TOP_UNIVPLL, 1, 6), |
| 96 | FACTOR1(CLK_TOP_UNIVPLL2_D4, CLK_TOP_UNIVPLL, 1, 12), |
| 97 | FACTOR1(CLK_TOP_UNIVPLL2_D8, CLK_TOP_UNIVPLL, 1, 24), |
| 98 | FACTOR1(CLK_TOP_UNIVPLL_D5, CLK_TOP_UNIVPLL, 1, 5), |
| 99 | FACTOR1(CLK_TOP_UNIVPLL3_D2, CLK_TOP_UNIVPLL, 1, 10), |
| 100 | FACTOR1(CLK_TOP_UNIVPLL3_D4, CLK_TOP_UNIVPLL, 1, 20), |
| 101 | FACTOR0(CLK_TOP_TCONPLL_D2, CLK_APMIXED_TCONPLL, 1, 2), |
| 102 | FACTOR0(CLK_TOP_TCONPLL_D4, CLK_APMIXED_TCONPLL, 1, 4), |
| 103 | FACTOR0(CLK_TOP_TCONPLL_D8, CLK_APMIXED_TCONPLL, 1, 8), |
| 104 | FACTOR0(CLK_TOP_TCONPLL_D16, CLK_APMIXED_TCONPLL, 1, 16), |
| 105 | FACTOR0(CLK_TOP_TCONPLL_D32, CLK_APMIXED_TCONPLL, 1, 32), |
| 106 | FACTOR0(CLK_TOP_TCONPLL_D64, CLK_APMIXED_TCONPLL, 1, 64), |
| 107 | FACTOR1(CLK_TOP_USB20_192M, CLK_TOP_UNIVPLL, 2, 13), |
| 108 | FACTOR1(CLK_TOP_USB20_192M_D2, CLK_TOP_USB20_192M, 1, 2), |
| 109 | FACTOR1(CLK_TOP_USB20_192M_D4_T, CLK_TOP_USB20_192M, 1, 4), |
| 110 | FACTOR0(CLK_TOP_APLL1, CLK_APMIXED_APLL1, 1, 1), |
| 111 | FACTOR0(CLK_TOP_APLL1_D2, CLK_APMIXED_APLL1, 1, 2), |
| 112 | FACTOR0(CLK_TOP_APLL1_D3, CLK_APMIXED_APLL1, 1, 3), |
| 113 | FACTOR0(CLK_TOP_APLL1_D4, CLK_APMIXED_APLL1, 1, 4), |
| 114 | FACTOR0(CLK_TOP_APLL1_D8, CLK_APMIXED_APLL1, 1, 8), |
| 115 | FACTOR0(CLK_TOP_APLL1_D16, CLK_APMIXED_APLL1, 1, 16), |
| 116 | FACTOR0(CLK_TOP_APLL2, CLK_APMIXED_APLL2, 1, 1), |
| 117 | FACTOR0(CLK_TOP_APLL2_D2, CLK_APMIXED_APLL2, 1, 2), |
| 118 | FACTOR0(CLK_TOP_APLL2_D3, CLK_APMIXED_APLL2, 1, 3), |
| 119 | FACTOR0(CLK_TOP_APLL2_D4, CLK_APMIXED_APLL2, 1, 4), |
| 120 | FACTOR0(CLK_TOP_APLL2_D8, CLK_APMIXED_APLL2, 1, 8), |
| 121 | FACTOR0(CLK_TOP_APLL2_D16, CLK_APMIXED_APLL2, 1, 16), |
| 122 | FACTOR2(CLK_TOP_CLK26M, CLK_XTAL, 1, 1), |
| 123 | FACTOR2(CLK_TOP_SYS_26M_D2, CLK_XTAL, 1, 2), |
| 124 | FACTOR0(CLK_TOP_MSDCPLL, CLK_APMIXED_MSDCPLL, 1, 1), |
| 125 | FACTOR0(CLK_TOP_MSDCPLL_D2, CLK_APMIXED_MSDCPLL, 1, 2), |
| 126 | FACTOR0(CLK_TOP_DSPPLL, CLK_APMIXED_DSPPLL, 1, 1), |
| 127 | FACTOR0(CLK_TOP_DSPPLL_D2, CLK_APMIXED_DSPPLL, 1, 2), |
| 128 | FACTOR0(CLK_TOP_DSPPLL_D4, CLK_APMIXED_DSPPLL, 1, 4), |
| 129 | FACTOR0(CLK_TOP_DSPPLL_D8, CLK_APMIXED_DSPPLL, 1, 8), |
| 130 | FACTOR0(CLK_TOP_IPPLL, CLK_APMIXED_IPPLL, 1, 1), |
| 131 | FACTOR0(CLK_TOP_IPPLL_D2, CLK_APMIXED_IPPLL, 1, 2), |
| 132 | FACTOR1(CLK_TOP_NFI2X_CK_D2, CLK_TOP_NFI2X_SEL, 1, 2), |
| 133 | }; |
| 134 | |
| 135 | static const int axi_parents[] = { |
| 136 | CLK_TOP_CLK26M, |
| 137 | CLK_TOP_SYSPLL1_D4, |
| 138 | CLK_TOP_UNIVPLL3_D2, |
| 139 | CLK_TOP_SYSPLL1_D8, |
| 140 | CLK_TOP_SYS_26M_D2, |
| 141 | CLK_TOP_CLK32K |
| 142 | }; |
| 143 | |
| 144 | static const int mem_parents[] = { |
| 145 | CLK_TOP_DSPPLL, |
| 146 | CLK_TOP_IPPLL, |
| 147 | CLK_TOP_CLK26M, |
| 148 | CLK_TOP_UNIVPLL_D3 |
| 149 | }; |
| 150 | |
| 151 | static const int uart_parents[] = { |
| 152 | CLK_TOP_CLK26M, |
| 153 | CLK_TOP_UNIVPLL2_D8 |
| 154 | }; |
| 155 | |
| 156 | static const int spi_parents[] = { |
| 157 | CLK_TOP_CLK26M, |
| 158 | CLK_TOP_UNIVPLL2_D2, |
| 159 | CLK_TOP_SYSPLL2_D2, |
| 160 | CLK_TOP_UNIVPLL1_D4, |
| 161 | CLK_TOP_SYSPLL1_D4, |
| 162 | CLK_TOP_UNIVPLL3_D2, |
| 163 | CLK_TOP_UNIVPLL2_D4, |
| 164 | CLK_TOP_SYSPLL4_D2 |
| 165 | }; |
| 166 | |
| 167 | static const int spis_parents[] = { |
| 168 | CLK_TOP_CLK26M, |
| 169 | CLK_TOP_UNIVPLL_D3, |
| 170 | CLK_TOP_SYSPLL_D3, |
| 171 | CLK_TOP_UNIVPLL1_D2, |
| 172 | CLK_TOP_UNIVPLL2_D2, |
| 173 | CLK_TOP_UNIVPLL1_D4, |
| 174 | CLK_TOP_UNIVPLL2_D4, |
| 175 | CLK_TOP_SYSPLL4_D2 |
| 176 | }; |
| 177 | |
| 178 | static const int msdc50_0_hc_parents[] = { |
| 179 | CLK_TOP_CLK26M, |
| 180 | CLK_TOP_SYSPLL1_D2, |
| 181 | CLK_TOP_UNIVPLL1_D4, |
| 182 | CLK_TOP_SYSPLL2_D2 |
| 183 | }; |
| 184 | |
| 185 | static const int msdc50_0_parents[] = { |
| 186 | CLK_TOP_CLK26M, |
| 187 | CLK_TOP_MSDCPLL_D2, |
| 188 | CLK_TOP_UNIVPLL2_D2, |
| 189 | CLK_TOP_SYSPLL2_D2, |
| 190 | CLK_TOP_UNIVPLL1_D4, |
| 191 | CLK_TOP_SYSPLL1_D4, |
| 192 | CLK_TOP_SYSPLL2_D4, |
| 193 | CLK_TOP_UNIVPLL2_D8 |
| 194 | }; |
| 195 | |
| 196 | static const int msdc50_2_parents[] = { |
| 197 | CLK_TOP_CLK26M, |
| 198 | CLK_TOP_MSDCPLL, |
| 199 | CLK_TOP_UNIVPLL_D3, |
| 200 | CLK_TOP_UNIVPLL1_D2, |
| 201 | CLK_TOP_SYSPLL1_D2, |
| 202 | CLK_TOP_UNIVPLL2_D2, |
| 203 | CLK_TOP_SYSPLL2_D2, |
| 204 | CLK_TOP_UNIVPLL1_D4 |
| 205 | }; |
| 206 | |
| 207 | static const int audio_parents[] = { |
| 208 | CLK_TOP_CLK26M, |
| 209 | CLK_TOP_UNIVPLL2_D8, |
| 210 | CLK_TOP_APLL1_D4, |
| 211 | CLK_TOP_APLL2_D4 |
| 212 | }; |
| 213 | |
| 214 | static const int aud_intbus_parents[] = { |
| 215 | CLK_TOP_CLK26M, |
| 216 | CLK_TOP_SYSPLL1_D4, |
| 217 | CLK_TOP_UNIVPLL3_D2, |
| 218 | CLK_TOP_APLL2_D8, |
| 219 | CLK_TOP_SYS_26M_D2, |
| 220 | CLK_TOP_APLL1_D8, |
| 221 | CLK_TOP_UNIVPLL3_D4 |
| 222 | }; |
| 223 | |
| 224 | static const int hapll1_parents[] = { |
| 225 | CLK_TOP_CLK26M, |
| 226 | CLK_TOP_APLL1, |
| 227 | CLK_TOP_APLL1_D2, |
| 228 | CLK_TOP_APLL1_D3, |
| 229 | CLK_TOP_APLL1_D4, |
| 230 | CLK_TOP_APLL1_D8, |
| 231 | CLK_TOP_APLL1_D16, |
| 232 | CLK_TOP_SYS_26M_D2 |
| 233 | }; |
| 234 | |
| 235 | static const int hapll2_parents[] = { |
| 236 | CLK_TOP_CLK26M, |
| 237 | CLK_TOP_APLL2, |
| 238 | CLK_TOP_APLL2_D2, |
| 239 | CLK_TOP_APLL2_D3, |
| 240 | CLK_TOP_APLL2_D4, |
| 241 | CLK_TOP_APLL2_D8, |
| 242 | CLK_TOP_APLL2_D16, |
| 243 | CLK_TOP_SYS_26M_D2 |
| 244 | }; |
| 245 | |
| 246 | static const int asm_l_parents[] = { |
| 247 | CLK_TOP_CLK26M, |
| 248 | CLK_TOP_UNIVPLL2_D4, |
| 249 | CLK_TOP_UNIVPLL2_D2, |
| 250 | CLK_TOP_SYSPLL_D5 |
| 251 | }; |
| 252 | |
| 253 | static const int aud_spdif_parents[] = { |
| 254 | CLK_TOP_CLK26M, |
| 255 | CLK_TOP_UNIVPLL_D2, |
| 256 | CLK_TOP_DSPPLL |
| 257 | }; |
| 258 | |
| 259 | static const int aud_1_parents[] = { |
| 260 | CLK_TOP_CLK26M, |
| 261 | CLK_TOP_APLL1 |
| 262 | }; |
| 263 | |
| 264 | static const int aud_2_parents[] = { |
| 265 | CLK_TOP_CLK26M, |
| 266 | CLK_TOP_APLL2 |
| 267 | }; |
| 268 | |
| 269 | static const int ssusb_sys_parents[] = { |
| 270 | CLK_TOP_CLK26M, |
| 271 | CLK_TOP_UNIVPLL3_D4, |
| 272 | CLK_TOP_UNIVPLL2_D4, |
| 273 | CLK_TOP_UNIVPLL3_D2 |
| 274 | }; |
| 275 | |
| 276 | static const int spm_parents[] = { |
| 277 | CLK_TOP_CLK26M, |
| 278 | CLK_TOP_SYSPLL1_D8 |
| 279 | }; |
| 280 | |
| 281 | static const int i2c_parents[] = { |
| 282 | CLK_TOP_CLK26M, |
| 283 | CLK_TOP_SYS_26M_D2, |
| 284 | CLK_TOP_UNIVPLL3_D4, |
| 285 | CLK_TOP_UNIVPLL3_D2, |
| 286 | CLK_TOP_SYSPLL1_D8, |
| 287 | CLK_TOP_SYSPLL2_D8, |
| 288 | CLK_TOP_CLK32K |
| 289 | }; |
| 290 | |
| 291 | static const int pwm_parents[] = { |
| 292 | CLK_TOP_CLK26M, |
| 293 | CLK_TOP_UNIVPLL3_D4, |
| 294 | CLK_TOP_SYSPLL1_D8, |
| 295 | CLK_TOP_UNIVPLL2_D4, |
| 296 | CLK_TOP_SYS_26M_D2, |
| 297 | CLK_TOP_CLK32K |
| 298 | }; |
| 299 | |
| 300 | static const int dsp_parents[] = { |
| 301 | CLK_TOP_CLK26M, |
| 302 | CLK_TOP_DSPPLL, |
| 303 | CLK_TOP_DSPPLL_D2, |
| 304 | CLK_TOP_DSPPLL_D4, |
| 305 | CLK_TOP_DSPPLL_D8, |
| 306 | CLK_TOP_APLL2_D4, |
| 307 | CLK_TOP_SYS_26M_D2, |
| 308 | CLK_TOP_CLK32K |
| 309 | }; |
| 310 | |
| 311 | static const int nfi2x_parents[] = { |
| 312 | CLK_TOP_CLK26M, |
| 313 | CLK_TOP_SYSPLL2_D2, |
| 314 | CLK_TOP_SYSPLL_D7, |
| 315 | CLK_TOP_SYSPLL_D3, |
| 316 | CLK_TOP_SYSPLL2_D4, |
| 317 | CLK_TOP_MSDCPLL_D2, |
| 318 | CLK_TOP_UNIVPLL1_D2, |
| 319 | CLK_TOP_UNIVPLL_D5 |
| 320 | }; |
| 321 | |
| 322 | static const int spinfi_parents[] = { |
| 323 | CLK_TOP_CLK26M, |
| 324 | CLK_TOP_UNIVPLL2_D8, |
| 325 | CLK_TOP_UNIVPLL3_D4, |
| 326 | CLK_TOP_SYSPLL1_D8, |
| 327 | CLK_TOP_SYSPLL4_D2, |
| 328 | CLK_TOP_SYSPLL2_D4, |
| 329 | CLK_TOP_UNIVPLL2_D4, |
| 330 | CLK_TOP_UNIVPLL3_D2 |
| 331 | }; |
| 332 | |
| 333 | static const int ecc_parents[] = { |
| 334 | CLK_TOP_CLK26M, |
| 335 | CLK_TOP_SYSPLL_D5, |
| 336 | CLK_TOP_SYSPLL_D3, |
| 337 | CLK_TOP_UNIVPLL_D3 |
| 338 | }; |
| 339 | |
| 340 | static const int gcpu_parents[] = { |
| 341 | CLK_TOP_CLK26M, |
| 342 | CLK_TOP_UNIVPLL_D3, |
| 343 | CLK_TOP_SYSPLL_D3, |
| 344 | CLK_TOP_UNIVPLL1_D2, |
| 345 | CLK_TOP_SYSPLL1_D2, |
| 346 | CLK_TOP_UNIVPLL2_D2 |
| 347 | }; |
| 348 | |
| 349 | static const int gcpu_cpm_parents[] = { |
| 350 | CLK_TOP_CLK26M, |
| 351 | CLK_TOP_UNIVPLL2_D2, |
| 352 | CLK_TOP_SYSPLL2_D2, |
| 353 | CLK_TOP_UNIVPLL1_D4 |
| 354 | }; |
| 355 | |
| 356 | static const int mbist_diag_parents[] = { |
| 357 | CLK_TOP_CLK26M, |
| 358 | CLK_TOP_SYS_26M_D2 |
| 359 | }; |
| 360 | |
| 361 | static const int ip0_nna_parents[] = { |
| 362 | CLK_TOP_CLK26M, |
| 363 | CLK_TOP_DSPPLL, |
| 364 | CLK_TOP_DSPPLL_D2, |
| 365 | CLK_TOP_DSPPLL_D4, |
| 366 | CLK_TOP_IPPLL, |
| 367 | CLK_TOP_SYS_26M_D2, |
| 368 | CLK_TOP_IPPLL_D2, |
| 369 | CLK_TOP_MSDCPLL_D2 |
| 370 | }; |
| 371 | |
| 372 | static const int ip2_wfst_parents[] = { |
| 373 | CLK_TOP_CLK26M, |
| 374 | CLK_TOP_UNIVPLL_D3, |
| 375 | CLK_TOP_UNIVPLL1_D2, |
| 376 | CLK_TOP_UNIVPLL2_D2, |
| 377 | CLK_TOP_IPPLL, |
| 378 | CLK_TOP_IPPLL_D2, |
| 379 | CLK_TOP_SYS_26M_D2, |
| 380 | CLK_TOP_MSDCPLL |
| 381 | }; |
| 382 | |
| 383 | static const int sflash_parents[] = { |
| 384 | CLK_TOP_CLK26M, |
| 385 | CLK_TOP_SYSPLL1_D16, |
| 386 | CLK_TOP_SYSPLL2_D8, |
| 387 | CLK_TOP_SYSPLL3_D4, |
| 388 | CLK_TOP_UNIVPLL3_D4, |
| 389 | CLK_TOP_UNIVPLL1_D8, |
| 390 | CLK_TOP_USB20_192M_D2, |
| 391 | CLK_TOP_UNIVPLL2_D4 |
| 392 | }; |
| 393 | |
| 394 | static const int sram_parents[] = { |
| 395 | CLK_TOP_CLK26M, |
| 396 | CLK_TOP_DSPPLL, |
| 397 | CLK_TOP_UNIVPLL_D3, |
| 398 | CLK_TOP_SYSPLL1_D2, |
| 399 | CLK_TOP_APLL1, |
| 400 | CLK_TOP_APLL2, |
| 401 | CLK_TOP_SYSPLL1_D4, |
| 402 | CLK_TOP_SYS_26M_D2 |
| 403 | }; |
| 404 | |
| 405 | static const int mm_parents[] = { |
| 406 | CLK_TOP_CLK26M, |
| 407 | CLK_TOP_SYSPLL_D3, |
| 408 | CLK_TOP_SYSPLL1_D2, |
| 409 | CLK_TOP_SYSPLL_D5, |
| 410 | CLK_TOP_SYSPLL1_D4, |
| 411 | CLK_TOP_UNIVPLL_D5, |
| 412 | CLK_TOP_UNIVPLL1_D2, |
| 413 | CLK_TOP_UNIVPLL_D3 |
| 414 | }; |
| 415 | |
| 416 | static const int dpi0_parents[] = { |
| 417 | CLK_TOP_CLK26M, |
| 418 | CLK_TOP_TCONPLL_D2, |
| 419 | CLK_TOP_TCONPLL_D4, |
| 420 | CLK_TOP_TCONPLL_D8, |
| 421 | CLK_TOP_TCONPLL_D16, |
| 422 | CLK_TOP_TCONPLL_D32, |
| 423 | CLK_TOP_TCONPLL_D64 |
| 424 | }; |
| 425 | |
| 426 | static const int dbg_atclk_parents[] = { |
| 427 | CLK_TOP_CLK26M, |
| 428 | CLK_TOP_UNIVPLL1_D2, |
| 429 | CLK_TOP_UNIVPLL_D5 |
| 430 | }; |
| 431 | |
| 432 | static const int occ_104m_parents[] = { |
| 433 | CLK_TOP_UNIVPLL2_D4, |
| 434 | CLK_TOP_UNIVPLL2_D8 |
| 435 | }; |
| 436 | |
| 437 | static const int occ_68m_parents[] = { |
| 438 | CLK_TOP_SYSPLL1_D8, |
| 439 | CLK_TOP_UNIVPLL2_D8 |
| 440 | }; |
| 441 | |
| 442 | static const int occ_182m_parents[] = { |
| 443 | CLK_TOP_SYSPLL2_D2, |
| 444 | CLK_TOP_UNIVPLL1_D4, |
| 445 | CLK_TOP_UNIVPLL2_D8 |
| 446 | }; |
| 447 | |
| 448 | static const struct mtk_composite top_muxes[] = { |
| 449 | /* CLK_CFG_0 */ |
| 450 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_AXI_SEL, axi_parents, |
| 451 | 0x040, 0x044, 0x048, 0, 3, 7, |
| 452 | 0x4, 0, CLK_MUX_SETCLR_UPD), |
| 453 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MEM_SEL, mem_parents, |
| 454 | 0x040, 0x044, 0x048, 8, 2, 15, |
| 455 | 0x4, 1, CLK_MUX_SETCLR_UPD), |
| 456 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_UART_SEL, uart_parents, |
| 457 | 0x040, 0x044, 0x048, 16, 1, 23, |
| 458 | 0x4, 2, CLK_MUX_SETCLR_UPD), |
| 459 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SPI_SEL, spi_parents, |
| 460 | 0x040, 0x044, 0x048, 24, 3, 31, |
| 461 | 0x4, 3, CLK_MUX_SETCLR_UPD), |
| 462 | /* CLK_CFG_1 */ |
| 463 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SPIS_SEL, spis_parents, |
| 464 | 0x050, 0x054, 0x058, 0, 3, 7, |
| 465 | 0x4, 4, CLK_MUX_SETCLR_UPD), |
| 466 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MSDC50_0_HC_SEL, msdc50_0_hc_parents, |
| 467 | 0x050, 0x054, 0x058, 8, 2, 15, |
| 468 | 0x4, 5, CLK_MUX_SETCLR_UPD), |
| 469 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MSDC2_2_HC_SEL, msdc50_0_hc_parents, |
| 470 | 0x050, 0x054, 0x058, 16, 2, 23, |
| 471 | 0x4, 6, CLK_MUX_SETCLR_UPD), |
| 472 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MSDC50_0_SEL, msdc50_0_parents, |
| 473 | 0x050, 0x054, 0x058, 24, 3, 31, |
| 474 | 0x4, 7, CLK_MUX_SETCLR_UPD), |
| 475 | /* CLK_CFG_2 */ |
| 476 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MSDC50_2_SEL, msdc50_2_parents, |
| 477 | 0x060, 0x064, 0x068, 0, 3, 7, |
| 478 | 0x4, 8, CLK_MUX_SETCLR_UPD), |
| 479 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MSDC30_1_SEL, msdc50_0_parents, |
| 480 | 0x060, 0x064, 0x068, 8, 3, 15, |
| 481 | 0x4, 9, CLK_MUX_SETCLR_UPD), |
| 482 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_AUDIO_SEL, audio_parents, |
| 483 | 0x060, 0x064, 0x068, 16, 2, 23, |
| 484 | 0x4, 10, CLK_MUX_SETCLR_UPD), |
| 485 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_AUD_INTBUS_SEL, aud_intbus_parents, |
| 486 | 0x060, 0x064, 0x068, 24, 3, 31, |
| 487 | 0x4, 11, CLK_MUX_SETCLR_UPD), |
| 488 | /* CLK_CFG_3 */ |
| 489 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_HAPLL1_SEL, hapll1_parents, |
| 490 | 0x070, 0x074, 0x078, 0, 3, 7, |
| 491 | 0x4, 12, CLK_MUX_SETCLR_UPD), |
| 492 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_HAPLL2_SEL, hapll2_parents, |
| 493 | 0x070, 0x074, 0x078, 8, 3, 15, |
| 494 | 0x4, 13, CLK_MUX_SETCLR_UPD), |
| 495 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_A2SYS_SEL, hapll1_parents, |
| 496 | 0x070, 0x074, 0x078, 16, 3, 23, |
| 497 | 0x4, 14, CLK_MUX_SETCLR_UPD), |
| 498 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_A1SYS_SEL, hapll2_parents, |
| 499 | 0x070, 0x074, 0x078, 24, 3, 31, |
| 500 | 0x4, 15, CLK_MUX_SETCLR_UPD), |
| 501 | /* CLK_CFG_4 */ |
| 502 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_ASM_L_SEL, asm_l_parents, |
| 503 | 0x080, 0x084, 0x088, 0, 2, 7, |
| 504 | 0x4, 16, CLK_MUX_SETCLR_UPD), |
| 505 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_ASM_M_SEL, asm_l_parents, |
| 506 | 0x080, 0x084, 0x088, 8, 2, 15, |
| 507 | 0x4, 17, CLK_MUX_SETCLR_UPD), |
| 508 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_ASM_H_SEL, asm_l_parents, |
| 509 | 0x080, 0x084, 0x088, 16, 2, 23, |
| 510 | 0x4, 18, CLK_MUX_SETCLR_UPD), |
| 511 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_AUD_SPDIF_SEL, aud_spdif_parents, |
| 512 | 0x080, 0x084, 0x088, 24, 2, 31, |
| 513 | 0x4, 19, CLK_MUX_SETCLR_UPD), |
| 514 | /* CLK_CFG_5 */ |
| 515 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_AUD_1_SEL, aud_1_parents, |
| 516 | 0x090, 0x094, 0x098, 0, 1, 7, |
| 517 | 0x4, 20, CLK_MUX_SETCLR_UPD), |
| 518 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_AUD_2_SEL, aud_2_parents, |
| 519 | 0x090, 0x094, 0x098, 8, 1, 15, |
| 520 | 0x4, 21, CLK_MUX_SETCLR_UPD), |
| 521 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SSUSB_SYS_SEL, ssusb_sys_parents, |
| 522 | 0x090, 0x094, 0x098, 16, 2, 23, |
| 523 | 0x4, 22, CLK_MUX_SETCLR_UPD), |
| 524 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SSUSB_XHCI_SEL, ssusb_sys_parents, |
| 525 | 0x090, 0x094, 0x098, 24, 2, 31, |
| 526 | 0x4, 23, CLK_MUX_SETCLR_UPD), |
| 527 | /* CLK_CFG_6 */ |
| 528 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SPM_SEL, spm_parents, |
| 529 | 0x0a0, 0x0a4, 0x0a8, 0, 1, 7, |
| 530 | 0x4, 24, CLK_MUX_SETCLR_UPD), |
| 531 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_I2C_SEL, i2c_parents, |
| 532 | 0x0a0, 0x0a4, 0x0a8, 8, 3, 15, |
| 533 | 0x4, 25, CLK_MUX_SETCLR_UPD), |
| 534 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_PWM_SEL, pwm_parents, |
| 535 | 0x0a0, 0x0a4, 0x0a8, 16, 3, 23, |
| 536 | 0x4, 26, CLK_MUX_SETCLR_UPD), |
| 537 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_DSP_SEL, dsp_parents, |
| 538 | 0x0a0, 0x0a4, 0x0a8, 24, 3, 31, |
| 539 | 0x4, 27, CLK_MUX_SETCLR_UPD), |
| 540 | /* CLK_CFG_7 */ |
| 541 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_NFI2X_SEL, nfi2x_parents, |
| 542 | 0x0b0, 0x0b4, 0x0b8, 0, 3, 7, |
| 543 | 0x4, 28, CLK_MUX_SETCLR_UPD), |
| 544 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SPINFI_SEL, spinfi_parents, |
| 545 | 0x0b0, 0x0b4, 0x0b8, 8, 3, 15, |
| 546 | 0x4, 29, CLK_MUX_SETCLR_UPD), |
| 547 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_ECC_SEL, ecc_parents, |
| 548 | 0x0b0, 0x0b4, 0x0b8, 16, 2, 23, |
| 549 | 0x4, 30, CLK_MUX_SETCLR_UPD), |
| 550 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_GCPU_SEL, gcpu_parents, |
| 551 | 0x0b0, 0x0b4, 0x0b8, 24, 3, 31, |
| 552 | 0x4, 31, CLK_MUX_SETCLR_UPD), |
| 553 | /* CLK_CFG_8 */ |
| 554 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_GCPU_CPM_SEL, gcpu_cpm_parents, |
| 555 | 0x0c0, 0x0c4, 0x0c8, 0, 2, 7, |
| 556 | 0x8, 0, CLK_MUX_SETCLR_UPD), |
| 557 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MBIST_DIAG_SEL, mbist_diag_parents, |
| 558 | 0x0c0, 0x0c4, 0x0c8, 8, 1, 15, |
| 559 | 0x8, 1, CLK_MUX_SETCLR_UPD), |
| 560 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_IP0_NNA_SEL, ip0_nna_parents, |
| 561 | 0x0c0, 0x0c4, 0x0c8, 16, 3, 23, |
| 562 | 0x8, 2, CLK_MUX_SETCLR_UPD), |
| 563 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_IP1_NNA_SEL, ip0_nna_parents, |
| 564 | 0x0c0, 0x0c4, 0x0c8, 24, 3, 31, |
| 565 | 0x8, 3, CLK_MUX_SETCLR_UPD), |
| 566 | /* CLK_CFG_9 */ |
| 567 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_IP2_WFST_SEL, ip2_wfst_parents, |
| 568 | 0x0d0, 0x0d4, 0x0d8, 0, 3, 7, |
| 569 | 0x8, 4, CLK_MUX_SETCLR_UPD), |
| 570 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SFLASH_SEL, sflash_parents, |
| 571 | 0x0d0, 0x0d4, 0x0d8, 8, 3, 15, |
| 572 | 0x8, 5, CLK_MUX_SETCLR_UPD), |
| 573 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_SRAM_SEL, sram_parents, |
| 574 | 0x0d0, 0x0d4, 0x0d8, 16, 3, 23, |
| 575 | 0x8, 6, CLK_MUX_SETCLR_UPD), |
| 576 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_MM_SEL, mm_parents, |
| 577 | 0x0d0, 0x0d4, 0x0d8, 24, 3, 31, |
| 578 | 0x8, 7, CLK_MUX_SETCLR_UPD), |
| 579 | /* CLK_CFG_10 */ |
| 580 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_DPI0_SEL, dpi0_parents, |
| 581 | 0x0e0, 0x0e4, 0x0e8, 0, 3, 7, |
| 582 | 0x8, 8, CLK_MUX_SETCLR_UPD), |
| 583 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_DBG_ATCLK_SEL, dbg_atclk_parents, |
| 584 | 0x0e0, 0x0e4, 0x0e8, 8, 2, 15, |
| 585 | 0x8, 9, CLK_MUX_SETCLR_UPD), |
| 586 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_OCC_104M_SEL, occ_104m_parents, |
| 587 | 0x0e0, 0x0e4, 0x0e8, 16, 1, 23, |
| 588 | 0x8, 10, CLK_MUX_SETCLR_UPD), |
| 589 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_OCC_68M_SEL, occ_68m_parents, |
| 590 | 0x0e0, 0x0e4, 0x0e8, 24, 1, 31, |
| 591 | 0x8, 11, CLK_MUX_SETCLR_UPD), |
| 592 | /* CLK_CFG_11 */ |
| 593 | MUX_CLR_SET_UPD_FLAGS(CLK_TOP_OCC_182M_SEL, occ_182m_parents, |
| 594 | 0x0ec, 0x0f0, 0x0f4, 0, 2, 7, |
| 595 | 0x8, 12, CLK_MUX_SETCLR_UPD), |
| 596 | }; |
| 597 | |
| 598 | static const struct mtk_gate_regs top0_cg_regs = { |
| 599 | .set_ofs = 0x0, |
| 600 | .clr_ofs = 0x0, |
| 601 | .sta_ofs = 0x0, |
| 602 | }; |
| 603 | |
| 604 | static const struct mtk_gate_regs top1_cg_regs = { |
| 605 | .set_ofs = 0x104, |
| 606 | .clr_ofs = 0x104, |
| 607 | .sta_ofs = 0x104, |
| 608 | }; |
| 609 | |
| 610 | #define GATE_TOP0(_id, _parent, _shift) { \ |
| 611 | .id = _id, \ |
| 612 | .parent = _parent, \ |
| 613 | .regs = &top0_cg_regs, \ |
| 614 | .shift = _shift, \ |
| 615 | .flags = CLK_GATE_NO_SETCLR | CLK_PARENT_TOPCKGEN, \ |
| 616 | } |
| 617 | |
| 618 | #define GATE_TOP1(_id, _parent, _shift) { \ |
| 619 | .id = _id, \ |
| 620 | .parent = _parent, \ |
| 621 | .regs = &top1_cg_regs, \ |
| 622 | .shift = _shift, \ |
| 623 | .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ |
| 624 | } |
| 625 | |
| 626 | static const struct mtk_gate top_clks[] = { |
| 627 | /* TOP0 */ |
| 628 | GATE_TOP0(CLK_TOP_CONN_32K, CLK_TOP_CLK32K, 10), |
| 629 | GATE_TOP0(CLK_TOP_CONN_26M, CLK_TOP_CLK26M, 11), |
| 630 | GATE_TOP0(CLK_TOP_DSP_32K, CLK_TOP_CLK32K, 16), |
| 631 | GATE_TOP0(CLK_TOP_DSP_26M, CLK_TOP_CLK26M, 17), |
| 632 | /* TOP1 */ |
| 633 | GATE_TOP1(CLK_TOP_USB20_48M_EN, CLK_TOP_USB20_192M_D4_T, 8), |
| 634 | GATE_TOP1(CLK_TOP_UNIVPLL_48M_EN, CLK_TOP_USB20_192M_D4_T, 9), |
| 635 | GATE_TOP1(CLK_TOP_SSUSB_TOP_CK_EN, CLK_TOP_CLK_NULL, 22), |
| 636 | GATE_TOP1(CLK_TOP_SSUSB_PHY_CK_EN, CLK_TOP_CLK_NULL, 23), |
| 637 | }; |
| 638 | |
| 639 | static const struct mtk_gate_regs infra0_cg_regs = { |
| 640 | .set_ofs = 0x294, |
| 641 | .clr_ofs = 0x294, |
| 642 | .sta_ofs = 0x294, |
| 643 | }; |
| 644 | |
| 645 | static const struct mtk_gate_regs infra1_cg_regs = { |
| 646 | .set_ofs = 0x80, |
| 647 | .clr_ofs = 0x84, |
| 648 | .sta_ofs = 0x90, |
| 649 | }; |
| 650 | |
| 651 | static const struct mtk_gate_regs infra2_cg_regs = { |
| 652 | .set_ofs = 0x88, |
| 653 | .clr_ofs = 0x8c, |
| 654 | .sta_ofs = 0x94, |
| 655 | }; |
| 656 | |
| 657 | static const struct mtk_gate_regs infra3_cg_regs = { |
| 658 | .set_ofs = 0xa4, |
| 659 | .clr_ofs = 0xa8, |
| 660 | .sta_ofs = 0xac, |
| 661 | }; |
| 662 | |
| 663 | static const struct mtk_gate_regs infra4_cg_regs = { |
| 664 | .set_ofs = 0xc0, |
| 665 | .clr_ofs = 0xc4, |
| 666 | .sta_ofs = 0xc8, |
| 667 | }; |
| 668 | |
| 669 | static const struct mtk_gate_regs infra5_cg_regs = { |
| 670 | .set_ofs = 0xd0, |
| 671 | .clr_ofs = 0xd4, |
| 672 | .sta_ofs = 0xd8, |
| 673 | }; |
| 674 | |
| 675 | #define GATE_INFRA0(_id, _parent, _shift) { \ |
| 676 | .id = _id, \ |
| 677 | .parent = _parent, \ |
| 678 | .regs = &infra0_cg_regs, \ |
| 679 | .shift = _shift, \ |
| 680 | .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ |
| 681 | } |
| 682 | |
| 683 | #define GATE_INFRA1(_id, _parent, _shift) { \ |
| 684 | .id = _id, \ |
| 685 | .parent = _parent, \ |
| 686 | .regs = &infra1_cg_regs, \ |
| 687 | .shift = _shift, \ |
| 688 | .flags = CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN, \ |
| 689 | } |
| 690 | |
| 691 | #define GATE_INFRA2(_id, _parent, _shift) { \ |
| 692 | .id = _id, \ |
| 693 | .parent = _parent, \ |
| 694 | .regs = &infra2_cg_regs, \ |
| 695 | .shift = _shift, \ |
| 696 | .flags = CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN, \ |
| 697 | } |
| 698 | |
| 699 | #define GATE_INFRA3(_id, _parent, _shift) { \ |
| 700 | .id = _id, \ |
| 701 | .parent = _parent, \ |
| 702 | .regs = &infra3_cg_regs, \ |
| 703 | .shift = _shift, \ |
| 704 | .flags = CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN, \ |
| 705 | } |
| 706 | |
| 707 | #define GATE_INFRA4(_id, _parent, _shift) { \ |
| 708 | .id = _id, \ |
| 709 | .parent = _parent, \ |
| 710 | .regs = &infra4_cg_regs, \ |
| 711 | .shift = _shift, \ |
| 712 | .flags = CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN, \ |
| 713 | } |
| 714 | |
| 715 | #define GATE_INFRA5(_id, _parent, _shift) { \ |
| 716 | .id = _id, \ |
| 717 | .parent = _parent, \ |
| 718 | .regs = &infra5_cg_regs, \ |
| 719 | .shift = _shift, \ |
| 720 | .flags = CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN, \ |
| 721 | } |
| 722 | |
| 723 | static const struct mtk_gate infra_clks[] = { |
| 724 | /* INFRA0 */ |
| 725 | GATE_INFRA0(CLK_INFRA_DSP_AXI, CLK_TOP_AXI_SEL, 8), |
| 726 | /* INFRA1 */ |
| 727 | GATE_INFRA1(CLK_INFRA_APXGPT, CLK_TOP_AXI_SEL, 6), |
| 728 | GATE_INFRA1(CLK_INFRA_ICUSB, CLK_TOP_AXI_SEL, 8), |
| 729 | GATE_INFRA1(CLK_INFRA_GCE, CLK_TOP_AXI_SEL, 9), |
| 730 | GATE_INFRA1(CLK_INFRA_THERM, CLK_TOP_AXI_SEL, 10), |
| 731 | GATE_INFRA1(CLK_INFRA_PWM_HCLK, CLK_TOP_AXI_SEL, 15), |
| 732 | GATE_INFRA1(CLK_INFRA_PWM1, CLK_TOP_PWM_SEL, 16), |
| 733 | GATE_INFRA1(CLK_INFRA_PWM2, CLK_TOP_PWM_SEL, 17), |
| 734 | GATE_INFRA1(CLK_INFRA_PWM3, CLK_TOP_PWM_SEL, 18), |
| 735 | GATE_INFRA1(CLK_INFRA_PWM4, CLK_TOP_PWM_SEL, 19), |
| 736 | GATE_INFRA1(CLK_INFRA_PWM5, CLK_TOP_PWM_SEL, 20), |
| 737 | GATE_INFRA1(CLK_INFRA_PWM, CLK_TOP_PWM_SEL, 21), |
| 738 | GATE_INFRA1(CLK_INFRA_UART0, CLK_TOP_UART_SEL, 22), |
| 739 | GATE_INFRA1(CLK_INFRA_UART1, CLK_TOP_UART_SEL, 23), |
| 740 | GATE_INFRA1(CLK_INFRA_UART2, CLK_TOP_UART_SEL, 24), |
| 741 | GATE_INFRA1(CLK_INFRA_DSP_UART, CLK_TOP_UART_SEL, 26), |
| 742 | GATE_INFRA1(CLK_INFRA_GCE_26M, CLK_TOP_CLK26M, 27), |
| 743 | GATE_INFRA1(CLK_INFRA_CQDMA_FPC, CLK_TOP_AXI_SEL, 28), |
| 744 | GATE_INFRA1(CLK_INFRA_BTIF, CLK_TOP_AXI_SEL, 31), |
| 745 | /* INFRA2 */ |
| 746 | GATE_INFRA2(CLK_INFRA_SPI, CLK_TOP_SPI_SEL, 1), |
| 747 | GATE_INFRA2(CLK_INFRA_MSDC0, CLK_TOP_MSDC50_0_HC_SEL, 2), |
| 748 | GATE_INFRA2(CLK_INFRA_MSDC1, CLK_TOP_AXI_SEL, 4), |
| 749 | GATE_INFRA2(CLK_INFRA_DVFSRC, CLK_TOP_CLK26M, 7), |
| 750 | GATE_INFRA2(CLK_INFRA_GCPU, CLK_TOP_AXI_SEL, 8), |
| 751 | GATE_INFRA2(CLK_INFRA_TRNG, CLK_TOP_AXI_SEL, 9), |
| 752 | GATE_INFRA2(CLK_INFRA_AUXADC, CLK_TOP_CLK26M, 10), |
| 753 | GATE_INFRA2(CLK_INFRA_AUXADC_MD, CLK_TOP_CLK26M, 14), |
| 754 | GATE_INFRA2(CLK_INFRA_AP_DMA, CLK_TOP_AXI_SEL, 18), |
| 755 | GATE_INFRA2(CLK_INFRA_DEBUGSYS, CLK_TOP_AXI_SEL, 24), |
| 756 | GATE_INFRA2(CLK_INFRA_AUDIO, CLK_TOP_AXI_SEL, 25), |
| 757 | GATE_INFRA2(CLK_INFRA_FLASHIF, CLK_TOP_SFLASH_SEL, 29), |
| 758 | /* INFRA3 */ |
| 759 | GATE_INFRA3(CLK_INFRA_PWM_FB6, CLK_TOP_PWM_SEL, 0), |
| 760 | GATE_INFRA3(CLK_INFRA_PWM_FB7, CLK_TOP_PWM_SEL, 1), |
| 761 | GATE_INFRA3(CLK_INFRA_AUD_ASRC, CLK_TOP_AXI_SEL, 3), |
| 762 | GATE_INFRA3(CLK_INFRA_AUD_26M, CLK_TOP_CLK26M, 4), |
| 763 | GATE_INFRA3(CLK_INFRA_SPIS, CLK_TOP_AXI_SEL, 6), |
| 764 | GATE_INFRA3(CLK_INFRA_CQ_DMA, CLK_TOP_AXI_SEL, 27), |
| 765 | /* INFRA4 */ |
| 766 | GATE_INFRA4(CLK_INFRA_AP_MSDC0, CLK_TOP_MSDC50_0_SEL, 7), |
| 767 | GATE_INFRA4(CLK_INFRA_MD_MSDC0, CLK_TOP_MSDC50_0_SEL, 8), |
| 768 | GATE_INFRA4(CLK_INFRA_MSDC0_SRC, CLK_TOP_MSDC50_0_SEL, 9), |
| 769 | GATE_INFRA4(CLK_INFRA_MSDC1_SRC, CLK_TOP_MSDC30_1_SEL, 10), |
| 770 | GATE_INFRA4(CLK_INFRA_IRRX_26M, CLK_TOP_AXI_SEL, 22), |
| 771 | GATE_INFRA4(CLK_INFRA_IRRX_32K, CLK_TOP_CLK32K, 23), |
| 772 | GATE_INFRA4(CLK_INFRA_I2C0_AXI, CLK_TOP_I2C_SEL, 24), |
| 773 | GATE_INFRA4(CLK_INFRA_I2C1_AXI, CLK_TOP_I2C_SEL, 25), |
| 774 | GATE_INFRA4(CLK_INFRA_I2C2_AXI, CLK_TOP_I2C_SEL, 26), |
| 775 | /* INFRA5 */ |
| 776 | GATE_INFRA5(CLK_INFRA_NFI, CLK_TOP_NFI2X_CK_D2, 1), |
| 777 | GATE_INFRA5(CLK_INFRA_NFIECC, CLK_TOP_NFI2X_CK_D2, 2), |
| 778 | GATE_INFRA5(CLK_INFRA_NFI_HCLK, CLK_TOP_AXI_SEL, 3), |
| 779 | GATE_INFRA5(CLK_INFRA_SUSB_133, CLK_TOP_AXI_SEL, 7), |
| 780 | GATE_INFRA5(CLK_INFRA_USB_SYS, CLK_TOP_SSUSB_SYS_SEL, 9), |
| 781 | GATE_INFRA5(CLK_INFRA_USB_XHCI, CLK_TOP_SSUSB_XHCI_SEL, 11), |
| 782 | }; |
| 783 | |
| 784 | static const struct mtk_clk_tree mt8512_clk_tree = { |
| 785 | .xtal_rate = 26 * MHZ, |
| 786 | .xtal2_rate = 26 * MHZ, |
| 787 | .fdivs_offs = CLK_TOP_SYSPLL1_D2, |
| 788 | .muxes_offs = CLK_TOP_AXI_SEL, |
| 789 | .plls = apmixed_plls, |
| 790 | .fclks = top_fixed_clks, |
| 791 | .fdivs = top_fixed_divs, |
| 792 | .muxes = top_muxes, |
| 793 | }; |
| 794 | |
| 795 | static int mt8512_apmixedsys_probe(struct udevice *dev) |
| 796 | { |
| 797 | return mtk_common_clk_init(dev, &mt8512_clk_tree); |
| 798 | } |
| 799 | |
| 800 | static int mt8512_topckgen_probe(struct udevice *dev) |
| 801 | { |
| 802 | return mtk_common_clk_init(dev, &mt8512_clk_tree); |
| 803 | } |
| 804 | |
| 805 | static int mt8512_topckgen_cg_probe(struct udevice *dev) |
| 806 | { |
| 807 | return mtk_common_clk_gate_init(dev, &mt8512_clk_tree, top_clks); |
| 808 | } |
| 809 | |
| 810 | static int mt8512_infracfg_probe(struct udevice *dev) |
| 811 | { |
| 812 | return mtk_common_clk_gate_init(dev, &mt8512_clk_tree, infra_clks); |
| 813 | } |
| 814 | |
| 815 | static const struct udevice_id mt8512_apmixed_compat[] = { |
| 816 | { .compatible = "mediatek,mt8512-apmixedsys", }, |
| 817 | { } |
| 818 | }; |
| 819 | |
| 820 | static const struct udevice_id mt8512_topckgen_compat[] = { |
| 821 | { .compatible = "mediatek,mt8512-topckgen", }, |
| 822 | { } |
| 823 | }; |
| 824 | |
| 825 | static const struct udevice_id mt8512_topckgen_cg_compat[] = { |
| 826 | { .compatible = "mediatek,mt8512-topckgen-cg", }, |
| 827 | { } |
| 828 | }; |
| 829 | |
| 830 | static const struct udevice_id mt8512_infracfg_compat[] = { |
| 831 | { .compatible = "mediatek,mt8512-infracfg", }, |
| 832 | { } |
| 833 | }; |
| 834 | |
| 835 | U_BOOT_DRIVER(mtk_clk_apmixedsys) = { |
| 836 | .name = "mt8512-apmixedsys", |
| 837 | .id = UCLASS_CLK, |
| 838 | .of_match = mt8512_apmixed_compat, |
| 839 | .probe = mt8512_apmixedsys_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 840 | .priv_auto = sizeof(struct mtk_clk_priv), |
developer | 4a79703 | 2019-12-31 11:29:20 +0800 | [diff] [blame] | 841 | .ops = &mtk_clk_apmixedsys_ops, |
| 842 | .flags = DM_FLAG_PRE_RELOC, |
| 843 | }; |
| 844 | |
| 845 | U_BOOT_DRIVER(mtk_clk_topckgen) = { |
| 846 | .name = "mt8512-topckgen", |
| 847 | .id = UCLASS_CLK, |
| 848 | .of_match = mt8512_topckgen_compat, |
| 849 | .probe = mt8512_topckgen_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 850 | .priv_auto = sizeof(struct mtk_clk_priv), |
developer | 4a79703 | 2019-12-31 11:29:20 +0800 | [diff] [blame] | 851 | .ops = &mtk_clk_topckgen_ops, |
| 852 | .flags = DM_FLAG_PRE_RELOC, |
| 853 | }; |
| 854 | |
| 855 | U_BOOT_DRIVER(mtk_clk_topckgen_cg) = { |
| 856 | .name = "mt8512-topckgen-cg", |
| 857 | .id = UCLASS_CLK, |
| 858 | .of_match = mt8512_topckgen_cg_compat, |
| 859 | .probe = mt8512_topckgen_cg_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 860 | .priv_auto = sizeof(struct mtk_cg_priv), |
developer | 4a79703 | 2019-12-31 11:29:20 +0800 | [diff] [blame] | 861 | .ops = &mtk_clk_gate_ops, |
| 862 | .flags = DM_FLAG_PRE_RELOC, |
| 863 | }; |
| 864 | |
| 865 | U_BOOT_DRIVER(mtk_clk_infracfg) = { |
| 866 | .name = "mt8512-infracfg", |
| 867 | .id = UCLASS_CLK, |
| 868 | .of_match = mt8512_infracfg_compat, |
| 869 | .probe = mt8512_infracfg_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 870 | .priv_auto = sizeof(struct mtk_cg_priv), |
developer | 4a79703 | 2019-12-31 11:29:20 +0800 | [diff] [blame] | 871 | .ops = &mtk_clk_gate_ops, |
| 872 | .flags = DM_FLAG_PRE_RELOC, |
| 873 | }; |