sun9i_a80_ccu.c revision 1.1 1 1.1 jmcneill /* $NetBSD: sun9i_a80_ccu.c,v 1.1 2017/10/08 18:00:36 jmcneill Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2017 Jared McNeill <jmcneill (at) invisible.ca>
5 1.1 jmcneill * All rights reserved.
6 1.1 jmcneill *
7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.1 jmcneill * modification, are permitted provided that the following conditions
9 1.1 jmcneill * are met:
10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill *
16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 jmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 jmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 jmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 jmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 jmcneill * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 jmcneill * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 jmcneill * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 jmcneill * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 jmcneill * SUCH DAMAGE.
27 1.1 jmcneill */
28 1.1 jmcneill
29 1.1 jmcneill #include <sys/cdefs.h>
30 1.1 jmcneill
31 1.1 jmcneill __KERNEL_RCSID(1, "$NetBSD: sun9i_a80_ccu.c,v 1.1 2017/10/08 18:00:36 jmcneill Exp $");
32 1.1 jmcneill
33 1.1 jmcneill #include <sys/param.h>
34 1.1 jmcneill #include <sys/bus.h>
35 1.1 jmcneill #include <sys/device.h>
36 1.1 jmcneill #include <sys/systm.h>
37 1.1 jmcneill
38 1.1 jmcneill #include <dev/fdt/fdtvar.h>
39 1.1 jmcneill
40 1.1 jmcneill #include <arm/sunxi/sunxi_ccu.h>
41 1.1 jmcneill #include <arm/sunxi/sun9i_a80_ccu.h>
42 1.1 jmcneill
43 1.1 jmcneill /* CCU */
44 1.1 jmcneill #define PLL_PERIPH0_CTRL_REG 0x00c
45 1.1 jmcneill #define PLL_PERIPH1_CTRL_REG 0x02c
46 1.1 jmcneill #define GTBUS_CLK_CFG_REG 0x05c
47 1.1 jmcneill #define AHB0_CLK_CFG_REG 0x060
48 1.1 jmcneill #define AHB1_CLK_CFG_REG 0x064
49 1.1 jmcneill #define AHB2_CLK_CFG_REG 0x068
50 1.1 jmcneill #define APB0_CLK_CFG_REG 0x070
51 1.1 jmcneill #define APB1_CLK_CFG_REG 0x074
52 1.1 jmcneill
53 1.1 jmcneill /* CCU_SCLK */
54 1.1 jmcneill #define SDMMC0_CLK_REG 0x410
55 1.1 jmcneill #define SDMMC1_CLK_REG 0x414
56 1.1 jmcneill #define SDMMC2_CLK_REG 0x418
57 1.1 jmcneill #define BUS_CLK_GATING_REG0 0x580
58 1.1 jmcneill #define BUS_CLK_GATING_REG1 0x584
59 1.1 jmcneill #define BUS_CLK_GATING_REG2 0x588
60 1.1 jmcneill #define BUS_CLK_GATING_REG3 0x590
61 1.1 jmcneill #define BUS_CLK_GATING_REG4 0x594
62 1.1 jmcneill #define BUS_SOFT_RST_REG0 0x5a0
63 1.1 jmcneill #define BUS_SOFT_RST_REG1 0x5a4
64 1.1 jmcneill #define BUS_SOFT_RST_REG2 0x5a8
65 1.1 jmcneill #define BUS_SOFT_RST_REG3 0x5b0
66 1.1 jmcneill #define BUS_SOFT_RST_REG4 0x5b4
67 1.1 jmcneill
68 1.1 jmcneill static int sun9i_a80_ccu_match(device_t, cfdata_t, void *);
69 1.1 jmcneill static void sun9i_a80_ccu_attach(device_t, device_t, void *);
70 1.1 jmcneill
71 1.1 jmcneill static const char * compatible[] = {
72 1.1 jmcneill "allwinner,sun9i-a80-ccu",
73 1.1 jmcneill NULL
74 1.1 jmcneill };
75 1.1 jmcneill
76 1.1 jmcneill CFATTACH_DECL_NEW(sunxi_a80_ccu, sizeof(struct sunxi_ccu_softc),
77 1.1 jmcneill sun9i_a80_ccu_match, sun9i_a80_ccu_attach, NULL, NULL);
78 1.1 jmcneill
79 1.1 jmcneill static struct sunxi_ccu_reset sun9i_a80_ccu_resets[] = {
80 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_FD, BUS_SOFT_RST_REG0, 0),
81 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_GPU_CTRL, BUS_SOFT_RST_REG0, 3),
82 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_SS, BUS_SOFT_RST_REG0, 5),
83 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_MMC, BUS_SOFT_RST_REG0, 8),
84 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_NAND1, BUS_SOFT_RST_REG0, 12),
85 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_NAND0, BUS_SOFT_RST_REG0, 13),
86 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_TS, BUS_SOFT_RST_REG0, 18),
87 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_SPI0, BUS_SOFT_RST_REG0, 20),
88 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_SPI1, BUS_SOFT_RST_REG0, 21),
89 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_SPI2, BUS_SOFT_RST_REG0, 22),
90 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_SPI3, BUS_SOFT_RST_REG0, 23),
91 1.1 jmcneill
92 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_OTG_PHY, BUS_SOFT_RST_REG1, 1),
93 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_MSGBOX, BUS_SOFT_RST_REG1, 21),
94 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_SPINLOCK, BUS_SOFT_RST_REG1, 22),
95 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_HSTIMER, BUS_SOFT_RST_REG1, 23),
96 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_DMA, BUS_SOFT_RST_REG1, 24),
97 1.1 jmcneill
98 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_LCD0, BUS_SOFT_RST_REG2, 0),
99 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_LCD1, BUS_SOFT_RST_REG2, 1),
100 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_CSI, BUS_SOFT_RST_REG2, 4),
101 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_DE, BUS_SOFT_RST_REG2, 7),
102 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_MP, BUS_SOFT_RST_REG2, 8),
103 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_GPU, BUS_SOFT_RST_REG2, 9),
104 1.1 jmcneill
105 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_LRADC, BUS_SOFT_RST_REG3, 15),
106 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_GPADC, BUS_SOFT_RST_REG3, 17),
107 1.1 jmcneill
108 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_I2C0, BUS_SOFT_RST_REG4, 0),
109 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_I2C1, BUS_SOFT_RST_REG4, 1),
110 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_I2C2, BUS_SOFT_RST_REG4, 2),
111 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_I2C3, BUS_SOFT_RST_REG4, 3),
112 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_I2C4, BUS_SOFT_RST_REG4, 4),
113 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_UART0, BUS_SOFT_RST_REG4, 16),
114 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_UART1, BUS_SOFT_RST_REG4, 17),
115 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_UART2, BUS_SOFT_RST_REG4, 18),
116 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_UART3, BUS_SOFT_RST_REG4, 19),
117 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_UART4, BUS_SOFT_RST_REG4, 20),
118 1.1 jmcneill SUNXI_CCU_RESET(A80_RST_BUS_UART5, BUS_SOFT_RST_REG4, 21),
119 1.1 jmcneill };
120 1.1 jmcneill
121 1.1 jmcneill static const char *gtbus_parents[] = { "hosc", "pll_periph0", "pll_periph1" };
122 1.1 jmcneill static const char *ahb0_parents[] = { "gtbus", "pll_periph0", "pll_periph1" };
123 1.1 jmcneill static const char *ahb1_parents[] = { "gtbus", "pll_periph0", "pll_periph1" };
124 1.1 jmcneill static const char *ahb2_parents[] = { "hosc", "pll_periph0", "pll_periph1" };
125 1.1 jmcneill static const char *apb_parents[] = { "hosc", "pll_periph0" };
126 1.1 jmcneill static const char *mmc_parents[] = { "hosc", "pll_periph0" };
127 1.1 jmcneill
128 1.1 jmcneill static struct sunxi_ccu_clk sun9i_a80_ccu_clks[] = {
129 1.1 jmcneill SUNXI_CCU_NKMP(A80_CLK_PLL_PERIPH0, "pll_periph0", "hosc",
130 1.1 jmcneill PLL_PERIPH0_CTRL_REG, /* reg */
131 1.1 jmcneill __BITS(15,8), /* n */
132 1.1 jmcneill __BIT(16), /* k */
133 1.1 jmcneill 0, /* m */
134 1.1 jmcneill __BIT(18), /* p */
135 1.1 jmcneill __BIT(31), /* enable */
136 1.1 jmcneill SUNXI_CCU_NKMP_FACTOR_N_EXACT),
137 1.1 jmcneill SUNXI_CCU_NKMP(A80_CLK_PLL_PERIPH1, "pll_periph1", "hosc",
138 1.1 jmcneill PLL_PERIPH1_CTRL_REG, /* reg */
139 1.1 jmcneill __BITS(15,8), /* n */
140 1.1 jmcneill __BIT(16), /* k */
141 1.1 jmcneill 0, /* m */
142 1.1 jmcneill __BIT(18), /* p */
143 1.1 jmcneill __BIT(31), /* enable */
144 1.1 jmcneill SUNXI_CCU_NKMP_FACTOR_N_EXACT),
145 1.1 jmcneill
146 1.1 jmcneill SUNXI_CCU_DIV(A80_CLK_GTBUS, "gtbus", gtbus_parents,
147 1.1 jmcneill GTBUS_CLK_CFG_REG, /* reg */
148 1.1 jmcneill __BITS(1,0), /* div */
149 1.1 jmcneill __BITS(25,24), /* sel */
150 1.1 jmcneill 0),
151 1.1 jmcneill
152 1.1 jmcneill SUNXI_CCU_DIV(A80_CLK_AHB0, "ahb0", ahb0_parents,
153 1.1 jmcneill AHB0_CLK_CFG_REG, /* reg */
154 1.1 jmcneill __BITS(1,0), /* div */
155 1.1 jmcneill __BITS(25,24), /* sel */
156 1.1 jmcneill SUNXI_CCU_DIV_POWER_OF_TWO),
157 1.1 jmcneill
158 1.1 jmcneill SUNXI_CCU_DIV(A80_CLK_AHB1, "ahb1", ahb1_parents,
159 1.1 jmcneill AHB1_CLK_CFG_REG, /* reg */
160 1.1 jmcneill __BITS(1,0), /* div */
161 1.1 jmcneill __BITS(25,24), /* sel */
162 1.1 jmcneill SUNXI_CCU_DIV_POWER_OF_TWO),
163 1.1 jmcneill
164 1.1 jmcneill SUNXI_CCU_DIV(A80_CLK_AHB2, "ahb2", ahb2_parents,
165 1.1 jmcneill AHB2_CLK_CFG_REG, /* reg */
166 1.1 jmcneill __BITS(1,0), /* div */
167 1.1 jmcneill __BITS(25,24), /* sel */
168 1.1 jmcneill SUNXI_CCU_DIV_POWER_OF_TWO),
169 1.1 jmcneill
170 1.1 jmcneill SUNXI_CCU_DIV(A80_CLK_APB0, "apb0", apb_parents,
171 1.1 jmcneill APB0_CLK_CFG_REG, /* reg */
172 1.1 jmcneill __BITS(1,0), /* div */
173 1.1 jmcneill __BIT(24), /* sel */
174 1.1 jmcneill SUNXI_CCU_DIV_POWER_OF_TWO),
175 1.1 jmcneill
176 1.1 jmcneill SUNXI_CCU_NM(A80_CLK_APB1, "apb1", apb_parents,
177 1.1 jmcneill APB1_CLK_CFG_REG, /* reg */
178 1.1 jmcneill __BITS(17,16), /* n */
179 1.1 jmcneill __BITS(4,0), /* m */
180 1.1 jmcneill __BIT(24), /* sel */
181 1.1 jmcneill 0, /* enable */
182 1.1 jmcneill SUNXI_CCU_NM_POWER_OF_TWO),
183 1.1 jmcneill
184 1.1 jmcneill SUNXI_CCU_NM(A80_CLK_MMC0, "mmc0", mmc_parents,
185 1.1 jmcneill SDMMC0_CLK_REG, /* reg */
186 1.1 jmcneill __BITS(17,16), /* n */
187 1.1 jmcneill __BITS(3,0), /* m */
188 1.1 jmcneill __BITS(27,24), /* sel */
189 1.1 jmcneill __BIT(31), /* enable */
190 1.1 jmcneill SUNXI_CCU_NM_POWER_OF_TWO),
191 1.1 jmcneill SUNXI_CCU_PHASE(A80_CLK_MMC0_SAMPLE, "mmc0_sample", "mmc0",
192 1.1 jmcneill SDMMC0_CLK_REG, __BITS(22,20)),
193 1.1 jmcneill SUNXI_CCU_PHASE(A80_CLK_MMC0_OUTPUT, "mmc0_output", "mmc0",
194 1.1 jmcneill SDMMC0_CLK_REG, __BITS(10,8)),
195 1.1 jmcneill SUNXI_CCU_NM(A80_CLK_MMC1, "mmc1", mmc_parents,
196 1.1 jmcneill SDMMC1_CLK_REG, /* reg */
197 1.1 jmcneill __BITS(17,16), /* n */
198 1.1 jmcneill __BITS(3,0), /* m */
199 1.1 jmcneill __BITS(27,24), /* sel */
200 1.1 jmcneill __BIT(31), /* enable */
201 1.1 jmcneill SUNXI_CCU_NM_POWER_OF_TWO),
202 1.1 jmcneill SUNXI_CCU_PHASE(A80_CLK_MMC1_SAMPLE, "mmc1_sample", "mmc1",
203 1.1 jmcneill SDMMC1_CLK_REG, __BITS(22,20)),
204 1.1 jmcneill SUNXI_CCU_PHASE(A80_CLK_MMC1_OUTPUT, "mmc1_output", "mmc1",
205 1.1 jmcneill SDMMC1_CLK_REG, __BITS(10,8)),
206 1.1 jmcneill SUNXI_CCU_NM(A80_CLK_MMC2, "mmc2", mmc_parents,
207 1.1 jmcneill SDMMC2_CLK_REG, /* reg */
208 1.1 jmcneill __BITS(17,16), /* n */
209 1.1 jmcneill __BITS(3,0), /* m */
210 1.1 jmcneill __BITS(27,24), /* sel */
211 1.1 jmcneill __BIT(31), /* enable */
212 1.1 jmcneill SUNXI_CCU_NM_POWER_OF_TWO),
213 1.1 jmcneill SUNXI_CCU_PHASE(A80_CLK_MMC2_SAMPLE, "mmc2_sample", "mmc2",
214 1.1 jmcneill SDMMC2_CLK_REG, __BITS(22,20)),
215 1.1 jmcneill SUNXI_CCU_PHASE(A80_CLK_MMC2_OUTPUT, "mmc2_output", "mmc2",
216 1.1 jmcneill SDMMC2_CLK_REG, __BITS(10,8)),
217 1.1 jmcneill
218 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_FD, "ahb0-fd", "ahb0",
219 1.1 jmcneill BUS_CLK_GATING_REG0, 0),
220 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_GPU_CTRL, "ahb0-gpu-ctrl", "ahb0",
221 1.1 jmcneill BUS_CLK_GATING_REG0, 3),
222 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_SS, "ahb0-ss", "ahb0",
223 1.1 jmcneill BUS_CLK_GATING_REG0, 5),
224 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_MMC, "ahb0-mmc", "ahb0",
225 1.1 jmcneill BUS_CLK_GATING_REG0, 8),
226 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_NAND1, "ahb0-nand1", "ahb0",
227 1.1 jmcneill BUS_CLK_GATING_REG0, 12),
228 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_NAND0, "ahb0-nand0", "ahb0",
229 1.1 jmcneill BUS_CLK_GATING_REG0, 13),
230 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_TS, "ahb0-ts", "ahb0",
231 1.1 jmcneill BUS_CLK_GATING_REG0, 18),
232 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_SPI0, "ahb0-spi0", "ahb0",
233 1.1 jmcneill BUS_CLK_GATING_REG0, 20),
234 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_SPI1, "ahb0-spi1", "ahb0",
235 1.1 jmcneill BUS_CLK_GATING_REG0, 21),
236 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_SPI2, "ahb0-spi2", "ahb0",
237 1.1 jmcneill BUS_CLK_GATING_REG0, 22),
238 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_SPI3, "ahb0-spi3", "ahb0",
239 1.1 jmcneill BUS_CLK_GATING_REG0, 23),
240 1.1 jmcneill
241 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_USB, "ahb1-usb", "ahb1",
242 1.1 jmcneill BUS_CLK_GATING_REG1, 1),
243 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_MSGBOX, "ahb1-msgbox", "ahb1",
244 1.1 jmcneill BUS_CLK_GATING_REG1, 21),
245 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_SPINLOCK, "ahb1-spinlock", "ahb1",
246 1.1 jmcneill BUS_CLK_GATING_REG1, 22),
247 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_HSTIMER, "ahb1-hstimer", "ahb1",
248 1.1 jmcneill BUS_CLK_GATING_REG1, 23),
249 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_DMA, "ahb1-dma", "ahb1",
250 1.1 jmcneill BUS_CLK_GATING_REG1, 24),
251 1.1 jmcneill
252 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_LCD0, "ahb2-lcd0", "ahb2",
253 1.1 jmcneill BUS_CLK_GATING_REG2, 0),
254 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_LCD1, "ahb2-lcd1", "ahb2",
255 1.1 jmcneill BUS_CLK_GATING_REG2, 1),
256 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_CSI, "ahb2-csi", "ahb2",
257 1.1 jmcneill BUS_CLK_GATING_REG2, 4),
258 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_DE, "ahb2-de", "ahb2",
259 1.1 jmcneill BUS_CLK_GATING_REG2, 7),
260 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_MP, "ahb2-mp", "ahb2",
261 1.1 jmcneill BUS_CLK_GATING_REG2, 8),
262 1.1 jmcneill
263 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_PIO, "apb0-pio", "apb0",
264 1.1 jmcneill BUS_CLK_GATING_REG3, 5),
265 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_LRADC, "apb0-lradc", "apb0",
266 1.1 jmcneill BUS_CLK_GATING_REG3, 15),
267 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_GPADC, "apb0-gpadc", "apb0",
268 1.1 jmcneill BUS_CLK_GATING_REG3, 17),
269 1.1 jmcneill
270 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_I2C0, "apb1-i2c0", "apb1",
271 1.1 jmcneill BUS_CLK_GATING_REG4, 0),
272 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_I2C1, "apb1-i2c1", "apb1",
273 1.1 jmcneill BUS_CLK_GATING_REG4, 1),
274 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_I2C2, "apb1-i2c2", "apb1",
275 1.1 jmcneill BUS_CLK_GATING_REG4, 2),
276 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_I2C3, "apb1-i2c3", "apb1",
277 1.1 jmcneill BUS_CLK_GATING_REG4, 3),
278 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_I2C4, "apb1-i2c4", "apb1",
279 1.1 jmcneill BUS_CLK_GATING_REG4, 4),
280 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_UART0, "apb1-uart0", "apb1",
281 1.1 jmcneill BUS_CLK_GATING_REG4, 16),
282 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_UART1, "apb1-uart1", "apb1",
283 1.1 jmcneill BUS_CLK_GATING_REG4, 17),
284 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_UART2, "apb1-uart2", "apb1",
285 1.1 jmcneill BUS_CLK_GATING_REG4, 18),
286 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_UART3, "apb1-uart3", "apb1",
287 1.1 jmcneill BUS_CLK_GATING_REG4, 19),
288 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_UART4, "apb1-uart4", "apb1",
289 1.1 jmcneill BUS_CLK_GATING_REG4, 20),
290 1.1 jmcneill SUNXI_CCU_GATE(A80_CLK_BUS_UART5, "apb1-uart5", "apb1",
291 1.1 jmcneill BUS_CLK_GATING_REG4, 21),
292 1.1 jmcneill };
293 1.1 jmcneill
294 1.1 jmcneill static int
295 1.1 jmcneill sun9i_a80_ccu_match(device_t parent, cfdata_t cf, void *aux)
296 1.1 jmcneill {
297 1.1 jmcneill struct fdt_attach_args * const faa = aux;
298 1.1 jmcneill
299 1.1 jmcneill return of_match_compatible(faa->faa_phandle, compatible);
300 1.1 jmcneill }
301 1.1 jmcneill
302 1.1 jmcneill static void
303 1.1 jmcneill sun9i_a80_ccu_attach(device_t parent, device_t self, void *aux)
304 1.1 jmcneill {
305 1.1 jmcneill struct sunxi_ccu_softc * const sc = device_private(self);
306 1.1 jmcneill struct fdt_attach_args * const faa = aux;
307 1.1 jmcneill
308 1.1 jmcneill sc->sc_dev = self;
309 1.1 jmcneill sc->sc_phandle = faa->faa_phandle;
310 1.1 jmcneill sc->sc_bst = faa->faa_bst;
311 1.1 jmcneill
312 1.1 jmcneill sc->sc_resets = sun9i_a80_ccu_resets;
313 1.1 jmcneill sc->sc_nresets = __arraycount(sun9i_a80_ccu_resets);
314 1.1 jmcneill
315 1.1 jmcneill sc->sc_clks = sun9i_a80_ccu_clks;
316 1.1 jmcneill sc->sc_nclks = __arraycount(sun9i_a80_ccu_clks);
317 1.1 jmcneill
318 1.1 jmcneill if (sunxi_ccu_attach(sc) != 0)
319 1.1 jmcneill return;
320 1.1 jmcneill
321 1.1 jmcneill aprint_naive("\n");
322 1.1 jmcneill aprint_normal(": A80 CCU\n");
323 1.1 jmcneill
324 1.1 jmcneill sunxi_ccu_print(sc);
325 1.1 jmcneill }
326