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