1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Copyright (c) 2014 MundoReader S.L.
4 * Author: Heiko Stuebner <[email protected]>
5 *
6 * Copyright (c) 2015 Rockchip Electronics Co. Ltd.
7 * Author: Xing Zheng <[email protected]>
8 *
9 * based on
10 *
11 * samsung/clk.h
12 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
13 * Copyright (c) 2013 Linaro Ltd.
14 * Author: Thomas Abraham <[email protected]>
15 */
16
17 #ifndef CLK_ROCKCHIP_CLK_H
18 #define CLK_ROCKCHIP_CLK_H
19
20 #include <linux/io.h>
21 #include <linux/clk-provider.h>
22
23 struct clk;
24
25 #define HIWORD_UPDATE(val, mask, shift) \
26 ((val) << (shift) | (mask) << ((shift) + 16))
27
28 /* register positions shared by PX30, RV1108, RK2928, RK3036, RK3066, RK3188 and RK3228 */
29 #define BOOST_PLL_H_CON(x) ((x) * 0x4)
30 #define BOOST_CLK_CON 0x0008
31 #define BOOST_BOOST_CON 0x000c
32 #define BOOST_SWITCH_CNT 0x0010
33 #define BOOST_HIGH_PERF_CNT0 0x0014
34 #define BOOST_HIGH_PERF_CNT1 0x0018
35 #define BOOST_STATIS_THRESHOLD 0x001c
36 #define BOOST_SHORT_SWITCH_CNT 0x0020
37 #define BOOST_SWITCH_THRESHOLD 0x0024
38 #define BOOST_FSM_STATUS 0x0028
39 #define BOOST_PLL_L_CON(x) ((x) * 0x4 + 0x2c)
40 #define BOOST_RECOVERY_MASK 0x1
41 #define BOOST_RECOVERY_SHIFT 1
42 #define BOOST_SW_CTRL_MASK 0x1
43 #define BOOST_SW_CTRL_SHIFT 2
44 #define BOOST_LOW_FREQ_EN_MASK 0x1
45 #define BOOST_LOW_FREQ_EN_SHIFT 3
46 #define BOOST_BUSY_STATE BIT(8)
47
48 #define PX30_PLL_CON(x) ((x) * 0x4)
49 #define PX30_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
50 #define PX30_CLKGATE_CON(x) ((x) * 0x4 + 0x200)
51 #define PX30_GLB_SRST_FST 0xb8
52 #define PX30_GLB_SRST_SND 0xbc
53 #define PX30_SOFTRST_CON(x) ((x) * 0x4 + 0x300)
54 #define PX30_MODE_CON 0xa0
55 #define PX30_MISC_CON 0xa4
56 #define PX30_SDMMC_CON0 0x380
57 #define PX30_SDMMC_CON1 0x384
58 #define PX30_SDIO_CON0 0x388
59 #define PX30_SDIO_CON1 0x38c
60 #define PX30_EMMC_CON0 0x390
61 #define PX30_EMMC_CON1 0x394
62
63 #define PX30_PMU_PLL_CON(x) ((x) * 0x4)
64 #define PX30_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x40)
65 #define PX30_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x80)
66 #define PX30_PMU_MODE 0x0020
67
68 #define RV1108_PLL_CON(x) ((x) * 0x4)
69 #define RV1108_CLKSEL_CON(x) ((x) * 0x4 + 0x60)
70 #define RV1108_CLKGATE_CON(x) ((x) * 0x4 + 0x120)
71 #define RV1108_SOFTRST_CON(x) ((x) * 0x4 + 0x180)
72 #define RV1108_GLB_SRST_FST 0x1c0
73 #define RV1108_GLB_SRST_SND 0x1c4
74 #define RV1108_MISC_CON 0x1cc
75 #define RV1108_SDMMC_CON0 0x1d8
76 #define RV1108_SDMMC_CON1 0x1dc
77 #define RV1108_SDIO_CON0 0x1e0
78 #define RV1108_SDIO_CON1 0x1e4
79 #define RV1108_EMMC_CON0 0x1e8
80 #define RV1108_EMMC_CON1 0x1ec
81
82 #define RV1126_PMU_MODE 0x0
83 #define RV1126_PMU_PLL_CON(x) ((x) * 0x4 + 0x10)
84 #define RV1126_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
85 #define RV1126_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x180)
86 #define RV1126_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x200)
87 #define RV1126_PLL_CON(x) ((x) * 0x4)
88 #define RV1126_MODE_CON 0x90
89 #define RV1126_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
90 #define RV1126_CLKGATE_CON(x) ((x) * 0x4 + 0x280)
91 #define RV1126_SOFTRST_CON(x) ((x) * 0x4 + 0x300)
92 #define RV1126_GLB_SRST_FST 0x408
93 #define RV1126_GLB_SRST_SND 0x40c
94 #define RV1126_SDMMC_CON0 0x440
95 #define RV1126_SDMMC_CON1 0x444
96 #define RV1126_SDIO_CON0 0x448
97 #define RV1126_SDIO_CON1 0x44c
98 #define RV1126_EMMC_CON0 0x450
99 #define RV1126_EMMC_CON1 0x454
100
101 #define RK2928_PLL_CON(x) ((x) * 0x4)
102 #define RK2928_MODE_CON 0x40
103 #define RK2928_CLKSEL_CON(x) ((x) * 0x4 + 0x44)
104 #define RK2928_CLKGATE_CON(x) ((x) * 0x4 + 0xd0)
105 #define RK2928_GLB_SRST_FST 0x100
106 #define RK2928_GLB_SRST_SND 0x104
107 #define RK2928_SOFTRST_CON(x) ((x) * 0x4 + 0x110)
108 #define RK2928_MISC_CON 0x134
109
110 #define RK3036_SDMMC_CON0 0x144
111 #define RK3036_SDMMC_CON1 0x148
112 #define RK3036_SDIO_CON0 0x14c
113 #define RK3036_SDIO_CON1 0x150
114 #define RK3036_EMMC_CON0 0x154
115 #define RK3036_EMMC_CON1 0x158
116
117 #define RK3228_GLB_SRST_FST 0x1f0
118 #define RK3228_GLB_SRST_SND 0x1f4
119 #define RK3228_SDMMC_CON0 0x1c0
120 #define RK3228_SDMMC_CON1 0x1c4
121 #define RK3228_SDIO_CON0 0x1c8
122 #define RK3228_SDIO_CON1 0x1cc
123 #define RK3228_EMMC_CON0 0x1d8
124 #define RK3228_EMMC_CON1 0x1dc
125
126 #define RK3288_PLL_CON(x) RK2928_PLL_CON(x)
127 #define RK3288_MODE_CON 0x50
128 #define RK3288_CLKSEL_CON(x) ((x) * 0x4 + 0x60)
129 #define RK3288_CLKGATE_CON(x) ((x) * 0x4 + 0x160)
130 #define RK3288_GLB_SRST_FST 0x1b0
131 #define RK3288_GLB_SRST_SND 0x1b4
132 #define RK3288_SOFTRST_CON(x) ((x) * 0x4 + 0x1b8)
133 #define RK3288_MISC_CON 0x1e8
134 #define RK3288_SDMMC_CON0 0x200
135 #define RK3288_SDMMC_CON1 0x204
136 #define RK3288_SDIO0_CON0 0x208
137 #define RK3288_SDIO0_CON1 0x20c
138 #define RK3288_SDIO1_CON0 0x210
139 #define RK3288_SDIO1_CON1 0x214
140 #define RK3288_EMMC_CON0 0x218
141 #define RK3288_EMMC_CON1 0x21c
142
143 #define RK3308_PLL_CON(x) RK2928_PLL_CON(x)
144 #define RK3308_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
145 #define RK3308_CLKGATE_CON(x) ((x) * 0x4 + 0x300)
146 #define RK3308_GLB_SRST_FST 0xb8
147 #define RK3308_SOFTRST_CON(x) ((x) * 0x4 + 0x400)
148 #define RK3308_MODE_CON 0xa0
149 #define RK3308_SDMMC_CON0 0x480
150 #define RK3308_SDMMC_CON1 0x484
151 #define RK3308_SDIO_CON0 0x488
152 #define RK3308_SDIO_CON1 0x48c
153 #define RK3308_EMMC_CON0 0x490
154 #define RK3308_EMMC_CON1 0x494
155
156 #define RK3328_PLL_CON(x) RK2928_PLL_CON(x)
157 #define RK3328_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
158 #define RK3328_CLKGATE_CON(x) ((x) * 0x4 + 0x200)
159 #define RK3328_GRFCLKSEL_CON(x) ((x) * 0x4 + 0x100)
160 #define RK3328_GLB_SRST_FST 0x9c
161 #define RK3328_GLB_SRST_SND 0x98
162 #define RK3328_SOFTRST_CON(x) ((x) * 0x4 + 0x300)
163 #define RK3328_MODE_CON 0x80
164 #define RK3328_MISC_CON 0x84
165 #define RK3328_SDMMC_CON0 0x380
166 #define RK3328_SDMMC_CON1 0x384
167 #define RK3328_SDIO_CON0 0x388
168 #define RK3328_SDIO_CON1 0x38c
169 #define RK3328_EMMC_CON0 0x390
170 #define RK3328_EMMC_CON1 0x394
171 #define RK3328_SDMMC_EXT_CON0 0x398
172 #define RK3328_SDMMC_EXT_CON1 0x39C
173
174 #define RK3368_PLL_CON(x) RK2928_PLL_CON(x)
175 #define RK3368_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
176 #define RK3368_CLKGATE_CON(x) ((x) * 0x4 + 0x200)
177 #define RK3368_GLB_SRST_FST 0x280
178 #define RK3368_GLB_SRST_SND 0x284
179 #define RK3368_SOFTRST_CON(x) ((x) * 0x4 + 0x300)
180 #define RK3368_MISC_CON 0x380
181 #define RK3368_SDMMC_CON0 0x400
182 #define RK3368_SDMMC_CON1 0x404
183 #define RK3368_SDIO0_CON0 0x408
184 #define RK3368_SDIO0_CON1 0x40c
185 #define RK3368_SDIO1_CON0 0x410
186 #define RK3368_SDIO1_CON1 0x414
187 #define RK3368_EMMC_CON0 0x418
188 #define RK3368_EMMC_CON1 0x41c
189
190 #define RK3399_PLL_CON(x) RK2928_PLL_CON(x)
191 #define RK3399_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
192 #define RK3399_CLKGATE_CON(x) ((x) * 0x4 + 0x300)
193 #define RK3399_SOFTRST_CON(x) ((x) * 0x4 + 0x400)
194 #define RK3399_GLB_SRST_FST 0x500
195 #define RK3399_GLB_SRST_SND 0x504
196 #define RK3399_GLB_CNT_TH 0x508
197 #define RK3399_MISC_CON 0x50c
198 #define RK3399_RST_CON 0x510
199 #define RK3399_RST_ST 0x514
200 #define RK3399_SDMMC_CON0 0x580
201 #define RK3399_SDMMC_CON1 0x584
202 #define RK3399_SDIO_CON0 0x588
203 #define RK3399_SDIO_CON1 0x58c
204
205 #define RK3399_PMU_PLL_CON(x) RK2928_PLL_CON(x)
206 #define RK3399_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x80)
207 #define RK3399_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x100)
208 #define RK3399_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x110)
209
210 #define RK3568_PLL_CON(x) RK2928_PLL_CON(x)
211 #define RK3568_MODE_CON0 0xc0
212 #define RK3568_MISC_CON0 0xc4
213 #define RK3568_MISC_CON1 0xc8
214 #define RK3568_MISC_CON2 0xcc
215 #define RK3568_GLB_CNT_TH 0xd0
216 #define RK3568_GLB_SRST_FST 0xd4
217 #define RK3568_GLB_SRST_SND 0xd8
218 #define RK3568_GLB_RST_CON 0xdc
219 #define RK3568_GLB_RST_ST 0xe0
220 #define RK3568_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
221 #define RK3568_CLKGATE_CON(x) ((x) * 0x4 + 0x300)
222 #define RK3568_SOFTRST_CON(x) ((x) * 0x4 + 0x400)
223 #define RK3568_SDMMC0_CON0 0x580
224 #define RK3568_SDMMC0_CON1 0x584
225 #define RK3568_SDMMC1_CON0 0x588
226 #define RK3568_SDMMC1_CON1 0x58c
227 #define RK3568_SDMMC2_CON0 0x590
228 #define RK3568_SDMMC2_CON1 0x594
229 #define RK3568_EMMC_CON0 0x598
230 #define RK3568_EMMC_CON1 0x59c
231
232 #define RK3568_PMU_PLL_CON(x) RK2928_PLL_CON(x)
233 #define RK3568_PMU_MODE_CON0 0x80
234 #define RK3568_PMU_CLKSEL_CON(x) ((x) * 0x4 + 0x100)
235 #define RK3568_PMU_CLKGATE_CON(x) ((x) * 0x4 + 0x180)
236 #define RK3568_PMU_SOFTRST_CON(x) ((x) * 0x4 + 0x200)
237
238 #define RK3576_PHP_CRU_BASE 0x8000
239 #define RK3576_SECURE_NS_CRU_BASE 0x10000
240 #define RK3576_PMU_CRU_BASE 0x20000
241 #define RK3576_BIGCORE_CRU_BASE 0x38000
242 #define RK3576_LITCORE_CRU_BASE 0x40000
243 #define RK3576_CCI_CRU_BASE 0x48000
244
245 #define RK3576_PLL_CON(x) RK2928_PLL_CON(x)
246 #define RK3576_MODE_CON0 0x280
247 #define RK3576_BPLL_MODE_CON0 (RK3576_BIGCORE_CRU_BASE + 0x280)
248 #define RK3576_LPLL_MODE_CON0 (RK3576_LITCORE_CRU_BASE + 0x280)
249 #define RK3576_PPLL_MODE_CON0 (RK3576_PHP_CRU_BASE + 0x280)
250 #define RK3576_CLKSEL_CON(x) ((x) * 0x4 + 0x300)
251 #define RK3576_CLKGATE_CON(x) ((x) * 0x4 + 0x800)
252 #define RK3576_SOFTRST_CON(x) ((x) * 0x4 + 0xa00)
253 #define RK3576_GLB_CNT_TH 0xc00
254 #define RK3576_GLB_SRST_FST 0xc08
255 #define RK3576_GLB_SRST_SND 0xc0c
256 #define RK3576_GLB_RST_CON 0xc10
257 #define RK3576_GLB_RST_ST 0xc04
258 #define RK3576_SDIO_CON0 0xC24
259 #define RK3576_SDIO_CON1 0xC28
260 #define RK3576_SDMMC_CON0 0xC30
261 #define RK3576_SDMMC_CON1 0xC34
262
263 #define RK3576_PHP_CLKSEL_CON(x) ((x) * 0x4 + RK3576_PHP_CRU_BASE + 0x300)
264 #define RK3576_PHP_CLKGATE_CON(x) ((x) * 0x4 + RK3576_PHP_CRU_BASE + 0x800)
265 #define RK3576_PHP_SOFTRST_CON(x) ((x) * 0x4 + RK3576_PHP_CRU_BASE + 0xa00)
266
267 #define RK3576_PMU_PLL_CON(x) ((x) * 0x4 + RK3576_PHP_CRU_BASE)
268 #define RK3576_PMU_CLKSEL_CON(x) ((x) * 0x4 + RK3576_PMU_CRU_BASE + 0x300)
269 #define RK3576_PMU_CLKGATE_CON(x) ((x) * 0x4 + RK3576_PMU_CRU_BASE + 0x800)
270 #define RK3576_PMU_SOFTRST_CON(x) ((x) * 0x4 + RK3576_PMU_CRU_BASE + 0xa00)
271
272 #define RK3576_SECURE_NS_CLKSEL_CON(x) ((x) * 0x4 + RK3576_SECURE_NS_CRU_BASE + 0x300)
273 #define RK3576_SECURE_NS_CLKGATE_CON(x) ((x) * 0x4 + RK3576_SECURE_NS_CRU_BASE + 0x800)
274 #define RK3576_SECURE_NS_SOFTRST_CON(x) ((x) * 0x4 + RK3576_SECURE_NS_CRU_BASE + 0xa00)
275
276 #define RK3576_CCI_CLKSEL_CON(x) ((x) * 0x4 + RK3576_CCI_CRU_BASE + 0x300)
277 #define RK3576_CCI_CLKGATE_CON(x) ((x) * 0x4 + RK3576_CCI_CRU_BASE + 0x800)
278 #define RK3576_CCI_SOFTRST_CON(x) ((x) * 0x4 + RK3576_CCI_CRU_BASE + 0xa00)
279
280 #define RK3576_BPLL_CON(x) ((x) * 0x4 + RK3576_BIGCORE_CRU_BASE)
281 #define RK3576_BIGCORE_CLKSEL_CON(x) ((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0x300)
282 #define RK3576_BIGCORE_CLKGATE_CON(x) ((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0x800)
283 #define RK3576_BIGCORE_SOFTRST_CON(x) ((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0xa00)
284 #define RK3576_LPLL_CON(x) ((x) * 0x4 + RK3576_CCI_CRU_BASE)
285 #define RK3576_LITCORE_CLKSEL_CON(x) ((x) * 0x4 + RK3576_LITCORE_CRU_BASE + 0x300)
286 #define RK3576_LITCORE_CLKGATE_CON(x) ((x) * 0x4 + RK3576_LITCORE_CRU_BASE + 0x800)
287 #define RK3576_LITCORE_SOFTRST_CON(x) ((x) * 0x4 + RK3576_LITCORE_CRU_BASE + 0xa00)
288 #define RK3576_NON_SECURE_GATING_CON00 0xc48
289
290 #define RK3588_PHP_CRU_BASE 0x8000
291 #define RK3588_PMU_CRU_BASE 0x30000
292 #define RK3588_BIGCORE0_CRU_BASE 0x50000
293 #define RK3588_BIGCORE1_CRU_BASE 0x52000
294 #define RK3588_DSU_CRU_BASE 0x58000
295
296 #define RK3588_PLL_CON(x) RK2928_PLL_CON(x)
297 #define RK3588_MODE_CON0 0x280
298 #define RK3588_B0_PLL_MODE_CON0 (RK3588_BIGCORE0_CRU_BASE + 0x280)
299 #define RK3588_B1_PLL_MODE_CON0 (RK3588_BIGCORE1_CRU_BASE + 0x280)
300 #define RK3588_LPLL_MODE_CON0 (RK3588_DSU_CRU_BASE + 0x280)
301 #define RK3588_CLKSEL_CON(x) ((x) * 0x4 + 0x300)
302 #define RK3588_CLKGATE_CON(x) ((x) * 0x4 + 0x800)
303 #define RK3588_SOFTRST_CON(x) ((x) * 0x4 + 0xa00)
304 #define RK3588_GLB_CNT_TH 0xc00
305 #define RK3588_GLB_SRST_FST 0xc08
306 #define RK3588_GLB_SRST_SND 0xc0c
307 #define RK3588_GLB_RST_CON 0xc10
308 #define RK3588_GLB_RST_ST 0xc04
309 #define RK3588_SDIO_CON0 0xC24
310 #define RK3588_SDIO_CON1 0xC28
311 #define RK3588_SDMMC_CON0 0xC30
312 #define RK3588_SDMMC_CON1 0xC34
313
314 #define RK3588_PHP_CLKGATE_CON(x) ((x) * 0x4 + RK3588_PHP_CRU_BASE + 0x800)
315 #define RK3588_PHP_SOFTRST_CON(x) ((x) * 0x4 + RK3588_PHP_CRU_BASE + 0xa00)
316
317 #define RK3588_PMU_PLL_CON(x) ((x) * 0x4 + RK3588_PHP_CRU_BASE)
318 #define RK3588_PMU_CLKSEL_CON(x) ((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x300)
319 #define RK3588_PMU_CLKGATE_CON(x) ((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x800)
320 #define RK3588_PMU_SOFTRST_CON(x) ((x) * 0x4 + RK3588_PMU_CRU_BASE + 0xa00)
321
322 #define RK3588_B0_PLL_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE)
323 #define RK3588_BIGCORE0_CLKSEL_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0x300)
324 #define RK3588_BIGCORE0_CLKGATE_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0x800)
325 #define RK3588_BIGCORE0_SOFTRST_CON(x) ((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0xa00)
326 #define RK3588_B1_PLL_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE)
327 #define RK3588_BIGCORE1_CLKSEL_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0x300)
328 #define RK3588_BIGCORE1_CLKGATE_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0x800)
329 #define RK3588_BIGCORE1_SOFTRST_CON(x) ((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0xa00)
330 #define RK3588_LPLL_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE)
331 #define RK3588_DSU_CLKSEL_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0x300)
332 #define RK3588_DSU_CLKGATE_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0x800)
333 #define RK3588_DSU_SOFTRST_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0xa00)
334
335 enum rockchip_pll_type {
336 pll_rk3036,
337 pll_rk3066,
338 pll_rk3328,
339 pll_rk3399,
340 pll_rk3588,
341 pll_rk3588_core,
342 pll_rk3588_ddr,
343 };
344
345 #define RK3036_PLL_RATE(_rate, _refdiv, _fbdiv, _postdiv1, \
346 _postdiv2, _dsmpd, _frac) \
347 { \
348 .rate = _rate##U, \
349 .fbdiv = _fbdiv, \
350 .postdiv1 = _postdiv1, \
351 .refdiv = _refdiv, \
352 .postdiv2 = _postdiv2, \
353 .dsmpd = _dsmpd, \
354 .frac = _frac, \
355 }
356
357 #define RK3066_PLL_RATE(_rate, _nr, _nf, _no) \
358 { \
359 .rate = _rate##U, \
360 .nr = _nr, \
361 .nf = _nf, \
362 .no = _no, \
363 .nb = ((_nf) < 2) ? 1 : (_nf) >> 1, \
364 }
365
366 #define RK3066_PLL_RATE_NB(_rate, _nr, _nf, _no, _nb) \
367 { \
368 .rate = _rate##U, \
369 .nr = _nr, \
370 .nf = _nf, \
371 .no = _no, \
372 .nb = _nb, \
373 }
374
375 #define RK3588_PLL_RATE(_rate, _p, _m, _s, _k) \
376 { \
377 .rate = _rate##U, \
378 .p = _p, \
379 .m = _m, \
380 .s = _s, \
381 .k = _k, \
382 }
383
384 /**
385 * struct rockchip_clk_provider - information about clock provider
386 * @reg_base: virtual address for the register base.
387 * @clk_data: holds clock related data like clk* and number of clocks.
388 * @cru_node: device-node of the clock-provider
389 * @grf: regmap of the general-register-files syscon
390 * @lock: maintains exclusion between callbacks for a given clock-provider.
391 */
392 struct rockchip_clk_provider {
393 void __iomem *reg_base;
394 struct clk_onecell_data clk_data;
395 struct device_node *cru_node;
396 struct regmap *grf;
397 spinlock_t lock;
398 };
399
400 struct rockchip_pll_rate_table {
401 unsigned long rate;
402 union {
403 struct {
404 /* for RK3066 */
405 unsigned int nr;
406 unsigned int nf;
407 unsigned int no;
408 unsigned int nb;
409 };
410 struct {
411 /* for RK3036/RK3399 */
412 unsigned int fbdiv;
413 unsigned int postdiv1;
414 unsigned int refdiv;
415 unsigned int postdiv2;
416 unsigned int dsmpd;
417 unsigned int frac;
418 };
419 struct {
420 /* for RK3588 */
421 unsigned int m;
422 unsigned int p;
423 unsigned int s;
424 unsigned int k;
425 };
426 };
427 };
428
429 /**
430 * struct rockchip_pll_clock - information about pll clock
431 * @id: platform specific id of the clock.
432 * @name: name of this pll clock.
433 * @parent_names: name of the parent clock.
434 * @num_parents: number of parents
435 * @flags: optional flags for basic clock.
436 * @con_offset: offset of the register for configuring the PLL.
437 * @mode_offset: offset of the register for configuring the PLL-mode.
438 * @mode_shift: offset inside the mode-register for the mode of this pll.
439 * @lock_shift: offset inside the lock register for the lock status.
440 * @type: Type of PLL to be registered.
441 * @pll_flags: hardware-specific flags
442 * @rate_table: Table of usable pll rates
443 *
444 * Flags:
445 * ROCKCHIP_PLL_SYNC_RATE - check rate parameters to match against the
446 * rate_table parameters and ajust them if necessary.
447 */
448 struct rockchip_pll_clock {
449 unsigned int id;
450 const char *name;
451 const char *const *parent_names;
452 u8 num_parents;
453 unsigned long flags;
454 int con_offset;
455 int mode_offset;
456 int mode_shift;
457 int lock_shift;
458 enum rockchip_pll_type type;
459 u8 pll_flags;
460 struct rockchip_pll_rate_table *rate_table;
461 };
462
463 #define ROCKCHIP_PLL_SYNC_RATE BIT(0)
464
465 #define PLL(_type, _id, _name, _pnames, _flags, _con, _mode, _mshift, \
466 _lshift, _pflags, _rtable) \
467 { \
468 .id = _id, \
469 .type = _type, \
470 .name = _name, \
471 .parent_names = _pnames, \
472 .num_parents = ARRAY_SIZE(_pnames), \
473 .flags = CLK_GET_RATE_NOCACHE | _flags, \
474 .con_offset = _con, \
475 .mode_offset = _mode, \
476 .mode_shift = _mshift, \
477 .lock_shift = _lshift, \
478 .pll_flags = _pflags, \
479 .rate_table = _rtable, \
480 }
481
482 struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
483 enum rockchip_pll_type pll_type,
484 const char *name, const char *const *parent_names,
485 u8 num_parents, int con_offset, int grf_lock_offset,
486 int lock_shift, int mode_offset, int mode_shift,
487 struct rockchip_pll_rate_table *rate_table,
488 unsigned long flags, u8 clk_pll_flags);
489
490 struct rockchip_cpuclk_clksel {
491 int reg;
492 u32 val;
493 };
494
495 #define ROCKCHIP_CPUCLK_NUM_DIVIDERS 6
496 #define ROCKCHIP_CPUCLK_MAX_CORES 4
497 struct rockchip_cpuclk_rate_table {
498 unsigned long prate;
499 struct rockchip_cpuclk_clksel divs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
500 struct rockchip_cpuclk_clksel pre_muxs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
501 struct rockchip_cpuclk_clksel post_muxs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
502 };
503
504 /**
505 * struct rockchip_cpuclk_reg_data - register offsets and masks of the cpuclock
506 * @core_reg[]: register offset of the cores setting register
507 * @div_core_shift[]: cores divider offset used to divide the pll value
508 * @div_core_mask[]: cores divider mask
509 * @num_cores: number of cpu cores
510 * @mux_core_reg: register offset of the cores select parent
511 * @mux_core_alt: mux value to select alternate parent
512 * @mux_core_main: mux value to select main parent of core
513 * @mux_core_shift: offset of the core multiplexer
514 * @mux_core_mask: core multiplexer mask
515 */
516 struct rockchip_cpuclk_reg_data {
517 int core_reg[ROCKCHIP_CPUCLK_MAX_CORES];
518 u8 div_core_shift[ROCKCHIP_CPUCLK_MAX_CORES];
519 u32 div_core_mask[ROCKCHIP_CPUCLK_MAX_CORES];
520 int num_cores;
521 int mux_core_reg;
522 u8 mux_core_alt;
523 u8 mux_core_main;
524 u8 mux_core_shift;
525 u32 mux_core_mask;
526 };
527
528 struct clk *rockchip_clk_register_cpuclk(const char *name,
529 const char *const *parent_names, u8 num_parents,
530 const struct rockchip_cpuclk_reg_data *reg_data,
531 const struct rockchip_cpuclk_rate_table *rates,
532 int nrates, void __iomem *reg_base, spinlock_t *lock);
533
534 struct clk *rockchip_clk_register_mmc(const char *name,
535 const char *const *parent_names, u8 num_parents,
536 void __iomem *reg, int shift);
537
538 /*
539 * DDRCLK flags, including method of setting the rate
540 * ROCKCHIP_DDRCLK_SIP: use SIP call to bl31 to change ddrclk rate.
541 */
542 #define ROCKCHIP_DDRCLK_SIP BIT(0)
543
544 struct clk *rockchip_clk_register_ddrclk(const char *name, int flags,
545 const char *const *parent_names,
546 u8 num_parents, int mux_offset,
547 int mux_shift, int mux_width,
548 int div_shift, int div_width,
549 int ddr_flags, void __iomem *reg_base,
550 spinlock_t *lock);
551
552 #define ROCKCHIP_INVERTER_HIWORD_MASK BIT(0)
553
554 struct clk *rockchip_clk_register_inverter(const char *name,
555 const char *const *parent_names, u8 num_parents,
556 void __iomem *reg, int shift, int flags,
557 spinlock_t *lock);
558
559 struct clk *rockchip_clk_register_muxgrf(const char *name,
560 const char *const *parent_names, u8 num_parents,
561 int flags, struct regmap *grf, int reg,
562 int shift, int width, int mux_flags);
563
564 #define PNAME(x) static const char *const x[] __initconst
565
566 enum rockchip_clk_branch_type {
567 branch_composite,
568 branch_mux,
569 branch_muxgrf,
570 branch_divider,
571 branch_fraction_divider,
572 branch_gate,
573 branch_linked_gate,
574 branch_mmc,
575 branch_inverter,
576 branch_factor,
577 branch_ddrclk,
578 branch_half_divider,
579 };
580
581 struct rockchip_clk_branch {
582 unsigned int id;
583 enum rockchip_clk_branch_type branch_type;
584 const char *name;
585 const char *const *parent_names;
586 u8 num_parents;
587 unsigned long flags;
588 int muxdiv_offset;
589 u8 mux_shift;
590 u8 mux_width;
591 u8 mux_flags;
592 u32 *mux_table;
593 int div_offset;
594 u8 div_shift;
595 u8 div_width;
596 u8 div_flags;
597 struct clk_div_table *div_table;
598 int gate_offset;
599 u8 gate_shift;
600 u8 gate_flags;
601 unsigned int linked_clk_id;
602 struct rockchip_clk_branch *child;
603 };
604
605 #define COMPOSITE(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\
606 df, go, gs, gf) \
607 { \
608 .id = _id, \
609 .branch_type = branch_composite, \
610 .name = cname, \
611 .parent_names = pnames, \
612 .num_parents = ARRAY_SIZE(pnames), \
613 .flags = f, \
614 .muxdiv_offset = mo, \
615 .mux_shift = ms, \
616 .mux_width = mw, \
617 .mux_flags = mf, \
618 .div_shift = ds, \
619 .div_width = dw, \
620 .div_flags = df, \
621 .gate_offset = go, \
622 .gate_shift = gs, \
623 .gate_flags = gf, \
624 }
625
626 #define COMPOSITE_DIV_OFFSET(_id, cname, pnames, f, mo, ms, mw, \
627 mf, do, ds, dw, df, go, gs, gf) \
628 { \
629 .id = _id, \
630 .branch_type = branch_composite, \
631 .name = cname, \
632 .parent_names = pnames, \
633 .num_parents = ARRAY_SIZE(pnames), \
634 .flags = f, \
635 .muxdiv_offset = mo, \
636 .mux_shift = ms, \
637 .mux_width = mw, \
638 .mux_flags = mf, \
639 .div_offset = do, \
640 .div_shift = ds, \
641 .div_width = dw, \
642 .div_flags = df, \
643 .gate_offset = go, \
644 .gate_shift = gs, \
645 .gate_flags = gf, \
646 }
647
648 #define COMPOSITE_NOMUX(_id, cname, pname, f, mo, ds, dw, df, \
649 go, gs, gf) \
650 { \
651 .id = _id, \
652 .branch_type = branch_composite, \
653 .name = cname, \
654 .parent_names = (const char *[]){ pname }, \
655 .num_parents = 1, \
656 .flags = f, \
657 .muxdiv_offset = mo, \
658 .div_shift = ds, \
659 .div_width = dw, \
660 .div_flags = df, \
661 .gate_offset = go, \
662 .gate_shift = gs, \
663 .gate_flags = gf, \
664 }
665
666 #define COMPOSITE_NOMUX_DIVTBL(_id, cname, pname, f, mo, ds, dw,\
667 df, dt, go, gs, gf) \
668 { \
669 .id = _id, \
670 .branch_type = branch_composite, \
671 .name = cname, \
672 .parent_names = (const char *[]){ pname }, \
673 .num_parents = 1, \
674 .flags = f, \
675 .muxdiv_offset = mo, \
676 .div_shift = ds, \
677 .div_width = dw, \
678 .div_flags = df, \
679 .div_table = dt, \
680 .gate_offset = go, \
681 .gate_shift = gs, \
682 .gate_flags = gf, \
683 }
684
685 #define COMPOSITE_NODIV(_id, cname, pnames, f, mo, ms, mw, mf, \
686 go, gs, gf) \
687 { \
688 .id = _id, \
689 .branch_type = branch_composite, \
690 .name = cname, \
691 .parent_names = pnames, \
692 .num_parents = ARRAY_SIZE(pnames), \
693 .flags = f, \
694 .muxdiv_offset = mo, \
695 .mux_shift = ms, \
696 .mux_width = mw, \
697 .mux_flags = mf, \
698 .gate_offset = go, \
699 .gate_shift = gs, \
700 .gate_flags = gf, \
701 }
702
703 #define COMPOSITE_NOGATE(_id, cname, pnames, f, mo, ms, mw, mf, \
704 ds, dw, df) \
705 { \
706 .id = _id, \
707 .branch_type = branch_composite, \
708 .name = cname, \
709 .parent_names = pnames, \
710 .num_parents = ARRAY_SIZE(pnames), \
711 .flags = f, \
712 .muxdiv_offset = mo, \
713 .mux_shift = ms, \
714 .mux_width = mw, \
715 .mux_flags = mf, \
716 .div_shift = ds, \
717 .div_width = dw, \
718 .div_flags = df, \
719 .gate_offset = -1, \
720 }
721
722 #define COMPOSITE_NOGATE_DIVTBL(_id, cname, pnames, f, mo, ms, \
723 mw, mf, ds, dw, df, dt) \
724 { \
725 .id = _id, \
726 .branch_type = branch_composite, \
727 .name = cname, \
728 .parent_names = pnames, \
729 .num_parents = ARRAY_SIZE(pnames), \
730 .flags = f, \
731 .muxdiv_offset = mo, \
732 .mux_shift = ms, \
733 .mux_width = mw, \
734 .mux_flags = mf, \
735 .div_shift = ds, \
736 .div_width = dw, \
737 .div_flags = df, \
738 .div_table = dt, \
739 .gate_offset = -1, \
740 }
741
742 #define COMPOSITE_FRAC(_id, cname, pname, f, mo, df, go, gs, gf)\
743 { \
744 .id = _id, \
745 .branch_type = branch_fraction_divider, \
746 .name = cname, \
747 .parent_names = (const char *[]){ pname }, \
748 .num_parents = 1, \
749 .flags = f, \
750 .muxdiv_offset = mo, \
751 .div_shift = 16, \
752 .div_width = 16, \
753 .div_flags = df, \
754 .gate_offset = go, \
755 .gate_shift = gs, \
756 .gate_flags = gf, \
757 }
758
759 #define COMPOSITE_FRACMUX(_id, cname, pname, f, mo, df, go, gs, gf, ch) \
760 { \
761 .id = _id, \
762 .branch_type = branch_fraction_divider, \
763 .name = cname, \
764 .parent_names = (const char *[]){ pname }, \
765 .num_parents = 1, \
766 .flags = f, \
767 .muxdiv_offset = mo, \
768 .div_shift = 16, \
769 .div_width = 16, \
770 .div_flags = df, \
771 .gate_offset = go, \
772 .gate_shift = gs, \
773 .gate_flags = gf, \
774 .child = ch, \
775 }
776
777 #define COMPOSITE_FRACMUX_NOGATE(_id, cname, pname, f, mo, df, ch) \
778 { \
779 .id = _id, \
780 .branch_type = branch_fraction_divider, \
781 .name = cname, \
782 .parent_names = (const char *[]){ pname }, \
783 .num_parents = 1, \
784 .flags = f, \
785 .muxdiv_offset = mo, \
786 .div_shift = 16, \
787 .div_width = 16, \
788 .div_flags = df, \
789 .gate_offset = -1, \
790 .child = ch, \
791 }
792
793 #define COMPOSITE_DDRCLK(_id, cname, pnames, f, mo, ms, mw, \
794 ds, dw, df) \
795 { \
796 .id = _id, \
797 .branch_type = branch_ddrclk, \
798 .name = cname, \
799 .parent_names = pnames, \
800 .num_parents = ARRAY_SIZE(pnames), \
801 .flags = f, \
802 .muxdiv_offset = mo, \
803 .mux_shift = ms, \
804 .mux_width = mw, \
805 .div_shift = ds, \
806 .div_width = dw, \
807 .div_flags = df, \
808 .gate_offset = -1, \
809 }
810
811 #define MUX(_id, cname, pnames, f, o, s, w, mf) \
812 { \
813 .id = _id, \
814 .branch_type = branch_mux, \
815 .name = cname, \
816 .parent_names = pnames, \
817 .num_parents = ARRAY_SIZE(pnames), \
818 .flags = f, \
819 .muxdiv_offset = o, \
820 .mux_shift = s, \
821 .mux_width = w, \
822 .mux_flags = mf, \
823 .gate_offset = -1, \
824 }
825
826 #define MUXTBL(_id, cname, pnames, f, o, s, w, mf, mt) \
827 { \
828 .id = _id, \
829 .branch_type = branch_mux, \
830 .name = cname, \
831 .parent_names = pnames, \
832 .num_parents = ARRAY_SIZE(pnames), \
833 .flags = f, \
834 .muxdiv_offset = o, \
835 .mux_shift = s, \
836 .mux_width = w, \
837 .mux_flags = mf, \
838 .gate_offset = -1, \
839 .mux_table = mt, \
840 }
841
842 #define MUXGRF(_id, cname, pnames, f, o, s, w, mf) \
843 { \
844 .id = _id, \
845 .branch_type = branch_muxgrf, \
846 .name = cname, \
847 .parent_names = pnames, \
848 .num_parents = ARRAY_SIZE(pnames), \
849 .flags = f, \
850 .muxdiv_offset = o, \
851 .mux_shift = s, \
852 .mux_width = w, \
853 .mux_flags = mf, \
854 .gate_offset = -1, \
855 }
856
857 #define DIV(_id, cname, pname, f, o, s, w, df) \
858 { \
859 .id = _id, \
860 .branch_type = branch_divider, \
861 .name = cname, \
862 .parent_names = (const char *[]){ pname }, \
863 .num_parents = 1, \
864 .flags = f, \
865 .muxdiv_offset = o, \
866 .div_shift = s, \
867 .div_width = w, \
868 .div_flags = df, \
869 .gate_offset = -1, \
870 }
871
872 #define DIVTBL(_id, cname, pname, f, o, s, w, df, dt) \
873 { \
874 .id = _id, \
875 .branch_type = branch_divider, \
876 .name = cname, \
877 .parent_names = (const char *[]){ pname }, \
878 .num_parents = 1, \
879 .flags = f, \
880 .muxdiv_offset = o, \
881 .div_shift = s, \
882 .div_width = w, \
883 .div_flags = df, \
884 .div_table = dt, \
885 }
886
887 #define GATE(_id, cname, pname, f, o, b, gf) \
888 { \
889 .id = _id, \
890 .branch_type = branch_gate, \
891 .name = cname, \
892 .parent_names = (const char *[]){ pname }, \
893 .num_parents = 1, \
894 .flags = f, \
895 .gate_offset = o, \
896 .gate_shift = b, \
897 .gate_flags = gf, \
898 }
899
900 #define GATE_LINK(_id, cname, pname, linkedclk, f, o, b, gf) \
901 { \
902 .id = _id, \
903 .branch_type = branch_linked_gate, \
904 .name = cname, \
905 .parent_names = (const char *[]){ pname }, \
906 .linked_clk_id = linkedclk, \
907 .num_parents = 1, \
908 .flags = f, \
909 .gate_offset = o, \
910 .gate_shift = b, \
911 .gate_flags = gf, \
912 }
913
914 #define MMC(_id, cname, pname, offset, shift) \
915 { \
916 .id = _id, \
917 .branch_type = branch_mmc, \
918 .name = cname, \
919 .parent_names = (const char *[]){ pname }, \
920 .num_parents = 1, \
921 .muxdiv_offset = offset, \
922 .div_shift = shift, \
923 }
924
925 #define INVERTER(_id, cname, pname, io, is, if) \
926 { \
927 .id = _id, \
928 .branch_type = branch_inverter, \
929 .name = cname, \
930 .parent_names = (const char *[]){ pname }, \
931 .num_parents = 1, \
932 .muxdiv_offset = io, \
933 .div_shift = is, \
934 .div_flags = if, \
935 }
936
937 #define FACTOR(_id, cname, pname, f, fm, fd) \
938 { \
939 .id = _id, \
940 .branch_type = branch_factor, \
941 .name = cname, \
942 .parent_names = (const char *[]){ pname }, \
943 .num_parents = 1, \
944 .flags = f, \
945 .div_shift = fm, \
946 .div_width = fd, \
947 }
948
949 #define FACTOR_GATE(_id, cname, pname, f, fm, fd, go, gb, gf) \
950 { \
951 .id = _id, \
952 .branch_type = branch_factor, \
953 .name = cname, \
954 .parent_names = (const char *[]){ pname }, \
955 .num_parents = 1, \
956 .flags = f, \
957 .div_shift = fm, \
958 .div_width = fd, \
959 .gate_offset = go, \
960 .gate_shift = gb, \
961 .gate_flags = gf, \
962 }
963
964 #define COMPOSITE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\
965 df, go, gs, gf) \
966 { \
967 .id = _id, \
968 .branch_type = branch_half_divider, \
969 .name = cname, \
970 .parent_names = pnames, \
971 .num_parents = ARRAY_SIZE(pnames), \
972 .flags = f, \
973 .muxdiv_offset = mo, \
974 .mux_shift = ms, \
975 .mux_width = mw, \
976 .mux_flags = mf, \
977 .div_shift = ds, \
978 .div_width = dw, \
979 .div_flags = df, \
980 .gate_offset = go, \
981 .gate_shift = gs, \
982 .gate_flags = gf, \
983 }
984
985 #define COMPOSITE_NOGATE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf, \
986 ds, dw, df) \
987 { \
988 .id = _id, \
989 .branch_type = branch_half_divider, \
990 .name = cname, \
991 .parent_names = pnames, \
992 .num_parents = ARRAY_SIZE(pnames), \
993 .flags = f, \
994 .muxdiv_offset = mo, \
995 .mux_shift = ms, \
996 .mux_width = mw, \
997 .mux_flags = mf, \
998 .div_shift = ds, \
999 .div_width = dw, \
1000 .div_flags = df, \
1001 .gate_offset = -1, \
1002 }
1003
1004 #define COMPOSITE_NOMUX_HALFDIV(_id, cname, pname, f, mo, ds, dw, df, \
1005 go, gs, gf) \
1006 { \
1007 .id = _id, \
1008 .branch_type = branch_half_divider, \
1009 .name = cname, \
1010 .parent_names = (const char *[]){ pname }, \
1011 .num_parents = 1, \
1012 .flags = f, \
1013 .muxdiv_offset = mo, \
1014 .div_shift = ds, \
1015 .div_width = dw, \
1016 .div_flags = df, \
1017 .gate_offset = go, \
1018 .gate_shift = gs, \
1019 .gate_flags = gf, \
1020 }
1021
1022 #define DIV_HALF(_id, cname, pname, f, o, s, w, df) \
1023 { \
1024 .id = _id, \
1025 .branch_type = branch_half_divider, \
1026 .name = cname, \
1027 .parent_names = (const char *[]){ pname }, \
1028 .num_parents = 1, \
1029 .flags = f, \
1030 .muxdiv_offset = o, \
1031 .div_shift = s, \
1032 .div_width = w, \
1033 .div_flags = df, \
1034 .gate_offset = -1, \
1035 }
1036
1037 /* SGRF clocks are only accessible from secure mode, so not controllable */
1038 #define SGRF_GATE(_id, cname, pname) \
1039 FACTOR(_id, cname, pname, 0, 1, 1)
1040
rockchip_clk_get_lookup(struct rockchip_clk_provider * ctx,unsigned int id)1041 static inline struct clk *rockchip_clk_get_lookup(struct rockchip_clk_provider *ctx,
1042 unsigned int id)
1043 {
1044 return ctx->clk_data.clks[id];
1045 }
1046
rockchip_clk_set_lookup(struct rockchip_clk_provider * ctx,struct clk * clk,unsigned int id)1047 static inline void rockchip_clk_set_lookup(struct rockchip_clk_provider *ctx,
1048 struct clk *clk, unsigned int id)
1049 {
1050 ctx->clk_data.clks[id] = clk;
1051 }
1052
1053 struct rockchip_gate_link_platdata {
1054 struct rockchip_clk_provider *ctx;
1055 struct rockchip_clk_branch *clkbr;
1056 };
1057
1058 struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
1059 void __iomem *base, unsigned long nr_clks);
1060 struct rockchip_clk_provider *rockchip_clk_init_early(struct device_node *np,
1061 void __iomem *base, unsigned long nr_clks);
1062 void rockchip_clk_finalize(struct rockchip_clk_provider *ctx);
1063 void rockchip_clk_of_add_provider(struct device_node *np,
1064 struct rockchip_clk_provider *ctx);
1065 unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,
1066 unsigned int nr_clk);
1067 void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
1068 struct rockchip_clk_branch *list,
1069 unsigned int nr_clk);
1070 void rockchip_clk_register_late_branches(struct device *dev,
1071 struct rockchip_clk_provider *ctx,
1072 struct rockchip_clk_branch *list,
1073 unsigned int nr_clk);
1074 void rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
1075 struct rockchip_pll_clock *pll_list,
1076 unsigned int nr_pll, int grf_lock_offset);
1077 void rockchip_clk_register_armclk(struct rockchip_clk_provider *ctx,
1078 unsigned int lookup_id, const char *name,
1079 const char *const *parent_names, u8 num_parents,
1080 const struct rockchip_cpuclk_reg_data *reg_data,
1081 const struct rockchip_cpuclk_rate_table *rates,
1082 int nrates);
1083 void rockchip_clk_protect_critical(const char *const clocks[], int nclocks);
1084 void rockchip_register_restart_notifier(struct rockchip_clk_provider *ctx,
1085 unsigned int reg, void (*cb)(void));
1086
1087 #define ROCKCHIP_SOFTRST_HIWORD_MASK BIT(0)
1088
1089 struct clk *rockchip_clk_register_halfdiv(const char *name,
1090 const char *const *parent_names,
1091 u8 num_parents, void __iomem *base,
1092 int muxdiv_offset, u8 mux_shift,
1093 u8 mux_width, u8 mux_flags,
1094 u8 div_shift, u8 div_width,
1095 u8 div_flags, int gate_offset,
1096 u8 gate_shift, u8 gate_flags,
1097 unsigned long flags,
1098 spinlock_t *lock);
1099
1100 #ifdef CONFIG_RESET_CONTROLLER
1101 void rockchip_register_softrst_lut(struct device_node *np,
1102 const int *lookup_table,
1103 unsigned int num_regs,
1104 void __iomem *base, u8 flags);
1105 #else
rockchip_register_softrst_lut(struct device_node * np,const int * lookup_table,unsigned int num_regs,void __iomem * base,u8 flags)1106 static inline void rockchip_register_softrst_lut(struct device_node *np,
1107 const int *lookup_table,
1108 unsigned int num_regs,
1109 void __iomem *base, u8 flags)
1110 {
1111 }
1112 #endif
1113
rockchip_register_softrst(struct device_node * np,unsigned int num_regs,void __iomem * base,u8 flags)1114 static inline void rockchip_register_softrst(struct device_node *np,
1115 unsigned int num_regs,
1116 void __iomem *base, u8 flags)
1117 {
1118 return rockchip_register_softrst_lut(np, NULL, num_regs, base, flags);
1119 }
1120
1121 void rk3576_rst_init(struct device_node *np, void __iomem *reg_base);
1122 void rk3588_rst_init(struct device_node *np, void __iomem *reg_base);
1123
1124 #endif
1125