hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/clk/rockchip/clk.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Copyright (c) 2014 MundoReader S.L.
34 * Author: Heiko Stuebner <heiko@sntech.de>
....@@ -11,16 +12,6 @@
1112 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
1213 * Copyright (c) 2013 Linaro Ltd.
1314 * 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.
2415 */
2516
2617 #ifndef CLK_ROCKCHIP_CLK_H
....@@ -86,6 +77,64 @@
8677 #define PX30_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x40)
8778 #define PX30_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x80)
8879 #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)
89138
90139 #define RV1108_PLL_CON(x) ((x) * 0x4)
91140 #define RV1108_CLKSEL_CON(x) ((x) * 0x4 + 0x60)
....@@ -283,6 +332,45 @@
283332 #define RK3528_GLB_SRST_FST 0xc08
284333 #define RK3528_GLB_SRST_SND 0xc0c
285334
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
+
286374 #define RK3568_PLL_CON(x) RK2928_PLL_CON(x)
287375 #define RK3568_MODE_CON0 0xc0
288376 #define RK3568_MISC_CON0 0xc4
....@@ -311,11 +399,58 @@
311399 #define RK3568_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x180)
312400 #define RK3568_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x200)
313401
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
+
314447 enum rockchip_pll_type {
315448 pll_rk3036,
316449 pll_rk3066,
317450 pll_rk3328,
318451 pll_rk3399,
452
+ pll_rk3588,
453
+ pll_rk3588_core,
319454 };
320455
321456 #define RK3036_PLL_RATE(_rate, _refdiv, _fbdiv, _postdiv1, \
....@@ -348,12 +483,22 @@
348483 .nb = _nb, \
349484 }
350485
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
+
351495 /**
352496 * struct rockchip_clk_provider - information about clock provider
353497 * @reg_base: virtual address for the register base.
354498 * @clk_data: holds clock related data like clk* and number of clocks.
355499 * @cru_node: device-node of the clock-provider
356500 * @grf: regmap of the general-register-files syscon
501
+ * @list_node: node in the global ctx list
357502 * @lock: maintains exclusion between callbacks for a given clock-provider.
358503 */
359504 struct rockchip_clk_provider {
....@@ -362,6 +507,7 @@
362507 struct device_node *cru_node;
363508 struct regmap *grf;
364509 struct regmap *pmugrf;
510
+ struct hlist_node list_node;
365511 spinlock_t lock;
366512 };
367513
....@@ -383,6 +529,13 @@
383529 unsigned int postdiv2;
384530 unsigned int dsmpd;
385531 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;
386539 };
387540 };
388541 };
....@@ -427,6 +580,7 @@
427580 #define ROCKCHIP_PLL_SYNC_RATE BIT(0)
428581 /* normal mode only. now only for pll_rk3036, pll_rk3328 type */
429582 #define ROCKCHIP_PLL_FIXED_MODE BIT(1)
583
+#define ROCKCHIP_PLL_ALLOW_POWER_DOWN BIT(2)
430584
431585 #define PLL(_type, _id, _name, _pnames, _flags, _con, _mode, _mshift, \
432586 _lshift, _pflags, _rtable) \
....@@ -466,7 +620,7 @@
466620 u32 val;
467621 };
468622
469
-#define ROCKCHIP_CPUCLK_NUM_DIVIDERS 5
623
+#define ROCKCHIP_CPUCLK_NUM_DIVIDERS 6
470624 #define ROCKCHIP_CPUCLK_MAX_CORES 4
471625 struct rockchip_cpuclk_rate_table {
472626 unsigned long prate;
....@@ -481,6 +635,7 @@
481635 * @div_core_shift[]: cores divider offset used to divide the pll value
482636 * @div_core_mask[]: cores divider mask
483637 * @num_cores: number of cpu cores
638
+ * @mux_core_reg: register offset of the cores select parent
484639 * @mux_core_alt: mux value to select alternate parent
485640 * @mux_core_main: mux value to select main parent of core
486641 * @mux_core_shift: offset of the core multiplexer
....@@ -491,6 +646,7 @@
491646 u8 div_core_shift[ROCKCHIP_CPUCLK_MAX_CORES];
492647 u32 div_core_mask[ROCKCHIP_CPUCLK_MAX_CORES];
493648 int num_cores;
649
+ int mux_core_reg;
494650 u8 mux_core_alt;
495651 u8 mux_core_main;
496652 u8 mux_core_shift;
....@@ -499,10 +655,22 @@
499655 };
500656
501657 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,
503660 const struct rockchip_cpuclk_reg_data *reg_data,
504661 const struct rockchip_cpuclk_rate_table *rates,
505662 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);
506674
507675 struct clk *rockchip_clk_register_mmc(const char *name,
508676 const char *const *parent_names, u8 num_parents,
....@@ -511,11 +679,13 @@
511679 /*
512680 * DDRCLK flags, including method of setting the rate
513681 * 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.
515682 */
516683 #define ROCKCHIP_DDRCLK_SIP BIT(0)
517
-#define ROCKCHIP_DDRCLK_SCPI 0x02
518684 #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));
519689
520690 struct clk *rockchip_clk_register_ddrclk(const char *name, int flags,
521691 const char *const *parent_names,
....@@ -523,6 +693,20 @@
523693 int mux_shift, int mux_width,
524694 int div_shift, int div_width,
525695 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
526710
527711 #define ROCKCHIP_INVERTER_HIWORD_MASK BIT(0)
528712
....@@ -540,19 +724,18 @@
540724
541725 enum rockchip_clk_branch_type {
542726 branch_composite,
543
- branch_composite_brother,
544727 branch_mux,
545728 branch_muxgrf,
546729 branch_muxpmugrf,
547730 branch_divider,
548731 branch_fraction_divider,
549732 branch_gate,
733
+ branch_gate_no_set_rate,
550734 branch_mmc,
551735 branch_inverter,
552736 branch_factor,
553737 branch_ddrclk,
554738 branch_half_divider,
555
- branch_dclk_divider,
556739 };
557740
558741 struct rockchip_clk_branch {
....@@ -576,7 +759,6 @@
576759 u8 gate_shift;
577760 u8 gate_flags;
578761 struct rockchip_clk_branch *child;
579
- unsigned long max_prate;
580762 };
581763
582764 #define COMPOSITE(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\
....@@ -598,28 +780,6 @@
598780 .gate_offset = go, \
599781 .gate_shift = gs, \
600782 .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, \
623783 }
624784
625785 #define COMPOSITE_MUXTBL(_id, cname, pnames, f, mo, ms, mw, mf, \
....@@ -740,26 +900,6 @@
740900 .gate_offset = -1, \
741901 }
742902
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
-
763903 #define COMPOSITE_NOGATE_DIVTBL(_id, cname, pnames, f, mo, ms, \
764904 mw, mf, ds, dw, df, dt) \
765905 { \
....@@ -780,7 +920,7 @@
780920 .gate_offset = -1, \
781921 }
782922
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)\
784924 { \
785925 .id = _id, \
786926 .branch_type = branch_fraction_divider, \
....@@ -795,10 +935,9 @@
795935 .gate_offset = go, \
796936 .gate_shift = gs, \
797937 .gate_flags = gf, \
798
- .max_prate = prate, \
799938 }
800939
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) \
802941 { \
803942 .id = _id, \
804943 .branch_type = branch_fraction_divider, \
....@@ -814,10 +953,9 @@
814953 .gate_shift = gs, \
815954 .gate_flags = gf, \
816955 .child = ch, \
817
- .max_prate = prate, \
818956 }
819957
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) \
821959 { \
822960 .id = _id, \
823961 .branch_type = branch_fraction_divider, \
....@@ -831,7 +969,6 @@
831969 .div_flags = df, \
832970 .gate_offset = -1, \
833971 .child = ch, \
834
- .max_prate = prate, \
835972 }
836973
837974 #define COMPOSITE_DDRCLK(_id, cname, pnames, f, mo, ms, mw, \
....@@ -947,6 +1084,19 @@
9471084 { \
9481085 .id = _id, \
9491086 .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, \
9501100 .name = cname, \
9511101 .parent_names = (const char *[]){ pname }, \
9521102 .num_parents = 1, \
....@@ -1101,28 +1251,6 @@
11011251 .gate_offset = -1, \
11021252 }
11031253
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
-
11261254 /* SGRF clocks are only accessible from secure mode, so not controllable */
11271255 #define SGRF_GATE(_id, cname, pname) \
11281256 FACTOR(_id, cname, pname, 0, 1, 1)
....@@ -1140,12 +1268,17 @@
11401268 struct rockchip_pll_clock *pll_list,
11411269 unsigned int nr_pll, int grf_lock_offset);
11421270 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);
11491282 int rockchip_pll_clk_rate_to_scale(struct clk *clk, unsigned long rate);
11501283 int rockchip_pll_clk_scale_to_rate(struct clk *clk, unsigned int scale);
11511284 int rockchip_pll_clk_adaptive_scaling(struct clk *clk, int sel);
....@@ -1165,21 +1298,6 @@
11651298 u8 gate_flags, unsigned long flags,
11661299 spinlock_t *lock);
11671300
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
-
11831301 #ifdef CONFIG_RESET_CONTROLLER
11841302 void rockchip_register_softrst(struct device_node *np,
11851303 unsigned int num_regs,
....@@ -1193,4 +1311,25 @@
11931311 #endif
11941312 extern void (*rk_dump_cru)(void);
11951313
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
11961335 #endif