Skip to content

Commit 89bf9bb

Browse files
committed
Merge tag 'v5.13-rockchip-clocks' of git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into clk-rockchip
Pull Rockchip clk driver updates from Heiko Stuebner: - Support for the clock controller on the new rk3568 - Some cleanups for rk3399 modularization * tag 'v5.13-rockchip-clocks' of git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip: clk: rockchip: drop MODULE_ALIAS from rk3399 clock controller clk: rockchip: drop parenthesis from ARM || COMPILE_TEST depends clk: rockchip: add clock controller for rk3568 clk: rockchip: support more core div setting dt-binding: clock: Document rockchip, rk3568-cru bindings clk: rockchip: add dt-binding header for rk3568
2 parents a38fd87 + 40f2983 commit 89bf9bb

File tree

18 files changed

+2857
-90
lines changed

18 files changed

+2857
-90
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/rockchip,rk3568-cru.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: ROCKCHIP rk3568 Family Clock Control Module Binding
8+
9+
maintainers:
10+
- Elaine Zhang <[email protected]>
11+
- Heiko Stuebner <[email protected]>
12+
13+
description: |
14+
The RK3568 clock controller generates the clock and also implements a
15+
reset controller for SoC peripherals.
16+
(examples: provide SCLK_UART1\PCLK_UART1 and SRST_P_UART1\SRST_S_UART1 for UART module)
17+
Each clock is assigned an identifier and client nodes can use this identifier
18+
to specify the clock which they consume. All available clocks are defined as
19+
preprocessor macros in the dt-bindings/clock/rk3568-cru.h headers and can be
20+
used in device tree sources.
21+
22+
properties:
23+
compatible:
24+
enum:
25+
- rockchip,rk3568-cru
26+
- rockchip,rk3568-pmucru
27+
28+
reg:
29+
maxItems: 1
30+
31+
"#clock-cells":
32+
const: 1
33+
34+
"#reset-cells":
35+
const: 1
36+
37+
required:
38+
- compatible
39+
- reg
40+
- "#clock-cells"
41+
- "#reset-cells"
42+
43+
additionalProperties: false
44+
45+
examples:
46+
# Clock Control Module node:
47+
- |
48+
pmucru: clock-controller@fdd00000 {
49+
compatible = "rockchip,rk3568-pmucru";
50+
reg = <0xfdd00000 0x1000>;
51+
#clock-cells = <1>;
52+
#reset-cells = <1>;
53+
};
54+
- |
55+
cru: clock-controller@fdd20000 {
56+
compatible = "rockchip,rk3568-cru";
57+
reg = <0xfdd20000 0x1000>;
58+
#clock-cells = <1>;
59+
#reset-cells = <1>;
60+
};

drivers/clk/rockchip/Kconfig

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,78 +11,85 @@ config COMMON_CLK_ROCKCHIP
1111
if COMMON_CLK_ROCKCHIP
1212
config CLK_PX30
1313
bool "Rockchip PX30 clock controller support"
14-
depends on (ARM64 || COMPILE_TEST)
14+
depends on ARM64 || COMPILE_TEST
1515
default y
1616
help
1717
Build the driver for PX30 Clock Driver.
1818

1919
config CLK_RV110X
2020
bool "Rockchip RV110x clock controller support"
21-
depends on (ARM || COMPILE_TEST)
21+
depends on ARM || COMPILE_TEST
2222
default y
2323
help
2424
Build the driver for RV110x Clock Driver.
2525

2626
config CLK_RK3036
2727
bool "Rockchip RK3036 clock controller support"
28-
depends on (ARM || COMPILE_TEST)
28+
depends on ARM || COMPILE_TEST
2929
default y
3030
help
3131
Build the driver for RK3036 Clock Driver.
3232

3333
config CLK_RK312X
3434
bool "Rockchip RK312x clock controller support"
35-
depends on (ARM || COMPILE_TEST)
35+
depends on ARM || COMPILE_TEST
3636
default y
3737
help
3838
Build the driver for RK312x Clock Driver.
3939

4040
config CLK_RK3188
4141
bool "Rockchip RK3188 clock controller support"
42-
depends on (ARM || COMPILE_TEST)
42+
depends on ARM || COMPILE_TEST
4343
default y
4444
help
4545
Build the driver for RK3188 Clock Driver.
4646

4747
config CLK_RK322X
4848
bool "Rockchip RK322x clock controller support"
49-
depends on (ARM || COMPILE_TEST)
49+
depends on ARM || COMPILE_TEST
5050
default y
5151
help
5252
Build the driver for RK322x Clock Driver.
5353

5454
config CLK_RK3288
5555
bool "Rockchip RK3288 clock controller support"
56-
depends on (ARM || COMPILE_TEST)
56+
depends on ARM || COMPILE_TEST
5757
default y
5858
help
5959
Build the driver for RK3288 Clock Driver.
6060

6161
config CLK_RK3308
6262
bool "Rockchip RK3308 clock controller support"
63-
depends on (ARM64 || COMPILE_TEST)
63+
depends on ARM64 || COMPILE_TEST
6464
default y
6565
help
6666
Build the driver for RK3308 Clock Driver.
6767

6868
config CLK_RK3328
6969
bool "Rockchip RK3328 clock controller support"
70-
depends on (ARM64 || COMPILE_TEST)
70+
depends on ARM64 || COMPILE_TEST
7171
default y
7272
help
7373
Build the driver for RK3328 Clock Driver.
7474

7575
config CLK_RK3368
7676
bool "Rockchip RK3368 clock controller support"
77-
depends on (ARM64 || COMPILE_TEST)
77+
depends on ARM64 || COMPILE_TEST
7878
default y
7979
help
8080
Build the driver for RK3368 Clock Driver.
8181

8282
config CLK_RK3399
8383
tristate "Rockchip RK3399 clock controller support"
84-
depends on (ARM64 || COMPILE_TEST)
84+
depends on ARM64 || COMPILE_TEST
8585
default y
8686
help
8787
Build the driver for RK3399 Clock Driver.
88+
89+
config CLK_RK3568
90+
tristate "Rockchip RK3568 clock controller support"
91+
depends on ARM64 || COMPILE_TEST
92+
default y
93+
help
94+
Build the driver for RK3568 Clock Driver.
8895
endif

drivers/clk/rockchip/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ obj-$(CONFIG_CLK_RK3308) += clk-rk3308.o
2626
obj-$(CONFIG_CLK_RK3328) += clk-rk3328.o
2727
obj-$(CONFIG_CLK_RK3368) += clk-rk3368.o
2828
obj-$(CONFIG_CLK_RK3399) += clk-rk3399.o
29+
obj-$(CONFIG_CLK_RK3568) += clk-rk3568.o

drivers/clk/rockchip/clk-cpu.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ static unsigned long rockchip_cpuclk_recalc_rate(struct clk_hw *hw,
8484
{
8585
struct rockchip_cpuclk *cpuclk = to_rockchip_cpuclk_hw(hw);
8686
const struct rockchip_cpuclk_reg_data *reg_data = cpuclk->reg_data;
87-
u32 clksel0 = readl_relaxed(cpuclk->reg_base + reg_data->core_reg);
87+
u32 clksel0 = readl_relaxed(cpuclk->reg_base + reg_data->core_reg[0]);
8888

89-
clksel0 >>= reg_data->div_core_shift;
90-
clksel0 &= reg_data->div_core_mask;
89+
clksel0 >>= reg_data->div_core_shift[0];
90+
clksel0 &= reg_data->div_core_mask[0];
9191
return parent_rate / (clksel0 + 1);
9292
}
9393

@@ -120,6 +120,7 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk,
120120
const struct rockchip_cpuclk_rate_table *rate;
121121
unsigned long alt_prate, alt_div;
122122
unsigned long flags;
123+
int i = 0;
123124

124125
/* check validity of the new rate */
125126
rate = rockchip_get_cpuclk_settings(cpuclk, ndata->new_rate);
@@ -142,10 +143,10 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk,
142143
if (alt_prate > ndata->old_rate) {
143144
/* calculate dividers */
144145
alt_div = DIV_ROUND_UP(alt_prate, ndata->old_rate) - 1;
145-
if (alt_div > reg_data->div_core_mask) {
146+
if (alt_div > reg_data->div_core_mask[0]) {
146147
pr_warn("%s: limiting alt-divider %lu to %d\n",
147-
__func__, alt_div, reg_data->div_core_mask);
148-
alt_div = reg_data->div_core_mask;
148+
__func__, alt_div, reg_data->div_core_mask[0]);
149+
alt_div = reg_data->div_core_mask[0];
149150
}
150151

151152
/*
@@ -158,19 +159,17 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk,
158159
pr_debug("%s: setting div %lu as alt-rate %lu > old-rate %lu\n",
159160
__func__, alt_div, alt_prate, ndata->old_rate);
160161

161-
writel(HIWORD_UPDATE(alt_div, reg_data->div_core_mask,
162-
reg_data->div_core_shift) |
163-
HIWORD_UPDATE(reg_data->mux_core_alt,
164-
reg_data->mux_core_mask,
165-
reg_data->mux_core_shift),
166-
cpuclk->reg_base + reg_data->core_reg);
167-
} else {
168-
/* select alternate parent */
169-
writel(HIWORD_UPDATE(reg_data->mux_core_alt,
170-
reg_data->mux_core_mask,
171-
reg_data->mux_core_shift),
172-
cpuclk->reg_base + reg_data->core_reg);
162+
for (i = 0; i < reg_data->num_cores; i++) {
163+
writel(HIWORD_UPDATE(alt_div, reg_data->div_core_mask[i],
164+
reg_data->div_core_shift[i]),
165+
cpuclk->reg_base + reg_data->core_reg[i]);
166+
}
173167
}
168+
/* select alternate parent */
169+
writel(HIWORD_UPDATE(reg_data->mux_core_alt,
170+
reg_data->mux_core_mask,
171+
reg_data->mux_core_shift),
172+
cpuclk->reg_base + reg_data->core_reg[0]);
174173

175174
spin_unlock_irqrestore(cpuclk->lock, flags);
176175
return 0;
@@ -182,6 +181,7 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk,
182181
const struct rockchip_cpuclk_reg_data *reg_data = cpuclk->reg_data;
183182
const struct rockchip_cpuclk_rate_table *rate;
184183
unsigned long flags;
184+
int i = 0;
185185

186186
rate = rockchip_get_cpuclk_settings(cpuclk, ndata->new_rate);
187187
if (!rate) {
@@ -202,12 +202,17 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk,
202202
* primary parent by the extra dividers that were needed for the alt.
203203
*/
204204

205-
writel(HIWORD_UPDATE(0, reg_data->div_core_mask,
206-
reg_data->div_core_shift) |
207-
HIWORD_UPDATE(reg_data->mux_core_main,
208-
reg_data->mux_core_mask,
209-
reg_data->mux_core_shift),
210-
cpuclk->reg_base + reg_data->core_reg);
205+
writel(HIWORD_UPDATE(reg_data->mux_core_main,
206+
reg_data->mux_core_mask,
207+
reg_data->mux_core_shift),
208+
cpuclk->reg_base + reg_data->core_reg[0]);
209+
210+
/* remove dividers */
211+
for (i = 0; i < reg_data->num_cores; i++) {
212+
writel(HIWORD_UPDATE(0, reg_data->div_core_mask[i],
213+
reg_data->div_core_shift[i]),
214+
cpuclk->reg_base + reg_data->core_reg[i]);
215+
}
211216

212217
if (ndata->old_rate > ndata->new_rate)
213218
rockchip_cpuclk_set_dividers(cpuclk, rate);

drivers/clk/rockchip/clk-px30.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ static struct rockchip_cpuclk_rate_table px30_cpuclk_rates[] __initdata = {
124124
};
125125

126126
static const struct rockchip_cpuclk_reg_data px30_cpuclk_data = {
127-
.core_reg = PX30_CLKSEL_CON(0),
128-
.div_core_shift = 0,
129-
.div_core_mask = 0xf,
127+
.core_reg[0] = PX30_CLKSEL_CON(0),
128+
.div_core_shift[0] = 0,
129+
.div_core_mask[0] = 0xf,
130+
.num_cores = 1,
130131
.mux_core_alt = 1,
131132
.mux_core_main = 0,
132133
.mux_core_shift = 7,

drivers/clk/rockchip/clk-rk3036.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ static struct rockchip_cpuclk_rate_table rk3036_cpuclk_rates[] __initdata = {
102102
};
103103

104104
static const struct rockchip_cpuclk_reg_data rk3036_cpuclk_data = {
105-
.core_reg = RK2928_CLKSEL_CON(0),
106-
.div_core_shift = 0,
107-
.div_core_mask = 0x1f,
105+
.core_reg[0] = RK2928_CLKSEL_CON(0),
106+
.div_core_shift[0] = 0,
107+
.div_core_mask[0] = 0x1f,
108+
.num_cores = 1,
108109
.mux_core_alt = 1,
109110
.mux_core_main = 0,
110111
.mux_core_shift = 7,

drivers/clk/rockchip/clk-rk3128.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ static struct rockchip_cpuclk_rate_table rk3128_cpuclk_rates[] __initdata = {
117117
};
118118

119119
static const struct rockchip_cpuclk_reg_data rk3128_cpuclk_data = {
120-
.core_reg = RK2928_CLKSEL_CON(0),
121-
.div_core_shift = 0,
122-
.div_core_mask = 0x1f,
120+
.core_reg[0] = RK2928_CLKSEL_CON(0),
121+
.div_core_shift[0] = 0,
122+
.div_core_mask[0] = 0x1f,
123+
.num_cores = 1,
123124
.mux_core_alt = 1,
124125
.mux_core_main = 0,
125126
.mux_core_shift = 7,

drivers/clk/rockchip/clk-rk3188.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ static struct rockchip_cpuclk_rate_table rk3066_cpuclk_rates[] __initdata = {
145145
};
146146

147147
static const struct rockchip_cpuclk_reg_data rk3066_cpuclk_data = {
148-
.core_reg = RK2928_CLKSEL_CON(0),
149-
.div_core_shift = 0,
150-
.div_core_mask = 0x1f,
148+
.core_reg[0] = RK2928_CLKSEL_CON(0),
149+
.div_core_shift[0] = 0,
150+
.div_core_mask[0] = 0x1f,
151+
.num_cores = 1,
151152
.mux_core_alt = 1,
152153
.mux_core_main = 0,
153154
.mux_core_shift = 8,
@@ -184,9 +185,10 @@ static struct rockchip_cpuclk_rate_table rk3188_cpuclk_rates[] __initdata = {
184185
};
185186

186187
static const struct rockchip_cpuclk_reg_data rk3188_cpuclk_data = {
187-
.core_reg = RK2928_CLKSEL_CON(0),
188-
.div_core_shift = 9,
189-
.div_core_mask = 0x1f,
188+
.core_reg[0] = RK2928_CLKSEL_CON(0),
189+
.div_core_shift[0] = 9,
190+
.div_core_mask[0] = 0x1f,
191+
.num_cores = 1,
190192
.mux_core_alt = 1,
191193
.mux_core_main = 0,
192194
.mux_core_shift = 8,

drivers/clk/rockchip/clk-rk3228.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ static struct rockchip_cpuclk_rate_table rk3228_cpuclk_rates[] __initdata = {
119119
};
120120

121121
static const struct rockchip_cpuclk_reg_data rk3228_cpuclk_data = {
122-
.core_reg = RK2928_CLKSEL_CON(0),
123-
.div_core_shift = 0,
124-
.div_core_mask = 0x1f,
122+
.core_reg[0] = RK2928_CLKSEL_CON(0),
123+
.div_core_shift[0] = 0,
124+
.div_core_mask[0] = 0x1f,
125+
.num_cores = 1,
125126
.mux_core_alt = 1,
126127
.mux_core_main = 0,
127128
.mux_core_shift = 6,

drivers/clk/rockchip/clk-rk3288.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@ static struct rockchip_cpuclk_rate_table rk3288_cpuclk_rates[] __initdata = {
179179
};
180180

181181
static const struct rockchip_cpuclk_reg_data rk3288_cpuclk_data = {
182-
.core_reg = RK3288_CLKSEL_CON(0),
183-
.div_core_shift = 8,
184-
.div_core_mask = 0x1f,
182+
.core_reg[0] = RK3288_CLKSEL_CON(0),
183+
.div_core_shift[0] = 8,
184+
.div_core_mask[0] = 0x1f,
185+
.num_cores = 1,
185186
.mux_core_alt = 1,
186187
.mux_core_main = 0,
187188
.mux_core_shift = 15,

0 commit comments

Comments
 (0)