xref: /openbmc/linux/drivers/clk/sunxi-ng/ccu-sun8i-r40.c (revision 01a7ea763fc46fd21692dfc070009d2c1cbc1b07)
1cd030a78SIcenowy Zheng /*
2cd030a78SIcenowy Zheng  * Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io>
3cd030a78SIcenowy Zheng  *
4cd030a78SIcenowy Zheng  * This software is licensed under the terms of the GNU General Public
5cd030a78SIcenowy Zheng  * License version 2, as published by the Free Software Foundation, and
6cd030a78SIcenowy Zheng  * may be copied, distributed, and modified under those terms.
7cd030a78SIcenowy Zheng  *
8cd030a78SIcenowy Zheng  * This program is distributed in the hope that it will be useful,
9cd030a78SIcenowy Zheng  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10cd030a78SIcenowy Zheng  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11cd030a78SIcenowy Zheng  * GNU General Public License for more details.
12cd030a78SIcenowy Zheng  */
13cd030a78SIcenowy Zheng 
14cd030a78SIcenowy Zheng #include <linux/clk-provider.h>
15c3bf29f6SIcenowy Zheng #include <linux/platform_device.h>
16c3bf29f6SIcenowy Zheng #include <linux/regmap.h>
17cd030a78SIcenowy Zheng 
18cd030a78SIcenowy Zheng #include "ccu_common.h"
19cd030a78SIcenowy Zheng #include "ccu_reset.h"
20cd030a78SIcenowy Zheng 
21cd030a78SIcenowy Zheng #include "ccu_div.h"
22cd030a78SIcenowy Zheng #include "ccu_gate.h"
23cd030a78SIcenowy Zheng #include "ccu_mp.h"
24cd030a78SIcenowy Zheng #include "ccu_mult.h"
25cd030a78SIcenowy Zheng #include "ccu_nk.h"
26cd030a78SIcenowy Zheng #include "ccu_nkm.h"
27cd030a78SIcenowy Zheng #include "ccu_nkmp.h"
28cd030a78SIcenowy Zheng #include "ccu_nm.h"
29cd030a78SIcenowy Zheng #include "ccu_phase.h"
30cd030a78SIcenowy Zheng 
31cd030a78SIcenowy Zheng #include "ccu-sun8i-r40.h"
32cd030a78SIcenowy Zheng 
33cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [10, 88] range. */
34cd030a78SIcenowy Zheng static struct ccu_nkmp pll_cpu_clk = {
35cd030a78SIcenowy Zheng 	.enable		= BIT(31),
36cd030a78SIcenowy Zheng 	.lock		= BIT(28),
37cd030a78SIcenowy Zheng 	.n		= _SUNXI_CCU_MULT(8, 5),
38cd030a78SIcenowy Zheng 	.k		= _SUNXI_CCU_MULT(4, 2),
39cd030a78SIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(0, 2),
40cd030a78SIcenowy Zheng 	.p		= _SUNXI_CCU_DIV_MAX(16, 2, 4),
41cd030a78SIcenowy Zheng 	.common		= {
42cd030a78SIcenowy Zheng 		.reg		= 0x000,
43cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-cpu",
44cd030a78SIcenowy Zheng 					      "osc24M",
45cd030a78SIcenowy Zheng 					      &ccu_nkmp_ops,
46cd030a78SIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
47cd030a78SIcenowy Zheng 	},
48cd030a78SIcenowy Zheng };
49cd030a78SIcenowy Zheng 
50cd030a78SIcenowy Zheng /*
51cd030a78SIcenowy Zheng  * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
52cd030a78SIcenowy Zheng  * the base (2x, 4x and 8x), and one variable divider (the one true
53cd030a78SIcenowy Zheng  * pll audio).
54cd030a78SIcenowy Zheng  *
55cd030a78SIcenowy Zheng  * We don't have any need for the variable divider for now, so we just
56cd030a78SIcenowy Zheng  * hardcode it to match with the clock names
57cd030a78SIcenowy Zheng  */
58cd030a78SIcenowy Zheng #define SUN8I_R40_PLL_AUDIO_REG	0x008
59cd030a78SIcenowy Zheng 
60cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
61cd030a78SIcenowy Zheng 				   "osc24M", 0x008,
62cd030a78SIcenowy Zheng 				   8, 7,	/* N */
63cd030a78SIcenowy Zheng 				   0, 5,	/* M */
64cd030a78SIcenowy Zheng 				   BIT(31),	/* gate */
65cd030a78SIcenowy Zheng 				   BIT(28),	/* lock */
66cd030a78SIcenowy Zheng 				   CLK_SET_RATE_UNGATE);
67cd030a78SIcenowy Zheng 
68b16fb669SJernej Skrabec static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0",
69cd030a78SIcenowy Zheng 						"osc24M", 0x0010,
7024a95f75SJernej Skrabec 						192000000,  /* Minimum rate */
71b16fb669SJernej Skrabec 						1008000000, /* Maximum rate */
72cd030a78SIcenowy Zheng 						8, 7,       /* N */
73cd030a78SIcenowy Zheng 						0, 4,       /* M */
74cd030a78SIcenowy Zheng 						BIT(24),    /* frac enable */
75cd030a78SIcenowy Zheng 						BIT(25),    /* frac select */
76cd030a78SIcenowy Zheng 						270000000,  /* frac rate 0 */
77cd030a78SIcenowy Zheng 						297000000,  /* frac rate 1 */
78cd030a78SIcenowy Zheng 						BIT(31),    /* gate */
79cd030a78SIcenowy Zheng 						BIT(28),    /* lock */
80cd030a78SIcenowy Zheng 						CLK_SET_RATE_UNGATE);
81cd030a78SIcenowy Zheng 
82cd030a78SIcenowy Zheng /* TODO: The result of N/M is required to be in [8, 25] range. */
83cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
84cd030a78SIcenowy Zheng 					"osc24M", 0x0018,
85cd030a78SIcenowy Zheng 					8, 7,		/* N */
86cd030a78SIcenowy Zheng 					0, 4,		/* M */
87cd030a78SIcenowy Zheng 					BIT(24),	/* frac enable */
88cd030a78SIcenowy Zheng 					BIT(25),	/* frac select */
89cd030a78SIcenowy Zheng 					270000000,	/* frac rate 0 */
90cd030a78SIcenowy Zheng 					297000000,	/* frac rate 1 */
91cd030a78SIcenowy Zheng 					BIT(31),	/* gate */
92cd030a78SIcenowy Zheng 					BIT(28),	/* lock */
93cd030a78SIcenowy Zheng 					CLK_SET_RATE_UNGATE);
94cd030a78SIcenowy Zheng 
95cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [10, 77] range. */
96cd030a78SIcenowy Zheng static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0",
97cd030a78SIcenowy Zheng 				    "osc24M", 0x020,
98cd030a78SIcenowy Zheng 				    8, 5,	/* N */
99cd030a78SIcenowy Zheng 				    4, 2,	/* K */
100cd030a78SIcenowy Zheng 				    0, 2,	/* M */
101cd030a78SIcenowy Zheng 				    BIT(31),	/* gate */
102cd030a78SIcenowy Zheng 				    BIT(28),	/* lock */
103cd030a78SIcenowy Zheng 				    CLK_SET_RATE_UNGATE);
104cd030a78SIcenowy Zheng 
105cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [21, 58] range. */
106cd030a78SIcenowy Zheng static struct ccu_nk pll_periph0_clk = {
107cd030a78SIcenowy Zheng 	.enable		= BIT(31),
108cd030a78SIcenowy Zheng 	.lock		= BIT(28),
109cd030a78SIcenowy Zheng 	.n		= _SUNXI_CCU_MULT(8, 5),
110cd030a78SIcenowy Zheng 	.k		= _SUNXI_CCU_MULT(4, 2),
111cd030a78SIcenowy Zheng 	.fixed_post_div	= 2,
112cd030a78SIcenowy Zheng 	.common		= {
113cd030a78SIcenowy Zheng 		.reg		= 0x028,
114cd030a78SIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
115cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-periph0", "osc24M",
116cd030a78SIcenowy Zheng 					      &ccu_nk_ops,
117cd030a78SIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
118cd030a78SIcenowy Zheng 	},
119cd030a78SIcenowy Zheng };
120cd030a78SIcenowy Zheng 
121cd030a78SIcenowy Zheng static struct ccu_div pll_periph0_sata_clk = {
122cd030a78SIcenowy Zheng 	.enable		= BIT(24),
123cd030a78SIcenowy Zheng 	.div		= _SUNXI_CCU_DIV(0, 2),
124cd030a78SIcenowy Zheng 	/*
125cd030a78SIcenowy Zheng 	 * The formula of pll-periph0 (1x) is 24MHz*N*K/2, and the formula
126cd030a78SIcenowy Zheng 	 * of pll-periph0-sata is 24MHz*N*K/M/6, so the postdiv here is
127cd030a78SIcenowy Zheng 	 * 6/2 = 3.
128cd030a78SIcenowy Zheng 	 */
129cd030a78SIcenowy Zheng 	.fixed_post_div	= 3,
130cd030a78SIcenowy Zheng 	.common		= {
131cd030a78SIcenowy Zheng 		.reg		= 0x028,
132cd030a78SIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
133cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-periph0-sata",
134cd030a78SIcenowy Zheng 					      "pll-periph0",
135cd030a78SIcenowy Zheng 					      &ccu_div_ops, 0),
136cd030a78SIcenowy Zheng 	},
137cd030a78SIcenowy Zheng };
138cd030a78SIcenowy Zheng 
139cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [21, 58] range. */
140cd030a78SIcenowy Zheng static struct ccu_nk pll_periph1_clk = {
141cd030a78SIcenowy Zheng 	.enable		= BIT(31),
142cd030a78SIcenowy Zheng 	.lock		= BIT(28),
143cd030a78SIcenowy Zheng 	.n		= _SUNXI_CCU_MULT(8, 5),
144cd030a78SIcenowy Zheng 	.k		= _SUNXI_CCU_MULT(4, 2),
145cd030a78SIcenowy Zheng 	.fixed_post_div	= 2,
146cd030a78SIcenowy Zheng 	.common		= {
147cd030a78SIcenowy Zheng 		.reg		= 0x02c,
148cd030a78SIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
149cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-periph1", "osc24M",
150cd030a78SIcenowy Zheng 					      &ccu_nk_ops,
151cd030a78SIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
152cd030a78SIcenowy Zheng 	},
153cd030a78SIcenowy Zheng };
154cd030a78SIcenowy Zheng 
155b16fb669SJernej Skrabec static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video1_clk, "pll-video1",
156cd030a78SIcenowy Zheng 						"osc24M", 0x030,
15724a95f75SJernej Skrabec 						192000000,  /* Minimum rate */
158b16fb669SJernej Skrabec 						1008000000, /* Maximum rate */
159cd030a78SIcenowy Zheng 						8, 7,       /* N */
160cd030a78SIcenowy Zheng 						0, 4,       /* M */
161cd030a78SIcenowy Zheng 						BIT(24),    /* frac enable */
162cd030a78SIcenowy Zheng 						BIT(25),    /* frac select */
163cd030a78SIcenowy Zheng 						270000000,  /* frac rate 0 */
164cd030a78SIcenowy Zheng 						297000000,  /* frac rate 1 */
165cd030a78SIcenowy Zheng 						BIT(31),    /* gate */
166cd030a78SIcenowy Zheng 						BIT(28),    /* lock */
167cd030a78SIcenowy Zheng 						CLK_SET_RATE_UNGATE);
168cd030a78SIcenowy Zheng 
169cd030a78SIcenowy Zheng static struct ccu_nkm pll_sata_clk = {
170cd030a78SIcenowy Zheng 	.enable		= BIT(31),
171cd030a78SIcenowy Zheng 	.lock		= BIT(28),
172cd030a78SIcenowy Zheng 	.n		= _SUNXI_CCU_MULT(8, 5),
173cd030a78SIcenowy Zheng 	.k		= _SUNXI_CCU_MULT(4, 2),
174cd030a78SIcenowy Zheng 	.m		= _SUNXI_CCU_DIV(0, 2),
175cd030a78SIcenowy Zheng 	.fixed_post_div	= 6,
176cd030a78SIcenowy Zheng 	.common		= {
177cd030a78SIcenowy Zheng 		.reg		= 0x034,
178cd030a78SIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_POSTDIV,
179cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT("pll-sata", "osc24M",
180cd030a78SIcenowy Zheng 					      &ccu_nkm_ops,
181cd030a78SIcenowy Zheng 					      CLK_SET_RATE_UNGATE),
182cd030a78SIcenowy Zheng 	},
183cd030a78SIcenowy Zheng };
184cd030a78SIcenowy Zheng 
185cd030a78SIcenowy Zheng static const char * const pll_sata_out_parents[] = { "pll-sata",
186cd030a78SIcenowy Zheng 						     "pll-periph0-sata" };
187cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(pll_sata_out_clk, "pll-sata-out",
188cd030a78SIcenowy Zheng 			       pll_sata_out_parents, 0x034,
189cd030a78SIcenowy Zheng 			       30, 1,	/* mux */
190cd030a78SIcenowy Zheng 			       BIT(14),	/* gate */
191cd030a78SIcenowy Zheng 			       CLK_SET_RATE_PARENT);
192cd030a78SIcenowy Zheng 
193cd030a78SIcenowy Zheng /* TODO: The result of N/M is required to be in [8, 25] range. */
194cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
195cd030a78SIcenowy Zheng 					"osc24M", 0x038,
196cd030a78SIcenowy Zheng 					8, 7,		/* N */
197cd030a78SIcenowy Zheng 					0, 4,		/* M */
198cd030a78SIcenowy Zheng 					BIT(24),	/* frac enable */
199cd030a78SIcenowy Zheng 					BIT(25),	/* frac select */
200cd030a78SIcenowy Zheng 					270000000,	/* frac rate 0 */
201cd030a78SIcenowy Zheng 					297000000,	/* frac rate 1 */
202cd030a78SIcenowy Zheng 					BIT(31),	/* gate */
203cd030a78SIcenowy Zheng 					BIT(28),	/* lock */
204cd030a78SIcenowy Zheng 					CLK_SET_RATE_UNGATE);
205cd030a78SIcenowy Zheng 
206cd030a78SIcenowy Zheng /*
207cd030a78SIcenowy Zheng  * The MIPI PLL has 2 modes: "MIPI" and "HDMI".
208cd030a78SIcenowy Zheng  *
209cd030a78SIcenowy Zheng  * The MIPI mode is a standard NKM-style clock. The HDMI mode is an
210cd030a78SIcenowy Zheng  * integer / fractional clock with switchable multipliers and dividers.
211cd030a78SIcenowy Zheng  * This is not supported here. We hardcode the PLL to MIPI mode.
212cd030a78SIcenowy Zheng  *
213cd030a78SIcenowy Zheng  * TODO: In the MIPI mode, M/N is required to be equal or lesser than 3,
214cd030a78SIcenowy Zheng  * which cannot be implemented now.
215cd030a78SIcenowy Zheng  */
216cd030a78SIcenowy Zheng #define SUN8I_R40_PLL_MIPI_REG	0x040
217cd030a78SIcenowy Zheng 
218cd030a78SIcenowy Zheng static const char * const pll_mipi_parents[] = { "pll-video0" };
219cd030a78SIcenowy Zheng static struct ccu_nkm pll_mipi_clk = {
220cd030a78SIcenowy Zheng 	.enable	= BIT(31) | BIT(23) | BIT(22),
221cd030a78SIcenowy Zheng 	.lock	= BIT(28),
222cd030a78SIcenowy Zheng 	.n	= _SUNXI_CCU_MULT(8, 4),
223cd030a78SIcenowy Zheng 	.k	= _SUNXI_CCU_MULT_MIN(4, 2, 2),
224cd030a78SIcenowy Zheng 	.m	= _SUNXI_CCU_DIV(0, 4),
225cd030a78SIcenowy Zheng 	.mux	= _SUNXI_CCU_MUX(21, 1),
226cd030a78SIcenowy Zheng 	.common	= {
227cd030a78SIcenowy Zheng 		.reg		= 0x040,
228cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("pll-mipi",
229cd030a78SIcenowy Zheng 						      pll_mipi_parents,
230cd030a78SIcenowy Zheng 						      &ccu_nkm_ops,
231cd030a78SIcenowy Zheng 						      CLK_SET_RATE_UNGATE)
232cd030a78SIcenowy Zheng 	},
233cd030a78SIcenowy Zheng };
234cd030a78SIcenowy Zheng 
235cd030a78SIcenowy Zheng /* TODO: The result of N/M is required to be in [8, 25] range. */
236cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
237cd030a78SIcenowy Zheng 					"osc24M", 0x048,
238cd030a78SIcenowy Zheng 					8, 7,		/* N */
239cd030a78SIcenowy Zheng 					0, 4,		/* M */
240cd030a78SIcenowy Zheng 					BIT(24),	/* frac enable */
241cd030a78SIcenowy Zheng 					BIT(25),	/* frac select */
242cd030a78SIcenowy Zheng 					270000000,	/* frac rate 0 */
243cd030a78SIcenowy Zheng 					297000000,	/* frac rate 1 */
244cd030a78SIcenowy Zheng 					BIT(31),	/* gate */
245cd030a78SIcenowy Zheng 					BIT(28),	/* lock */
246cd030a78SIcenowy Zheng 					CLK_SET_RATE_UNGATE);
247cd030a78SIcenowy Zheng 
248cd030a78SIcenowy Zheng /* TODO: The N factor is required to be in [16, 75] range. */
249cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1",
250cd030a78SIcenowy Zheng 				   "osc24M", 0x04c,
251cd030a78SIcenowy Zheng 				   8, 7,	/* N */
252cd030a78SIcenowy Zheng 				   0, 2,	/* M */
253cd030a78SIcenowy Zheng 				   BIT(31),	/* gate */
254cd030a78SIcenowy Zheng 				   BIT(28),	/* lock */
255cd030a78SIcenowy Zheng 				   CLK_SET_RATE_UNGATE);
256cd030a78SIcenowy Zheng 
257cd030a78SIcenowy Zheng static const char * const cpu_parents[] = { "osc32k", "osc24M",
258cd030a78SIcenowy Zheng 					     "pll-cpu", "pll-cpu" };
259cd030a78SIcenowy Zheng static SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents,
260cd030a78SIcenowy Zheng 		     0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
261cd030a78SIcenowy Zheng 
262cd030a78SIcenowy Zheng static SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0);
263cd030a78SIcenowy Zheng 
264cd030a78SIcenowy Zheng static const char * const ahb1_parents[] = { "osc32k", "osc24M",
265cd030a78SIcenowy Zheng 					     "axi", "pll-periph0" };
266cd030a78SIcenowy Zheng static const struct ccu_mux_var_prediv ahb1_predivs[] = {
267cd030a78SIcenowy Zheng 	{ .index = 3, .shift = 6, .width = 2 },
268cd030a78SIcenowy Zheng };
269cd030a78SIcenowy Zheng static struct ccu_div ahb1_clk = {
270cd030a78SIcenowy Zheng 	.div		= _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
271cd030a78SIcenowy Zheng 
272cd030a78SIcenowy Zheng 	.mux		= {
273cd030a78SIcenowy Zheng 		.shift	= 12,
274cd030a78SIcenowy Zheng 		.width	= 2,
275cd030a78SIcenowy Zheng 
276cd030a78SIcenowy Zheng 		.var_predivs	= ahb1_predivs,
277cd030a78SIcenowy Zheng 		.n_var_predivs	= ARRAY_SIZE(ahb1_predivs),
278cd030a78SIcenowy Zheng 	},
279cd030a78SIcenowy Zheng 
280cd030a78SIcenowy Zheng 	.common		= {
281cd030a78SIcenowy Zheng 		.reg		= 0x054,
282cd030a78SIcenowy Zheng 		.features	= CCU_FEATURE_VARIABLE_PREDIV,
283cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("ahb1",
284cd030a78SIcenowy Zheng 						      ahb1_parents,
285cd030a78SIcenowy Zheng 						      &ccu_div_ops,
286cd030a78SIcenowy Zheng 						      0),
287cd030a78SIcenowy Zheng 	},
288cd030a78SIcenowy Zheng };
289cd030a78SIcenowy Zheng 
290cd030a78SIcenowy Zheng static struct clk_div_table apb1_div_table[] = {
291cd030a78SIcenowy Zheng 	{ .val = 0, .div = 2 },
292cd030a78SIcenowy Zheng 	{ .val = 1, .div = 2 },
293cd030a78SIcenowy Zheng 	{ .val = 2, .div = 4 },
294cd030a78SIcenowy Zheng 	{ .val = 3, .div = 8 },
295cd030a78SIcenowy Zheng 	{ /* Sentinel */ },
296cd030a78SIcenowy Zheng };
297cd030a78SIcenowy Zheng static SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
298cd030a78SIcenowy Zheng 			   0x054, 8, 2, apb1_div_table, 0);
299cd030a78SIcenowy Zheng 
300cd030a78SIcenowy Zheng static const char * const apb2_parents[] = { "osc32k", "osc24M",
301cd030a78SIcenowy Zheng 					     "pll-periph0-2x",
302cd030a78SIcenowy Zheng 					     "pll-periph0-2x" };
303cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
304cd030a78SIcenowy Zheng 			     0, 5,	/* M */
305cd030a78SIcenowy Zheng 			     16, 2,	/* P */
306cd030a78SIcenowy Zheng 			     24, 2,	/* mux */
307cd030a78SIcenowy Zheng 			     0);
308cd030a78SIcenowy Zheng 
309cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mipi_dsi_clk,	"bus-mipi-dsi",	"ahb1",
310cd030a78SIcenowy Zheng 		      0x060, BIT(1), 0);
311cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ce_clk,	"bus-ce",	"ahb1",
312cd030a78SIcenowy Zheng 		      0x060, BIT(5), 0);
313cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_dma_clk,	"bus-dma",	"ahb1",
314cd030a78SIcenowy Zheng 		      0x060, BIT(6), 0);
315cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc0_clk,	"bus-mmc0",	"ahb1",
316cd030a78SIcenowy Zheng 		      0x060, BIT(8), 0);
317cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc1_clk,	"bus-mmc1",	"ahb1",
318cd030a78SIcenowy Zheng 		      0x060, BIT(9), 0);
319cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc2_clk,	"bus-mmc2",	"ahb1",
320cd030a78SIcenowy Zheng 		      0x060, BIT(10), 0);
321cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc3_clk,	"bus-mmc3",	"ahb1",
322cd030a78SIcenowy Zheng 		      0x060, BIT(11), 0);
323cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_nand_clk,	"bus-nand",	"ahb1",
324cd030a78SIcenowy Zheng 		      0x060, BIT(13), 0);
325cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_dram_clk,	"bus-dram",	"ahb1",
326cd030a78SIcenowy Zheng 		      0x060, BIT(14), 0);
327cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_emac_clk,	"bus-emac",	"ahb1",
328cd030a78SIcenowy Zheng 		      0x060, BIT(17), 0);
329cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ts_clk,	"bus-ts",	"ahb1",
330cd030a78SIcenowy Zheng 		      0x060, BIT(18), 0);
331cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_hstimer_clk,	"bus-hstimer",	"ahb1",
332cd030a78SIcenowy Zheng 		      0x060, BIT(19), 0);
333cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi0_clk,	"bus-spi0",	"ahb1",
334cd030a78SIcenowy Zheng 		      0x060, BIT(20), 0);
335cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi1_clk,	"bus-spi1",	"ahb1",
336cd030a78SIcenowy Zheng 		      0x060, BIT(21), 0);
337cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi2_clk,	"bus-spi2",	"ahb1",
338cd030a78SIcenowy Zheng 		      0x060, BIT(22), 0);
339cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi3_clk,	"bus-spi3",	"ahb1",
340cd030a78SIcenowy Zheng 		      0x060, BIT(23), 0);
341cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_sata_clk,	"bus-sata",	"ahb1",
342cd030a78SIcenowy Zheng 		      0x060, BIT(24), 0);
343cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_otg_clk,	"bus-otg",	"ahb1",
344cd030a78SIcenowy Zheng 		      0x060, BIT(25), 0);
345cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci0_clk,	"bus-ehci0",	"ahb1",
346cd030a78SIcenowy Zheng 		      0x060, BIT(26), 0);
347cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci1_clk,	"bus-ehci1",	"ahb1",
348cd030a78SIcenowy Zheng 		      0x060, BIT(27), 0);
349cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci2_clk,	"bus-ehci2",	"ahb1",
350cd030a78SIcenowy Zheng 		      0x060, BIT(28), 0);
351cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci0_clk,	"bus-ohci0",	"ahb1",
352cd030a78SIcenowy Zheng 		      0x060, BIT(29), 0);
353cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci1_clk,	"bus-ohci1",	"ahb1",
354cd030a78SIcenowy Zheng 		      0x060, BIT(30), 0);
355cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci2_clk,	"bus-ohci2",	"ahb1",
356cd030a78SIcenowy Zheng 		      0x060, BIT(31), 0);
357cd030a78SIcenowy Zheng 
358cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ve_clk,	"bus-ve",	"ahb1",
359cd030a78SIcenowy Zheng 		      0x064, BIT(0), 0);
360cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mp_clk,	"bus-mp",	"ahb1",
361cd030a78SIcenowy Zheng 		      0x064, BIT(2), 0);
362cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_deinterlace_clk,	"bus-deinterlace",	"ahb1",
363cd030a78SIcenowy Zheng 		      0x064, BIT(5), 0);
364cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_csi0_clk,	"bus-csi0",	"ahb1",
365cd030a78SIcenowy Zheng 		      0x064, BIT(8), 0);
366cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_csi1_clk,	"bus-csi1",	"ahb1",
367cd030a78SIcenowy Zheng 		      0x064, BIT(9), 0);
368cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_hdmi0_clk,	"bus-hdmi0",	"ahb1",
369cd030a78SIcenowy Zheng 		      0x064, BIT(10), 0);
370cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_hdmi1_clk,	"bus-hdmi1",	"ahb1",
371cd030a78SIcenowy Zheng 		      0x064, BIT(11), 0);
372cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_de_clk,	"bus-de",	"ahb1",
373cd030a78SIcenowy Zheng 		      0x064, BIT(12), 0);
374cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tve0_clk,	"bus-tve0",	"ahb1",
375cd030a78SIcenowy Zheng 		      0x064, BIT(13), 0);
376cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tve1_clk,	"bus-tve1",	"ahb1",
377cd030a78SIcenowy Zheng 		      0x064, BIT(14), 0);
378cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tve_top_clk,	"bus-tve-top",	"ahb1",
379cd030a78SIcenowy Zheng 		      0x064, BIT(15), 0);
380cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_gmac_clk,	"bus-gmac",	"ahb1",
381cd030a78SIcenowy Zheng 		      0x064, BIT(17), 0);
382cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
383cd030a78SIcenowy Zheng 		      0x064, BIT(20), 0);
384cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd0_clk,	"bus-tvd0",	"ahb1",
385cd030a78SIcenowy Zheng 		      0x064, BIT(21), 0);
386cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd1_clk,	"bus-tvd1",	"ahb1",
387cd030a78SIcenowy Zheng 		      0x064, BIT(22), 0);
388cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd2_clk,	"bus-tvd2",	"ahb1",
389cd030a78SIcenowy Zheng 		      0x064, BIT(23), 0);
390cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd3_clk,	"bus-tvd3",	"ahb1",
391cd030a78SIcenowy Zheng 		      0x064, BIT(24), 0);
392cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd_top_clk,	"bus-tvd-top",	"ahb1",
393cd030a78SIcenowy Zheng 		      0x064, BIT(25), 0);
394cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_lcd0_clk,	"bus-tcon-lcd0",	"ahb1",
395cd030a78SIcenowy Zheng 		      0x064, BIT(26), 0);
396cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_lcd1_clk,	"bus-tcon-lcd1",	"ahb1",
397cd030a78SIcenowy Zheng 		      0x064, BIT(27), 0);
398cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_tv0_clk,	"bus-tcon-tv0",	"ahb1",
399cd030a78SIcenowy Zheng 		      0x064, BIT(28), 0);
400cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_tv1_clk,	"bus-tcon-tv1",	"ahb1",
401cd030a78SIcenowy Zheng 		      0x064, BIT(29), 0);
402cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_top_clk,	"bus-tcon-top",	"ahb1",
403cd030a78SIcenowy Zheng 		      0x064, BIT(30), 0);
404cd030a78SIcenowy Zheng 
405cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_codec_clk,	"bus-codec",	"apb1",
406cd030a78SIcenowy Zheng 		      0x068, BIT(0), 0);
407cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spdif_clk,	"bus-spdif",	"apb1",
408cd030a78SIcenowy Zheng 		      0x068, BIT(1), 0);
409cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ac97_clk,	"bus-ac97",	"apb1",
410cd030a78SIcenowy Zheng 		      0x068, BIT(2), 0);
411cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_pio_clk,	"bus-pio",	"apb1",
412cd030a78SIcenowy Zheng 		      0x068, BIT(5), 0);
413cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ir0_clk,	"bus-ir0",	"apb1",
414cd030a78SIcenowy Zheng 		      0x068, BIT(6), 0);
415cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ir1_clk,	"bus-ir1",	"apb1",
416cd030a78SIcenowy Zheng 		      0x068, BIT(7), 0);
417cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ths_clk,	"bus-ths",	"apb1",
418cd030a78SIcenowy Zheng 		      0x068, BIT(8), 0);
419cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_keypad_clk,	"bus-keypad",	"apb1",
420cd030a78SIcenowy Zheng 		      0x068, BIT(10), 0);
421cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s0_clk,	"bus-i2s0",	"apb1",
422cd030a78SIcenowy Zheng 		      0x068, BIT(12), 0);
423cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s1_clk,	"bus-i2s1",	"apb1",
424cd030a78SIcenowy Zheng 		      0x068, BIT(13), 0);
425cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s2_clk,	"bus-i2s2",	"apb1",
426cd030a78SIcenowy Zheng 		      0x068, BIT(14), 0);
427cd030a78SIcenowy Zheng 
428cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c0_clk,	"bus-i2c0",	"apb2",
429cd030a78SIcenowy Zheng 		      0x06c, BIT(0), 0);
430cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c1_clk,	"bus-i2c1",	"apb2",
431cd030a78SIcenowy Zheng 		      0x06c, BIT(1), 0);
432cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c2_clk,	"bus-i2c2",	"apb2",
433cd030a78SIcenowy Zheng 		      0x06c, BIT(2), 0);
434cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c3_clk,	"bus-i2c3",	"apb2",
435cd030a78SIcenowy Zheng 		      0x06c, BIT(3), 0);
436cd030a78SIcenowy Zheng /*
437cd030a78SIcenowy Zheng  * In datasheet here's "Reserved", however the gate exists in BSP soucre
438cd030a78SIcenowy Zheng  * code.
439cd030a78SIcenowy Zheng  */
440cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_can_clk,	"bus-can",	"apb2",
441cd030a78SIcenowy Zheng 		      0x06c, BIT(4), 0);
442cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_scr_clk,	"bus-scr",	"apb2",
443cd030a78SIcenowy Zheng 		      0x06c, BIT(5), 0);
444cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ps20_clk,	"bus-ps20",	"apb2",
445cd030a78SIcenowy Zheng 		      0x06c, BIT(6), 0);
446cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ps21_clk,	"bus-ps21",	"apb2",
447cd030a78SIcenowy Zheng 		      0x06c, BIT(7), 0);
448cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c4_clk,	"bus-i2c4",	"apb2",
449cd030a78SIcenowy Zheng 		      0x06c, BIT(15), 0);
450cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart0_clk,	"bus-uart0",	"apb2",
451cd030a78SIcenowy Zheng 		      0x06c, BIT(16), 0);
452cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart1_clk,	"bus-uart1",	"apb2",
453cd030a78SIcenowy Zheng 		      0x06c, BIT(17), 0);
454cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart2_clk,	"bus-uart2",	"apb2",
455cd030a78SIcenowy Zheng 		      0x06c, BIT(18), 0);
456cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart3_clk,	"bus-uart3",	"apb2",
457cd030a78SIcenowy Zheng 		      0x06c, BIT(19), 0);
458cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart4_clk,	"bus-uart4",	"apb2",
459cd030a78SIcenowy Zheng 		      0x06c, BIT(20), 0);
460cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart5_clk,	"bus-uart5",	"apb2",
461cd030a78SIcenowy Zheng 		      0x06c, BIT(21), 0);
462cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart6_clk,	"bus-uart6",	"apb2",
463cd030a78SIcenowy Zheng 		      0x06c, BIT(22), 0);
464cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart7_clk,	"bus-uart7",	"apb2",
465cd030a78SIcenowy Zheng 		      0x06c, BIT(23), 0);
466cd030a78SIcenowy Zheng 
467cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_dbg_clk,	"bus-dbg",	"ahb1",
468cd030a78SIcenowy Zheng 		      0x070, BIT(7), 0);
469cd030a78SIcenowy Zheng 
470cd030a78SIcenowy Zheng static const char * const ths_parents[] = { "osc24M" };
471cd030a78SIcenowy Zheng static struct ccu_div ths_clk = {
472cd030a78SIcenowy Zheng 	.enable	= BIT(31),
473cd030a78SIcenowy Zheng 	.div	= _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
474cd030a78SIcenowy Zheng 	.mux	= _SUNXI_CCU_MUX(24, 2),
475cd030a78SIcenowy Zheng 	.common	= {
476cd030a78SIcenowy Zheng 		.reg		= 0x074,
477cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("ths",
478cd030a78SIcenowy Zheng 						      ths_parents,
479cd030a78SIcenowy Zheng 						      &ccu_div_ops,
480cd030a78SIcenowy Zheng 						      0),
481cd030a78SIcenowy Zheng 	},
482cd030a78SIcenowy Zheng };
483cd030a78SIcenowy Zheng 
484cd030a78SIcenowy Zheng static const char * const mod0_default_parents[] = { "osc24M", "pll-periph0",
485cd030a78SIcenowy Zheng 						     "pll-periph1" };
486cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
487cd030a78SIcenowy Zheng 				  0, 4,		/* M */
488cd030a78SIcenowy Zheng 				  16, 2,	/* P */
489cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
490cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
491cd030a78SIcenowy Zheng 				  0);
492cd030a78SIcenowy Zheng 
493cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
494cd030a78SIcenowy Zheng 				  0, 4,		/* M */
495cd030a78SIcenowy Zheng 				  16, 2,	/* P */
496cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
497cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
498cd030a78SIcenowy Zheng 				  0);
499cd030a78SIcenowy Zheng 
500cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
501cd030a78SIcenowy Zheng 				  0, 4,		/* M */
502cd030a78SIcenowy Zheng 				  16, 2,	/* P */
503cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
504cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
505cd030a78SIcenowy Zheng 				  0);
506cd030a78SIcenowy Zheng 
507cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
508cd030a78SIcenowy Zheng 				  0, 4,		/* M */
509cd030a78SIcenowy Zheng 				  16, 2,	/* P */
510cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
511cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
512cd030a78SIcenowy Zheng 				  0);
513cd030a78SIcenowy Zheng 
514cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc3_clk, "mmc3", mod0_default_parents, 0x094,
515cd030a78SIcenowy Zheng 				  0, 4,		/* M */
516cd030a78SIcenowy Zheng 				  16, 2,	/* P */
517cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
518cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
519cd030a78SIcenowy Zheng 				  0);
520cd030a78SIcenowy Zheng 
521cd030a78SIcenowy Zheng static const char * const ts_parents[] = { "osc24M", "pll-periph0", };
522cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098,
523cd030a78SIcenowy Zheng 				  0, 4,		/* M */
524cd030a78SIcenowy Zheng 				  16, 2,	/* P */
525cd030a78SIcenowy Zheng 				  24, 4,	/* mux */
526cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
527cd030a78SIcenowy Zheng 				  0);
528cd030a78SIcenowy Zheng 
529cd030a78SIcenowy Zheng static const char * const ce_parents[] = { "osc24M", "pll-periph0-2x",
530cd030a78SIcenowy Zheng 					   "pll-periph1-2x" };
531cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x09c,
532cd030a78SIcenowy Zheng 				  0, 4,		/* M */
533cd030a78SIcenowy Zheng 				  16, 2,	/* P */
534cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
535cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
536cd030a78SIcenowy Zheng 				  0);
537cd030a78SIcenowy Zheng 
538cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
539cd030a78SIcenowy Zheng 				  0, 4,		/* M */
540cd030a78SIcenowy Zheng 				  16, 2,	/* P */
541cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
542cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
543cd030a78SIcenowy Zheng 				  0);
544cd030a78SIcenowy Zheng 
545cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
546cd030a78SIcenowy Zheng 				  0, 4,		/* M */
547cd030a78SIcenowy Zheng 				  16, 2,	/* P */
548cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
549cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
550cd030a78SIcenowy Zheng 				  0);
551cd030a78SIcenowy Zheng 
552cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", mod0_default_parents, 0x0a8,
553cd030a78SIcenowy Zheng 				  0, 4,		/* M */
554cd030a78SIcenowy Zheng 				  16, 2,	/* P */
555cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
556cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
557cd030a78SIcenowy Zheng 				  0);
558cd030a78SIcenowy Zheng 
559cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi3_clk, "spi3", mod0_default_parents, 0x0ac,
560cd030a78SIcenowy Zheng 				  0, 4,		/* M */
561cd030a78SIcenowy Zheng 				  16, 2,	/* P */
562cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
563cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
564cd030a78SIcenowy Zheng 				  0);
565cd030a78SIcenowy Zheng 
566cd030a78SIcenowy Zheng static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
567cd030a78SIcenowy Zheng 					    "pll-audio-2x", "pll-audio" };
568cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
569cd030a78SIcenowy Zheng 			       0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
570cd030a78SIcenowy Zheng 
571cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
572cd030a78SIcenowy Zheng 			       0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
573cd030a78SIcenowy Zheng 
574cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents,
575cd030a78SIcenowy Zheng 			       0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
576cd030a78SIcenowy Zheng 
577cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(ac97_clk, "ac97", i2s_parents,
578cd030a78SIcenowy Zheng 			       0x0bc, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
579cd030a78SIcenowy Zheng 
580cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", i2s_parents,
581cd030a78SIcenowy Zheng 			       0x0c0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
582cd030a78SIcenowy Zheng 
583cd030a78SIcenowy Zheng static const char * const keypad_parents[] = { "osc24M", "osc32k" };
584cd030a78SIcenowy Zheng static const u8 keypad_table[] = { 0, 2 };
585cd030a78SIcenowy Zheng static struct ccu_mp keypad_clk = {
586cd030a78SIcenowy Zheng 	.enable	= BIT(31),
587cd030a78SIcenowy Zheng 	.m	= _SUNXI_CCU_DIV(0, 5),
588cd030a78SIcenowy Zheng 	.p	= _SUNXI_CCU_DIV(16, 2),
589cd030a78SIcenowy Zheng 	.mux	= _SUNXI_CCU_MUX_TABLE(24, 2, keypad_table),
590cd030a78SIcenowy Zheng 	.common	= {
591cd030a78SIcenowy Zheng 		.reg		= 0x0c4,
592cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("keypad",
593cd030a78SIcenowy Zheng 						      keypad_parents,
594cd030a78SIcenowy Zheng 						      &ccu_mp_ops,
595cd030a78SIcenowy Zheng 						      0),
596cd030a78SIcenowy Zheng 	}
597cd030a78SIcenowy Zheng };
598cd030a78SIcenowy Zheng 
599cd030a78SIcenowy Zheng static const char * const sata_parents[] = { "pll-sata-out", "sata-ext" };
600cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(sata_clk, "sata", sata_parents,
601cd030a78SIcenowy Zheng 			       0x0c8, 24, 1, BIT(31), CLK_SET_RATE_PARENT);
602cd030a78SIcenowy Zheng 
603cd030a78SIcenowy Zheng /*
604cd030a78SIcenowy Zheng  * There are 3 OHCI 12M clock source selection bits in this register.
605cd030a78SIcenowy Zheng  * We will force them to 0 (12M divided from 48M).
606cd030a78SIcenowy Zheng  */
607cd030a78SIcenowy Zheng #define SUN8I_R40_USB_CLK_REG	0x0cc
608cd030a78SIcenowy Zheng 
609cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
610cd030a78SIcenowy Zheng 		      0x0cc, BIT(8), 0);
611cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_phy1_clk,	"usb-phy1",	"osc24M",
612cd030a78SIcenowy Zheng 		      0x0cc, BIT(9), 0);
613cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_phy2_clk,	"usb-phy2",	"osc24M",
614cd030a78SIcenowy Zheng 		      0x0cc, BIT(10), 0);
615cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci0_clk,	"usb-ohci0",	"osc12M",
616cd030a78SIcenowy Zheng 		      0x0cc, BIT(16), 0);
617cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci1_clk,	"usb-ohci1",	"osc12M",
618cd030a78SIcenowy Zheng 		      0x0cc, BIT(17), 0);
619cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci2_clk,	"usb-ohci2",	"osc12M",
620cd030a78SIcenowy Zheng 		      0x0cc, BIT(18), 0);
621cd030a78SIcenowy Zheng 
622cd030a78SIcenowy Zheng static const char * const ir_parents[] = { "osc24M", "pll-periph0",
623cd030a78SIcenowy Zheng 					   "pll-periph1", "osc32k" };
624cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ir0_clk, "ir0", ir_parents, 0x0d0,
625cd030a78SIcenowy Zheng 				  0, 4,		/* M */
626cd030a78SIcenowy Zheng 				  16, 2,	/* P */
627cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
628cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
629cd030a78SIcenowy Zheng 				  0);
630cd030a78SIcenowy Zheng 
631cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ir1_clk, "ir1", ir_parents, 0x0d4,
632cd030a78SIcenowy Zheng 				  0, 4,		/* M */
633cd030a78SIcenowy Zheng 				  16, 2,	/* P */
634cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
635cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
636cd030a78SIcenowy Zheng 				  0);
637cd030a78SIcenowy Zheng 
638cd030a78SIcenowy Zheng static const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1" };
639cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
640cd030a78SIcenowy Zheng 			    0x0f4, 0, 2, 20, 2, CLK_IS_CRITICAL);
641cd030a78SIcenowy Zheng 
642cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_ve_clk,	"dram-ve",	"dram",
643cd030a78SIcenowy Zheng 		      0x100, BIT(0), 0);
644cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_csi0_clk,	"dram-csi0",	"dram",
645cd030a78SIcenowy Zheng 		      0x100, BIT(1), 0);
646cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_csi1_clk,	"dram-csi1",	"dram",
647cd030a78SIcenowy Zheng 		      0x100, BIT(2), 0);
648cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_ts_clk,	"dram-ts",	"dram",
649cd030a78SIcenowy Zheng 		      0x100, BIT(3), 0);
650cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_tvd_clk,	"dram-tvd",	"dram",
651cd030a78SIcenowy Zheng 		      0x100, BIT(4), 0);
652cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_mp_clk,	"dram-mp",	"dram",
653cd030a78SIcenowy Zheng 		      0x100, BIT(5), 0);
654cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_deinterlace_clk,	"dram-deinterlace",	"dram",
655cd030a78SIcenowy Zheng 		      0x100, BIT(6), 0);
656cd030a78SIcenowy Zheng 
657cd030a78SIcenowy Zheng static const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
658cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
659fb4aa0f6SJernej Skrabec 				 0x104, 0, 4, 24, 3, BIT(31),
660fb4aa0f6SJernej Skrabec 				 CLK_SET_RATE_PARENT);
661cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(mp_clk, "mp", de_parents,
662cd030a78SIcenowy Zheng 				 0x108, 0, 4, 24, 3, BIT(31), 0);
663cd030a78SIcenowy Zheng 
664cd030a78SIcenowy Zheng static const char * const tcon_parents[] = { "pll-video0", "pll-video1",
665cd030a78SIcenowy Zheng 					     "pll-video0-2x", "pll-video1-2x",
666cd030a78SIcenowy Zheng 					     "pll-mipi" };
667cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(tcon_lcd0_clk, "tcon-lcd0", tcon_parents,
668cd030a78SIcenowy Zheng 			       0x110, 24, 3, BIT(31), CLK_SET_RATE_PARENT);
669cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(tcon_lcd1_clk, "tcon-lcd1", tcon_parents,
670cd030a78SIcenowy Zheng 			       0x114, 24, 3, BIT(31), CLK_SET_RATE_PARENT);
671cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv0_clk, "tcon-tv0", tcon_parents,
672fb4aa0f6SJernej Skrabec 				 0x118, 0, 4, 24, 3, BIT(31),
673fb4aa0f6SJernej Skrabec 				 CLK_SET_RATE_PARENT);
674cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv1_clk, "tcon-tv1", tcon_parents,
675fb4aa0f6SJernej Skrabec 				 0x11c, 0, 4, 24, 3, BIT(31),
676fb4aa0f6SJernej Skrabec 				 CLK_SET_RATE_PARENT);
677cd030a78SIcenowy Zheng 
678cd030a78SIcenowy Zheng static const char * const deinterlace_parents[] = { "pll-periph0",
679cd030a78SIcenowy Zheng 						    "pll-periph1" };
680cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace",
681cd030a78SIcenowy Zheng 				 deinterlace_parents, 0x124, 0, 4, 24, 3,
682cd030a78SIcenowy Zheng 				 BIT(31), 0);
683cd030a78SIcenowy Zheng 
684cd030a78SIcenowy Zheng static const char * const csi_mclk_parents[] = { "osc24M", "pll-video1",
685cd030a78SIcenowy Zheng 						 "pll-periph1" };
686cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk, "csi1-mclk", csi_mclk_parents,
687cd030a78SIcenowy Zheng 				 0x130, 0, 5, 8, 3, BIT(15), 0);
688cd030a78SIcenowy Zheng 
689cd030a78SIcenowy Zheng static const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
690cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
691cd030a78SIcenowy Zheng 				 0x134, 16, 4, 24, 3, BIT(31), 0);
692cd030a78SIcenowy Zheng 
693cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk, "csi0-mclk", csi_mclk_parents,
694cd030a78SIcenowy Zheng 				 0x134, 0, 5, 8, 3, BIT(15), 0);
695cd030a78SIcenowy Zheng 
696cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
697cd030a78SIcenowy Zheng 			     0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT);
698cd030a78SIcenowy Zheng 
699cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(codec_clk,	"codec",	"pll-audio",
700cd030a78SIcenowy Zheng 		      0x140, BIT(31), CLK_SET_RATE_PARENT);
701cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
702cd030a78SIcenowy Zheng 		      0x144, BIT(31), 0);
703cd030a78SIcenowy Zheng 
704cd030a78SIcenowy Zheng static const char * const hdmi_parents[] = { "pll-video0", "pll-video1" };
705cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
706fb4aa0f6SJernej Skrabec 				 0x150, 0, 4, 24, 2, BIT(31),
707fb4aa0f6SJernej Skrabec 				 CLK_SET_RATE_PARENT);
708cd030a78SIcenowy Zheng 
709cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(hdmi_slow_clk,	"hdmi-slow",	"osc24M",
710cd030a78SIcenowy Zheng 		      0x154, BIT(31), 0);
711cd030a78SIcenowy Zheng 
712cd030a78SIcenowy Zheng /*
713cd030a78SIcenowy Zheng  * In the SoC's user manual, the P factor is mentioned, but not used in
714cd030a78SIcenowy Zheng  * the frequency formula.
715cd030a78SIcenowy Zheng  *
716cd030a78SIcenowy Zheng  * Here the factor is included, according to the BSP kernel source,
717cd030a78SIcenowy Zheng  * which contains the P factor of this clock.
718cd030a78SIcenowy Zheng  */
719cd030a78SIcenowy Zheng static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x",
720cd030a78SIcenowy Zheng 					     "pll-ddr0" };
721cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x15c,
722cd030a78SIcenowy Zheng 				  0, 4,		/* M */
723cd030a78SIcenowy Zheng 				  16, 2,	/* P */
724cd030a78SIcenowy Zheng 				  24, 2,	/* mux */
725cd030a78SIcenowy Zheng 				  BIT(31),	/* gate */
726cd030a78SIcenowy Zheng 				  CLK_IS_CRITICAL);
727cd030a78SIcenowy Zheng 
728cd030a78SIcenowy Zheng static const char * const dsi_dphy_parents[] = { "pll-video0", "pll-video1",
729cd030a78SIcenowy Zheng 						 "pll-periph0" };
730cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(dsi_dphy_clk, "dsi-dphy", dsi_dphy_parents,
731cd030a78SIcenowy Zheng 				 0x168, 0, 4, 8, 2, BIT(15), 0);
732cd030a78SIcenowy Zheng 
733cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tve0_clk, "tve0", tcon_parents,
734cd030a78SIcenowy Zheng 				 0x180, 0, 4, 24, 3, BIT(31), 0);
735cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tve1_clk, "tve1", tcon_parents,
736cd030a78SIcenowy Zheng 				 0x184, 0, 4, 24, 3, BIT(31), 0);
737cd030a78SIcenowy Zheng 
738cd030a78SIcenowy Zheng static const char * const tvd_parents[] = { "pll-video0", "pll-video1",
739cd030a78SIcenowy Zheng 					    "pll-video0-2x", "pll-video1-2x" };
740cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd0_clk, "tvd0", tvd_parents,
741cd030a78SIcenowy Zheng 				 0x188, 0, 4, 24, 3, BIT(31), 0);
742cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd1_clk, "tvd1", tvd_parents,
743cd030a78SIcenowy Zheng 				 0x18c, 0, 4, 24, 3, BIT(31), 0);
744cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd2_clk, "tvd2", tvd_parents,
745cd030a78SIcenowy Zheng 				 0x190, 0, 4, 24, 3, BIT(31), 0);
746cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd3_clk, "tvd3", tvd_parents,
747cd030a78SIcenowy Zheng 				 0x194, 0, 4, 24, 3, BIT(31), 0);
748cd030a78SIcenowy Zheng 
749cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
750cd030a78SIcenowy Zheng 			     0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);
751cd030a78SIcenowy Zheng 
752cd030a78SIcenowy Zheng static const char * const out_parents[] = { "osc24M", "osc32k", "osc24M" };
753cd030a78SIcenowy Zheng static const struct ccu_mux_fixed_prediv out_predivs[] = {
754cd030a78SIcenowy Zheng 	{ .index = 0, .div = 750, },
755cd030a78SIcenowy Zheng };
756cd030a78SIcenowy Zheng 
757cd030a78SIcenowy Zheng static struct ccu_mp outa_clk = {
758cd030a78SIcenowy Zheng 	.enable	= BIT(31),
759cd030a78SIcenowy Zheng 	.m	= _SUNXI_CCU_DIV(8, 5),
760cd030a78SIcenowy Zheng 	.p	= _SUNXI_CCU_DIV(20, 2),
761cd030a78SIcenowy Zheng 	.mux	= {
762cd030a78SIcenowy Zheng 		.shift		= 24,
763cd030a78SIcenowy Zheng 		.width		= 2,
764cd030a78SIcenowy Zheng 		.fixed_predivs	= out_predivs,
765cd030a78SIcenowy Zheng 		.n_predivs	= ARRAY_SIZE(out_predivs),
766cd030a78SIcenowy Zheng 	},
767cd030a78SIcenowy Zheng 	.common	= {
768cd030a78SIcenowy Zheng 		.reg		= 0x1f0,
769cd030a78SIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_PREDIV,
770cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("outa", out_parents,
771cd030a78SIcenowy Zheng 						      &ccu_mp_ops, 0),
772cd030a78SIcenowy Zheng 	}
773cd030a78SIcenowy Zheng };
774cd030a78SIcenowy Zheng 
775cd030a78SIcenowy Zheng static struct ccu_mp outb_clk = {
776cd030a78SIcenowy Zheng 	.enable	= BIT(31),
777cd030a78SIcenowy Zheng 	.m	= _SUNXI_CCU_DIV(8, 5),
778cd030a78SIcenowy Zheng 	.p	= _SUNXI_CCU_DIV(20, 2),
779cd030a78SIcenowy Zheng 	.mux	= {
780cd030a78SIcenowy Zheng 		.shift		= 24,
781cd030a78SIcenowy Zheng 		.width		= 2,
782cd030a78SIcenowy Zheng 		.fixed_predivs	= out_predivs,
783cd030a78SIcenowy Zheng 		.n_predivs	= ARRAY_SIZE(out_predivs),
784cd030a78SIcenowy Zheng 	},
785cd030a78SIcenowy Zheng 	.common	= {
786cd030a78SIcenowy Zheng 		.reg		= 0x1f4,
787cd030a78SIcenowy Zheng 		.features	= CCU_FEATURE_FIXED_PREDIV,
788cd030a78SIcenowy Zheng 		.hw.init	= CLK_HW_INIT_PARENTS("outb", out_parents,
789cd030a78SIcenowy Zheng 						      &ccu_mp_ops, 0),
790cd030a78SIcenowy Zheng 	}
791cd030a78SIcenowy Zheng };
792cd030a78SIcenowy Zheng 
793cd030a78SIcenowy Zheng static struct ccu_common *sun8i_r40_ccu_clks[] = {
794cd030a78SIcenowy Zheng 	&pll_cpu_clk.common,
795cd030a78SIcenowy Zheng 	&pll_audio_base_clk.common,
796cd030a78SIcenowy Zheng 	&pll_video0_clk.common,
797cd030a78SIcenowy Zheng 	&pll_ve_clk.common,
798cd030a78SIcenowy Zheng 	&pll_ddr0_clk.common,
799cd030a78SIcenowy Zheng 	&pll_periph0_clk.common,
800cd030a78SIcenowy Zheng 	&pll_periph0_sata_clk.common,
801cd030a78SIcenowy Zheng 	&pll_periph1_clk.common,
802cd030a78SIcenowy Zheng 	&pll_video1_clk.common,
803cd030a78SIcenowy Zheng 	&pll_sata_clk.common,
804cd030a78SIcenowy Zheng 	&pll_sata_out_clk.common,
805cd030a78SIcenowy Zheng 	&pll_gpu_clk.common,
806cd030a78SIcenowy Zheng 	&pll_mipi_clk.common,
807cd030a78SIcenowy Zheng 	&pll_de_clk.common,
808cd030a78SIcenowy Zheng 	&pll_ddr1_clk.common,
809cd030a78SIcenowy Zheng 	&cpu_clk.common,
810cd030a78SIcenowy Zheng 	&axi_clk.common,
811cd030a78SIcenowy Zheng 	&ahb1_clk.common,
812cd030a78SIcenowy Zheng 	&apb1_clk.common,
813cd030a78SIcenowy Zheng 	&apb2_clk.common,
814cd030a78SIcenowy Zheng 	&bus_mipi_dsi_clk.common,
815cd030a78SIcenowy Zheng 	&bus_ce_clk.common,
816cd030a78SIcenowy Zheng 	&bus_dma_clk.common,
817cd030a78SIcenowy Zheng 	&bus_mmc0_clk.common,
818cd030a78SIcenowy Zheng 	&bus_mmc1_clk.common,
819cd030a78SIcenowy Zheng 	&bus_mmc2_clk.common,
820cd030a78SIcenowy Zheng 	&bus_mmc3_clk.common,
821cd030a78SIcenowy Zheng 	&bus_nand_clk.common,
822cd030a78SIcenowy Zheng 	&bus_dram_clk.common,
823cd030a78SIcenowy Zheng 	&bus_emac_clk.common,
824cd030a78SIcenowy Zheng 	&bus_ts_clk.common,
825cd030a78SIcenowy Zheng 	&bus_hstimer_clk.common,
826cd030a78SIcenowy Zheng 	&bus_spi0_clk.common,
827cd030a78SIcenowy Zheng 	&bus_spi1_clk.common,
828cd030a78SIcenowy Zheng 	&bus_spi2_clk.common,
829cd030a78SIcenowy Zheng 	&bus_spi3_clk.common,
830cd030a78SIcenowy Zheng 	&bus_sata_clk.common,
831cd030a78SIcenowy Zheng 	&bus_otg_clk.common,
832cd030a78SIcenowy Zheng 	&bus_ehci0_clk.common,
833cd030a78SIcenowy Zheng 	&bus_ehci1_clk.common,
834cd030a78SIcenowy Zheng 	&bus_ehci2_clk.common,
835cd030a78SIcenowy Zheng 	&bus_ohci0_clk.common,
836cd030a78SIcenowy Zheng 	&bus_ohci1_clk.common,
837cd030a78SIcenowy Zheng 	&bus_ohci2_clk.common,
838cd030a78SIcenowy Zheng 	&bus_ve_clk.common,
839cd030a78SIcenowy Zheng 	&bus_mp_clk.common,
840cd030a78SIcenowy Zheng 	&bus_deinterlace_clk.common,
841cd030a78SIcenowy Zheng 	&bus_csi0_clk.common,
842cd030a78SIcenowy Zheng 	&bus_csi1_clk.common,
843cd030a78SIcenowy Zheng 	&bus_hdmi0_clk.common,
844cd030a78SIcenowy Zheng 	&bus_hdmi1_clk.common,
845cd030a78SIcenowy Zheng 	&bus_de_clk.common,
846cd030a78SIcenowy Zheng 	&bus_tve0_clk.common,
847cd030a78SIcenowy Zheng 	&bus_tve1_clk.common,
848cd030a78SIcenowy Zheng 	&bus_tve_top_clk.common,
849cd030a78SIcenowy Zheng 	&bus_gmac_clk.common,
850cd030a78SIcenowy Zheng 	&bus_gpu_clk.common,
851cd030a78SIcenowy Zheng 	&bus_tvd0_clk.common,
852cd030a78SIcenowy Zheng 	&bus_tvd1_clk.common,
853cd030a78SIcenowy Zheng 	&bus_tvd2_clk.common,
854cd030a78SIcenowy Zheng 	&bus_tvd3_clk.common,
855cd030a78SIcenowy Zheng 	&bus_tvd_top_clk.common,
856cd030a78SIcenowy Zheng 	&bus_tcon_lcd0_clk.common,
857cd030a78SIcenowy Zheng 	&bus_tcon_lcd1_clk.common,
858cd030a78SIcenowy Zheng 	&bus_tcon_tv0_clk.common,
859cd030a78SIcenowy Zheng 	&bus_tcon_tv1_clk.common,
860cd030a78SIcenowy Zheng 	&bus_tcon_top_clk.common,
861cd030a78SIcenowy Zheng 	&bus_codec_clk.common,
862cd030a78SIcenowy Zheng 	&bus_spdif_clk.common,
863cd030a78SIcenowy Zheng 	&bus_ac97_clk.common,
864cd030a78SIcenowy Zheng 	&bus_pio_clk.common,
865cd030a78SIcenowy Zheng 	&bus_ir0_clk.common,
866cd030a78SIcenowy Zheng 	&bus_ir1_clk.common,
867cd030a78SIcenowy Zheng 	&bus_ths_clk.common,
868cd030a78SIcenowy Zheng 	&bus_keypad_clk.common,
869cd030a78SIcenowy Zheng 	&bus_i2s0_clk.common,
870cd030a78SIcenowy Zheng 	&bus_i2s1_clk.common,
871cd030a78SIcenowy Zheng 	&bus_i2s2_clk.common,
872cd030a78SIcenowy Zheng 	&bus_i2c0_clk.common,
873cd030a78SIcenowy Zheng 	&bus_i2c1_clk.common,
874cd030a78SIcenowy Zheng 	&bus_i2c2_clk.common,
875cd030a78SIcenowy Zheng 	&bus_i2c3_clk.common,
876cd030a78SIcenowy Zheng 	&bus_can_clk.common,
877cd030a78SIcenowy Zheng 	&bus_scr_clk.common,
878cd030a78SIcenowy Zheng 	&bus_ps20_clk.common,
879cd030a78SIcenowy Zheng 	&bus_ps21_clk.common,
880cd030a78SIcenowy Zheng 	&bus_i2c4_clk.common,
881cd030a78SIcenowy Zheng 	&bus_uart0_clk.common,
882cd030a78SIcenowy Zheng 	&bus_uart1_clk.common,
883cd030a78SIcenowy Zheng 	&bus_uart2_clk.common,
884cd030a78SIcenowy Zheng 	&bus_uart3_clk.common,
885cd030a78SIcenowy Zheng 	&bus_uart4_clk.common,
886cd030a78SIcenowy Zheng 	&bus_uart5_clk.common,
887cd030a78SIcenowy Zheng 	&bus_uart6_clk.common,
888cd030a78SIcenowy Zheng 	&bus_uart7_clk.common,
889cd030a78SIcenowy Zheng 	&bus_dbg_clk.common,
890cd030a78SIcenowy Zheng 	&ths_clk.common,
891cd030a78SIcenowy Zheng 	&nand_clk.common,
892cd030a78SIcenowy Zheng 	&mmc0_clk.common,
893cd030a78SIcenowy Zheng 	&mmc1_clk.common,
894cd030a78SIcenowy Zheng 	&mmc2_clk.common,
895cd030a78SIcenowy Zheng 	&mmc3_clk.common,
896cd030a78SIcenowy Zheng 	&ts_clk.common,
897cd030a78SIcenowy Zheng 	&ce_clk.common,
898cd030a78SIcenowy Zheng 	&spi0_clk.common,
899cd030a78SIcenowy Zheng 	&spi1_clk.common,
900cd030a78SIcenowy Zheng 	&spi2_clk.common,
901cd030a78SIcenowy Zheng 	&spi3_clk.common,
902cd030a78SIcenowy Zheng 	&i2s0_clk.common,
903cd030a78SIcenowy Zheng 	&i2s1_clk.common,
904cd030a78SIcenowy Zheng 	&i2s2_clk.common,
905cd030a78SIcenowy Zheng 	&ac97_clk.common,
906cd030a78SIcenowy Zheng 	&spdif_clk.common,
907cd030a78SIcenowy Zheng 	&keypad_clk.common,
908cd030a78SIcenowy Zheng 	&sata_clk.common,
909cd030a78SIcenowy Zheng 	&usb_phy0_clk.common,
910cd030a78SIcenowy Zheng 	&usb_phy1_clk.common,
911cd030a78SIcenowy Zheng 	&usb_phy2_clk.common,
912cd030a78SIcenowy Zheng 	&usb_ohci0_clk.common,
913cd030a78SIcenowy Zheng 	&usb_ohci1_clk.common,
914cd030a78SIcenowy Zheng 	&usb_ohci2_clk.common,
915cd030a78SIcenowy Zheng 	&ir0_clk.common,
916cd030a78SIcenowy Zheng 	&ir1_clk.common,
917cd030a78SIcenowy Zheng 	&dram_clk.common,
918cd030a78SIcenowy Zheng 	&dram_ve_clk.common,
919cd030a78SIcenowy Zheng 	&dram_csi0_clk.common,
920cd030a78SIcenowy Zheng 	&dram_csi1_clk.common,
921cd030a78SIcenowy Zheng 	&dram_ts_clk.common,
922cd030a78SIcenowy Zheng 	&dram_tvd_clk.common,
923cd030a78SIcenowy Zheng 	&dram_mp_clk.common,
924cd030a78SIcenowy Zheng 	&dram_deinterlace_clk.common,
925cd030a78SIcenowy Zheng 	&de_clk.common,
926cd030a78SIcenowy Zheng 	&mp_clk.common,
927cd030a78SIcenowy Zheng 	&tcon_lcd0_clk.common,
928cd030a78SIcenowy Zheng 	&tcon_lcd1_clk.common,
929cd030a78SIcenowy Zheng 	&tcon_tv0_clk.common,
930cd030a78SIcenowy Zheng 	&tcon_tv1_clk.common,
931cd030a78SIcenowy Zheng 	&deinterlace_clk.common,
932cd030a78SIcenowy Zheng 	&csi1_mclk_clk.common,
933cd030a78SIcenowy Zheng 	&csi_sclk_clk.common,
934cd030a78SIcenowy Zheng 	&csi0_mclk_clk.common,
935cd030a78SIcenowy Zheng 	&ve_clk.common,
936cd030a78SIcenowy Zheng 	&codec_clk.common,
937cd030a78SIcenowy Zheng 	&avs_clk.common,
938cd030a78SIcenowy Zheng 	&hdmi_clk.common,
939cd030a78SIcenowy Zheng 	&hdmi_slow_clk.common,
940cd030a78SIcenowy Zheng 	&mbus_clk.common,
941cd030a78SIcenowy Zheng 	&dsi_dphy_clk.common,
942cd030a78SIcenowy Zheng 	&tve0_clk.common,
943cd030a78SIcenowy Zheng 	&tve1_clk.common,
944cd030a78SIcenowy Zheng 	&tvd0_clk.common,
945cd030a78SIcenowy Zheng 	&tvd1_clk.common,
946cd030a78SIcenowy Zheng 	&tvd2_clk.common,
947cd030a78SIcenowy Zheng 	&tvd3_clk.common,
948cd030a78SIcenowy Zheng 	&gpu_clk.common,
949cd030a78SIcenowy Zheng 	&outa_clk.common,
950cd030a78SIcenowy Zheng 	&outb_clk.common,
951cd030a78SIcenowy Zheng };
952cd030a78SIcenowy Zheng 
953cd030a78SIcenowy Zheng /* Fixed Factor clocks */
954cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(osc12M_clk, "osc12M", "osc24M", 2, 1, 0);
955cd030a78SIcenowy Zheng 
956cd030a78SIcenowy Zheng /* We hardcode the divider to 4 for now */
957cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",
958cd030a78SIcenowy Zheng 			"pll-audio-base", 4, 1, CLK_SET_RATE_PARENT);
959cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x",
960cd030a78SIcenowy Zheng 			"pll-audio-base", 2, 1, CLK_SET_RATE_PARENT);
961cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x",
962cd030a78SIcenowy Zheng 			"pll-audio-base", 1, 1, CLK_SET_RATE_PARENT);
963cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_8x_clk, "pll-audio-8x",
964cd030a78SIcenowy Zheng 			"pll-audio-base", 1, 2, CLK_SET_RATE_PARENT);
965cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x",
966cd030a78SIcenowy Zheng 			"pll-periph0", 1, 2, 0);
967cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph1_2x_clk, "pll-periph1-2x",
968cd030a78SIcenowy Zheng 			"pll-periph1", 1, 2, 0);
969cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_video0_2x_clk, "pll-video0-2x",
970cd030a78SIcenowy Zheng 			"pll-video0", 1, 2, 0);
971cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_video1_2x_clk, "pll-video1-2x",
972cd030a78SIcenowy Zheng 			"pll-video1", 1, 2, 0);
973cd030a78SIcenowy Zheng 
974cd030a78SIcenowy Zheng static struct clk_hw_onecell_data sun8i_r40_hw_clks = {
975cd030a78SIcenowy Zheng 	.hws	= {
976cd030a78SIcenowy Zheng 		[CLK_OSC_12M]		= &osc12M_clk.hw,
977cd030a78SIcenowy Zheng 		[CLK_PLL_CPU]		= &pll_cpu_clk.common.hw,
978cd030a78SIcenowy Zheng 		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
979cd030a78SIcenowy Zheng 		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
980cd030a78SIcenowy Zheng 		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
981cd030a78SIcenowy Zheng 		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
982cd030a78SIcenowy Zheng 		[CLK_PLL_AUDIO_8X]	= &pll_audio_8x_clk.hw,
983cd030a78SIcenowy Zheng 		[CLK_PLL_VIDEO0]	= &pll_video0_clk.common.hw,
984cd030a78SIcenowy Zheng 		[CLK_PLL_VIDEO0_2X]	= &pll_video0_2x_clk.hw,
985cd030a78SIcenowy Zheng 		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
986cd030a78SIcenowy Zheng 		[CLK_PLL_DDR0]		= &pll_ddr0_clk.common.hw,
987cd030a78SIcenowy Zheng 		[CLK_PLL_PERIPH0]	= &pll_periph0_clk.common.hw,
988cd030a78SIcenowy Zheng 		[CLK_PLL_PERIPH0_SATA]	= &pll_periph0_sata_clk.common.hw,
989cd030a78SIcenowy Zheng 		[CLK_PLL_PERIPH0_2X]	= &pll_periph0_2x_clk.hw,
990cd030a78SIcenowy Zheng 		[CLK_PLL_PERIPH1]	= &pll_periph1_clk.common.hw,
991cd030a78SIcenowy Zheng 		[CLK_PLL_PERIPH1_2X]	= &pll_periph1_2x_clk.hw,
992cd030a78SIcenowy Zheng 		[CLK_PLL_VIDEO1]	= &pll_video1_clk.common.hw,
993cd030a78SIcenowy Zheng 		[CLK_PLL_VIDEO1_2X]	= &pll_video1_2x_clk.hw,
994cd030a78SIcenowy Zheng 		[CLK_PLL_SATA]		= &pll_sata_clk.common.hw,
995cd030a78SIcenowy Zheng 		[CLK_PLL_SATA_OUT]	= &pll_sata_out_clk.common.hw,
996cd030a78SIcenowy Zheng 		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,
997cd030a78SIcenowy Zheng 		[CLK_PLL_MIPI]		= &pll_mipi_clk.common.hw,
998cd030a78SIcenowy Zheng 		[CLK_PLL_DE]		= &pll_de_clk.common.hw,
999cd030a78SIcenowy Zheng 		[CLK_PLL_DDR1]		= &pll_ddr1_clk.common.hw,
1000cd030a78SIcenowy Zheng 		[CLK_CPU]		= &cpu_clk.common.hw,
1001cd030a78SIcenowy Zheng 		[CLK_AXI]		= &axi_clk.common.hw,
1002cd030a78SIcenowy Zheng 		[CLK_AHB1]		= &ahb1_clk.common.hw,
1003cd030a78SIcenowy Zheng 		[CLK_APB1]		= &apb1_clk.common.hw,
1004cd030a78SIcenowy Zheng 		[CLK_APB2]		= &apb2_clk.common.hw,
1005cd030a78SIcenowy Zheng 		[CLK_BUS_MIPI_DSI]	= &bus_mipi_dsi_clk.common.hw,
1006cd030a78SIcenowy Zheng 		[CLK_BUS_CE]		= &bus_ce_clk.common.hw,
1007cd030a78SIcenowy Zheng 		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
1008cd030a78SIcenowy Zheng 		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
1009cd030a78SIcenowy Zheng 		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
1010cd030a78SIcenowy Zheng 		[CLK_BUS_MMC2]		= &bus_mmc2_clk.common.hw,
1011cd030a78SIcenowy Zheng 		[CLK_BUS_MMC3]		= &bus_mmc3_clk.common.hw,
1012cd030a78SIcenowy Zheng 		[CLK_BUS_NAND]		= &bus_nand_clk.common.hw,
1013cd030a78SIcenowy Zheng 		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
1014cd030a78SIcenowy Zheng 		[CLK_BUS_EMAC]		= &bus_emac_clk.common.hw,
1015cd030a78SIcenowy Zheng 		[CLK_BUS_TS]		= &bus_ts_clk.common.hw,
1016cd030a78SIcenowy Zheng 		[CLK_BUS_HSTIMER]	= &bus_hstimer_clk.common.hw,
1017cd030a78SIcenowy Zheng 		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
1018cd030a78SIcenowy Zheng 		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
1019cd030a78SIcenowy Zheng 		[CLK_BUS_SPI2]		= &bus_spi2_clk.common.hw,
1020cd030a78SIcenowy Zheng 		[CLK_BUS_SPI3]		= &bus_spi3_clk.common.hw,
1021cd030a78SIcenowy Zheng 		[CLK_BUS_SATA]		= &bus_sata_clk.common.hw,
1022cd030a78SIcenowy Zheng 		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
1023cd030a78SIcenowy Zheng 		[CLK_BUS_EHCI0]		= &bus_ehci0_clk.common.hw,
1024cd030a78SIcenowy Zheng 		[CLK_BUS_EHCI1]		= &bus_ehci1_clk.common.hw,
1025cd030a78SIcenowy Zheng 		[CLK_BUS_EHCI2]		= &bus_ehci2_clk.common.hw,
1026cd030a78SIcenowy Zheng 		[CLK_BUS_OHCI0]		= &bus_ohci0_clk.common.hw,
1027cd030a78SIcenowy Zheng 		[CLK_BUS_OHCI1]		= &bus_ohci1_clk.common.hw,
1028cd030a78SIcenowy Zheng 		[CLK_BUS_OHCI2]		= &bus_ohci2_clk.common.hw,
1029cd030a78SIcenowy Zheng 		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
1030cd030a78SIcenowy Zheng 		[CLK_BUS_MP]		= &bus_mp_clk.common.hw,
1031cd030a78SIcenowy Zheng 		[CLK_BUS_DEINTERLACE]	= &bus_deinterlace_clk.common.hw,
1032cd030a78SIcenowy Zheng 		[CLK_BUS_CSI0]		= &bus_csi0_clk.common.hw,
1033cd030a78SIcenowy Zheng 		[CLK_BUS_CSI1]		= &bus_csi1_clk.common.hw,
1034cd030a78SIcenowy Zheng 		[CLK_BUS_HDMI0]		= &bus_hdmi0_clk.common.hw,
1035cd030a78SIcenowy Zheng 		[CLK_BUS_HDMI1]		= &bus_hdmi1_clk.common.hw,
1036cd030a78SIcenowy Zheng 		[CLK_BUS_DE]		= &bus_de_clk.common.hw,
1037cd030a78SIcenowy Zheng 		[CLK_BUS_TVE0]		= &bus_tve0_clk.common.hw,
1038cd030a78SIcenowy Zheng 		[CLK_BUS_TVE1]		= &bus_tve1_clk.common.hw,
1039cd030a78SIcenowy Zheng 		[CLK_BUS_TVE_TOP]	= &bus_tve_top_clk.common.hw,
1040cd030a78SIcenowy Zheng 		[CLK_BUS_GMAC]		= &bus_gmac_clk.common.hw,
1041cd030a78SIcenowy Zheng 		[CLK_BUS_GPU]		= &bus_gpu_clk.common.hw,
1042cd030a78SIcenowy Zheng 		[CLK_BUS_TVD0]		= &bus_tvd0_clk.common.hw,
1043cd030a78SIcenowy Zheng 		[CLK_BUS_TVD1]		= &bus_tvd1_clk.common.hw,
1044cd030a78SIcenowy Zheng 		[CLK_BUS_TVD2]		= &bus_tvd2_clk.common.hw,
1045cd030a78SIcenowy Zheng 		[CLK_BUS_TVD3]		= &bus_tvd3_clk.common.hw,
1046cd030a78SIcenowy Zheng 		[CLK_BUS_TVD_TOP]	= &bus_tvd_top_clk.common.hw,
1047cd030a78SIcenowy Zheng 		[CLK_BUS_TCON_LCD0]	= &bus_tcon_lcd0_clk.common.hw,
1048cd030a78SIcenowy Zheng 		[CLK_BUS_TCON_LCD1]	= &bus_tcon_lcd1_clk.common.hw,
1049cd030a78SIcenowy Zheng 		[CLK_BUS_TCON_TV0]	= &bus_tcon_tv0_clk.common.hw,
1050cd030a78SIcenowy Zheng 		[CLK_BUS_TCON_TV1]	= &bus_tcon_tv1_clk.common.hw,
1051cd030a78SIcenowy Zheng 		[CLK_BUS_TCON_TOP]	= &bus_tcon_top_clk.common.hw,
1052cd030a78SIcenowy Zheng 		[CLK_BUS_CODEC]		= &bus_codec_clk.common.hw,
1053cd030a78SIcenowy Zheng 		[CLK_BUS_SPDIF]		= &bus_spdif_clk.common.hw,
1054cd030a78SIcenowy Zheng 		[CLK_BUS_AC97]		= &bus_ac97_clk.common.hw,
1055cd030a78SIcenowy Zheng 		[CLK_BUS_PIO]		= &bus_pio_clk.common.hw,
1056cd030a78SIcenowy Zheng 		[CLK_BUS_IR0]		= &bus_ir0_clk.common.hw,
1057cd030a78SIcenowy Zheng 		[CLK_BUS_IR1]		= &bus_ir1_clk.common.hw,
1058cd030a78SIcenowy Zheng 		[CLK_BUS_THS]		= &bus_ths_clk.common.hw,
1059cd030a78SIcenowy Zheng 		[CLK_BUS_KEYPAD]	= &bus_keypad_clk.common.hw,
1060cd030a78SIcenowy Zheng 		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
1061cd030a78SIcenowy Zheng 		[CLK_BUS_I2S1]		= &bus_i2s1_clk.common.hw,
1062cd030a78SIcenowy Zheng 		[CLK_BUS_I2S2]		= &bus_i2s2_clk.common.hw,
1063cd030a78SIcenowy Zheng 		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
1064cd030a78SIcenowy Zheng 		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
1065cd030a78SIcenowy Zheng 		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
1066cd030a78SIcenowy Zheng 		[CLK_BUS_I2C3]		= &bus_i2c3_clk.common.hw,
1067cd030a78SIcenowy Zheng 		[CLK_BUS_CAN]		= &bus_can_clk.common.hw,
1068cd030a78SIcenowy Zheng 		[CLK_BUS_SCR]		= &bus_scr_clk.common.hw,
1069cd030a78SIcenowy Zheng 		[CLK_BUS_PS20]		= &bus_ps20_clk.common.hw,
1070cd030a78SIcenowy Zheng 		[CLK_BUS_PS21]		= &bus_ps21_clk.common.hw,
1071cd030a78SIcenowy Zheng 		[CLK_BUS_I2C4]		= &bus_i2c4_clk.common.hw,
1072cd030a78SIcenowy Zheng 		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
1073cd030a78SIcenowy Zheng 		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
1074cd030a78SIcenowy Zheng 		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
1075cd030a78SIcenowy Zheng 		[CLK_BUS_UART3]		= &bus_uart3_clk.common.hw,
1076cd030a78SIcenowy Zheng 		[CLK_BUS_UART4]		= &bus_uart4_clk.common.hw,
1077cd030a78SIcenowy Zheng 		[CLK_BUS_UART5]		= &bus_uart5_clk.common.hw,
1078cd030a78SIcenowy Zheng 		[CLK_BUS_UART6]		= &bus_uart6_clk.common.hw,
1079cd030a78SIcenowy Zheng 		[CLK_BUS_UART7]		= &bus_uart7_clk.common.hw,
1080cd030a78SIcenowy Zheng 		[CLK_BUS_DBG]		= &bus_dbg_clk.common.hw,
1081cd030a78SIcenowy Zheng 		[CLK_THS]		= &ths_clk.common.hw,
1082cd030a78SIcenowy Zheng 		[CLK_NAND]		= &nand_clk.common.hw,
1083cd030a78SIcenowy Zheng 		[CLK_MMC0]		= &mmc0_clk.common.hw,
1084cd030a78SIcenowy Zheng 		[CLK_MMC1]		= &mmc1_clk.common.hw,
1085cd030a78SIcenowy Zheng 		[CLK_MMC2]		= &mmc2_clk.common.hw,
1086cd030a78SIcenowy Zheng 		[CLK_MMC3]		= &mmc3_clk.common.hw,
1087cd030a78SIcenowy Zheng 		[CLK_TS]		= &ts_clk.common.hw,
1088cd030a78SIcenowy Zheng 		[CLK_CE]		= &ce_clk.common.hw,
1089cd030a78SIcenowy Zheng 		[CLK_SPI0]		= &spi0_clk.common.hw,
1090cd030a78SIcenowy Zheng 		[CLK_SPI1]		= &spi1_clk.common.hw,
1091cd030a78SIcenowy Zheng 		[CLK_SPI2]		= &spi2_clk.common.hw,
1092cd030a78SIcenowy Zheng 		[CLK_SPI3]		= &spi3_clk.common.hw,
1093cd030a78SIcenowy Zheng 		[CLK_I2S0]		= &i2s0_clk.common.hw,
1094cd030a78SIcenowy Zheng 		[CLK_I2S1]		= &i2s1_clk.common.hw,
1095cd030a78SIcenowy Zheng 		[CLK_I2S2]		= &i2s2_clk.common.hw,
1096cd030a78SIcenowy Zheng 		[CLK_AC97]		= &ac97_clk.common.hw,
1097cd030a78SIcenowy Zheng 		[CLK_SPDIF]		= &spdif_clk.common.hw,
1098cd030a78SIcenowy Zheng 		[CLK_KEYPAD]		= &keypad_clk.common.hw,
1099cd030a78SIcenowy Zheng 		[CLK_SATA]		= &sata_clk.common.hw,
1100cd030a78SIcenowy Zheng 		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
1101cd030a78SIcenowy Zheng 		[CLK_USB_PHY1]		= &usb_phy1_clk.common.hw,
1102cd030a78SIcenowy Zheng 		[CLK_USB_PHY2]		= &usb_phy2_clk.common.hw,
1103cd030a78SIcenowy Zheng 		[CLK_USB_OHCI0]		= &usb_ohci0_clk.common.hw,
1104cd030a78SIcenowy Zheng 		[CLK_USB_OHCI1]		= &usb_ohci1_clk.common.hw,
1105cd030a78SIcenowy Zheng 		[CLK_USB_OHCI2]		= &usb_ohci2_clk.common.hw,
1106cd030a78SIcenowy Zheng 		[CLK_IR0]		= &ir0_clk.common.hw,
1107cd030a78SIcenowy Zheng 		[CLK_IR1]		= &ir1_clk.common.hw,
1108cd030a78SIcenowy Zheng 		[CLK_DRAM]		= &dram_clk.common.hw,
1109cd030a78SIcenowy Zheng 		[CLK_DRAM_VE]		= &dram_ve_clk.common.hw,
1110cd030a78SIcenowy Zheng 		[CLK_DRAM_CSI0]		= &dram_csi0_clk.common.hw,
1111cd030a78SIcenowy Zheng 		[CLK_DRAM_CSI1]		= &dram_csi1_clk.common.hw,
1112cd030a78SIcenowy Zheng 		[CLK_DRAM_TS]		= &dram_ts_clk.common.hw,
1113cd030a78SIcenowy Zheng 		[CLK_DRAM_TVD]		= &dram_tvd_clk.common.hw,
1114cd030a78SIcenowy Zheng 		[CLK_DRAM_MP]		= &dram_mp_clk.common.hw,
1115cd030a78SIcenowy Zheng 		[CLK_DRAM_DEINTERLACE]	= &dram_deinterlace_clk.common.hw,
1116cd030a78SIcenowy Zheng 		[CLK_DE]		= &de_clk.common.hw,
1117cd030a78SIcenowy Zheng 		[CLK_MP]		= &mp_clk.common.hw,
1118cd030a78SIcenowy Zheng 		[CLK_TCON_LCD0]		= &tcon_lcd0_clk.common.hw,
1119cd030a78SIcenowy Zheng 		[CLK_TCON_LCD1]		= &tcon_lcd1_clk.common.hw,
1120cd030a78SIcenowy Zheng 		[CLK_TCON_TV0]		= &tcon_tv0_clk.common.hw,
1121cd030a78SIcenowy Zheng 		[CLK_TCON_TV1]		= &tcon_tv1_clk.common.hw,
1122cd030a78SIcenowy Zheng 		[CLK_DEINTERLACE]	= &deinterlace_clk.common.hw,
1123cd030a78SIcenowy Zheng 		[CLK_CSI1_MCLK]		= &csi1_mclk_clk.common.hw,
1124cd030a78SIcenowy Zheng 		[CLK_CSI_SCLK]		= &csi_sclk_clk.common.hw,
1125cd030a78SIcenowy Zheng 		[CLK_CSI0_MCLK]		= &csi0_mclk_clk.common.hw,
1126cd030a78SIcenowy Zheng 		[CLK_VE]		= &ve_clk.common.hw,
1127cd030a78SIcenowy Zheng 		[CLK_CODEC]		= &codec_clk.common.hw,
1128cd030a78SIcenowy Zheng 		[CLK_AVS]		= &avs_clk.common.hw,
1129cd030a78SIcenowy Zheng 		[CLK_HDMI]		= &hdmi_clk.common.hw,
1130cd030a78SIcenowy Zheng 		[CLK_HDMI_SLOW]		= &hdmi_slow_clk.common.hw,
1131cd030a78SIcenowy Zheng 		[CLK_MBUS]		= &mbus_clk.common.hw,
1132cd030a78SIcenowy Zheng 		[CLK_DSI_DPHY]		= &dsi_dphy_clk.common.hw,
1133cd030a78SIcenowy Zheng 		[CLK_TVE0]		= &tve0_clk.common.hw,
1134cd030a78SIcenowy Zheng 		[CLK_TVE1]		= &tve1_clk.common.hw,
1135cd030a78SIcenowy Zheng 		[CLK_TVD0]		= &tvd0_clk.common.hw,
1136cd030a78SIcenowy Zheng 		[CLK_TVD1]		= &tvd1_clk.common.hw,
1137cd030a78SIcenowy Zheng 		[CLK_TVD2]		= &tvd2_clk.common.hw,
1138cd030a78SIcenowy Zheng 		[CLK_TVD3]		= &tvd3_clk.common.hw,
1139cd030a78SIcenowy Zheng 		[CLK_GPU]		= &gpu_clk.common.hw,
1140cd030a78SIcenowy Zheng 		[CLK_OUTA]		= &outa_clk.common.hw,
1141cd030a78SIcenowy Zheng 		[CLK_OUTB]		= &outb_clk.common.hw,
1142cd030a78SIcenowy Zheng 	},
1143cd030a78SIcenowy Zheng 	.num	= CLK_NUMBER,
1144cd030a78SIcenowy Zheng };
1145cd030a78SIcenowy Zheng 
1146cd030a78SIcenowy Zheng static struct ccu_reset_map sun8i_r40_ccu_resets[] = {
1147cd030a78SIcenowy Zheng 	[RST_USB_PHY0]		=  { 0x0cc, BIT(0) },
1148cd030a78SIcenowy Zheng 	[RST_USB_PHY1]		=  { 0x0cc, BIT(1) },
1149cd030a78SIcenowy Zheng 	[RST_USB_PHY2]		=  { 0x0cc, BIT(2) },
1150cd030a78SIcenowy Zheng 
1151cd030a78SIcenowy Zheng 	[RST_DRAM]		=  { 0x0f4, BIT(31) },
1152cd030a78SIcenowy Zheng 	[RST_MBUS]		=  { 0x0fc, BIT(31) },
1153cd030a78SIcenowy Zheng 
1154cd030a78SIcenowy Zheng 	[RST_BUS_MIPI_DSI]	=  { 0x2c0, BIT(1) },
1155cd030a78SIcenowy Zheng 	[RST_BUS_CE]		=  { 0x2c0, BIT(5) },
1156cd030a78SIcenowy Zheng 	[RST_BUS_DMA]		=  { 0x2c0, BIT(6) },
1157cd030a78SIcenowy Zheng 	[RST_BUS_MMC0]		=  { 0x2c0, BIT(8) },
1158cd030a78SIcenowy Zheng 	[RST_BUS_MMC1]		=  { 0x2c0, BIT(9) },
1159cd030a78SIcenowy Zheng 	[RST_BUS_MMC2]		=  { 0x2c0, BIT(10) },
1160cd030a78SIcenowy Zheng 	[RST_BUS_MMC3]		=  { 0x2c0, BIT(11) },
1161cd030a78SIcenowy Zheng 	[RST_BUS_NAND]		=  { 0x2c0, BIT(13) },
1162cd030a78SIcenowy Zheng 	[RST_BUS_DRAM]		=  { 0x2c0, BIT(14) },
1163cd030a78SIcenowy Zheng 	[RST_BUS_EMAC]		=  { 0x2c0, BIT(17) },
1164cd030a78SIcenowy Zheng 	[RST_BUS_TS]		=  { 0x2c0, BIT(18) },
1165cd030a78SIcenowy Zheng 	[RST_BUS_HSTIMER]	=  { 0x2c0, BIT(19) },
1166cd030a78SIcenowy Zheng 	[RST_BUS_SPI0]		=  { 0x2c0, BIT(20) },
1167cd030a78SIcenowy Zheng 	[RST_BUS_SPI1]		=  { 0x2c0, BIT(21) },
1168cd030a78SIcenowy Zheng 	[RST_BUS_SPI2]		=  { 0x2c0, BIT(22) },
1169cd030a78SIcenowy Zheng 	[RST_BUS_SPI3]		=  { 0x2c0, BIT(23) },
1170cd030a78SIcenowy Zheng 	[RST_BUS_SATA]		=  { 0x2c0, BIT(24) },
1171cd030a78SIcenowy Zheng 	[RST_BUS_OTG]		=  { 0x2c0, BIT(25) },
1172cd030a78SIcenowy Zheng 	[RST_BUS_EHCI0]		=  { 0x2c0, BIT(26) },
1173cd030a78SIcenowy Zheng 	[RST_BUS_EHCI1]		=  { 0x2c0, BIT(27) },
1174cd030a78SIcenowy Zheng 	[RST_BUS_EHCI2]		=  { 0x2c0, BIT(28) },
1175cd030a78SIcenowy Zheng 	[RST_BUS_OHCI0]		=  { 0x2c0, BIT(29) },
1176cd030a78SIcenowy Zheng 	[RST_BUS_OHCI1]		=  { 0x2c0, BIT(30) },
1177cd030a78SIcenowy Zheng 	[RST_BUS_OHCI2]		=  { 0x2c0, BIT(31) },
1178cd030a78SIcenowy Zheng 
1179cd030a78SIcenowy Zheng 	[RST_BUS_VE]		=  { 0x2c4, BIT(0) },
1180cd030a78SIcenowy Zheng 	[RST_BUS_MP]		=  { 0x2c4, BIT(2) },
1181cd030a78SIcenowy Zheng 	[RST_BUS_DEINTERLACE]	=  { 0x2c4, BIT(5) },
1182cd030a78SIcenowy Zheng 	[RST_BUS_CSI0]		=  { 0x2c4, BIT(8) },
1183cd030a78SIcenowy Zheng 	[RST_BUS_CSI1]		=  { 0x2c4, BIT(9) },
1184cd030a78SIcenowy Zheng 	[RST_BUS_HDMI0]		=  { 0x2c4, BIT(10) },
1185cd030a78SIcenowy Zheng 	[RST_BUS_HDMI1]		=  { 0x2c4, BIT(11) },
1186cd030a78SIcenowy Zheng 	[RST_BUS_DE]		=  { 0x2c4, BIT(12) },
1187cd030a78SIcenowy Zheng 	[RST_BUS_TVE0]		=  { 0x2c4, BIT(13) },
1188cd030a78SIcenowy Zheng 	[RST_BUS_TVE1]		=  { 0x2c4, BIT(14) },
1189cd030a78SIcenowy Zheng 	[RST_BUS_TVE_TOP]	=  { 0x2c4, BIT(15) },
1190cd030a78SIcenowy Zheng 	[RST_BUS_GMAC]		=  { 0x2c4, BIT(17) },
1191cd030a78SIcenowy Zheng 	[RST_BUS_GPU]		=  { 0x2c4, BIT(20) },
1192cd030a78SIcenowy Zheng 	[RST_BUS_TVD0]		=  { 0x2c4, BIT(21) },
1193cd030a78SIcenowy Zheng 	[RST_BUS_TVD1]		=  { 0x2c4, BIT(22) },
1194cd030a78SIcenowy Zheng 	[RST_BUS_TVD2]		=  { 0x2c4, BIT(23) },
1195cd030a78SIcenowy Zheng 	[RST_BUS_TVD3]		=  { 0x2c4, BIT(24) },
1196cd030a78SIcenowy Zheng 	[RST_BUS_TVD_TOP]	=  { 0x2c4, BIT(25) },
1197cd030a78SIcenowy Zheng 	[RST_BUS_TCON_LCD0]	=  { 0x2c4, BIT(26) },
1198cd030a78SIcenowy Zheng 	[RST_BUS_TCON_LCD1]	=  { 0x2c4, BIT(27) },
1199cd030a78SIcenowy Zheng 	[RST_BUS_TCON_TV0]	=  { 0x2c4, BIT(28) },
1200cd030a78SIcenowy Zheng 	[RST_BUS_TCON_TV1]	=  { 0x2c4, BIT(29) },
1201cd030a78SIcenowy Zheng 	[RST_BUS_TCON_TOP]	=  { 0x2c4, BIT(30) },
1202cd030a78SIcenowy Zheng 	[RST_BUS_DBG]		=  { 0x2c4, BIT(31) },
1203cd030a78SIcenowy Zheng 
1204cd030a78SIcenowy Zheng 	[RST_BUS_LVDS]		=  { 0x2c8, BIT(0) },
1205cd030a78SIcenowy Zheng 
1206cd030a78SIcenowy Zheng 	[RST_BUS_CODEC]		=  { 0x2d0, BIT(0) },
1207cd030a78SIcenowy Zheng 	[RST_BUS_SPDIF]		=  { 0x2d0, BIT(1) },
1208cd030a78SIcenowy Zheng 	[RST_BUS_AC97]		=  { 0x2d0, BIT(2) },
1209cd030a78SIcenowy Zheng 	[RST_BUS_IR0]		=  { 0x2d0, BIT(6) },
1210cd030a78SIcenowy Zheng 	[RST_BUS_IR1]		=  { 0x2d0, BIT(7) },
1211cd030a78SIcenowy Zheng 	[RST_BUS_THS]		=  { 0x2d0, BIT(8) },
1212cd030a78SIcenowy Zheng 	[RST_BUS_KEYPAD]	=  { 0x2d0, BIT(10) },
1213cd030a78SIcenowy Zheng 	[RST_BUS_I2S0]		=  { 0x2d0, BIT(12) },
1214cd030a78SIcenowy Zheng 	[RST_BUS_I2S1]		=  { 0x2d0, BIT(13) },
1215cd030a78SIcenowy Zheng 	[RST_BUS_I2S2]		=  { 0x2d0, BIT(14) },
1216cd030a78SIcenowy Zheng 
1217cd030a78SIcenowy Zheng 	[RST_BUS_I2C0]		=  { 0x2d8, BIT(0) },
1218cd030a78SIcenowy Zheng 	[RST_BUS_I2C1]		=  { 0x2d8, BIT(1) },
1219cd030a78SIcenowy Zheng 	[RST_BUS_I2C2]		=  { 0x2d8, BIT(2) },
1220cd030a78SIcenowy Zheng 	[RST_BUS_I2C3]		=  { 0x2d8, BIT(3) },
1221cd030a78SIcenowy Zheng 	[RST_BUS_CAN]		=  { 0x2d8, BIT(4) },
1222cd030a78SIcenowy Zheng 	[RST_BUS_SCR]		=  { 0x2d8, BIT(5) },
1223cd030a78SIcenowy Zheng 	[RST_BUS_PS20]		=  { 0x2d8, BIT(6) },
1224cd030a78SIcenowy Zheng 	[RST_BUS_PS21]		=  { 0x2d8, BIT(7) },
1225cd030a78SIcenowy Zheng 	[RST_BUS_I2C4]		=  { 0x2d8, BIT(15) },
1226cd030a78SIcenowy Zheng 	[RST_BUS_UART0]		=  { 0x2d8, BIT(16) },
1227cd030a78SIcenowy Zheng 	[RST_BUS_UART1]		=  { 0x2d8, BIT(17) },
1228cd030a78SIcenowy Zheng 	[RST_BUS_UART2]		=  { 0x2d8, BIT(18) },
1229cd030a78SIcenowy Zheng 	[RST_BUS_UART3]		=  { 0x2d8, BIT(19) },
1230cd030a78SIcenowy Zheng 	[RST_BUS_UART4]		=  { 0x2d8, BIT(20) },
1231cd030a78SIcenowy Zheng 	[RST_BUS_UART5]		=  { 0x2d8, BIT(21) },
1232cd030a78SIcenowy Zheng 	[RST_BUS_UART6]		=  { 0x2d8, BIT(22) },
1233cd030a78SIcenowy Zheng 	[RST_BUS_UART7]		=  { 0x2d8, BIT(23) },
1234cd030a78SIcenowy Zheng };
1235cd030a78SIcenowy Zheng 
1236cd030a78SIcenowy Zheng static const struct sunxi_ccu_desc sun8i_r40_ccu_desc = {
1237cd030a78SIcenowy Zheng 	.ccu_clks	= sun8i_r40_ccu_clks,
1238cd030a78SIcenowy Zheng 	.num_ccu_clks	= ARRAY_SIZE(sun8i_r40_ccu_clks),
1239cd030a78SIcenowy Zheng 
1240cd030a78SIcenowy Zheng 	.hw_clks	= &sun8i_r40_hw_clks,
1241cd030a78SIcenowy Zheng 
1242cd030a78SIcenowy Zheng 	.resets		= sun8i_r40_ccu_resets,
1243cd030a78SIcenowy Zheng 	.num_resets	= ARRAY_SIZE(sun8i_r40_ccu_resets),
1244cd030a78SIcenowy Zheng };
1245cd030a78SIcenowy Zheng 
1246cd030a78SIcenowy Zheng static struct ccu_pll_nb sun8i_r40_pll_cpu_nb = {
1247cd030a78SIcenowy Zheng 	.common	= &pll_cpu_clk.common,
1248cd030a78SIcenowy Zheng 	/* copy from pll_cpu_clk */
1249cd030a78SIcenowy Zheng 	.enable	= BIT(31),
1250cd030a78SIcenowy Zheng 	.lock	= BIT(28),
1251cd030a78SIcenowy Zheng };
1252cd030a78SIcenowy Zheng 
1253cd030a78SIcenowy Zheng static struct ccu_mux_nb sun8i_r40_cpu_nb = {
1254cd030a78SIcenowy Zheng 	.common		= &cpu_clk.common,
1255cd030a78SIcenowy Zheng 	.cm		= &cpu_clk.mux,
1256cd030a78SIcenowy Zheng 	.delay_us	= 1, /* > 8 clock cycles at 24 MHz */
1257cd030a78SIcenowy Zheng 	.bypass_index	= 1, /* index of 24 MHz oscillator */
1258cd030a78SIcenowy Zheng };
1259cd030a78SIcenowy Zheng 
126017de4c85SIcenowy Zheng /*
126117de4c85SIcenowy Zheng  * Add a regmap for the GMAC driver (dwmac-sun8i) to access the
126217de4c85SIcenowy Zheng  * GMAC configuration register.
126317de4c85SIcenowy Zheng  * Only this register is allowed to be written, in order to
126417de4c85SIcenowy Zheng  * prevent overriding critical clock configuration.
126517de4c85SIcenowy Zheng  */
126617de4c85SIcenowy Zheng 
126717de4c85SIcenowy Zheng #define SUN8I_R40_GMAC_CFG_REG 0x164
126817de4c85SIcenowy Zheng static bool sun8i_r40_ccu_regmap_accessible_reg(struct device *dev,
126917de4c85SIcenowy Zheng 						unsigned int reg)
127017de4c85SIcenowy Zheng {
127117de4c85SIcenowy Zheng 	if (reg == SUN8I_R40_GMAC_CFG_REG)
127217de4c85SIcenowy Zheng 		return true;
127317de4c85SIcenowy Zheng 	return false;
127417de4c85SIcenowy Zheng }
127517de4c85SIcenowy Zheng 
127617de4c85SIcenowy Zheng static struct regmap_config sun8i_r40_ccu_regmap_config = {
127717de4c85SIcenowy Zheng 	.reg_bits	= 32,
127817de4c85SIcenowy Zheng 	.val_bits	= 32,
127917de4c85SIcenowy Zheng 	.reg_stride	= 4,
128017de4c85SIcenowy Zheng 	.max_register	= 0x320, /* PLL_LOCK_CTRL_REG */
128117de4c85SIcenowy Zheng 
128217de4c85SIcenowy Zheng 	/* other devices have no business accessing other registers */
128317de4c85SIcenowy Zheng 	.readable_reg	= sun8i_r40_ccu_regmap_accessible_reg,
128417de4c85SIcenowy Zheng 	.writeable_reg	= sun8i_r40_ccu_regmap_accessible_reg,
128517de4c85SIcenowy Zheng };
128617de4c85SIcenowy Zheng 
1287*01a7ea76SChen-Yu Tsai #define SUN8I_R40_SYS_32K_CLK_REG 0x310
1288*01a7ea76SChen-Yu Tsai #define SUN8I_R40_SYS_32K_CLK_KEY (0x16AA << 16)
1289*01a7ea76SChen-Yu Tsai 
1290c3bf29f6SIcenowy Zheng static int sun8i_r40_ccu_probe(struct platform_device *pdev)
1291cd030a78SIcenowy Zheng {
1292c3bf29f6SIcenowy Zheng 	struct resource *res;
129317de4c85SIcenowy Zheng 	struct regmap *regmap;
1294cd030a78SIcenowy Zheng 	void __iomem *reg;
1295cd030a78SIcenowy Zheng 	u32 val;
1296c3bf29f6SIcenowy Zheng 	int ret;
1297cd030a78SIcenowy Zheng 
1298c3bf29f6SIcenowy Zheng 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1299c3bf29f6SIcenowy Zheng 	reg = devm_ioremap_resource(&pdev->dev, res);
1300c3bf29f6SIcenowy Zheng 	if (IS_ERR(reg))
1301c3bf29f6SIcenowy Zheng 		return PTR_ERR(reg);
1302cd030a78SIcenowy Zheng 
1303cd030a78SIcenowy Zheng 	/* Force the PLL-Audio-1x divider to 4 */
1304cd030a78SIcenowy Zheng 	val = readl(reg + SUN8I_R40_PLL_AUDIO_REG);
1305cd030a78SIcenowy Zheng 	val &= ~GENMASK(19, 16);
1306cd030a78SIcenowy Zheng 	writel(val | (3 << 16), reg + SUN8I_R40_PLL_AUDIO_REG);
1307cd030a78SIcenowy Zheng 
1308cd030a78SIcenowy Zheng 	/* Force PLL-MIPI to MIPI mode */
1309cd030a78SIcenowy Zheng 	val = readl(reg + SUN8I_R40_PLL_MIPI_REG);
1310cd030a78SIcenowy Zheng 	val &= ~BIT(16);
1311cd030a78SIcenowy Zheng 	writel(val, reg + SUN8I_R40_PLL_MIPI_REG);
1312cd030a78SIcenowy Zheng 
1313cd030a78SIcenowy Zheng 	/* Force OHCI 12M parent to 12M divided from 48M */
1314cd030a78SIcenowy Zheng 	val = readl(reg + SUN8I_R40_USB_CLK_REG);
1315cd030a78SIcenowy Zheng 	val &= ~GENMASK(25, 20);
1316cd030a78SIcenowy Zheng 	writel(val, reg + SUN8I_R40_USB_CLK_REG);
1317cd030a78SIcenowy Zheng 
1318*01a7ea76SChen-Yu Tsai 	/*
1319*01a7ea76SChen-Yu Tsai 	 * Force SYS 32k (otherwise known as LOSC throughout the CCU)
1320*01a7ea76SChen-Yu Tsai 	 * clock parent to LOSC output from RTC module instead of the
1321*01a7ea76SChen-Yu Tsai 	 * CCU's internal RC oscillator divided output.
1322*01a7ea76SChen-Yu Tsai 	 */
1323*01a7ea76SChen-Yu Tsai 	writel(SUN8I_R40_SYS_32K_CLK_KEY | BIT(8),
1324*01a7ea76SChen-Yu Tsai 	       reg + SUN8I_R40_SYS_32K_CLK_REG);
1325*01a7ea76SChen-Yu Tsai 
132617de4c85SIcenowy Zheng 	regmap = devm_regmap_init_mmio(&pdev->dev, reg,
132717de4c85SIcenowy Zheng 				       &sun8i_r40_ccu_regmap_config);
132817de4c85SIcenowy Zheng 	if (IS_ERR(regmap))
132917de4c85SIcenowy Zheng 		return PTR_ERR(regmap);
133017de4c85SIcenowy Zheng 
1331c3bf29f6SIcenowy Zheng 	ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun8i_r40_ccu_desc);
1332c3bf29f6SIcenowy Zheng 	if (ret)
1333c3bf29f6SIcenowy Zheng 		return ret;
1334cd030a78SIcenowy Zheng 
1335cd030a78SIcenowy Zheng 	/* Gate then ungate PLL CPU after any rate changes */
1336cd030a78SIcenowy Zheng 	ccu_pll_notifier_register(&sun8i_r40_pll_cpu_nb);
1337cd030a78SIcenowy Zheng 
1338cd030a78SIcenowy Zheng 	/* Reparent CPU during PLL CPU rate changes */
1339cd030a78SIcenowy Zheng 	ccu_mux_notifier_register(pll_cpu_clk.common.hw.clk,
1340cd030a78SIcenowy Zheng 				  &sun8i_r40_cpu_nb);
1341c3bf29f6SIcenowy Zheng 
1342c3bf29f6SIcenowy Zheng 	return 0;
1343cd030a78SIcenowy Zheng }
1344c3bf29f6SIcenowy Zheng 
1345c3bf29f6SIcenowy Zheng static const struct of_device_id sun8i_r40_ccu_ids[] = {
1346c3bf29f6SIcenowy Zheng 	{ .compatible = "allwinner,sun8i-r40-ccu" },
1347c3bf29f6SIcenowy Zheng 	{ }
1348c3bf29f6SIcenowy Zheng };
1349c3bf29f6SIcenowy Zheng 
1350c3bf29f6SIcenowy Zheng static struct platform_driver sun8i_r40_ccu_driver = {
1351c3bf29f6SIcenowy Zheng 	.probe	= sun8i_r40_ccu_probe,
1352c3bf29f6SIcenowy Zheng 	.driver	= {
1353c3bf29f6SIcenowy Zheng 		.name	= "sun8i-r40-ccu",
1354c3bf29f6SIcenowy Zheng 		.of_match_table	= sun8i_r40_ccu_ids,
1355c3bf29f6SIcenowy Zheng 	},
1356c3bf29f6SIcenowy Zheng };
1357c3bf29f6SIcenowy Zheng builtin_platform_driver(sun8i_r40_ccu_driver);
1358