.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2014 MundoReader S.L. |
---|
3 | 4 | * Author: Heiko Stuebner <heiko@sntech.de> |
---|
.. | .. |
---|
11 | 12 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
---|
12 | 13 | * Copyright (c) 2013 Linaro Ltd. |
---|
13 | 14 | * Author: Thomas Abraham <thomas.ab@samsung.com> |
---|
14 | | - * |
---|
15 | | - * This program is free software; you can redistribute it and/or modify |
---|
16 | | - * it under the terms of the GNU General Public License as published by |
---|
17 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
18 | | - * (at your option) any later version. |
---|
19 | | - * |
---|
20 | | - * This program is distributed in the hope that it will be useful, |
---|
21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
23 | | - * GNU General Public License for more details. |
---|
24 | 15 | */ |
---|
25 | 16 | |
---|
26 | 17 | #ifndef CLK_ROCKCHIP_CLK_H |
---|
.. | .. |
---|
86 | 77 | #define PX30_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x40) |
---|
87 | 78 | #define PX30_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x80) |
---|
88 | 79 | #define PX30_PMU_MODE 0x0020 |
---|
| 80 | + |
---|
| 81 | +#define RV1106_TOPCRU_BASE 0x10000 |
---|
| 82 | +#define RV1106_PERICRU_BASE 0x12000 |
---|
| 83 | +#define RV1106_VICRU_BASE 0x14000 |
---|
| 84 | +#define RV1106_NPUCRU_BASE 0x16000 |
---|
| 85 | +#define RV1106_CORECRU_BASE 0x18000 |
---|
| 86 | +#define RV1106_VEPUCRU_BASE 0x1A000 |
---|
| 87 | +#define RV1106_VOCRU_BASE 0x1C000 |
---|
| 88 | +#define RV1106_DDRCRU_BASE 0x1E000 |
---|
| 89 | +#define RV1106_SUBDDRCRU_BASE 0x1F000 |
---|
| 90 | + |
---|
| 91 | +#define RV1106_VI_GRF_BASE 0x50000 |
---|
| 92 | +#define RV1106_VO_GRF_BASE 0x60000 |
---|
| 93 | + |
---|
| 94 | +#define RV1106_PMUCLKSEL_CON(x) ((x) * 0x4 + 0x300) |
---|
| 95 | +#define RV1106_PMUCLKGATE_CON(x) ((x) * 0x4 + 0x800) |
---|
| 96 | +#define RV1106_PMUSOFTRST_CON(x) ((x) * 0x4 + 0xa00) |
---|
| 97 | +#define RV1106_PLL_CON(x) ((x) * 0x4 + RV1106_TOPCRU_BASE) |
---|
| 98 | +#define RV1106_MODE_CON (0x280 + RV1106_TOPCRU_BASE) |
---|
| 99 | +#define RV1106_CLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_TOPCRU_BASE) |
---|
| 100 | +#define RV1106_CLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_TOPCRU_BASE) |
---|
| 101 | +#define RV1106_SOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_TOPCRU_BASE) |
---|
| 102 | +#define RV1106_GLB_SRST_FST (0xc08 + RV1106_TOPCRU_BASE) |
---|
| 103 | +#define RV1106_GLB_SRST_SND (0xc0c + RV1106_TOPCRU_BASE) |
---|
| 104 | +#define RV1106_SDIO_CON0 (0x1c + RV1106_VO_GRF_BASE) |
---|
| 105 | +#define RV1106_SDIO_CON1 (0x20 + RV1106_VO_GRF_BASE) |
---|
| 106 | +#define RV1106_SDMMC_CON0 (0x4 + RV1106_VI_GRF_BASE) |
---|
| 107 | +#define RV1106_SDMMC_CON1 (0x8 + RV1106_VI_GRF_BASE) |
---|
| 108 | +#define RV1106_EMMC_CON0 (0x20) |
---|
| 109 | +#define RV1106_EMMC_CON1 (0x24) |
---|
| 110 | +#define RV1106_PERICLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_PERICRU_BASE) |
---|
| 111 | +#define RV1106_PERICLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_PERICRU_BASE) |
---|
| 112 | +#define RV1106_PERISOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_PERICRU_BASE) |
---|
| 113 | +#define RV1106_VICLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_VICRU_BASE) |
---|
| 114 | +#define RV1106_VICLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_VICRU_BASE) |
---|
| 115 | +#define RV1106_VISOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_VICRU_BASE) |
---|
| 116 | +#define RV1106_VICLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_VICRU_BASE) |
---|
| 117 | +#define RV1106_VICLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_VICRU_BASE) |
---|
| 118 | +#define RV1106_VISOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_VICRU_BASE) |
---|
| 119 | +#define RV1106_NPUCLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_NPUCRU_BASE) |
---|
| 120 | +#define RV1106_NPUCLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_NPUCRU_BASE) |
---|
| 121 | +#define RV1106_NPUSOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_NPUCRU_BASE) |
---|
| 122 | +#define RV1106_CORECLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_CORECRU_BASE) |
---|
| 123 | +#define RV1106_CORECLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_CORECRU_BASE) |
---|
| 124 | +#define RV1106_CORESOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_CORECRU_BASE) |
---|
| 125 | +#define RV1106_VEPUCLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_VEPUCRU_BASE) |
---|
| 126 | +#define RV1106_VEPUCLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_VEPUCRU_BASE) |
---|
| 127 | +#define RV1106_VEPUSOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_VEPUCRU_BASE) |
---|
| 128 | +#define RV1106_VOCLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_VOCRU_BASE) |
---|
| 129 | +#define RV1106_VOCLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_VOCRU_BASE) |
---|
| 130 | +#define RV1106_VOSOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_VOCRU_BASE) |
---|
| 131 | +#define RV1106_DDRCLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_DDRCRU_BASE) |
---|
| 132 | +#define RV1106_DDRCLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_DDRCRU_BASE) |
---|
| 133 | +#define RV1106_DDRSOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_DDRCRU_BASE) |
---|
| 134 | +#define RV1106_SUBDDRCLKSEL_CON(x) ((x) * 0x4 + 0x300 + RV1106_SUBDDRCRU_BASE) |
---|
| 135 | +#define RV1106_SUBDDRCLKGATE_CON(x) ((x) * 0x4 + 0x800 + RV1106_SUBDDRCRU_BASE) |
---|
| 136 | +#define RV1106_SUBDDRSOFTRST_CON(x) ((x) * 0x4 + 0xa00 + RV1106_SUBDDRCRU_BASE) |
---|
| 137 | +#define RV1106_SUBDDRMODE_CON (0x280 + RV1106_SUBDDRCRU_BASE) |
---|
89 | 138 | |
---|
90 | 139 | #define RV1108_PLL_CON(x) ((x) * 0x4) |
---|
91 | 140 | #define RV1108_CLKSEL_CON(x) ((x) * 0x4 + 0x60) |
---|
.. | .. |
---|
255 | 304 | #define RK3399_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x100) |
---|
256 | 305 | #define RK3399_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x110) |
---|
257 | 306 | |
---|
| 307 | +#define RK3528_PMU_CRU_BASE 0x10000 |
---|
| 308 | +#define RK3528_PCIE_CRU_BASE 0x20000 |
---|
| 309 | +#define RK3528_DDRPHY_CRU_BASE 0x28000 |
---|
| 310 | +#define RK3528_VPU_GRF_BASE 0x40000 |
---|
| 311 | +#define RK3528_VO_GRF_BASE 0x60000 |
---|
| 312 | +#define RK3528_SDMMC_CON0 (RK3528_VO_GRF_BASE + 0x24) |
---|
| 313 | +#define RK3528_SDMMC_CON1 (RK3528_VO_GRF_BASE + 0x28) |
---|
| 314 | +#define RK3528_SDIO0_CON0 (RK3528_VPU_GRF_BASE + 0x4) |
---|
| 315 | +#define RK3528_SDIO0_CON1 (RK3528_VPU_GRF_BASE + 0x8) |
---|
| 316 | +#define RK3528_SDIO1_CON0 (RK3528_VPU_GRF_BASE + 0xc) |
---|
| 317 | +#define RK3528_SDIO1_CON1 (RK3528_VPU_GRF_BASE + 0x10) |
---|
| 318 | +#define RK3528_PLL_CON(x) RK2928_PLL_CON(x) |
---|
| 319 | +#define RK3528_PCIE_PLL_CON(x) ((x) * 0x4 + RK3528_PCIE_CRU_BASE) |
---|
| 320 | +#define RK3528_DDRPHY_PLL_CON(x) ((x) * 0x4 + RK3528_DDRPHY_CRU_BASE) |
---|
| 321 | +#define RK3528_MODE_CON 0x280 |
---|
| 322 | +#define RK3528_CLKSEL_CON(x) ((x) * 0x4 + 0x300) |
---|
| 323 | +#define RK3528_CLKGATE_CON(x) ((x) * 0x4 + 0x800) |
---|
| 324 | +#define RK3528_SOFTRST_CON(x) ((x) * 0x4 + 0xa00) |
---|
| 325 | +#define RK3528_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x300 + RK3528_PMU_CRU_BASE) |
---|
| 326 | +#define RK3528_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x800 + RK3528_PMU_CRU_BASE) |
---|
| 327 | +#define RK3528_PCIE_CLKSEL_CON(x) ((x) * 0x4 + 0x300 + RK3528_PCIE_CRU_BASE) |
---|
| 328 | +#define RK3528_PCIE_CLKGATE_CON(x) ((x) * 0x4 + 0x800 + RK3528_PCIE_CRU_BASE) |
---|
| 329 | +#define RK3528_DDRPHY_CLKGATE_CON(x) ((x) * 0x4 + 0x800 + RK3528_DDRPHY_CRU_BASE) |
---|
| 330 | +#define RK3528_DDRPHY_MODE_CON (0x280 + RK3528_DDRPHY_CRU_BASE) |
---|
| 331 | +#define RK3528_GLB_CNT_TH 0xc00 |
---|
| 332 | +#define RK3528_GLB_SRST_FST 0xc08 |
---|
| 333 | +#define RK3528_GLB_SRST_SND 0xc0c |
---|
| 334 | + |
---|
| 335 | +#define RK3562_PMU0_CRU_BASE 0x10000 |
---|
| 336 | +#define RK3562_PMU1_CRU_BASE 0x18000 |
---|
| 337 | +#define RK3562_DDR_CRU_BASE 0x20000 |
---|
| 338 | +#define RK3562_SUBDDR_CRU_BASE 0x28000 |
---|
| 339 | +#define RK3562_PERI_CRU_BASE 0x30000 |
---|
| 340 | + |
---|
| 341 | +#define RK3562_PLL_CON(x) RK2928_PLL_CON(x) |
---|
| 342 | +#define RK3562_PMU1_PLL_CON(x) ((x) * 0x4 + RK3562_PMU1_CRU_BASE + 0x40) |
---|
| 343 | +#define RK3562_SUBDDR_PLL_CON(x) ((x) * 0x4 + RK3562_SUBDDR_CRU_BASE + 0x20) |
---|
| 344 | +#define RK3562_MODE_CON 0x600 |
---|
| 345 | +#define RK3562_PMU1_MODE_CON (RK3562_PMU1_CRU_BASE + 0x380) |
---|
| 346 | +#define RK3562_SUBDDR_MODE_CON (RK3562_SUBDDR_CRU_BASE + 0x380) |
---|
| 347 | +#define RK3562_CLKSEL_CON(x) ((x) * 0x4 + 0x100) |
---|
| 348 | +#define RK3562_CLKGATE_CON(x) ((x) * 0x4 + 0x300) |
---|
| 349 | +#define RK3562_SOFTRST_CON(x) ((x) * 0x4 + 0x400) |
---|
| 350 | +#define RK3562_DDR_CLKSEL_CON(x) ((x) * 0x4 + RK3562_DDR_CRU_BASE + 0x100) |
---|
| 351 | +#define RK3562_DDR_CLKGATE_CON(x) ((x) * 0x4 + RK3562_DDR_CRU_BASE + 0x180) |
---|
| 352 | +#define RK3562_DDR_SOFTRST_CON(x) ((x) * 0x4 + RK3562_DDR_CRU_BASE + 0x200) |
---|
| 353 | +#define RK3562_SUBDDR_CLKSEL_CON(x) ((x) * 0x4 + RK3562_SUBDDR_CRU_BASE + 0x100) |
---|
| 354 | +#define RK3562_SUBDDR_CLKGATE_CON(x) ((x) * 0x4 + RK3562_SUBDDR_CRU_BASE + 0x180) |
---|
| 355 | +#define RK3562_SUBDDR_SOFTRST_CON(x) ((x) * 0x4 + RK3562_SUBDDR_CRU_BASE + 0x200) |
---|
| 356 | +#define RK3562_PERI_CLKSEL_CON(x) ((x) * 0x4 + RK3562_PERI_CRU_BASE + 0x100) |
---|
| 357 | +#define RK3562_PERI_CLKGATE_CON(x) ((x) * 0x4 + RK3562_PERI_CRU_BASE + 0x300) |
---|
| 358 | +#define RK3562_PERI_SOFTRST_CON(x) ((x) * 0x4 + RK3562_PERI_CRU_BASE + 0x400) |
---|
| 359 | +#define RK3562_PMU0_CLKSEL_CON(x) ((x) * 0x4 + RK3562_PMU0_CRU_BASE + 0x100) |
---|
| 360 | +#define RK3562_PMU0_CLKGATE_CON(x) ((x) * 0x4 + RK3562_PMU0_CRU_BASE + 0x180) |
---|
| 361 | +#define RK3562_PMU0_SOFTRST_CON(x) ((x) * 0x4 + RK3562_PMU0_CRU_BASE + 0x200) |
---|
| 362 | +#define RK3562_PMU1_CLKSEL_CON(x) ((x) * 0x4 + RK3562_PMU1_CRU_BASE + 0x100) |
---|
| 363 | +#define RK3562_PMU1_CLKGATE_CON(x) ((x) * 0x4 + RK3562_PMU1_CRU_BASE + 0x180) |
---|
| 364 | +#define RK3562_PMU1_SOFTRST_CON(x) ((x) * 0x4 + RK3562_PMU1_CRU_BASE + 0x200) |
---|
| 365 | +#define RK3562_GLB_SRST_FST 0x614 |
---|
| 366 | +#define RK3562_GLB_SRST_SND 0x618 |
---|
| 367 | +#define RK3562_GLB_RST_CON 0x61c |
---|
| 368 | +#define RK3562_GLB_RST_ST 0x620 |
---|
| 369 | +#define RK3562_SDMMC0_CON0 0x624 |
---|
| 370 | +#define RK3562_SDMMC0_CON1 0x628 |
---|
| 371 | +#define RK3562_SDMMC1_CON0 0x62c |
---|
| 372 | +#define RK3562_SDMMC1_CON1 0x630 |
---|
| 373 | + |
---|
258 | 374 | #define RK3568_PLL_CON(x) RK2928_PLL_CON(x) |
---|
259 | 375 | #define RK3568_MODE_CON0 0xc0 |
---|
260 | 376 | #define RK3568_MISC_CON0 0xc4 |
---|
.. | .. |
---|
283 | 399 | #define RK3568_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x180) |
---|
284 | 400 | #define RK3568_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x200) |
---|
285 | 401 | |
---|
| 402 | +#define RK3588_PHP_CRU_BASE 0x8000 |
---|
| 403 | +#define RK3588_PMU_CRU_BASE 0x30000 |
---|
| 404 | +#define RK3588_BIGCORE0_CRU_BASE 0x50000 |
---|
| 405 | +#define RK3588_BIGCORE1_CRU_BASE 0x52000 |
---|
| 406 | +#define RK3588_DSU_CRU_BASE 0x58000 |
---|
| 407 | + |
---|
| 408 | +#define RK3588_PLL_CON(x) RK2928_PLL_CON(x) |
---|
| 409 | +#define RK3588_MODE_CON0 0x280 |
---|
| 410 | +#define RK3588_B0_PLL_MODE_CON0 (RK3588_BIGCORE0_CRU_BASE + 0x280) |
---|
| 411 | +#define RK3588_B1_PLL_MODE_CON0 (RK3588_BIGCORE1_CRU_BASE + 0x280) |
---|
| 412 | +#define RK3588_LPLL_MODE_CON0 (RK3588_DSU_CRU_BASE + 0x280) |
---|
| 413 | +#define RK3588_CLKSEL_CON(x) ((x) * 0x4 + 0x300) |
---|
| 414 | +#define RK3588_CLKGATE_CON(x) ((x) * 0x4 + 0x800) |
---|
| 415 | +#define RK3588_SOFTRST_CON(x) ((x) * 0x4 + 0xa00) |
---|
| 416 | +#define RK3588_GLB_CNT_TH 0xc00 |
---|
| 417 | +#define RK3588_GLB_SRST_FST 0xc08 |
---|
| 418 | +#define RK3588_GLB_SRST_SND 0xc0c |
---|
| 419 | +#define RK3588_GLB_RST_CON 0xc10 |
---|
| 420 | +#define RK3588_GLB_RST_ST 0xc04 |
---|
| 421 | +#define RK3588_SDIO_CON0 0xC24 |
---|
| 422 | +#define RK3588_SDIO_CON1 0xC28 |
---|
| 423 | +#define RK3588_SDMMC_CON0 0xC30 |
---|
| 424 | +#define RK3588_SDMMC_CON1 0xC34 |
---|
| 425 | + |
---|
| 426 | +#define RK3588_PHP_CLKGATE_CON(x) ((x) * 0x4 + RK3588_PHP_CRU_BASE + 0x800) |
---|
| 427 | +#define RK3588_PHP_SOFTRST_CON(x) ((x) * 0x4 + RK3588_PHP_CRU_BASE + 0xa00) |
---|
| 428 | + |
---|
| 429 | +#define RK3588_PMU_PLL_CON(x) ((x) * 0x4 + RK3588_PHP_CRU_BASE) |
---|
| 430 | +#define RK3588_PMU_CLKSEL_CON(x) ((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x300) |
---|
| 431 | +#define RK3588_PMU_CLKGATE_CON(x) ((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x800) |
---|
| 432 | +#define RK3588_PMU_SOFTRST_CON(x) ((x) * 0x4 + RK3588_PMU_CRU_BASE + 0xa00) |
---|
| 433 | + |
---|
| 434 | +#define RK3588_B0_PLL_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE) |
---|
| 435 | +#define RK3588_BIGCORE0_CLKSEL_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0x300) |
---|
| 436 | +#define RK3588_BIGCORE0_CLKGATE_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0x800) |
---|
| 437 | +#define RK3588_BIGCORE0_SOFTRST_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0xa00) |
---|
| 438 | +#define RK3588_B1_PLL_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE) |
---|
| 439 | +#define RK3588_BIGCORE1_CLKSEL_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0x300) |
---|
| 440 | +#define RK3588_BIGCORE1_CLKGATE_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0x800) |
---|
| 441 | +#define RK3588_BIGCORE1_SOFTRST_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0xa00) |
---|
| 442 | +#define RK3588_LPLL_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE) |
---|
| 443 | +#define RK3588_DSU_CLKSEL_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0x300) |
---|
| 444 | +#define RK3588_DSU_CLKGATE_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0x800) |
---|
| 445 | +#define RK3588_DSU_SOFTRST_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0xa00) |
---|
| 446 | + |
---|
286 | 447 | enum rockchip_pll_type { |
---|
287 | 448 | pll_rk3036, |
---|
288 | 449 | pll_rk3066, |
---|
289 | 450 | pll_rk3328, |
---|
290 | 451 | pll_rk3399, |
---|
| 452 | + pll_rk3588, |
---|
| 453 | + pll_rk3588_core, |
---|
291 | 454 | }; |
---|
292 | 455 | |
---|
293 | 456 | #define RK3036_PLL_RATE(_rate, _refdiv, _fbdiv, _postdiv1, \ |
---|
.. | .. |
---|
320 | 483 | .nb = _nb, \ |
---|
321 | 484 | } |
---|
322 | 485 | |
---|
| 486 | +#define RK3588_PLL_RATE(_rate, _p, _m, _s, _k) \ |
---|
| 487 | +{ \ |
---|
| 488 | + .rate = _rate##U, \ |
---|
| 489 | + .p = _p, \ |
---|
| 490 | + .m = _m, \ |
---|
| 491 | + .s = _s, \ |
---|
| 492 | + .k = _k, \ |
---|
| 493 | +} |
---|
| 494 | + |
---|
323 | 495 | /** |
---|
324 | 496 | * struct rockchip_clk_provider - information about clock provider |
---|
325 | 497 | * @reg_base: virtual address for the register base. |
---|
326 | 498 | * @clk_data: holds clock related data like clk* and number of clocks. |
---|
327 | 499 | * @cru_node: device-node of the clock-provider |
---|
328 | 500 | * @grf: regmap of the general-register-files syscon |
---|
| 501 | + * @list_node: node in the global ctx list |
---|
329 | 502 | * @lock: maintains exclusion between callbacks for a given clock-provider. |
---|
330 | 503 | */ |
---|
331 | 504 | struct rockchip_clk_provider { |
---|
.. | .. |
---|
334 | 507 | struct device_node *cru_node; |
---|
335 | 508 | struct regmap *grf; |
---|
336 | 509 | struct regmap *pmugrf; |
---|
| 510 | + struct hlist_node list_node; |
---|
337 | 511 | spinlock_t lock; |
---|
338 | 512 | }; |
---|
339 | 513 | |
---|
.. | .. |
---|
355 | 529 | unsigned int postdiv2; |
---|
356 | 530 | unsigned int dsmpd; |
---|
357 | 531 | unsigned int frac; |
---|
| 532 | + }; |
---|
| 533 | + struct { |
---|
| 534 | + /* for RK3588 */ |
---|
| 535 | + unsigned int m; |
---|
| 536 | + unsigned int p; |
---|
| 537 | + unsigned int s; |
---|
| 538 | + unsigned int k; |
---|
358 | 539 | }; |
---|
359 | 540 | }; |
---|
360 | 541 | }; |
---|
.. | .. |
---|
399 | 580 | #define ROCKCHIP_PLL_SYNC_RATE BIT(0) |
---|
400 | 581 | /* normal mode only. now only for pll_rk3036, pll_rk3328 type */ |
---|
401 | 582 | #define ROCKCHIP_PLL_FIXED_MODE BIT(1) |
---|
| 583 | +#define ROCKCHIP_PLL_ALLOW_POWER_DOWN BIT(2) |
---|
402 | 584 | |
---|
403 | 585 | #define PLL(_type, _id, _name, _pnames, _flags, _con, _mode, _mshift, \ |
---|
404 | 586 | _lshift, _pflags, _rtable) \ |
---|
.. | .. |
---|
438 | 620 | u32 val; |
---|
439 | 621 | }; |
---|
440 | 622 | |
---|
441 | | -#define ROCKCHIP_CPUCLK_NUM_DIVIDERS 5 |
---|
| 623 | +#define ROCKCHIP_CPUCLK_NUM_DIVIDERS 6 |
---|
442 | 624 | #define ROCKCHIP_CPUCLK_MAX_CORES 4 |
---|
443 | 625 | struct rockchip_cpuclk_rate_table { |
---|
444 | 626 | unsigned long prate; |
---|
.. | .. |
---|
453 | 635 | * @div_core_shift[]: cores divider offset used to divide the pll value |
---|
454 | 636 | * @div_core_mask[]: cores divider mask |
---|
455 | 637 | * @num_cores: number of cpu cores |
---|
| 638 | + * @mux_core_reg: register offset of the cores select parent |
---|
456 | 639 | * @mux_core_alt: mux value to select alternate parent |
---|
457 | 640 | * @mux_core_main: mux value to select main parent of core |
---|
458 | 641 | * @mux_core_shift: offset of the core multiplexer |
---|
.. | .. |
---|
463 | 646 | u8 div_core_shift[ROCKCHIP_CPUCLK_MAX_CORES]; |
---|
464 | 647 | u32 div_core_mask[ROCKCHIP_CPUCLK_MAX_CORES]; |
---|
465 | 648 | int num_cores; |
---|
| 649 | + int mux_core_reg; |
---|
466 | 650 | u8 mux_core_alt; |
---|
467 | 651 | u8 mux_core_main; |
---|
468 | 652 | u8 mux_core_shift; |
---|
.. | .. |
---|
471 | 655 | }; |
---|
472 | 656 | |
---|
473 | 657 | struct clk *rockchip_clk_register_cpuclk(const char *name, |
---|
474 | | - const char *const *parent_names, u8 num_parents, |
---|
| 658 | + u8 num_parents, |
---|
| 659 | + struct clk *parent, struct clk *alt_parent, |
---|
475 | 660 | const struct rockchip_cpuclk_reg_data *reg_data, |
---|
476 | 661 | const struct rockchip_cpuclk_rate_table *rates, |
---|
477 | 662 | int nrates, void __iomem *reg_base, spinlock_t *lock); |
---|
| 663 | + |
---|
| 664 | +struct clk *rockchip_clk_register_cpuclk_v2(const char *name, |
---|
| 665 | + const char *const *parent_names, |
---|
| 666 | + u8 num_parents, void __iomem *base, |
---|
| 667 | + int muxdiv_offset, u8 mux_shift, |
---|
| 668 | + u8 mux_width, u8 mux_flags, |
---|
| 669 | + int div_offset, u8 div_shift, |
---|
| 670 | + u8 div_width, u8 div_flags, |
---|
| 671 | + unsigned long flags, spinlock_t *lock, |
---|
| 672 | + const struct rockchip_cpuclk_rate_table *rates, |
---|
| 673 | + int nrates); |
---|
478 | 674 | |
---|
479 | 675 | struct clk *rockchip_clk_register_mmc(const char *name, |
---|
480 | 676 | const char *const *parent_names, u8 num_parents, |
---|
.. | .. |
---|
483 | 679 | /* |
---|
484 | 680 | * DDRCLK flags, including method of setting the rate |
---|
485 | 681 | * ROCKCHIP_DDRCLK_SIP: use SIP call to bl31 to change ddrclk rate. |
---|
486 | | - * ROCKCHIP_DDRCLK_SCPI: use SCPI APIs to let mcu change ddrclk rate. |
---|
487 | 682 | */ |
---|
488 | 683 | #define ROCKCHIP_DDRCLK_SIP BIT(0) |
---|
489 | | -#define ROCKCHIP_DDRCLK_SCPI 0x02 |
---|
490 | 684 | #define ROCKCHIP_DDRCLK_SIP_V2 0x03 |
---|
| 685 | + |
---|
| 686 | +#ifdef CONFIG_ROCKCHIP_DDRCLK |
---|
| 687 | +void rockchip_set_ddrclk_params(void __iomem *params); |
---|
| 688 | +void rockchip_set_ddrclk_dmcfreq_wait_complete(int (*func)(void)); |
---|
491 | 689 | |
---|
492 | 690 | struct clk *rockchip_clk_register_ddrclk(const char *name, int flags, |
---|
493 | 691 | const char *const *parent_names, |
---|
.. | .. |
---|
495 | 693 | int mux_shift, int mux_width, |
---|
496 | 694 | int div_shift, int div_width, |
---|
497 | 695 | int ddr_flags, void __iomem *reg_base); |
---|
| 696 | +#else |
---|
| 697 | +static inline void rockchip_set_ddrclk_params(void __iomem *params) {} |
---|
| 698 | +static inline void rockchip_set_ddrclk_dmcfreq_wait_complete(int (*func)(void)) {} |
---|
| 699 | +static inline |
---|
| 700 | +struct clk *rockchip_clk_register_ddrclk(const char *name, int flags, |
---|
| 701 | + const char *const *parent_names, |
---|
| 702 | + u8 num_parents, int mux_offset, |
---|
| 703 | + int mux_shift, int mux_width, |
---|
| 704 | + int div_shift, int div_width, |
---|
| 705 | + int ddr_flags, void __iomem *reg_base) |
---|
| 706 | +{ |
---|
| 707 | + return NULL; |
---|
| 708 | +} |
---|
| 709 | +#endif |
---|
498 | 710 | |
---|
499 | 711 | #define ROCKCHIP_INVERTER_HIWORD_MASK BIT(0) |
---|
500 | 712 | |
---|
.. | .. |
---|
512 | 724 | |
---|
513 | 725 | enum rockchip_clk_branch_type { |
---|
514 | 726 | branch_composite, |
---|
515 | | - branch_composite_brother, |
---|
516 | 727 | branch_mux, |
---|
517 | 728 | branch_muxgrf, |
---|
518 | 729 | branch_muxpmugrf, |
---|
519 | 730 | branch_divider, |
---|
520 | 731 | branch_fraction_divider, |
---|
521 | 732 | branch_gate, |
---|
| 733 | + branch_gate_no_set_rate, |
---|
522 | 734 | branch_mmc, |
---|
523 | 735 | branch_inverter, |
---|
524 | 736 | branch_factor, |
---|
525 | 737 | branch_ddrclk, |
---|
526 | 738 | branch_half_divider, |
---|
527 | | - branch_dclk_divider, |
---|
528 | 739 | }; |
---|
529 | 740 | |
---|
530 | 741 | struct rockchip_clk_branch { |
---|
.. | .. |
---|
548 | 759 | u8 gate_shift; |
---|
549 | 760 | u8 gate_flags; |
---|
550 | 761 | struct rockchip_clk_branch *child; |
---|
551 | | - unsigned long max_prate; |
---|
552 | 762 | }; |
---|
553 | 763 | |
---|
554 | 764 | #define COMPOSITE(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\ |
---|
.. | .. |
---|
570 | 780 | .gate_offset = go, \ |
---|
571 | 781 | .gate_shift = gs, \ |
---|
572 | 782 | .gate_flags = gf, \ |
---|
573 | | - } |
---|
574 | | - |
---|
575 | | -#define COMPOSITE_BROTHER(_id, cname, pnames, f, mo, ms, mw, mf,\ |
---|
576 | | - ds, dw, df, go, gs, gf, bro) \ |
---|
577 | | - { \ |
---|
578 | | - .id = _id, \ |
---|
579 | | - .branch_type = branch_composite_brother, \ |
---|
580 | | - .name = cname, \ |
---|
581 | | - .parent_names = pnames, \ |
---|
582 | | - .num_parents = ARRAY_SIZE(pnames), \ |
---|
583 | | - .flags = f, \ |
---|
584 | | - .muxdiv_offset = mo, \ |
---|
585 | | - .mux_shift = ms, \ |
---|
586 | | - .mux_width = mw, \ |
---|
587 | | - .mux_flags = mf, \ |
---|
588 | | - .div_shift = ds, \ |
---|
589 | | - .div_width = dw, \ |
---|
590 | | - .div_flags = df, \ |
---|
591 | | - .gate_offset = go, \ |
---|
592 | | - .gate_shift = gs, \ |
---|
593 | | - .gate_flags = gf, \ |
---|
594 | | - .child = bro, \ |
---|
595 | 783 | } |
---|
596 | 784 | |
---|
597 | 785 | #define COMPOSITE_MUXTBL(_id, cname, pnames, f, mo, ms, mw, mf, \ |
---|
.. | .. |
---|
712 | 900 | .gate_offset = -1, \ |
---|
713 | 901 | } |
---|
714 | 902 | |
---|
715 | | -#define COMPOSITE_BROTHER_NOGATE(_id, cname, pnames, f, mo, ms, \ |
---|
716 | | - mw, mf, ds, dw, df, bro) \ |
---|
717 | | - { \ |
---|
718 | | - .id = _id, \ |
---|
719 | | - .branch_type = branch_composite_brother, \ |
---|
720 | | - .name = cname, \ |
---|
721 | | - .parent_names = pnames, \ |
---|
722 | | - .num_parents = ARRAY_SIZE(pnames), \ |
---|
723 | | - .flags = f, \ |
---|
724 | | - .muxdiv_offset = mo, \ |
---|
725 | | - .mux_shift = ms, \ |
---|
726 | | - .mux_width = mw, \ |
---|
727 | | - .mux_flags = mf, \ |
---|
728 | | - .div_shift = ds, \ |
---|
729 | | - .div_width = dw, \ |
---|
730 | | - .div_flags = df, \ |
---|
731 | | - .gate_offset = -1, \ |
---|
732 | | - .child = bro, \ |
---|
733 | | - } |
---|
734 | | - |
---|
735 | 903 | #define COMPOSITE_NOGATE_DIVTBL(_id, cname, pnames, f, mo, ms, \ |
---|
736 | 904 | mw, mf, ds, dw, df, dt) \ |
---|
737 | 905 | { \ |
---|
.. | .. |
---|
752 | 920 | .gate_offset = -1, \ |
---|
753 | 921 | } |
---|
754 | 922 | |
---|
755 | | -#define COMPOSITE_FRAC(_id, cname, pname, f, mo, df, go, gs, gf, prate)\ |
---|
| 923 | +#define COMPOSITE_FRAC(_id, cname, pname, f, mo, df, go, gs, gf)\ |
---|
756 | 924 | { \ |
---|
757 | 925 | .id = _id, \ |
---|
758 | 926 | .branch_type = branch_fraction_divider, \ |
---|
.. | .. |
---|
767 | 935 | .gate_offset = go, \ |
---|
768 | 936 | .gate_shift = gs, \ |
---|
769 | 937 | .gate_flags = gf, \ |
---|
770 | | - .max_prate = prate, \ |
---|
771 | 938 | } |
---|
772 | 939 | |
---|
773 | | -#define COMPOSITE_FRACMUX(_id, cname, pname, f, mo, df, go, gs, gf, ch, prate) \ |
---|
| 940 | +#define COMPOSITE_FRACMUX(_id, cname, pname, f, mo, df, go, gs, gf, ch) \ |
---|
774 | 941 | { \ |
---|
775 | 942 | .id = _id, \ |
---|
776 | 943 | .branch_type = branch_fraction_divider, \ |
---|
.. | .. |
---|
786 | 953 | .gate_shift = gs, \ |
---|
787 | 954 | .gate_flags = gf, \ |
---|
788 | 955 | .child = ch, \ |
---|
789 | | - .max_prate = prate, \ |
---|
790 | 956 | } |
---|
791 | 957 | |
---|
792 | | -#define COMPOSITE_FRACMUX_NOGATE(_id, cname, pname, f, mo, df, ch, prate) \ |
---|
| 958 | +#define COMPOSITE_FRACMUX_NOGATE(_id, cname, pname, f, mo, df, ch) \ |
---|
793 | 959 | { \ |
---|
794 | 960 | .id = _id, \ |
---|
795 | 961 | .branch_type = branch_fraction_divider, \ |
---|
.. | .. |
---|
803 | 969 | .div_flags = df, \ |
---|
804 | 970 | .gate_offset = -1, \ |
---|
805 | 971 | .child = ch, \ |
---|
806 | | - .max_prate = prate, \ |
---|
807 | 972 | } |
---|
808 | 973 | |
---|
809 | 974 | #define COMPOSITE_DDRCLK(_id, cname, pnames, f, mo, ms, mw, \ |
---|
.. | .. |
---|
919 | 1084 | { \ |
---|
920 | 1085 | .id = _id, \ |
---|
921 | 1086 | .branch_type = branch_gate, \ |
---|
| 1087 | + .name = cname, \ |
---|
| 1088 | + .parent_names = (const char *[]){ pname }, \ |
---|
| 1089 | + .num_parents = 1, \ |
---|
| 1090 | + .flags = f, \ |
---|
| 1091 | + .gate_offset = o, \ |
---|
| 1092 | + .gate_shift = b, \ |
---|
| 1093 | + .gate_flags = gf, \ |
---|
| 1094 | + } |
---|
| 1095 | + |
---|
| 1096 | +#define GATE_NO_SET_RATE(_id, cname, pname, f, o, b, gf) \ |
---|
| 1097 | + { \ |
---|
| 1098 | + .id = _id, \ |
---|
| 1099 | + .branch_type = branch_gate_no_set_rate, \ |
---|
922 | 1100 | .name = cname, \ |
---|
923 | 1101 | .parent_names = (const char *[]){ pname }, \ |
---|
924 | 1102 | .num_parents = 1, \ |
---|
.. | .. |
---|
1073 | 1251 | .gate_offset = -1, \ |
---|
1074 | 1252 | } |
---|
1075 | 1253 | |
---|
1076 | | -#define COMPOSITE_DCLK(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\ |
---|
1077 | | - df, go, gs, gf, prate) \ |
---|
1078 | | - { \ |
---|
1079 | | - .id = _id, \ |
---|
1080 | | - .branch_type = branch_dclk_divider, \ |
---|
1081 | | - .name = cname, \ |
---|
1082 | | - .parent_names = pnames, \ |
---|
1083 | | - .num_parents = ARRAY_SIZE(pnames), \ |
---|
1084 | | - .flags = f, \ |
---|
1085 | | - .muxdiv_offset = mo, \ |
---|
1086 | | - .mux_shift = ms, \ |
---|
1087 | | - .mux_width = mw, \ |
---|
1088 | | - .mux_flags = mf, \ |
---|
1089 | | - .div_shift = ds, \ |
---|
1090 | | - .div_width = dw, \ |
---|
1091 | | - .div_flags = df, \ |
---|
1092 | | - .gate_offset = go, \ |
---|
1093 | | - .gate_shift = gs, \ |
---|
1094 | | - .gate_flags = gf, \ |
---|
1095 | | - .max_prate = prate, \ |
---|
1096 | | - } |
---|
1097 | | - |
---|
1098 | 1254 | /* SGRF clocks are only accessible from secure mode, so not controllable */ |
---|
1099 | 1255 | #define SGRF_GATE(_id, cname, pname) \ |
---|
1100 | 1256 | FACTOR(_id, cname, pname, 0, 1, 1) |
---|
.. | .. |
---|
1112 | 1268 | struct rockchip_pll_clock *pll_list, |
---|
1113 | 1269 | unsigned int nr_pll, int grf_lock_offset); |
---|
1114 | 1270 | void rockchip_clk_register_armclk(struct rockchip_clk_provider *ctx, |
---|
1115 | | - unsigned int lookup_id, const char *name, |
---|
1116 | | - const char *const *parent_names, u8 num_parents, |
---|
1117 | | - const struct rockchip_cpuclk_reg_data *reg_data, |
---|
1118 | | - const struct rockchip_cpuclk_rate_table *rates, |
---|
1119 | | - int nrates); |
---|
1120 | | -void rockchip_clk_protect_critical(const char *const clocks[], int nclocks); |
---|
| 1271 | + unsigned int lookup_id, |
---|
| 1272 | + const char *name, |
---|
| 1273 | + u8 num_parents, |
---|
| 1274 | + struct clk *parent, struct clk *alt_parent, |
---|
| 1275 | + const struct rockchip_cpuclk_reg_data *reg_data, |
---|
| 1276 | + const struct rockchip_cpuclk_rate_table *rates, |
---|
| 1277 | + int nrates); |
---|
| 1278 | +void rockchip_clk_register_armclk_v2(struct rockchip_clk_provider *ctx, |
---|
| 1279 | + struct rockchip_clk_branch *list, |
---|
| 1280 | + const struct rockchip_cpuclk_rate_table *rates, |
---|
| 1281 | + int nrates); |
---|
1121 | 1282 | int rockchip_pll_clk_rate_to_scale(struct clk *clk, unsigned long rate); |
---|
1122 | 1283 | int rockchip_pll_clk_scale_to_rate(struct clk *clk, unsigned int scale); |
---|
1123 | 1284 | int rockchip_pll_clk_adaptive_scaling(struct clk *clk, int sel); |
---|
.. | .. |
---|
1137 | 1298 | u8 gate_flags, unsigned long flags, |
---|
1138 | 1299 | spinlock_t *lock); |
---|
1139 | 1300 | |
---|
1140 | | -struct clk *rockchip_clk_register_dclk_branch(const char *name, |
---|
1141 | | - const char *const *parent_names, |
---|
1142 | | - u8 num_parents, |
---|
1143 | | - void __iomem *base, |
---|
1144 | | - int muxdiv_offset, u8 mux_shift, |
---|
1145 | | - u8 mux_width, u8 mux_flags, |
---|
1146 | | - int div_offset, u8 div_shift, |
---|
1147 | | - u8 div_width, u8 div_flags, |
---|
1148 | | - struct clk_div_table *div_table, |
---|
1149 | | - int gate_offset, |
---|
1150 | | - u8 gate_shift, u8 gate_flags, |
---|
1151 | | - unsigned long flags, |
---|
1152 | | - unsigned long max_prate, |
---|
1153 | | - spinlock_t *lock); |
---|
1154 | | - |
---|
1155 | 1301 | #ifdef CONFIG_RESET_CONTROLLER |
---|
1156 | 1302 | void rockchip_register_softrst(struct device_node *np, |
---|
1157 | 1303 | unsigned int num_regs, |
---|
.. | .. |
---|
1165 | 1311 | #endif |
---|
1166 | 1312 | extern void (*rk_dump_cru)(void); |
---|
1167 | 1313 | |
---|
| 1314 | +#if IS_MODULE(CONFIG_COMMON_CLK_ROCKCHIP) |
---|
| 1315 | +int rockchip_clk_protect(struct rockchip_clk_provider *ctx, |
---|
| 1316 | + unsigned int *clocks, unsigned int nclocks); |
---|
| 1317 | +void rockchip_clk_unprotect(void); |
---|
| 1318 | +void rockchip_clk_disable_unused(void); |
---|
| 1319 | +#else |
---|
| 1320 | +static inline int rockchip_clk_protect(struct rockchip_clk_provider *ctx, |
---|
| 1321 | + unsigned int *clocks, |
---|
| 1322 | + unsigned int nclocks) |
---|
| 1323 | +{ |
---|
| 1324 | + return -EOPNOTSUPP; |
---|
| 1325 | +} |
---|
| 1326 | + |
---|
| 1327 | +static inline void rockchip_clk_unprotect(void) |
---|
| 1328 | +{ |
---|
| 1329 | +} |
---|
| 1330 | + |
---|
| 1331 | +static inline void rockchip_clk_disable_unused(void) |
---|
| 1332 | +{ |
---|
| 1333 | +} |
---|
| 1334 | +#endif |
---|
1168 | 1335 | #endif |
---|