1524353eaSIcenowy Zheng // SPDX-License-Identifier: GPL-2.0
2524353eaSIcenowy Zheng /*
3524353eaSIcenowy Zheng  * Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io>
4524353eaSIcenowy Zheng  */
5524353eaSIcenowy Zheng 
6524353eaSIcenowy Zheng #include <linux/clk-provider.h>
7524353eaSIcenowy Zheng #include <linux/of_address.h>
8524353eaSIcenowy Zheng #include <linux/platform_device.h>
9524353eaSIcenowy Zheng 
10524353eaSIcenowy Zheng #include "ccu_common.h"
11524353eaSIcenowy Zheng #include "ccu_reset.h"
12524353eaSIcenowy Zheng 
13524353eaSIcenowy Zheng #include "ccu_div.h"
14524353eaSIcenowy Zheng #include "ccu_gate.h"
15524353eaSIcenowy Zheng #include "ccu_mp.h"
16524353eaSIcenowy Zheng #include "ccu_mult.h"
17524353eaSIcenowy Zheng #include "ccu_nk.h"
18524353eaSIcenowy Zheng #include "ccu_nkm.h"
19524353eaSIcenowy Zheng #include "ccu_nkmp.h"
20524353eaSIcenowy Zheng #include "ccu_nm.h"
21524353eaSIcenowy Zheng 
22524353eaSIcenowy Zheng #include "ccu-sun50i-h6.h"
23524353eaSIcenowy Zheng 
24524353eaSIcenowy Zheng /*
25524353eaSIcenowy Zheng  * The CPU PLL is actually NP clock, with P being /1, /2 or /4. However
26524353eaSIcenowy Zheng  * P should only be used for output frequencies lower than 288 MHz.
27524353eaSIcenowy Zheng  *
28524353eaSIcenowy Zheng  * For now we can just model it as a multiplier clock, and force P to /1.
29524353eaSIcenowy Zheng  *
30524353eaSIcenowy Zheng  * The M factor is present in the register's description, but not in the
31524353eaSIcenowy Zheng  * frequency formula, and it's documented as "M is only used for backdoor
32524353eaSIcenowy Zheng  * testing", so it's not modelled and then force to 0.
33524353eaSIcenowy Zheng  */
34524353eaSIcenowy Zheng #define SUN50I_H6_PLL_CPUX_REG		0x000
35524353eaSIcenowy Zheng static struct ccu_mult pll_cpux_clk = {
36524353eaSIcenowy Zheng 	.enable		= BIT(31),
37524353eaSIcenowy Zheng 	.lock		= BIT(28),
38524353eaSIcenowy Zheng 	.mult		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
39524353eaSIcenowy Zheng 	.common		= {
40524353eaSIcenowy Zheng 		.reg		= 0x000,
41524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-cpux", "osc24M",
42524353eaSIcenowy Zheng 					      &ccu_mult_ops,
43524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
44524353eaSIcenowy Zheng 	},
45524353eaSIcenowy Zheng };
46524353eaSIcenowy Zheng 
47524353eaSIcenowy Zheng /* Some PLLs are input * N / div1 / P. Model them as NKMP with no K */
48524353eaSIcenowy Zheng #define SUN50I_H6_PLL_DDR0_REG		0x010
49524353eaSIcenowy Zheng static struct ccu_nkmp pll_ddr0_clk = {
50524353eaSIcenowy Zheng 	.enable		= BIT(31),
51524353eaSIcenowy Zheng 	.lock		= BIT(28),
52524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
53524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
54524353eaSIcenowy Zheng 	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
55524353eaSIcenowy Zheng 	.common		= {
56524353eaSIcenowy Zheng 		.reg		= 0x010,
57524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-ddr0", "osc24M",
58524353eaSIcenowy Zheng 					      &ccu_nkmp_ops,
59524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
60524353eaSIcenowy Zheng 	},
61524353eaSIcenowy Zheng };
62524353eaSIcenowy Zheng 
63524353eaSIcenowy Zheng #define SUN50I_H6_PLL_PERIPH0_REG	0x020
64524353eaSIcenowy Zheng static struct ccu_nkmp pll_periph0_clk = {
65524353eaSIcenowy Zheng 	.enable		= BIT(31),
66524353eaSIcenowy Zheng 	.lock		= BIT(28),
67524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
68524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
69524353eaSIcenowy Zheng 	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
70524353eaSIcenowy Zheng 	.fixed_post_div	= 4,
71524353eaSIcenowy Zheng 	.common		= {
72524353eaSIcenowy Zheng 		.reg		= 0x020,
73524353eaSIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
74524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-periph0", "osc24M",
75524353eaSIcenowy Zheng 					      &ccu_nkmp_ops,
76524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
77524353eaSIcenowy Zheng 	},
78524353eaSIcenowy Zheng };
79524353eaSIcenowy Zheng 
80524353eaSIcenowy Zheng #define SUN50I_H6_PLL_PERIPH1_REG	0x028
81524353eaSIcenowy Zheng static struct ccu_nkmp pll_periph1_clk = {
82524353eaSIcenowy Zheng 	.enable		= BIT(31),
83524353eaSIcenowy Zheng 	.lock		= BIT(28),
84524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
85524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
86524353eaSIcenowy Zheng 	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
87524353eaSIcenowy Zheng 	.fixed_post_div	= 4,
88524353eaSIcenowy Zheng 	.common		= {
89524353eaSIcenowy Zheng 		.reg		= 0x028,
90524353eaSIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
91524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-periph1", "osc24M",
92524353eaSIcenowy Zheng 					      &ccu_nkmp_ops,
93524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
94524353eaSIcenowy Zheng 	},
95524353eaSIcenowy Zheng };
96524353eaSIcenowy Zheng 
97524353eaSIcenowy Zheng #define SUN50I_H6_PLL_GPU_REG		0x030
98524353eaSIcenowy Zheng static struct ccu_nkmp pll_gpu_clk = {
99524353eaSIcenowy Zheng 	.enable		= BIT(31),
100524353eaSIcenowy Zheng 	.lock		= BIT(28),
101524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
102524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
103524353eaSIcenowy Zheng 	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
104524353eaSIcenowy Zheng 	.common		= {
105524353eaSIcenowy Zheng 		.reg		= 0x030,
106524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-gpu", "osc24M",
107524353eaSIcenowy Zheng 					      &ccu_nkmp_ops,
108524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
109524353eaSIcenowy Zheng 	},
110524353eaSIcenowy Zheng };
111524353eaSIcenowy Zheng 
112524353eaSIcenowy Zheng /*
113524353eaSIcenowy Zheng  * For Video PLLs, the output divider is described as "used for testing"
114524353eaSIcenowy Zheng  * in the user manual. So it's not modelled and forced to 0.
115524353eaSIcenowy Zheng  */
116524353eaSIcenowy Zheng #define SUN50I_H6_PLL_VIDEO0_REG	0x040
117524353eaSIcenowy Zheng static struct ccu_nm pll_video0_clk = {
118524353eaSIcenowy Zheng 	.enable		= BIT(31),
119524353eaSIcenowy Zheng 	.lock		= BIT(28),
120524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
121524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
122524353eaSIcenowy Zheng 	.fixed_post_div	= 4,
123ed443341SJernej Skrabec 	.min_rate	= 288000000,
124ed443341SJernej Skrabec 	.max_rate	= 2400000000UL,
125524353eaSIcenowy Zheng 	.common		= {
126524353eaSIcenowy Zheng 		.reg		= 0x040,
127524353eaSIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
128524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-video0", "osc24M",
129524353eaSIcenowy Zheng 					      &ccu_nm_ops,
130524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
131524353eaSIcenowy Zheng 	},
132524353eaSIcenowy Zheng };
133524353eaSIcenowy Zheng 
134524353eaSIcenowy Zheng #define SUN50I_H6_PLL_VIDEO1_REG	0x048
135524353eaSIcenowy Zheng static struct ccu_nm pll_video1_clk = {
136524353eaSIcenowy Zheng 	.enable		= BIT(31),
137524353eaSIcenowy Zheng 	.lock		= BIT(28),
138524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
139524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
140524353eaSIcenowy Zheng 	.fixed_post_div	= 4,
141ed443341SJernej Skrabec 	.min_rate	= 288000000,
142ed443341SJernej Skrabec 	.max_rate	= 2400000000UL,
143524353eaSIcenowy Zheng 	.common		= {
144524353eaSIcenowy Zheng 		.reg		= 0x048,
145524353eaSIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
146524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-video1", "osc24M",
147524353eaSIcenowy Zheng 					      &ccu_nm_ops,
148524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
149524353eaSIcenowy Zheng 	},
150524353eaSIcenowy Zheng };
151524353eaSIcenowy Zheng 
152524353eaSIcenowy Zheng #define SUN50I_H6_PLL_VE_REG		0x058
153524353eaSIcenowy Zheng static struct ccu_nkmp pll_ve_clk = {
154524353eaSIcenowy Zheng 	.enable		= BIT(31),
155524353eaSIcenowy Zheng 	.lock		= BIT(28),
156524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
157524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
158524353eaSIcenowy Zheng 	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
159524353eaSIcenowy Zheng 	.common		= {
160524353eaSIcenowy Zheng 		.reg		= 0x058,
161524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-ve", "osc24M",
162524353eaSIcenowy Zheng 					      &ccu_nkmp_ops,
163524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
164524353eaSIcenowy Zheng 	},
165524353eaSIcenowy Zheng };
166524353eaSIcenowy Zheng 
167524353eaSIcenowy Zheng #define SUN50I_H6_PLL_DE_REG		0x060
168524353eaSIcenowy Zheng static struct ccu_nkmp pll_de_clk = {
169524353eaSIcenowy Zheng 	.enable		= BIT(31),
170524353eaSIcenowy Zheng 	.lock		= BIT(28),
171524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
172524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
173524353eaSIcenowy Zheng 	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
174524353eaSIcenowy Zheng 	.common		= {
175524353eaSIcenowy Zheng 		.reg		= 0x060,
176524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-de", "osc24M",
177524353eaSIcenowy Zheng 					      &ccu_nkmp_ops,
178524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
179524353eaSIcenowy Zheng 	},
180524353eaSIcenowy Zheng };
181524353eaSIcenowy Zheng 
182524353eaSIcenowy Zheng #define SUN50I_H6_PLL_HSIC_REG		0x070
183524353eaSIcenowy Zheng static struct ccu_nkmp pll_hsic_clk = {
184524353eaSIcenowy Zheng 	.enable		= BIT(31),
185524353eaSIcenowy Zheng 	.lock		= BIT(28),
186524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
187524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
188524353eaSIcenowy Zheng 	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
189524353eaSIcenowy Zheng 	.common		= {
190524353eaSIcenowy Zheng 		.reg		= 0x070,
191524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-hsic", "osc24M",
192524353eaSIcenowy Zheng 					      &ccu_nkmp_ops,
193524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
194524353eaSIcenowy Zheng 	},
195524353eaSIcenowy Zheng };
196524353eaSIcenowy Zheng 
197524353eaSIcenowy Zheng /*
198524353eaSIcenowy Zheng  * The Audio PLL is supposed to have 3 outputs: 2 fixed factors from
199524353eaSIcenowy Zheng  * the base (2x and 4x), and one variable divider (the one true pll audio).
200524353eaSIcenowy Zheng  *
201524353eaSIcenowy Zheng  * We don't have any need for the variable divider for now, so we just
202524353eaSIcenowy Zheng  * hardcode it to match with the clock names.
203524353eaSIcenowy Zheng  */
204524353eaSIcenowy Zheng #define SUN50I_H6_PLL_AUDIO_REG		0x078
205524353eaSIcenowy Zheng static struct ccu_nm pll_audio_base_clk = {
206524353eaSIcenowy Zheng 	.enable		= BIT(31),
207524353eaSIcenowy Zheng 	.lock		= BIT(28),
208524353eaSIcenowy Zheng 	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
209524353eaSIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
210524353eaSIcenowy Zheng 	.common		= {
211524353eaSIcenowy Zheng 		.reg		= 0x078,
212524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-audio-base", "osc24M",
213524353eaSIcenowy Zheng 					      &ccu_nm_ops,
214524353eaSIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
215524353eaSIcenowy Zheng 	},
216524353eaSIcenowy Zheng };
217524353eaSIcenowy Zheng 
218524353eaSIcenowy Zheng static const char * const cpux_parents[] = { "osc24M", "osc32k",
219524353eaSIcenowy Zheng 					     "iosc", "pll-cpux" };
220524353eaSIcenowy Zheng static SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
221524353eaSIcenowy Zheng 		     0x500, 24, 2, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL);
222524353eaSIcenowy Zheng static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x500, 0, 2, 0);
223524353eaSIcenowy Zheng static SUNXI_CCU_M(cpux_apb_clk, "cpux-apb", "cpux", 0x500, 8, 2, 0);
224524353eaSIcenowy Zheng 
225524353eaSIcenowy Zheng static const char * const psi_ahb1_ahb2_parents[] = { "osc24M", "osc32k",
226524353eaSIcenowy Zheng 						      "iosc", "pll-periph0" };
227524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX(psi_ahb1_ahb2_clk, "psi-ahb1-ahb2",
228524353eaSIcenowy Zheng 			     psi_ahb1_ahb2_parents,
229524353eaSIcenowy Zheng 			     0x510,
230524353eaSIcenowy Zheng 			     0, 5,	/* M */
2312852bfbfSIcenowy Zheng 			     8, 2,	/* P */
232524353eaSIcenowy Zheng 			     24, 2,	/* mux */
233524353eaSIcenowy Zheng 			     0);
234524353eaSIcenowy Zheng 
235524353eaSIcenowy Zheng static const char * const ahb3_apb1_apb2_parents[] = { "osc24M", "osc32k",
236524353eaSIcenowy Zheng 						       "psi-ahb1-ahb2",
237524353eaSIcenowy Zheng 						       "pll-periph0" };
238524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX(ahb3_clk, "ahb3", ahb3_apb1_apb2_parents, 0x51c,
239524353eaSIcenowy Zheng 			     0, 5,	/* M */
2402852bfbfSIcenowy Zheng 			     8, 2,	/* P */
241524353eaSIcenowy Zheng 			     24, 2,	/* mux */
242524353eaSIcenowy Zheng 			     0);
243524353eaSIcenowy Zheng 
244524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX(apb1_clk, "apb1", ahb3_apb1_apb2_parents, 0x520,
245524353eaSIcenowy Zheng 			     0, 5,	/* M */
2462852bfbfSIcenowy Zheng 			     8, 2,	/* P */
247524353eaSIcenowy Zheng 			     24, 2,	/* mux */
248524353eaSIcenowy Zheng 			     0);
249524353eaSIcenowy Zheng 
250524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", ahb3_apb1_apb2_parents, 0x524,
251524353eaSIcenowy Zheng 			     0, 5,	/* M */
2522852bfbfSIcenowy Zheng 			     8, 2,	/* P */
253524353eaSIcenowy Zheng 			     24, 2,	/* mux */
254524353eaSIcenowy Zheng 			     0);
255524353eaSIcenowy Zheng 
256524353eaSIcenowy Zheng static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x",
257524353eaSIcenowy Zheng 					     "pll-ddr0", "pll-periph0-4x" };
258524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x540,
259524353eaSIcenowy Zheng 				       0, 3,	/* M */
260524353eaSIcenowy Zheng 				       24, 2,	/* mux */
261524353eaSIcenowy Zheng 				       BIT(31),	/* gate */
262524353eaSIcenowy Zheng 				       CLK_IS_CRITICAL);
263524353eaSIcenowy Zheng 
264524353eaSIcenowy Zheng static const char * const de_parents[] = { "pll-de", "pll-periph0-2x" };
265524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, 0x600,
266524353eaSIcenowy Zheng 				       0, 4,	/* M */
267524353eaSIcenowy Zheng 				       24, 1,	/* mux */
268524353eaSIcenowy Zheng 				       BIT(31),	/* gate */
269ab65e04dSJernej Skrabec 				       CLK_SET_RATE_PARENT);
270524353eaSIcenowy Zheng 
271524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "psi-ahb1-ahb2",
272524353eaSIcenowy Zheng 		      0x60c, BIT(0), 0);
273524353eaSIcenowy Zheng 
274524353eaSIcenowy Zheng static const char * const deinterlace_parents[] = { "pll-periph0",
275524353eaSIcenowy Zheng 						    "pll-periph1" };
276524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace",
277524353eaSIcenowy Zheng 				       deinterlace_parents,
278524353eaSIcenowy Zheng 				       0x620,
279524353eaSIcenowy Zheng 				       0, 4,	/* M */
280524353eaSIcenowy Zheng 				       24, 1,	/* mux */
281524353eaSIcenowy Zheng 				       BIT(31),	/* gate */
282524353eaSIcenowy Zheng 				       0);
283524353eaSIcenowy Zheng 
284524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_deinterlace_clk, "bus-deinterlace", "psi-ahb1-ahb2",
285524353eaSIcenowy Zheng 		      0x62c, BIT(0), 0);
286524353eaSIcenowy Zheng 
287524353eaSIcenowy Zheng static const char * const gpu_parents[] = { "pll-gpu" };
288524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
289524353eaSIcenowy Zheng 				       0, 3,	/* M */
290524353eaSIcenowy Zheng 				       24, 1,	/* mux */
291524353eaSIcenowy Zheng 				       BIT(31),	/* gate */
292524353eaSIcenowy Zheng 				       0);
293524353eaSIcenowy Zheng 
294524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "psi-ahb1-ahb2",
295524353eaSIcenowy Zheng 		      0x67c, BIT(0), 0);
296524353eaSIcenowy Zheng 
297524353eaSIcenowy Zheng /* Also applies to EMCE */
298524353eaSIcenowy Zheng static const char * const ce_parents[] = { "osc24M", "pll-periph0-2x" };
299524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x680,
300524353eaSIcenowy Zheng 					0, 4,	/* M */
301524353eaSIcenowy Zheng 					8, 2,	/* N */
302524353eaSIcenowy Zheng 					24, 1,	/* mux */
303524353eaSIcenowy Zheng 					BIT(31),/* gate */
304524353eaSIcenowy Zheng 					0);
305524353eaSIcenowy Zheng 
306524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "psi-ahb1-ahb2",
307524353eaSIcenowy Zheng 		      0x68c, BIT(0), 0);
308524353eaSIcenowy Zheng 
309524353eaSIcenowy Zheng static const char * const ve_parents[] = { "pll-ve" };
310524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(ve_clk, "ve", ve_parents, 0x690,
311524353eaSIcenowy Zheng 				       0, 3,	/* M */
312524353eaSIcenowy Zheng 				       24, 1,	/* mux */
313524353eaSIcenowy Zheng 				       BIT(31),	/* gate */
314524353eaSIcenowy Zheng 				       0);
315524353eaSIcenowy Zheng 
316524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "psi-ahb1-ahb2",
317524353eaSIcenowy Zheng 		      0x69c, BIT(0), 0);
318524353eaSIcenowy Zheng 
319524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(emce_clk, "emce", ce_parents, 0x6b0,
320524353eaSIcenowy Zheng 					0, 4,	/* M */
321524353eaSIcenowy Zheng 					8, 2,	/* N */
322524353eaSIcenowy Zheng 					24, 1,	/* mux */
323524353eaSIcenowy Zheng 					BIT(31),/* gate */
324524353eaSIcenowy Zheng 					0);
325524353eaSIcenowy Zheng 
326524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_emce_clk, "bus-emce", "psi-ahb1-ahb2",
327524353eaSIcenowy Zheng 		      0x6bc, BIT(0), 0);
328524353eaSIcenowy Zheng 
329524353eaSIcenowy Zheng static const char * const vp9_parents[] = { "pll-ve", "pll-periph0-2x" };
330524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(vp9_clk, "vp9", vp9_parents, 0x6c0,
331524353eaSIcenowy Zheng 				       0, 3,	/* M */
332524353eaSIcenowy Zheng 				       24, 1,	/* mux */
333524353eaSIcenowy Zheng 				       BIT(31),	/* gate */
334524353eaSIcenowy Zheng 				       0);
335524353eaSIcenowy Zheng 
336524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_vp9_clk, "bus-vp9", "psi-ahb1-ahb2",
337524353eaSIcenowy Zheng 		      0x6cc, BIT(0), 0);
338524353eaSIcenowy Zheng 
339524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "psi-ahb1-ahb2",
340524353eaSIcenowy Zheng 		      0x70c, BIT(0), 0);
341524353eaSIcenowy Zheng 
342524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "psi-ahb1-ahb2",
343524353eaSIcenowy Zheng 		      0x71c, BIT(0), 0);
344524353eaSIcenowy Zheng 
345524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "psi-ahb1-ahb2",
346524353eaSIcenowy Zheng 		      0x72c, BIT(0), 0);
347524353eaSIcenowy Zheng 
348524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "psi-ahb1-ahb2",
349524353eaSIcenowy Zheng 		      0x73c, BIT(0), 0);
350524353eaSIcenowy Zheng 
351524353eaSIcenowy Zheng static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 0x740, BIT(31), 0);
352524353eaSIcenowy Zheng 
353524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "psi-ahb1-ahb2",
354524353eaSIcenowy Zheng 		      0x78c, BIT(0), 0);
355524353eaSIcenowy Zheng 
356524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_psi_clk, "bus-psi", "psi-ahb1-ahb2",
357524353eaSIcenowy Zheng 		      0x79c, BIT(0), 0);
358524353eaSIcenowy Zheng 
35958c0f798SRongyi Chen static SUNXI_CCU_GATE(bus_pwm_clk, "bus-pwm", "apb1", 0x7ac, BIT(0), 0);
360524353eaSIcenowy Zheng 
361524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_iommu_clk, "bus-iommu", "apb1", 0x7bc, BIT(0), 0);
362524353eaSIcenowy Zheng 
363524353eaSIcenowy Zheng static const char * const dram_parents[] = { "pll-ddr0" };
364524353eaSIcenowy Zheng static struct ccu_div dram_clk = {
365524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV(0, 2),
366524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
367524353eaSIcenowy Zheng 	.common	= {
368524353eaSIcenowy Zheng 		.reg		= 0x800,
369524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("dram",
370524353eaSIcenowy Zheng 						      dram_parents,
371524353eaSIcenowy Zheng 						      &ccu_div_ops,
372524353eaSIcenowy Zheng 						      CLK_IS_CRITICAL),
373524353eaSIcenowy Zheng 	},
374524353eaSIcenowy Zheng };
375524353eaSIcenowy Zheng 
376524353eaSIcenowy Zheng static SUNXI_CCU_GATE(mbus_dma_clk, "mbus-dma", "mbus",
377524353eaSIcenowy Zheng 		      0x804, BIT(0), 0);
378524353eaSIcenowy Zheng static SUNXI_CCU_GATE(mbus_ve_clk, "mbus-ve", "mbus",
379524353eaSIcenowy Zheng 		      0x804, BIT(1), 0);
380524353eaSIcenowy Zheng static SUNXI_CCU_GATE(mbus_ce_clk, "mbus-ce", "mbus",
381524353eaSIcenowy Zheng 		      0x804, BIT(2), 0);
382524353eaSIcenowy Zheng static SUNXI_CCU_GATE(mbus_ts_clk, "mbus-ts", "mbus",
383524353eaSIcenowy Zheng 		      0x804, BIT(3), 0);
384524353eaSIcenowy Zheng static SUNXI_CCU_GATE(mbus_nand_clk, "mbus-nand", "mbus",
385524353eaSIcenowy Zheng 		      0x804, BIT(5), 0);
386524353eaSIcenowy Zheng static SUNXI_CCU_GATE(mbus_csi_clk, "mbus-csi", "mbus",
387524353eaSIcenowy Zheng 		      0x804, BIT(8), 0);
388524353eaSIcenowy Zheng static SUNXI_CCU_GATE(mbus_deinterlace_clk, "mbus-deinterlace", "mbus",
389524353eaSIcenowy Zheng 		      0x804, BIT(11), 0);
390524353eaSIcenowy Zheng 
391524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "psi-ahb1-ahb2",
392524353eaSIcenowy Zheng 		      0x80c, BIT(0), CLK_IS_CRITICAL);
393524353eaSIcenowy Zheng 
394524353eaSIcenowy Zheng static const char * const nand_spi_parents[] = { "osc24M", "pll-periph0",
395524353eaSIcenowy Zheng 					     "pll-periph1", "pll-periph0-2x",
396524353eaSIcenowy Zheng 					     "pll-periph1-2x" };
397524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(nand0_clk, "nand0", nand_spi_parents, 0x810,
398524353eaSIcenowy Zheng 					0, 4,	/* M */
399524353eaSIcenowy Zheng 					8, 2,	/* N */
400524353eaSIcenowy Zheng 					24, 3,	/* mux */
401524353eaSIcenowy Zheng 					BIT(31),/* gate */
402524353eaSIcenowy Zheng 					0);
403524353eaSIcenowy Zheng 
404524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(nand1_clk, "nand1", nand_spi_parents, 0x814,
405524353eaSIcenowy Zheng 					0, 4,	/* M */
406524353eaSIcenowy Zheng 					8, 2,	/* N */
407524353eaSIcenowy Zheng 					24, 3,	/* mux */
408524353eaSIcenowy Zheng 					BIT(31),/* gate */
409524353eaSIcenowy Zheng 					0);
410524353eaSIcenowy Zheng 
411524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb3", 0x82c, BIT(0), 0);
412524353eaSIcenowy Zheng 
413524353eaSIcenowy Zheng static const char * const mmc_parents[] = { "osc24M", "pll-periph0-2x",
414524353eaSIcenowy Zheng 					    "pll-periph1-2x" };
415c2ff8383SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc0_clk, "mmc0", mmc_parents, 0x830,
416524353eaSIcenowy Zheng 					  0, 4,		/* M */
417524353eaSIcenowy Zheng 					  8, 2,		/* N */
418db754893SJagan Teki 					  24, 2,	/* mux */
419524353eaSIcenowy Zheng 					  BIT(31),	/* gate */
420c2ff8383SIcenowy Zheng 					  2,		/* post-div */
421524353eaSIcenowy Zheng 					  0);
422524353eaSIcenowy Zheng 
423c2ff8383SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc1_clk, "mmc1", mmc_parents, 0x834,
424524353eaSIcenowy Zheng 					  0, 4,		/* M */
425524353eaSIcenowy Zheng 					  8, 2,		/* N */
426db754893SJagan Teki 					  24, 2,	/* mux */
427524353eaSIcenowy Zheng 					  BIT(31),	/* gate */
428c2ff8383SIcenowy Zheng 					  2,		/* post-div */
429524353eaSIcenowy Zheng 					  0);
430524353eaSIcenowy Zheng 
431c2ff8383SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc2_clk, "mmc2", mmc_parents, 0x838,
432524353eaSIcenowy Zheng 					  0, 4,		/* M */
433524353eaSIcenowy Zheng 					  8, 2,		/* N */
434db754893SJagan Teki 					  24, 2,	/* mux */
435524353eaSIcenowy Zheng 					  BIT(31),	/* gate */
436c2ff8383SIcenowy Zheng 					  2,		/* post-div */
437524353eaSIcenowy Zheng 					  0);
438524353eaSIcenowy Zheng 
439524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb3", 0x84c, BIT(0), 0);
440524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb3", 0x84c, BIT(1), 0);
441524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb3", 0x84c, BIT(2), 0);
442524353eaSIcenowy Zheng 
443524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 0x90c, BIT(0), 0);
444524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 0x90c, BIT(1), 0);
445524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 0x90c, BIT(2), 0);
446524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2", 0x90c, BIT(3), 0);
447524353eaSIcenowy Zheng 
448524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 0x91c, BIT(0), 0);
449524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 0x91c, BIT(1), 0);
450524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2", 0x91c, BIT(2), 0);
451524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c3_clk, "bus-i2c3", "apb2", 0x91c, BIT(3), 0);
452524353eaSIcenowy Zheng 
453524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_scr0_clk, "bus-scr0", "apb2", 0x93c, BIT(0), 0);
454524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_scr1_clk, "bus-scr1", "apb2", 0x93c, BIT(1), 0);
455524353eaSIcenowy Zheng 
456524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", nand_spi_parents, 0x940,
457524353eaSIcenowy Zheng 					0, 4,	/* M */
458524353eaSIcenowy Zheng 					8, 2,	/* N */
459524353eaSIcenowy Zheng 					24, 3,	/* mux */
460524353eaSIcenowy Zheng 					BIT(31),/* gate */
461524353eaSIcenowy Zheng 					0);
462524353eaSIcenowy Zheng 
463524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", nand_spi_parents, 0x944,
464524353eaSIcenowy Zheng 					0, 4,	/* M */
465524353eaSIcenowy Zheng 					8, 2,	/* N */
466524353eaSIcenowy Zheng 					24, 3,	/* mux */
467524353eaSIcenowy Zheng 					BIT(31),/* gate */
468524353eaSIcenowy Zheng 					0);
469524353eaSIcenowy Zheng 
470524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb3", 0x96c, BIT(0), 0);
471524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb3", 0x96c, BIT(1), 0);
472524353eaSIcenowy Zheng 
473524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb3", 0x97c, BIT(0), 0);
474524353eaSIcenowy Zheng 
475524353eaSIcenowy Zheng static const char * const ts_parents[] = { "osc24M", "pll-periph0" };
476524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x9b0,
477524353eaSIcenowy Zheng 					0, 4,	/* M */
478524353eaSIcenowy Zheng 					8, 2,	/* N */
479524353eaSIcenowy Zheng 					24, 1,	/* mux */
480524353eaSIcenowy Zheng 					BIT(31),/* gate */
481524353eaSIcenowy Zheng 					0);
482524353eaSIcenowy Zheng 
483524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ts_clk, "bus-ts", "ahb3", 0x9bc, BIT(0), 0);
484524353eaSIcenowy Zheng 
485524353eaSIcenowy Zheng static const char * const ir_tx_parents[] = { "osc32k", "osc24M" };
486524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ir_tx_clk, "ir-tx", ir_tx_parents, 0x9c0,
487524353eaSIcenowy Zheng 					0, 4,	/* M */
488524353eaSIcenowy Zheng 					8, 2,	/* N */
489524353eaSIcenowy Zheng 					24, 1,	/* mux */
490524353eaSIcenowy Zheng 					BIT(31),/* gate */
491524353eaSIcenowy Zheng 					0);
492524353eaSIcenowy Zheng 
493524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ir_tx_clk, "bus-ir-tx", "apb1", 0x9cc, BIT(0), 0);
494524353eaSIcenowy Zheng 
495524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ths_clk, "bus-ths", "apb1", 0x9fc, BIT(0), 0);
496524353eaSIcenowy Zheng 
497524353eaSIcenowy Zheng static const char * const audio_parents[] = { "pll-audio", "pll-audio-2x", "pll-audio-4x" };
498524353eaSIcenowy Zheng static struct ccu_div i2s3_clk = {
499524353eaSIcenowy Zheng 	.enable		= BIT(31),
500524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
501524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
502524353eaSIcenowy Zheng 	.common		= {
503524353eaSIcenowy Zheng 		.reg		= 0xa0c,
504524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("i2s3",
505524353eaSIcenowy Zheng 						      audio_parents,
506524353eaSIcenowy Zheng 						      &ccu_div_ops,
507524353eaSIcenowy Zheng 						      0),
508524353eaSIcenowy Zheng 	},
509524353eaSIcenowy Zheng };
510524353eaSIcenowy Zheng 
511524353eaSIcenowy Zheng static struct ccu_div i2s0_clk = {
512524353eaSIcenowy Zheng 	.enable		= BIT(31),
513524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
514524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
515524353eaSIcenowy Zheng 	.common		= {
516524353eaSIcenowy Zheng 		.reg		= 0xa10,
517524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("i2s0",
518524353eaSIcenowy Zheng 						      audio_parents,
519524353eaSIcenowy Zheng 						      &ccu_div_ops,
520524353eaSIcenowy Zheng 						      0),
521524353eaSIcenowy Zheng 	},
522524353eaSIcenowy Zheng };
523524353eaSIcenowy Zheng 
524524353eaSIcenowy Zheng static struct ccu_div i2s1_clk = {
525524353eaSIcenowy Zheng 	.enable		= BIT(31),
526524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
527524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
528524353eaSIcenowy Zheng 	.common		= {
529524353eaSIcenowy Zheng 		.reg		= 0xa14,
530524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("i2s1",
531524353eaSIcenowy Zheng 						      audio_parents,
532524353eaSIcenowy Zheng 						      &ccu_div_ops,
533524353eaSIcenowy Zheng 						      0),
534524353eaSIcenowy Zheng 	},
535524353eaSIcenowy Zheng };
536524353eaSIcenowy Zheng 
537524353eaSIcenowy Zheng static struct ccu_div i2s2_clk = {
538524353eaSIcenowy Zheng 	.enable		= BIT(31),
539524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
540524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
541524353eaSIcenowy Zheng 	.common		= {
542524353eaSIcenowy Zheng 		.reg		= 0xa18,
543524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("i2s2",
544524353eaSIcenowy Zheng 						      audio_parents,
545524353eaSIcenowy Zheng 						      &ccu_div_ops,
546524353eaSIcenowy Zheng 						      0),
547524353eaSIcenowy Zheng 	},
548524353eaSIcenowy Zheng };
549524353eaSIcenowy Zheng 
550524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 0xa1c, BIT(0), 0);
551524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1", 0xa1c, BIT(1), 0);
552524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s2_clk, "bus-i2s2", "apb1", 0xa1c, BIT(2), 0);
553524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s3_clk, "bus-i2s3", "apb1", 0xa1c, BIT(3), 0);
554524353eaSIcenowy Zheng 
555524353eaSIcenowy Zheng static struct ccu_div spdif_clk = {
556524353eaSIcenowy Zheng 	.enable		= BIT(31),
557524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
558524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
559524353eaSIcenowy Zheng 	.common		= {
560524353eaSIcenowy Zheng 		.reg		= 0xa20,
561524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("spdif",
562524353eaSIcenowy Zheng 						      audio_parents,
563524353eaSIcenowy Zheng 						      &ccu_div_ops,
564524353eaSIcenowy Zheng 						      0),
565524353eaSIcenowy Zheng 	},
566524353eaSIcenowy Zheng };
567524353eaSIcenowy Zheng 
568524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb1", 0xa2c, BIT(0), 0);
569524353eaSIcenowy Zheng 
570524353eaSIcenowy Zheng static struct ccu_div dmic_clk = {
571524353eaSIcenowy Zheng 	.enable		= BIT(31),
572524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
573524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
574524353eaSIcenowy Zheng 	.common		= {
575524353eaSIcenowy Zheng 		.reg		= 0xa40,
576524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("dmic",
577524353eaSIcenowy Zheng 						      audio_parents,
578524353eaSIcenowy Zheng 						      &ccu_div_ops,
579524353eaSIcenowy Zheng 						      0),
580524353eaSIcenowy Zheng 	},
581524353eaSIcenowy Zheng };
582524353eaSIcenowy Zheng 
583524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_dmic_clk, "bus-dmic", "apb1", 0xa4c, BIT(0), 0);
584524353eaSIcenowy Zheng 
585524353eaSIcenowy Zheng static struct ccu_div audio_hub_clk = {
586524353eaSIcenowy Zheng 	.enable		= BIT(31),
587524353eaSIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
588524353eaSIcenowy Zheng 	.mux		= _SUNXI_CCU_MUX(24, 2),
589524353eaSIcenowy Zheng 	.common		= {
590524353eaSIcenowy Zheng 		.reg		= 0xa60,
591524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("audio-hub",
592524353eaSIcenowy Zheng 						      audio_parents,
593524353eaSIcenowy Zheng 						      &ccu_div_ops,
594524353eaSIcenowy Zheng 						      0),
595524353eaSIcenowy Zheng 	},
596524353eaSIcenowy Zheng };
597524353eaSIcenowy Zheng 
598524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_audio_hub_clk, "bus-audio-hub", "apb1", 0xa6c, BIT(0), 0);
599524353eaSIcenowy Zheng 
600524353eaSIcenowy Zheng /*
601524353eaSIcenowy Zheng  * There are OHCI 12M clock source selection bits for 2 USB 2.0 ports.
602524353eaSIcenowy Zheng  * We will force them to 0 (12M divided from 48M).
603524353eaSIcenowy Zheng  */
604524353eaSIcenowy Zheng #define SUN50I_H6_USB0_CLK_REG		0xa70
605524353eaSIcenowy Zheng #define SUN50I_H6_USB3_CLK_REG		0xa7c
606524353eaSIcenowy Zheng 
607524353eaSIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc12M", 0xa70, BIT(31), 0);
608524353eaSIcenowy Zheng static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 0xa70, BIT(29), 0);
609524353eaSIcenowy Zheng 
610524353eaSIcenowy Zheng static SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "osc24M", 0xa74, BIT(29), 0);
611524353eaSIcenowy Zheng 
612524353eaSIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci3_clk, "usb-ohci3", "osc12M", 0xa7c, BIT(31), 0);
613524353eaSIcenowy Zheng static SUNXI_CCU_GATE(usb_phy3_clk, "usb-phy3", "osc12M", 0xa7c, BIT(29), 0);
614524353eaSIcenowy Zheng static SUNXI_CCU_GATE(usb_hsic_12m_clk, "usb-hsic-12M", "osc12M", 0xa7c, BIT(27), 0);
615524353eaSIcenowy Zheng static SUNXI_CCU_GATE(usb_hsic_clk, "usb-hsic", "pll-hsic", 0xa7c, BIT(26), 0);
616524353eaSIcenowy Zheng 
617524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb3", 0xa8c, BIT(0), 0);
618524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci3_clk, "bus-ohci3", "ahb3", 0xa8c, BIT(3), 0);
619524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb3", 0xa8c, BIT(4), 0);
620524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_xhci_clk, "bus-xhci", "ahb3", 0xa8c, BIT(5), 0);
621524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci3_clk, "bus-ehci3", "ahb3", 0xa8c, BIT(7), 0);
622524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb3", 0xa8c, BIT(8), 0);
623524353eaSIcenowy Zheng 
624524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pcie_ref_100m_clk, "pcie-ref-100M",
625524353eaSIcenowy Zheng 			"pll-periph0-4x", 24, 1, 0);
626524353eaSIcenowy Zheng static SUNXI_CCU_GATE(pcie_ref_clk, "pcie-ref", "pcie-ref-100M",
627524353eaSIcenowy Zheng 		      0xab0, BIT(31), 0);
628524353eaSIcenowy Zheng static SUNXI_CCU_GATE(pcie_ref_out_clk, "pcie-ref-out", "pcie-ref",
629524353eaSIcenowy Zheng 		      0xab0, BIT(30), 0);
630524353eaSIcenowy Zheng 
631524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_GATE(pcie_maxi_clk, "pcie-maxi",
632524353eaSIcenowy Zheng 			     "pll-periph0", 0xab4,
633524353eaSIcenowy Zheng 			     0, 4,	/* M */
634524353eaSIcenowy Zheng 			     BIT(31),	/* gate */
635524353eaSIcenowy Zheng 			     0);
636524353eaSIcenowy Zheng 
637524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_GATE(pcie_aux_clk, "pcie-aux", "osc24M", 0xab8,
638524353eaSIcenowy Zheng 			     0, 5,	/* M */
639524353eaSIcenowy Zheng 			     BIT(31),	/* gate */
640524353eaSIcenowy Zheng 			     0);
641524353eaSIcenowy Zheng 
642524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_pcie_clk, "bus-pcie", "psi-ahb1-ahb2",
643524353eaSIcenowy Zheng 		      0xabc, BIT(0), 0);
644524353eaSIcenowy Zheng 
645524353eaSIcenowy Zheng static const char * const hdmi_parents[] = { "pll-video0", "pll-video1",
646524353eaSIcenowy Zheng 					      "pll-video1-4x" };
647524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents, 0xb00,
648524353eaSIcenowy Zheng 				 0, 4,		/* M */
649524353eaSIcenowy Zheng 				 24, 2,		/* mux */
650524353eaSIcenowy Zheng 				 BIT(31),	/* gate */
651524353eaSIcenowy Zheng 				 0);
652524353eaSIcenowy Zheng 
653f422fa55SIcenowy Zheng static SUNXI_CCU_GATE(hdmi_slow_clk, "hdmi-slow", "osc24M", 0xb04, BIT(31), 0);
654f422fa55SIcenowy Zheng 
655524353eaSIcenowy Zheng static const char * const hdmi_cec_parents[] = { "osc32k", "pll-periph0-2x" };
656524353eaSIcenowy Zheng static const struct ccu_mux_fixed_prediv hdmi_cec_predivs[] = {
657524353eaSIcenowy Zheng 	{ .index = 1, .div = 36621 },
658524353eaSIcenowy Zheng };
65926fae7a4SJernej Skrabec 
66026fae7a4SJernej Skrabec #define SUN50I_H6_HDMI_CEC_CLK_REG		0xb10
661524353eaSIcenowy Zheng static struct ccu_mux hdmi_cec_clk = {
662524353eaSIcenowy Zheng 	.enable		= BIT(31),
663524353eaSIcenowy Zheng 
664524353eaSIcenowy Zheng 	.mux		= {
665524353eaSIcenowy Zheng 		.shift	= 24,
666524353eaSIcenowy Zheng 		.width	= 2,
667524353eaSIcenowy Zheng 
668524353eaSIcenowy Zheng 		.fixed_predivs	= hdmi_cec_predivs,
669524353eaSIcenowy Zheng 		.n_predivs	= ARRAY_SIZE(hdmi_cec_predivs),
670524353eaSIcenowy Zheng 	},
671524353eaSIcenowy Zheng 
672524353eaSIcenowy Zheng 	.common		= {
673524353eaSIcenowy Zheng 		.reg		= 0xb10,
674524353eaSIcenowy Zheng 		.features	= CCU_FEATURE_VARIABLE_PREDIV,
675524353eaSIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("hdmi-cec",
676524353eaSIcenowy Zheng 						      hdmi_cec_parents,
677524353eaSIcenowy Zheng 						      &ccu_mux_ops,
678524353eaSIcenowy Zheng 						      0),
679524353eaSIcenowy Zheng 	},
680524353eaSIcenowy Zheng };
681524353eaSIcenowy Zheng 
682524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_hdmi_clk, "bus-hdmi", "ahb3", 0xb1c, BIT(0), 0);
683524353eaSIcenowy Zheng 
684524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_top_clk, "bus-tcon-top", "ahb3",
685524353eaSIcenowy Zheng 		      0xb5c, BIT(0), 0);
686524353eaSIcenowy Zheng 
687524353eaSIcenowy Zheng static const char * const tcon_lcd0_parents[] = { "pll-video0",
688524353eaSIcenowy Zheng 						  "pll-video0-4x",
689524353eaSIcenowy Zheng 						  "pll-video1" };
690524353eaSIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(tcon_lcd0_clk, "tcon-lcd0",
691524353eaSIcenowy Zheng 			       tcon_lcd0_parents, 0xb60,
692524353eaSIcenowy Zheng 			       24, 3,	/* mux */
693524353eaSIcenowy Zheng 			       BIT(31),	/* gate */
694524353eaSIcenowy Zheng 			       0);
695524353eaSIcenowy Zheng 
696524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_lcd0_clk, "bus-tcon-lcd0", "ahb3",
697524353eaSIcenowy Zheng 		      0xb7c, BIT(0), 0);
698524353eaSIcenowy Zheng 
699524353eaSIcenowy Zheng static const char * const tcon_tv0_parents[] = { "pll-video0",
700524353eaSIcenowy Zheng 						 "pll-video0-4x",
701524353eaSIcenowy Zheng 						 "pll-video1",
702524353eaSIcenowy Zheng 						 "pll-video1-4x" };
703524353eaSIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(tcon_tv0_clk, "tcon-tv0",
704524353eaSIcenowy Zheng 				  tcon_tv0_parents, 0xb80,
705524353eaSIcenowy Zheng 				  0, 4,		/* M */
706524353eaSIcenowy Zheng 				  8, 2,		/* P */
707524353eaSIcenowy Zheng 				  24, 3,	/* mux */
708524353eaSIcenowy Zheng 				  BIT(31),	/* gate */
709524353eaSIcenowy Zheng 				  0);
710524353eaSIcenowy Zheng 
711524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_tv0_clk, "bus-tcon-tv0", "ahb3",
712524353eaSIcenowy Zheng 		      0xb9c, BIT(0), 0);
713524353eaSIcenowy Zheng 
714524353eaSIcenowy Zheng static SUNXI_CCU_GATE(csi_cci_clk, "csi-cci", "osc24M", 0xc00, BIT(0), 0);
715524353eaSIcenowy Zheng 
716524353eaSIcenowy Zheng static const char * const csi_top_parents[] = { "pll-video0", "pll-ve",
717524353eaSIcenowy Zheng 					      "pll-periph0" };
718524353eaSIcenowy Zheng static const u8 csi_top_table[] = { 0, 2, 3 };
719524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_top_clk, "csi-top",
720524353eaSIcenowy Zheng 				       csi_top_parents, csi_top_table, 0xc04,
721524353eaSIcenowy Zheng 				       0, 4,	/* M */
722524353eaSIcenowy Zheng 				       24, 3,	/* mux */
723524353eaSIcenowy Zheng 				       BIT(31),	/* gate */
724524353eaSIcenowy Zheng 				       0);
725524353eaSIcenowy Zheng 
726524353eaSIcenowy Zheng static const char * const csi_mclk_parents[] = { "osc24M", "pll-video0",
727524353eaSIcenowy Zheng 					       "pll-periph0", "pll-periph1" };
728524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk, "csi-mclk",
729524353eaSIcenowy Zheng 				 csi_mclk_parents, 0xc08,
730524353eaSIcenowy Zheng 				 0, 5,		/* M */
731524353eaSIcenowy Zheng 				 24, 3,		/* mux */
732524353eaSIcenowy Zheng 				 BIT(31),	/* gate */
733524353eaSIcenowy Zheng 				 0);
734524353eaSIcenowy Zheng 
735524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb3", 0xc2c, BIT(0), 0);
736524353eaSIcenowy Zheng 
737524353eaSIcenowy Zheng static const char * const hdcp_parents[] = { "pll-periph0", "pll-periph1" };
738524353eaSIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(hdcp_clk, "hdcp", hdcp_parents, 0xc40,
739524353eaSIcenowy Zheng 				 0, 4,		/* M */
740524353eaSIcenowy Zheng 				 24, 2,		/* mux */
741524353eaSIcenowy Zheng 				 BIT(31),	/* gate */
742524353eaSIcenowy Zheng 				 0);
743524353eaSIcenowy Zheng 
744524353eaSIcenowy Zheng static SUNXI_CCU_GATE(bus_hdcp_clk, "bus-hdcp", "ahb3", 0xc4c, BIT(0), 0);
745524353eaSIcenowy Zheng 
746524353eaSIcenowy Zheng /* Fixed factor clocks */
747524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(osc12M_clk, "osc12M", "osc24M", 2, 1, 0);
748524353eaSIcenowy Zheng 
749524353eaSIcenowy Zheng /*
750524353eaSIcenowy Zheng  * The divider of pll-audio is fixed to 8 now, as pll-audio-4x has a
751524353eaSIcenowy Zheng  * fixed post-divider 2.
752524353eaSIcenowy Zheng  */
753524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",
754524353eaSIcenowy Zheng 			"pll-audio-base", 8, 1, CLK_SET_RATE_PARENT);
755524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x",
756524353eaSIcenowy Zheng 			"pll-audio-base", 4, 1, CLK_SET_RATE_PARENT);
757524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x",
758524353eaSIcenowy Zheng 			"pll-audio-base", 2, 1, CLK_SET_RATE_PARENT);
759524353eaSIcenowy Zheng 
760524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph0_4x_clk, "pll-periph0-4x",
761524353eaSIcenowy Zheng 			"pll-periph0", 1, 4, 0);
762524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x",
763524353eaSIcenowy Zheng 			"pll-periph0", 1, 2, 0);
764524353eaSIcenowy Zheng 
765524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph1_4x_clk, "pll-periph1-4x",
766524353eaSIcenowy Zheng 			"pll-periph1", 1, 4, 0);
767524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph1_2x_clk, "pll-periph1-2x",
768524353eaSIcenowy Zheng 			"pll-periph1", 1, 2, 0);
769524353eaSIcenowy Zheng 
770524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_video0_4x_clk, "pll-video0-4x",
771524353eaSIcenowy Zheng 			"pll-video0", 1, 4, CLK_SET_RATE_PARENT);
772524353eaSIcenowy Zheng 
773524353eaSIcenowy Zheng static CLK_FIXED_FACTOR(pll_video1_4x_clk, "pll-video1-4x",
774524353eaSIcenowy Zheng 			"pll-video1", 1, 4, CLK_SET_RATE_PARENT);
775524353eaSIcenowy Zheng 
776524353eaSIcenowy Zheng static struct ccu_common *sun50i_h6_ccu_clks[] = {
777524353eaSIcenowy Zheng 	&pll_cpux_clk.common,
778524353eaSIcenowy Zheng 	&pll_ddr0_clk.common,
779524353eaSIcenowy Zheng 	&pll_periph0_clk.common,
780524353eaSIcenowy Zheng 	&pll_periph1_clk.common,
781524353eaSIcenowy Zheng 	&pll_gpu_clk.common,
782524353eaSIcenowy Zheng 	&pll_video0_clk.common,
783524353eaSIcenowy Zheng 	&pll_video1_clk.common,
784524353eaSIcenowy Zheng 	&pll_ve_clk.common,
785524353eaSIcenowy Zheng 	&pll_de_clk.common,
786524353eaSIcenowy Zheng 	&pll_hsic_clk.common,
787524353eaSIcenowy Zheng 	&pll_audio_base_clk.common,
788524353eaSIcenowy Zheng 	&cpux_clk.common,
789524353eaSIcenowy Zheng 	&axi_clk.common,
790524353eaSIcenowy Zheng 	&cpux_apb_clk.common,
791524353eaSIcenowy Zheng 	&psi_ahb1_ahb2_clk.common,
792524353eaSIcenowy Zheng 	&ahb3_clk.common,
793524353eaSIcenowy Zheng 	&apb1_clk.common,
794524353eaSIcenowy Zheng 	&apb2_clk.common,
795524353eaSIcenowy Zheng 	&mbus_clk.common,
796524353eaSIcenowy Zheng 	&de_clk.common,
797524353eaSIcenowy Zheng 	&bus_de_clk.common,
798524353eaSIcenowy Zheng 	&deinterlace_clk.common,
799524353eaSIcenowy Zheng 	&bus_deinterlace_clk.common,
800524353eaSIcenowy Zheng 	&gpu_clk.common,
801524353eaSIcenowy Zheng 	&bus_gpu_clk.common,
802524353eaSIcenowy Zheng 	&ce_clk.common,
803524353eaSIcenowy Zheng 	&bus_ce_clk.common,
804524353eaSIcenowy Zheng 	&ve_clk.common,
805524353eaSIcenowy Zheng 	&bus_ve_clk.common,
806524353eaSIcenowy Zheng 	&emce_clk.common,
807524353eaSIcenowy Zheng 	&bus_emce_clk.common,
808524353eaSIcenowy Zheng 	&vp9_clk.common,
809524353eaSIcenowy Zheng 	&bus_vp9_clk.common,
810524353eaSIcenowy Zheng 	&bus_dma_clk.common,
811524353eaSIcenowy Zheng 	&bus_msgbox_clk.common,
812524353eaSIcenowy Zheng 	&bus_spinlock_clk.common,
813524353eaSIcenowy Zheng 	&bus_hstimer_clk.common,
814524353eaSIcenowy Zheng 	&avs_clk.common,
815524353eaSIcenowy Zheng 	&bus_dbg_clk.common,
816524353eaSIcenowy Zheng 	&bus_psi_clk.common,
817524353eaSIcenowy Zheng 	&bus_pwm_clk.common,
818524353eaSIcenowy Zheng 	&bus_iommu_clk.common,
819524353eaSIcenowy Zheng 	&dram_clk.common,
820524353eaSIcenowy Zheng 	&mbus_dma_clk.common,
821524353eaSIcenowy Zheng 	&mbus_ve_clk.common,
822524353eaSIcenowy Zheng 	&mbus_ce_clk.common,
823524353eaSIcenowy Zheng 	&mbus_ts_clk.common,
824524353eaSIcenowy Zheng 	&mbus_nand_clk.common,
825524353eaSIcenowy Zheng 	&mbus_csi_clk.common,
826524353eaSIcenowy Zheng 	&mbus_deinterlace_clk.common,
827524353eaSIcenowy Zheng 	&bus_dram_clk.common,
828524353eaSIcenowy Zheng 	&nand0_clk.common,
829524353eaSIcenowy Zheng 	&nand1_clk.common,
830524353eaSIcenowy Zheng 	&bus_nand_clk.common,
831524353eaSIcenowy Zheng 	&mmc0_clk.common,
832524353eaSIcenowy Zheng 	&mmc1_clk.common,
833524353eaSIcenowy Zheng 	&mmc2_clk.common,
834524353eaSIcenowy Zheng 	&bus_mmc0_clk.common,
835524353eaSIcenowy Zheng 	&bus_mmc1_clk.common,
836524353eaSIcenowy Zheng 	&bus_mmc2_clk.common,
837524353eaSIcenowy Zheng 	&bus_uart0_clk.common,
838524353eaSIcenowy Zheng 	&bus_uart1_clk.common,
839524353eaSIcenowy Zheng 	&bus_uart2_clk.common,
840524353eaSIcenowy Zheng 	&bus_uart3_clk.common,
841524353eaSIcenowy Zheng 	&bus_i2c0_clk.common,
842524353eaSIcenowy Zheng 	&bus_i2c1_clk.common,
843524353eaSIcenowy Zheng 	&bus_i2c2_clk.common,
844524353eaSIcenowy Zheng 	&bus_i2c3_clk.common,
845524353eaSIcenowy Zheng 	&bus_scr0_clk.common,
846524353eaSIcenowy Zheng 	&bus_scr1_clk.common,
847524353eaSIcenowy Zheng 	&spi0_clk.common,
848524353eaSIcenowy Zheng 	&spi1_clk.common,
849524353eaSIcenowy Zheng 	&bus_spi0_clk.common,
850524353eaSIcenowy Zheng 	&bus_spi1_clk.common,
851524353eaSIcenowy Zheng 	&bus_emac_clk.common,
852524353eaSIcenowy Zheng 	&ts_clk.common,
853524353eaSIcenowy Zheng 	&bus_ts_clk.common,
854524353eaSIcenowy Zheng 	&ir_tx_clk.common,
855524353eaSIcenowy Zheng 	&bus_ir_tx_clk.common,
856524353eaSIcenowy Zheng 	&bus_ths_clk.common,
857524353eaSIcenowy Zheng 	&i2s3_clk.common,
858524353eaSIcenowy Zheng 	&i2s0_clk.common,
859524353eaSIcenowy Zheng 	&i2s1_clk.common,
860524353eaSIcenowy Zheng 	&i2s2_clk.common,
861524353eaSIcenowy Zheng 	&bus_i2s0_clk.common,
862524353eaSIcenowy Zheng 	&bus_i2s1_clk.common,
863524353eaSIcenowy Zheng 	&bus_i2s2_clk.common,
864524353eaSIcenowy Zheng 	&bus_i2s3_clk.common,
865524353eaSIcenowy Zheng 	&spdif_clk.common,
866524353eaSIcenowy Zheng 	&bus_spdif_clk.common,
867524353eaSIcenowy Zheng 	&dmic_clk.common,
868524353eaSIcenowy Zheng 	&bus_dmic_clk.common,
869524353eaSIcenowy Zheng 	&audio_hub_clk.common,
870524353eaSIcenowy Zheng 	&bus_audio_hub_clk.common,
871524353eaSIcenowy Zheng 	&usb_ohci0_clk.common,
872524353eaSIcenowy Zheng 	&usb_phy0_clk.common,
873524353eaSIcenowy Zheng 	&usb_phy1_clk.common,
874524353eaSIcenowy Zheng 	&usb_ohci3_clk.common,
875524353eaSIcenowy Zheng 	&usb_phy3_clk.common,
876524353eaSIcenowy Zheng 	&usb_hsic_12m_clk.common,
877524353eaSIcenowy Zheng 	&usb_hsic_clk.common,
878524353eaSIcenowy Zheng 	&bus_ohci0_clk.common,
879524353eaSIcenowy Zheng 	&bus_ohci3_clk.common,
880524353eaSIcenowy Zheng 	&bus_ehci0_clk.common,
881524353eaSIcenowy Zheng 	&bus_xhci_clk.common,
882524353eaSIcenowy Zheng 	&bus_ehci3_clk.common,
883524353eaSIcenowy Zheng 	&bus_otg_clk.common,
884524353eaSIcenowy Zheng 	&pcie_ref_clk.common,
885524353eaSIcenowy Zheng 	&pcie_ref_out_clk.common,
886524353eaSIcenowy Zheng 	&pcie_maxi_clk.common,
887524353eaSIcenowy Zheng 	&pcie_aux_clk.common,
888524353eaSIcenowy Zheng 	&bus_pcie_clk.common,
889524353eaSIcenowy Zheng 	&hdmi_clk.common,
890f422fa55SIcenowy Zheng 	&hdmi_slow_clk.common,
891524353eaSIcenowy Zheng 	&hdmi_cec_clk.common,
892524353eaSIcenowy Zheng 	&bus_hdmi_clk.common,
893524353eaSIcenowy Zheng 	&bus_tcon_top_clk.common,
894524353eaSIcenowy Zheng 	&tcon_lcd0_clk.common,
895524353eaSIcenowy Zheng 	&bus_tcon_lcd0_clk.common,
896524353eaSIcenowy Zheng 	&tcon_tv0_clk.common,
897524353eaSIcenowy Zheng 	&bus_tcon_tv0_clk.common,
898524353eaSIcenowy Zheng 	&csi_cci_clk.common,
899524353eaSIcenowy Zheng 	&csi_top_clk.common,
900524353eaSIcenowy Zheng 	&csi_mclk_clk.common,
901524353eaSIcenowy Zheng 	&bus_csi_clk.common,
902524353eaSIcenowy Zheng 	&hdcp_clk.common,
903524353eaSIcenowy Zheng 	&bus_hdcp_clk.common,
904524353eaSIcenowy Zheng };
905524353eaSIcenowy Zheng 
906524353eaSIcenowy Zheng static struct clk_hw_onecell_data sun50i_h6_hw_clks = {
907524353eaSIcenowy Zheng 	.hws	= {
908524353eaSIcenowy Zheng 		[CLK_OSC12M]		= &osc12M_clk.hw,
909524353eaSIcenowy Zheng 		[CLK_PLL_CPUX]		= &pll_cpux_clk.common.hw,
910524353eaSIcenowy Zheng 		[CLK_PLL_DDR0]		= &pll_ddr0_clk.common.hw,
911524353eaSIcenowy Zheng 		[CLK_PLL_PERIPH0]	= &pll_periph0_clk.common.hw,
912524353eaSIcenowy Zheng 		[CLK_PLL_PERIPH0_2X]	= &pll_periph0_2x_clk.hw,
913524353eaSIcenowy Zheng 		[CLK_PLL_PERIPH0_4X]	= &pll_periph0_4x_clk.hw,
914524353eaSIcenowy Zheng 		[CLK_PLL_PERIPH1]	= &pll_periph1_clk.common.hw,
915524353eaSIcenowy Zheng 		[CLK_PLL_PERIPH1_2X]	= &pll_periph1_2x_clk.hw,
916524353eaSIcenowy Zheng 		[CLK_PLL_PERIPH1_4X]	= &pll_periph1_4x_clk.hw,
917524353eaSIcenowy Zheng 		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,
918524353eaSIcenowy Zheng 		[CLK_PLL_VIDEO0]	= &pll_video0_clk.common.hw,
919524353eaSIcenowy Zheng 		[CLK_PLL_VIDEO0_4X]	= &pll_video0_4x_clk.hw,
920524353eaSIcenowy Zheng 		[CLK_PLL_VIDEO1]	= &pll_video1_clk.common.hw,
921524353eaSIcenowy Zheng 		[CLK_PLL_VIDEO1_4X]	= &pll_video1_4x_clk.hw,
922524353eaSIcenowy Zheng 		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
923524353eaSIcenowy Zheng 		[CLK_PLL_DE]		= &pll_de_clk.common.hw,
924524353eaSIcenowy Zheng 		[CLK_PLL_HSIC]		= &pll_hsic_clk.common.hw,
925524353eaSIcenowy Zheng 		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
926524353eaSIcenowy Zheng 		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
927524353eaSIcenowy Zheng 		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
928524353eaSIcenowy Zheng 		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
929524353eaSIcenowy Zheng 		[CLK_CPUX]		= &cpux_clk.common.hw,
930524353eaSIcenowy Zheng 		[CLK_AXI]		= &axi_clk.common.hw,
931524353eaSIcenowy Zheng 		[CLK_CPUX_APB]		= &cpux_apb_clk.common.hw,
932524353eaSIcenowy Zheng 		[CLK_PSI_AHB1_AHB2]	= &psi_ahb1_ahb2_clk.common.hw,
933524353eaSIcenowy Zheng 		[CLK_AHB3]		= &ahb3_clk.common.hw,
934524353eaSIcenowy Zheng 		[CLK_APB1]		= &apb1_clk.common.hw,
935524353eaSIcenowy Zheng 		[CLK_APB2]		= &apb2_clk.common.hw,
936524353eaSIcenowy Zheng 		[CLK_MBUS]		= &mbus_clk.common.hw,
937524353eaSIcenowy Zheng 		[CLK_DE]		= &de_clk.common.hw,
938524353eaSIcenowy Zheng 		[CLK_BUS_DE]		= &bus_de_clk.common.hw,
939524353eaSIcenowy Zheng 		[CLK_DEINTERLACE]	= &deinterlace_clk.common.hw,
940524353eaSIcenowy Zheng 		[CLK_BUS_DEINTERLACE]	= &bus_deinterlace_clk.common.hw,
941524353eaSIcenowy Zheng 		[CLK_GPU]		= &gpu_clk.common.hw,
942524353eaSIcenowy Zheng 		[CLK_BUS_GPU]		= &bus_gpu_clk.common.hw,
943524353eaSIcenowy Zheng 		[CLK_CE]		= &ce_clk.common.hw,
944524353eaSIcenowy Zheng 		[CLK_BUS_CE]		= &bus_ce_clk.common.hw,
945524353eaSIcenowy Zheng 		[CLK_VE]		= &ve_clk.common.hw,
946524353eaSIcenowy Zheng 		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
947524353eaSIcenowy Zheng 		[CLK_EMCE]		= &emce_clk.common.hw,
948524353eaSIcenowy Zheng 		[CLK_BUS_EMCE]		= &bus_emce_clk.common.hw,
949524353eaSIcenowy Zheng 		[CLK_VP9]		= &vp9_clk.common.hw,
950524353eaSIcenowy Zheng 		[CLK_BUS_VP9]		= &bus_vp9_clk.common.hw,
951524353eaSIcenowy Zheng 		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
952524353eaSIcenowy Zheng 		[CLK_BUS_MSGBOX]	= &bus_msgbox_clk.common.hw,
953524353eaSIcenowy Zheng 		[CLK_BUS_SPINLOCK]	= &bus_spinlock_clk.common.hw,
954524353eaSIcenowy Zheng 		[CLK_BUS_HSTIMER]	= &bus_hstimer_clk.common.hw,
955524353eaSIcenowy Zheng 		[CLK_AVS]		= &avs_clk.common.hw,
956524353eaSIcenowy Zheng 		[CLK_BUS_DBG]		= &bus_dbg_clk.common.hw,
957524353eaSIcenowy Zheng 		[CLK_BUS_PSI]		= &bus_psi_clk.common.hw,
958524353eaSIcenowy Zheng 		[CLK_BUS_PWM]		= &bus_pwm_clk.common.hw,
959524353eaSIcenowy Zheng 		[CLK_BUS_IOMMU]		= &bus_iommu_clk.common.hw,
960524353eaSIcenowy Zheng 		[CLK_DRAM]		= &dram_clk.common.hw,
961524353eaSIcenowy Zheng 		[CLK_MBUS_DMA]		= &mbus_dma_clk.common.hw,
962524353eaSIcenowy Zheng 		[CLK_MBUS_VE]		= &mbus_ve_clk.common.hw,
963524353eaSIcenowy Zheng 		[CLK_MBUS_CE]		= &mbus_ce_clk.common.hw,
964524353eaSIcenowy Zheng 		[CLK_MBUS_TS]		= &mbus_ts_clk.common.hw,
965524353eaSIcenowy Zheng 		[CLK_MBUS_NAND]		= &mbus_nand_clk.common.hw,
966524353eaSIcenowy Zheng 		[CLK_MBUS_CSI]		= &mbus_csi_clk.common.hw,
967524353eaSIcenowy Zheng 		[CLK_MBUS_DEINTERLACE]	= &mbus_deinterlace_clk.common.hw,
968524353eaSIcenowy Zheng 		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
969524353eaSIcenowy Zheng 		[CLK_NAND0]		= &nand0_clk.common.hw,
970524353eaSIcenowy Zheng 		[CLK_NAND1]		= &nand1_clk.common.hw,
971524353eaSIcenowy Zheng 		[CLK_BUS_NAND]		= &bus_nand_clk.common.hw,
972524353eaSIcenowy Zheng 		[CLK_MMC0]		= &mmc0_clk.common.hw,
973524353eaSIcenowy Zheng 		[CLK_MMC1]		= &mmc1_clk.common.hw,
974524353eaSIcenowy Zheng 		[CLK_MMC2]		= &mmc2_clk.common.hw,
975524353eaSIcenowy Zheng 		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
976524353eaSIcenowy Zheng 		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
977524353eaSIcenowy Zheng 		[CLK_BUS_MMC2]		= &bus_mmc2_clk.common.hw,
978524353eaSIcenowy Zheng 		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
979524353eaSIcenowy Zheng 		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
980524353eaSIcenowy Zheng 		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
981524353eaSIcenowy Zheng 		[CLK_BUS_UART3]		= &bus_uart3_clk.common.hw,
982524353eaSIcenowy Zheng 		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
983524353eaSIcenowy Zheng 		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
984524353eaSIcenowy Zheng 		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
985524353eaSIcenowy Zheng 		[CLK_BUS_I2C3]		= &bus_i2c3_clk.common.hw,
986524353eaSIcenowy Zheng 		[CLK_BUS_SCR0]		= &bus_scr0_clk.common.hw,
987524353eaSIcenowy Zheng 		[CLK_BUS_SCR1]		= &bus_scr1_clk.common.hw,
988524353eaSIcenowy Zheng 		[CLK_SPI0]		= &spi0_clk.common.hw,
989524353eaSIcenowy Zheng 		[CLK_SPI1]		= &spi1_clk.common.hw,
990524353eaSIcenowy Zheng 		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
991524353eaSIcenowy Zheng 		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
992524353eaSIcenowy Zheng 		[CLK_BUS_EMAC]		= &bus_emac_clk.common.hw,
993524353eaSIcenowy Zheng 		[CLK_TS]		= &ts_clk.common.hw,
994524353eaSIcenowy Zheng 		[CLK_BUS_TS]		= &bus_ts_clk.common.hw,
995524353eaSIcenowy Zheng 		[CLK_IR_TX]		= &ir_tx_clk.common.hw,
996524353eaSIcenowy Zheng 		[CLK_BUS_IR_TX]		= &bus_ir_tx_clk.common.hw,
997524353eaSIcenowy Zheng 		[CLK_BUS_THS]		= &bus_ths_clk.common.hw,
998524353eaSIcenowy Zheng 		[CLK_I2S3]		= &i2s3_clk.common.hw,
999524353eaSIcenowy Zheng 		[CLK_I2S0]		= &i2s0_clk.common.hw,
1000524353eaSIcenowy Zheng 		[CLK_I2S1]		= &i2s1_clk.common.hw,
1001524353eaSIcenowy Zheng 		[CLK_I2S2]		= &i2s2_clk.common.hw,
1002524353eaSIcenowy Zheng 		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
1003524353eaSIcenowy Zheng 		[CLK_BUS_I2S1]		= &bus_i2s1_clk.common.hw,
1004524353eaSIcenowy Zheng 		[CLK_BUS_I2S2]		= &bus_i2s2_clk.common.hw,
1005524353eaSIcenowy Zheng 		[CLK_BUS_I2S3]		= &bus_i2s3_clk.common.hw,
1006524353eaSIcenowy Zheng 		[CLK_SPDIF]		= &spdif_clk.common.hw,
1007524353eaSIcenowy Zheng 		[CLK_BUS_SPDIF]		= &bus_spdif_clk.common.hw,
1008524353eaSIcenowy Zheng 		[CLK_DMIC]		= &dmic_clk.common.hw,
1009524353eaSIcenowy Zheng 		[CLK_BUS_DMIC]		= &bus_dmic_clk.common.hw,
1010524353eaSIcenowy Zheng 		[CLK_AUDIO_HUB]		= &audio_hub_clk.common.hw,
1011524353eaSIcenowy Zheng 		[CLK_BUS_AUDIO_HUB]	= &bus_audio_hub_clk.common.hw,
1012524353eaSIcenowy Zheng 		[CLK_USB_OHCI0]		= &usb_ohci0_clk.common.hw,
1013524353eaSIcenowy Zheng 		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
1014524353eaSIcenowy Zheng 		[CLK_USB_PHY1]		= &usb_phy1_clk.common.hw,
1015524353eaSIcenowy Zheng 		[CLK_USB_OHCI3]		= &usb_ohci3_clk.common.hw,
1016524353eaSIcenowy Zheng 		[CLK_USB_PHY3]		= &usb_phy3_clk.common.hw,
1017524353eaSIcenowy Zheng 		[CLK_USB_HSIC_12M]	= &usb_hsic_12m_clk.common.hw,
1018524353eaSIcenowy Zheng 		[CLK_USB_HSIC]		= &usb_hsic_clk.common.hw,
1019524353eaSIcenowy Zheng 		[CLK_BUS_OHCI0]		= &bus_ohci0_clk.common.hw,
1020524353eaSIcenowy Zheng 		[CLK_BUS_OHCI3]		= &bus_ohci3_clk.common.hw,
1021524353eaSIcenowy Zheng 		[CLK_BUS_EHCI0]		= &bus_ehci0_clk.common.hw,
1022524353eaSIcenowy Zheng 		[CLK_BUS_XHCI]		= &bus_xhci_clk.common.hw,
1023524353eaSIcenowy Zheng 		[CLK_BUS_EHCI3]		= &bus_ehci3_clk.common.hw,
1024524353eaSIcenowy Zheng 		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
1025524353eaSIcenowy Zheng 		[CLK_PCIE_REF_100M]	= &pcie_ref_100m_clk.hw,
1026524353eaSIcenowy Zheng 		[CLK_PCIE_REF]		= &pcie_ref_clk.common.hw,
1027524353eaSIcenowy Zheng 		[CLK_PCIE_REF_OUT]	= &pcie_ref_out_clk.common.hw,
1028524353eaSIcenowy Zheng 		[CLK_PCIE_MAXI]		= &pcie_maxi_clk.common.hw,
1029524353eaSIcenowy Zheng 		[CLK_PCIE_AUX]		= &pcie_aux_clk.common.hw,
1030524353eaSIcenowy Zheng 		[CLK_BUS_PCIE]		= &bus_pcie_clk.common.hw,
1031524353eaSIcenowy Zheng 		[CLK_HDMI]		= &hdmi_clk.common.hw,
1032f422fa55SIcenowy Zheng 		[CLK_HDMI_SLOW]		= &hdmi_slow_clk.common.hw,
1033524353eaSIcenowy Zheng 		[CLK_HDMI_CEC]		= &hdmi_cec_clk.common.hw,
1034524353eaSIcenowy Zheng 		[CLK_BUS_HDMI]		= &bus_hdmi_clk.common.hw,
1035524353eaSIcenowy Zheng 		[CLK_BUS_TCON_TOP]	= &bus_tcon_top_clk.common.hw,
1036524353eaSIcenowy Zheng 		[CLK_TCON_LCD0]		= &tcon_lcd0_clk.common.hw,
1037524353eaSIcenowy Zheng 		[CLK_BUS_TCON_LCD0]	= &bus_tcon_lcd0_clk.common.hw,
1038524353eaSIcenowy Zheng 		[CLK_TCON_TV0]		= &tcon_tv0_clk.common.hw,
1039524353eaSIcenowy Zheng 		[CLK_BUS_TCON_TV0]	= &bus_tcon_tv0_clk.common.hw,
1040524353eaSIcenowy Zheng 		[CLK_CSI_CCI]		= &csi_cci_clk.common.hw,
1041524353eaSIcenowy Zheng 		[CLK_CSI_TOP]		= &csi_top_clk.common.hw,
1042524353eaSIcenowy Zheng 		[CLK_CSI_MCLK]		= &csi_mclk_clk.common.hw,
1043524353eaSIcenowy Zheng 		[CLK_BUS_CSI]		= &bus_csi_clk.common.hw,
1044524353eaSIcenowy Zheng 		[CLK_HDCP]		= &hdcp_clk.common.hw,
1045524353eaSIcenowy Zheng 		[CLK_BUS_HDCP]		= &bus_hdcp_clk.common.hw,
1046524353eaSIcenowy Zheng 	},
1047524353eaSIcenowy Zheng 	.num = CLK_NUMBER,
1048524353eaSIcenowy Zheng };
1049524353eaSIcenowy Zheng 
1050524353eaSIcenowy Zheng static struct ccu_reset_map sun50i_h6_ccu_resets[] = {
1051524353eaSIcenowy Zheng 	[RST_MBUS]		= { 0x540, BIT(30) },
1052524353eaSIcenowy Zheng 
1053524353eaSIcenowy Zheng 	[RST_BUS_DE]		= { 0x60c, BIT(16) },
1054524353eaSIcenowy Zheng 	[RST_BUS_DEINTERLACE]	= { 0x62c, BIT(16) },
1055524353eaSIcenowy Zheng 	[RST_BUS_GPU]		= { 0x67c, BIT(16) },
1056524353eaSIcenowy Zheng 	[RST_BUS_CE]		= { 0x68c, BIT(16) },
1057524353eaSIcenowy Zheng 	[RST_BUS_VE]		= { 0x69c, BIT(16) },
1058524353eaSIcenowy Zheng 	[RST_BUS_EMCE]		= { 0x6bc, BIT(16) },
1059524353eaSIcenowy Zheng 	[RST_BUS_VP9]		= { 0x6cc, BIT(16) },
1060524353eaSIcenowy Zheng 	[RST_BUS_DMA]		= { 0x70c, BIT(16) },
1061524353eaSIcenowy Zheng 	[RST_BUS_MSGBOX]	= { 0x71c, BIT(16) },
1062524353eaSIcenowy Zheng 	[RST_BUS_SPINLOCK]	= { 0x72c, BIT(16) },
1063524353eaSIcenowy Zheng 	[RST_BUS_HSTIMER]	= { 0x73c, BIT(16) },
1064524353eaSIcenowy Zheng 	[RST_BUS_DBG]		= { 0x78c, BIT(16) },
1065524353eaSIcenowy Zheng 	[RST_BUS_PSI]		= { 0x79c, BIT(16) },
1066524353eaSIcenowy Zheng 	[RST_BUS_PWM]		= { 0x7ac, BIT(16) },
1067524353eaSIcenowy Zheng 	[RST_BUS_IOMMU]		= { 0x7bc, BIT(16) },
1068524353eaSIcenowy Zheng 	[RST_BUS_DRAM]		= { 0x80c, BIT(16) },
1069524353eaSIcenowy Zheng 	[RST_BUS_NAND]		= { 0x82c, BIT(16) },
1070524353eaSIcenowy Zheng 	[RST_BUS_MMC0]		= { 0x84c, BIT(16) },
1071524353eaSIcenowy Zheng 	[RST_BUS_MMC1]		= { 0x84c, BIT(17) },
1072524353eaSIcenowy Zheng 	[RST_BUS_MMC2]		= { 0x84c, BIT(18) },
1073524353eaSIcenowy Zheng 	[RST_BUS_UART0]		= { 0x90c, BIT(16) },
1074524353eaSIcenowy Zheng 	[RST_BUS_UART1]		= { 0x90c, BIT(17) },
1075524353eaSIcenowy Zheng 	[RST_BUS_UART2]		= { 0x90c, BIT(18) },
1076524353eaSIcenowy Zheng 	[RST_BUS_UART3]		= { 0x90c, BIT(19) },
1077524353eaSIcenowy Zheng 	[RST_BUS_I2C0]		= { 0x91c, BIT(16) },
1078524353eaSIcenowy Zheng 	[RST_BUS_I2C1]		= { 0x91c, BIT(17) },
1079524353eaSIcenowy Zheng 	[RST_BUS_I2C2]		= { 0x91c, BIT(18) },
1080524353eaSIcenowy Zheng 	[RST_BUS_I2C3]		= { 0x91c, BIT(19) },
1081524353eaSIcenowy Zheng 	[RST_BUS_SCR0]		= { 0x93c, BIT(16) },
1082524353eaSIcenowy Zheng 	[RST_BUS_SCR1]		= { 0x93c, BIT(17) },
1083524353eaSIcenowy Zheng 	[RST_BUS_SPI0]		= { 0x96c, BIT(16) },
1084524353eaSIcenowy Zheng 	[RST_BUS_SPI1]		= { 0x96c, BIT(17) },
1085524353eaSIcenowy Zheng 	[RST_BUS_EMAC]		= { 0x97c, BIT(16) },
1086524353eaSIcenowy Zheng 	[RST_BUS_TS]		= { 0x9bc, BIT(16) },
1087524353eaSIcenowy Zheng 	[RST_BUS_IR_TX]		= { 0x9cc, BIT(16) },
1088524353eaSIcenowy Zheng 	[RST_BUS_THS]		= { 0x9fc, BIT(16) },
1089524353eaSIcenowy Zheng 	[RST_BUS_I2S0]		= { 0xa1c, BIT(16) },
1090524353eaSIcenowy Zheng 	[RST_BUS_I2S1]		= { 0xa1c, BIT(17) },
1091524353eaSIcenowy Zheng 	[RST_BUS_I2S2]		= { 0xa1c, BIT(18) },
1092524353eaSIcenowy Zheng 	[RST_BUS_I2S3]		= { 0xa1c, BIT(19) },
1093524353eaSIcenowy Zheng 	[RST_BUS_SPDIF]		= { 0xa2c, BIT(16) },
1094524353eaSIcenowy Zheng 	[RST_BUS_DMIC]		= { 0xa4c, BIT(16) },
1095524353eaSIcenowy Zheng 	[RST_BUS_AUDIO_HUB]	= { 0xa6c, BIT(16) },
1096524353eaSIcenowy Zheng 
1097524353eaSIcenowy Zheng 	[RST_USB_PHY0]		= { 0xa70, BIT(30) },
1098524353eaSIcenowy Zheng 	[RST_USB_PHY1]		= { 0xa74, BIT(30) },
1099524353eaSIcenowy Zheng 	[RST_USB_PHY3]		= { 0xa7c, BIT(30) },
1100524353eaSIcenowy Zheng 	[RST_USB_HSIC]		= { 0xa7c, BIT(28) },
1101524353eaSIcenowy Zheng 
1102524353eaSIcenowy Zheng 	[RST_BUS_OHCI0]		= { 0xa8c, BIT(16) },
1103524353eaSIcenowy Zheng 	[RST_BUS_OHCI3]		= { 0xa8c, BIT(19) },
1104524353eaSIcenowy Zheng 	[RST_BUS_EHCI0]		= { 0xa8c, BIT(20) },
1105524353eaSIcenowy Zheng 	[RST_BUS_XHCI]		= { 0xa8c, BIT(21) },
1106524353eaSIcenowy Zheng 	[RST_BUS_EHCI3]		= { 0xa8c, BIT(23) },
1107524353eaSIcenowy Zheng 	[RST_BUS_OTG]		= { 0xa8c, BIT(24) },
1108524353eaSIcenowy Zheng 	[RST_BUS_PCIE]		= { 0xabc, BIT(16) },
1109524353eaSIcenowy Zheng 
1110524353eaSIcenowy Zheng 	[RST_PCIE_POWERUP]	= { 0xabc, BIT(17) },
1111524353eaSIcenowy Zheng 
1112524353eaSIcenowy Zheng 	[RST_BUS_HDMI]		= { 0xb1c, BIT(16) },
1113524353eaSIcenowy Zheng 	[RST_BUS_HDMI_SUB]	= { 0xb1c, BIT(17) },
1114524353eaSIcenowy Zheng 	[RST_BUS_TCON_TOP]	= { 0xb5c, BIT(16) },
1115524353eaSIcenowy Zheng 	[RST_BUS_TCON_LCD0]	= { 0xb7c, BIT(16) },
1116524353eaSIcenowy Zheng 	[RST_BUS_TCON_TV0]	= { 0xb9c, BIT(16) },
1117524353eaSIcenowy Zheng 	[RST_BUS_CSI]		= { 0xc2c, BIT(16) },
1118524353eaSIcenowy Zheng 	[RST_BUS_HDCP]		= { 0xc4c, BIT(16) },
1119524353eaSIcenowy Zheng };
1120524353eaSIcenowy Zheng 
1121524353eaSIcenowy Zheng static const struct sunxi_ccu_desc sun50i_h6_ccu_desc = {
1122524353eaSIcenowy Zheng 	.ccu_clks	= sun50i_h6_ccu_clks,
1123524353eaSIcenowy Zheng 	.num_ccu_clks	= ARRAY_SIZE(sun50i_h6_ccu_clks),
1124524353eaSIcenowy Zheng 
1125524353eaSIcenowy Zheng 	.hw_clks	= &sun50i_h6_hw_clks,
1126524353eaSIcenowy Zheng 
1127524353eaSIcenowy Zheng 	.resets		= sun50i_h6_ccu_resets,
1128524353eaSIcenowy Zheng 	.num_resets	= ARRAY_SIZE(sun50i_h6_ccu_resets),
1129524353eaSIcenowy Zheng };
1130524353eaSIcenowy Zheng 
1131524353eaSIcenowy Zheng static const u32 pll_regs[] = {
1132524353eaSIcenowy Zheng 	SUN50I_H6_PLL_CPUX_REG,
1133524353eaSIcenowy Zheng 	SUN50I_H6_PLL_DDR0_REG,
1134524353eaSIcenowy Zheng 	SUN50I_H6_PLL_PERIPH0_REG,
1135524353eaSIcenowy Zheng 	SUN50I_H6_PLL_PERIPH1_REG,
1136524353eaSIcenowy Zheng 	SUN50I_H6_PLL_GPU_REG,
1137524353eaSIcenowy Zheng 	SUN50I_H6_PLL_VIDEO0_REG,
1138524353eaSIcenowy Zheng 	SUN50I_H6_PLL_VIDEO1_REG,
1139524353eaSIcenowy Zheng 	SUN50I_H6_PLL_VE_REG,
1140524353eaSIcenowy Zheng 	SUN50I_H6_PLL_DE_REG,
1141524353eaSIcenowy Zheng 	SUN50I_H6_PLL_HSIC_REG,
1142524353eaSIcenowy Zheng 	SUN50I_H6_PLL_AUDIO_REG,
1143524353eaSIcenowy Zheng };
1144524353eaSIcenowy Zheng 
1145524353eaSIcenowy Zheng static const u32 pll_video_regs[] = {
1146524353eaSIcenowy Zheng 	SUN50I_H6_PLL_VIDEO0_REG,
1147524353eaSIcenowy Zheng 	SUN50I_H6_PLL_VIDEO1_REG,
1148524353eaSIcenowy Zheng };
1149524353eaSIcenowy Zheng 
1150524353eaSIcenowy Zheng static const u32 usb2_clk_regs[] = {
1151524353eaSIcenowy Zheng 	SUN50I_H6_USB0_CLK_REG,
1152524353eaSIcenowy Zheng 	SUN50I_H6_USB3_CLK_REG,
1153524353eaSIcenowy Zheng };
1154524353eaSIcenowy Zheng 
1155524353eaSIcenowy Zheng static int sun50i_h6_ccu_probe(struct platform_device *pdev)
1156524353eaSIcenowy Zheng {
1157524353eaSIcenowy Zheng 	struct resource *res;
1158524353eaSIcenowy Zheng 	void __iomem *reg;
1159524353eaSIcenowy Zheng 	u32 val;
1160524353eaSIcenowy Zheng 	int i;
1161524353eaSIcenowy Zheng 
1162524353eaSIcenowy Zheng 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1163524353eaSIcenowy Zheng 	reg = devm_ioremap_resource(&pdev->dev, res);
1164524353eaSIcenowy Zheng 	if (IS_ERR(reg))
1165524353eaSIcenowy Zheng 		return PTR_ERR(reg);
1166524353eaSIcenowy Zheng 
1167524353eaSIcenowy Zheng 	/* Enable the lock bits on all PLLs */
1168524353eaSIcenowy Zheng 	for (i = 0; i < ARRAY_SIZE(pll_regs); i++) {
1169524353eaSIcenowy Zheng 		val = readl(reg + pll_regs[i]);
1170524353eaSIcenowy Zheng 		val |= BIT(29);
1171524353eaSIcenowy Zheng 		writel(val, reg + pll_regs[i]);
1172524353eaSIcenowy Zheng 	}
1173524353eaSIcenowy Zheng 
1174524353eaSIcenowy Zheng 	/*
1175524353eaSIcenowy Zheng 	 * Force the output divider of video PLLs to 0.
1176524353eaSIcenowy Zheng 	 *
1177524353eaSIcenowy Zheng 	 * See the comment before pll-video0 definition for the reason.
1178524353eaSIcenowy Zheng 	 */
1179524353eaSIcenowy Zheng 	for (i = 0; i < ARRAY_SIZE(pll_video_regs); i++) {
1180524353eaSIcenowy Zheng 		val = readl(reg + pll_video_regs[i]);
1181524353eaSIcenowy Zheng 		val &= ~BIT(0);
1182524353eaSIcenowy Zheng 		writel(val, reg + pll_video_regs[i]);
1183524353eaSIcenowy Zheng 	}
1184524353eaSIcenowy Zheng 
1185524353eaSIcenowy Zheng 	/*
1186524353eaSIcenowy Zheng 	 * Force OHCI 12M clock sources to 00 (12MHz divided from 48MHz)
1187524353eaSIcenowy Zheng 	 *
1188524353eaSIcenowy Zheng 	 * This clock mux is still mysterious, and the code just enforces
1189524353eaSIcenowy Zheng 	 * it to have a valid clock parent.
1190524353eaSIcenowy Zheng 	 */
1191524353eaSIcenowy Zheng 	for (i = 0; i < ARRAY_SIZE(usb2_clk_regs); i++) {
1192524353eaSIcenowy Zheng 		val = readl(reg + usb2_clk_regs[i]);
1193524353eaSIcenowy Zheng 		val &= ~GENMASK(25, 24);
1194524353eaSIcenowy Zheng 		writel (val, reg + usb2_clk_regs[i]);
1195524353eaSIcenowy Zheng 	}
1196524353eaSIcenowy Zheng 
1197524353eaSIcenowy Zheng 	/*
1198524353eaSIcenowy Zheng 	 * Force the post-divider of pll-audio to 8 and the output divider
1199524353eaSIcenowy Zheng 	 * of it to 1, to make the clock name represents the real frequency.
1200524353eaSIcenowy Zheng 	 */
1201524353eaSIcenowy Zheng 	val = readl(reg + SUN50I_H6_PLL_AUDIO_REG);
1202524353eaSIcenowy Zheng 	val &= ~(GENMASK(21, 16) | BIT(0));
1203524353eaSIcenowy Zheng 	writel(val | (7 << 16), reg + SUN50I_H6_PLL_AUDIO_REG);
1204524353eaSIcenowy Zheng 
120526fae7a4SJernej Skrabec 	/*
120626fae7a4SJernej Skrabec 	 * First clock parent (osc32K) is unusable for CEC. But since there
120726fae7a4SJernej Skrabec 	 * is no good way to force parent switch (both run with same frequency),
120826fae7a4SJernej Skrabec 	 * just set second clock parent here.
120926fae7a4SJernej Skrabec 	 */
121026fae7a4SJernej Skrabec 	val = readl(reg + SUN50I_H6_HDMI_CEC_CLK_REG);
121126fae7a4SJernej Skrabec 	val |= BIT(24);
121226fae7a4SJernej Skrabec 	writel(val, reg + SUN50I_H6_HDMI_CEC_CLK_REG);
121326fae7a4SJernej Skrabec 
1214524353eaSIcenowy Zheng 	return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_h6_ccu_desc);
1215524353eaSIcenowy Zheng }
1216524353eaSIcenowy Zheng 
1217524353eaSIcenowy Zheng static const struct of_device_id sun50i_h6_ccu_ids[] = {
1218524353eaSIcenowy Zheng 	{ .compatible = "allwinner,sun50i-h6-ccu" },
1219524353eaSIcenowy Zheng 	{ }
1220524353eaSIcenowy Zheng };
1221524353eaSIcenowy Zheng 
1222524353eaSIcenowy Zheng static struct platform_driver sun50i_h6_ccu_driver = {
1223524353eaSIcenowy Zheng 	.probe	= sun50i_h6_ccu_probe,
1224524353eaSIcenowy Zheng 	.driver	= {
1225524353eaSIcenowy Zheng 		.name	= "sun50i-h6-ccu",
1226524353eaSIcenowy Zheng 		.of_match_table	= sun50i_h6_ccu_ids,
1227524353eaSIcenowy Zheng 	},
1228524353eaSIcenowy Zheng };
1229524353eaSIcenowy Zheng builtin_platform_driver(sun50i_h6_ccu_driver);
1230