.. | .. |
---|
| 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) |
---|
.. | .. |
---|
283 | 332 | #define RK3528_GLB_SRST_FST 0xc08 |
---|
284 | 333 | #define RK3528_GLB_SRST_SND 0xc0c |
---|
285 | 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 | + |
---|
286 | 374 | #define RK3568_PLL_CON(x) RK2928_PLL_CON(x) |
---|
287 | 375 | #define RK3568_MODE_CON0 0xc0 |
---|
288 | 376 | #define RK3568_MISC_CON0 0xc4 |
---|
.. | .. |
---|
311 | 399 | #define RK3568_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x180) |
---|
312 | 400 | #define RK3568_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x200) |
---|
313 | 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 | + |
---|
314 | 447 | enum rockchip_pll_type { |
---|
315 | 448 | pll_rk3036, |
---|
316 | 449 | pll_rk3066, |
---|
317 | 450 | pll_rk3328, |
---|
318 | 451 | pll_rk3399, |
---|
| 452 | + pll_rk3588, |
---|
| 453 | + pll_rk3588_core, |
---|
319 | 454 | }; |
---|
320 | 455 | |
---|
321 | 456 | #define RK3036_PLL_RATE(_rate, _refdiv, _fbdiv, _postdiv1, \ |
---|
.. | .. |
---|
348 | 483 | .nb = _nb, \ |
---|
349 | 484 | } |
---|
350 | 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 | + |
---|
351 | 495 | /** |
---|
352 | 496 | * struct rockchip_clk_provider - information about clock provider |
---|
353 | 497 | * @reg_base: virtual address for the register base. |
---|
354 | 498 | * @clk_data: holds clock related data like clk* and number of clocks. |
---|
355 | 499 | * @cru_node: device-node of the clock-provider |
---|
356 | 500 | * @grf: regmap of the general-register-files syscon |
---|
| 501 | + * @list_node: node in the global ctx list |
---|
357 | 502 | * @lock: maintains exclusion between callbacks for a given clock-provider. |
---|
358 | 503 | */ |
---|
359 | 504 | struct rockchip_clk_provider { |
---|
.. | .. |
---|
362 | 507 | struct device_node *cru_node; |
---|
363 | 508 | struct regmap *grf; |
---|
364 | 509 | struct regmap *pmugrf; |
---|
| 510 | + struct hlist_node list_node; |
---|
365 | 511 | spinlock_t lock; |
---|
366 | 512 | }; |
---|
367 | 513 | |
---|
.. | .. |
---|
383 | 529 | unsigned int postdiv2; |
---|
384 | 530 | unsigned int dsmpd; |
---|
385 | 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; |
---|
386 | 539 | }; |
---|
387 | 540 | }; |
---|
388 | 541 | }; |
---|
.. | .. |
---|
427 | 580 | #define ROCKCHIP_PLL_SYNC_RATE BIT(0) |
---|
428 | 581 | /* normal mode only. now only for pll_rk3036, pll_rk3328 type */ |
---|
429 | 582 | #define ROCKCHIP_PLL_FIXED_MODE BIT(1) |
---|
| 583 | +#define ROCKCHIP_PLL_ALLOW_POWER_DOWN BIT(2) |
---|
430 | 584 | |
---|
431 | 585 | #define PLL(_type, _id, _name, _pnames, _flags, _con, _mode, _mshift, \ |
---|
432 | 586 | _lshift, _pflags, _rtable) \ |
---|
.. | .. |
---|
466 | 620 | u32 val; |
---|
467 | 621 | }; |
---|
468 | 622 | |
---|
469 | | -#define ROCKCHIP_CPUCLK_NUM_DIVIDERS 5 |
---|
| 623 | +#define ROCKCHIP_CPUCLK_NUM_DIVIDERS 6 |
---|
470 | 624 | #define ROCKCHIP_CPUCLK_MAX_CORES 4 |
---|
471 | 625 | struct rockchip_cpuclk_rate_table { |
---|
472 | 626 | unsigned long prate; |
---|
.. | .. |
---|
481 | 635 | * @div_core_shift[]: cores divider offset used to divide the pll value |
---|
482 | 636 | * @div_core_mask[]: cores divider mask |
---|
483 | 637 | * @num_cores: number of cpu cores |
---|
| 638 | + * @mux_core_reg: register offset of the cores select parent |
---|
484 | 639 | * @mux_core_alt: mux value to select alternate parent |
---|
485 | 640 | * @mux_core_main: mux value to select main parent of core |
---|
486 | 641 | * @mux_core_shift: offset of the core multiplexer |
---|
.. | .. |
---|
491 | 646 | u8 div_core_shift[ROCKCHIP_CPUCLK_MAX_CORES]; |
---|
492 | 647 | u32 div_core_mask[ROCKCHIP_CPUCLK_MAX_CORES]; |
---|
493 | 648 | int num_cores; |
---|
| 649 | + int mux_core_reg; |
---|
494 | 650 | u8 mux_core_alt; |
---|
495 | 651 | u8 mux_core_main; |
---|
496 | 652 | u8 mux_core_shift; |
---|
.. | .. |
---|
499 | 655 | }; |
---|
500 | 656 | |
---|
501 | 657 | struct clk *rockchip_clk_register_cpuclk(const char *name, |
---|
502 | | - const char *const *parent_names, u8 num_parents, |
---|
| 658 | + u8 num_parents, |
---|
| 659 | + struct clk *parent, struct clk *alt_parent, |
---|
503 | 660 | const struct rockchip_cpuclk_reg_data *reg_data, |
---|
504 | 661 | const struct rockchip_cpuclk_rate_table *rates, |
---|
505 | 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); |
---|
506 | 674 | |
---|
507 | 675 | struct clk *rockchip_clk_register_mmc(const char *name, |
---|
508 | 676 | const char *const *parent_names, u8 num_parents, |
---|
.. | .. |
---|
511 | 679 | /* |
---|
512 | 680 | * DDRCLK flags, including method of setting the rate |
---|
513 | 681 | * ROCKCHIP_DDRCLK_SIP: use SIP call to bl31 to change ddrclk rate. |
---|
514 | | - * ROCKCHIP_DDRCLK_SCPI: use SCPI APIs to let mcu change ddrclk rate. |
---|
515 | 682 | */ |
---|
516 | 683 | #define ROCKCHIP_DDRCLK_SIP BIT(0) |
---|
517 | | -#define ROCKCHIP_DDRCLK_SCPI 0x02 |
---|
518 | 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)); |
---|
519 | 689 | |
---|
520 | 690 | struct clk *rockchip_clk_register_ddrclk(const char *name, int flags, |
---|
521 | 691 | const char *const *parent_names, |
---|
.. | .. |
---|
523 | 693 | int mux_shift, int mux_width, |
---|
524 | 694 | int div_shift, int div_width, |
---|
525 | 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 |
---|
526 | 710 | |
---|
527 | 711 | #define ROCKCHIP_INVERTER_HIWORD_MASK BIT(0) |
---|
528 | 712 | |
---|
.. | .. |
---|
540 | 724 | |
---|
541 | 725 | enum rockchip_clk_branch_type { |
---|
542 | 726 | branch_composite, |
---|
543 | | - branch_composite_brother, |
---|
544 | 727 | branch_mux, |
---|
545 | 728 | branch_muxgrf, |
---|
546 | 729 | branch_muxpmugrf, |
---|
547 | 730 | branch_divider, |
---|
548 | 731 | branch_fraction_divider, |
---|
549 | 732 | branch_gate, |
---|
| 733 | + branch_gate_no_set_rate, |
---|
550 | 734 | branch_mmc, |
---|
551 | 735 | branch_inverter, |
---|
552 | 736 | branch_factor, |
---|
553 | 737 | branch_ddrclk, |
---|
554 | 738 | branch_half_divider, |
---|
555 | | - branch_dclk_divider, |
---|
556 | 739 | }; |
---|
557 | 740 | |
---|
558 | 741 | struct rockchip_clk_branch { |
---|
.. | .. |
---|
576 | 759 | u8 gate_shift; |
---|
577 | 760 | u8 gate_flags; |
---|
578 | 761 | struct rockchip_clk_branch *child; |
---|
579 | | - unsigned long max_prate; |
---|
580 | 762 | }; |
---|
581 | 763 | |
---|
582 | 764 | #define COMPOSITE(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\ |
---|
.. | .. |
---|
598 | 780 | .gate_offset = go, \ |
---|
599 | 781 | .gate_shift = gs, \ |
---|
600 | 782 | .gate_flags = gf, \ |
---|
601 | | - } |
---|
602 | | - |
---|
603 | | -#define COMPOSITE_BROTHER(_id, cname, pnames, f, mo, ms, mw, mf,\ |
---|
604 | | - ds, dw, df, go, gs, gf, bro) \ |
---|
605 | | - { \ |
---|
606 | | - .id = _id, \ |
---|
607 | | - .branch_type = branch_composite_brother, \ |
---|
608 | | - .name = cname, \ |
---|
609 | | - .parent_names = pnames, \ |
---|
610 | | - .num_parents = ARRAY_SIZE(pnames), \ |
---|
611 | | - .flags = f, \ |
---|
612 | | - .muxdiv_offset = mo, \ |
---|
613 | | - .mux_shift = ms, \ |
---|
614 | | - .mux_width = mw, \ |
---|
615 | | - .mux_flags = mf, \ |
---|
616 | | - .div_shift = ds, \ |
---|
617 | | - .div_width = dw, \ |
---|
618 | | - .div_flags = df, \ |
---|
619 | | - .gate_offset = go, \ |
---|
620 | | - .gate_shift = gs, \ |
---|
621 | | - .gate_flags = gf, \ |
---|
622 | | - .child = bro, \ |
---|
623 | 783 | } |
---|
624 | 784 | |
---|
625 | 785 | #define COMPOSITE_MUXTBL(_id, cname, pnames, f, mo, ms, mw, mf, \ |
---|
.. | .. |
---|
740 | 900 | .gate_offset = -1, \ |
---|
741 | 901 | } |
---|
742 | 902 | |
---|
743 | | -#define COMPOSITE_BROTHER_NOGATE(_id, cname, pnames, f, mo, ms, \ |
---|
744 | | - mw, mf, ds, dw, df, bro) \ |
---|
745 | | - { \ |
---|
746 | | - .id = _id, \ |
---|
747 | | - .branch_type = branch_composite_brother, \ |
---|
748 | | - .name = cname, \ |
---|
749 | | - .parent_names = pnames, \ |
---|
750 | | - .num_parents = ARRAY_SIZE(pnames), \ |
---|
751 | | - .flags = f, \ |
---|
752 | | - .muxdiv_offset = mo, \ |
---|
753 | | - .mux_shift = ms, \ |
---|
754 | | - .mux_width = mw, \ |
---|
755 | | - .mux_flags = mf, \ |
---|
756 | | - .div_shift = ds, \ |
---|
757 | | - .div_width = dw, \ |
---|
758 | | - .div_flags = df, \ |
---|
759 | | - .gate_offset = -1, \ |
---|
760 | | - .child = bro, \ |
---|
761 | | - } |
---|
762 | | - |
---|
763 | 903 | #define COMPOSITE_NOGATE_DIVTBL(_id, cname, pnames, f, mo, ms, \ |
---|
764 | 904 | mw, mf, ds, dw, df, dt) \ |
---|
765 | 905 | { \ |
---|
.. | .. |
---|
780 | 920 | .gate_offset = -1, \ |
---|
781 | 921 | } |
---|
782 | 922 | |
---|
783 | | -#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)\ |
---|
784 | 924 | { \ |
---|
785 | 925 | .id = _id, \ |
---|
786 | 926 | .branch_type = branch_fraction_divider, \ |
---|
.. | .. |
---|
795 | 935 | .gate_offset = go, \ |
---|
796 | 936 | .gate_shift = gs, \ |
---|
797 | 937 | .gate_flags = gf, \ |
---|
798 | | - .max_prate = prate, \ |
---|
799 | 938 | } |
---|
800 | 939 | |
---|
801 | | -#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) \ |
---|
802 | 941 | { \ |
---|
803 | 942 | .id = _id, \ |
---|
804 | 943 | .branch_type = branch_fraction_divider, \ |
---|
.. | .. |
---|
814 | 953 | .gate_shift = gs, \ |
---|
815 | 954 | .gate_flags = gf, \ |
---|
816 | 955 | .child = ch, \ |
---|
817 | | - .max_prate = prate, \ |
---|
818 | 956 | } |
---|
819 | 957 | |
---|
820 | | -#define COMPOSITE_FRACMUX_NOGATE(_id, cname, pname, f, mo, df, ch, prate) \ |
---|
| 958 | +#define COMPOSITE_FRACMUX_NOGATE(_id, cname, pname, f, mo, df, ch) \ |
---|
821 | 959 | { \ |
---|
822 | 960 | .id = _id, \ |
---|
823 | 961 | .branch_type = branch_fraction_divider, \ |
---|
.. | .. |
---|
831 | 969 | .div_flags = df, \ |
---|
832 | 970 | .gate_offset = -1, \ |
---|
833 | 971 | .child = ch, \ |
---|
834 | | - .max_prate = prate, \ |
---|
835 | 972 | } |
---|
836 | 973 | |
---|
837 | 974 | #define COMPOSITE_DDRCLK(_id, cname, pnames, f, mo, ms, mw, \ |
---|
.. | .. |
---|
947 | 1084 | { \ |
---|
948 | 1085 | .id = _id, \ |
---|
949 | 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, \ |
---|
950 | 1100 | .name = cname, \ |
---|
951 | 1101 | .parent_names = (const char *[]){ pname }, \ |
---|
952 | 1102 | .num_parents = 1, \ |
---|
.. | .. |
---|
1101 | 1251 | .gate_offset = -1, \ |
---|
1102 | 1252 | } |
---|
1103 | 1253 | |
---|
1104 | | -#define COMPOSITE_DCLK(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\ |
---|
1105 | | - df, go, gs, gf, prate) \ |
---|
1106 | | - { \ |
---|
1107 | | - .id = _id, \ |
---|
1108 | | - .branch_type = branch_dclk_divider, \ |
---|
1109 | | - .name = cname, \ |
---|
1110 | | - .parent_names = pnames, \ |
---|
1111 | | - .num_parents = ARRAY_SIZE(pnames), \ |
---|
1112 | | - .flags = f, \ |
---|
1113 | | - .muxdiv_offset = mo, \ |
---|
1114 | | - .mux_shift = ms, \ |
---|
1115 | | - .mux_width = mw, \ |
---|
1116 | | - .mux_flags = mf, \ |
---|
1117 | | - .div_shift = ds, \ |
---|
1118 | | - .div_width = dw, \ |
---|
1119 | | - .div_flags = df, \ |
---|
1120 | | - .gate_offset = go, \ |
---|
1121 | | - .gate_shift = gs, \ |
---|
1122 | | - .gate_flags = gf, \ |
---|
1123 | | - .max_prate = prate, \ |
---|
1124 | | - } |
---|
1125 | | - |
---|
1126 | 1254 | /* SGRF clocks are only accessible from secure mode, so not controllable */ |
---|
1127 | 1255 | #define SGRF_GATE(_id, cname, pname) \ |
---|
1128 | 1256 | FACTOR(_id, cname, pname, 0, 1, 1) |
---|
.. | .. |
---|
1140 | 1268 | struct rockchip_pll_clock *pll_list, |
---|
1141 | 1269 | unsigned int nr_pll, int grf_lock_offset); |
---|
1142 | 1270 | void rockchip_clk_register_armclk(struct rockchip_clk_provider *ctx, |
---|
1143 | | - unsigned int lookup_id, const char *name, |
---|
1144 | | - const char *const *parent_names, u8 num_parents, |
---|
1145 | | - const struct rockchip_cpuclk_reg_data *reg_data, |
---|
1146 | | - const struct rockchip_cpuclk_rate_table *rates, |
---|
1147 | | - int nrates); |
---|
1148 | | -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); |
---|
1149 | 1282 | int rockchip_pll_clk_rate_to_scale(struct clk *clk, unsigned long rate); |
---|
1150 | 1283 | int rockchip_pll_clk_scale_to_rate(struct clk *clk, unsigned int scale); |
---|
1151 | 1284 | int rockchip_pll_clk_adaptive_scaling(struct clk *clk, int sel); |
---|
.. | .. |
---|
1165 | 1298 | u8 gate_flags, unsigned long flags, |
---|
1166 | 1299 | spinlock_t *lock); |
---|
1167 | 1300 | |
---|
1168 | | -struct clk *rockchip_clk_register_dclk_branch(const char *name, |
---|
1169 | | - const char *const *parent_names, |
---|
1170 | | - u8 num_parents, |
---|
1171 | | - void __iomem *base, |
---|
1172 | | - int muxdiv_offset, u8 mux_shift, |
---|
1173 | | - u8 mux_width, u8 mux_flags, |
---|
1174 | | - int div_offset, u8 div_shift, |
---|
1175 | | - u8 div_width, u8 div_flags, |
---|
1176 | | - struct clk_div_table *div_table, |
---|
1177 | | - int gate_offset, |
---|
1178 | | - u8 gate_shift, u8 gate_flags, |
---|
1179 | | - unsigned long flags, |
---|
1180 | | - unsigned long max_prate, |
---|
1181 | | - spinlock_t *lock); |
---|
1182 | | - |
---|
1183 | 1301 | #ifdef CONFIG_RESET_CONTROLLER |
---|
1184 | 1302 | void rockchip_register_softrst(struct device_node *np, |
---|
1185 | 1303 | unsigned int num_regs, |
---|
.. | .. |
---|
1193 | 1311 | #endif |
---|
1194 | 1312 | extern void (*rk_dump_cru)(void); |
---|
1195 | 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 |
---|
1196 | 1335 | #endif |
---|