-/* $OpenBSD: sxiccmu.c,v 1.32 2023/08/15 08:27:30 miod Exp $ */
+/* $OpenBSD: sxiccmu.c,v 1.33 2024/01/26 17:50:00 kettenis Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2013 Artturi Alm
int sxiccmu_a64_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t);
uint32_t sxiccmu_a80_get_frequency(struct sxiccmu_softc *, uint32_t);
int sxiccmu_a80_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t);
+uint32_t sxiccmu_d1_get_frequency(struct sxiccmu_softc *, uint32_t);
+int sxiccmu_d1_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t);
uint32_t sxiccmu_h3_get_frequency(struct sxiccmu_softc *, uint32_t);
int sxiccmu_h3_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t);
uint32_t sxiccmu_h3_r_get_frequency(struct sxiccmu_softc *, uint32_t);
OF_is_compatible(node, "allwinner,sun9i-a80-ccu") ||
OF_is_compatible(node, "allwinner,sun9i-a80-usb-clks") ||
OF_is_compatible(node, "allwinner,sun9i-a80-mmc-config-clk") ||
+ OF_is_compatible(node, "allwinner,sun20i-d1-ccu") ||
OF_is_compatible(node, "allwinner,sun50i-a64-ccu") ||
OF_is_compatible(node, "allwinner,sun50i-a64-r-ccu") ||
OF_is_compatible(node, "allwinner,sun50i-h5-ccu") ||
sc->sc_nresets = nitems(sun9i_a80_mmc_resets);
sc->sc_get_frequency = sxiccmu_nop_get_frequency;
sc->sc_set_frequency = sxiccmu_nop_set_frequency;
+ } else if (OF_is_compatible(node, "allwinner,sun20i-d1-ccu")) {
+ KASSERT(faa->fa_nreg > 0);
+ sc->sc_gates = sun20i_d1_gates;
+ sc->sc_ngates = nitems(sun20i_d1_gates);
+ sc->sc_resets = sun20i_d1_resets;
+ sc->sc_nresets = nitems(sun20i_d1_resets);
+ sc->sc_get_frequency = sxiccmu_d1_get_frequency;
+ sc->sc_set_frequency = sxiccmu_d1_set_frequency;
} else if (OF_is_compatible(node, "allwinner,sun50i-a64-ccu")) {
KASSERT(faa->fa_nreg > 0);
sc->sc_gates = sun50i_a64_gates;
return 0;
}
+/* Allwinner D1 */
+
+uint32_t
+sxiccmu_d1_get_frequency(struct sxiccmu_softc *sc, uint32_t idx)
+{
+ switch (idx) {
+ case D1_CLK_APB1:
+ /* XXX Controlled by a MUX. */
+ return 24000000;
+ }
+
+ printf("%s: 0x%08x\n", __func__, idx);
+ return 0;
+}
+
/* Allwinner H3/H5 */
#define H3_PLL_CPUX_CTRL_REG 0x0000
#define H3_PLL_CPUX_ENABLE (1U << 31)
return -1;
}
+int
+sxiccmu_d1_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq)
+{
+ printf("%s: 0x%08x\n", __func__, idx);
+ return -1;
+}
+
int
sxiccmu_h3_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq)
{
{ 0x000c, 16 },
};
+/* D1 */
+
+#define D1_CLK_APB1 25
+#define D1_CLK_BUS_UART0 62
+#define D1_CLK_BUS_UART1 63
+#define D1_CLK_BUS_UART2 64
+#define D1_CLK_BUS_UART3 65
+#define D1_CLK_BUS_UART4 66
+#define D1_CLK_BUS_UART5 67
+#define D1_CLK_USB_OHCI0 97
+#define D1_CLK_USB_OHCI1 98
+#define D1_CLK_BUS_OHCI0 99
+#define D1_CLK_BUS_OHCI1 100
+#define D1_CLK_BUS_EHCI0 101
+#define D1_CLK_BUS_EHCI1 102
+
+const struct sxiccmu_ccu_bit sun20i_d1_gates[] = {
+ [D1_CLK_BUS_UART0] = { 0x090c, 0, D1_CLK_APB1 },
+ [D1_CLK_BUS_UART1] = { 0x090c, 1, D1_CLK_APB1 },
+ [D1_CLK_BUS_UART2] = { 0x090c, 2, D1_CLK_APB1 },
+ [D1_CLK_BUS_UART3] = { 0x090c, 3, D1_CLK_APB1 },
+ [D1_CLK_BUS_UART4] = { 0x090c, 4, D1_CLK_APB1 },
+ [D1_CLK_BUS_UART5] = { 0x090c, 5, D1_CLK_APB1 },
+ [D1_CLK_USB_OHCI0] = { 0x0a70, 31 },
+ [D1_CLK_USB_OHCI1] = { 0x0a74, 31 },
+ [D1_CLK_BUS_OHCI0] = { 0x0a8c, 0 },
+ [D1_CLK_BUS_OHCI1] = { 0x0a8c, 1 },
+ [D1_CLK_BUS_EHCI0] = { 0x0a8c, 4 },
+ [D1_CLK_BUS_EHCI1] = { 0x0a8c, 5 },
+};
+
/* H3/H5 */
#define H3_CLK_PLL_CPUX 0
{ 0x000c, 18 },
};
+/* D1 */
+
+#define D1_RST_BUS_UART0 18
+#define D1_RST_BUS_UART1 19
+#define D1_RST_BUS_UART2 20
+#define D1_RST_BUS_UART3 21
+#define D1_RST_BUS_UART4 22
+#define D1_RST_BUS_UART5 23
+#define D1_RST_USB_PHY0 40
+#define D1_RST_USB_PHY1 41
+#define D1_RST_BUS_OHCI0 42
+#define D1_RST_BUS_OHCI1 43
+#define D1_RST_BUS_EHCI0 44
+#define D1_RST_BUS_EHCI1 45
+
+const struct sxiccmu_ccu_bit sun20i_d1_resets[] = {
+ [D1_RST_BUS_UART0] = { 0x090c, 16 },
+ [D1_RST_BUS_UART1] = { 0x090c, 17 },
+ [D1_RST_BUS_UART2] = { 0x090c, 18 },
+ [D1_RST_BUS_UART3] = { 0x090c, 19 },
+ [D1_RST_BUS_UART4] = { 0x090c, 20 },
+ [D1_RST_BUS_UART5] = { 0x090c, 21 },
+ [D1_RST_USB_PHY0] = { 0x0a70, 30 },
+ [D1_RST_USB_PHY1] = { 0x0a74, 30 },
+ [D1_RST_BUS_OHCI0] = { 0x0a8c, 16 },
+ [D1_RST_BUS_OHCI1] = { 0x0a8c, 17 },
+ [D1_RST_BUS_EHCI0] = { 0x0a8c, 20 },
+ [D1_RST_BUS_EHCI1] = { 0x0a8c, 21 },
+};
+
/* H3/H5 */
#define H3_RST_USB_PHY0 0