xref: /linux/drivers/clk/ingenic/jz4755-cgu.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1*ff0d3ae0SSiarhei Volkau // SPDX-License-Identifier: GPL-2.0
2*ff0d3ae0SSiarhei Volkau /*
3*ff0d3ae0SSiarhei Volkau  * Ingenic JZ4755 SoC CGU driver
4*ff0d3ae0SSiarhei Volkau  * Heavily based on JZ4725b CGU driver
5*ff0d3ae0SSiarhei Volkau  *
6*ff0d3ae0SSiarhei Volkau  * Copyright (C) 2022 Siarhei Volkau
7*ff0d3ae0SSiarhei Volkau  * Author: Siarhei Volkau <lis8215@gmail.com>
8*ff0d3ae0SSiarhei Volkau  */
9*ff0d3ae0SSiarhei Volkau 
10*ff0d3ae0SSiarhei Volkau #include <linux/clk-provider.h>
11*ff0d3ae0SSiarhei Volkau #include <linux/delay.h>
12*ff0d3ae0SSiarhei Volkau #include <linux/of.h>
13*ff0d3ae0SSiarhei Volkau 
14*ff0d3ae0SSiarhei Volkau #include <dt-bindings/clock/ingenic,jz4755-cgu.h>
15*ff0d3ae0SSiarhei Volkau 
16*ff0d3ae0SSiarhei Volkau #include "cgu.h"
17*ff0d3ae0SSiarhei Volkau #include "pm.h"
18*ff0d3ae0SSiarhei Volkau 
19*ff0d3ae0SSiarhei Volkau /* CGU register offsets */
20*ff0d3ae0SSiarhei Volkau #define CGU_REG_CPCCR		0x00
21*ff0d3ae0SSiarhei Volkau #define CGU_REG_CPPCR		0x10
22*ff0d3ae0SSiarhei Volkau #define CGU_REG_CLKGR		0x20
23*ff0d3ae0SSiarhei Volkau #define CGU_REG_OPCR		0x24
24*ff0d3ae0SSiarhei Volkau #define CGU_REG_I2SCDR		0x60
25*ff0d3ae0SSiarhei Volkau #define CGU_REG_LPCDR		0x64
26*ff0d3ae0SSiarhei Volkau #define CGU_REG_MSCCDR		0x68
27*ff0d3ae0SSiarhei Volkau #define CGU_REG_SSICDR		0x74
28*ff0d3ae0SSiarhei Volkau #define CGU_REG_CIMCDR		0x7C
29*ff0d3ae0SSiarhei Volkau 
30*ff0d3ae0SSiarhei Volkau static struct ingenic_cgu *cgu;
31*ff0d3ae0SSiarhei Volkau 
32*ff0d3ae0SSiarhei Volkau static const s8 pll_od_encoding[4] = {
33*ff0d3ae0SSiarhei Volkau 	0x0, 0x1, -1, 0x3,
34*ff0d3ae0SSiarhei Volkau };
35*ff0d3ae0SSiarhei Volkau 
36*ff0d3ae0SSiarhei Volkau static const u8 jz4755_cgu_cpccr_div_table[] = {
37*ff0d3ae0SSiarhei Volkau 	1, 2, 3, 4, 6, 8,
38*ff0d3ae0SSiarhei Volkau };
39*ff0d3ae0SSiarhei Volkau 
40*ff0d3ae0SSiarhei Volkau static const u8 jz4755_cgu_pll_half_div_table[] = {
41*ff0d3ae0SSiarhei Volkau 	2, 1,
42*ff0d3ae0SSiarhei Volkau };
43*ff0d3ae0SSiarhei Volkau 
44*ff0d3ae0SSiarhei Volkau static const struct ingenic_cgu_clk_info jz4755_cgu_clocks[] = {
45*ff0d3ae0SSiarhei Volkau 
46*ff0d3ae0SSiarhei Volkau 	/* External clocks */
47*ff0d3ae0SSiarhei Volkau 
48*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_EXT] = { "ext", CGU_CLK_EXT },
49*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_OSC32K] = { "osc32k", CGU_CLK_EXT },
50*ff0d3ae0SSiarhei Volkau 
51*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_PLL] = {
52*ff0d3ae0SSiarhei Volkau 		"pll", CGU_CLK_PLL,
53*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT, },
54*ff0d3ae0SSiarhei Volkau 		.pll = {
55*ff0d3ae0SSiarhei Volkau 			.reg = CGU_REG_CPPCR,
56*ff0d3ae0SSiarhei Volkau 			.rate_multiplier = 1,
57*ff0d3ae0SSiarhei Volkau 			.m_shift = 23,
58*ff0d3ae0SSiarhei Volkau 			.m_bits = 9,
59*ff0d3ae0SSiarhei Volkau 			.m_offset = 2,
60*ff0d3ae0SSiarhei Volkau 			.n_shift = 18,
61*ff0d3ae0SSiarhei Volkau 			.n_bits = 5,
62*ff0d3ae0SSiarhei Volkau 			.n_offset = 2,
63*ff0d3ae0SSiarhei Volkau 			.od_shift = 16,
64*ff0d3ae0SSiarhei Volkau 			.od_bits = 2,
65*ff0d3ae0SSiarhei Volkau 			.od_max = 4,
66*ff0d3ae0SSiarhei Volkau 			.od_encoding = pll_od_encoding,
67*ff0d3ae0SSiarhei Volkau 			.stable_bit = 10,
68*ff0d3ae0SSiarhei Volkau 			.bypass_reg = CGU_REG_CPPCR,
69*ff0d3ae0SSiarhei Volkau 			.bypass_bit = 9,
70*ff0d3ae0SSiarhei Volkau 			.enable_bit = 8,
71*ff0d3ae0SSiarhei Volkau 		},
72*ff0d3ae0SSiarhei Volkau 	},
73*ff0d3ae0SSiarhei Volkau 
74*ff0d3ae0SSiarhei Volkau 	/* Muxes & dividers */
75*ff0d3ae0SSiarhei Volkau 
76*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_PLL_HALF] = {
77*ff0d3ae0SSiarhei Volkau 		"pll half", CGU_CLK_DIV,
78*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL, },
79*ff0d3ae0SSiarhei Volkau 		.div = {
80*ff0d3ae0SSiarhei Volkau 			CGU_REG_CPCCR, 21, 1, 1, -1, -1, -1, 0,
81*ff0d3ae0SSiarhei Volkau 			jz4755_cgu_pll_half_div_table,
82*ff0d3ae0SSiarhei Volkau 		},
83*ff0d3ae0SSiarhei Volkau 	},
84*ff0d3ae0SSiarhei Volkau 
85*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_EXT_HALF] = {
86*ff0d3ae0SSiarhei Volkau 		"ext half", CGU_CLK_DIV,
87*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT, },
88*ff0d3ae0SSiarhei Volkau 		.div = {
89*ff0d3ae0SSiarhei Volkau 			CGU_REG_CPCCR, 30, 1, 1, -1, -1, -1, 0,
90*ff0d3ae0SSiarhei Volkau 			NULL,
91*ff0d3ae0SSiarhei Volkau 		},
92*ff0d3ae0SSiarhei Volkau 	},
93*ff0d3ae0SSiarhei Volkau 
94*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_CCLK] = {
95*ff0d3ae0SSiarhei Volkau 		"cclk", CGU_CLK_DIV,
96*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL, },
97*ff0d3ae0SSiarhei Volkau 		.div = {
98*ff0d3ae0SSiarhei Volkau 			CGU_REG_CPCCR, 0, 1, 4, 22, -1, -1, 0,
99*ff0d3ae0SSiarhei Volkau 			jz4755_cgu_cpccr_div_table,
100*ff0d3ae0SSiarhei Volkau 		},
101*ff0d3ae0SSiarhei Volkau 	},
102*ff0d3ae0SSiarhei Volkau 
103*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_H0CLK] = {
104*ff0d3ae0SSiarhei Volkau 		"hclk", CGU_CLK_DIV,
105*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL, },
106*ff0d3ae0SSiarhei Volkau 		.div = {
107*ff0d3ae0SSiarhei Volkau 			CGU_REG_CPCCR, 4, 1, 4, 22, -1, -1, 0,
108*ff0d3ae0SSiarhei Volkau 			jz4755_cgu_cpccr_div_table,
109*ff0d3ae0SSiarhei Volkau 		},
110*ff0d3ae0SSiarhei Volkau 	},
111*ff0d3ae0SSiarhei Volkau 
112*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_PCLK] = {
113*ff0d3ae0SSiarhei Volkau 		"pclk", CGU_CLK_DIV,
114*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL, },
115*ff0d3ae0SSiarhei Volkau 		.div = {
116*ff0d3ae0SSiarhei Volkau 			CGU_REG_CPCCR, 8, 1, 4, 22, -1, -1, 0,
117*ff0d3ae0SSiarhei Volkau 			jz4755_cgu_cpccr_div_table,
118*ff0d3ae0SSiarhei Volkau 		},
119*ff0d3ae0SSiarhei Volkau 	},
120*ff0d3ae0SSiarhei Volkau 
121*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_MCLK] = {
122*ff0d3ae0SSiarhei Volkau 		"mclk", CGU_CLK_DIV,
123*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL, },
124*ff0d3ae0SSiarhei Volkau 		.div = {
125*ff0d3ae0SSiarhei Volkau 			CGU_REG_CPCCR, 12, 1, 4, 22, -1, -1, 0,
126*ff0d3ae0SSiarhei Volkau 			jz4755_cgu_cpccr_div_table,
127*ff0d3ae0SSiarhei Volkau 		},
128*ff0d3ae0SSiarhei Volkau 	},
129*ff0d3ae0SSiarhei Volkau 
130*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_H1CLK] = {
131*ff0d3ae0SSiarhei Volkau 		"h1clk", CGU_CLK_DIV,
132*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL, },
133*ff0d3ae0SSiarhei Volkau 		.div = {
134*ff0d3ae0SSiarhei Volkau 			CGU_REG_CPCCR, 16, 1, 4, 22, -1, -1, 0,
135*ff0d3ae0SSiarhei Volkau 			jz4755_cgu_cpccr_div_table,
136*ff0d3ae0SSiarhei Volkau 		},
137*ff0d3ae0SSiarhei Volkau 	},
138*ff0d3ae0SSiarhei Volkau 
139*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_UDC] = {
140*ff0d3ae0SSiarhei Volkau 		"udc", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE,
141*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, JZ4755_CLK_PLL_HALF, },
142*ff0d3ae0SSiarhei Volkau 		.mux = { CGU_REG_CPCCR, 29, 1 },
143*ff0d3ae0SSiarhei Volkau 		.div = { CGU_REG_CPCCR, 23, 1, 6, -1, -1, -1 },
144*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 10 },
145*ff0d3ae0SSiarhei Volkau 	},
146*ff0d3ae0SSiarhei Volkau 
147*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_LCD] = {
148*ff0d3ae0SSiarhei Volkau 		"lcd", CGU_CLK_DIV | CGU_CLK_GATE,
149*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL_HALF, },
150*ff0d3ae0SSiarhei Volkau 		.div = { CGU_REG_LPCDR, 0, 1, 11, -1, -1, -1 },
151*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 9 },
152*ff0d3ae0SSiarhei Volkau 	},
153*ff0d3ae0SSiarhei Volkau 
154*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_MMC] = {
155*ff0d3ae0SSiarhei Volkau 		"mmc", CGU_CLK_DIV,
156*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL_HALF, },
157*ff0d3ae0SSiarhei Volkau 		.div = { CGU_REG_MSCCDR, 0, 1, 5, -1, -1, -1 },
158*ff0d3ae0SSiarhei Volkau 	},
159*ff0d3ae0SSiarhei Volkau 
160*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_I2S] = {
161*ff0d3ae0SSiarhei Volkau 		"i2s", CGU_CLK_MUX | CGU_CLK_DIV,
162*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, JZ4755_CLK_PLL_HALF, },
163*ff0d3ae0SSiarhei Volkau 		.mux = { CGU_REG_CPCCR, 31, 1 },
164*ff0d3ae0SSiarhei Volkau 		.div = { CGU_REG_I2SCDR, 0, 1, 9, -1, -1, -1 },
165*ff0d3ae0SSiarhei Volkau 	},
166*ff0d3ae0SSiarhei Volkau 
167*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_SPI] = {
168*ff0d3ae0SSiarhei Volkau 		"spi", CGU_CLK_DIV | CGU_CLK_GATE,
169*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL_HALF, },
170*ff0d3ae0SSiarhei Volkau 		.div = { CGU_REG_SSICDR, 0, 1, 4, -1, -1, -1 },
171*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 4 },
172*ff0d3ae0SSiarhei Volkau 	},
173*ff0d3ae0SSiarhei Volkau 
174*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_TVE] = {
175*ff0d3ae0SSiarhei Volkau 		"tve", CGU_CLK_MUX | CGU_CLK_GATE,
176*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_LCD, JZ4755_CLK_EXT, },
177*ff0d3ae0SSiarhei Volkau 		.mux = { CGU_REG_LPCDR, 31, 1 },
178*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 18 },
179*ff0d3ae0SSiarhei Volkau 	},
180*ff0d3ae0SSiarhei Volkau 
181*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_RTC] = {
182*ff0d3ae0SSiarhei Volkau 		"rtc", CGU_CLK_MUX | CGU_CLK_GATE,
183*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT512, JZ4755_CLK_OSC32K, },
184*ff0d3ae0SSiarhei Volkau 		.mux = { CGU_REG_OPCR, 2, 1},
185*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 2 },
186*ff0d3ae0SSiarhei Volkau 	},
187*ff0d3ae0SSiarhei Volkau 
188*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_CIM] = {
189*ff0d3ae0SSiarhei Volkau 		"cim", CGU_CLK_DIV | CGU_CLK_GATE,
190*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL_HALF, },
191*ff0d3ae0SSiarhei Volkau 		.div = { CGU_REG_CIMCDR, 0, 1, 8, -1, -1, -1 },
192*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 8 },
193*ff0d3ae0SSiarhei Volkau 	},
194*ff0d3ae0SSiarhei Volkau 
195*ff0d3ae0SSiarhei Volkau 	/* Gate-only clocks */
196*ff0d3ae0SSiarhei Volkau 
197*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_UART0] = {
198*ff0d3ae0SSiarhei Volkau 		"uart0", CGU_CLK_GATE,
199*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, },
200*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 0 },
201*ff0d3ae0SSiarhei Volkau 	},
202*ff0d3ae0SSiarhei Volkau 
203*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_UART1] = {
204*ff0d3ae0SSiarhei Volkau 		"uart1", CGU_CLK_GATE,
205*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, },
206*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 14 },
207*ff0d3ae0SSiarhei Volkau 	},
208*ff0d3ae0SSiarhei Volkau 
209*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_UART2] = {
210*ff0d3ae0SSiarhei Volkau 		"uart2", CGU_CLK_GATE,
211*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, },
212*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 15 },
213*ff0d3ae0SSiarhei Volkau 	},
214*ff0d3ae0SSiarhei Volkau 
215*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_ADC] = {
216*ff0d3ae0SSiarhei Volkau 		"adc", CGU_CLK_GATE,
217*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, },
218*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 7 },
219*ff0d3ae0SSiarhei Volkau 	},
220*ff0d3ae0SSiarhei Volkau 
221*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_AIC] = {
222*ff0d3ae0SSiarhei Volkau 		"aic", CGU_CLK_GATE,
223*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, },
224*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 5 },
225*ff0d3ae0SSiarhei Volkau 	},
226*ff0d3ae0SSiarhei Volkau 
227*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_I2C] = {
228*ff0d3ae0SSiarhei Volkau 		"i2c", CGU_CLK_GATE,
229*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, },
230*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 3 },
231*ff0d3ae0SSiarhei Volkau 	},
232*ff0d3ae0SSiarhei Volkau 
233*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_BCH] = {
234*ff0d3ae0SSiarhei Volkau 		"bch", CGU_CLK_GATE,
235*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_H1CLK, },
236*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 11 },
237*ff0d3ae0SSiarhei Volkau 	},
238*ff0d3ae0SSiarhei Volkau 
239*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_TCU] = {
240*ff0d3ae0SSiarhei Volkau 		"tcu", CGU_CLK_GATE,
241*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT, },
242*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 1 },
243*ff0d3ae0SSiarhei Volkau 	},
244*ff0d3ae0SSiarhei Volkau 
245*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_DMA] = {
246*ff0d3ae0SSiarhei Volkau 		"dma", CGU_CLK_GATE,
247*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PCLK, },
248*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 12 },
249*ff0d3ae0SSiarhei Volkau 	},
250*ff0d3ae0SSiarhei Volkau 
251*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_MMC0] = {
252*ff0d3ae0SSiarhei Volkau 		"mmc0", CGU_CLK_GATE,
253*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_MMC, },
254*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 6 },
255*ff0d3ae0SSiarhei Volkau 	},
256*ff0d3ae0SSiarhei Volkau 
257*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_MMC1] = {
258*ff0d3ae0SSiarhei Volkau 		"mmc1", CGU_CLK_GATE,
259*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_MMC, },
260*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 16 },
261*ff0d3ae0SSiarhei Volkau 	},
262*ff0d3ae0SSiarhei Volkau 
263*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_AUX_CPU] = {
264*ff0d3ae0SSiarhei Volkau 		"aux_cpu", CGU_CLK_GATE,
265*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_H1CLK, },
266*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 24 },
267*ff0d3ae0SSiarhei Volkau 	},
268*ff0d3ae0SSiarhei Volkau 
269*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_AHB1] = {
270*ff0d3ae0SSiarhei Volkau 		"ahb1", CGU_CLK_GATE,
271*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_H1CLK, },
272*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 23 },
273*ff0d3ae0SSiarhei Volkau 	},
274*ff0d3ae0SSiarhei Volkau 
275*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_IDCT] = {
276*ff0d3ae0SSiarhei Volkau 		"idct", CGU_CLK_GATE,
277*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_H1CLK, },
278*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 22 },
279*ff0d3ae0SSiarhei Volkau 	},
280*ff0d3ae0SSiarhei Volkau 
281*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_DB] = {
282*ff0d3ae0SSiarhei Volkau 		"db", CGU_CLK_GATE,
283*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_H1CLK, },
284*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 21 },
285*ff0d3ae0SSiarhei Volkau 	},
286*ff0d3ae0SSiarhei Volkau 
287*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_ME] = {
288*ff0d3ae0SSiarhei Volkau 		"me", CGU_CLK_GATE,
289*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_H1CLK, },
290*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 20 },
291*ff0d3ae0SSiarhei Volkau 	},
292*ff0d3ae0SSiarhei Volkau 
293*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_MC] = {
294*ff0d3ae0SSiarhei Volkau 		"mc", CGU_CLK_GATE,
295*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_H1CLK, },
296*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 19 },
297*ff0d3ae0SSiarhei Volkau 	},
298*ff0d3ae0SSiarhei Volkau 
299*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_TSSI] = {
300*ff0d3ae0SSiarhei Volkau 		"tssi", CGU_CLK_GATE,
301*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF/* not sure */, },
302*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 17 },
303*ff0d3ae0SSiarhei Volkau 	},
304*ff0d3ae0SSiarhei Volkau 
305*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_IPU] = {
306*ff0d3ae0SSiarhei Volkau 		"ipu", CGU_CLK_GATE,
307*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_PLL_HALF/* not sure */, },
308*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_CLKGR, 13 },
309*ff0d3ae0SSiarhei Volkau 	},
310*ff0d3ae0SSiarhei Volkau 
311*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_EXT512] = {
312*ff0d3ae0SSiarhei Volkau 		"ext/512", CGU_CLK_FIXDIV,
313*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT, },
314*ff0d3ae0SSiarhei Volkau 
315*ff0d3ae0SSiarhei Volkau 		.fixdiv = { 512 },
316*ff0d3ae0SSiarhei Volkau 	},
317*ff0d3ae0SSiarhei Volkau 
318*ff0d3ae0SSiarhei Volkau 	[JZ4755_CLK_UDC_PHY] = {
319*ff0d3ae0SSiarhei Volkau 		"udc_phy", CGU_CLK_GATE,
320*ff0d3ae0SSiarhei Volkau 		.parents = { JZ4755_CLK_EXT_HALF, },
321*ff0d3ae0SSiarhei Volkau 		.gate = { CGU_REG_OPCR, 6, true },
322*ff0d3ae0SSiarhei Volkau 	},
323*ff0d3ae0SSiarhei Volkau };
324*ff0d3ae0SSiarhei Volkau 
jz4755_cgu_init(struct device_node * np)325*ff0d3ae0SSiarhei Volkau static void __init jz4755_cgu_init(struct device_node *np)
326*ff0d3ae0SSiarhei Volkau {
327*ff0d3ae0SSiarhei Volkau 	int retval;
328*ff0d3ae0SSiarhei Volkau 
329*ff0d3ae0SSiarhei Volkau 	cgu = ingenic_cgu_new(jz4755_cgu_clocks,
330*ff0d3ae0SSiarhei Volkau 			      ARRAY_SIZE(jz4755_cgu_clocks), np);
331*ff0d3ae0SSiarhei Volkau 	if (!cgu) {
332*ff0d3ae0SSiarhei Volkau 		pr_err("%s: failed to initialise CGU\n", __func__);
333*ff0d3ae0SSiarhei Volkau 		return;
334*ff0d3ae0SSiarhei Volkau 	}
335*ff0d3ae0SSiarhei Volkau 
336*ff0d3ae0SSiarhei Volkau 	retval = ingenic_cgu_register_clocks(cgu);
337*ff0d3ae0SSiarhei Volkau 	if (retval)
338*ff0d3ae0SSiarhei Volkau 		pr_err("%s: failed to register CGU Clocks\n", __func__);
339*ff0d3ae0SSiarhei Volkau 
340*ff0d3ae0SSiarhei Volkau 	ingenic_cgu_register_syscore_ops(cgu);
341*ff0d3ae0SSiarhei Volkau }
342*ff0d3ae0SSiarhei Volkau /*
343*ff0d3ae0SSiarhei Volkau  * CGU has some children devices, this is useful for probing children devices
344*ff0d3ae0SSiarhei Volkau  * in the case where the device node is compatible with "simple-mfd".
345*ff0d3ae0SSiarhei Volkau  */
346*ff0d3ae0SSiarhei Volkau CLK_OF_DECLARE_DRIVER(jz4755_cgu, "ingenic,jz4755-cgu", jz4755_cgu_init);
347