xref: /freebsd/sys/dev/clk/rockchip/rk3568_pmucru.c (revision 77f222415832c58c2e307f74f1200941efe868d9)
1*77f22241SEmmanuel Vadot /*-
2*77f22241SEmmanuel Vadot  * SPDX-License-Identifier: BSD-2-Clause
3*77f22241SEmmanuel Vadot  *
4*77f22241SEmmanuel Vadot  * Copyright (c) 2021, 2022 Soren Schmidt <sos@deepcore.dk>
5*77f22241SEmmanuel Vadot  * Copyright (c) 2023, Emmanuel Vadot <manu@freebsd.org>
6*77f22241SEmmanuel Vadot  *
7*77f22241SEmmanuel Vadot  * Redistribution and use in source and binary forms, with or without
8*77f22241SEmmanuel Vadot  * modification, are permitted provided that the following conditions
9*77f22241SEmmanuel Vadot  * are met:
10*77f22241SEmmanuel Vadot  * 1. Redistributions of source code must retain the above copyright
11*77f22241SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer.
12*77f22241SEmmanuel Vadot  * 2. Redistributions in binary form must reproduce the above copyright
13*77f22241SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer in the
14*77f22241SEmmanuel Vadot  *    documentation and/or other materials provided with the distribution.
15*77f22241SEmmanuel Vadot  *
16*77f22241SEmmanuel Vadot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17*77f22241SEmmanuel Vadot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18*77f22241SEmmanuel Vadot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19*77f22241SEmmanuel Vadot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20*77f22241SEmmanuel Vadot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21*77f22241SEmmanuel Vadot  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22*77f22241SEmmanuel Vadot  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23*77f22241SEmmanuel Vadot  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24*77f22241SEmmanuel Vadot  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*77f22241SEmmanuel Vadot  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*77f22241SEmmanuel Vadot  * SUCH DAMAGE.
27*77f22241SEmmanuel Vadot  */
28*77f22241SEmmanuel Vadot 
29*77f22241SEmmanuel Vadot #include <sys/param.h>
30*77f22241SEmmanuel Vadot #include <sys/systm.h>
31*77f22241SEmmanuel Vadot #include <sys/bus.h>
32*77f22241SEmmanuel Vadot #include <sys/rman.h>
33*77f22241SEmmanuel Vadot #include <sys/kernel.h>
34*77f22241SEmmanuel Vadot #include <sys/module.h>
35*77f22241SEmmanuel Vadot #include <machine/bus.h>
36*77f22241SEmmanuel Vadot 
37*77f22241SEmmanuel Vadot #include <dev/fdt/simplebus.h>
38*77f22241SEmmanuel Vadot 
39*77f22241SEmmanuel Vadot #include <dev/ofw/ofw_bus.h>
40*77f22241SEmmanuel Vadot #include <dev/ofw/ofw_bus_subr.h>
41*77f22241SEmmanuel Vadot 
42*77f22241SEmmanuel Vadot #include <dev/extres/clk/clk_div.h>
43*77f22241SEmmanuel Vadot #include <dev/extres/clk/clk_fixed.h>
44*77f22241SEmmanuel Vadot #include <dev/extres/clk/clk_mux.h>
45*77f22241SEmmanuel Vadot 
46*77f22241SEmmanuel Vadot #include <dev/clk/rockchip/rk_cru.h>
47*77f22241SEmmanuel Vadot #include <contrib/device-tree/include/dt-bindings/clock/rk3568-cru.h>
48*77f22241SEmmanuel Vadot 
49*77f22241SEmmanuel Vadot 
50*77f22241SEmmanuel Vadot #define	CRU_PLLSEL_CON(x)		((x) * 0x20)
51*77f22241SEmmanuel Vadot #define	CRU_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
52*77f22241SEmmanuel Vadot #define	CRU_CLKGATE_CON(x)		((x) * 0x4 + 0x180)
53*77f22241SEmmanuel Vadot 
54*77f22241SEmmanuel Vadot /* PLL clock */
55*77f22241SEmmanuel Vadot #define	RK_PLL(_id, _name, _pnames, _off, _shift)			\
56*77f22241SEmmanuel Vadot {									\
57*77f22241SEmmanuel Vadot 	.type = RK3328_CLK_PLL,						\
58*77f22241SEmmanuel Vadot 	.clk.pll = &(struct rk_clk_pll_def) {				\
59*77f22241SEmmanuel Vadot 		.clkdef.id = _id,					\
60*77f22241SEmmanuel Vadot 		.clkdef.name = _name,					\
61*77f22241SEmmanuel Vadot 		.clkdef.parent_names = _pnames,				\
62*77f22241SEmmanuel Vadot 		.clkdef.parent_cnt = nitems(_pnames),			\
63*77f22241SEmmanuel Vadot 		.clkdef.flags = CLK_NODE_STATIC_STRINGS,		\
64*77f22241SEmmanuel Vadot 		.base_offset = CRU_PLLSEL_CON(_off),			\
65*77f22241SEmmanuel Vadot 		.mode_reg = 0x80,					\
66*77f22241SEmmanuel Vadot 		.mode_shift = _shift,					\
67*77f22241SEmmanuel Vadot 		.rates = rk3568_pll_rates,				\
68*77f22241SEmmanuel Vadot 	},								\
69*77f22241SEmmanuel Vadot }
70*77f22241SEmmanuel Vadot 
71*77f22241SEmmanuel Vadot extern struct rk_clk_pll_rate rk3568_pll_rates[];
72*77f22241SEmmanuel Vadot 
73*77f22241SEmmanuel Vadot /* Parent clock defines */
74*77f22241SEmmanuel Vadot PLIST(mux_pll_p) = { "xin24m" };
75*77f22241SEmmanuel Vadot PLIST(xin24m_32k_p) = { "xin24m", "clk_rtc_32k" };
76*77f22241SEmmanuel Vadot PLIST(sclk_uart0_p) = { "sclk_uart0_div", "sclk_uart0_frac", "xin24m" };
77*77f22241SEmmanuel Vadot PLIST(sclk_uart0_div_p) = { "ppll", "usb480m", "cpll", "gpll" };
78*77f22241SEmmanuel Vadot PLIST(clk_rtc32k_pmu_p) = { "clk_32k_pvtm", "xin32k", "clk_osc0_div32k" };
79*77f22241SEmmanuel Vadot PLIST(clk_usbphy0_ref_p) = { "clk_ref24m", "xin_osc0_usbphy0_g" };
80*77f22241SEmmanuel Vadot PLIST(clk_usbphy1_ref_p) = { "clk_ref24m", "xin_osc0_usbphy1_g" };
81*77f22241SEmmanuel Vadot PLIST(clk_mipidsiphy0_ref_p) = { "clk_ref24m", "xin_osc0_mipidsiphy0_g" };
82*77f22241SEmmanuel Vadot PLIST(clk_mipidsiphy1_ref_p) = { "clk_ref24m", "xin_osc0_mipidsiphy1_g" };
83*77f22241SEmmanuel Vadot PLIST(clk_wifi_p) = { "clk_wifi_osc0", "clk_wifi_div" };
84*77f22241SEmmanuel Vadot PLIST(clk_pciephy0_ref_p) = { "clk_pciephy0_osc0", "clk_pciephy0_div" };
85*77f22241SEmmanuel Vadot PLIST(clk_pciephy1_ref_p) = { "clk_pciephy1_osc0", "clk_pciephy1_div" };
86*77f22241SEmmanuel Vadot PLIST(clk_pciephy2_ref_p) = { "clk_pciephy2_osc0", "clk_pciephy2_div" };
87*77f22241SEmmanuel Vadot PLIST(clk_hdmi_ref_p) = { "hpll", "hpll_ph0" };
88*77f22241SEmmanuel Vadot PLIST(clk_pdpmu_p) = { "ppll", "gpll" };
89*77f22241SEmmanuel Vadot PLIST(clk_pwm0_p) = { "xin24m", "clk_pdpmu" };
90*77f22241SEmmanuel Vadot 
91*77f22241SEmmanuel Vadot /* CLOCKS */
92*77f22241SEmmanuel Vadot static struct rk_clk rk3568_clks[] = {
93*77f22241SEmmanuel Vadot 	/* External clocks */
94*77f22241SEmmanuel Vadot 	LINK("xin24m"),
95*77f22241SEmmanuel Vadot 	LINK("cpll"),
96*77f22241SEmmanuel Vadot 	LINK("gpll"),
97*77f22241SEmmanuel Vadot 	LINK("usb480m"),
98*77f22241SEmmanuel Vadot 	LINK("clk_32k_pvtm"),
99*77f22241SEmmanuel Vadot 
100*77f22241SEmmanuel Vadot 	/* Fixed clocks */
101*77f22241SEmmanuel Vadot 	FFACT(0, "ppll_ph0", "ppll", 1, 2),
102*77f22241SEmmanuel Vadot 	FFACT(0, "ppll_ph180", "ppll", 1, 2),
103*77f22241SEmmanuel Vadot 	FFACT(0, "hpll_ph0", "hpll", 1, 2),
104*77f22241SEmmanuel Vadot 
105*77f22241SEmmanuel Vadot 	/* PLL's */
106*77f22241SEmmanuel Vadot 	RK_PLL(PLL_PPLL, "ppll", mux_pll_p, 0, 0),
107*77f22241SEmmanuel Vadot 	RK_PLL(PLL_HPLL, "hpll", mux_pll_p, 2, 2),
108*77f22241SEmmanuel Vadot 
109*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON00 */
110*77f22241SEmmanuel Vadot 	CDIV(0, "xin_osc0_div_div", "xin24m", 0, 0, 0, 5),
111*77f22241SEmmanuel Vadot 	MUX(0, "clk_rtc_32k_mux", clk_rtc32k_pmu_p, 0, 0, 6, 2),
112*77f22241SEmmanuel Vadot 
113*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON01 */
114*77f22241SEmmanuel Vadot 	FRACT(0, "clk_osc0_div32k", "xin24m", 0, 1),
115*77f22241SEmmanuel Vadot 
116*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON02 */
117*77f22241SEmmanuel Vadot 	CDIV(0, "pclk_pdpmu_pre", "clk_pdpmu", 0, 2, 0, 5),
118*77f22241SEmmanuel Vadot 	MUX(CLK_PDPMU, "clk_pdpmu", clk_pdpmu_p, 0, 2, 15, 1),
119*77f22241SEmmanuel Vadot 
120*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON03 */
121*77f22241SEmmanuel Vadot 	CDIV(0, "clk_i2c0_div", "clk_pdpmu", 0, 3, 0, 7),
122*77f22241SEmmanuel Vadot 
123*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON04 */
124*77f22241SEmmanuel Vadot 	CDIV(0, "sclk_uart0_div_div", "sclk_uart0_div_sel", 0, 4, 0, 7),
125*77f22241SEmmanuel Vadot 	MUX(0, "sclk_uart0_div_sel", sclk_uart0_div_p, 0, 4, 8, 2),
126*77f22241SEmmanuel Vadot 	MUX(0, "sclk_uart0_mux", sclk_uart0_p, 0, 4, 10, 2),
127*77f22241SEmmanuel Vadot 
128*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON05 */
129*77f22241SEmmanuel Vadot 	FRACT(0, "sclk_uart0_frac_div", "sclk_uart0_div", 0, 5),
130*77f22241SEmmanuel Vadot 
131*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON06 */
132*77f22241SEmmanuel Vadot 	CDIV(0, "clk_pwm0_div", "clk_pwm0_sel", 0, 6, 0, 7),
133*77f22241SEmmanuel Vadot 	MUX(0, "clk_pwm0_sel", clk_pwm0_p, 0, 6, 7, 1),
134*77f22241SEmmanuel Vadot 	MUX(0, "dbclk_gpio0_sel", xin24m_32k_p, 0, 6, 15, 1),
135*77f22241SEmmanuel Vadot 
136*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON07 */
137*77f22241SEmmanuel Vadot 	CDIV(0, "clk_ref24m_div", "clk_pdpmu", 0, 7, 0, 6),
138*77f22241SEmmanuel Vadot 
139*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON08 */
140*77f22241SEmmanuel Vadot 	MUX(CLK_USBPHY0_REF, "clk_usbphy0_ref", clk_usbphy0_ref_p, 0, 8, 0, 1),
141*77f22241SEmmanuel Vadot 	MUX(CLK_USBPHY1_REF, "clk_usbphy1_ref", clk_usbphy1_ref_p, 0, 8, 1, 1),
142*77f22241SEmmanuel Vadot 	MUX(CLK_MIPIDSIPHY0_REF, "clk_mipidsiphy0_ref", clk_mipidsiphy0_ref_p, 0, 8, 2, 1),
143*77f22241SEmmanuel Vadot 	MUX(CLK_MIPIDSIPHY1_REF, "clk_mipidsiphy1_ref", clk_mipidsiphy1_ref_p, 0, 8, 3, 1),
144*77f22241SEmmanuel Vadot 	MUX(CLK_HDMI_REF, "clk_hdmi_ref", clk_hdmi_ref_p, 0, 8, 7, 1),
145*77f22241SEmmanuel Vadot 	CDIV(0, "clk_wifi_div_div", "clk_pdpmu", 0, 8, 8, 6),
146*77f22241SEmmanuel Vadot 	MUX(CLK_WIFI, "clk_wifi", clk_wifi_p, 0, 8, 15, 1),
147*77f22241SEmmanuel Vadot 
148*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUCLKSEL_CON09 */
149*77f22241SEmmanuel Vadot 	CDIV(0, "clk_pciephy0_div_div", "ppll_ph0", 0, 9, 0, 3),
150*77f22241SEmmanuel Vadot 	MUX(CLK_PCIEPHY0_REF, "clk_pciephy0_ref",
151*77f22241SEmmanuel Vadot 	  clk_pciephy0_ref_p, 0, 9, 3, 1),
152*77f22241SEmmanuel Vadot 	CDIV(0, "clk_pciephy1_div_div", "ppll_ph0", 0, 9, 4, 3),
153*77f22241SEmmanuel Vadot 	MUX(CLK_PCIEPHY1_REF, "clk_pciephy1_ref",
154*77f22241SEmmanuel Vadot 	  clk_pciephy1_ref_p, 0, 9, 7, 1),
155*77f22241SEmmanuel Vadot 	CDIV(0, "clk_pciephy2_div_div", "ppll_ph0", 0, 9, 8, 3),
156*77f22241SEmmanuel Vadot 	MUX(CLK_PCIEPHY2_REF, "clk_pciephy2_ref",
157*77f22241SEmmanuel Vadot 	  clk_pciephy2_ref_p, 0, 9, 11, 1),
158*77f22241SEmmanuel Vadot };
159*77f22241SEmmanuel Vadot 
160*77f22241SEmmanuel Vadot /* GATES */
161*77f22241SEmmanuel Vadot static struct rk_cru_gate rk3568_gates[] = {
162*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUGATE_CON00 */
163*77f22241SEmmanuel Vadot 	GATE(XIN_OSC0_DIV, "xin_osc0_div", "xin_osc0_div_div",			0, 0),
164*77f22241SEmmanuel Vadot 	GATE(CLK_RTC_32K, "clk_rtc_32k", "clk_rtc_32k_mux",			0, 1),
165*77f22241SEmmanuel Vadot 	GATE(PCLK_PDPMU, "pclk_pdpmu", "pclk_pdpmu_pre",			0, 2),
166*77f22241SEmmanuel Vadot 	GATE(PCLK_PMU, "pclk_pmu", "pclk_pdpmu",				0, 6),
167*77f22241SEmmanuel Vadot 	GATE(CLK_PMU, "clk_pmu", "xin24m",					0, 7),
168*77f22241SEmmanuel Vadot 
169*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUGATE_CON01 */
170*77f22241SEmmanuel Vadot 	GATE(PCLK_I2C0, "pclk_i2c0", "pclk_pdpmu",				1, 0),
171*77f22241SEmmanuel Vadot 	GATE(CLK_I2C0, "clk_i2c0", "clk_i2c0_div",				1, 1),
172*77f22241SEmmanuel Vadot 	GATE(PCLK_UART0, "pclk_uart0", "pclk_pdpmu",				1, 2),
173*77f22241SEmmanuel Vadot 	GATE(CLK_UART0_DIV, "sclk_uart0_div", "sclk_uart0_div_div",		1, 3),
174*77f22241SEmmanuel Vadot 	GATE(CLK_UART0_FRAC, "sclk_uart0_frac", "sclk_uart0_frac_div",		1, 4),
175*77f22241SEmmanuel Vadot 	GATE(SCLK_UART0, "sclk_uart0", "sclk_uart0_mux",			1, 5),
176*77f22241SEmmanuel Vadot 	GATE(PCLK_PWM0, "pclk_pwm0", "pclk_pdpmu",				1, 6),
177*77f22241SEmmanuel Vadot 	GATE(CLK_PWM0, "clk_pwm0", "clk_pwm0_div",				1, 7),
178*77f22241SEmmanuel Vadot 	GATE(CLK_CAPTURE_PWM0_NDFT, "clk_capture_pwm0_ndft", "xin24m",		1, 8),
179*77f22241SEmmanuel Vadot 	GATE(PCLK_GPIO0, "pclk_gpio0", "pclk_pdpmu",				1, 9),
180*77f22241SEmmanuel Vadot 	GATE(DBCLK_GPIO0, "dbclk_gpio0", "dbclk_gpio0_sel",			1, 10),
181*77f22241SEmmanuel Vadot 	GATE(PCLK_PMUPVTM, "pclk_pmupvtm", "pclk_pdpmu",			1, 11),
182*77f22241SEmmanuel Vadot 	GATE(CLK_PMUPVTM, "clk_pmupvtm", "xin24m",				1, 12),
183*77f22241SEmmanuel Vadot 	GATE(CLK_CORE_PMUPVTM, "clk_core_pmupvtm", "xin24m",			1, 13),
184*77f22241SEmmanuel Vadot 
185*77f22241SEmmanuel Vadot 	/* PMUCRU_PMUGATE_CON02 */
186*77f22241SEmmanuel Vadot 	GATE(CLK_REF24M, "clk_ref24m", "clk_ref24m_div",			2, 0),
187*77f22241SEmmanuel Vadot 	GATE(XIN_OSC0_USBPHY0_G, "xin_osc0_usbphy0_g", "xin24m",		2, 1),
188*77f22241SEmmanuel Vadot 	GATE(XIN_OSC0_USBPHY1_G, "xin_osc0_usbphy1_g", "xin24m",		2, 2),
189*77f22241SEmmanuel Vadot 	GATE(XIN_OSC0_MIPIDSIPHY0_G, "xin_osc0_mipidsiphy0_g", "xin24m",	2, 3),
190*77f22241SEmmanuel Vadot 	GATE(XIN_OSC0_MIPIDSIPHY1_G, "xin_osc0_mipidsiphy1_g", "xin24m",	2, 4),
191*77f22241SEmmanuel Vadot 	GATE(CLK_WIFI_DIV, "clk_wifi_div", "clk_wifi_div_div",			2, 5),
192*77f22241SEmmanuel Vadot 	GATE(CLK_WIFI_OSC0, "clk_wifi_osc0", "xin24m",				2, 6),
193*77f22241SEmmanuel Vadot 	GATE(CLK_PCIEPHY0_DIV, "clk_pciephy0_div", "clk_pciephy0_div_div",	2, 7),
194*77f22241SEmmanuel Vadot 	GATE(CLK_PCIEPHY0_OSC0, "clk_pciephy0_osc0", "xin24m",			2, 8),
195*77f22241SEmmanuel Vadot 	GATE(CLK_PCIEPHY1_DIV, "clk_pciephy1_div", "clk_pciephy1_div_div",	2, 9),
196*77f22241SEmmanuel Vadot 	GATE(CLK_PCIEPHY1_OSC0, "clk_pciephy1_osc0", "xin24m",			2, 10),
197*77f22241SEmmanuel Vadot 	GATE(CLK_PCIEPHY2_DIV, "clk_pciephy2_div", "clk_pciephy2_div_div",	2, 11),
198*77f22241SEmmanuel Vadot 	GATE(CLK_PCIEPHY2_OSC0, "clk_pciephy2_osc0", "xin24m",			2, 12),
199*77f22241SEmmanuel Vadot 	GATE(CLK_PCIE30PHY_REF_M, "clk_pcie30phy_ref_m", "ppll_ph0",		2, 13),
200*77f22241SEmmanuel Vadot 	GATE(CLK_PCIE30PHY_REF_N, "clk_pcie30phy_ref_n", "ppll_ph180",		2, 14),
201*77f22241SEmmanuel Vadot 	GATE(XIN_OSC0_EDPPHY_G, "xin_osc0_edpphy_g", "xin24m",			2, 15),
202*77f22241SEmmanuel Vadot };
203*77f22241SEmmanuel Vadot 
204*77f22241SEmmanuel Vadot static int
205*77f22241SEmmanuel Vadot rk3568_pmucru_probe(device_t dev)
206*77f22241SEmmanuel Vadot {
207*77f22241SEmmanuel Vadot 
208*77f22241SEmmanuel Vadot 	if (!ofw_bus_status_okay(dev))
209*77f22241SEmmanuel Vadot 		return (ENXIO);
210*77f22241SEmmanuel Vadot 
211*77f22241SEmmanuel Vadot 	if (ofw_bus_is_compatible(dev, "rockchip,rk3568-pmucru")) {
212*77f22241SEmmanuel Vadot 		device_set_desc(dev, "Rockchip RK3568 PMU Clock & Reset Unit");
213*77f22241SEmmanuel Vadot 		return (BUS_PROBE_DEFAULT);
214*77f22241SEmmanuel Vadot 	}
215*77f22241SEmmanuel Vadot 
216*77f22241SEmmanuel Vadot 	return (ENXIO);
217*77f22241SEmmanuel Vadot }
218*77f22241SEmmanuel Vadot 
219*77f22241SEmmanuel Vadot static int
220*77f22241SEmmanuel Vadot rk3568_pmucru_attach(device_t dev)
221*77f22241SEmmanuel Vadot {
222*77f22241SEmmanuel Vadot 	struct rk_cru_softc *sc;
223*77f22241SEmmanuel Vadot 
224*77f22241SEmmanuel Vadot 	sc = device_get_softc(dev);
225*77f22241SEmmanuel Vadot 	sc->dev = dev;
226*77f22241SEmmanuel Vadot 	sc->clks = rk3568_clks;
227*77f22241SEmmanuel Vadot 	sc->nclks = nitems(rk3568_clks);
228*77f22241SEmmanuel Vadot 	sc->gates = rk3568_gates;
229*77f22241SEmmanuel Vadot 	sc->ngates = nitems(rk3568_gates);
230*77f22241SEmmanuel Vadot 	sc->reset_offset = 0x200;
231*77f22241SEmmanuel Vadot 	sc->reset_num = 4;
232*77f22241SEmmanuel Vadot 
233*77f22241SEmmanuel Vadot 	return (rk_cru_attach(dev));
234*77f22241SEmmanuel Vadot }
235*77f22241SEmmanuel Vadot 
236*77f22241SEmmanuel Vadot static device_method_t methods[] = {
237*77f22241SEmmanuel Vadot 	/* Device interface */
238*77f22241SEmmanuel Vadot 	DEVMETHOD(device_probe,		rk3568_pmucru_probe),
239*77f22241SEmmanuel Vadot 	DEVMETHOD(device_attach,	rk3568_pmucru_attach),
240*77f22241SEmmanuel Vadot 
241*77f22241SEmmanuel Vadot 	DEVMETHOD_END
242*77f22241SEmmanuel Vadot };
243*77f22241SEmmanuel Vadot 
244*77f22241SEmmanuel Vadot DEFINE_CLASS_1(rk3568_pmucru, rk3568_pmucru_driver, methods,
245*77f22241SEmmanuel Vadot     sizeof(struct rk_cru_softc), rk_cru_driver);
246*77f22241SEmmanuel Vadot 
247*77f22241SEmmanuel Vadot EARLY_DRIVER_MODULE(rk3568_pmucru, simplebus, rk3568_pmucru_driver,
248*77f22241SEmmanuel Vadot     0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
249