2 * Copyright (c) 2017 Kyle Evans <kevans@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/systm.h>
36 #include <dev/extres/clk/clk_div.h>
37 #include <dev/extres/clk/clk_fixed.h>
38 #include <dev/extres/clk/clk_mux.h>
40 #include <arm/allwinner/clkng/aw_ccung.h>
41 #include <arm/allwinner/clkng/aw_clk.h>
42 #include <arm/allwinner/clkng/aw_clk_nm.h>
43 #include <arm/allwinner/clkng/aw_clk_nkmp.h>
44 #include <arm/allwinner/clkng/aw_clk_prediv_mux.h>
46 #include <gnu/dts/include/dt-bindings/clock/sun8i-a83t-ccu.h>
47 #include <gnu/dts/include/dt-bindings/reset/sun8i-a83t-ccu.h>
51 /* Non-exported resets */
53 #define RST_BUS_SCR 53
56 /* Non-exported clocks */
58 #define CLK_PLL_C0CPUX 0
59 #define CLK_PLL_C1CPUX 1
60 #define CLK_PLL_AUDIO 2
61 #define CLK_PLL_VIDEO0 3
66 #define CLK_PLL_HSIC 8
67 #define CLK_PLL_VIDEO1 10
82 /* Non-exported fixed clocks */
83 #define CLK_OSC_12M 150
86 static struct aw_ccung_reset a83t_ccu_resets[] = {
87 CCU_RESET(RST_USB_PHY0, 0xcc, 0)
88 CCU_RESET(RST_USB_PHY1, 0xcc, 1)
89 CCU_RESET(RST_USB_HSIC, 0xcc, 2)
91 CCU_RESET(RST_DRAM, 0xf4, 31)
92 CCU_RESET(RST_MBUS, 0xfc, 31)
94 CCU_RESET(RST_BUS_MIPI_DSI, 0x2c0, 1)
95 CCU_RESET(RST_BUS_SS, 0x2c0, 5)
96 CCU_RESET(RST_BUS_DMA, 0x2c0, 6)
97 CCU_RESET(RST_BUS_MMC0, 0x2c0, 8)
98 CCU_RESET(RST_BUS_MMC1, 0x2c0, 9)
99 CCU_RESET(RST_BUS_MMC2, 0x2c0, 10)
100 CCU_RESET(RST_BUS_NAND, 0x2c0, 13)
101 CCU_RESET(RST_BUS_DRAM, 0x2c0, 14)
102 CCU_RESET(RST_BUS_EMAC, 0x2c0, 17)
103 CCU_RESET(RST_BUS_HSTIMER, 0x2c0, 19)
104 CCU_RESET(RST_BUS_SPI0, 0x2c0, 20)
105 CCU_RESET(RST_BUS_SPI1, 0x2c0, 21)
106 CCU_RESET(RST_BUS_OTG, 0x2c0, 24)
107 CCU_RESET(RST_BUS_EHCI0, 0x2c0, 26)
108 CCU_RESET(RST_BUS_EHCI1, 0x2c0, 27)
109 CCU_RESET(RST_BUS_OHCI0, 0x2c0, 29)
111 CCU_RESET(RST_BUS_VE, 0x2c4, 0)
112 CCU_RESET(RST_BUS_TCON0, 0x2c4, 4)
113 CCU_RESET(RST_BUS_TCON1, 0x2c4, 5)
114 CCU_RESET(RST_BUS_CSI, 0x2c4, 8)
115 CCU_RESET(RST_BUS_HDMI0, 0x2c4, 10)
116 CCU_RESET(RST_BUS_HDMI1, 0x2c4, 11)
117 CCU_RESET(RST_BUS_DE, 0x2c4, 12)
118 CCU_RESET(RST_BUS_GPU, 0x2c4, 20)
119 CCU_RESET(RST_BUS_MSGBOX, 0x2c4, 21)
120 CCU_RESET(RST_BUS_SPINLOCK, 0x2c4, 22)
122 CCU_RESET(RST_BUS_LVDS, 0x2c8, 0)
124 CCU_RESET(RST_BUS_SPDIF, 0x2d0, 1)
125 CCU_RESET(RST_BUS_I2S0, 0x2d0, 12)
126 CCU_RESET(RST_BUS_I2S1, 0x2d0, 13)
127 CCU_RESET(RST_BUS_I2S2, 0x2d0, 14)
128 CCU_RESET(RST_BUS_TDM, 0x2d0, 15)
130 CCU_RESET(RST_BUS_I2C0, 0x2d8, 0)
131 CCU_RESET(RST_BUS_I2C1, 0x2d8, 1)
132 CCU_RESET(RST_BUS_I2C2, 0x2d8, 2)
133 CCU_RESET(RST_BUS_UART0, 0x2d8, 16)
134 CCU_RESET(RST_BUS_UART1, 0x2d8, 17)
135 CCU_RESET(RST_BUS_UART2, 0x2d8, 18)
136 CCU_RESET(RST_BUS_UART3, 0x2d8, 19)
137 CCU_RESET(RST_BUS_UART4, 0x2d8, 20)
140 static struct aw_ccung_gate a83t_ccu_gates[] = {
141 CCU_GATE(CLK_BUS_MIPI_DSI, "bus-mipi-dsi", "ahb1", 0x60, 1)
142 CCU_GATE(CLK_BUS_SS, "bus-ss", "ahb1", 0x60, 5)
143 CCU_GATE(CLK_BUS_DMA, "bus-dma", "ahb1", 0x60, 6)
144 CCU_GATE(CLK_BUS_MMC0, "bus-mmc0", "ahb1", 0x60, 8)
145 CCU_GATE(CLK_BUS_MMC1, "bus-mmc1", "ahb1", 0x60, 9)
146 CCU_GATE(CLK_BUS_MMC2, "bus-mmc2", "ahb1", 0x60, 10)
147 CCU_GATE(CLK_BUS_NAND, "bus-nand", "ahb1", 0x60, 13)
148 CCU_GATE(CLK_BUS_DRAM, "bus-dram", "ahb1", 0x60, 14)
149 CCU_GATE(CLK_BUS_EMAC, "bus-emac", "ahb1", 0x60, 17)
150 CCU_GATE(CLK_BUS_HSTIMER, "bus-hstimer", "ahb1", 0x60, 19)
151 CCU_GATE(CLK_BUS_SPI0, "bus-spi0", "ahb1", 0x60, 20)
152 CCU_GATE(CLK_BUS_SPI1, "bus-spi1", "ahb1", 0x60, 21)
153 CCU_GATE(CLK_BUS_OTG, "bus-otg", "ahb1", 0x60, 24)
154 CCU_GATE(CLK_BUS_EHCI0, "bus-ehci0", "ahb2", 0x60, 26)
155 CCU_GATE(CLK_BUS_EHCI1, "bus-ehci1", "ahb2", 0x60, 27)
156 CCU_GATE(CLK_BUS_OHCI0, "bus-ohci0", "ahb2", 0x60, 29)
158 CCU_GATE(CLK_BUS_VE, "bus-ve", "ahb1", 0x64, 0)
159 CCU_GATE(CLK_BUS_TCON0, "bus-tcon0", "ahb1", 0x64, 4)
160 CCU_GATE(CLK_BUS_TCON1, "bus-tcon1", "ahb1", 0x64, 5)
161 CCU_GATE(CLK_BUS_CSI, "bus-csi", "ahb1", 0x64, 8)
162 CCU_GATE(CLK_BUS_HDMI, "bus-hdmi", "ahb1", 0x64, 11)
163 CCU_GATE(CLK_BUS_DE, "bus-de", "ahb1", 0x64, 12)
164 CCU_GATE(CLK_BUS_GPU, "bus-gpu", "ahb1", 0x64, 20)
165 CCU_GATE(CLK_BUS_MSGBOX, "bus-msgbox", "ahb1", 0x64, 21)
166 CCU_GATE(CLK_BUS_SPINLOCK, "bus-spinlock", "ahb1", 0x64, 22)
168 CCU_GATE(CLK_BUS_SPDIF, "bus-spdif", "apb1", 0x68, 1)
169 CCU_GATE(CLK_BUS_PIO, "bus-pio", "apb1", 0x68, 5)
170 CCU_GATE(CLK_BUS_I2S0, "bus-i2s0", "apb1", 0x68, 12)
171 CCU_GATE(CLK_BUS_I2S1, "bus-i2s1", "apb1", 0x68, 13)
172 CCU_GATE(CLK_BUS_I2S2, "bus-i2s2", "apb1", 0x68, 14)
173 CCU_GATE(CLK_BUS_TDM, "bus-tdm", "apb1", 0x68, 15)
175 CCU_GATE(CLK_BUS_I2C0, "bus-i2c0", "apb2", 0x6c, 0)
176 CCU_GATE(CLK_BUS_I2C1, "bus-i2c1", "apb2", 0x6c, 1)
177 CCU_GATE(CLK_BUS_I2C2, "bus-i2c2", "apb2", 0x6c, 2)
178 CCU_GATE(CLK_BUS_UART0, "bus-uart0", "apb2", 0x6c, 16)
179 CCU_GATE(CLK_BUS_UART1, "bus-uart1", "apb2", 0x6c, 17)
180 CCU_GATE(CLK_BUS_UART2, "bus-uart2", "apb2", 0x6c, 18)
181 CCU_GATE(CLK_BUS_UART3, "bus-uart3", "apb2", 0x6c, 19)
182 CCU_GATE(CLK_BUS_UART4, "bus-uart4", "apb2", 0x6c, 20)
184 CCU_GATE(CLK_USB_PHY0, "usb-phy0", "osc24M", 0xcc, 8)
185 CCU_GATE(CLK_USB_PHY1, "usb-phy1", "osc24M", 0xcc, 9)
186 CCU_GATE(CLK_USB_HSIC, "usb-hsic", "pll_hsic", 0xcc, 10)
187 CCU_GATE(CLK_USB_HSIC_12M, "usb-hsic-12M", "osc12M", 0xcc, 11)
188 CCU_GATE(CLK_USB_OHCI0, "usb-ohci0", "osc12M", 0xcc, 16)
190 CCU_GATE(CLK_DRAM_VE, "dram-ve", "dram", 0x100, 0)
191 CCU_GATE(CLK_DRAM_CSI, "dram-csi", "dram", 0x100, 1)
193 CCU_GATE(CLK_CSI_MISC, "csi-misc", "osc24M", 0x130, 16)
194 CCU_GATE(CLK_MIPI_CSI, "mipi-csi", "osc24M", 0x130, 31)
196 CCU_GATE(CLK_AVS, "avs", "osc24M", 0x144, 31)
198 CCU_GATE(CLK_HDMI_SLOW, "hdmi-ddc", "osc24M", 0x154, 31)
201 static const char *osc12m_parents[] = {"osc24M"};
202 FIXED_CLK(osc12m_clk,
203 CLK_OSC_12M, /* id */
204 "osc12M", osc12m_parents, /* name, parents */
210 static const char *pll_c0cpux_parents[] = {"osc24M"};
211 static const char *pll_c1cpux_parents[] = {"osc24M"};
212 NM_CLK(pll_c0cpux_clk,
213 CLK_PLL_C0CPUX, /* id */
214 "pll_c0cpux", pll_c0cpux_parents, /* name, parents */
216 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
217 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
220 AW_CLK_HAS_GATE | AW_CLK_SCALE_CHANGE); /* flags */
221 NM_CLK(pll_c1cpux_clk,
222 CLK_PLL_C1CPUX, /* id */
223 "pll_c1cpux", pll_c1cpux_parents, /* name, parents */
225 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
226 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
229 AW_CLK_HAS_GATE | AW_CLK_SCALE_CHANGE); /* flags */
231 static const char *pll_audio_parents[] = {"osc24M"};
232 NKMP_CLK(pll_audio_clk,
233 CLK_PLL_AUDIO, /* id */
234 "pll_audio", pll_audio_parents, /* name, parents */
236 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
237 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
238 16, 1, 0, 0, /* m factor */
239 18, 1, 0, 0, /* p factor */
242 AW_CLK_HAS_GATE); /* flags */
244 static const char *pll_video0_parents[] = {"osc24M"};
245 NKMP_CLK(pll_video0_clk,
246 CLK_PLL_VIDEO0, /* id */
247 "pll_video0", pll_video0_parents, /* name, parents */
249 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
250 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
251 16, 1, 0, 0, /* m factor */
252 0, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
255 AW_CLK_HAS_GATE); /* flags */
257 static const char *pll_ve_parents[] = {"osc24M"};
260 "pll_ve", pll_ve_parents, /* name, parents */
262 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
263 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
264 16, 1, 0, 0, /* m factor */
265 18, 1, 0, 0, /* p factor */
268 AW_CLK_HAS_GATE); /* flags */
270 static const char *pll_ddr_parents[] = {"osc24M"};
271 NKMP_CLK(pll_ddr_clk,
272 CLK_PLL_DDR, /* id */
273 "pll_ddr", pll_ddr_parents, /* name, parents */
275 8, 5, 0, 0, /* n factor */
276 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
277 16, 1, 0, 0, /* m factor */
278 18, 1, 0, 0, /* p factor */
281 AW_CLK_HAS_GATE); /* flags */
283 static const char *pll_periph_parents[] = {"osc24M"};
284 NKMP_CLK(pll_periph_clk,
285 CLK_PLL_PERIPH, /* id */
286 "pll_periph", pll_periph_parents, /* name, parents */
288 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
289 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
290 16, 1, 1, 0, /* m factor */
291 18, 1, 1, 0, /* p factor */
294 AW_CLK_HAS_GATE); /* flags */
296 static const char *pll_gpu_parents[] = {"osc24M"};
297 NKMP_CLK(pll_gpu_clk,
298 CLK_PLL_GPU, /* id */
299 "pll_gpu", pll_gpu_parents, /* name, parents */
301 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
302 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
303 16, 1, 1, 0, /* m factor */
304 18, 1, 1, 0, /* p factor */
307 AW_CLK_HAS_GATE); /* flags */
309 static const char *pll_hsic_parents[] = {"osc24M"};
310 NKMP_CLK(pll_hsic_clk,
311 CLK_PLL_HSIC, /* id */
312 "pll_hsic", pll_hsic_parents, /* name, parents */
314 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
315 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
316 16, 1, 1, 0, /* m factor */
317 18, 1, 1, 0, /* p factor */
320 AW_CLK_HAS_GATE); /* flags */
322 static const char *pll_de_parents[] = {"osc24M"};
325 "pll_de", pll_de_parents, /* name, parents */
327 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
328 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
329 16, 1, 1, 0, /* m factor */
330 18, 1, 1, 0, /* p factor */
333 AW_CLK_HAS_GATE); /* flags */
335 static const char *pll_video1_parents[] = {"osc24M"};
336 NKMP_CLK(pll_video1_clk,
337 CLK_PLL_VIDEO1, /* id */
338 "pll_video1", pll_video1_parents, /* name, parents */
340 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
341 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
342 16, 1, 1, 0, /* m factor */
343 0, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
346 AW_CLK_HAS_GATE); /* flags */
348 static const char *c0cpux_parents[] = {"osc24M", "pll_c0cpux"};
351 "c0cpux", c0cpux_parents, /* name, parents */
352 0x50, 12, 1); /* offset, shift, width */
354 static const char *c1cpux_parents[] = {"osc24M", "pll_c1cpux"};
357 "c1cpux", c1cpux_parents, /* name, parents */
358 0x50, 28, 1); /* offset, shift, width */
360 static const char *axi0_parents[] = {"c0cpux"};
363 "axi0", axi0_parents, /* name, parents */
365 0, 2, /* shift, width */
366 0, NULL); /* flags, div table */
368 static const char *axi1_parents[] = {"c1cpux"};
371 "axi1", axi1_parents, /* name, parents */
373 16, 2, /* shift, width */
374 0, NULL); /* flags, div table */
376 static const char *ahb1_parents[] = {"osc16M-d512", "osc24M", "pll_periph", "pll_periph"};
377 PREDIV_CLK_WITH_MASK(ahb1_clk,
379 "ahb1", ahb1_parents, /* name, parents */
382 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
383 6, 2, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
384 (2 << 12), (2 << 12)); /* prediv condition */
386 static const char *apb1_parents[] = {"ahb1"};
389 "apb1", apb1_parents, /* name, parents */
391 8, 2, /* shift, width */
392 0, NULL); /* flags, div table */
394 static const char *apb2_parents[] = {"osc16M-d512", "osc24M", "pll_periph", "pll_periph"};
397 "apb2", apb2_parents, /* name, parents */
399 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
400 0, 5, 0, 0, /* m factor */
405 static const char *ahb2_parents[] = {"ahb1", "pll_periph"};
408 "ahb2", ahb2_parents, /* name, parents */
411 0, 0, 1, AW_CLK_FACTOR_FIXED, /* div (fake) */
412 0, 0, 2, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */
413 0, 2, 1); /* prediv cond */
415 /* Actually has a divider, but we don't use it */
416 static const char *cci400_parents[] = {"osc24M", "pll_periph", "pll_hsic"};
419 "cci400", cci400_parents, /* name, parents */
420 0x78, 24, 2); /* offset, shift, width */
422 static const char *mod_parents[] = {"osc24M", "pll_periph"};
426 "nand", mod_parents, /* name, parents */
428 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
429 0, 4, 0, 0, /* m factor */
432 AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
436 "mmc0", mod_parents, /* name, parents */
438 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
439 0, 4, 0, 0, /* m factor */
442 AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
446 "mmc1", mod_parents, /* name, parents */
448 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
449 0, 4, 0, 0, /* m factor */
452 AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
456 "mmc2", mod_parents, /* name, parents */
458 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
459 0, 4, 0, 0, /* m factor */
462 AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
467 "ss", mod_parents, /* name, parents */
469 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
470 0, 4, 0, 0, /* m factor */
473 AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
477 "spi0", mod_parents, /* name, parents */
479 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
480 0, 4, 0, 0, /* m factor */
483 AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
486 "spi1", mod_parents, /* name, parents */
488 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
489 0, 4, 0, 0, /* m factor */
492 AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
494 static const char *daudio_parents[] = {"pll_audio"};
497 "i2s0", daudio_parents, /* name, parents */
499 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
500 0, 4, 0, 0, /* m factor */
506 "i2s1", daudio_parents, /* name, parents */
508 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
509 0, 4, 0, 0, /* m factor */
515 "i2s2", daudio_parents, /* name, parents */
517 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
518 0, 4, 0, 0, /* m factor */
523 static const char *tdm_parents[] = {"pll_audio"};
526 "tdm", tdm_parents, /* name, parents */
528 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
529 0, 4, 0, 0, /* m factor */
534 static const char *spdif_parents[] = {"pll_audio"};
537 "spdif", spdif_parents, /* name, parents */
539 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
540 0, 4, 0, 0, /* m factor */
545 static const char *dram_parents[] = {"pll_ddr"};
548 "dram", dram_parents, /* name, parents */
550 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
551 0, 4, 0, 0, /* m factor */
556 static const char *tcon0_parents[] = {"pll_video0"};
559 "tcon0", tcon0_parents, /* name, parents */
560 0x118, 24, 2); /* offset, shift, width */
562 static const char *tcon1_parents[] = {"pll_video1"};
565 "tcon1", tcon1_parents, /* name, parents */
567 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
568 0, 4, 0, 0, /* m factor */
573 static const char *csi_mclk_parents[] = {"pll_de", "osc24M"};
575 CLK_CSI_MCLK, /* id */
576 "csi-mclk", csi_mclk_parents, /* name, parents */
578 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
579 0, 4, 0, 0, /* m factor */
582 AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
584 static const char *csi_sclk_parents[] = {"pll_periph", "pll_ve"};
586 CLK_CSI_SCLK, /* id */
587 "csi-sclk", csi_sclk_parents, /* name, parents */
589 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
590 16, 4, 0, 0, /* m factor */
593 AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
595 static const char *ve_parents[] = {"pll_ve"};
598 "ve", ve_parents, /* name, parents */
600 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
601 16, 3, 0, 0, /* m factor */
606 static const char *hdmi_parents[] = {"pll_video1"};
609 "hdmi", hdmi_parents, /* name, parents */
611 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
612 0, 4, 0, 0, /* m factor */
615 AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
617 static const char *mbus_parents[] = {"osc24M", "pll_periph", "pll_ddr"};
620 "mbus", mbus_parents, /* name, parents */
622 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
623 0, 3, 0, 0, /* m factor */
626 AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
628 static const char *mipi_dsi0_parents[] = {"pll_video0"};
629 NM_CLK(mipi_dsi0_clk,
630 CLK_MIPI_DSI0, /* id */
631 "mipi-dsi0", mipi_dsi0_parents, /* name, parents */
633 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
634 0, 4, 0, 0, /* m factor */
637 AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
639 static const char *mipi_dsi1_parents[] = {"osc24M", "pll_video0"};
640 NM_CLK(mipi_dsi1_clk,
641 CLK_MIPI_DSI1, /* id */
642 "mipi-dsi1", mipi_dsi1_parents, /* name, parents */
644 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
645 0, 4, 0, 0, /* m factor */
648 AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
650 static const char *gpu_core_parents[] = {"pll_gpu"};
652 CLK_GPU_CORE, /* id */
653 "gpu-core", gpu_core_parents, /* name, parents */
655 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
656 0, 3, 0, 0, /* m factor */
661 static const char *gpu_memory_parents[] = {"pll_gpu", "pll_periph"};
662 NM_CLK(gpu_memory_clk,
663 CLK_GPU_MEMORY, /* id */
664 "gpu-memory", gpu_memory_parents, /* name, parents */
666 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
667 0, 3, 0, 0, /* m factor */
670 AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
672 static const char *gpu_hyd_parents[] = {"pll_gpu"};
674 CLK_GPU_HYD, /* id */
675 "gpu-hyd", gpu_hyd_parents, /* name, parents */
677 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
678 0, 3, 0, 0, /* m factor */
684 static struct aw_clk_nkmp_def *nkmp_clks[] = {
696 static struct aw_clk_nm_def *nm_clks[] = {
726 static struct aw_clk_prediv_mux_def *prediv_mux_clks[] = {
731 static struct clk_mux_def *mux_clks[] = {
738 static struct clk_div_def *div_clks[] = {
744 static struct clk_fixed_def *fixed_factor_clks[] = {
748 static struct aw_clk_init init_clks[] = {
749 {"ahb1", "pll_periph", 0, false},
750 {"ahb2", "ahb1", 0, false},
751 {"dram", "pll_ddr", 0, false},
755 ccu_a83t_register_clocks(struct aw_ccung_softc *sc)
759 sc->resets = a83t_ccu_resets;
760 sc->nresets = nitems(a83t_ccu_resets);
761 sc->gates = a83t_ccu_gates;
762 sc->ngates = nitems(a83t_ccu_gates);
763 sc->clk_init = init_clks;
764 sc->n_clk_init = nitems(init_clks);
766 for (i = 0; i < nitems(nkmp_clks); i++)
767 aw_clk_nkmp_register(sc->clkdom, nkmp_clks[i]);
768 for (i = 0; i < nitems(nm_clks); i++)
769 aw_clk_nm_register(sc->clkdom, nm_clks[i]);
770 for (i = 0; i < nitems(prediv_mux_clks); i++)
771 aw_clk_prediv_mux_register(sc->clkdom, prediv_mux_clks[i]);
773 for (i = 0; i < nitems(mux_clks); i++)
774 clknode_mux_register(sc->clkdom, mux_clks[i]);
775 for (i = 0; i < nitems(div_clks); i++)
776 clknode_div_register(sc->clkdom, div_clks[i]);
777 for (i = 0; i < nitems(fixed_factor_clks); i++)
778 clknode_fixed_register(sc->clkdom, fixed_factor_clks[i]);