aboutsummaryrefslogtreecommitdiff
path: root/sys/arm/allwinner
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arm/allwinner')
-rw-r--r--sys/arm/allwinner/a10/a10_intc.c4
-rw-r--r--sys/arm/allwinner/a10/a10_padconf.c3
-rw-r--r--sys/arm/allwinner/a10/files.a103
-rw-r--r--sys/arm/allwinner/a10_ahci.c7
-rw-r--r--sys/arm/allwinner/a10_codec.c20
-rw-r--r--sys/arm/allwinner/a10_dmac.c5
-rw-r--r--sys/arm/allwinner/a10_dmac.h2
-rw-r--r--sys/arm/allwinner/a10_fb.c660
-rw-r--r--sys/arm/allwinner/a10_hdmi.c723
-rw-r--r--sys/arm/allwinner/a10_hdmiaudio.c435
-rw-r--r--sys/arm/allwinner/a10_sramc.c7
-rw-r--r--sys/arm/allwinner/a10_sramc.h4
-rw-r--r--sys/arm/allwinner/a13/a13_padconf.c3
-rw-r--r--sys/arm/allwinner/a13/files.a133
-rw-r--r--sys/arm/allwinner/a20/a20_cpu_cfg.c5
-rw-r--r--sys/arm/allwinner/a20/a20_cpu_cfg.h4
-rw-r--r--sys/arm/allwinner/a20/a20_padconf.c3
-rw-r--r--sys/arm/allwinner/a20/files.a203
-rw-r--r--sys/arm/allwinner/a31/a31_padconf.c3
-rw-r--r--sys/arm/allwinner/a31/a31_r_padconf.c3
-rw-r--r--sys/arm/allwinner/a31/a31s_padconf.c3
-rw-r--r--sys/arm/allwinner/a31/files.a313
-rw-r--r--sys/arm/allwinner/a31_dmac.c7
-rw-r--r--sys/arm/allwinner/a33/a33_padconf.c3
-rw-r--r--sys/arm/allwinner/a33/files.a331
-rw-r--r--sys/arm/allwinner/a33_codec.c11
-rw-r--r--sys/arm/allwinner/a64/a64_padconf.c5
-rw-r--r--sys/arm/allwinner/a64/a64_r_padconf.c5
-rw-r--r--sys/arm/allwinner/a64/sun50i_a64_acodec.c13
-rw-r--r--sys/arm/allwinner/a83t/a83t_padconf.c5
-rw-r--r--sys/arm/allwinner/a83t/a83t_r_padconf.c5
-rw-r--r--sys/arm/allwinner/a83t/files.a83t5
-rw-r--r--sys/arm/allwinner/allwinner_pinctrl.h6
-rw-r--r--sys/arm/allwinner/aw_ccu.c252
-rw-r--r--sys/arm/allwinner/aw_cir.c7
-rw-r--r--sys/arm/allwinner/aw_dwc3.c144
-rw-r--r--sys/arm/allwinner/aw_gmacclk.c9
-rw-r--r--sys/arm/allwinner/aw_gpio.c168
-rw-r--r--sys/arm/allwinner/aw_i2s.c11
-rw-r--r--sys/arm/allwinner/aw_if_dwc.c146
-rw-r--r--sys/arm/allwinner/aw_machdep.c3
-rw-r--r--sys/arm/allwinner/aw_machdep.h2
-rw-r--r--sys/arm/allwinner/aw_mmc.c65
-rw-r--r--sys/arm/allwinner/aw_mmc.h4
-rw-r--r--sys/arm/allwinner/aw_mp.c4
-rw-r--r--sys/arm/allwinner/aw_mp.h2
-rw-r--r--sys/arm/allwinner/aw_nmi.c2
-rw-r--r--sys/arm/allwinner/aw_pwm.c403
-rw-r--r--sys/arm/allwinner/aw_r_intc.c4
-rw-r--r--sys/arm/allwinner/aw_reset.c7
-rw-r--r--sys/arm/allwinner/aw_rsb.c13
-rw-r--r--sys/arm/allwinner/aw_rtc.c34
-rw-r--r--sys/arm/allwinner/aw_sid.c31
-rw-r--r--sys/arm/allwinner/aw_sid.h2
-rw-r--r--sys/arm/allwinner/aw_spi.c615
-rw-r--r--sys/arm/allwinner/aw_syscon.c10
-rw-r--r--sys/arm/allwinner/aw_thermal.c11
-rw-r--r--sys/arm/allwinner/aw_timer.c (renamed from sys/arm/allwinner/a10_timer.c)226
-rw-r--r--sys/arm/allwinner/aw_ts.c3
-rw-r--r--sys/arm/allwinner/aw_usb3phy.c10
-rw-r--r--sys/arm/allwinner/aw_usbphy.c22
-rw-r--r--sys/arm/allwinner/aw_wdog.c5
-rw-r--r--sys/arm/allwinner/aw_wdog.h2
-rw-r--r--sys/arm/allwinner/axp209.c4
-rw-r--r--sys/arm/allwinner/axp209reg.h2
-rw-r--r--sys/arm/allwinner/axp81x.c7
-rw-r--r--sys/arm/allwinner/clkng/aw_ccung.c364
-rw-r--r--sys/arm/allwinner/clkng/aw_ccung.h110
-rw-r--r--sys/arm/allwinner/clkng/aw_clk.h604
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_frac.c399
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_frac.h55
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_m.c289
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_m.h48
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_mipi.c294
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_mipi.h53
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_nkmp.c412
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_nkmp.h56
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_nm.c357
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_nm.h52
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_nmm.c282
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_nmm.h52
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_np.c264
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_np.h51
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_prediv_mux.c183
-rw-r--r--sys/arm/allwinner/clkng/aw_clk_prediv_mux.h48
-rw-r--r--sys/arm/allwinner/clkng/ccu_a10.c623
-rw-r--r--sys/arm/allwinner/clkng/ccu_a13.c568
-rw-r--r--sys/arm/allwinner/clkng/ccu_a31.c978
-rw-r--r--sys/arm/allwinner/clkng/ccu_a64.c841
-rw-r--r--sys/arm/allwinner/clkng/ccu_a83t.c786
-rw-r--r--sys/arm/allwinner/clkng/ccu_de2.c238
-rw-r--r--sys/arm/allwinner/clkng/ccu_h3.c792
-rw-r--r--sys/arm/allwinner/clkng/ccu_h6.c499
-rw-r--r--sys/arm/allwinner/clkng/ccu_h6_r.c170
-rw-r--r--sys/arm/allwinner/clkng/ccu_sun8i_r.c261
-rw-r--r--sys/arm/allwinner/files.allwinner27
-rw-r--r--sys/arm/allwinner/files.allwinner_up3
-rw-r--r--sys/arm/allwinner/h3/files.h35
-rw-r--r--sys/arm/allwinner/h3/h3_padconf.c3
-rw-r--r--sys/arm/allwinner/h3/h3_r_padconf.c3
-rw-r--r--sys/arm/allwinner/h6/h6_padconf.c3
-rw-r--r--sys/arm/allwinner/h6/h6_r_padconf.c3
-rw-r--r--sys/arm/allwinner/if_awg.c19
-rw-r--r--sys/arm/allwinner/if_awgreg.h2
-rw-r--r--sys/arm/allwinner/if_emac.c147
-rw-r--r--sys/arm/allwinner/if_emacreg.h4
-rw-r--r--sys/arm/allwinner/std.allwinner1
-rw-r--r--sys/arm/allwinner/std.allwinner_up1
-rw-r--r--sys/arm/allwinner/sunxi_dma_if.m1
109 files changed, 508 insertions, 13645 deletions
diff --git a/sys/arm/allwinner/a10/a10_intc.c b/sys/arm/allwinner/a10/a10_intc.c
index 5a36377b8089..0bac9edbfd08 100644
--- a/sys/arm/allwinner/a10/a10_intc.c
+++ b/sys/arm/allwinner/a10/a10_intc.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "opt_platform.h"
#include <sys/param.h>
@@ -238,7 +236,7 @@ a10_intr_pic_attach(struct a10_aintc_softc *sc)
if (pic == NULL)
return (ENXIO);
- return (intr_pic_claim_root(sc->sc_dev, xref, a10_intr, sc, 0));
+ return (intr_pic_claim_root(sc->sc_dev, xref, a10_intr, sc, INTR_ROOT_IRQ));
}
static void
diff --git a/sys/arm/allwinner/a10/a10_padconf.c b/sys/arm/allwinner/a10/a10_padconf.c
index c9bf62e002ab..b5ad0cd0e771 100644
--- a/sys/arm/allwinner/a10/a10_padconf.c
+++ b/sys/arm/allwinner/a10/a10_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a10/files.a10 b/sys/arm/allwinner/a10/files.a10
index 5fe53134f44c..f21b937b1b45 100644
--- a/sys/arm/allwinner/a10/files.a10
+++ b/sys/arm/allwinner/a10/files.a10
@@ -1,5 +1,4 @@
-# $FreeBSD$
arm/allwinner/a10/a10_intc.c standard
arm/allwinner/a10/a10_padconf.c standard
-arm/allwinner/clkng/ccu_a10.c standard
+dev/clk/allwinner/ccu_a10.c standard
diff --git a/sys/arm/allwinner/a10_ahci.c b/sys/arm/allwinner/a10_ahci.c
index ac35a033f76c..b7aa991b6543 100644
--- a/sys/arm/allwinner/a10_ahci.c
+++ b/sys/arm/allwinner/a10_ahci.c
@@ -31,9 +31,6 @@
#include "opt_bus.h"
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -46,8 +43,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ahci/ahci.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/regulator/regulator.h>
+#include <dev/clk/clk.h>
+#include <dev/regulator/regulator.h>
/*
* Allwinner a1x/a2x/a8x SATA attachment. This is just the AHCI register
diff --git a/sys/arm/allwinner/a10_codec.c b/sys/arm/allwinner/a10_codec.c
index c0f0862cadf4..12d389d24243 100644
--- a/sys/arm/allwinner/a10_codec.c
+++ b/sys/arm/allwinner/a10_codec.c
@@ -22,17 +22,12 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Allwinner A10/A20 and H3 Audio Codec
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -45,15 +40,14 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <dev/sound/pcm/sound.h>
-#include <dev/sound/chip.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/gpio/gpiobusvar.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
#include "sunxi_dma_if.h"
#include "mixer_if.h"
@@ -1171,16 +1165,16 @@ a10codec_attach(device_t dev)
pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE);
- if (pcm_register(dev, sc, 1, 1)) {
- device_printf(dev, "pcm_register failed\n");
- goto fail;
- }
+ pcm_init(dev, sc);
pcm_addchan(dev, PCMDIR_PLAY, &a10codec_chan_class, sc);
pcm_addchan(dev, PCMDIR_REC, &a10codec_chan_class, sc);
snprintf(status, SND_STATUSLEN, "at %s", ofw_bus_get_name(dev));
- pcm_setstatus(dev, status);
+ if (pcm_register(dev, status)) {
+ device_printf(dev, "pcm_register failed\n");
+ goto fail;
+ }
return (0);
diff --git a/sys/arm/allwinner/a10_dmac.c b/sys/arm/allwinner/a10_dmac.c
index 0ecd68917d8a..e711c5268b2d 100644
--- a/sys/arm/allwinner/a10_dmac.c
+++ b/sys/arm/allwinner/a10_dmac.c
@@ -29,9 +29,6 @@
* Allwinner A10/A20 DMA controller
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -48,7 +45,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <arm/allwinner/a10_dmac.h>
-#include <dev/extres/clk/clk.h>
+#include <dev/clk/clk.h>
#include "sunxi_dma_if.h"
diff --git a/sys/arm/allwinner/a10_dmac.h b/sys/arm/allwinner/a10_dmac.h
index 7b337b35bec9..42c0c54179c6 100644
--- a/sys/arm/allwinner/a10_dmac.h
+++ b/sys/arm/allwinner/a10_dmac.h
@@ -22,8 +22,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _A10_DMAC_H_
diff --git a/sys/arm/allwinner/a10_fb.c b/sys/arm/allwinner/a10_fb.c
deleted file mode 100644
index 387d5daa10c1..000000000000
--- a/sys/arm/allwinner/a10_fb.c
+++ /dev/null
@@ -1,660 +0,0 @@
-/*-
- * Copyright (c) 2016 Jared McNeill <jmcneill@invisible.ca>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * Allwinner A10/A20 Framebuffer
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/condvar.h>
-#include <sys/eventhandler.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/fbio.h>
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_kern.h>
-#include <vm/pmap.h>
-
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/videomode/videomode.h>
-#include <dev/videomode/edidvar.h>
-
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-
-#include "fb_if.h"
-#include "hdmi_if.h"
-
-#define FB_DEFAULT_W 800
-#define FB_DEFAULT_H 600
-#define FB_DEFAULT_REF 60
-#define FB_BPP 32
-#define FB_ALIGN 0x1000
-
-#define HDMI_ENABLE_DELAY 20000
-#define DEBE_FREQ 300000000
-
-#define DOT_CLOCK_TO_HZ(c) ((c) * 1000)
-
-/* Display backend */
-#define DEBE_REG_START 0x800
-#define DEBE_REG_END 0x1000
-#define DEBE_REG_WIDTH 4
-#define DEBE_MODCTL 0x800
-#define MODCTL_ITLMOD_EN (1 << 28)
-#define MODCTL_OUT_SEL_MASK (0x7 << 20)
-#define MODCTL_OUT_SEL(sel) ((sel) << 20)
-#define OUT_SEL_LCD 0
-#define MODCTL_LAY0_EN (1 << 8)
-#define MODCTL_START_CTL (1 << 1)
-#define MODCTL_EN (1 << 0)
-#define DEBE_DISSIZE 0x808
-#define DIS_HEIGHT(h) (((h) - 1) << 16)
-#define DIS_WIDTH(w) (((w) - 1) << 0)
-#define DEBE_LAYSIZE0 0x810
-#define LAY_HEIGHT(h) (((h) - 1) << 16)
-#define LAY_WIDTH(w) (((w) - 1) << 0)
-#define DEBE_LAYCOOR0 0x820
-#define LAY_XCOOR(x) ((x) << 16)
-#define LAY_YCOOR(y) ((y) << 0)
-#define DEBE_LAYLINEWIDTH0 0x840
-#define DEBE_LAYFB_L32ADD0 0x850
-#define LAYFB_L32ADD(pa) ((pa) << 3)
-#define DEBE_LAYFB_H4ADD 0x860
-#define LAY0FB_H4ADD(pa) ((pa) >> 29)
-#define DEBE_REGBUFFCTL 0x870
-#define REGBUFFCTL_LOAD (1 << 0)
-#define DEBE_ATTCTL1 0x8a0
-#define ATTCTL1_FBFMT(fmt) ((fmt) << 8)
-#define FBFMT_XRGB8888 9
-#define ATTCTL1_FBPS(ps) ((ps) << 0)
-#define FBPS_32BPP_ARGB 0
-
-/* Timing controller */
-#define TCON_GCTL 0x000
-#define GCTL_TCON_EN (1 << 31)
-#define GCTL_IO_MAP_SEL_TCON1 (1 << 0)
-#define TCON_GINT1 0x008
-#define GINT1_TCON1_LINENO(n) (((n) + 2) << 0)
-#define TCON0_DCLK 0x044
-#define DCLK_EN 0xf0000000
-#define TCON1_CTL 0x090
-#define TCON1_EN (1 << 31)
-#define INTERLACE_EN (1 << 20)
-#define TCON1_SRC_SEL(src) ((src) << 0)
-#define TCON1_SRC_CH1 0
-#define TCON1_SRC_CH2 1
-#define TCON1_SRC_BLUE 2
-#define TCON1_START_DELAY(sd) ((sd) << 4)
-#define TCON1_BASIC0 0x094
-#define TCON1_BASIC1 0x098
-#define TCON1_BASIC2 0x09c
-#define TCON1_BASIC3 0x0a0
-#define TCON1_BASIC4 0x0a4
-#define TCON1_BASIC5 0x0a8
-#define BASIC_X(x) (((x) - 1) << 16)
-#define BASIC_Y(y) (((y) - 1) << 0)
-#define BASIC3_HT(ht) (((ht) - 1) << 16)
-#define BASIC3_HBP(hbp) (((hbp) - 1) << 0)
-#define BASIC4_VT(vt) ((vt) << 16)
-#define BASIC4_VBP(vbp) (((vbp) - 1) << 0)
-#define BASIC5_HSPW(hspw) (((hspw) - 1) << 16)
-#define BASIC5_VSPW(vspw) (((vspw) - 1) << 0)
-#define TCON1_IO_POL 0x0f0
-#define IO_POL_IO2_INV (1 << 26)
-#define IO_POL_PHSYNC (1 << 25)
-#define IO_POL_PVSYNC (1 << 24)
-#define TCON1_IO_TRI 0x0f4
-#define IO0_OUTPUT_TRI_EN (1 << 24)
-#define IO1_OUTPUT_TRI_EN (1 << 25)
-#define IO_TRI_MASK 0xffffffff
-#define START_DELAY(vbl) (MIN(32, (vbl)) - 2)
-#define VBLANK_LEN(vt, vd, i) ((((vt) << (i)) >> 1) - (vd) - 2)
-#define VTOTAL(vt) ((vt) * 2)
-#define DIVIDE(x, y) (((x) + ((y) / 2)) / (y))
-
-struct a10fb_softc {
- device_t dev;
- device_t fbdev;
- struct resource *res[2];
-
- /* Framebuffer */
- struct fb_info info;
- size_t fbsize;
- bus_addr_t paddr;
- vm_offset_t vaddr;
-
- /* HDMI */
- eventhandler_tag hdmi_evh;
-};
-
-static struct resource_spec a10fb_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* DEBE */
- { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* TCON */
- { -1, 0 }
-};
-
-#define DEBE_READ(sc, reg) bus_read_4((sc)->res[0], (reg))
-#define DEBE_WRITE(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val))
-
-#define TCON_READ(sc, reg) bus_read_4((sc)->res[1], (reg))
-#define TCON_WRITE(sc, reg, val) bus_write_4((sc)->res[1], (reg), (val))
-
-static int
-a10fb_allocfb(struct a10fb_softc *sc)
-{
- sc->vaddr = kmem_alloc_contig(sc->fbsize, M_NOWAIT | M_ZERO, 0, ~0,
- FB_ALIGN, 0, VM_MEMATTR_WRITE_COMBINING);
- if (sc->vaddr == 0) {
- device_printf(sc->dev, "failed to allocate FB memory\n");
- return (ENOMEM);
- }
- sc->paddr = pmap_kextract(sc->vaddr);
-
- return (0);
-}
-
-static void
-a10fb_freefb(struct a10fb_softc *sc)
-{
- kmem_free(sc->vaddr, sc->fbsize);
-}
-
-static int
-a10fb_setup_debe(struct a10fb_softc *sc, const struct videomode *mode)
-{
- int width, height, interlace, reg;
- clk_t clk_ahb, clk_dram, clk_debe;
- hwreset_t rst;
- uint32_t val;
- int error;
-
- interlace = !!(mode->flags & VID_INTERLACE);
- width = mode->hdisplay;
- height = mode->vdisplay << interlace;
-
- /* Leave reset */
- error = hwreset_get_by_ofw_name(sc->dev, 0, "de_be", &rst);
- if (error != 0) {
- device_printf(sc->dev, "cannot find reset 'de_be'\n");
- return (error);
- }
- error = hwreset_deassert(rst);
- if (error != 0) {
- device_printf(sc->dev, "couldn't de-assert reset 'de_be'\n");
- return (error);
- }
- /* Gating AHB clock for BE */
- error = clk_get_by_ofw_name(sc->dev, 0, "ahb_de_be", &clk_ahb);
- if (error != 0) {
- device_printf(sc->dev, "cannot find clk 'ahb_de_be'\n");
- return (error);
- }
- error = clk_enable(clk_ahb);
- if (error != 0) {
- device_printf(sc->dev, "cannot enable clk 'ahb_de_be'\n");
- return (error);
- }
- /* Enable DRAM clock to BE */
- error = clk_get_by_ofw_name(sc->dev, 0, "dram_de_be", &clk_dram);
- if (error != 0) {
- device_printf(sc->dev, "cannot find clk 'dram_de_be'\n");
- return (error);
- }
- error = clk_enable(clk_dram);
- if (error != 0) {
- device_printf(sc->dev, "cannot enable clk 'dram_de_be'\n");
- return (error);
- }
- /* Set BE clock to 300MHz and enable */
- error = clk_get_by_ofw_name(sc->dev, 0, "de_be", &clk_debe);
- if (error != 0) {
- device_printf(sc->dev, "cannot find clk 'de_be'\n");
- return (error);
- }
- error = clk_set_freq(clk_debe, DEBE_FREQ, CLK_SET_ROUND_DOWN);
- if (error != 0) {
- device_printf(sc->dev, "cannot set 'de_be' frequency\n");
- return (error);
- }
- error = clk_enable(clk_debe);
- if (error != 0) {
- device_printf(sc->dev, "cannot enable clk 'de_be'\n");
- return (error);
- }
-
- /* Initialize all registers to 0 */
- for (reg = DEBE_REG_START; reg < DEBE_REG_END; reg += DEBE_REG_WIDTH)
- DEBE_WRITE(sc, reg, 0);
-
- /* Enable display backend */
- DEBE_WRITE(sc, DEBE_MODCTL, MODCTL_EN);
-
- /* Set display size */
- DEBE_WRITE(sc, DEBE_DISSIZE, DIS_HEIGHT(height) | DIS_WIDTH(width));
-
- /* Set layer 0 size, position, and stride */
- DEBE_WRITE(sc, DEBE_LAYSIZE0, LAY_HEIGHT(height) | LAY_WIDTH(width));
- DEBE_WRITE(sc, DEBE_LAYCOOR0, LAY_XCOOR(0) | LAY_YCOOR(0));
- DEBE_WRITE(sc, DEBE_LAYLINEWIDTH0, width * FB_BPP);
-
- /* Point layer 0 to FB memory */
- DEBE_WRITE(sc, DEBE_LAYFB_L32ADD0, LAYFB_L32ADD(sc->paddr));
- DEBE_WRITE(sc, DEBE_LAYFB_H4ADD, LAY0FB_H4ADD(sc->paddr));
-
- /* Set backend format and pixel sequence */
- DEBE_WRITE(sc, DEBE_ATTCTL1, ATTCTL1_FBFMT(FBFMT_XRGB8888) |
- ATTCTL1_FBPS(FBPS_32BPP_ARGB));
-
- /* Enable layer 0, output to LCD, setup interlace */
- val = DEBE_READ(sc, DEBE_MODCTL);
- val |= MODCTL_LAY0_EN;
- val &= ~MODCTL_OUT_SEL_MASK;
- val |= MODCTL_OUT_SEL(OUT_SEL_LCD);
- if (interlace)
- val |= MODCTL_ITLMOD_EN;
- else
- val &= ~MODCTL_ITLMOD_EN;
- DEBE_WRITE(sc, DEBE_MODCTL, val);
-
- /* Commit settings */
- DEBE_WRITE(sc, DEBE_REGBUFFCTL, REGBUFFCTL_LOAD);
-
- /* Start DEBE */
- val = DEBE_READ(sc, DEBE_MODCTL);
- val |= MODCTL_START_CTL;
- DEBE_WRITE(sc, DEBE_MODCTL, val);
-
- return (0);
-}
-
-static int
-a10fb_setup_pll(struct a10fb_softc *sc, uint64_t freq)
-{
- clk_t clk_sclk1, clk_sclk2;
- int error;
-
- error = clk_get_by_ofw_name(sc->dev, 0, "lcd_ch1_sclk1", &clk_sclk1);
- if (error != 0) {
- device_printf(sc->dev, "cannot find clk 'lcd_ch1_sclk1'\n");
- return (error);
- }
- error = clk_get_by_ofw_name(sc->dev, 0, "lcd_ch1_sclk2", &clk_sclk2);
- if (error != 0) {
- device_printf(sc->dev, "cannot find clk 'lcd_ch1_sclk2'\n");
- return (error);
- }
-
- error = clk_set_freq(clk_sclk2, freq, 0);
- if (error != 0) {
- device_printf(sc->dev, "cannot set lcd ch1 frequency\n");
- return (error);
- }
- error = clk_enable(clk_sclk2);
- if (error != 0) {
- device_printf(sc->dev, "cannot enable lcd ch1 sclk2\n");
- return (error);
- }
- error = clk_enable(clk_sclk1);
- if (error != 0) {
- device_printf(sc->dev, "cannot enable lcd ch1 sclk1\n");
- return (error);
- }
-
- return (0);
-}
-
-static int
-a10fb_setup_tcon(struct a10fb_softc *sc, const struct videomode *mode)
-{
- u_int interlace, hspw, hbp, vspw, vbp, vbl, width, height, start_delay;
- u_int vtotal, framerate, clk;
- clk_t clk_ahb;
- hwreset_t rst;
- uint32_t val;
- int error;
-
- interlace = !!(mode->flags & VID_INTERLACE);
- width = mode->hdisplay;
- height = mode->vdisplay;
- hspw = mode->hsync_end - mode->hsync_start;
- hbp = mode->htotal - mode->hsync_start;
- vspw = mode->vsync_end - mode->vsync_start;
- vbp = mode->vtotal - mode->vsync_start;
- vbl = VBLANK_LEN(mode->vtotal, mode->vdisplay, interlace);
- start_delay = START_DELAY(vbl);
-
- /* Leave reset */
- error = hwreset_get_by_ofw_name(sc->dev, 0, "lcd", &rst);
- if (error != 0) {
- device_printf(sc->dev, "cannot find reset 'lcd'\n");
- return (error);
- }
- error = hwreset_deassert(rst);
- if (error != 0) {
- device_printf(sc->dev, "couldn't de-assert reset 'lcd'\n");
- return (error);
- }
- /* Gating AHB clock for LCD */
- error = clk_get_by_ofw_name(sc->dev, 0, "ahb_lcd", &clk_ahb);
- if (error != 0) {
- device_printf(sc->dev, "cannot find clk 'ahb_lcd'\n");
- return (error);
- }
- error = clk_enable(clk_ahb);
- if (error != 0) {
- device_printf(sc->dev, "cannot enable clk 'ahb_lcd'\n");
- return (error);
- }
-
- /* Disable TCON and TCON1 */
- TCON_WRITE(sc, TCON_GCTL, 0);
- TCON_WRITE(sc, TCON1_CTL, 0);
-
- /* Enable clocks */
- TCON_WRITE(sc, TCON0_DCLK, DCLK_EN);
-
- /* Disable IO and data output ports */
- TCON_WRITE(sc, TCON1_IO_TRI, IO_TRI_MASK);
-
- /* Disable TCON and select TCON1 */
- TCON_WRITE(sc, TCON_GCTL, GCTL_IO_MAP_SEL_TCON1);
-
- /* Source width and height */
- TCON_WRITE(sc, TCON1_BASIC0, BASIC_X(width) | BASIC_Y(height));
- /* Scaler width and height */
- TCON_WRITE(sc, TCON1_BASIC1, BASIC_X(width) | BASIC_Y(height));
- /* Output width and height */
- TCON_WRITE(sc, TCON1_BASIC2, BASIC_X(width) | BASIC_Y(height));
- /* Horizontal total and back porch */
- TCON_WRITE(sc, TCON1_BASIC3, BASIC3_HT(mode->htotal) | BASIC3_HBP(hbp));
- /* Vertical total and back porch */
- vtotal = VTOTAL(mode->vtotal);
- if (interlace) {
- framerate = DIVIDE(DIVIDE(DOT_CLOCK_TO_HZ(mode->dot_clock),
- mode->htotal), mode->vtotal);
- clk = mode->htotal * (VTOTAL(mode->vtotal) + 1) * framerate;
- if ((clk / 2) == DOT_CLOCK_TO_HZ(mode->dot_clock))
- vtotal += 1;
- }
- TCON_WRITE(sc, TCON1_BASIC4, BASIC4_VT(vtotal) | BASIC4_VBP(vbp));
- /* Horizontal and vertical sync */
- TCON_WRITE(sc, TCON1_BASIC5, BASIC5_HSPW(hspw) | BASIC5_VSPW(vspw));
- /* Polarity */
- val = IO_POL_IO2_INV;
- if (mode->flags & VID_PHSYNC)
- val |= IO_POL_PHSYNC;
- if (mode->flags & VID_PVSYNC)
- val |= IO_POL_PVSYNC;
- TCON_WRITE(sc, TCON1_IO_POL, val);
-
- /* Set scan line for TCON1 line trigger */
- TCON_WRITE(sc, TCON_GINT1, GINT1_TCON1_LINENO(start_delay));
-
- /* Enable TCON1 */
- val = TCON1_EN;
- if (interlace)
- val |= INTERLACE_EN;
- val |= TCON1_START_DELAY(start_delay);
- val |= TCON1_SRC_SEL(TCON1_SRC_CH1);
- TCON_WRITE(sc, TCON1_CTL, val);
-
- /* Setup PLL */
- return (a10fb_setup_pll(sc, DOT_CLOCK_TO_HZ(mode->dot_clock)));
-}
-
-static void
-a10fb_enable_tcon(struct a10fb_softc *sc, int onoff)
-{
- uint32_t val;
-
- /* Enable TCON */
- val = TCON_READ(sc, TCON_GCTL);
- if (onoff)
- val |= GCTL_TCON_EN;
- else
- val &= ~GCTL_TCON_EN;
- TCON_WRITE(sc, TCON_GCTL, val);
-
- /* Enable TCON1 IO0/IO1 outputs */
- val = TCON_READ(sc, TCON1_IO_TRI);
- if (onoff)
- val &= ~(IO0_OUTPUT_TRI_EN | IO1_OUTPUT_TRI_EN);
- else
- val |= (IO0_OUTPUT_TRI_EN | IO1_OUTPUT_TRI_EN);
- TCON_WRITE(sc, TCON1_IO_TRI, val);
-}
-
-static int
-a10fb_configure(struct a10fb_softc *sc, const struct videomode *mode)
-{
- size_t fbsize;
- int error;
-
- fbsize = round_page(mode->hdisplay * mode->vdisplay * (FB_BPP / NBBY));
-
- /* Detach the old FB device */
- if (sc->fbdev != NULL) {
- device_delete_child(sc->dev, sc->fbdev);
- sc->fbdev = NULL;
- }
-
- /* If the FB size has changed, free the old FB memory */
- if (sc->fbsize > 0 && sc->fbsize != fbsize) {
- a10fb_freefb(sc);
- sc->vaddr = 0;
- }
-
- /* Allocate the FB if necessary */
- sc->fbsize = fbsize;
- if (sc->vaddr == 0) {
- error = a10fb_allocfb(sc);
- if (error != 0) {
- device_printf(sc->dev, "failed to allocate FB memory\n");
- return (ENXIO);
- }
- }
-
- /* Setup display backend */
- error = a10fb_setup_debe(sc, mode);
- if (error != 0)
- return (error);
-
- /* Setup display timing controller */
- error = a10fb_setup_tcon(sc, mode);
- if (error != 0)
- return (error);
-
- /* Attach framebuffer device */
- sc->info.fb_name = device_get_nameunit(sc->dev);
- sc->info.fb_vbase = (intptr_t)sc->vaddr;
- sc->info.fb_pbase = sc->paddr;
- sc->info.fb_size = sc->fbsize;
- sc->info.fb_bpp = sc->info.fb_depth = FB_BPP;
- sc->info.fb_stride = mode->hdisplay * (FB_BPP / NBBY);
- sc->info.fb_width = mode->hdisplay;
- sc->info.fb_height = mode->vdisplay;
-
- sc->fbdev = device_add_child(sc->dev, "fbd", device_get_unit(sc->dev));
- if (sc->fbdev == NULL) {
- device_printf(sc->dev, "failed to add fbd child\n");
- return (ENOENT);
- }
-
- error = device_probe_and_attach(sc->fbdev);
- if (error != 0) {
- device_printf(sc->dev, "failed to attach fbd device\n");
- return (error);
- }
-
- return (0);
-}
-
-static void
-a10fb_hdmi_event(void *arg, device_t hdmi_dev)
-{
- const struct videomode *mode;
- struct videomode hdmi_mode;
- struct a10fb_softc *sc;
- struct edid_info ei;
- uint8_t *edid;
- uint32_t edid_len;
- int error;
-
- sc = arg;
- edid = NULL;
- edid_len = 0;
- mode = NULL;
-
- error = HDMI_GET_EDID(hdmi_dev, &edid, &edid_len);
- if (error != 0) {
- device_printf(sc->dev, "failed to get EDID: %d\n", error);
- } else {
- error = edid_parse(edid, &ei);
- if (error != 0) {
- device_printf(sc->dev, "failed to parse EDID: %d\n",
- error);
- } else {
- if (bootverbose)
- edid_print(&ei);
- mode = ei.edid_preferred_mode;
- }
- }
-
- /* If the preferred mode could not be determined, use the default */
- if (mode == NULL)
- mode = pick_mode_by_ref(FB_DEFAULT_W, FB_DEFAULT_H,
- FB_DEFAULT_REF);
-
- if (mode == NULL) {
- device_printf(sc->dev, "failed to find usable video mode\n");
- return;
- }
-
- if (bootverbose)
- device_printf(sc->dev, "using %dx%d\n",
- mode->hdisplay, mode->vdisplay);
-
- /* Disable HDMI */
- HDMI_ENABLE(hdmi_dev, 0);
-
- /* Disable timing controller */
- a10fb_enable_tcon(sc, 0);
-
- /* Configure DEBE and TCON */
- error = a10fb_configure(sc, mode);
- if (error != 0) {
- device_printf(sc->dev, "failed to configure FB: %d\n", error);
- return;
- }
-
- hdmi_mode = *mode;
- hdmi_mode.hskew = mode->hsync_end - mode->hsync_start;
- hdmi_mode.flags |= VID_HSKEW;
- HDMI_SET_VIDEOMODE(hdmi_dev, &hdmi_mode);
-
- /* Enable timing controller */
- a10fb_enable_tcon(sc, 1);
-
- DELAY(HDMI_ENABLE_DELAY);
-
- /* Enable HDMI */
- HDMI_ENABLE(hdmi_dev, 1);
-}
-
-static int
-a10fb_probe(device_t dev)
-{
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun7i-a20-fb"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner Framebuffer");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-a10fb_attach(device_t dev)
-{
- struct a10fb_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, a10fb_spec, sc->res)) {
- device_printf(dev, "cannot allocate resources for device\n");
- return (ENXIO);
- }
-
- sc->hdmi_evh = EVENTHANDLER_REGISTER(hdmi_event,
- a10fb_hdmi_event, sc, 0);
-
- return (0);
-}
-
-static struct fb_info *
-a10fb_fb_getinfo(device_t dev)
-{
- struct a10fb_softc *sc;
-
- sc = device_get_softc(dev);
-
- return (&sc->info);
-}
-
-static device_method_t a10fb_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, a10fb_probe),
- DEVMETHOD(device_attach, a10fb_attach),
-
- /* FB interface */
- DEVMETHOD(fb_getinfo, a10fb_fb_getinfo),
-
- DEVMETHOD_END
-};
-
-static driver_t a10fb_driver = {
- "fb",
- a10fb_methods,
- sizeof(struct a10fb_softc),
-};
-
-DRIVER_MODULE(fb, simplebus, a10fb_driver, 0, 0);
diff --git a/sys/arm/allwinner/a10_hdmi.c b/sys/arm/allwinner/a10_hdmi.c
deleted file mode 100644
index ee57c07737de..000000000000
--- a/sys/arm/allwinner/a10_hdmi.c
+++ /dev/null
@@ -1,723 +0,0 @@
-/*-
- * Copyright (c) 2016 Jared McNeill <jmcneill@invisible.ca>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * Allwinner A10/A20 HDMI TX
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/condvar.h>
-#include <sys/eventhandler.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/videomode/videomode.h>
-#include <dev/videomode/edidvar.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include "hdmi_if.h"
-
-#define HDMI_CTRL 0x004
-#define CTRL_MODULE_EN (1 << 31)
-#define HDMI_INT_STATUS 0x008
-#define HDMI_HPD 0x00c
-#define HPD_DET (1 << 0)
-#define HDMI_VID_CTRL 0x010
-#define VID_CTRL_VIDEO_EN (1 << 31)
-#define VID_CTRL_HDMI_MODE (1 << 30)
-#define VID_CTRL_INTERLACE (1 << 4)
-#define VID_CTRL_REPEATER_2X (1 << 0)
-#define HDMI_VID_TIMING0 0x014
-#define VID_ACT_V(v) (((v) - 1) << 16)
-#define VID_ACT_H(h) (((h) - 1) << 0)
-#define HDMI_VID_TIMING1 0x018
-#define VID_VBP(vbp) (((vbp) - 1) << 16)
-#define VID_HBP(hbp) (((hbp) - 1) << 0)
-#define HDMI_VID_TIMING2 0x01c
-#define VID_VFP(vfp) (((vfp) - 1) << 16)
-#define VID_HFP(hfp) (((hfp) - 1) << 0)
-#define HDMI_VID_TIMING3 0x020
-#define VID_VSPW(vspw) (((vspw) - 1) << 16)
-#define VID_HSPW(hspw) (((hspw) - 1) << 0)
-#define HDMI_VID_TIMING4 0x024
-#define TX_CLOCK_NORMAL 0x03e00000
-#define VID_VSYNC_ACTSEL (1 << 1)
-#define VID_HSYNC_ACTSEL (1 << 0)
-#define HDMI_AUD_CTRL 0x040
-#define AUD_CTRL_EN (1 << 31)
-#define AUD_CTRL_RST (1 << 30)
-#define HDMI_ADMA_CTRL 0x044
-#define HDMI_ADMA_MODE (1 << 31)
-#define HDMI_ADMA_MODE_DDMA (0 << 31)
-#define HDMI_ADMA_MODE_NDMA (1 << 31)
-#define HDMI_AUD_FMT 0x048
-#define AUD_FMT_CH(n) ((n) - 1)
-#define HDMI_PCM_CTRL 0x04c
-#define HDMI_AUD_CTS 0x050
-#define HDMI_AUD_N 0x054
-#define HDMI_AUD_CH_STATUS0 0x058
-#define CH_STATUS0_FS_FREQ (0xf << 24)
-#define CH_STATUS0_FS_FREQ_48 (2 << 24)
-#define HDMI_AUD_CH_STATUS1 0x05c
-#define CH_STATUS1_WORD_LEN (0x7 << 1)
-#define CH_STATUS1_WORD_LEN_16 (1 << 1)
-#define HDMI_AUDIO_RESET_RETRY 1000
-#define HDMI_AUDIO_CHANNELS 2
-#define HDMI_AUDIO_CHANNELMAP 0x76543210
-#define HDMI_AUDIO_N 6144 /* 48 kHz */
-#define HDMI_AUDIO_CTS(r, n) ((((r) * 10) * ((n) / 128)) / 480)
-#define HDMI_PADCTRL0 0x200
-#define PADCTRL0_BIASEN (1 << 31)
-#define PADCTRL0_LDOCEN (1 << 30)
-#define PADCTRL0_LDODEN (1 << 29)
-#define PADCTRL0_PWENC (1 << 28)
-#define PADCTRL0_PWEND (1 << 27)
-#define PADCTRL0_PWENG (1 << 26)
-#define PADCTRL0_CKEN (1 << 25)
-#define PADCTRL0_SEN (1 << 24)
-#define PADCTRL0_TXEN (1 << 23)
-#define HDMI_PADCTRL1 0x204
-#define PADCTRL1_AMP_OPT (1 << 23)
-#define PADCTRL1_AMPCK_OPT (1 << 22)
-#define PADCTRL1_DMP_OPT (1 << 21)
-#define PADCTRL1_EMP_OPT (1 << 20)
-#define PADCTRL1_EMPCK_OPT (1 << 19)
-#define PADCTRL1_PWSCK (1 << 18)
-#define PADCTRL1_PWSDT (1 << 17)
-#define PADCTRL1_REG_CSMPS (1 << 16)
-#define PADCTRL1_REG_DEN (1 << 15)
-#define PADCTRL1_REG_DENCK (1 << 14)
-#define PADCTRL1_REG_PLRCK (1 << 13)
-#define PADCTRL1_REG_EMP (0x7 << 10)
-#define PADCTRL1_REG_EMP_EN (0x2 << 10)
-#define PADCTRL1_REG_CD (0x3 << 8)
-#define PADCTRL1_REG_CKSS (0x3 << 6)
-#define PADCTRL1_REG_CKSS_1X (0x1 << 6)
-#define PADCTRL1_REG_CKSS_2X (0x0 << 6)
-#define PADCTRL1_REG_AMP (0x7 << 3)
-#define PADCTRL1_REG_AMP_EN (0x6 << 3)
-#define PADCTRL1_REG_PLR (0x7 << 0)
-#define HDMI_PLLCTRL0 0x208
-#define PLLCTRL0_PLL_EN (1 << 31)
-#define PLLCTRL0_BWS (1 << 30)
-#define PLLCTRL0_HV_IS_33 (1 << 29)
-#define PLLCTRL0_LDO1_EN (1 << 28)
-#define PLLCTRL0_LDO2_EN (1 << 27)
-#define PLLCTRL0_SDIV2 (1 << 25)
-#define PLLCTRL0_VCO_GAIN (0x1 << 22)
-#define PLLCTRL0_S (0x7 << 17)
-#define PLLCTRL0_CP_S (0xf << 12)
-#define PLLCTRL0_CS (0x7 << 8)
-#define PLLCTRL0_PREDIV(x) ((x) << 4)
-#define PLLCTRL0_VCO_S (0x8 << 0)
-#define HDMI_PLLDBG0 0x20c
-#define PLLDBG0_CKIN_SEL (1 << 21)
-#define PLLDBG0_CKIN_SEL_PLL3 (0 << 21)
-#define PLLDBG0_CKIN_SEL_PLL7 (1 << 21)
-#define HDMI_PKTCTRL0 0x2f0
-#define HDMI_PKTCTRL1 0x2f4
-#define PKTCTRL_PACKET(n,t) ((t) << ((n) << 2))
-#define PKT_NULL 0
-#define PKT_GC 1
-#define PKT_AVI 2
-#define PKT_AI 3
-#define PKT_SPD 5
-#define PKT_END 15
-#define DDC_CTRL 0x500
-#define CTRL_DDC_EN (1 << 31)
-#define CTRL_DDC_ACMD_START (1 << 30)
-#define CTRL_DDC_FIFO_DIR (1 << 8)
-#define CTRL_DDC_FIFO_DIR_READ (0 << 8)
-#define CTRL_DDC_FIFO_DIR_WRITE (1 << 8)
-#define CTRL_DDC_SWRST (1 << 0)
-#define DDC_SLAVE_ADDR 0x504
-#define SLAVE_ADDR_SEG_SHIFT 24
-#define SLAVE_ADDR_EDDC_SHIFT 16
-#define SLAVE_ADDR_OFFSET_SHIFT 8
-#define SLAVE_ADDR_SHIFT 0
-#define DDC_INT_STATUS 0x50c
-#define INT_STATUS_XFER_DONE (1 << 0)
-#define DDC_FIFO_CTRL 0x510
-#define FIFO_CTRL_CLEAR (1 << 31)
-#define DDC_BYTE_COUNTER 0x51c
-#define DDC_COMMAND 0x520
-#define COMMAND_EOREAD (4 << 0)
-#define DDC_CLOCK 0x528
-#define DDC_CLOCK_M (1 << 3)
-#define DDC_CLOCK_N (5 << 0)
-#define DDC_FIFO 0x518
-#define SWRST_DELAY 1000
-#define DDC_DELAY 1000
-#define DDC_RETRY 1000
-#define DDC_BLKLEN 16
-#define DDC_ADDR 0x50
-#define EDDC_ADDR 0x60
-#define EDID_LENGTH 128
-#define DDC_CTRL_LINE 0x540
-#define DDC_LINE_SCL_ENABLE (1 << 8)
-#define DDC_LINE_SDA_ENABLE (1 << 9)
-#define HDMI_ENABLE_DELAY 50000
-#define DDC_READ_RETRY 4
-#define EXT_TAG 0x00
-#define CEA_TAG_ID 0x02
-#define CEA_DTD 0x03
-#define DTD_BASIC_AUDIO (1 << 6)
-#define CEA_REV 0x02
-#define CEA_DATA_OFF 0x03
-#define CEA_DATA_START 4
-#define BLOCK_TAG(x) (((x) >> 5) & 0x7)
-#define BLOCK_TAG_VSDB 3
-#define BLOCK_LEN(x) ((x) & 0x1f)
-#define HDMI_VSDB_MINLEN 5
-#define HDMI_OUI "\x03\x0c\x00"
-#define HDMI_OUI_LEN 3
-#define HDMI_DEFAULT_FREQ 297000000
-
-struct a10hdmi_softc {
- struct resource *res;
-
- struct intr_config_hook mode_hook;
-
- uint8_t edid[EDID_LENGTH];
-
- int has_hdmi;
- int has_audio;
-
- clk_t clk_ahb;
- clk_t clk_hdmi;
- clk_t clk_lcd;
-};
-
-static struct resource_spec a10hdmi_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-#define HDMI_READ(sc, reg) bus_read_4((sc)->res, (reg))
-#define HDMI_WRITE(sc, reg, val) bus_write_4((sc)->res, (reg), (val))
-
-static void
-a10hdmi_init(struct a10hdmi_softc *sc)
-{
- /* Enable the HDMI module */
- HDMI_WRITE(sc, HDMI_CTRL, CTRL_MODULE_EN);
-
- /* Configure PLL/DRV settings */
- HDMI_WRITE(sc, HDMI_PADCTRL0, PADCTRL0_BIASEN | PADCTRL0_LDOCEN |
- PADCTRL0_LDODEN | PADCTRL0_PWENC | PADCTRL0_PWEND |
- PADCTRL0_PWENG | PADCTRL0_CKEN | PADCTRL0_TXEN);
- HDMI_WRITE(sc, HDMI_PADCTRL1, PADCTRL1_AMP_OPT | PADCTRL1_AMPCK_OPT |
- PADCTRL1_EMP_OPT | PADCTRL1_EMPCK_OPT | PADCTRL1_REG_DEN |
- PADCTRL1_REG_DENCK | PADCTRL1_REG_EMP_EN | PADCTRL1_REG_AMP_EN);
-
- /* Select PLL3 as input clock */
- HDMI_WRITE(sc, HDMI_PLLDBG0, PLLDBG0_CKIN_SEL_PLL3);
-
- DELAY(HDMI_ENABLE_DELAY);
-}
-
-static void
-a10hdmi_hpd(void *arg)
-{
- struct a10hdmi_softc *sc;
- device_t dev;
- uint32_t hpd;
-
- dev = arg;
- sc = device_get_softc(dev);
-
- hpd = HDMI_READ(sc, HDMI_HPD);
- if ((hpd & HPD_DET) == HPD_DET)
- EVENTHANDLER_INVOKE(hdmi_event, dev, HDMI_EVENT_CONNECTED);
-
- config_intrhook_disestablish(&sc->mode_hook);
-}
-
-static int
-a10hdmi_probe(device_t dev)
-{
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun7i-a20-hdmi"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner HDMI TX");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-a10hdmi_attach(device_t dev)
-{
- struct a10hdmi_softc *sc;
- int error;
-
- sc = device_get_softc(dev);
-
- if (bus_alloc_resources(dev, a10hdmi_spec, &sc->res)) {
- device_printf(dev, "cannot allocate resources for device\n");
- return (ENXIO);
- }
-
- /* Setup clocks */
- error = clk_get_by_ofw_name(dev, 0, "ahb", &sc->clk_ahb);
- if (error != 0) {
- device_printf(dev, "cannot find ahb clock\n");
- return (error);
- }
- error = clk_get_by_ofw_name(dev, 0, "hdmi", &sc->clk_hdmi);
- if (error != 0) {
- device_printf(dev, "cannot find hdmi clock\n");
- return (error);
- }
- error = clk_get_by_ofw_name(dev, 0, "lcd", &sc->clk_lcd);
- if (error != 0) {
- device_printf(dev, "cannot find lcd clock\n");
- }
- /* Enable HDMI clock */
- error = clk_enable(sc->clk_hdmi);
- if (error != 0) {
- device_printf(dev, "cannot enable hdmi clock\n");
- return (error);
- }
- /* Gating AHB clock for HDMI */
- error = clk_enable(sc->clk_ahb);
- if (error != 0) {
- device_printf(dev, "cannot enable ahb gate\n");
- return (error);
- }
-
- a10hdmi_init(sc);
-
- sc->mode_hook.ich_func = a10hdmi_hpd;
- sc->mode_hook.ich_arg = dev;
-
- error = config_intrhook_establish(&sc->mode_hook);
- if (error != 0)
- return (error);
-
- return (0);
-}
-
-static int
-a10hdmi_ddc_xfer(struct a10hdmi_softc *sc, uint16_t addr, uint8_t seg,
- uint8_t off, int len)
-{
- uint32_t val;
- int retry;
-
- /* Set FIFO direction to read */
- val = HDMI_READ(sc, DDC_CTRL);
- val &= ~CTRL_DDC_FIFO_DIR;
- val |= CTRL_DDC_FIFO_DIR_READ;
- HDMI_WRITE(sc, DDC_CTRL, val);
-
- /* Setup DDC slave address */
- val = (addr << SLAVE_ADDR_SHIFT) | (seg << SLAVE_ADDR_SEG_SHIFT) |
- (EDDC_ADDR << SLAVE_ADDR_EDDC_SHIFT) |
- (off << SLAVE_ADDR_OFFSET_SHIFT);
- HDMI_WRITE(sc, DDC_SLAVE_ADDR, val);
-
- /* Clear FIFO */
- val = HDMI_READ(sc, DDC_FIFO_CTRL);
- val |= FIFO_CTRL_CLEAR;
- HDMI_WRITE(sc, DDC_FIFO_CTRL, val);
-
- /* Set transfer length */
- HDMI_WRITE(sc, DDC_BYTE_COUNTER, len);
-
- /* Set command to "Explicit Offset Address Read" */
- HDMI_WRITE(sc, DDC_COMMAND, COMMAND_EOREAD);
-
- /* Start transfer */
- val = HDMI_READ(sc, DDC_CTRL);
- val |= CTRL_DDC_ACMD_START;
- HDMI_WRITE(sc, DDC_CTRL, val);
-
- /* Wait for command to start */
- retry = DDC_RETRY;
- while (--retry > 0) {
- val = HDMI_READ(sc, DDC_CTRL);
- if ((val & CTRL_DDC_ACMD_START) == 0)
- break;
- DELAY(DDC_DELAY);
- }
- if (retry == 0)
- return (ETIMEDOUT);
-
- /* Ensure that the transfer completed */
- val = HDMI_READ(sc, DDC_INT_STATUS);
- if ((val & INT_STATUS_XFER_DONE) == 0)
- return (EIO);
-
- return (0);
-}
-
-static int
-a10hdmi_ddc_read(struct a10hdmi_softc *sc, int block, uint8_t *edid)
-{
- int resid, off, len, error;
- uint8_t *pbuf;
-
- pbuf = edid;
- resid = EDID_LENGTH;
- off = (block & 1) ? EDID_LENGTH : 0;
-
- while (resid > 0) {
- len = min(resid, DDC_BLKLEN);
- error = a10hdmi_ddc_xfer(sc, DDC_ADDR, block >> 1, off, len);
- if (error != 0)
- return (error);
-
- bus_read_multi_1(sc->res, DDC_FIFO, pbuf, len);
-
- pbuf += len;
- off += len;
- resid -= len;
- }
-
- return (0);
-}
-
-static int
-a10hdmi_detect_hdmi_vsdb(uint8_t *edid)
-{
- int off, p, btag, blen;
-
- if (edid[EXT_TAG] != CEA_TAG_ID)
- return (0);
-
- off = edid[CEA_DATA_OFF];
-
- /* CEA data block collection starts at byte 4 */
- if (off <= CEA_DATA_START)
- return (0);
-
- /* Parse the CEA data blocks */
- for (p = CEA_DATA_START; p < off;) {
- btag = BLOCK_TAG(edid[p]);
- blen = BLOCK_LEN(edid[p]);
-
- /* Make sure the length is sane */
- if (p + blen + 1 > off)
- break;
-
- /* Look for a VSDB with the HDMI 24-bit IEEE registration ID */
- if (btag == BLOCK_TAG_VSDB && blen >= HDMI_VSDB_MINLEN &&
- memcmp(&edid[p + 1], HDMI_OUI, HDMI_OUI_LEN) == 0)
- return (1);
-
- /* Next data block */
- p += (1 + blen);
- }
-
- return (0);
-}
-
-static void
-a10hdmi_detect_hdmi(struct a10hdmi_softc *sc, int *phdmi, int *paudio)
-{
- struct edid_info ei;
- uint8_t edid[EDID_LENGTH];
- int block;
-
- *phdmi = *paudio = 0;
-
- if (edid_parse(sc->edid, &ei) != 0)
- return;
-
- /* Scan through extension blocks, looking for a CEA-861 block. */
- for (block = 1; block <= ei.edid_ext_block_count; block++) {
- if (a10hdmi_ddc_read(sc, block, edid) != 0)
- return;
-
- if (a10hdmi_detect_hdmi_vsdb(edid) != 0) {
- *phdmi = 1;
- *paudio = ((edid[CEA_DTD] & DTD_BASIC_AUDIO) != 0);
- return;
- }
- }
-}
-
-static int
-a10hdmi_get_edid(device_t dev, uint8_t **edid, uint32_t *edid_len)
-{
- struct a10hdmi_softc *sc;
- int error, retry;
-
- sc = device_get_softc(dev);
- retry = DDC_READ_RETRY;
-
- while (--retry > 0) {
- /* I2C software reset */
- HDMI_WRITE(sc, DDC_FIFO_CTRL, 0);
- HDMI_WRITE(sc, DDC_CTRL, CTRL_DDC_EN | CTRL_DDC_SWRST);
- DELAY(SWRST_DELAY);
- if (HDMI_READ(sc, DDC_CTRL) & CTRL_DDC_SWRST) {
- device_printf(dev, "DDC software reset failed\n");
- return (ENXIO);
- }
-
- /* Configure DDC clock */
- HDMI_WRITE(sc, DDC_CLOCK, DDC_CLOCK_M | DDC_CLOCK_N);
-
- /* Enable SDA/SCL */
- HDMI_WRITE(sc, DDC_CTRL_LINE,
- DDC_LINE_SCL_ENABLE | DDC_LINE_SDA_ENABLE);
-
- /* Read EDID block */
- error = a10hdmi_ddc_read(sc, 0, sc->edid);
- if (error == 0) {
- *edid = sc->edid;
- *edid_len = sizeof(sc->edid);
- break;
- }
- }
-
- if (error == 0)
- a10hdmi_detect_hdmi(sc, &sc->has_hdmi, &sc->has_audio);
- else
- sc->has_hdmi = sc->has_audio = 0;
-
- return (error);
-}
-
-static void
-a10hdmi_set_audiomode(device_t dev, const struct videomode *mode)
-{
- struct a10hdmi_softc *sc;
- uint32_t val;
- int retry;
-
- sc = device_get_softc(dev);
-
- /* Disable and reset audio module and wait for reset bit to clear */
- HDMI_WRITE(sc, HDMI_AUD_CTRL, AUD_CTRL_RST);
- for (retry = HDMI_AUDIO_RESET_RETRY; retry > 0; retry--) {
- val = HDMI_READ(sc, HDMI_AUD_CTRL);
- if ((val & AUD_CTRL_RST) == 0)
- break;
- }
- if (retry == 0) {
- device_printf(dev, "timeout waiting for audio module\n");
- return;
- }
-
- if (!sc->has_audio)
- return;
-
- /* DMA and FIFO control */
- HDMI_WRITE(sc, HDMI_ADMA_CTRL, HDMI_ADMA_MODE_DDMA);
-
- /* Audio format control (LPCM, S16LE, stereo) */
- HDMI_WRITE(sc, HDMI_AUD_FMT, AUD_FMT_CH(HDMI_AUDIO_CHANNELS));
-
- /* Channel mappings */
- HDMI_WRITE(sc, HDMI_PCM_CTRL, HDMI_AUDIO_CHANNELMAP);
-
- /* Clocks */
- HDMI_WRITE(sc, HDMI_AUD_CTS,
- HDMI_AUDIO_CTS(mode->dot_clock, HDMI_AUDIO_N));
- HDMI_WRITE(sc, HDMI_AUD_N, HDMI_AUDIO_N);
-
- /* Set sampling frequency to 48 kHz, word length to 16-bit */
- HDMI_WRITE(sc, HDMI_AUD_CH_STATUS0, CH_STATUS0_FS_FREQ_48);
- HDMI_WRITE(sc, HDMI_AUD_CH_STATUS1, CH_STATUS1_WORD_LEN_16);
-
- /* Enable */
- HDMI_WRITE(sc, HDMI_AUD_CTRL, AUD_CTRL_EN);
-}
-
-static int
-a10hdmi_get_tcon_config(struct a10hdmi_softc *sc, int *div, int *dbl)
-{
- uint64_t lcd_fin, lcd_fout;
- clk_t clk_lcd_parent;
- const char *pname;
- int error;
-
- error = clk_get_parent(sc->clk_lcd, &clk_lcd_parent);
- if (error != 0)
- return (error);
-
- /* Get the LCD CH1 special clock 2 divider */
- error = clk_get_freq(sc->clk_lcd, &lcd_fout);
- if (error != 0)
- return (error);
- error = clk_get_freq(clk_lcd_parent, &lcd_fin);
- if (error != 0)
- return (error);
- *div = lcd_fin / lcd_fout;
-
- /* Detect LCD CH1 special clock using a 1X or 2X source */
- /* XXX */
- pname = clk_get_name(clk_lcd_parent);
- if (strcmp(pname, "pll3") == 0 || strcmp(pname, "pll7") == 0)
- *dbl = 0;
- else
- *dbl = 1;
-
- return (0);
-}
-
-static int
-a10hdmi_set_videomode(device_t dev, const struct videomode *mode)
-{
- struct a10hdmi_softc *sc;
- int error, clk_div, clk_dbl;
- int dblscan, hfp, hspw, hbp, vfp, vspw, vbp;
- uint32_t val;
-
- sc = device_get_softc(dev);
- dblscan = !!(mode->flags & VID_DBLSCAN);
- hfp = mode->hsync_start - mode->hdisplay;
- hspw = mode->hsync_end - mode->hsync_start;
- hbp = mode->htotal - mode->hsync_start;
- vfp = mode->vsync_start - mode->vdisplay;
- vspw = mode->vsync_end - mode->vsync_start;
- vbp = mode->vtotal - mode->vsync_start;
-
- error = a10hdmi_get_tcon_config(sc, &clk_div, &clk_dbl);
- if (error != 0) {
- device_printf(dev, "couldn't get tcon config: %d\n", error);
- return (error);
- }
-
- /* Clear interrupt status */
- HDMI_WRITE(sc, HDMI_INT_STATUS, HDMI_READ(sc, HDMI_INT_STATUS));
-
- /* Clock setup */
- val = HDMI_READ(sc, HDMI_PADCTRL1);
- val &= ~PADCTRL1_REG_CKSS;
- val |= (clk_dbl ? PADCTRL1_REG_CKSS_2X : PADCTRL1_REG_CKSS_1X);
- HDMI_WRITE(sc, HDMI_PADCTRL1, val);
- HDMI_WRITE(sc, HDMI_PLLCTRL0, PLLCTRL0_PLL_EN | PLLCTRL0_BWS |
- PLLCTRL0_HV_IS_33 | PLLCTRL0_LDO1_EN | PLLCTRL0_LDO2_EN |
- PLLCTRL0_SDIV2 | PLLCTRL0_VCO_GAIN | PLLCTRL0_S |
- PLLCTRL0_CP_S | PLLCTRL0_CS | PLLCTRL0_PREDIV(clk_div) |
- PLLCTRL0_VCO_S);
-
- /* Setup display settings */
- if (bootverbose)
- device_printf(dev, "HDMI: %s, Audio: %s\n",
- sc->has_hdmi ? "yes" : "no", sc->has_audio ? "yes" : "no");
- val = 0;
- if (sc->has_hdmi)
- val |= VID_CTRL_HDMI_MODE;
- if (mode->flags & VID_INTERLACE)
- val |= VID_CTRL_INTERLACE;
- if (mode->flags & VID_DBLSCAN)
- val |= VID_CTRL_REPEATER_2X;
- HDMI_WRITE(sc, HDMI_VID_CTRL, val);
-
- /* Setup display timings */
- HDMI_WRITE(sc, HDMI_VID_TIMING0,
- VID_ACT_V(mode->vdisplay) | VID_ACT_H(mode->hdisplay << dblscan));
- HDMI_WRITE(sc, HDMI_VID_TIMING1,
- VID_VBP(vbp) | VID_HBP(hbp << dblscan));
- HDMI_WRITE(sc, HDMI_VID_TIMING2,
- VID_VFP(vfp) | VID_HFP(hfp << dblscan));
- HDMI_WRITE(sc, HDMI_VID_TIMING3,
- VID_VSPW(vspw) | VID_HSPW(hspw << dblscan));
- val = TX_CLOCK_NORMAL;
- if (mode->flags & VID_PVSYNC)
- val |= VID_VSYNC_ACTSEL;
- if (mode->flags & VID_PHSYNC)
- val |= VID_HSYNC_ACTSEL;
- HDMI_WRITE(sc, HDMI_VID_TIMING4, val);
-
- /* This is an ordered list of infoframe packets that the HDMI
- * transmitter will send. Transmit packets in the following order:
- * 1. General control packet
- * 2. AVI infoframe
- * 3. Audio infoframe
- * There are 2 registers with 4 slots each. The list is terminated
- * with the special PKT_END marker.
- */
- HDMI_WRITE(sc, HDMI_PKTCTRL0,
- PKTCTRL_PACKET(0, PKT_GC) | PKTCTRL_PACKET(1, PKT_AVI) |
- PKTCTRL_PACKET(2, PKT_AI) | PKTCTRL_PACKET(3, PKT_END));
- HDMI_WRITE(sc, HDMI_PKTCTRL1, 0);
-
- /* Setup audio */
- a10hdmi_set_audiomode(dev, mode);
-
- return (0);
-}
-
-static int
-a10hdmi_enable(device_t dev, int onoff)
-{
- struct a10hdmi_softc *sc;
- uint32_t val;
-
- sc = device_get_softc(dev);
-
- /* Enable or disable video output */
- val = HDMI_READ(sc, HDMI_VID_CTRL);
- if (onoff)
- val |= VID_CTRL_VIDEO_EN;
- else
- val &= ~VID_CTRL_VIDEO_EN;
- HDMI_WRITE(sc, HDMI_VID_CTRL, val);
-
- return (0);
-}
-
-static device_method_t a10hdmi_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, a10hdmi_probe),
- DEVMETHOD(device_attach, a10hdmi_attach),
-
- /* HDMI interface */
- DEVMETHOD(hdmi_get_edid, a10hdmi_get_edid),
- DEVMETHOD(hdmi_set_videomode, a10hdmi_set_videomode),
- DEVMETHOD(hdmi_enable, a10hdmi_enable),
-
- DEVMETHOD_END
-};
-
-static driver_t a10hdmi_driver = {
- "a10hdmi",
- a10hdmi_methods,
- sizeof(struct a10hdmi_softc),
-};
-
-DRIVER_MODULE(a10hdmi, simplebus, a10hdmi_driver, 0, 0);
-MODULE_VERSION(a10hdmi, 1);
diff --git a/sys/arm/allwinner/a10_hdmiaudio.c b/sys/arm/allwinner/a10_hdmiaudio.c
deleted file mode 100644
index 13fe2ea7f1b7..000000000000
--- a/sys/arm/allwinner/a10_hdmiaudio.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/*-
- * Copyright (c) 2016 Jared McNeill <jmcneill@invisible.ca>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * Allwinner A10/A20 HDMI Audio
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/condvar.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-
-#include <dev/sound/pcm/sound.h>
-#include <dev/sound/chip.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include "sunxi_dma_if.h"
-#include "mixer_if.h"
-
-#define DRQTYPE_HDMIAUDIO 24
-#define DRQTYPE_SDRAM 1
-
-#define DMA_WIDTH 32
-#define DMA_BURST_LEN 8
-#define DDMA_BLKSIZE 32
-#define DDMA_WAIT_CYC 8
-
-#define DMABUF_MIN 4096
-#define DMABUF_DEFAULT 65536
-#define DMABUF_MAX 131072
-
-#define HDMI_SAMPLERATE 48000
-
-#define TX_FIFO 0x01c16400
-
-static uint32_t a10hdmiaudio_fmt[] = {
- SND_FORMAT(AFMT_S16_LE, 2, 0),
- 0
-};
-
-static struct pcmchan_caps a10hdmiaudio_pcaps = {
- HDMI_SAMPLERATE, HDMI_SAMPLERATE, a10hdmiaudio_fmt, 0
-};
-
-struct a10hdmiaudio_info;
-
-struct a10hdmiaudio_chinfo {
- struct snd_dbuf *buffer;
- struct pcm_channel *channel;
- struct a10hdmiaudio_info *parent;
- bus_dmamap_t dmamap;
- void *dmaaddr;
- bus_addr_t physaddr;
- device_t dmac;
- void *dmachan;
-
- int run;
- uint32_t pos;
- uint32_t blocksize;
-};
-
-struct a10hdmiaudio_info {
- device_t dev;
- struct mtx *lock;
- bus_dma_tag_t dmat;
- unsigned dmasize;
-
- struct a10hdmiaudio_chinfo play;
-};
-
-/*
- * Mixer interface
- */
-
-static int
-a10hdmiaudio_mixer_init(struct snd_mixer *m)
-{
- mix_setdevs(m, SOUND_MASK_PCM);
-
- return (0);
-}
-
-static int
-a10hdmiaudio_mixer_set(struct snd_mixer *m, unsigned dev, unsigned left,
- unsigned right)
-{
- return (-1);
-}
-
-static kobj_method_t a10hdmiaudio_mixer_methods[] = {
- KOBJMETHOD(mixer_init, a10hdmiaudio_mixer_init),
- KOBJMETHOD(mixer_set, a10hdmiaudio_mixer_set),
- KOBJMETHOD_END
-};
-MIXER_DECLARE(a10hdmiaudio_mixer);
-
-/*
- * Channel interface
- */
-
-static void
-a10hdmiaudio_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- struct a10hdmiaudio_chinfo *ch = arg;
-
- if (error != 0)
- return;
-
- ch->physaddr = segs[0].ds_addr;
-}
-
-static void
-a10hdmiaudio_transfer(struct a10hdmiaudio_chinfo *ch)
-{
- int error;
-
- error = SUNXI_DMA_TRANSFER(ch->dmac, ch->dmachan,
- ch->physaddr + ch->pos, TX_FIFO, ch->blocksize);
- if (error) {
- ch->run = 0;
- device_printf(ch->parent->dev, "DMA transfer failed: %d\n",
- error);
- }
-}
-
-static void
-a10hdmiaudio_dmaconfig(struct a10hdmiaudio_chinfo *ch)
-{
- struct sunxi_dma_config conf;
-
- memset(&conf, 0, sizeof(conf));
- conf.src_width = conf.dst_width = DMA_WIDTH;
- conf.src_burst_len = conf.dst_burst_len = DMA_BURST_LEN;
- conf.src_blksize = conf.dst_blksize = DDMA_BLKSIZE;
- conf.src_wait_cyc = conf.dst_wait_cyc = DDMA_WAIT_CYC;
- conf.src_drqtype = DRQTYPE_SDRAM;
- conf.dst_drqtype = DRQTYPE_HDMIAUDIO;
- conf.dst_noincr = true;
-
- SUNXI_DMA_SET_CONFIG(ch->dmac, ch->dmachan, &conf);
-}
-
-static void
-a10hdmiaudio_dmaintr(void *priv)
-{
- struct a10hdmiaudio_chinfo *ch = priv;
- unsigned bufsize;
-
- bufsize = sndbuf_getsize(ch->buffer);
-
- ch->pos += ch->blocksize;
- if (ch->pos >= bufsize)
- ch->pos -= bufsize;
-
- if (ch->run) {
- chn_intr(ch->channel);
- a10hdmiaudio_transfer(ch);
- }
-}
-
-static void
-a10hdmiaudio_start(struct a10hdmiaudio_chinfo *ch)
-{
- ch->pos = 0;
-
- /* Configure DMA channel */
- a10hdmiaudio_dmaconfig(ch);
-
- /* Start DMA transfer */
- a10hdmiaudio_transfer(ch);
-}
-
-static void
-a10hdmiaudio_stop(struct a10hdmiaudio_chinfo *ch)
-{
- /* Disable DMA channel */
- SUNXI_DMA_HALT(ch->dmac, ch->dmachan);
-}
-
-static void *
-a10hdmiaudio_chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
- struct pcm_channel *c, int dir)
-{
- struct a10hdmiaudio_info *sc = devinfo;
- struct a10hdmiaudio_chinfo *ch = &sc->play;
- int error;
-
- ch->parent = sc;
- ch->channel = c;
- ch->buffer = b;
-
- ch->dmac = devclass_get_device(devclass_find("a10dmac"), 0);
- if (ch->dmac == NULL) {
- device_printf(sc->dev, "cannot find DMA controller\n");
- return (NULL);
- }
- ch->dmachan = SUNXI_DMA_ALLOC(ch->dmac, true, a10hdmiaudio_dmaintr, ch);
- if (ch->dmachan == NULL) {
- device_printf(sc->dev, "cannot allocate DMA channel\n");
- return (NULL);
- }
-
- error = bus_dmamem_alloc(sc->dmat, &ch->dmaaddr,
- BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &ch->dmamap);
- if (error != 0) {
- device_printf(sc->dev, "cannot allocate channel buffer\n");
- return (NULL);
- }
- error = bus_dmamap_load(sc->dmat, ch->dmamap, ch->dmaaddr,
- sc->dmasize, a10hdmiaudio_dmamap_cb, ch, BUS_DMA_NOWAIT);
- if (error != 0) {
- device_printf(sc->dev, "cannot load DMA map\n");
- return (NULL);
- }
- memset(ch->dmaaddr, 0, sc->dmasize);
-
- if (sndbuf_setup(ch->buffer, ch->dmaaddr, sc->dmasize) != 0) {
- device_printf(sc->dev, "cannot setup sndbuf\n");
- return (NULL);
- }
-
- return (ch);
-}
-
-static int
-a10hdmiaudio_chan_free(kobj_t obj, void *data)
-{
- struct a10hdmiaudio_chinfo *ch = data;
- struct a10hdmiaudio_info *sc = ch->parent;
-
- SUNXI_DMA_FREE(ch->dmac, ch->dmachan);
- bus_dmamap_unload(sc->dmat, ch->dmamap);
- bus_dmamem_free(sc->dmat, ch->dmaaddr, ch->dmamap);
-
- return (0);
-}
-
-static int
-a10hdmiaudio_chan_setformat(kobj_t obj, void *data, uint32_t format)
-{
- return (0);
-}
-
-static uint32_t
-a10hdmiaudio_chan_setspeed(kobj_t obj, void *data, uint32_t speed)
-{
- return (HDMI_SAMPLERATE);
-}
-
-static uint32_t
-a10hdmiaudio_chan_setblocksize(kobj_t obj, void *data, uint32_t blocksize)
-{
- struct a10hdmiaudio_chinfo *ch = data;
-
- ch->blocksize = blocksize & ~3;
-
- return (ch->blocksize);
-}
-
-static int
-a10hdmiaudio_chan_trigger(kobj_t obj, void *data, int go)
-{
- struct a10hdmiaudio_chinfo *ch = data;
- struct a10hdmiaudio_info *sc = ch->parent;
-
- if (!PCMTRIG_COMMON(go))
- return (0);
-
- snd_mtxlock(sc->lock);
- switch (go) {
- case PCMTRIG_START:
- ch->run = 1;
- a10hdmiaudio_start(ch);
- break;
- case PCMTRIG_STOP:
- case PCMTRIG_ABORT:
- ch->run = 0;
- a10hdmiaudio_stop(ch);
- break;
- default:
- break;
- }
- snd_mtxunlock(sc->lock);
-
- return (0);
-}
-
-static uint32_t
-a10hdmiaudio_chan_getptr(kobj_t obj, void *data)
-{
- struct a10hdmiaudio_chinfo *ch = data;
-
- return (ch->pos);
-}
-
-static struct pcmchan_caps *
-a10hdmiaudio_chan_getcaps(kobj_t obj, void *data)
-{
- return (&a10hdmiaudio_pcaps);
-}
-
-static kobj_method_t a10hdmiaudio_chan_methods[] = {
- KOBJMETHOD(channel_init, a10hdmiaudio_chan_init),
- KOBJMETHOD(channel_free, a10hdmiaudio_chan_free),
- KOBJMETHOD(channel_setformat, a10hdmiaudio_chan_setformat),
- KOBJMETHOD(channel_setspeed, a10hdmiaudio_chan_setspeed),
- KOBJMETHOD(channel_setblocksize, a10hdmiaudio_chan_setblocksize),
- KOBJMETHOD(channel_trigger, a10hdmiaudio_chan_trigger),
- KOBJMETHOD(channel_getptr, a10hdmiaudio_chan_getptr),
- KOBJMETHOD(channel_getcaps, a10hdmiaudio_chan_getcaps),
- KOBJMETHOD_END
-};
-CHANNEL_DECLARE(a10hdmiaudio_chan);
-
-/*
- * Device interface
- */
-
-static int
-a10hdmiaudio_probe(device_t dev)
-{
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun7i-a20-hdmiaudio"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner HDMI Audio");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-a10hdmiaudio_attach(device_t dev)
-{
- struct a10hdmiaudio_info *sc;
- char status[SND_STATUSLEN];
- int error;
-
- sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
- sc->dev = dev;
- sc->lock = snd_mtxcreate(device_get_nameunit(dev), "a10hdmiaudio softc");
-
- sc->dmasize = pcm_getbuffersize(dev, DMABUF_MIN,
- DMABUF_DEFAULT, DMABUF_MAX);
- error = bus_dma_tag_create(
- bus_get_dma_tag(dev),
- 4, sc->dmasize, /* alignment, boundary */
- BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- sc->dmasize, 1, /* maxsize, nsegs */
- sc->dmasize, 0, /* maxsegsize, flags */
- NULL, NULL, /* lockfunc, lockarg */
- &sc->dmat);
- if (error != 0) {
- device_printf(dev, "cannot create DMA tag\n");
- goto fail;
- }
-
- if (mixer_init(dev, &a10hdmiaudio_mixer_class, sc)) {
- device_printf(dev, "mixer_init failed\n");
- goto fail;
- }
-
- pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE);
- pcm_setflags(dev, pcm_getflags(dev) | SD_F_SOFTPCMVOL);
-
- if (pcm_register(dev, sc, 1, 0)) {
- device_printf(dev, "pcm_register failed\n");
- goto fail;
- }
-
- pcm_addchan(dev, PCMDIR_PLAY, &a10hdmiaudio_chan_class, sc);
-
- snprintf(status, SND_STATUSLEN, "at %s", ofw_bus_get_name(dev));
- pcm_setstatus(dev, status);
-
- return (0);
-
-fail:
- snd_mtxfree(sc->lock);
- free(sc, M_DEVBUF);
-
- return (error);
-}
-
-static device_method_t a10hdmiaudio_pcm_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, a10hdmiaudio_probe),
- DEVMETHOD(device_attach, a10hdmiaudio_attach),
-
- DEVMETHOD_END
-};
-
-static driver_t a10hdmiaudio_pcm_driver = {
- "pcm",
- a10hdmiaudio_pcm_methods,
- PCM_SOFTC_SIZE,
-};
-
-DRIVER_MODULE(a10hdmiaudio, simplebus, a10hdmiaudio_pcm_driver, 0, 0);
-MODULE_DEPEND(a10hdmiaudio, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
-MODULE_VERSION(a10hdmiaudio, 1);
diff --git a/sys/arm/allwinner/a10_sramc.c b/sys/arm/allwinner/a10_sramc.c
index 776137d32894..fe7dd4025d7e 100644
--- a/sys/arm/allwinner/a10_sramc.c
+++ b/sys/arm/allwinner/a10_sramc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
* All rights reserved.
@@ -24,13 +24,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
diff --git a/sys/arm/allwinner/a10_sramc.h b/sys/arm/allwinner/a10_sramc.h
index 882091319a67..226236464be0 100644
--- a/sys/arm/allwinner/a10_sramc.h
+++ b/sys/arm/allwinner/a10_sramc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
* All rights reserved.
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _A10_SRAMC_H_
diff --git a/sys/arm/allwinner/a13/a13_padconf.c b/sys/arm/allwinner/a13/a13_padconf.c
index b8a2e3a20c1a..d5e38fe8042b 100644
--- a/sys/arm/allwinner/a13/a13_padconf.c
+++ b/sys/arm/allwinner/a13/a13_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a13/files.a13 b/sys/arm/allwinner/a13/files.a13
index 0a84d63ef7b8..ec248227e058 100644
--- a/sys/arm/allwinner/a13/files.a13
+++ b/sys/arm/allwinner/a13/files.a13
@@ -1,4 +1,3 @@
-# $FreeBSD$
arm/allwinner/a13/a13_padconf.c standard
-arm/allwinner/clkng/ccu_a13.c standard
+dev/clk/allwinner/ccu_a13.c standard
diff --git a/sys/arm/allwinner/a20/a20_cpu_cfg.c b/sys/arm/allwinner/a20/a20_cpu_cfg.c
index f323f3483fe0..ffbb2cc183e7 100644
--- a/sys/arm/allwinner/a20/a20_cpu_cfg.c
+++ b/sys/arm/allwinner/a20/a20_cpu_cfg.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
* All rights reserved.
@@ -28,9 +28,6 @@
/* CPU configuration module for Allwinner A20 */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
diff --git a/sys/arm/allwinner/a20/a20_cpu_cfg.h b/sys/arm/allwinner/a20/a20_cpu_cfg.h
index 6f3d400f0edc..e60a2bceaac1 100644
--- a/sys/arm/allwinner/a20/a20_cpu_cfg.h
+++ b/sys/arm/allwinner/a20/a20_cpu_cfg.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
* All rights reserved.
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _A20_CPU_CFG_H_
diff --git a/sys/arm/allwinner/a20/a20_padconf.c b/sys/arm/allwinner/a20/a20_padconf.c
index a6d58b40a8b1..d0c1e8e4d0ad 100644
--- a/sys/arm/allwinner/a20/a20_padconf.c
+++ b/sys/arm/allwinner/a20/a20_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a20/files.a20 b/sys/arm/allwinner/a20/files.a20
index 6cc952bd6ee9..663047867e45 100644
--- a/sys/arm/allwinner/a20/files.a20
+++ b/sys/arm/allwinner/a20/files.a20
@@ -1,4 +1,3 @@
-# $FreeBSD$
arm/allwinner/a20/a20_padconf.c standard
-arm/allwinner/clkng/ccu_a10.c standard
+dev/clk/allwinner/ccu_a10.c standard
diff --git a/sys/arm/allwinner/a31/a31_padconf.c b/sys/arm/allwinner/a31/a31_padconf.c
index 01207fd767da..e1dcbf7c43f7 100644
--- a/sys/arm/allwinner/a31/a31_padconf.c
+++ b/sys/arm/allwinner/a31/a31_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a31/a31_r_padconf.c b/sys/arm/allwinner/a31/a31_r_padconf.c
index 0bc3d60b8a15..0e3a341b7150 100644
--- a/sys/arm/allwinner/a31/a31_r_padconf.c
+++ b/sys/arm/allwinner/a31/a31_r_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a31/a31s_padconf.c b/sys/arm/allwinner/a31/a31s_padconf.c
index cdceef03fb3b..8c14b34dfef4 100644
--- a/sys/arm/allwinner/a31/a31s_padconf.c
+++ b/sys/arm/allwinner/a31/a31s_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a31/files.a31 b/sys/arm/allwinner/a31/files.a31
index df3ad57da03e..9b3ac550b6fa 100644
--- a/sys/arm/allwinner/a31/files.a31
+++ b/sys/arm/allwinner/a31/files.a31
@@ -1,6 +1,5 @@
-# $FreeBSD$
-arm/allwinner/clkng/ccu_a31.c standard
+dev/clk/allwinner/ccu_a31.c standard
arm/allwinner/a31/a31_padconf.c standard
arm/allwinner/a31/a31_r_padconf.c standard
arm/allwinner/a31/a31s_padconf.c standard
diff --git a/sys/arm/allwinner/a31_dmac.c b/sys/arm/allwinner/a31_dmac.c
index 26e4b45d677d..9dc98342a159 100644
--- a/sys/arm/allwinner/a31_dmac.c
+++ b/sys/arm/allwinner/a31_dmac.c
@@ -29,9 +29,6 @@
* Allwinner DMA controller
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -49,8 +46,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <arm/allwinner/a10_dmac.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
#include "sunxi_dma_if.h"
diff --git a/sys/arm/allwinner/a33/a33_padconf.c b/sys/arm/allwinner/a33/a33_padconf.c
index 9ad3dd4e6caf..6e4732d0d24c 100644
--- a/sys/arm/allwinner/a33/a33_padconf.c
+++ b/sys/arm/allwinner/a33/a33_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a33/files.a33 b/sys/arm/allwinner/a33/files.a33
index c80c476e7dd2..0171368dc62a 100644
--- a/sys/arm/allwinner/a33/files.a33
+++ b/sys/arm/allwinner/a33/files.a33
@@ -1,3 +1,2 @@
-# $FreeBSD$
arm/allwinner/a33/a33_padconf.c standard
diff --git a/sys/arm/allwinner/a33_codec.c b/sys/arm/allwinner/a33_codec.c
index 79866587ed3d..4bf2863b74ef 100644
--- a/sys/arm/allwinner/a33_codec.c
+++ b/sys/arm/allwinner/a33_codec.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
* Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
@@ -24,13 +24,8 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -46,8 +41,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
#include <dev/gpio/gpiobusvar.h>
diff --git a/sys/arm/allwinner/a64/a64_padconf.c b/sys/arm/allwinner/a64/a64_padconf.c
index 08d600bf7112..0732ddf3d4a9 100644
--- a/sys/arm/allwinner/a64/a64_padconf.c
+++ b/sys/arm/allwinner/a64/a64_padconf.c
@@ -21,13 +21,8 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a64/a64_r_padconf.c b/sys/arm/allwinner/a64/a64_r_padconf.c
index afbdfc28f7fc..2d11c5c1b4ab 100644
--- a/sys/arm/allwinner/a64/a64_r_padconf.c
+++ b/sys/arm/allwinner/a64/a64_r_padconf.c
@@ -21,13 +21,8 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a64/sun50i_a64_acodec.c b/sys/arm/allwinner/a64/sun50i_a64_acodec.c
index 0b63ca4a1d35..12c9a86cf361 100644
--- a/sys/arm/allwinner/a64/sun50i_a64_acodec.c
+++ b/sys/arm/allwinner/a64/sun50i_a64_acodec.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
* Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
@@ -24,13 +24,8 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -45,9 +40,9 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/regulator/regulator.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
+#include <dev/regulator/regulator.h>
#include "syscon_if.h"
diff --git a/sys/arm/allwinner/a83t/a83t_padconf.c b/sys/arm/allwinner/a83t/a83t_padconf.c
index 5dc6f2752c1d..f9bfda112bd8 100644
--- a/sys/arm/allwinner/a83t/a83t_padconf.c
+++ b/sys/arm/allwinner/a83t/a83t_padconf.c
@@ -21,13 +21,8 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a83t/a83t_r_padconf.c b/sys/arm/allwinner/a83t/a83t_r_padconf.c
index ed4f08d67415..b114c7d929a4 100644
--- a/sys/arm/allwinner/a83t/a83t_r_padconf.c
+++ b/sys/arm/allwinner/a83t/a83t_r_padconf.c
@@ -21,13 +21,8 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/a83t/files.a83t b/sys/arm/allwinner/a83t/files.a83t
index d8822ae019c4..3a641f12fa5e 100644
--- a/sys/arm/allwinner/a83t/files.a83t
+++ b/sys/arm/allwinner/a83t/files.a83t
@@ -1,6 +1,5 @@
-# $FreeBSD$
-arm/allwinner/clkng/ccu_a83t.c standard
-arm/allwinner/clkng/ccu_sun8i_r.c standard
+dev/clk/allwinner/ccu_a83t.c standard
+dev/clk/allwinner/ccu_sun8i_r.c standard
arm/allwinner/a83t/a83t_padconf.c standard
arm/allwinner/a83t/a83t_r_padconf.c standard
diff --git a/sys/arm/allwinner/allwinner_pinctrl.h b/sys/arm/allwinner/allwinner_pinctrl.h
index d9fb056dff67..67fd13683a46 100644
--- a/sys/arm/allwinner/allwinner_pinctrl.h
+++ b/sys/arm/allwinner/allwinner_pinctrl.h
@@ -21,20 +21,18 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _ALLWINNER_PINCTRL_H_
#define _ALLWINNER_PINCTRL_H_
-#define AW_MAX_FUNC_BY_PIN 8
+#define AW_MAX_FUNC_BY_PIN 15
struct allwinner_pins {
const char *name;
uint8_t port;
uint8_t pin;
- const char *functions[8];
+ const char *functions[AW_MAX_FUNC_BY_PIN];
uint8_t eint_func;
uint8_t eint_num;
uint8_t eint_bank;
diff --git a/sys/arm/allwinner/aw_ccu.c b/sys/arm/allwinner/aw_ccu.c
deleted file mode 100644
index ce31ad4f4c46..000000000000
--- a/sys/arm/allwinner/aw_ccu.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*-
- * Copyright (c) 2016 Jared McNeill <jmcneill@invisible.ca>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * Allwinner oscillator clock
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/mutex.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include "clkdev_if.h"
-
-#define CCU_BASE 0x01c20000
-#define CCU_SIZE 0x400
-
-struct aw_ccu_softc {
- struct simplebus_softc sc;
- bus_space_tag_t bst;
- bus_space_handle_t bsh;
- struct mtx mtx;
- int flags;
-};
-
-static struct ofw_compat_data compat_data[] = {
- { "allwinner,sun7i-a20", 1 },
- { "allwinner,sun6i-a31", 1 },
- { "allwinner,sun6i-a31s", 1 },
- { NULL, 0 }
-};
-
-static int
-aw_ccu_check_addr(struct aw_ccu_softc *sc, bus_addr_t addr,
- bus_space_handle_t *pbsh, bus_size_t *poff)
-{
- if (addr >= CCU_BASE && addr < (CCU_BASE + CCU_SIZE)) {
- *poff = addr - CCU_BASE;
- *pbsh = sc->bsh;
- return (0);
- }
- return (EINVAL);
-}
-
-static int
-aw_ccu_write_4(device_t dev, bus_addr_t addr, uint32_t val)
-{
- struct aw_ccu_softc *sc;
- bus_space_handle_t bsh;
- bus_size_t reg;
-
- sc = device_get_softc(dev);
-
- if (aw_ccu_check_addr(sc, addr, &bsh, &reg) != 0)
- return (EINVAL);
-
- mtx_assert(&sc->mtx, MA_OWNED);
- bus_space_write_4(sc->bst, bsh, reg, val);
-
- return (0);
-}
-
-static int
-aw_ccu_read_4(device_t dev, bus_addr_t addr, uint32_t *val)
-{
- struct aw_ccu_softc *sc;
- bus_space_handle_t bsh;
- bus_size_t reg;
-
- sc = device_get_softc(dev);
-
- if (aw_ccu_check_addr(sc, addr, &bsh, &reg) != 0)
- return (EINVAL);
-
- mtx_assert(&sc->mtx, MA_OWNED);
- *val = bus_space_read_4(sc->bst, bsh, reg);
-
- return (0);
-}
-
-static int
-aw_ccu_modify_4(device_t dev, bus_addr_t addr, uint32_t clr, uint32_t set)
-{
- struct aw_ccu_softc *sc;
- bus_space_handle_t bsh;
- bus_size_t reg;
- uint32_t val;
-
- sc = device_get_softc(dev);
-
- if (aw_ccu_check_addr(sc, addr, &bsh, &reg) != 0)
- return (EINVAL);
-
- mtx_assert(&sc->mtx, MA_OWNED);
- val = bus_space_read_4(sc->bst, bsh, reg);
- val &= ~clr;
- val |= set;
- bus_space_write_4(sc->bst, bsh, reg, val);
-
- return (0);
-}
-
-static void
-aw_ccu_device_lock(device_t dev)
-{
- struct aw_ccu_softc *sc;
-
- sc = device_get_softc(dev);
- mtx_lock(&sc->mtx);
-}
-
-static void
-aw_ccu_device_unlock(device_t dev)
-{
- struct aw_ccu_softc *sc;
-
- sc = device_get_softc(dev);
- mtx_unlock(&sc->mtx);
-}
-
-static const struct ofw_compat_data *
-aw_ccu_search_compatible(void)
-{
- const struct ofw_compat_data *compat;
- phandle_t root;
-
- root = OF_finddevice("/");
- for (compat = compat_data; compat->ocd_str != NULL; compat++)
- if (ofw_bus_node_is_compatible(root, compat->ocd_str))
- break;
-
- return (compat);
-}
-
-static int
-aw_ccu_probe(device_t dev)
-{
- const char *name;
-
- name = ofw_bus_get_name(dev);
-
- if (name == NULL || strcmp(name, "clocks") != 0)
- return (ENXIO);
-
- if (aw_ccu_search_compatible()->ocd_data == 0)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner Clock Control Unit");
- return (BUS_PROBE_SPECIFIC);
-}
-
-static int
-aw_ccu_attach(device_t dev)
-{
- struct aw_ccu_softc *sc;
- phandle_t node, child;
- device_t cdev;
- int error;
-
- sc = device_get_softc(dev);
- node = ofw_bus_get_node(dev);
-
- simplebus_init(dev, node);
-
- sc->flags = aw_ccu_search_compatible()->ocd_data;
-
- /*
- * Map registers. The DT doesn't have a "reg" property
- * for the /clocks node and child nodes have conflicting "reg"
- * properties.
- */
- sc->bst = bus_get_bus_tag(dev);
- error = bus_space_map(sc->bst, CCU_BASE, CCU_SIZE, 0,
- &sc->bsh);
- if (error != 0) {
- device_printf(dev, "couldn't map CCU: %d\n", error);
- return (error);
- }
-
- mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF);
-
- /* Attach child devices */
- for (child = OF_child(node); child > 0; child = OF_peer(child)) {
- cdev = simplebus_add_device(dev, child, 0, NULL, -1, NULL);
- if (cdev != NULL)
- device_probe_and_attach(cdev);
- }
-
- return (bus_generic_attach(dev));
-}
-
-static device_method_t aw_ccu_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aw_ccu_probe),
- DEVMETHOD(device_attach, aw_ccu_attach),
-
- /* clkdev interface */
- DEVMETHOD(clkdev_write_4, aw_ccu_write_4),
- DEVMETHOD(clkdev_read_4, aw_ccu_read_4),
- DEVMETHOD(clkdev_modify_4, aw_ccu_modify_4),
- DEVMETHOD(clkdev_device_lock, aw_ccu_device_lock),
- DEVMETHOD(clkdev_device_unlock, aw_ccu_device_unlock),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_ccu, aw_ccu_driver, aw_ccu_methods,
- sizeof(struct aw_ccu_softc), simplebus_driver);
-
-EARLY_DRIVER_MODULE(aw_ccu, simplebus, aw_ccu_driver, 0, 0,
- BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
-
-MODULE_VERSION(aw_ccu, 1);
diff --git a/sys/arm/allwinner/aw_cir.c b/sys/arm/allwinner/aw_cir.c
index 30a00b99a467..5ebb57f48040 100644
--- a/sys/arm/allwinner/aw_cir.c
+++ b/sys/arm/allwinner/aw_cir.c
@@ -28,9 +28,6 @@
* Allwinner Consumer IR controller
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -43,8 +40,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
#include <dev/evdev/input.h>
#include <dev/evdev/evdev.h>
diff --git a/sys/arm/allwinner/aw_dwc3.c b/sys/arm/allwinner/aw_dwc3.c
deleted file mode 100644
index d99ea66ce1a3..000000000000
--- a/sys/arm/allwinner/aw_dwc3.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2019 Emmanuel Vadot <manu@FreeBSD.Org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Rockchip DWC3 glue
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/gpio.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/fdt/fdt_common.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/ofw/ofw_subr.h>
-
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/phy/phy_usb.h>
-
-static struct ofw_compat_data compat_data[] = {
- { "allwinner,sun50i-h6-dwc3", 1 },
- { NULL, 0 }
-};
-
-struct aw_dwc3_softc {
- struct simplebus_softc sc;
- device_t dev;
- clk_t clk_bus;
- hwreset_t rst_bus;
-};
-
-static int
-aw_dwc3_probe(device_t dev)
-{
- phandle_t node;
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
- return (ENXIO);
-
- /* Binding says that we need a child node for the actual dwc3 controller */
- node = ofw_bus_get_node(dev);
- if (OF_child(node) <= 0)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner H6 DWC3");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aw_dwc3_attach(device_t dev)
-{
- struct aw_dwc3_softc *sc;
- device_t cdev;
- phandle_t node, child;
- int err;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
- node = ofw_bus_get_node(dev);
-
- /* Enable the clocks */
- if (clk_get_by_ofw_name(dev, 0, "bus", &sc->clk_bus) != 0) {
- device_printf(dev, "Cannot get bus clock\n");
- return (ENXIO);
- }
- err = clk_enable(sc->clk_bus);
- if (err != 0) {
- device_printf(dev, "Could not enable clock %s\n",
- clk_get_name(sc->clk_bus));
- return (ENXIO);
- }
-
- /* Put module out of reset */
- if (hwreset_get_by_ofw_name(dev, node, "bus", &sc->rst_bus) == 0) {
- if (hwreset_deassert(sc->rst_bus) != 0) {
- device_printf(dev, "Cannot deassert reset\n");
- return (ENXIO);
- }
- }
-
- simplebus_init(dev, node);
- if (simplebus_fill_ranges(node, &sc->sc) < 0) {
- device_printf(dev, "could not get ranges\n");
- return (ENXIO);
- }
-
- for (child = OF_child(node); child > 0; child = OF_peer(child)) {
- cdev = simplebus_add_device(dev, child, 0, NULL, -1, NULL);
- if (cdev != NULL)
- device_probe_and_attach(cdev);
- }
-
- return (bus_generic_attach(dev));
-}
-
-static device_method_t aw_dwc3_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aw_dwc3_probe),
- DEVMETHOD(device_attach, aw_dwc3_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_dwc3, aw_dwc3_driver, aw_dwc3_methods,
- sizeof(struct aw_dwc3_softc), simplebus_driver);
-DRIVER_MODULE(aw_dwc3, simplebus, aw_dwc3_driver, 0, 0);
diff --git a/sys/arm/allwinner/aw_gmacclk.c b/sys/arm/allwinner/aw_gmacclk.c
index f793cccdc88b..99e69674bd25 100644
--- a/sys/arm/allwinner/aw_gmacclk.c
+++ b/sys/arm/allwinner/aw_gmacclk.c
@@ -21,17 +21,12 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Allwinner GMAC clock
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -44,8 +39,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/ofw_subr.h>
-#include <dev/extres/clk/clk_mux.h>
-#include <dev/extres/clk/clk_gate.h>
+#include <dev/clk/clk_mux.h>
+#include <dev/clk/clk_gate.h>
#include "clkdev_if.h"
diff --git a/sys/arm/allwinner/aw_gpio.c b/sys/arm/allwinner/aw_gpio.c
index e4e8a247e3c7..2061e38a155f 100644
--- a/sys/arm/allwinner/aw_gpio.c
+++ b/sys/arm/allwinner/aw_gpio.c
@@ -1,9 +1,10 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
* Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
* Copyright (c) 2012 Luiz Otavio O Souza.
+ * Copyright (c) 2022 Julien Cassette <julien.cassette@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,8 +29,6 @@
* SUCH DAMAGE.
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,11 +53,11 @@ __FBSDID("$FreeBSD$");
#include <arm/allwinner/aw_machdep.h>
#include <arm/allwinner/allwinner_pinctrl.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/regulator/regulator.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
+#include <dev/regulator/regulator.h>
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__riscv)
#include "opt_soc.h"
#endif
@@ -84,9 +83,18 @@ __FBSDID("$FreeBSD$");
#define AW_PINCTRL 1
#define AW_R_PINCTRL 2
+#if defined(__arm__) || defined(__aarch64__)
+#define IRQ_MEMORY_BARRIER(x) arm_irq_memory_barrier(x)
+#else
+#define IRQ_MEMORY_BARRIER(x) fence()
+#endif
+
struct aw_gpio_conf {
struct allwinner_padconf *padconf;
const char *banks;
+ uint32_t bank_size;
+ uint32_t drv_pin_shift;
+ uint32_t pul_offset;
};
/* Defined in aw_padconf.c */
@@ -95,6 +103,9 @@ extern struct allwinner_padconf a10_padconf;
struct aw_gpio_conf a10_gpio_conf = {
.padconf = &a10_padconf,
.banks = "abcdefghi",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -104,6 +115,9 @@ extern struct allwinner_padconf a13_padconf;
struct aw_gpio_conf a13_gpio_conf = {
.padconf = &a13_padconf,
.banks = "bcdefg",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -113,6 +127,9 @@ extern struct allwinner_padconf a20_padconf;
struct aw_gpio_conf a20_gpio_conf = {
.padconf = &a20_padconf,
.banks = "abcdefghi",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -122,6 +139,9 @@ extern struct allwinner_padconf a31_padconf;
struct aw_gpio_conf a31_gpio_conf = {
.padconf = &a31_padconf,
.banks = "abcdefgh",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -131,6 +151,9 @@ extern struct allwinner_padconf a31s_padconf;
struct aw_gpio_conf a31s_gpio_conf = {
.padconf = &a31s_padconf,
.banks = "abcdefgh",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -139,6 +162,9 @@ extern struct allwinner_padconf a31_r_padconf;
struct aw_gpio_conf a31_r_gpio_conf = {
.padconf = &a31_r_padconf,
.banks = "lm",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -148,6 +174,9 @@ extern struct allwinner_padconf a33_padconf;
struct aw_gpio_conf a33_gpio_conf = {
.padconf = &a33_padconf,
.banks = "bcdefgh",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -158,10 +187,16 @@ extern struct allwinner_padconf h3_r_padconf;
struct aw_gpio_conf h3_gpio_conf = {
.padconf = &h3_padconf,
.banks = "acdefg",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
struct aw_gpio_conf h3_r_gpio_conf = {
.padconf = &h3_r_padconf,
.banks = "l",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -171,11 +206,17 @@ extern struct allwinner_padconf a83t_padconf;
extern struct allwinner_padconf a83t_r_padconf;
struct aw_gpio_conf a83t_gpio_conf = {
.padconf = &a83t_padconf,
- .banks = "bcdefgh"
+ .banks = "bcdefgh",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
struct aw_gpio_conf a83t_r_gpio_conf = {
.padconf = &a83t_r_padconf,
.banks = "l",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -186,10 +227,28 @@ extern struct allwinner_padconf a64_r_padconf;
struct aw_gpio_conf a64_gpio_conf = {
.padconf = &a64_padconf,
.banks = "bcdefgh",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
struct aw_gpio_conf a64_r_gpio_conf = {
.padconf = &a64_r_padconf,
.banks = "l",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
+};
+#endif
+
+/* Defined in d1_padconf.c */
+#ifdef SOC_ALLWINNER_D1
+extern struct allwinner_padconf d1_padconf;
+struct aw_gpio_conf d1_gpio_conf = {
+ .padconf = &d1_padconf,
+ .banks = "bcdefg",
+ .bank_size = 0x30,
+ .drv_pin_shift = 2,
+ .pul_offset = 0x24,
};
#endif
@@ -200,10 +259,16 @@ extern struct allwinner_padconf h6_r_padconf;
struct aw_gpio_conf h6_gpio_conf = {
.padconf = &h6_padconf,
.banks = "cdfgh",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
struct aw_gpio_conf h6_r_gpio_conf = {
.padconf = &h6_r_padconf,
.banks = "lm",
+ .bank_size = 0x24,
+ .drv_pin_shift = 1,
+ .pul_offset = 0x1C,
};
#endif
@@ -242,6 +307,9 @@ static struct ofw_compat_data compat_data[] = {
{"allwinner,sun50i-a64-pinctrl", (uintptr_t)&a64_gpio_conf},
{"allwinner,sun50i-a64-r-pinctrl", (uintptr_t)&a64_r_gpio_conf},
#endif
+#ifdef SOC_ALLWINNER_D1
+ {"allwinner,sun20i-d1-pinctrl", (uintptr_t)&d1_gpio_conf},
+#endif
#ifdef SOC_ALLWINNER_H6
{"allwinner,sun50i-h6-pinctrl", (uintptr_t)&h6_gpio_conf},
{"allwinner,sun50i-h6-r-pinctrl", (uintptr_t)&h6_r_gpio_conf},
@@ -295,10 +363,16 @@ static struct resource_spec aw_gpio_res_spec[] = {
#define AW_GPIO_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->sc_mtx)
#define AW_GPIO_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
-#define AW_GPIO_GP_CFG(_bank, _idx) 0x00 + ((_bank) * 0x24) + ((_idx) << 2)
-#define AW_GPIO_GP_DAT(_bank) 0x10 + ((_bank) * 0x24)
-#define AW_GPIO_GP_DRV(_bank, _idx) 0x14 + ((_bank) * 0x24) + ((_idx) << 2)
-#define AW_GPIO_GP_PUL(_bank, _idx) 0x1c + ((_bank) * 0x24) + ((_idx) << 2)
+#define AW_GPIO_GP_BASE(_sc, _bank) ((_sc)->conf->bank_size * (_bank))
+
+#define AW_GPIO_GP_CFG(_sc, _bank, _idx) \
+ (AW_GPIO_GP_BASE(_sc, _bank) + 0x00 + ((_idx) << 2))
+#define AW_GPIO_GP_DAT(_sc, _bank) \
+ (AW_GPIO_GP_BASE(_sc, _bank) + 0x10)
+#define AW_GPIO_GP_DRV(_sc, _bank, _idx) \
+ (AW_GPIO_GP_BASE(_sc, _bank) + 0x14 + ((_idx) << 2))
+#define AW_GPIO_GP_PUL(_sc, _bank, _idx) \
+ (AW_GPIO_GP_BASE(_sc, _bank) + (_sc)->conf->pul_offset + ((_idx) << 2))
#define AW_GPIO_GP_INT_BASE(_bank) (0x200 + 0x20 * _bank)
@@ -348,9 +422,9 @@ aw_gpio_get_function(struct aw_gpio_softc *sc, uint32_t pin)
pin = sc->conf->padconf->pins[pin].pin;
offset = ((pin & 0x07) << 2);
- func = AW_GPIO_READ(sc, AW_GPIO_GP_CFG(bank, pin >> 3));
+ func = AW_GPIO_READ(sc, AW_GPIO_GP_CFG(sc, bank, pin >> 3));
- return ((func >> offset) & 0x7);
+ return ((func >> offset) & 0xF);
}
static int
@@ -369,10 +443,10 @@ aw_gpio_set_function(struct aw_gpio_softc *sc, uint32_t pin, uint32_t f)
pin = sc->conf->padconf->pins[pin].pin;
offset = ((pin & 0x07) << 2);
- data = AW_GPIO_READ(sc, AW_GPIO_GP_CFG(bank, pin >> 3));
- data &= ~(7 << offset);
+ data = AW_GPIO_READ(sc, AW_GPIO_GP_CFG(sc, bank, pin >> 3));
+ data &= ~(0xF << offset);
data |= (f << offset);
- AW_GPIO_WRITE(sc, AW_GPIO_GP_CFG(bank, pin >> 3), data);
+ AW_GPIO_WRITE(sc, AW_GPIO_GP_CFG(sc, bank, pin >> 3), data);
return (0);
}
@@ -389,7 +463,7 @@ aw_gpio_get_pud(struct aw_gpio_softc *sc, uint32_t pin)
pin = sc->conf->padconf->pins[pin].pin;
offset = ((pin & 0x0f) << 1);
- val = AW_GPIO_READ(sc, AW_GPIO_GP_PUL(bank, pin >> 4));
+ val = AW_GPIO_READ(sc, AW_GPIO_GP_PUL(sc, bank, pin >> 4));
return ((val >> offset) & AW_GPIO_PUD_MASK);
}
@@ -409,25 +483,26 @@ aw_gpio_set_pud(struct aw_gpio_softc *sc, uint32_t pin, uint32_t state)
pin = sc->conf->padconf->pins[pin].pin;
offset = ((pin & 0x0f) << 1);
- val = AW_GPIO_READ(sc, AW_GPIO_GP_PUL(bank, pin >> 4));
+ val = AW_GPIO_READ(sc, AW_GPIO_GP_PUL(sc, bank, pin >> 4));
val &= ~(AW_GPIO_PUD_MASK << offset);
val |= (state << offset);
- AW_GPIO_WRITE(sc, AW_GPIO_GP_PUL(bank, pin >> 4), val);
+ AW_GPIO_WRITE(sc, AW_GPIO_GP_PUL(sc, bank, pin >> 4), val);
}
static uint32_t
aw_gpio_get_drv(struct aw_gpio_softc *sc, uint32_t pin)
{
- uint32_t bank, offset, val;
+ uint32_t bank, idx, offset, val;
/* Must be called with lock held. */
AW_GPIO_LOCK_ASSERT(sc);
bank = sc->conf->padconf->pins[pin].port;
pin = sc->conf->padconf->pins[pin].pin;
- offset = ((pin & 0x0f) << 1);
+ offset = (pin << sc->conf->drv_pin_shift) & 0x1F;
+ idx = (pin << sc->conf->drv_pin_shift) >> 5;
- val = AW_GPIO_READ(sc, AW_GPIO_GP_DRV(bank, pin >> 4));
+ val = AW_GPIO_READ(sc, AW_GPIO_GP_DRV(sc, bank, idx));
return ((val >> offset) & AW_GPIO_DRV_MASK);
}
@@ -435,7 +510,7 @@ aw_gpio_get_drv(struct aw_gpio_softc *sc, uint32_t pin)
static void
aw_gpio_set_drv(struct aw_gpio_softc *sc, uint32_t pin, uint32_t drive)
{
- uint32_t bank, offset, val;
+ uint32_t bank, idx, offset, val;
if (aw_gpio_get_drv(sc, pin) == drive)
return;
@@ -445,12 +520,13 @@ aw_gpio_set_drv(struct aw_gpio_softc *sc, uint32_t pin, uint32_t drive)
bank = sc->conf->padconf->pins[pin].port;
pin = sc->conf->padconf->pins[pin].pin;
- offset = ((pin & 0x0f) << 1);
+ offset = (pin << sc->conf->drv_pin_shift) & 0x1F;
+ idx = (pin << sc->conf->drv_pin_shift) >> 5;
- val = AW_GPIO_READ(sc, AW_GPIO_GP_DRV(bank, pin >> 4));
+ val = AW_GPIO_READ(sc, AW_GPIO_GP_DRV(sc, bank, idx));
val &= ~(AW_GPIO_DRV_MASK << offset);
val |= (drive << offset);
- AW_GPIO_WRITE(sc, AW_GPIO_GP_DRV(bank, pin >> 4), val);
+ AW_GPIO_WRITE(sc, AW_GPIO_GP_DRV(sc, bank, idx), val);
}
static int
@@ -626,12 +702,12 @@ aw_gpio_pin_set_locked(struct aw_gpio_softc *sc, uint32_t pin,
bank = sc->conf->padconf->pins[pin].port;
pin = sc->conf->padconf->pins[pin].pin;
- data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(bank));
+ data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(sc, bank));
if (value)
data |= (1 << pin);
else
data &= ~(1 << pin);
- AW_GPIO_WRITE(sc, AW_GPIO_GP_DAT(bank), data);
+ AW_GPIO_WRITE(sc, AW_GPIO_GP_DAT(sc, bank), data);
return (0);
}
@@ -656,18 +732,30 @@ aw_gpio_pin_get_locked(struct aw_gpio_softc *sc,uint32_t pin,
unsigned int *val)
{
uint32_t bank, reg_data;
+ int32_t func;
+ int err;
AW_GPIO_LOCK_ASSERT(sc);
if (pin > sc->conf->padconf->npins)
return (EINVAL);
+ func = aw_gpio_get_function(sc, pin);
+ if (func == sc->conf->padconf->pins[pin].eint_func) { /* "pl_eintX */
+ err = aw_gpio_set_function(sc, pin, AW_GPIO_INPUT);
+ if (err != 0)
+ return (err);
+ }
+
bank = sc->conf->padconf->pins[pin].port;
pin = sc->conf->padconf->pins[pin].pin;
- reg_data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(bank));
+ reg_data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(sc, bank));
*val = (reg_data & (1 << pin)) ? 1 : 0;
+ if (func == sc->conf->padconf->pins[pin].eint_func)
+ (void)aw_gpio_set_function(sc, pin, func);
+
return (0);
}
@@ -769,12 +857,12 @@ aw_gpio_pin_toggle(device_t dev, uint32_t pin)
pin = sc->conf->padconf->pins[pin].pin;
AW_GPIO_LOCK(sc);
- data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(bank));
+ data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(sc, bank));
if (data & (1 << pin))
data &= ~(1 << pin);
else
data |= (1 << pin);
- AW_GPIO_WRITE(sc, AW_GPIO_GP_DAT(bank), data);
+ AW_GPIO_WRITE(sc, AW_GPIO_GP_DAT(sc, bank), data);
AW_GPIO_UNLOCK(sc);
return (0);
@@ -803,9 +891,9 @@ aw_gpio_pin_access_32(device_t dev, uint32_t first_pin, uint32_t clear_pins,
return (EINVAL);
AW_GPIO_LOCK(sc);
- data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(bank));
+ data = AW_GPIO_READ(sc, AW_GPIO_GP_DAT(sc, bank));
if ((clear_pins | change_pins) != 0)
- AW_GPIO_WRITE(sc, AW_GPIO_GP_DAT(bank),
+ AW_GPIO_WRITE(sc, AW_GPIO_GP_DAT(sc, bank),
(data & ~clear_pins) ^ change_pins);
AW_GPIO_UNLOCK(sc);
@@ -1066,10 +1154,6 @@ aw_gpio_attach(device_t dev)
aw_gpio_register_isrcs(sc);
intr_pic_register(dev, OF_xref_from_node(ofw_bus_get_node(dev)));
- sc->sc_busdev = gpiobus_attach_bus(dev);
- if (sc->sc_busdev == NULL)
- goto fail;
-
/*
* Register as a pinctrl device
*/
@@ -1078,6 +1162,10 @@ aw_gpio_attach(device_t dev)
fdt_pinctrl_register(dev, "allwinner,pins");
fdt_pinctrl_configure_tree(dev);
+ sc->sc_busdev = gpiobus_attach_bus(dev);
+ if (sc->sc_busdev == NULL)
+ goto fail;
+
config_intrhook_oneshot(aw_gpio_enable_bank_supply, sc);
return (0);
@@ -1398,7 +1486,7 @@ aw_gpio_pic_post_filter(device_t dev, struct intr_irqsrc *isrc)
sc = device_get_softc(dev);
gi = (struct gpio_irqsrc *)isrc;
- arm_irq_memory_barrier(0);
+ IRQ_MEMORY_BARRIER(0);
AW_GPIO_WRITE(sc, AW_GPIO_GP_INT_STA(gi->bank), 1 << gi->intnum);
}
@@ -1411,7 +1499,7 @@ aw_gpio_pic_post_ithread(device_t dev, struct intr_irqsrc *isrc)
sc = device_get_softc(dev);
gi = (struct gpio_irqsrc *)isrc;
- arm_irq_memory_barrier(0);
+ IRQ_MEMORY_BARRIER(0);
AW_GPIO_WRITE(sc, AW_GPIO_GP_INT_STA(gi->bank), 1 << gi->intnum);
aw_gpio_pic_enable_intr(dev, isrc);
}
diff --git a/sys/arm/allwinner/aw_i2s.c b/sys/arm/allwinner/aw_i2s.c
index 961de578110d..87dfb109363f 100644
--- a/sys/arm/allwinner/aw_i2s.c
+++ b/sys/arm/allwinner/aw_i2s.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
* Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
@@ -24,13 +24,8 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -45,8 +40,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
#include "syscon_if.h"
diff --git a/sys/arm/allwinner/aw_if_dwc.c b/sys/arm/allwinner/aw_if_dwc.c
deleted file mode 100644
index 067afbdbd9c4..000000000000
--- a/sys/arm/allwinner/aw_if_dwc.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*-
- * Copyright (c) 2015 Luiz Otavio O Souza <loos@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-
-#include <machine/bus.h>
-
-#include <dev/dwc/if_dwc.h>
-#include <dev/dwc/if_dwcvar.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <arm/allwinner/aw_machdep.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/regulator/regulator.h>
-
-#include "if_dwc_if.h"
-
-static int
-a20_if_dwc_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "allwinner,sun7i-a20-gmac"))
- return (ENXIO);
- device_set_desc(dev, "A20 Gigabit Ethernet Controller");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-a20_if_dwc_init(device_t dev)
-{
- struct dwc_softc *sc;
- const char *tx_parent_name;
- clk_t clk_tx, clk_tx_parent;
- regulator_t reg;
- int error;
-
- sc = device_get_softc(dev);
-
- /* Configure PHY for MII or RGMII mode */
- switch(sc->phy_mode) {
- case PHY_MODE_RGMII:
- tx_parent_name = "gmac_int_tx";
- break;
- case PHY_MODE_MII:
- tx_parent_name = "mii_phy_tx";
- break;
- default:
- device_printf(dev, "unsupported PHY connection type: %d",
- sc->phy_mode);
- return (ENXIO);
- }
-
- error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx);
- if (error != 0) {
- device_printf(dev, "could not get tx clk\n");
- return (error);
- }
- error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent);
- if (error != 0) {
- device_printf(dev, "could not get clock '%s'\n",
- tx_parent_name);
- return (error);
- }
- error = clk_set_parent_by_clk(clk_tx, clk_tx_parent);
- if (error != 0) {
- device_printf(dev, "could not set tx clk parent\n");
- return (error);
- }
-
- /* Enable PHY regulator if applicable */
- if (regulator_get_by_ofw_property(dev, 0, "phy-supply", &reg) == 0) {
- error = regulator_enable(reg);
- if (error != 0) {
- device_printf(dev, "could not enable PHY regulator\n");
- return (error);
- }
- }
-
- return (0);
-}
-
-static int
-a20_if_dwc_mac_type(device_t dev)
-{
-
- return (DWC_GMAC_NORMAL_DESC);
-}
-
-static int
-a20_if_dwc_mii_clk(device_t dev)
-{
-
- return (GMAC_MII_CLK_150_250M_DIV102);
-}
-
-static device_method_t a20_dwc_methods[] = {
- DEVMETHOD(device_probe, a20_if_dwc_probe),
-
- DEVMETHOD(if_dwc_init, a20_if_dwc_init),
- DEVMETHOD(if_dwc_mac_type, a20_if_dwc_mac_type),
- DEVMETHOD(if_dwc_mii_clk, a20_if_dwc_mii_clk),
-
- DEVMETHOD_END
-};
-
-extern driver_t dwc_driver;
-
-DEFINE_CLASS_1(dwc, a20_dwc_driver, a20_dwc_methods, sizeof(struct dwc_softc),
- dwc_driver);
-DRIVER_MODULE(a20_dwc, simplebus, a20_dwc_driver, 0, 0);
-
-MODULE_DEPEND(a20_dwc, dwc, 1, 1, 1);
diff --git a/sys/arm/allwinner/aw_machdep.c b/sys/arm/allwinner/aw_machdep.c
index 688012d5f14c..8b6bdd9805d1 100644
--- a/sys/arm/allwinner/aw_machdep.c
+++ b/sys/arm/allwinner/aw_machdep.c
@@ -33,9 +33,6 @@
#include "opt_ddb.h"
#include "opt_platform.h"
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
diff --git a/sys/arm/allwinner/aw_machdep.h b/sys/arm/allwinner/aw_machdep.h
index 11e116ddc6a4..200105d00027 100644
--- a/sys/arm/allwinner/aw_machdep.h
+++ b/sys/arm/allwinner/aw_machdep.h
@@ -22,8 +22,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#ifndef AW_MACHDEP_H
diff --git a/sys/arm/allwinner/aw_mmc.c b/sys/arm/allwinner/aw_mmc.c
index 3decbba2e125..a8add957dc74 100644
--- a/sys/arm/allwinner/aw_mmc.c
+++ b/sys/arm/allwinner/aw_mmc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Emmanuel Vadot <manu@FreeBSD.org>
* Copyright (c) 2013 Alexander Fedorov
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -55,9 +52,9 @@ __FBSDID("$FreeBSD$");
#include <dev/mmc/mmc_fdt_helpers.h>
#include <arm/allwinner/aw_mmc.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/regulator/regulator.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
+#include <dev/regulator/regulator.h>
#include "opt_mmccam.h"
@@ -87,21 +84,26 @@ __FBSDID("$FreeBSD$");
struct aw_mmc_conf {
uint32_t dma_xferlen;
+ uint32_t dma_desc_shift;
bool mask_data0;
bool can_calibrate;
bool new_timing;
+ bool zero_is_skip;
};
static const struct aw_mmc_conf a10_mmc_conf = {
.dma_xferlen = 0x2000,
+ .dma_desc_shift = 0,
};
static const struct aw_mmc_conf a13_mmc_conf = {
.dma_xferlen = 0x10000,
+ .dma_desc_shift = 0,
};
static const struct aw_mmc_conf a64_mmc_conf = {
.dma_xferlen = 0x10000,
+ .dma_desc_shift = 0,
.mask_data0 = true,
.can_calibrate = true,
.new_timing = true,
@@ -109,13 +111,24 @@ static const struct aw_mmc_conf a64_mmc_conf = {
static const struct aw_mmc_conf a64_emmc_conf = {
.dma_xferlen = 0x2000,
+ .dma_desc_shift = 0,
.can_calibrate = true,
};
+static const struct aw_mmc_conf d1_mmc_conf = {
+ .dma_xferlen = 0x1000,
+ .dma_desc_shift = 2,
+ .mask_data0 = true,
+ .can_calibrate = true,
+ .new_timing = true,
+ .zero_is_skip = true,
+};
+
static struct ofw_compat_data compat_data[] = {
{"allwinner,sun4i-a10-mmc", (uintptr_t)&a10_mmc_conf},
{"allwinner,sun5i-a13-mmc", (uintptr_t)&a13_mmc_conf},
{"allwinner,sun7i-a20-mmc", (uintptr_t)&a13_mmc_conf},
+ {"allwinner,sun20i-d1-mmc", (uintptr_t)&d1_mmc_conf},
{"allwinner,sun50i-a64-mmc", (uintptr_t)&a64_mmc_conf},
{"allwinner,sun50i-a64-emmc", (uintptr_t)&a64_emmc_conf},
{NULL, 0}
@@ -325,32 +338,29 @@ aw_mmc_helper_cd_handler(device_t dev, bool present)
#ifdef MMCCAM
mmc_cam_sim_discover(&sc->mmc_sim);
#else
- AW_MMC_LOCK(sc);
+ bus_topo_lock();
if (present) {
if (sc->child == NULL) {
if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
device_printf(sc->aw_dev, "Card inserted\n");
- sc->child = device_add_child(sc->aw_dev, "mmc", -1);
- AW_MMC_UNLOCK(sc);
+ sc->child = device_add_child(sc->aw_dev, "mmc", DEVICE_UNIT_ANY);
if (sc->child) {
device_set_ivars(sc->child, sc);
(void)device_probe_and_attach(sc->child);
}
- } else
- AW_MMC_UNLOCK(sc);
+ }
} else {
/* Card isn't present, detach if necessary */
if (sc->child != NULL) {
if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
device_printf(sc->aw_dev, "Card removed\n");
- AW_MMC_UNLOCK(sc);
device_delete_child(sc->aw_dev, sc->child);
sc->child = NULL;
- } else
- AW_MMC_UNLOCK(sc);
+ }
}
+ bus_topo_unlock();
#endif /* MMCCAM */
}
@@ -485,7 +495,6 @@ static int
aw_mmc_detach(device_t dev)
{
struct aw_mmc_softc *sc;
- device_t d;
sc = device_get_softc(dev);
@@ -497,12 +506,7 @@ aw_mmc_detach(device_t dev)
callout_drain(&sc->aw_timeoutc);
- AW_MMC_LOCK(sc);
- d = sc->child;
- sc->child = NULL;
- AW_MMC_UNLOCK(sc);
- if (d != NULL)
- device_delete_child(sc->aw_dev, d);
+ device_delete_children(sc->aw_dev);
aw_mmc_teardown_dma(sc);
@@ -619,16 +623,18 @@ aw_dma_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int err)
dma_desc = sc->aw_dma_desc;
for (i = 0; i < nsegs; i++) {
- if (segs[i].ds_len == sc->aw_mmc_conf->dma_xferlen)
+ if ((segs[i].ds_len == sc->aw_mmc_conf->dma_xferlen) &&
+ !sc->aw_mmc_conf->zero_is_skip)
dma_desc[i].buf_size = 0; /* Size of 0 indicate max len */
else
dma_desc[i].buf_size = segs[i].ds_len;
- dma_desc[i].buf_addr = segs[i].ds_addr;
+ dma_desc[i].buf_addr = segs[i].ds_addr >>
+ sc->aw_mmc_conf->dma_desc_shift;
dma_desc[i].config = AW_MMC_DMA_CONFIG_CH |
- AW_MMC_DMA_CONFIG_OWN | AW_MMC_DMA_CONFIG_DIC;
-
- dma_desc[i].next = sc->aw_dma_desc_phys +
- ((i + 1) * sizeof(struct aw_mmc_dma_desc));
+ AW_MMC_DMA_CONFIG_OWN | AW_MMC_DMA_CONFIG_DIC;
+ dma_desc[i].next = (sc->aw_dma_desc_phys +
+ (i + 1) * sizeof(struct aw_mmc_dma_desc)) >>
+ sc->aw_mmc_conf->dma_desc_shift;
}
dma_desc[0].config |= AW_MMC_DMA_CONFIG_FD;
@@ -690,7 +696,8 @@ aw_mmc_prepare_dma(struct aw_mmc_softc *sc)
AW_MMC_WRITE_4(sc, AW_MMC_IDIE, val);
/* Set DMA descritptor list address */
- AW_MMC_WRITE_4(sc, AW_MMC_DLBA, sc->aw_dma_desc_phys);
+ AW_MMC_WRITE_4(sc, AW_MMC_DLBA, sc->aw_dma_desc_phys >>
+ sc->aw_mmc_conf->dma_desc_shift);
/* FIFO trigger level */
AW_MMC_WRITE_4(sc, AW_MMC_FWLR, AW_MMC_DMA_FTRGLEVEL);
diff --git a/sys/arm/allwinner/aw_mmc.h b/sys/arm/allwinner/aw_mmc.h
index 18308b55cc43..de15afd6de22 100644
--- a/sys/arm/allwinner/aw_mmc.h
+++ b/sys/arm/allwinner/aw_mmc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Emmanuel Vadot <manu@FreeBSD.org>
* Copyright (c) 2013 Alexander Fedorov <alexander.fedorov@rtlservice.com>
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _AW_MMC_H_
diff --git a/sys/arm/allwinner/aw_mp.c b/sys/arm/allwinner/aw_mp.c
index df798443a44a..0c773f71ac41 100644
--- a/sys/arm/allwinner/aw_mp.c
+++ b/sys/arm/allwinner/aw_mp.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -39,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#include <machine/cpu.h>
-#include <machine/cpu-v6.h>
#include <machine/smp.h>
#include <machine/fdt.h>
#include <machine/intr.h>
diff --git a/sys/arm/allwinner/aw_mp.h b/sys/arm/allwinner/aw_mp.h
index c86bd08087c3..726ae9189eef 100644
--- a/sys/arm/allwinner/aw_mp.h
+++ b/sys/arm/allwinner/aw_mp.h
@@ -20,8 +20,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _AW_MP_H_
diff --git a/sys/arm/allwinner/aw_nmi.c b/sys/arm/allwinner/aw_nmi.c
index d39f3765901d..febf970c7ffb 100644
--- a/sys/arm/allwinner/aw_nmi.c
+++ b/sys/arm/allwinner/aw_nmi.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "opt_platform.h"
#include <sys/param.h>
diff --git a/sys/arm/allwinner/aw_pwm.c b/sys/arm/allwinner/aw_pwm.c
deleted file mode 100644
index 625edf19ebb1..000000000000
--- a/sys/arm/allwinner/aw_pwm.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2018 Emmanuel Vadot <manu@FreeBSD.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/rman.h>
-#include <sys/resource.h>
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include "pwmbus_if.h"
-
-#define AW_PWM_CTRL 0x00
-#define AW_PWM_CTRL_PRESCALE_MASK 0xF
-#define AW_PWM_CTRL_EN (1 << 4)
-#define AW_PWM_CTRL_ACTIVE_LEVEL_HIGH (1 << 5)
-#define AW_PWM_CTRL_GATE (1 << 6)
-#define AW_PWM_CTRL_MODE_MASK 0x80
-#define AW_PWM_CTRL_PULSE_MODE (1 << 7)
-#define AW_PWM_CTRL_CYCLE_MODE (0 << 7)
-#define AW_PWM_CTRL_PULSE_START (1 << 8)
-#define AW_PWM_CTRL_CLK_BYPASS (1 << 9)
-#define AW_PWM_CTRL_PERIOD_BUSY (1 << 28)
-
-#define AW_PWM_PERIOD 0x04
-#define AW_PWM_PERIOD_TOTAL_MASK 0xFFFF
-#define AW_PWM_PERIOD_TOTAL_SHIFT 16
-#define AW_PWM_PERIOD_ACTIVE_MASK 0xFFFF
-#define AW_PWM_PERIOD_ACTIVE_SHIFT 0
-
-#define AW_PWM_MAX_FREQ 24000000
-
-#define NS_PER_SEC 1000000000
-
-static struct ofw_compat_data compat_data[] = {
- { "allwinner,sun5i-a13-pwm", 1 },
- { "allwinner,sun8i-h3-pwm", 1 },
- { NULL, 0 }
-};
-
-static struct resource_spec aw_pwm_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-struct aw_pwm_softc {
- device_t dev;
- device_t busdev;
- clk_t clk;
- struct resource *res;
-
- uint64_t clk_freq;
- unsigned int period;
- unsigned int duty;
- uint32_t flags;
- bool enabled;
-};
-
-static uint32_t aw_pwm_clk_prescaler[] = {
- 120,
- 180,
- 240,
- 360,
- 480,
- 0,
- 0,
- 0,
- 12000,
- 24000,
- 36000,
- 48000,
- 72000,
- 0,
- 0,
- 1,
-};
-
-#define AW_PWM_READ(sc, reg) bus_read_4((sc)->res, (reg))
-#define AW_PWM_WRITE(sc, reg, val) bus_write_4((sc)->res, (reg), (val))
-
-static int aw_pwm_probe(device_t dev);
-static int aw_pwm_attach(device_t dev);
-static int aw_pwm_detach(device_t dev);
-
-static int
-aw_pwm_probe(device_t dev)
-{
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner PWM");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aw_pwm_attach(device_t dev)
-{
- struct aw_pwm_softc *sc;
- uint64_t clk_freq;
- uint32_t reg;
- phandle_t node;
- int error;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
-
- error = clk_get_by_ofw_index(dev, 0, 0, &sc->clk);
- if (error != 0) {
- device_printf(dev, "cannot get clock\n");
- goto fail;
- }
- error = clk_enable(sc->clk);
- if (error != 0) {
- device_printf(dev, "cannot enable clock\n");
- goto fail;
- }
-
- error = clk_get_freq(sc->clk, &sc->clk_freq);
- if (error != 0) {
- device_printf(dev, "cannot get clock frequency\n");
- goto fail;
- }
-
- if (bus_alloc_resources(dev, aw_pwm_spec, &sc->res) != 0) {
- device_printf(dev, "cannot allocate resources for device\n");
- error = ENXIO;
- goto fail;
- }
-
- /* Read the configuration left by U-Boot */
- reg = AW_PWM_READ(sc, AW_PWM_CTRL);
- if (reg & (AW_PWM_CTRL_GATE | AW_PWM_CTRL_EN))
- sc->enabled = true;
-
- reg = AW_PWM_READ(sc, AW_PWM_CTRL);
- reg &= AW_PWM_CTRL_PRESCALE_MASK;
- if (reg > nitems(aw_pwm_clk_prescaler)) {
- device_printf(dev, "Bad prescaler %x, cannot guess current settings\n", reg);
- goto skipcfg;
- }
- clk_freq = sc->clk_freq / aw_pwm_clk_prescaler[reg];
-
- reg = AW_PWM_READ(sc, AW_PWM_PERIOD);
- sc->period = NS_PER_SEC /
- (clk_freq / ((reg >> AW_PWM_PERIOD_TOTAL_SHIFT) & AW_PWM_PERIOD_TOTAL_MASK));
- sc->duty = NS_PER_SEC /
- (clk_freq / ((reg >> AW_PWM_PERIOD_ACTIVE_SHIFT) & AW_PWM_PERIOD_ACTIVE_MASK));
-
-skipcfg:
- /*
- * Note that we don't check for failure to attach pwmbus -- even without
- * it we can still service clients who connect via fdt xref data.
- */
- node = ofw_bus_get_node(dev);
- OF_device_register_xref(OF_xref_from_node(node), dev);
-
- sc->busdev = device_add_child(dev, "pwmbus", -1);
-
- return (bus_generic_attach(dev));
-
-fail:
- aw_pwm_detach(dev);
- return (error);
-}
-
-static int
-aw_pwm_detach(device_t dev)
-{
- struct aw_pwm_softc *sc;
- int error;
-
- sc = device_get_softc(dev);
-
- if ((error = bus_generic_detach(sc->dev)) != 0) {
- device_printf(sc->dev, "cannot detach child devices\n");
- return (error);
- }
-
- if (sc->busdev != NULL)
- device_delete_child(dev, sc->busdev);
-
- if (sc->res != NULL)
- bus_release_resources(dev, aw_pwm_spec, &sc->res);
-
- return (0);
-}
-
-static phandle_t
-aw_pwm_get_node(device_t bus, device_t dev)
-{
-
- /*
- * Share our controller node with our pwmbus child; it instantiates
- * devices by walking the children contained within our node.
- */
- return ofw_bus_get_node(bus);
-}
-
-static int
-aw_pwm_channel_count(device_t dev, u_int *nchannel)
-{
-
- *nchannel = 1;
-
- return (0);
-}
-
-static int
-aw_pwm_channel_config(device_t dev, u_int channel, u_int period, u_int duty)
-{
- struct aw_pwm_softc *sc;
- uint64_t period_freq, duty_freq;
- uint64_t clk_rate, div;
- uint32_t reg;
- int prescaler;
- int i;
-
- sc = device_get_softc(dev);
-
- period_freq = NS_PER_SEC / period;
- if (period_freq > AW_PWM_MAX_FREQ)
- return (EINVAL);
-
- /*
- * FIXME. The hardware is capable of sub-Hz frequencies, that is,
- * periods longer than a second. But the current code cannot deal
- * with those properly.
- */
- if (period_freq == 0)
- return (EINVAL);
-
- /*
- * FIXME. There is a great loss of precision when the period and the
- * duty are near 1 second. In some cases period_freq and duty_freq can
- * be equal even if the period and the duty are significantly different.
- */
- duty_freq = NS_PER_SEC / duty;
- if (duty_freq < period_freq) {
- device_printf(sc->dev, "duty < period\n");
- return (EINVAL);
- }
-
- /* First test without prescaler */
- clk_rate = AW_PWM_MAX_FREQ;
- prescaler = AW_PWM_CTRL_PRESCALE_MASK;
- div = AW_PWM_MAX_FREQ / period_freq;
- if ((div - 1) > AW_PWM_PERIOD_TOTAL_MASK) {
- /* Test all prescaler */
- for (i = 0; i < nitems(aw_pwm_clk_prescaler); i++) {
- if (aw_pwm_clk_prescaler[i] == 0)
- continue;
- div = AW_PWM_MAX_FREQ / aw_pwm_clk_prescaler[i] / period_freq;
- if ((div - 1) < AW_PWM_PERIOD_TOTAL_MASK ) {
- prescaler = i;
- clk_rate = AW_PWM_MAX_FREQ / aw_pwm_clk_prescaler[i];
- break;
- }
- }
- if (prescaler == AW_PWM_CTRL_PRESCALE_MASK)
- return (EINVAL);
- }
-
- reg = AW_PWM_READ(sc, AW_PWM_CTRL);
-
- /* Write the prescalar */
- reg &= ~AW_PWM_CTRL_PRESCALE_MASK;
- reg |= prescaler;
-
- reg &= ~AW_PWM_CTRL_MODE_MASK;
- reg |= AW_PWM_CTRL_CYCLE_MODE;
-
- reg &= ~AW_PWM_CTRL_PULSE_START;
- reg &= ~AW_PWM_CTRL_CLK_BYPASS;
-
- AW_PWM_WRITE(sc, AW_PWM_CTRL, reg);
-
- /* Write the total/active cycles */
- reg = ((clk_rate / period_freq - 1) << AW_PWM_PERIOD_TOTAL_SHIFT) |
- ((clk_rate / duty_freq) << AW_PWM_PERIOD_ACTIVE_SHIFT);
- AW_PWM_WRITE(sc, AW_PWM_PERIOD, reg);
-
- sc->period = period;
- sc->duty = duty;
-
- return (0);
-}
-
-static int
-aw_pwm_channel_get_config(device_t dev, u_int channel, u_int *period, u_int *duty)
-{
- struct aw_pwm_softc *sc;
-
- sc = device_get_softc(dev);
-
- *period = sc->period;
- *duty = sc->duty;
-
- return (0);
-}
-
-static int
-aw_pwm_channel_enable(device_t dev, u_int channel, bool enable)
-{
- struct aw_pwm_softc *sc;
- uint32_t reg;
-
- sc = device_get_softc(dev);
-
- if (enable && sc->enabled)
- return (0);
-
- reg = AW_PWM_READ(sc, AW_PWM_CTRL);
- if (enable)
- reg |= AW_PWM_CTRL_GATE | AW_PWM_CTRL_EN;
- else
- reg &= ~(AW_PWM_CTRL_GATE | AW_PWM_CTRL_EN);
-
- AW_PWM_WRITE(sc, AW_PWM_CTRL, reg);
-
- sc->enabled = enable;
-
- return (0);
-}
-
-static int
-aw_pwm_channel_is_enabled(device_t dev, u_int channel, bool *enabled)
-{
- struct aw_pwm_softc *sc;
-
- sc = device_get_softc(dev);
-
- *enabled = sc->enabled;
-
- return (0);
-}
-
-static device_method_t aw_pwm_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aw_pwm_probe),
- DEVMETHOD(device_attach, aw_pwm_attach),
- DEVMETHOD(device_detach, aw_pwm_detach),
-
- /* ofw_bus interface */
- DEVMETHOD(ofw_bus_get_node, aw_pwm_get_node),
-
- /* pwmbus interface */
- DEVMETHOD(pwmbus_channel_count, aw_pwm_channel_count),
- DEVMETHOD(pwmbus_channel_config, aw_pwm_channel_config),
- DEVMETHOD(pwmbus_channel_get_config, aw_pwm_channel_get_config),
- DEVMETHOD(pwmbus_channel_enable, aw_pwm_channel_enable),
- DEVMETHOD(pwmbus_channel_is_enabled, aw_pwm_channel_is_enabled),
-
- DEVMETHOD_END
-};
-
-static driver_t aw_pwm_driver = {
- "pwm",
- aw_pwm_methods,
- sizeof(struct aw_pwm_softc),
-};
-
-DRIVER_MODULE(aw_pwm, simplebus, aw_pwm_driver, 0, 0);
-MODULE_VERSION(aw_pwm, 1);
-SIMPLEBUS_PNP_INFO(compat_data);
diff --git a/sys/arm/allwinner/aw_r_intc.c b/sys/arm/allwinner/aw_r_intc.c
index c3bffb721ba6..6a2629a35765 100644
--- a/sys/arm/allwinner/aw_r_intc.c
+++ b/sys/arm/allwinner/aw_r_intc.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "opt_platform.h"
#include <sys/param.h>
@@ -50,6 +48,8 @@ struct aw_r_intc_gicp_softc {
static struct ofw_compat_data compat_data[] = {
{"allwinner,sun6i-a31-r-intc", 1},
+ {"allwinner,sun6i-a64-r-intc", 1},
+ {"allwinner,sun50i-h6-r-intc", 1},
{NULL, 0}
};
diff --git a/sys/arm/allwinner/aw_reset.c b/sys/arm/allwinner/aw_reset.c
index 43467f9265e2..4fadaf2bfef4 100644
--- a/sys/arm/allwinner/aw_reset.c
+++ b/sys/arm/allwinner/aw_reset.c
@@ -21,17 +21,12 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Allwinner module software reset registers
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -45,7 +40,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/hwreset/hwreset.h>
+#include <dev/hwreset/hwreset.h>
#include "hwreset_if.h"
diff --git a/sys/arm/allwinner/aw_rsb.c b/sys/arm/allwinner/aw_rsb.c
index 09ee39157200..773b88d01d84 100644
--- a/sys/arm/allwinner/aw_rsb.c
+++ b/sys/arm/allwinner/aw_rsb.c
@@ -21,17 +21,12 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Allwinner RSB (Reduced Serial Bus) and P2WI (Push-Pull Two Wire Interface)
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -48,8 +43,8 @@ __FBSDID("$FreeBSD$");
#include <dev/iicbus/iiconf.h>
#include <dev/iicbus/iicbus.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
#include "iicbus_if.h"
@@ -447,14 +442,14 @@ rsb_attach(device_t dev)
/* Set the PMIC into RSB mode as ATF might have leave it in I2C mode */
RSB_WRITE(sc, RSB_PMCR, RSB_PMCR_REG(PMIC_MODE_REG) | RSB_PMCR_DATA(PMIC_MODE_RSB) | RSB_PMCR_START);
- sc->iicbus = device_add_child(dev, "iicbus", -1);
+ sc->iicbus = device_add_child(dev, "iicbus", DEVICE_UNIT_ANY);
if (sc->iicbus == NULL) {
device_printf(dev, "cannot add iicbus child device\n");
error = ENXIO;
goto fail;
}
- bus_generic_attach(dev);
+ bus_attach_children(dev);
return (0);
diff --git a/sys/arm/allwinner/aw_rtc.c b/sys/arm/allwinner/aw_rtc.c
index d3ff82aaec01..4af57ab879e8 100644
--- a/sys/arm/allwinner/aw_rtc.c
+++ b/sys/arm/allwinner/aw_rtc.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/time.h>
@@ -44,7 +41,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk_fixed.h>
+#include <dev/clk/clk_fixed.h>
#include <arm/allwinner/aw_machdep.h>
@@ -137,6 +134,7 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun7i-a20-rtc", (uintptr_t) &a20_conf },
{ "allwinner,sun6i-a31-rtc", (uintptr_t) &a31_conf },
{ "allwinner,sun8i-h3-rtc", (uintptr_t) &h3_conf },
+ { "allwinner,sun20i-d1-rtc", (uintptr_t) &h3_conf },
{ "allwinner,sun50i-h5-rtc", (uintptr_t) &h3_conf },
{ "allwinner,sun50i-h6-rtc", (uintptr_t) &h3_conf },
{ NULL, 0 }
@@ -150,11 +148,13 @@ struct aw_rtc_softc {
static struct clk_fixed_def aw_rtc_osc32k = {
.clkdef.id = 0,
+ .clkdef.name = "osc32k",
.freq = 32768,
};
static struct clk_fixed_def aw_rtc_iosc = {
.clkdef.id = 2,
+ .clkdef.name = "iosc",
};
static void aw_rtc_install_clocks(struct aw_rtc_softc *sc, device_t dev);
@@ -253,23 +253,33 @@ aw_rtc_install_clocks(struct aw_rtc_softc *sc, device_t dev) {
int nclocks;
node = ofw_bus_get_node(dev);
- nclocks = ofw_bus_string_list_to_array(node, "clock-output-names", &clknames);
- /* No clocks to export */
- if (nclocks <= 0)
- return;
- if (nclocks != 3) {
- device_printf(dev, "Having only %d clocks instead of 3, aborting\n", nclocks);
+ /* Nothing to do. */
+ if (!OF_hasprop(node, "clocks"))
return;
+
+ /*
+ * If the device tree gives us specific output names for the clocks,
+ * use them.
+ */
+ nclocks = ofw_bus_string_list_to_array(node, "clock-output-names", &clknames);
+ if (nclocks > 0) {
+ if (nclocks != 3) {
+ device_printf(dev,
+ "Found %d clocks names instead of 3, aborting\n",
+ nclocks);
+ return;
+ }
+
+ aw_rtc_osc32k.clkdef.name = clknames[0];
+ aw_rtc_iosc.clkdef.name = clknames[2];
}
clkdom = clkdom_create(dev);
- aw_rtc_osc32k.clkdef.name = clknames[0];
if (clknode_fixed_register(clkdom, &aw_rtc_osc32k) != 0)
device_printf(dev, "Cannot register osc32k clock\n");
- aw_rtc_iosc.clkdef.name = clknames[2];
aw_rtc_iosc.freq = sc->conf->iosc_freq;
if (clknode_fixed_register(clkdom, &aw_rtc_iosc) != 0)
device_printf(dev, "Cannot register iosc clock\n");
diff --git a/sys/arm/allwinner/aw_sid.c b/sys/arm/allwinner/aw_sid.c
index b50f6016c9ca..ba5faca33c5e 100644
--- a/sys/arm/allwinner/aw_sid.c
+++ b/sys/arm/allwinner/aw_sid.c
@@ -21,8 +21,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
@@ -30,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/endian.h>
#include <sys/param.h>
#include <sys/systm.h>
@@ -173,6 +169,27 @@ static struct aw_sid_efuse h5_efuses[] = {
},
};
+static struct aw_sid_efuse d1_efuses[] = {
+ {
+ .name = "rootkey",
+ .desc = "Root Key or ChipID",
+ .base = EFUSE_OFFSET,
+ .offset = 0x00,
+ .size = 16,
+ .id = AW_SID_FUSE_ROOTKEY,
+ .public = true,
+ },
+ {
+ .name = "calibration",
+ .desc = "Thermal Sensor Calibration Data",
+ .base = EFUSE_OFFSET,
+ .offset = 0x34,
+ .size = 4,
+ .id = AW_SID_FUSE_THSSENSOR,
+ .public = true,
+ },
+};
+
struct aw_sid_conf {
struct aw_sid_efuse *efuses;
size_t nfuses;
@@ -208,6 +225,11 @@ static const struct aw_sid_conf h5_conf = {
.nfuses = nitems(h5_efuses),
};
+static const struct aw_sid_conf d1_conf = {
+ .efuses = d1_efuses,
+ .nfuses = nitems(d1_efuses),
+};
+
static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun4i-a10-sid", (uintptr_t)&a10_conf},
{ "allwinner,sun7i-a20-sid", (uintptr_t)&a20_conf},
@@ -215,6 +237,7 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun8i-a83t-sid", (uintptr_t)&a83t_conf},
{ "allwinner,sun8i-h3-sid", (uintptr_t)&h3_conf},
{ "allwinner,sun50i-h5-sid", (uintptr_t)&h5_conf},
+ { "allwinner,sun20i-d1-sid", (uintptr_t)&d1_conf},
{ NULL, 0 }
};
diff --git a/sys/arm/allwinner/aw_sid.h b/sys/arm/allwinner/aw_sid.h
index a94b3d6ab36f..2022b0a663c9 100644
--- a/sys/arm/allwinner/aw_sid.h
+++ b/sys/arm/allwinner/aw_sid.h
@@ -21,8 +21,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef __AW_SID_H__
diff --git a/sys/arm/allwinner/aw_spi.c b/sys/arm/allwinner/aw_spi.c
deleted file mode 100644
index 77653acc1b80..000000000000
--- a/sys/arm/allwinner/aw_spi.c
+++ /dev/null
@@ -1,615 +0,0 @@
-/*-
- * Copyright (c) 2018 Emmanuel Vadot <manu@FreeBSD.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/mutex.h>
-#include <sys/rman.h>
-#include <sys/resource.h>
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/spibus/spi.h>
-#include <dev/spibus/spibusvar.h>
-
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-
-#include "spibus_if.h"
-
-#define AW_SPI_GCR 0x04 /* Global Control Register */
-#define AW_SPI_GCR_EN (1 << 0) /* ENable */
-#define AW_SPI_GCR_MODE_MASTER (1 << 1) /* 1 = Master, 0 = Slave */
-#define AW_SPI_GCR_TP_EN (1 << 7) /* 1 = Stop transmit when FIFO is full */
-#define AW_SPI_GCR_SRST (1 << 31) /* Soft Reset */
-
-#define AW_SPI_TCR 0x08 /* Transfer Control register */
-#define AW_SPI_TCR_XCH (1 << 31) /* Initiate transfer */
-#define AW_SPI_TCR_SDDM (1 << 14) /* Sending Delay Data Mode */
-#define AW_SPI_TCR_SDM (1 << 13) /* Master Sample Data Mode */
-#define AW_SPI_TCR_FBS (1 << 12) /* First Transmit Bit Select (1 == LSB) */
-#define AW_SPI_TCR_SDC (1 << 11) /* Master Sample Data Control */
-#define AW_SPI_TCR_RPSM (1 << 10) /* Rapid Mode Select */
-#define AW_SPI_TCR_DDB (1 << 9) /* Dummy Burst Type */
-#define AW_SPI_TCR_SSSEL_MASK 0x30 /* Chip select */
-#define AW_SPI_TCR_SSSEL_SHIFT 4
-#define AW_SPI_TCR_SS_LEVEL (1 << 7) /* 1 == CS High */
-#define AW_SPI_TCR_SS_OWNER (1 << 6) /* 1 == Software controlled */
-#define AW_SPI_TCR_SPOL (1 << 2) /* 1 == Active low */
-#define AW_SPI_TCR_CPOL (1 << 1) /* 1 == Active low */
-#define AW_SPI_TCR_CPHA (1 << 0) /* 1 == Phase 1 */
-
-#define AW_SPI_IER 0x10 /* Interrupt Control Register */
-#define AW_SPI_IER_SS (1 << 13) /* Chip select went from valid to invalid */
-#define AW_SPI_IER_TC (1 << 12) /* Transfer complete */
-#define AW_SPI_IER_TF_UDR (1 << 11) /* TXFIFO underrun */
-#define AW_SPI_IER_TF_OVF (1 << 10) /* TXFIFO overrun */
-#define AW_SPI_IER_RF_UDR (1 << 9) /* RXFIFO underrun */
-#define AW_SPI_IER_RF_OVF (1 << 8) /* RXFIFO overrun */
-#define AW_SPI_IER_TF_FULL (1 << 6) /* TXFIFO Full */
-#define AW_SPI_IER_TF_EMP (1 << 5) /* TXFIFO Empty */
-#define AW_SPI_IER_TF_ERQ (1 << 4) /* TXFIFO Empty Request */
-#define AW_SPI_IER_RF_FULL (1 << 2) /* RXFIFO Full */
-#define AW_SPI_IER_RF_EMP (1 << 1) /* RXFIFO Empty */
-#define AW_SPI_IER_RF_RDY (1 << 0) /* RXFIFO Ready Request */
-
-#define AW_SPI_ISR 0x14 /* Interrupt Status Register */
-
-#define AW_SPI_FCR 0x18 /* FIFO Control Register */
-#define AW_SPI_FCR_TX_RST (1 << 31) /* Reset TX FIFO */
-#define AW_SPI_FCR_TX_TRIG_MASK 0xFF0000 /* TX FIFO Trigger level */
-#define AW_SPI_FCR_TX_TRIG_SHIFT 16
-#define AW_SPI_FCR_RX_RST (1 << 15) /* Reset RX FIFO */
-#define AW_SPI_FCR_RX_TRIG_MASK 0xFF /* RX FIFO Trigger level */
-#define AW_SPI_FCR_RX_TRIG_SHIFT 0
-
-#define AW_SPI_FSR 0x1C /* FIFO Status Register */
-#define AW_SPI_FSR_TB_WR (1 << 31)
-#define AW_SPI_FSR_TB_CNT_MASK 0x70000000
-#define AW_SPI_FSR_TB_CNT_SHIFT 28
-#define AW_SPI_FSR_TF_CNT_MASK 0xFF0000
-#define AW_SPI_FSR_TF_CNT_SHIFT 16
-#define AW_SPI_FSR_RB_WR (1 << 15)
-#define AW_SPI_FSR_RB_CNT_MASK 0x7000
-#define AW_SPI_FSR_RB_CNT_SHIFT 12
-#define AW_SPI_FSR_RF_CNT_MASK 0xFF
-#define AW_SPI_FSR_RF_CNT_SHIFT 0
-
-#define AW_SPI_WCR 0x20 /* Wait Clock Counter Register */
-
-#define AW_SPI_CCR 0x24 /* Clock Rate Control Register */
-#define AW_SPI_CCR_DRS (1 << 12) /* Clock divider select */
-#define AW_SPI_CCR_CDR1_MASK 0xF00
-#define AW_SPI_CCR_CDR1_SHIFT 8
-#define AW_SPI_CCR_CDR2_MASK 0xFF
-#define AW_SPI_CCR_CDR2_SHIFT 0
-
-#define AW_SPI_MBC 0x30 /* Burst Counter Register */
-#define AW_SPI_MTC 0x34 /* Transmit Counter Register */
-#define AW_SPI_BCC 0x38 /* Burst Control Register */
-#define AW_SPI_MDMA_CTL 0x88 /* Normal DMA Control Register */
-#define AW_SPI_TXD 0x200 /* TX Data Register */
-#define AW_SPI_RDX 0x300 /* RX Data Register */
-
-#define AW_SPI_MAX_CS 4
-#define AW_SPI_FIFO_SIZE 64
-
-static struct ofw_compat_data compat_data[] = {
- { "allwinner,sun8i-h3-spi", 1 },
- { NULL, 0 }
-};
-
-static struct resource_spec aw_spi_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
- { -1, 0 }
-};
-
-struct aw_spi_softc {
- device_t dev;
- device_t spibus;
- struct resource *res[2];
- struct mtx mtx;
- clk_t clk_ahb;
- clk_t clk_mod;
- uint64_t mod_freq;
- hwreset_t rst_ahb;
- void * intrhand;
- int transfer;
-
- uint8_t *rxbuf;
- uint32_t rxcnt;
- uint8_t *txbuf;
- uint32_t txcnt;
- uint32_t txlen;
- uint32_t rxlen;
-};
-
-#define AW_SPI_LOCK(sc) mtx_lock(&(sc)->mtx)
-#define AW_SPI_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
-#define AW_SPI_ASSERT_LOCKED(sc) mtx_assert(&(sc)->mtx, MA_OWNED)
-#define AW_SPI_READ_1(sc, reg) bus_read_1((sc)->res[0], (reg))
-#define AW_SPI_WRITE_1(sc, reg, val) bus_write_1((sc)->res[0], (reg), (val))
-#define AW_SPI_READ_4(sc, reg) bus_read_4((sc)->res[0], (reg))
-#define AW_SPI_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val))
-
-static int aw_spi_probe(device_t dev);
-static int aw_spi_attach(device_t dev);
-static int aw_spi_detach(device_t dev);
-static int aw_spi_intr(void *arg);
-
-static int
-aw_spi_probe(device_t dev)
-{
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner SPI");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aw_spi_attach(device_t dev)
-{
- struct aw_spi_softc *sc;
- int error;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
-
- mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF);
-
- if (bus_alloc_resources(dev, aw_spi_spec, sc->res) != 0) {
- device_printf(dev, "cannot allocate resources for device\n");
- error = ENXIO;
- goto fail;
- }
-
- if (bus_setup_intr(dev, sc->res[1],
- INTR_TYPE_MISC | INTR_MPSAFE, aw_spi_intr, NULL, sc,
- &sc->intrhand)) {
- bus_release_resources(dev, aw_spi_spec, sc->res);
- device_printf(dev, "cannot setup interrupt handler\n");
- return (ENXIO);
- }
-
- /* De-assert reset */
- if (hwreset_get_by_ofw_idx(dev, 0, 0, &sc->rst_ahb) == 0) {
- error = hwreset_deassert(sc->rst_ahb);
- if (error != 0) {
- device_printf(dev, "cannot de-assert reset\n");
- goto fail;
- }
- }
-
- /* Activate the module clock. */
- error = clk_get_by_ofw_name(dev, 0, "ahb", &sc->clk_ahb);
- if (error != 0) {
- device_printf(dev, "cannot get ahb clock\n");
- goto fail;
- }
- error = clk_get_by_ofw_name(dev, 0, "mod", &sc->clk_mod);
- if (error != 0) {
- device_printf(dev, "cannot get mod clock\n");
- goto fail;
- }
- error = clk_enable(sc->clk_ahb);
- if (error != 0) {
- device_printf(dev, "cannot enable ahb clock\n");
- goto fail;
- }
- error = clk_enable(sc->clk_mod);
- if (error != 0) {
- device_printf(dev, "cannot enable mod clock\n");
- goto fail;
- }
-
- sc->spibus = device_add_child(dev, "spibus", -1);
-
- return (bus_generic_attach(dev));
-
-fail:
- aw_spi_detach(dev);
- return (error);
-}
-
-static int
-aw_spi_detach(device_t dev)
-{
- struct aw_spi_softc *sc;
-
- sc = device_get_softc(dev);
-
- bus_generic_detach(sc->dev);
- if (sc->spibus != NULL)
- device_delete_child(dev, sc->spibus);
-
- if (sc->clk_mod != NULL)
- clk_release(sc->clk_mod);
- if (sc->clk_ahb)
- clk_release(sc->clk_ahb);
- if (sc->rst_ahb)
- hwreset_assert(sc->rst_ahb);
-
- if (sc->intrhand != NULL)
- bus_teardown_intr(sc->dev, sc->res[1], sc->intrhand);
-
- bus_release_resources(dev, aw_spi_spec, sc->res);
- mtx_destroy(&sc->mtx);
-
- return (0);
-}
-
-static phandle_t
-aw_spi_get_node(device_t bus, device_t dev)
-{
-
- return ofw_bus_get_node(bus);
-}
-
-static void
-aw_spi_setup_mode(struct aw_spi_softc *sc, uint32_t mode)
-{
- uint32_t reg;
-
- /* We only support master mode */
- reg = AW_SPI_READ_4(sc, AW_SPI_GCR);
- reg |= AW_SPI_GCR_MODE_MASTER;
- AW_SPI_WRITE_4(sc, AW_SPI_GCR, reg);
-
- /* Setup the modes */
- reg = AW_SPI_READ_4(sc, AW_SPI_TCR);
- if (mode & SPIBUS_MODE_CPHA)
- reg |= AW_SPI_TCR_CPHA;
- if (mode & SPIBUS_MODE_CPOL)
- reg |= AW_SPI_TCR_CPOL;
-
- AW_SPI_WRITE_4(sc, AW_SPI_TCR, reg);
-}
-
-static void
-aw_spi_setup_cs(struct aw_spi_softc *sc, uint32_t cs, bool low)
-{
- uint32_t reg;
-
- /* Setup CS */
- reg = AW_SPI_READ_4(sc, AW_SPI_TCR);
- reg &= ~(AW_SPI_TCR_SSSEL_MASK);
- reg |= cs << AW_SPI_TCR_SSSEL_SHIFT;
- reg |= AW_SPI_TCR_SS_OWNER;
- if (low)
- reg &= ~(AW_SPI_TCR_SS_LEVEL);
- else
- reg |= AW_SPI_TCR_SS_LEVEL;
-
- AW_SPI_WRITE_4(sc, AW_SPI_TCR, reg);
-}
-
-static uint64_t
-aw_spi_clock_test_cdr1(struct aw_spi_softc *sc, uint64_t clock, uint32_t *ccr)
-{
- uint64_t cur, best = 0;
- int i, max, best_div;
-
- max = AW_SPI_CCR_CDR1_MASK >> AW_SPI_CCR_CDR1_SHIFT;
- for (i = 0; i < max; i++) {
- cur = sc->mod_freq / (1 << i);
- if ((clock - cur) < (clock - best)) {
- best = cur;
- best_div = i;
- }
- }
-
- *ccr = (best_div << AW_SPI_CCR_CDR1_SHIFT);
- return (best);
-}
-
-static uint64_t
-aw_spi_clock_test_cdr2(struct aw_spi_softc *sc, uint64_t clock, uint32_t *ccr)
-{
- uint64_t cur, best = 0;
- int i, max, best_div;
-
- max = ((AW_SPI_CCR_CDR2_MASK) >> AW_SPI_CCR_CDR2_SHIFT);
- for (i = 0; i < max; i++) {
- cur = sc->mod_freq / (2 * i + 1);
- if ((clock - cur) < (clock - best)) {
- best = cur;
- best_div = i;
- }
- }
-
- *ccr = AW_SPI_CCR_DRS | (best_div << AW_SPI_CCR_CDR2_SHIFT);
- return (best);
-}
-
-static void
-aw_spi_setup_clock(struct aw_spi_softc *sc, uint64_t clock)
-{
- uint64_t best_ccr1, best_ccr2;
- uint32_t ccr, ccr1, ccr2;
-
- best_ccr1 = aw_spi_clock_test_cdr1(sc, clock, &ccr1);
- best_ccr2 = aw_spi_clock_test_cdr2(sc, clock, &ccr2);
-
- if (best_ccr1 == clock) {
- ccr = ccr1;
- } else if (best_ccr2 == clock) {
- ccr = ccr2;
- } else {
- if ((clock - best_ccr1) < (clock - best_ccr2))
- ccr = ccr1;
- else
- ccr = ccr2;
- }
-
- AW_SPI_WRITE_4(sc, AW_SPI_CCR, ccr);
-}
-
-static inline void
-aw_spi_fill_txfifo(struct aw_spi_softc *sc)
-{
- uint32_t reg, txcnt;
- int i;
-
- if (sc->txcnt == sc->txlen)
- return;
-
- reg = AW_SPI_READ_4(sc, AW_SPI_FSR);
- reg &= AW_SPI_FSR_TF_CNT_MASK;
- txcnt = reg >> AW_SPI_FSR_TF_CNT_SHIFT;
-
- for (i = 0; i < (AW_SPI_FIFO_SIZE - txcnt); i++) {
- AW_SPI_WRITE_1(sc, AW_SPI_TXD, sc->txbuf[sc->txcnt++]);
- if (sc->txcnt == sc->txlen)
- break;
- }
-
- return;
-}
-
-static inline void
-aw_spi_read_rxfifo(struct aw_spi_softc *sc)
-{
- uint32_t reg;
- uint8_t val;
- int i;
-
- if (sc->rxcnt == sc->rxlen)
- return;
-
- reg = AW_SPI_READ_4(sc, AW_SPI_FSR);
- reg = (reg & AW_SPI_FSR_RF_CNT_MASK) >> AW_SPI_FSR_RF_CNT_SHIFT;
-
- for (i = 0; i < reg; i++) {
- val = AW_SPI_READ_1(sc, AW_SPI_RDX);
- if (sc->rxcnt < sc->rxlen)
- sc->rxbuf[sc->rxcnt++] = val;
- }
-}
-
-static int
-aw_spi_intr(void *arg)
-{
- struct aw_spi_softc *sc;
- uint32_t intr;
-
- sc = (struct aw_spi_softc *)arg;
-
- intr = AW_SPI_READ_4(sc, AW_SPI_ISR);
-
- if (intr & AW_SPI_IER_RF_RDY)
- aw_spi_read_rxfifo(sc);
-
- if (intr & AW_SPI_IER_TF_ERQ) {
- aw_spi_fill_txfifo(sc);
-
- /*
- * If we don't have anything else to write
- * disable TXFifo interrupts
- */
- if (sc->txcnt == sc->txlen)
- AW_SPI_WRITE_4(sc, AW_SPI_IER, AW_SPI_IER_TC |
- AW_SPI_IER_RF_RDY);
- }
-
- if (intr & AW_SPI_IER_TC) {
- /* read the rest of the data from the fifo */
- aw_spi_read_rxfifo(sc);
-
- /* Disable the interrupts */
- AW_SPI_WRITE_4(sc, AW_SPI_IER, 0);
- sc->transfer = 0;
- wakeup(sc);
- }
-
- /* Clear Interrupts */
- AW_SPI_WRITE_4(sc, AW_SPI_ISR, intr);
- return (intr != 0 ? FILTER_HANDLED : FILTER_STRAY);
-}
-
-static int
-aw_spi_xfer(struct aw_spi_softc *sc, void *rxbuf, void *txbuf, uint32_t txlen, uint32_t rxlen)
-{
- uint32_t reg;
- int error = 0, timeout;
-
- sc->rxbuf = rxbuf;
- sc->rxcnt = 0;
- sc->txbuf = txbuf;
- sc->txcnt = 0;
- sc->txlen = txlen;
- sc->rxlen = rxlen;
-
- /* Reset the FIFOs */
- AW_SPI_WRITE_4(sc, AW_SPI_FCR, AW_SPI_FCR_TX_RST | AW_SPI_FCR_RX_RST);
-
- for (timeout = 1000; timeout > 0; timeout--) {
- reg = AW_SPI_READ_4(sc, AW_SPI_FCR);
- if (reg == 0)
- break;
- }
- if (timeout == 0) {
- device_printf(sc->dev, "Cannot reset the FIFOs\n");
- return (EIO);
- }
-
- /*
- * Set the TX FIFO threshold to 3/4-th the size and
- * the RX FIFO one to 1/4-th.
- */
- AW_SPI_WRITE_4(sc, AW_SPI_FCR,
- ((3 * AW_SPI_FIFO_SIZE / 4) << AW_SPI_FCR_TX_TRIG_SHIFT) |
- ((AW_SPI_FIFO_SIZE / 4) << AW_SPI_FCR_RX_TRIG_SHIFT));
-
- /* Write the counters */
- AW_SPI_WRITE_4(sc, AW_SPI_MBC, txlen);
- AW_SPI_WRITE_4(sc, AW_SPI_MTC, txlen);
- AW_SPI_WRITE_4(sc, AW_SPI_BCC, txlen);
-
- /* First fill */
- aw_spi_fill_txfifo(sc);
-
- /* Start transmit */
- reg = AW_SPI_READ_4(sc, AW_SPI_TCR);
- reg |= AW_SPI_TCR_XCH;
- AW_SPI_WRITE_4(sc, AW_SPI_TCR, reg);
-
- /*
- * Enable interrupts for :
- * Transmit complete
- * TX Fifo is below its trigger threshold
- * RX Fifo is above its trigger threshold
- */
- AW_SPI_WRITE_4(sc, AW_SPI_IER, AW_SPI_IER_TC |
- AW_SPI_IER_TF_ERQ | AW_SPI_IER_RF_RDY);
-
- sc->transfer = 1;
-
- while (error == 0 && sc->transfer != 0)
- error = msleep(sc, &sc->mtx, 0, "aw_spi", 10 * hz);
-
- return (0);
-}
-
-static int
-aw_spi_transfer(device_t dev, device_t child, struct spi_command *cmd)
-{
- struct aw_spi_softc *sc;
- uint32_t cs, mode, clock, reg;
- int err = 0;
-
- sc = device_get_softc(dev);
-
- spibus_get_cs(child, &cs);
- spibus_get_clock(child, &clock);
- spibus_get_mode(child, &mode);
-
- /* The minimum divider is 2 so set the clock at twice the needed speed */
- clk_set_freq(sc->clk_mod, 2 * clock, CLK_SET_ROUND_DOWN);
- clk_get_freq(sc->clk_mod, &sc->mod_freq);
- if (cs >= AW_SPI_MAX_CS) {
- device_printf(dev, "Invalid cs %d\n", cs);
- return (EINVAL);
- }
-
- mtx_lock(&sc->mtx);
-
- /* Enable and reset the module */
- reg = AW_SPI_READ_4(sc, AW_SPI_GCR);
- reg |= AW_SPI_GCR_EN | AW_SPI_GCR_SRST;
- AW_SPI_WRITE_4(sc, AW_SPI_GCR, reg);
-
- /* Setup clock, CS and mode */
- aw_spi_setup_clock(sc, clock);
- aw_spi_setup_mode(sc, mode);
- if (cs & SPIBUS_CS_HIGH)
- aw_spi_setup_cs(sc, cs, false);
- else
- aw_spi_setup_cs(sc, cs, true);
-
- /* xfer */
- err = 0;
- if (cmd->tx_cmd_sz > 0)
- err = aw_spi_xfer(sc, cmd->rx_cmd, cmd->tx_cmd,
- cmd->tx_cmd_sz, cmd->rx_cmd_sz);
- if (cmd->tx_data_sz > 0 && err == 0)
- err = aw_spi_xfer(sc, cmd->rx_data, cmd->tx_data,
- cmd->tx_data_sz, cmd->rx_data_sz);
-
- if (cs & SPIBUS_CS_HIGH)
- aw_spi_setup_cs(sc, cs, true);
- else
- aw_spi_setup_cs(sc, cs, false);
-
- /* Disable the module */
- reg = AW_SPI_READ_4(sc, AW_SPI_GCR);
- reg &= ~AW_SPI_GCR_EN;
- AW_SPI_WRITE_4(sc, AW_SPI_GCR, reg);
-
- mtx_unlock(&sc->mtx);
-
- return (err);
-}
-
-static device_method_t aw_spi_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aw_spi_probe),
- DEVMETHOD(device_attach, aw_spi_attach),
- DEVMETHOD(device_detach, aw_spi_detach),
-
- /* spibus_if */
- DEVMETHOD(spibus_transfer, aw_spi_transfer),
-
- /* ofw_bus_if */
- DEVMETHOD(ofw_bus_get_node, aw_spi_get_node),
-
- DEVMETHOD_END
-};
-
-static driver_t aw_spi_driver = {
- "aw_spi",
- aw_spi_methods,
- sizeof(struct aw_spi_softc),
-};
-
-DRIVER_MODULE(aw_spi, simplebus, aw_spi_driver, 0, 0);
-DRIVER_MODULE(ofw_spibus, aw_spi, ofw_spibus_driver, 0, 0);
-MODULE_DEPEND(aw_spi, ofw_spibus, 1, 1, 1);
-SIMPLEBUS_PNP_INFO(compat_data);
diff --git a/sys/arm/allwinner/aw_syscon.c b/sys/arm/allwinner/aw_syscon.c
index 054b906a9960..cd2d3eeb53cd 100644
--- a/sys/arm/allwinner/aw_syscon.c
+++ b/sys/arm/allwinner/aw_syscon.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
*
@@ -29,9 +29,6 @@
* Allwinner syscon driver
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kernel.h>
@@ -44,8 +41,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/syscon/syscon.h>
-#include <dev/extres/syscon/syscon_generic.h>
+#include <dev/syscon/syscon.h>
+#include <dev/syscon/syscon_generic.h>
static struct ofw_compat_data compat_data[] = {
{"allwinner,sun50i-a64-system-controller", 1},
@@ -54,6 +51,7 @@ static struct ofw_compat_data compat_data[] = {
{"allwinner,sun8i-h3-system-controller", 1},
{"allwinner,sun8i-h3-system-control", 1},
{"allwinner,sun50i-h5-system-control", 1},
+ {"allwinner,sun20i-d1-system-control", 1},
{NULL, 0}
};
diff --git a/sys/arm/allwinner/aw_thermal.c b/sys/arm/allwinner/aw_thermal.c
index 454ce9c47e31..bdb7e2dacc4e 100644
--- a/sys/arm/allwinner/aw_thermal.c
+++ b/sys/arm/allwinner/aw_thermal.c
@@ -21,17 +21,12 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Allwinner thermal sensor controller
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>
@@ -48,9 +43,9 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/nvmem/nvmem.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
+#include <dev/nvmem/nvmem.h>
#include <arm/allwinner/aw_sid.h>
diff --git a/sys/arm/allwinner/a10_timer.c b/sys/arm/allwinner/aw_timer.c
index b13223f5efba..ae609f96f1d3 100644
--- a/sys/arm/allwinner/a10_timer.c
+++ b/sys/arm/allwinner/aw_timer.c
@@ -24,19 +24,17 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
-#include <sys/module.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/rman.h>
#include <sys/timeet.h>
#include <sys/timetc.h>
#include <sys/watchdog.h>
+
#include <machine/bus.h>
#include <machine/intr.h>
#include <machine/machdep.h>
@@ -45,9 +43,9 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk.h>
+#include <dev/clk/clk.h>
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__riscv)
#include "opt_soc.h"
#else
#include <arm/allwinner/aw_machdep.h>
@@ -82,79 +80,91 @@ __FBSDID("$FreeBSD$");
/* 64 bit counter, available in A10 and A13 */
#define CNT64_CTRL_REG 0xa0
#define CNT64_CTRL_RL_EN 0x02 /* read latch enable */
-#define CNT64_LO_REG 0xa4
-#define CNT64_HI_REG 0xa8
+#define CNT64_LO_REG 0xa4
+#define CNT64_HI_REG 0xa8
#define SYS_TIMER_CLKSRC 24000000 /* clock source */
-enum a10_timer_type {
+enum aw_timer_type {
A10_TIMER = 1,
A23_TIMER,
+ D1_TIMER,
};
-struct a10_timer_softc {
+struct aw_timer_softc {
device_t sc_dev;
struct resource *res[2];
void *sc_ih; /* interrupt handler */
uint32_t sc_period;
uint64_t timer0_freq;
struct eventtimer et;
- enum a10_timer_type type;
+ enum aw_timer_type type;
};
#define timer_read_4(sc, reg) \
- bus_read_4(sc->res[A10_TIMER_MEMRES], reg)
+ bus_read_4(sc->res[AW_TIMER_MEMRES], reg)
#define timer_write_4(sc, reg, val) \
- bus_write_4(sc->res[A10_TIMER_MEMRES], reg, val)
+ bus_write_4(sc->res[AW_TIMER_MEMRES], reg, val)
-static u_int a10_timer_get_timecount(struct timecounter *);
#if defined(__arm__)
-static int a10_timer_timer_start(struct eventtimer *,
- sbintime_t first, sbintime_t period);
-static int a10_timer_timer_stop(struct eventtimer *);
+static u_int a10_timer_get_timecount(struct timecounter *);
+static uint64_t a10_timer_read_counter64(struct aw_timer_softc *sc);
+static void a10_timer_timecounter_setup(struct aw_timer_softc *sc);
#endif
-static uint64_t timer_read_counter64(struct a10_timer_softc *sc);
-#if defined(__arm__)
-static void a10_timer_eventtimer_setup(struct a10_timer_softc *sc);
+#if defined(__arm__) || defined(__riscv)
+#define USE_EVENTTIMER
+static void aw_timer_eventtimer_setup(struct aw_timer_softc *sc);
+static int aw_timer_eventtimer_start(struct eventtimer *, sbintime_t first,
+ sbintime_t period);
+static int aw_timer_eventtimer_stop(struct eventtimer *);
#endif
#if defined(__aarch64__)
-static void a23_timer_timecounter_setup(struct a10_timer_softc *sc);
+static void a23_timer_timecounter_setup(struct aw_timer_softc *sc);
static u_int a23_timer_get_timecount(struct timecounter *tc);
#endif
-static int a10_timer_irq(void *);
-static int a10_timer_probe(device_t);
-static int a10_timer_attach(device_t);
+static int aw_timer_irq(void *);
+static int aw_timer_probe(device_t);
+static int aw_timer_attach(device_t);
#if defined(__arm__)
+#define AW_TIMER_QUALITY 1000
+
static delay_func a10_timer_delay;
-#endif
static struct timecounter a10_timer_timecounter = {
- .tc_name = "a10_timer timer0",
+ .tc_name = "aw_timer timer0",
.tc_get_timecount = a10_timer_get_timecount,
.tc_counter_mask = ~0u,
.tc_frequency = 0,
- .tc_quality = 1000,
+ .tc_quality = AW_TIMER_QUALITY,
};
+#endif
#if defined(__aarch64__)
+/* We want it to be selected over the arm generic timecounter */
+#define AW_TIMER_QUALITY 2000
+
static struct timecounter a23_timer_timecounter = {
- .tc_name = "a10_timer timer0",
+ .tc_name = "aw_timer timer0",
.tc_get_timecount = a23_timer_get_timecount,
.tc_counter_mask = ~0u,
.tc_frequency = 0,
- /* We want it to be selected over the arm generic timecounter */
- .tc_quality = 2000,
+ .tc_quality = AW_TIMER_QUALITY,
};
#endif
-#define A10_TIMER_MEMRES 0
-#define A10_TIMER_IRQRES 1
+#if defined(__riscv)
+/* We want it to be selected over the generic RISC-V eventtimer */
+#define AW_TIMER_QUALITY 2000
+#endif
+
+#define AW_TIMER_MEMRES 0
+#define AW_TIMER_IRQRES 1
-static struct resource_spec a10_timer_spec[] = {
+static struct resource_spec aw_timer_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ SYS_RES_IRQ, 0, RF_ACTIVE },
{ -1, 0 }
@@ -164,23 +174,21 @@ static struct ofw_compat_data compat_data[] = {
{"allwinner,sun4i-a10-timer", A10_TIMER},
#if defined(__aarch64__)
{"allwinner,sun8i-a23-timer", A23_TIMER},
+#elif defined(__riscv)
+ {"allwinner,sun20i-d1-timer", D1_TIMER},
#endif
{NULL, 0},
};
static int
-a10_timer_probe(device_t dev)
+aw_timer_probe(device_t dev)
{
-#if defined(__arm__)
- u_int soc_family;
-#endif
-
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
#if defined(__arm__)
/* For SoC >= A10 we have the ARM Timecounter/Eventtimer */
- soc_family = allwinner_soc_family();
+ u_int soc_family = allwinner_soc_family();
if (soc_family != ALLWINNERSOC_SUN4I &&
soc_family != ALLWINNERSOC_SUN5I)
return (ENXIO);
@@ -191,16 +199,16 @@ a10_timer_probe(device_t dev)
}
static int
-a10_timer_attach(device_t dev)
+aw_timer_attach(device_t dev)
{
- struct a10_timer_softc *sc;
+ struct aw_timer_softc *sc;
clk_t clk;
int err;
sc = device_get_softc(dev);
sc->type = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
- if (bus_alloc_resources(dev, a10_timer_spec, sc->res)) {
+ if (bus_alloc_resources(dev, aw_timer_spec, sc->res)) {
device_printf(dev, "could not allocate resources\n");
return (ENXIO);
}
@@ -208,53 +216,51 @@ a10_timer_attach(device_t dev)
sc->sc_dev = dev;
/* Setup and enable the timer interrupt */
- err = bus_setup_intr(dev, sc->res[A10_TIMER_IRQRES], INTR_TYPE_CLK,
- a10_timer_irq, NULL, sc, &sc->sc_ih);
+ err = bus_setup_intr(dev, sc->res[AW_TIMER_IRQRES], INTR_TYPE_CLK,
+ aw_timer_irq, NULL, sc, &sc->sc_ih);
if (err != 0) {
- bus_release_resources(dev, a10_timer_spec, sc->res);
+ bus_release_resources(dev, aw_timer_spec, sc->res);
device_printf(dev, "Unable to setup the clock irq handler, "
"err = %d\n", err);
return (ENXIO);
}
- if (clk_get_by_ofw_index(dev, 0, 0, &clk) != 0)
+ if (clk_get_by_ofw_index(dev, 0, 0, &clk) != 0) {
sc->timer0_freq = SYS_TIMER_CLKSRC;
- else {
+ } else {
if (clk_get_freq(clk, &sc->timer0_freq) != 0) {
device_printf(dev, "Cannot get clock source frequency\n");
return (ENXIO);
}
}
+ if (bootverbose) {
+ device_printf(sc->sc_dev, "clock: hz=%d stathz = %d\n", hz,
+ stathz);
+ }
+
+ /* Set up eventtimer (if applicable) */
+#if defined(USE_EVENTTIMER)
+ aw_timer_eventtimer_setup(sc);
+#endif
+
+ /* Set up timercounter (if applicable) */
#if defined(__arm__)
- a10_timer_eventtimer_setup(sc);
- arm_set_delay(a10_timer_delay, sc);
- a10_timer_timecounter.tc_priv = sc;
- a10_timer_timecounter.tc_frequency = sc->timer0_freq;
- tc_init(&a10_timer_timecounter);
+ a10_timer_timecounter_setup(sc);
#elif defined(__aarch64__)
a23_timer_timecounter_setup(sc);
#endif
- if (bootverbose) {
- device_printf(sc->sc_dev, "clock: hz=%d stathz = %d\n", hz, stathz);
-
- device_printf(sc->sc_dev, "event timer clock frequency %ju\n",
- sc->timer0_freq);
- device_printf(sc->sc_dev, "timecounter clock frequency %jd\n",
- a10_timer_timecounter.tc_frequency);
- }
-
return (0);
}
static int
-a10_timer_irq(void *arg)
+aw_timer_irq(void *arg)
{
- struct a10_timer_softc *sc;
+ struct aw_timer_softc *sc;
uint32_t val;
- sc = (struct a10_timer_softc *)arg;
+ sc = (struct aw_timer_softc *)arg;
/* Clear interrupt pending bit. */
timer_write_4(sc, TIMER_IRQ_STA_REG, TIMER_IRQ_PENDING(0));
@@ -283,12 +289,11 @@ a10_timer_irq(void *arg)
}
/*
- * Event timer function for A10 and A13
+ * Event timer function for A10, A13, and D1.
*/
-
-#if defined(__arm__)
+#if defined(USE_EVENTTIMER)
static void
-a10_timer_eventtimer_setup(struct a10_timer_softc *sc)
+aw_timer_eventtimer_setup(struct aw_timer_softc *sc)
{
uint32_t val;
@@ -305,26 +310,31 @@ a10_timer_eventtimer_setup(struct a10_timer_softc *sc)
/* Set desired frequency in event timer and timecounter */
sc->et.et_frequency = sc->timer0_freq;
- sc->et.et_name = "a10_timer Eventtimer";
+ sc->et.et_name = "aw_timer Eventtimer";
sc->et.et_flags = ET_FLAGS_ONESHOT | ET_FLAGS_PERIODIC;
- sc->et.et_quality = 1000;
+ sc->et.et_quality = AW_TIMER_QUALITY;
sc->et.et_min_period = (0x00000005LLU << 32) / sc->et.et_frequency;
sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency;
- sc->et.et_start = a10_timer_timer_start;
- sc->et.et_stop = a10_timer_timer_stop;
+ sc->et.et_start = aw_timer_eventtimer_start;
+ sc->et.et_stop = aw_timer_eventtimer_stop;
sc->et.et_priv = sc;
et_register(&sc->et);
+
+ if (bootverbose) {
+ device_printf(sc->sc_dev, "event timer clock frequency %ju\n",
+ sc->timer0_freq);
+ }
}
static int
-a10_timer_timer_start(struct eventtimer *et, sbintime_t first,
+aw_timer_eventtimer_start(struct eventtimer *et, sbintime_t first,
sbintime_t period)
{
- struct a10_timer_softc *sc;
+ struct aw_timer_softc *sc;
uint32_t count;
uint32_t val;
- sc = (struct a10_timer_softc *)et->et_priv;
+ sc = (struct aw_timer_softc *)et->et_priv;
if (period != 0)
sc->sc_period = ((uint32_t)et->et_frequency * period) >> 32;
@@ -355,12 +365,12 @@ a10_timer_timer_start(struct eventtimer *et, sbintime_t first,
}
static int
-a10_timer_timer_stop(struct eventtimer *et)
+aw_timer_eventtimer_stop(struct eventtimer *et)
{
- struct a10_timer_softc *sc;
+ struct aw_timer_softc *sc;
uint32_t val;
- sc = (struct a10_timer_softc *)et->et_priv;
+ sc = (struct aw_timer_softc *)et->et_priv;
/* Disable timer0 */
val = timer_read_4(sc, TIMER_CTRL_REG(0));
@@ -371,7 +381,7 @@ a10_timer_timer_stop(struct eventtimer *et)
return (0);
}
-#endif
+#endif /* USE_EVENTTIMER */
/*
* Timecounter functions for A23 and above
@@ -379,7 +389,7 @@ a10_timer_timer_stop(struct eventtimer *et)
#if defined(__aarch64__)
static void
-a23_timer_timecounter_setup(struct a10_timer_softc *sc)
+a23_timer_timecounter_setup(struct aw_timer_softc *sc)
{
uint32_t val;
@@ -403,15 +413,20 @@ a23_timer_timecounter_setup(struct a10_timer_softc *sc)
a23_timer_timecounter.tc_priv = sc;
a23_timer_timecounter.tc_frequency = sc->timer0_freq;
tc_init(&a23_timer_timecounter);
+
+ if (bootverbose) {
+ device_printf(sc->sc_dev, "timecounter clock frequency %jd\n",
+ a23_timer_timecounter.tc_frequency);
+ }
}
static u_int
a23_timer_get_timecount(struct timecounter *tc)
{
- struct a10_timer_softc *sc;
+ struct aw_timer_softc *sc;
uint32_t val;
- sc = (struct a10_timer_softc *)tc->tc_priv;
+ sc = (struct aw_timer_softc *)tc->tc_priv;
if (sc == NULL)
return (0);
@@ -419,14 +434,15 @@ a23_timer_get_timecount(struct timecounter *tc)
/* Counter count backwards */
return (~0u - val);
}
-#endif
+#endif /* __aarch64__ */
/*
* Timecounter functions for A10 and A13, using the 64 bits counter
*/
+#if defined(__arm__)
static uint64_t
-timer_read_counter64(struct a10_timer_softc *sc)
+a10_timer_read_counter64(struct aw_timer_softc *sc)
{
uint32_t lo, hi;
@@ -441,43 +457,55 @@ timer_read_counter64(struct a10_timer_softc *sc)
return (((uint64_t)hi << 32) | lo);
}
-#if defined(__arm__)
static void
a10_timer_delay(int usec, void *arg)
{
- struct a10_timer_softc *sc = arg;
+ struct aw_timer_softc *sc = arg;
uint64_t end, now;
- now = timer_read_counter64(sc);
+ now = a10_timer_read_counter64(sc);
end = now + (sc->timer0_freq / 1000000) * (usec + 1);
while (now < end)
- now = timer_read_counter64(sc);
+ now = a10_timer_read_counter64(sc);
}
-#endif
static u_int
a10_timer_get_timecount(struct timecounter *tc)
{
-
if (tc->tc_priv == NULL)
return (0);
- return ((u_int)timer_read_counter64(tc->tc_priv));
+ return ((u_int)a10_timer_read_counter64(tc->tc_priv));
+}
+
+static void
+a10_timer_timecounter_setup(struct aw_timer_softc *sc)
+{
+ arm_set_delay(a10_timer_delay, sc);
+ a10_timer_timecounter.tc_priv = sc;
+ a10_timer_timecounter.tc_frequency = sc->timer0_freq;
+ tc_init(&a10_timer_timecounter);
+
+ if (bootverbose) {
+ device_printf(sc->sc_dev, "timecounter clock frequency %jd\n",
+ a10_timer_timecounter.tc_frequency);
+ }
}
+#endif /* __arm__ */
-static device_method_t a10_timer_methods[] = {
- DEVMETHOD(device_probe, a10_timer_probe),
- DEVMETHOD(device_attach, a10_timer_attach),
+static device_method_t aw_timer_methods[] = {
+ DEVMETHOD(device_probe, aw_timer_probe),
+ DEVMETHOD(device_attach, aw_timer_attach),
DEVMETHOD_END
};
-static driver_t a10_timer_driver = {
- "a10_timer",
- a10_timer_methods,
- sizeof(struct a10_timer_softc),
+static driver_t aw_timer_driver = {
+ "aw_timer",
+ aw_timer_methods,
+ sizeof(struct aw_timer_softc),
};
-EARLY_DRIVER_MODULE(a10_timer, simplebus, a10_timer_driver, 0, 0,
+EARLY_DRIVER_MODULE(aw_timer, simplebus, aw_timer_driver, 0, 0,
BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/aw_ts.c b/sys/arm/allwinner/aw_ts.c
index 09f7dc7db30f..ca35a29decf8 100644
--- a/sys/arm/allwinner/aw_ts.c
+++ b/sys/arm/allwinner/aw_ts.c
@@ -28,9 +28,6 @@
* Touch screen part is not done, only the thermal sensor part is.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
diff --git a/sys/arm/allwinner/aw_usb3phy.c b/sys/arm/allwinner/aw_usb3phy.c
index a97c87301b2c..66033ef22a18 100644
--- a/sys/arm/allwinner/aw_usb3phy.c
+++ b/sys/arm/allwinner/aw_usb3phy.c
@@ -30,8 +30,6 @@
* Allwinner USB3PHY
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -44,10 +42,10 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/regulator/regulator.h>
-#include <dev/extres/phy/phy_usb.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
+#include <dev/regulator/regulator.h>
+#include <dev/phy/phy_usb.h>
#include "phynode_if.h"
diff --git a/sys/arm/allwinner/aw_usbphy.c b/sys/arm/allwinner/aw_usbphy.c
index b7dd6af48d60..97c3d2207773 100644
--- a/sys/arm/allwinner/aw_usbphy.c
+++ b/sys/arm/allwinner/aw_usbphy.c
@@ -21,17 +21,12 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Allwinner USB PHY
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -45,10 +40,10 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/gpio/gpiobusvar.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/regulator/regulator.h>
-#include <dev/extres/phy/phy_usb.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
+#include <dev/regulator/regulator.h>
+#include <dev/phy/phy_usb.h>
#include "phynode_if.h"
@@ -61,6 +56,7 @@ enum awusbphy_type {
AWUSBPHY_TYPE_A64,
AWUSBPHY_TYPE_A83T,
AWUSBPHY_TYPE_H6,
+ AWUSBPHY_TYPE_D1,
};
struct aw_usbphy_conf {
@@ -126,6 +122,13 @@ static const struct aw_usbphy_conf h6_usbphy_conf = {
.phy0_route = true,
};
+static const struct aw_usbphy_conf d1_usbphy_conf = {
+ .num_phys = 2,
+ .phy_type = AWUSBPHY_TYPE_D1,
+ .pmu_unk1 = true,
+ .phy0_route = true,
+};
+
static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun4i-a10-usb-phy", (uintptr_t)&a10_usbphy_conf },
{ "allwinner,sun5i-a13-usb-phy", (uintptr_t)&a13_usbphy_conf },
@@ -135,6 +138,7 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun50i-a64-usb-phy", (uintptr_t)&a64_usbphy_conf },
{ "allwinner,sun8i-a83t-usb-phy", (uintptr_t)&a83t_usbphy_conf },
{ "allwinner,sun50i-h6-usb-phy", (uintptr_t)&h6_usbphy_conf },
+ { "allwinner,sun20i-d1-usb-phy", (uintptr_t)&d1_usbphy_conf },
{ NULL, 0 }
};
diff --git a/sys/arm/allwinner/aw_wdog.c b/sys/arm/allwinner/aw_wdog.c
index 4b65635c571b..acfbdd8fe6d0 100644
--- a/sys/arm/allwinner/aw_wdog.c
+++ b/sys/arm/allwinner/aw_wdog.c
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/eventhandler.h>
@@ -204,6 +202,9 @@ aw_wdog_attach(device_t dev)
EVENTHANDLER_REGISTER(shutdown_final, aw_wdog_shutdown_fn, sc,
SHUTDOWN_PRI_LAST - 1);
+ /* Disable watchdog for now. */
+ WRITE(sc, sc->wdog_mode, sc->wdog_mode_key);
+
return (0);
}
diff --git a/sys/arm/allwinner/aw_wdog.h b/sys/arm/allwinner/aw_wdog.h
index 1aac03ae8c30..2867f052c121 100644
--- a/sys/arm/allwinner/aw_wdog.h
+++ b/sys/arm/allwinner/aw_wdog.h
@@ -23,8 +23,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#ifndef __AW_WDOG_H__
#define __AW_WDOG_H__
diff --git a/sys/arm/allwinner/axp209.c b/sys/arm/allwinner/axp209.c
index 9d5d31f92010..239ead02d0e0 100644
--- a/sys/arm/allwinner/axp209.c
+++ b/sys/arm/allwinner/axp209.c
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* X-Power AXP209/AXP211 PMU for Allwinner SoCs
*/
@@ -53,7 +51,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/regulator/regulator.h>
+#include <dev/regulator/regulator.h>
#include <arm/allwinner/axp209reg.h>
diff --git a/sys/arm/allwinner/axp209reg.h b/sys/arm/allwinner/axp209reg.h
index d6be123c5281..22b929c39c16 100644
--- a/sys/arm/allwinner/axp209reg.h
+++ b/sys/arm/allwinner/axp209reg.h
@@ -20,8 +20,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _AXP209REG_H_
diff --git a/sys/arm/allwinner/axp81x.c b/sys/arm/allwinner/axp81x.c
index fcbfb5909874..fc1a168595e5 100644
--- a/sys/arm/allwinner/axp81x.c
+++ b/sys/arm/allwinner/axp81x.c
@@ -22,17 +22,12 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* X-Powers AXP803/813/818 PMU for Allwinner SoCs
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>
@@ -52,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/extres/regulator/regulator.h>
+#include <dev/regulator/regulator.h>
#include "gpio_if.h"
#include "iicbus_if.h"
diff --git a/sys/arm/allwinner/clkng/aw_ccung.c b/sys/arm/allwinner/clkng/aw_ccung.c
deleted file mode 100644
index ba930b993f20..000000000000
--- a/sys/arm/allwinner/clkng/aw_ccung.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * Allwinner Clock Control Unit
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/mutex.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/clk/clk_gate.h>
-
-#include <dev/extres/hwreset/hwreset.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-#include <arm/allwinner/clkng/aw_clk.h>
-
-#ifdef __aarch64__
-#include "opt_soc.h"
-#endif
-
-#include "clkdev_if.h"
-#include "hwreset_if.h"
-
-#if 0
-#define dprintf(format, arg...) device_printf(dev, "%s: " format, __func__, arg)
-#else
-#define dprintf(format, arg...)
-#endif
-
-static struct resource_spec aw_ccung_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-#define CCU_READ4(sc, reg) bus_read_4((sc)->res, (reg))
-#define CCU_WRITE4(sc, reg, val) bus_write_4((sc)->res, (reg), (val))
-
-static int
-aw_ccung_write_4(device_t dev, bus_addr_t addr, uint32_t val)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
- dprintf("offset=%lx write %x\n", addr, val);
- CCU_WRITE4(sc, addr, val);
- return (0);
-}
-
-static int
-aw_ccung_read_4(device_t dev, bus_addr_t addr, uint32_t *val)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- *val = CCU_READ4(sc, addr);
- dprintf("offset=%lx Read %x\n", addr, *val);
- return (0);
-}
-
-static int
-aw_ccung_modify_4(device_t dev, bus_addr_t addr, uint32_t clr, uint32_t set)
-{
- struct aw_ccung_softc *sc;
- uint32_t reg;
-
- sc = device_get_softc(dev);
-
- dprintf("offset=%lx clr: %x set: %x\n", addr, clr, set);
- reg = CCU_READ4(sc, addr);
- reg &= ~clr;
- reg |= set;
- CCU_WRITE4(sc, addr, reg);
-
- return (0);
-}
-
-static int
-aw_ccung_reset_assert(device_t dev, intptr_t id, bool reset)
-{
- struct aw_ccung_softc *sc;
- uint32_t val;
-
- sc = device_get_softc(dev);
-
- dprintf("%sassert reset id %ld\n", reset ? "" : "De", id);
- if (id >= sc->nresets || sc->resets[id].offset == 0)
- return (0);
-
- mtx_lock(&sc->mtx);
- val = CCU_READ4(sc, sc->resets[id].offset);
- dprintf("offset=%x Read %x\n", sc->resets[id].offset, val);
- if (reset)
- val &= ~(1 << sc->resets[id].shift);
- else
- val |= 1 << sc->resets[id].shift;
- dprintf("offset=%x Write %x\n", sc->resets[id].offset, val);
- CCU_WRITE4(sc, sc->resets[id].offset, val);
- mtx_unlock(&sc->mtx);
-
- return (0);
-}
-
-static int
-aw_ccung_reset_is_asserted(device_t dev, intptr_t id, bool *reset)
-{
- struct aw_ccung_softc *sc;
- uint32_t val;
-
- sc = device_get_softc(dev);
-
- if (id >= sc->nresets || sc->resets[id].offset == 0)
- return (0);
-
- mtx_lock(&sc->mtx);
- val = CCU_READ4(sc, sc->resets[id].offset);
- dprintf("offset=%x Read %x\n", sc->resets[id].offset, val);
- *reset = (val & (1 << sc->resets[id].shift)) != 0 ? false : true;
- mtx_unlock(&sc->mtx);
-
- return (0);
-}
-
-static void
-aw_ccung_device_lock(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
- mtx_lock(&sc->mtx);
-}
-
-static void
-aw_ccung_device_unlock(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
- mtx_unlock(&sc->mtx);
-}
-
-static int
-aw_ccung_register_gates(struct aw_ccung_softc *sc)
-{
- struct clk_gate_def def;
- int i;
-
- for (i = 0; i < sc->ngates; i++) {
- if (sc->gates[i].name == NULL)
- continue;
- memset(&def, 0, sizeof(def));
- def.clkdef.id = i;
- def.clkdef.name = sc->gates[i].name;
- def.clkdef.parent_names = &sc->gates[i].parent_name;
- def.clkdef.parent_cnt = 1;
- def.offset = sc->gates[i].offset;
- def.shift = sc->gates[i].shift;
- def.mask = 1;
- def.on_value = 1;
- def.off_value = 0;
- clknode_gate_register(sc->clkdom, &def);
- }
-
- return (0);
-}
-
-static void
-aw_ccung_init_clocks(struct aw_ccung_softc *sc)
-{
- struct clknode *clknode;
- int i, error;
-
- for (i = 0; i < sc->n_clk_init; i++) {
- clknode = clknode_find_by_name(sc->clk_init[i].name);
- if (clknode == NULL) {
- device_printf(sc->dev, "Cannot find clock %s\n",
- sc->clk_init[i].name);
- continue;
- }
-
- if (sc->clk_init[i].parent_name != NULL) {
- if (bootverbose)
- device_printf(sc->dev, "Setting %s as parent for %s\n",
- sc->clk_init[i].parent_name,
- sc->clk_init[i].name);
- error = clknode_set_parent_by_name(clknode,
- sc->clk_init[i].parent_name);
- if (error != 0) {
- device_printf(sc->dev,
- "Cannot set parent to %s for %s\n",
- sc->clk_init[i].parent_name,
- sc->clk_init[i].name);
- continue;
- }
- }
- if (sc->clk_init[i].default_freq != 0) {
- if (bootverbose)
- device_printf(sc->dev,
- "Setting freq %ju for %s\n",
- sc->clk_init[i].default_freq,
- sc->clk_init[i].name);
- error = clknode_set_freq(clknode,
- sc->clk_init[i].default_freq, 0 , 0);
- if (error != 0) {
- device_printf(sc->dev,
- "Cannot set frequency for %s to %ju\n",
- sc->clk_init[i].name,
- sc->clk_init[i].default_freq);
- continue;
- }
- }
- if (sc->clk_init[i].enable) {
- error = clknode_enable(clknode);
- if (error != 0) {
- device_printf(sc->dev,
- "Cannot enable %s\n",
- sc->clk_init[i].name);
- continue;
- }
- }
- }
-}
-
-int
-aw_ccung_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
- int i;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, aw_ccung_spec, &sc->res) != 0) {
- device_printf(dev, "cannot allocate resources for device\n");
- return (ENXIO);
- }
-
- mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF);
-
- sc->clkdom = clkdom_create(dev);
- if (sc->clkdom == NULL)
- panic("Cannot create clkdom\n");
-
- for (i = 0; i < sc->nclks; i++) {
- switch (sc->clks[i].type) {
- case AW_CLK_UNDEFINED:
- break;
- case AW_CLK_MUX:
- clknode_mux_register(sc->clkdom, sc->clks[i].clk.mux);
- break;
- case AW_CLK_DIV:
- clknode_div_register(sc->clkdom, sc->clks[i].clk.div);
- break;
- case AW_CLK_FIXED:
- clknode_fixed_register(sc->clkdom,
- sc->clks[i].clk.fixed);
- break;
- case AW_CLK_NKMP:
- aw_clk_nkmp_register(sc->clkdom, sc->clks[i].clk.nkmp);
- break;
- case AW_CLK_NM:
- aw_clk_nm_register(sc->clkdom, sc->clks[i].clk.nm);
- break;
- case AW_CLK_M:
- aw_clk_m_register(sc->clkdom, sc->clks[i].clk.m);
- break;
- case AW_CLK_PREDIV_MUX:
- aw_clk_prediv_mux_register(sc->clkdom,
- sc->clks[i].clk.prediv_mux);
- break;
- case AW_CLK_FRAC:
- aw_clk_frac_register(sc->clkdom, sc->clks[i].clk.frac);
- break;
- case AW_CLK_MIPI:
- aw_clk_mipi_register(sc->clkdom, sc->clks[i].clk.mipi);
- break;
- case AW_CLK_NP:
- aw_clk_np_register(sc->clkdom, sc->clks[i].clk.np);
- break;
- case AW_CLK_NMM:
- aw_clk_nmm_register(sc->clkdom, sc->clks[i].clk.nmm);
- break;
- }
- }
-
- if (sc->gates)
- aw_ccung_register_gates(sc);
- if (clkdom_finit(sc->clkdom) != 0)
- panic("cannot finalize clkdom initialization\n");
-
- clkdom_xlock(sc->clkdom);
- aw_ccung_init_clocks(sc);
- clkdom_unlock(sc->clkdom);
-
- if (bootverbose)
- clkdom_dump(sc->clkdom);
-
- /* If we have resets, register our self as a reset provider */
- if (sc->resets)
- hwreset_register_ofw_provider(dev);
-
- return (0);
-}
-
-static device_method_t aw_ccung_methods[] = {
- /* clkdev interface */
- DEVMETHOD(clkdev_write_4, aw_ccung_write_4),
- DEVMETHOD(clkdev_read_4, aw_ccung_read_4),
- DEVMETHOD(clkdev_modify_4, aw_ccung_modify_4),
- DEVMETHOD(clkdev_device_lock, aw_ccung_device_lock),
- DEVMETHOD(clkdev_device_unlock, aw_ccung_device_unlock),
-
- /* Reset interface */
- DEVMETHOD(hwreset_assert, aw_ccung_reset_assert),
- DEVMETHOD(hwreset_is_asserted, aw_ccung_reset_is_asserted),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_0(aw_ccung, aw_ccung_driver, aw_ccung_methods,
- sizeof(struct aw_ccung_softc));
diff --git a/sys/arm/allwinner/clkng/aw_ccung.h b/sys/arm/allwinner/clkng/aw_ccung.h
deleted file mode 100644
index 6a5c2fff2dde..000000000000
--- a/sys/arm/allwinner/clkng/aw_ccung.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __CCU_NG_H__
-#define __CCU_NG_H__
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_m.h>
-#include <arm/allwinner/clkng/aw_clk_mipi.h>
-#include <arm/allwinner/clkng/aw_clk_nkmp.h>
-#include <arm/allwinner/clkng/aw_clk_nm.h>
-#include <arm/allwinner/clkng/aw_clk_nmm.h>
-#include <arm/allwinner/clkng/aw_clk_np.h>
-#include <arm/allwinner/clkng/aw_clk_prediv_mux.h>
-#include <arm/allwinner/clkng/aw_clk_frac.h>
-#include <dev/extres/clk/clk_mux.h>
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-
-enum aw_ccung_clk_type {
- AW_CLK_UNDEFINED = 0,
- AW_CLK_MUX,
- AW_CLK_DIV,
- AW_CLK_FIXED,
- AW_CLK_NKMP,
- AW_CLK_NM,
- AW_CLK_PREDIV_MUX,
- AW_CLK_FRAC,
- AW_CLK_M,
- AW_CLK_MIPI,
- AW_CLK_NP,
- AW_CLK_NMM,
-};
-
-struct aw_ccung_clk {
- enum aw_ccung_clk_type type;
- union {
- struct clk_mux_def *mux;
- struct clk_div_def *div;
- struct clk_fixed_def *fixed;
- struct aw_clk_nkmp_def *nkmp;
- struct aw_clk_nm_def *nm;
- struct aw_clk_prediv_mux_def *prediv_mux;
- struct aw_clk_frac_def *frac;
- struct aw_clk_m_def *m;
- struct aw_clk_mipi_def *mipi;
- struct aw_clk_np_def *np;
- struct aw_clk_nmm_def *nmm;
- } clk;
-};
-
-struct aw_ccung_softc {
- device_t dev;
- struct resource *res;
- struct clkdom *clkdom;
- struct mtx mtx;
- struct aw_ccung_reset *resets;
- int nresets;
- struct aw_ccung_gate *gates;
- int ngates;
- struct aw_ccung_clk *clks;
- int nclks;
- struct aw_clk_init *clk_init;
- int n_clk_init;
-};
-
-struct aw_ccung_reset {
- uint32_t offset;
- uint32_t shift;
-};
-
-struct aw_ccung_gate {
- const char *name;
- const char *parent_name;
- uint32_t id;
- uint32_t offset;
- uint32_t shift;
-};
-
-DECLARE_CLASS(aw_ccung_driver);
-
-int aw_ccung_attach(device_t dev);
-
-#endif /* __CCU_NG_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk.h b/sys/arm/allwinner/clkng/aw_clk.h
deleted file mode 100644
index ec8d13599bb9..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk.h
+++ /dev/null
@@ -1,604 +0,0 @@
-/*-
- * Copyright (c) 2017 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_H__
-#define __AW_CLK_H__
-
-/*
- Allwinner clocks formula :
-
-PLLs:
-
-(24MHz*N*K)/(M*P)
-(24MHz*N)/(M*P)
-(24MHz*N*2)/M
-(24MHz*N)/M
-(24MHz*N*K)/M
-(24MHz*N*K/2)
-(24MHz*N)/M
-(24MHz*N*K/2)
-(24MHz*N)/M
-
-Periph clocks:
-
-Clock Source/Divider N/Divider M
-Clock Source/Divider N/Divider M/2
-Clock Source*N/(Divider M+1)/(Divider P+1)
-
- */
-
-struct aw_clk_init {
- const char *name;
- const char *parent_name;
- uint64_t default_freq;
- bool enable;
-};
-
-#define AW_CLK_HAS_GATE 0x0001
-#define AW_CLK_HAS_LOCK 0x0002
-#define AW_CLK_HAS_MUX 0x0004
-#define AW_CLK_REPARENT 0x0008
-#define AW_CLK_SCALE_CHANGE 0x0010
-#define AW_CLK_HAS_UPDATE 0x0040
-#define AW_CLK_HAS_PREDIV 0x0080
-#define AW_CLK_SET_PARENT 0x0100
-
-#define AW_CLK_FACTOR_POWER_OF_TWO 0x0001
-#define AW_CLK_FACTOR_ZERO_BASED 0x0002
-#define AW_CLK_FACTOR_HAS_COND 0x0004
-#define AW_CLK_FACTOR_FIXED 0x0008
-#define AW_CLK_FACTOR_ZERO_IS_ONE 0x0010
-#define AW_CLK_FACTOR_MIN_VALUE 0x0020
-#define AW_CLK_FACTOR_MAX_VALUE 0x0040
-
-struct aw_clk_factor {
- uint32_t shift; /* Shift bits for the factor */
- uint32_t mask; /* Mask to get the factor, will be override by the clk methods */
- uint32_t width; /* Number of bits for the factor */
- uint32_t value; /* Fixed value, depends on AW_CLK_FACTOR_FIXED */
-
- uint32_t cond_shift;
- uint32_t cond_mask;
- uint32_t cond_width;
- uint32_t cond_value;
-
- uint32_t min_value;
- uint32_t max_value;
-
- uint32_t flags; /* Flags */
-};
-
-struct aw_clk_frac {
- uint64_t freq0;
- uint64_t freq1;
- uint32_t mode_sel;
- uint32_t freq_sel;
-};
-
-static inline uint32_t
-aw_clk_get_factor(uint32_t val, struct aw_clk_factor *factor)
-{
- uint32_t factor_val;
- uint32_t cond;
-
- if (factor->flags & AW_CLK_FACTOR_HAS_COND) {
- cond = (val & factor->cond_mask) >> factor->cond_shift;
- if (cond != factor->cond_value)
- return (1);
- }
-
- if (factor->flags & AW_CLK_FACTOR_FIXED)
- return (factor->value);
-
- factor_val = (val & factor->mask) >> factor->shift;
- if (factor_val == 0 && (factor->flags & AW_CLK_FACTOR_ZERO_IS_ONE))
- factor_val = 1;
-
- if (factor->flags & AW_CLK_FACTOR_POWER_OF_TWO)
- factor_val = 1 << factor_val;
- else if (!(factor->flags & AW_CLK_FACTOR_ZERO_BASED))
- factor_val += 1;
-
- return (factor_val);
-}
-
-static inline uint32_t
-aw_clk_factor_get_max(struct aw_clk_factor *factor)
-{
- uint32_t max;
-
- if (factor->flags & AW_CLK_FACTOR_FIXED)
- max = factor->value;
- else if (factor->flags & AW_CLK_FACTOR_POWER_OF_TWO)
- max = 1 << ((1 << factor->width) - 1);
- else {
- max = (1 << factor->width);
- }
-
- return (max);
-}
-
-static inline uint32_t
-aw_clk_factor_get_min(struct aw_clk_factor *factor)
-{
- uint32_t min;
-
- if (factor->flags & AW_CLK_FACTOR_FIXED)
- min = factor->value;
- else if (factor->flags & AW_CLK_FACTOR_ZERO_BASED)
- min = 0;
- else if (factor->flags & AW_CLK_FACTOR_MIN_VALUE)
- min = factor->min_value;
- else
- min = 1;
-
- return (min);
-}
-
-static inline uint32_t
-aw_clk_factor_get_value(struct aw_clk_factor *factor, uint32_t raw)
-{
- uint32_t val;
-
- if (factor->flags & AW_CLK_FACTOR_FIXED)
- return (factor->value);
-
- if (factor->flags & AW_CLK_FACTOR_ZERO_BASED)
- val = raw;
- else if (factor->flags & AW_CLK_FACTOR_POWER_OF_TWO) {
- for (val = 0; raw != 1; val++)
- raw >>= 1;
- } else if (factor->flags & AW_CLK_FACTOR_MAX_VALUE)
- val = factor->max_value;
- else
- val = raw - 1;
-
- return (val);
-}
-
-#define CCU_RESET(idx, o, s) \
- [idx] = { \
- .offset = o, \
- .shift = s, \
- },
-
-#define CCU_GATE(idx, clkname, pname, o, s) \
- [idx] = { \
- .name = clkname, \
- .parent_name = pname, \
- .offset = o, \
- .shift = s, \
- },
-
-#define NKMP_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _n_shift, _n_width, _n_value, _n_flags, \
- _k_shift, _k_width, _k_value, _k_flags, \
- _m_shift, _m_width, _m_value, _m_flags, \
- _p_shift, _p_width, _p_value, _p_flags, \
- _gate, \
- _lock, _lock_retries, \
- _flags) \
- static struct aw_clk_nkmp_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .n.shift = _n_shift, \
- .n.width = _n_width, \
- .n.value = _n_value, \
- .n.flags = _n_flags, \
- .k.shift = _k_shift, \
- .k.width = _k_width, \
- .k.value = _k_value, \
- .k.flags = _k_flags, \
- .m.shift = _m_shift, \
- .m.width = _m_width, \
- .m.value = _m_value, \
- .m.flags = _m_flags, \
- .p.shift = _p_shift, \
- .p.width = _p_width, \
- .p.value = _p_value, \
- .p.flags = _p_flags, \
- .gate_shift = _gate, \
- .lock_shift = _lock, \
- .lock_retries = _lock_retries, \
- .flags = _flags, \
- }
-
-#define NKMP_CLK_WITH_MUX(_clkname, \
- _id, _name, _pnames, \
- _offset, \
- _n_shift, _n_width, _n_value, _n_flags, \
- _k_shift, _k_width, _k_value, _k_flags, \
- _m_shift, _m_width, _m_value, _m_flags, \
- _p_shift, _p_width, _p_value, _p_flags, \
- _mux_shift, _mux_width, _gate, \
- _lock, _lock_retries, \
- _flags) \
- static struct aw_clk_nkmp_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .n.shift = _n_shift, \
- .n.width = _n_width, \
- .n.value = _n_value, \
- .n.flags = _n_flags, \
- .k.shift = _k_shift, \
- .k.width = _k_width, \
- .k.value = _k_value, \
- .k.flags = _k_flags, \
- .m.shift = _m_shift, \
- .m.width = _m_width, \
- .m.value = _m_value, \
- .m.flags = _m_flags, \
- .p.shift = _p_shift, \
- .p.width = _p_width, \
- .p.value = _p_value, \
- .p.flags = _p_flags, \
- .mux_shift = _mux_shift, \
- .mux_width = _mux_width, \
- .gate_shift = _gate, \
- .lock_shift = _lock, \
- .lock_retries = _lock_retries, \
- .flags = _flags, \
- }
-
-#define NKMP_CLK_WITH_UPDATE(_clkname, \
- _id, _name, _pnames, \
- _offset, \
- _n_shift, _n_width, _n_value, _n_flags, \
- _k_shift, _k_width, _k_value, _k_flags, \
- _m_shift, _m_width, _m_value, _m_flags, \
- _p_shift, _p_width, _p_value, _p_flags, \
- _gate, \
- _lock, _lock_retries, \
- _update, \
- _flags) \
- static struct aw_clk_nkmp_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .n.shift = _n_shift, \
- .n.width = _n_width, \
- .n.value = _n_value, \
- .n.flags = _n_flags, \
- .k.shift = _k_shift, \
- .k.width = _k_width, \
- .k.value = _k_value, \
- .k.flags = _k_flags, \
- .m.shift = _m_shift, \
- .m.width = _m_width, \
- .m.value = _m_value, \
- .m.flags = _m_flags, \
- .p.shift = _p_shift, \
- .p.width = _p_width, \
- .p.value = _p_value, \
- .p.flags = _p_flags, \
- .gate_shift = _gate, \
- .lock_shift = _lock, \
- .lock_retries = _lock_retries, \
- .update_shift = _update, \
- .flags = _flags | AW_CLK_HAS_UPDATE, \
- }
-
-#define FRAC_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _nshift, _nwidth, _nvalue, _nflags, \
- _mshift, _mwidth, _mvalue, _mflags, \
- _gate_shift, _lock_shift,_lock_retries, \
- _flags, _freq0, _freq1, _mode_sel, _freq_sel, \
- _min_freq, _max_freq) \
- static struct aw_clk_frac_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- .flags = CLK_NODE_GLITCH_FREE, \
- }, \
- .offset = _offset, \
- .n.shift = _nshift, \
- .n.width = _nwidth, \
- .n.value = _nvalue, \
- .n.flags = _nflags, \
- .m.shift = _mshift, \
- .m.width = _mwidth, \
- .m.value = _mvalue, \
- .m.flags = _mflags, \
- .gate_shift = _gate_shift, \
- .lock_shift = _lock_shift, \
- .lock_retries = _lock_retries, \
- .flags = _flags, \
- .frac.freq0 = _freq0, \
- .frac.freq1 = _freq1, \
- .frac.mode_sel = _mode_sel, \
- .frac.freq_sel = _freq_sel, \
- .min_freq = _min_freq, \
- .max_freq = _max_freq, \
- }
-
-#define M_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _mshift, _mwidth, _mvalue, _mflags, \
- _mux_shift, _mux_width, \
- _gate_shift, \
- _flags) \
- static struct aw_clk_m_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .mux_shift = _mux_shift, \
- .m.shift = _mshift, \
- .m.width = _mwidth, \
- .m.value = _mvalue, \
- .m.flags = _mflags, \
- .mux_width = _mux_width, \
- .gate_shift = _gate_shift, \
- .flags = _flags, \
- }
-
-#define NM_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _nshift, _nwidth, _nvalue, _nflags, \
- _mshift, _mwidth, _mvalue, _mflags, \
- _mux_shift, _mux_width, \
- _gate_shift, \
- _flags) \
- static struct aw_clk_nm_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .n.shift = _nshift, \
- .n.width = _nwidth, \
- .n.value = _nvalue, \
- .n.flags = _nflags, \
- .mux_shift = _mux_shift, \
- .m.shift = _mshift, \
- .m.width = _mwidth, \
- .m.value = _mvalue, \
- .m.flags = _mflags, \
- .mux_width = _mux_width, \
- .gate_shift = _gate_shift, \
- .flags = _flags, \
- }
-
-#define NMM_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _nshift, _nwidth, _nvalue, _nflags, \
- _m0shift, _m0width, _m0value, _m0flags, \
- _m1shift, _m1width, _m1value, _m1flags, \
- _gate_shift, \
- _lock, _lock_retries, \
- _flags) \
- static struct aw_clk_nmm_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .n.shift = _nshift, \
- .n.width = _nwidth, \
- .n.value = _nvalue, \
- .n.flags = _nflags, \
- .m0.shift = _m0shift, \
- .m0.width = _m0width, \
- .m0.value = _m0value, \
- .m0.flags = _m0flags, \
- .m1.shift = _m1shift, \
- .m1.width = _m1width, \
- .m1.value = _m1value, \
- .m1.flags = _m1flags, \
- .gate_shift = _gate_shift, \
- .lock_shift = _lock, \
- .lock_retries = _lock_retries, \
- .flags = _flags, \
- }
-
-#define NP_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _nshift, _nwidth, _nvalue, _nflags, \
- _pshift, _pwidth, _pvalue, _pflags, \
- _gate_shift, \
- _lock, _lock_retries, \
- _flags) \
- static struct aw_clk_np_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .n.shift = _nshift, \
- .n.width = _nwidth, \
- .n.value = _nvalue, \
- .n.flags = _nflags, \
- .p.shift = _pshift, \
- .p.width = _pwidth, \
- .p.value = _pvalue, \
- .p.flags = _pflags, \
- .gate_shift = _gate_shift, \
- .lock_shift = _lock, \
- .lock_retries = _lock_retries, \
- .flags = _flags, \
- }
-
-#define PREDIV_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _mux_shift, _mux_width, \
- _div_shift, _div_width, _div_value, _div_flags, \
- _prediv_shift, _prediv_width, _prediv_value, _prediv_flags, \
- _prediv_cond_shift, _prediv_cond_width, _prediv_cond_value) \
- static struct aw_clk_prediv_mux_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .mux_shift = _mux_shift, \
- .mux_width = _mux_width, \
- .div.shift = _div_shift, \
- .div.width = _div_width, \
- .div.value = _div_value, \
- .div.flags = _div_flags, \
- .prediv.shift = _prediv_shift, \
- .prediv.width = _prediv_width, \
- .prediv.value = _prediv_value, \
- .prediv.flags = _prediv_flags, \
- .prediv.cond_shift = _prediv_cond_shift, \
- .prediv.cond_width = _prediv_cond_width, \
- .prediv.cond_value = _prediv_cond_value, \
- }
-
-#define PREDIV_CLK_WITH_MASK(_clkname, _id, _name, _pnames, \
- _offset, \
- _mux_shift, _mux_width, \
- _div_shift, _div_width, _div_value, _div_flags, \
- _prediv_shift, _prediv_width, _prediv_value, _prediv_flags, \
- _prediv_cond_mask, _prediv_cond_value) \
- static struct aw_clk_prediv_mux_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames), \
- }, \
- .offset = _offset, \
- .mux_shift = _mux_shift, \
- .mux_width = _mux_width, \
- .div.shift = _div_shift, \
- .div.width = _div_width, \
- .div.value = _div_value, \
- .div.flags = _div_flags, \
- .prediv.shift = _prediv_shift, \
- .prediv.width = _prediv_width, \
- .prediv.value = _prediv_value, \
- .prediv.flags = _prediv_flags, \
- .prediv.cond_shift = 0, \
- .prediv.cond_width = 0, \
- .prediv.cond_mask = _prediv_cond_mask, \
- .prediv.cond_value = _prediv_cond_value, \
- }
-
-#define MIPI_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _kshift, _kwidth, _kflags, _kmin, \
- _mshift, _mwidth, \
- _nshift, _nwidth, \
- _gate_shift, _lock_shift) \
- static struct aw_clk_mipi_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames) \
- }, \
- .offset = _offset, \
- .k.shift = _kshift, \
- .k.width = _kwidth, \
- .k.flags = _kflags, \
- .k.min_value = _kmin, \
- .m.shift = _mshift, \
- .m.width = _mwidth, \
- .n.shift = _nshift, \
- .n.width = _nwidth, \
- .gate_shift = _gate_shift, \
- .lock_shift = _lock_shift, \
- }
-
-#define MUX_CLK(_clkname, _id, _name, _pnames, \
- _offset, _shift, _width) \
- static struct clk_mux_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames) \
- }, \
- .offset = _offset, \
- .shift = _shift, \
- .width = _width, \
- }
-
-#define DIV_CLK(_clkname, _id, _name, _pnames, \
- _offset, \
- _i_shift, _i_width, \
- _div_flags, _div_table) \
- static struct clk_div_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = nitems(_pnames) \
- }, \
- .offset = _offset, \
- .i_shift = _i_shift, \
- .i_width = _i_width, \
- .div_flags = _div_flags, \
- .div_table = _div_table, \
- }
-
-#define FIXED_CLK(_clkname, _id, _name, _pnames, \
- _freq, _mult, _div, _flags) \
- static struct clk_fixed_def _clkname = { \
- .clkdef = { \
- .id = _id, \
- .name = _name, \
- .parent_names = _pnames, \
- .parent_cnt = 1, \
- }, \
- .freq = _freq, \
- .mult = _mult, \
- .div = _div, \
- .fixed_flags = _flags, \
- }
-
-#endif /* __AW_CLK_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_frac.c b/sys/arm/allwinner/clkng/aw_clk_frac.c
deleted file mode 100644
index 93235c0d3b15..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_frac.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/*-
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_frac.h>
-
-#include "clkdev_if.h"
-
-/* #define dprintf(format, arg...) printf("%s:(%s)" format, __func__, clknode_get_name(clk), arg) */
-#define dprintf(format, arg...)
-
-/*
- * clknode for clocks matching the formula :
- *
- * clk = (24Mhz * n) / m in integer mode
- * clk = frac_out1 or frac_out2 in fractional mode
- *
- */
-
-struct aw_clk_frac_sc {
- uint32_t offset;
-
- struct aw_clk_factor m;
- struct aw_clk_factor n;
- struct aw_clk_frac frac;
-
- uint64_t min_freq;
- uint64_t max_freq;
-
- uint32_t mux_shift;
- uint32_t mux_mask;
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-static int
-aw_clk_frac_init(struct clknode *clk, device_t dev)
-{
- struct aw_clk_frac_sc *sc;
- uint32_t val, idx;
-
- sc = clknode_get_softc(clk);
-
- idx = 0;
- if ((sc->flags & AW_CLK_HAS_MUX) != 0) {
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- idx = (val & sc->mux_mask) >> sc->mux_shift;
- }
-
- dprintf("init parent idx %d\n", idx);
- clknode_init_parent_idx(clk, idx);
- return (0);
-}
-
-static int
-aw_clk_frac_set_gate(struct clknode *clk, bool enable)
-{
- struct aw_clk_frac_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_GATE) == 0)
- return (0);
-
- dprintf("%sabling gate\n", enable ? "En" : "Dis");
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- if (enable)
- val |= (1 << sc->gate_shift);
- else
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static int
-aw_clk_frac_set_mux(struct clknode *clk, int index)
-{
- struct aw_clk_frac_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_MUX) == 0)
- return (0);
-
- dprintf("Set mux to %d\n", index);
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- val &= ~sc->mux_mask;
- val |= index << sc->mux_shift;
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static uint64_t
-aw_clk_frac_find_best(struct aw_clk_frac_sc *sc, uint64_t fparent, uint64_t fout,
- uint32_t *factor_n, uint32_t *factor_m)
-{
- uint64_t cur, best;
- uint32_t m, n, max_m, max_n, min_m, min_n;
-
- *factor_n = *factor_m = 0;
- best = cur = 0;
-
- max_m = aw_clk_factor_get_max(&sc->m);
- max_n = aw_clk_factor_get_max(&sc->n);
- min_m = aw_clk_factor_get_min(&sc->m);
- min_n = sc->min_freq / fparent;
-
- for (n = min_n; n <= max_n; n++) {
- for (m = min_m; m <= max_m; m++) {
- cur = fparent * n / m;
- if (cur < sc->min_freq) {
- continue;
- }
- if (cur > sc->max_freq) {
- continue;
- }
- if (cur == fout) {
- *factor_n = n;
- *factor_m = m;
- return (cur);
- }
- if (abs((fout - cur)) < abs((fout - best))) {
- best = cur;
- *factor_n = n;
- *factor_m = m;
- }
- }
- }
-
- return (best);
-}
-
-static int
-aw_clk_frac_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
- int flags, int *stop)
-{
- struct aw_clk_frac_sc *sc;
- uint64_t cur, best, best_frac;
- uint32_t val, m, n, best_m, best_n;
- int retry, multiple, max_mult, best_mult;
-
- sc = clknode_get_softc(clk);
-
- best = best_frac = cur = 0;
- best_mult = 0;
- max_mult = 1;
-
- dprintf("Trying to find freq %ju with parent %ju\n", *fout, fparent);
- if ((flags & CLK_SET_ROUND_MULTIPLE) != 0)
- max_mult = 10;
- for (multiple = 1; multiple <= max_mult; multiple++) {
- /* First test the fractional frequencies */
- dprintf("Testing with multiple %d\n", multiple);
- if (*fout * multiple == sc->frac.freq0) {
- best = best_frac = sc->frac.freq0;
- best_mult = multiple;
- dprintf("Found with using frac.freq0 and multiple %d\n", multiple);
- break;
- }
- else if (*fout * multiple == sc->frac.freq1) {
- best = best_frac = sc->frac.freq1;
- best_mult = multiple;
- dprintf("Found with using frac.freq1 and multiple %d\n", multiple);
- break;
- }
- else {
- cur = aw_clk_frac_find_best(sc, fparent, *fout * multiple,
- &n, &m);
- dprintf("Got %ju with n=%d, m=%d\n", cur, n, m);
- if (cur == (*fout * multiple)) {
- best = cur;
- best_mult = multiple;
- best_n = n;
- best_m = m;
- dprintf("This is the one: n=%d m=%d mult=%d\n", best_n, best_m, best_mult);
- break;
- }
- if (abs(((*fout * multiple) - cur)) < abs(((*fout * multiple) - best))) {
- best = cur;
- best_mult = multiple;
- best_n = n;
- best_m = m;
- dprintf("This is the best for now: n=%d m=%d mult=%d\n", best_n, best_m, best_mult);
- }
- }
- }
-
- if (best < sc->min_freq ||
- best > sc->max_freq) {
- printf("%s: Cannot set %ju for %s (min=%ju max=%ju)\n",
- __func__, best, clknode_get_name(clk),
- sc->min_freq, sc->max_freq);
- return (ERANGE);
- }
- if ((flags & CLK_SET_DRYRUN) != 0) {
- *fout = best;
- *stop = 1;
- return (0);
- }
-
- if ((best < (*fout * best_mult)) &&
- ((flags & CLK_SET_ROUND_DOWN) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
- if ((best > *fout * best_mult) &&
- ((flags & CLK_SET_ROUND_UP) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- /* Disable clock during freq changes */
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
-
- if (best_frac != 0) {
- val &= ~sc->frac.mode_sel;
- /* M should be 0 per the manual */
- val &= ~sc->m.mask;
- if (best_frac == sc->frac.freq0)
- val &= ~sc->frac.freq_sel;
- else
- val |= sc->frac.freq_sel;
- } else {
- val |= sc->frac.mode_sel; /* Select integer mode */
- n = aw_clk_factor_get_value(&sc->n, best_n);
- m = aw_clk_factor_get_value(&sc->m, best_m);
- val &= ~sc->n.mask;
- val &= ~sc->m.mask;
- val |= n << sc->n.shift;
- val |= m << sc->m.shift;
- }
-
- /* Write the clock changes */
- WRITE4(clk, sc->offset, val);
-
- /* Enable clock now that we've change it */
- val |= 1 << sc->gate_shift;
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- for (retry = 0; retry < sc->lock_retries; retry++) {
- READ4(clk, sc->offset, &val);
- if ((val & (1 << sc->lock_shift)) != 0)
- break;
- DELAY(1000);
- }
-
- *fout = best;
- *stop = 1;
-
- return (0);
-}
-
-static int
-aw_clk_frac_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_frac_sc *sc;
- uint32_t val, m, n;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- if ((val & sc->frac.mode_sel) == 0) {
- if (val & sc->frac.freq_sel)
- *freq = sc->frac.freq1;
- else
- *freq = sc->frac.freq0;
- } else {
- m = aw_clk_get_factor(val, &sc->m);
- n = aw_clk_get_factor(val, &sc->n);
- *freq = *freq * n / m;
- }
-
- return (0);
-}
-
-static clknode_method_t aw_frac_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_frac_init),
- CLKNODEMETHOD(clknode_set_gate, aw_clk_frac_set_gate),
- CLKNODEMETHOD(clknode_set_mux, aw_clk_frac_set_mux),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_frac_recalc),
- CLKNODEMETHOD(clknode_set_freq, aw_clk_frac_set_freq),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_frac_clknode, aw_frac_clknode_class, aw_frac_clknode_methods,
- sizeof(struct aw_clk_frac_sc), clknode_class);
-
-int
-aw_clk_frac_register(struct clkdom *clkdom, struct aw_clk_frac_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_frac_sc *sc;
-
- clk = clknode_create(clkdom, &aw_frac_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->m.shift = clkdef->m.shift;
- sc->m.width = clkdef->m.width;
- sc->m.mask = ((1 << sc->m.width) - 1) << sc->m.shift;
- sc->m.value = clkdef->m.value;
- sc->m.flags = clkdef->m.flags;
-
- sc->n.shift = clkdef->n.shift;
- sc->n.width = clkdef->n.width;
- sc->n.mask = ((1 << sc->n.width) - 1) << sc->n.shift;
- sc->n.value = clkdef->n.value;
- sc->n.flags = clkdef->n.flags;
-
- sc->frac.freq0 = clkdef->frac.freq0;
- sc->frac.freq1 = clkdef->frac.freq1;
- sc->frac.mode_sel = 1 << clkdef->frac.mode_sel;
- sc->frac.freq_sel = 1 << clkdef->frac.freq_sel;
-
- sc->min_freq = clkdef->min_freq;
- sc->max_freq = clkdef->max_freq;
-
- sc->mux_shift = clkdef->mux_shift;
- sc->mux_mask = ((1 << clkdef->mux_width) - 1) << sc->mux_shift;
-
- sc->gate_shift = clkdef->gate_shift;
-
- sc->lock_shift = clkdef->lock_shift;
- sc->lock_retries = clkdef->lock_retries;
-
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_frac.h b/sys/arm/allwinner/clkng/aw_clk_frac.h
deleted file mode 100644
index 5206e1daf9e7..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_frac.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_FRAC_H__
-#define __AW_CLK_FRAC_H__
-
-#include <dev/extres/clk/clk.h>
-
-struct aw_clk_frac_def {
- struct clknode_init_def clkdef;
- uint32_t offset;
-
- struct aw_clk_factor m;
- struct aw_clk_factor n;
- struct aw_clk_frac frac;
-
- uint64_t min_freq;
- uint64_t max_freq;
-
- uint32_t mux_shift;
- uint32_t mux_width;
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-int aw_clk_frac_register(struct clkdom *clkdom, struct aw_clk_frac_def *clkdef);
-
-#endif /* __AW_CLK_FRAC_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_m.c b/sys/arm/allwinner/clkng/aw_clk_m.c
deleted file mode 100644
index 9f2dea6722bc..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_m.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*-
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_m.h>
-
-#include "clkdev_if.h"
-
-/*
- * clknode for clocks matching the formula :
- *
- * clk = clkin / m
- * And that needs to potentially :
- * 1) Set the parent freq
- * 2) Support Setting the parent to a multiple
- *
- */
-
-struct aw_clk_m_sc {
- uint32_t offset;
-
- struct aw_clk_factor m;
-
- uint32_t mux_shift;
- uint32_t mux_mask;
- uint32_t gate_shift;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-static int
-aw_clk_m_init(struct clknode *clk, device_t dev)
-{
- struct aw_clk_m_sc *sc;
- uint32_t val, idx;
-
- sc = clknode_get_softc(clk);
-
- idx = 0;
- if ((sc->flags & AW_CLK_HAS_MUX) != 0) {
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- idx = (val & sc->mux_mask) >> sc->mux_shift;
- }
-
- clknode_init_parent_idx(clk, idx);
- return (0);
-}
-
-static int
-aw_clk_m_set_gate(struct clknode *clk, bool enable)
-{
- struct aw_clk_m_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_GATE) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- if (enable)
- val |= (1 << sc->gate_shift);
- else
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static int
-aw_clk_m_set_mux(struct clknode *clk, int index)
-{
- struct aw_clk_m_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_MUX) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- val &= ~sc->mux_mask;
- val |= index << sc->mux_shift;
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static uint64_t
-aw_clk_m_find_best(struct aw_clk_m_sc *sc, uint64_t fparent, uint64_t *fout,
- uint32_t *factor_m)
-{
- uint64_t cur, best;
- uint32_t m, max_m, min_m;
-
- *factor_m = 0;
-
- max_m = aw_clk_factor_get_max(&sc->m);
- min_m = aw_clk_factor_get_min(&sc->m);
-
- for (m = min_m; m <= max_m; ) {
- cur = fparent / m;
- if (abs(*fout - cur) < abs(*fout - best)) {
- best = cur;
- *factor_m = m;
- }
- if ((sc->m.flags & AW_CLK_FACTOR_POWER_OF_TWO) != 0)
- m <<= 1;
- else
- m++;
- }
-
- return (best);
-}
-
-static int
-aw_clk_m_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
- int flags, int *stop)
-{
- struct aw_clk_m_sc *sc;
- struct clknode *p_clk;
- uint64_t cur, best;
- uint32_t val, m, best_m;
-
- sc = clknode_get_softc(clk);
-
- best = cur = 0;
-
- best = aw_clk_m_find_best(sc, fparent, fout,
- &best_m);
- if ((best != *fout) && ((sc->flags & AW_CLK_SET_PARENT) != 0)) {
- p_clk = clknode_get_parent(clk);
- if (p_clk == NULL) {
- printf("%s: Cannot get parent for clock %s\n",
- __func__,
- clknode_get_name(clk));
- return (ENXIO);
- }
- clknode_set_freq(p_clk, *fout, CLK_SET_ROUND_MULTIPLE, 0);
- clknode_get_freq(p_clk, &fparent);
- best = aw_clk_m_find_best(sc, fparent, fout,
- &best_m);
- }
-
- if ((flags & CLK_SET_DRYRUN) != 0) {
- *fout = best;
- *stop = 1;
- return (0);
- }
-
- if ((best < *fout) &&
- ((flags & CLK_SET_ROUND_DOWN) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
- if ((best > *fout) &&
- ((flags & CLK_SET_ROUND_UP) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
-
- m = aw_clk_factor_get_value(&sc->m, best_m);
- val &= ~sc->m.mask;
- val |= m << sc->m.shift;
-
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- *fout = best;
- *stop = 1;
-
- return (0);
-}
-
-static int
-aw_clk_m_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_m_sc *sc;
- uint32_t val, m;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- m = aw_clk_get_factor(val, &sc->m);
-
- *freq = *freq / m;
-
- return (0);
-}
-
-static clknode_method_t aw_m_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_m_init),
- CLKNODEMETHOD(clknode_set_gate, aw_clk_m_set_gate),
- CLKNODEMETHOD(clknode_set_mux, aw_clk_m_set_mux),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_m_recalc),
- CLKNODEMETHOD(clknode_set_freq, aw_clk_m_set_freq),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_m_clknode, aw_m_clknode_class, aw_m_clknode_methods,
- sizeof(struct aw_clk_m_sc), clknode_class);
-
-int
-aw_clk_m_register(struct clkdom *clkdom, struct aw_clk_m_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_m_sc *sc;
-
- clk = clknode_create(clkdom, &aw_m_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->m.shift = clkdef->m.shift;
- sc->m.width = clkdef->m.width;
- sc->m.mask = ((1 << sc->m.width) - 1) << sc->m.shift;
- sc->m.value = clkdef->m.value;
- sc->m.flags = clkdef->m.flags;
-
- sc->mux_shift = clkdef->mux_shift;
- sc->mux_mask = ((1 << clkdef->mux_width) - 1) << sc->mux_shift;
-
- sc->gate_shift = clkdef->gate_shift;
-
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_m.h b/sys/arm/allwinner/clkng/aw_clk_m.h
deleted file mode 100644
index 028a1fe541cf..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_m.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_M_H__
-#define __AW_CLK_M_H__
-
-#include <dev/extres/clk/clk.h>
-
-struct aw_clk_m_def {
- struct clknode_init_def clkdef;
- uint32_t offset;
-
- struct aw_clk_factor m;
-
- uint32_t mux_shift;
- uint32_t mux_width;
- uint32_t gate_shift;
-
- uint32_t flags;
-};
-
-int aw_clk_m_register(struct clkdom *clkdom, struct aw_clk_m_def *clkdef);
-
-#endif /* __AW_CLK_M_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_mipi.c b/sys/arm/allwinner/clkng/aw_clk_mipi.c
deleted file mode 100644
index 350d0355f4eb..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_mipi.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*-
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_mipi.h>
-
-#include "clkdev_if.h"
-
-/* #define dprintf(format, arg...) printf("%s:(%s)" format, __func__, clknode_get_name(clk), arg) */
-#define dprintf(format, arg...)
-
-/*
- * clknode for PLL_MIPI :
- *
- * clk = (pll_video0 * n * k) / m when vfb_sel=0
- * clk depend on sint_frac, sdiv2, s6p25_7p5, pll_feedback_div when vfb_sel=1
- *
- */
-
-struct aw_clk_mipi_sc {
- uint32_t offset;
-
- struct aw_clk_factor k;
- struct aw_clk_factor m;
- struct aw_clk_factor n;
-
- uint64_t min_freq;
- uint64_t max_freq;
-
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-#define LDO1_EN_SHIFT 23
-#define LDO2_EN_SHIFT 22
-#define VFB_SEL_SHIFT 16
-
-static int
-aw_clk_mipi_init(struct clknode *clk, device_t dev)
-{
-
- clknode_init_parent_idx(clk, 0);
- return (0);
-}
-
-static int
-aw_clk_mipi_set_gate(struct clknode *clk, bool enable)
-{
- struct aw_clk_mipi_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- dprintf("%sabling gate\n", enable ? "En" : "Dis");
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- if (enable) {
- val |= (1 << sc->gate_shift);
- val |= (1 << LDO1_EN_SHIFT);
- val |= (1 << LDO2_EN_SHIFT);
- } else {
- val &= ~(1 << sc->gate_shift);
- val &= ~(1 << LDO1_EN_SHIFT);
- val &= ~(1 << LDO2_EN_SHIFT);
- }
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static uint64_t
-aw_clk_mipi_find_best(struct aw_clk_mipi_sc *sc, uint64_t fparent, uint64_t *fout,
- uint32_t *factor_k, uint32_t *factor_m, uint32_t *factor_n)
-{
- uint64_t cur, best;
- uint32_t n, k, m;
-
- best = 0;
- *factor_n = 0;
- *factor_k = 0;
- *factor_m = 0;
-
- for (n = aw_clk_factor_get_min(&sc->n); n <= aw_clk_factor_get_max(&sc->n); n++) {
- for (k = aw_clk_factor_get_min(&sc->k); k <= aw_clk_factor_get_max(&sc->k); k++) {
- for (m = aw_clk_factor_get_min(&sc->m); m <= aw_clk_factor_get_max(&sc->m); m++) {
- cur = (fparent * n * k) / m;
- if ((*fout - cur) < (*fout - best)) {
- best = cur;
- *factor_n = n;
- *factor_k = k;
- *factor_m = m;
- }
- if (best == *fout)
- return (best);
- }
- }
- }
-
- return best;
-}
-
-static int
-aw_clk_mipi_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
- int flags, int *stop)
-{
- struct aw_clk_mipi_sc *sc;
- uint64_t best = 0;
- uint32_t best_k, best_m, best_n;
- uint32_t k, m, n;
- uint32_t val;
- uint32_t retry;
-
- sc = clknode_get_softc(clk);
-
- best = aw_clk_mipi_find_best(sc, fparent, fout, &best_k, &best_m, &best_n);
-
- if (best < sc->min_freq ||
- best > sc->max_freq) {
- printf("%s: Cannot set %ju for %s (min=%ju max=%ju)\n",
- __func__, best, clknode_get_name(clk),
- sc->min_freq, sc->max_freq);
- return (ERANGE);
- }
- if ((flags & CLK_SET_DRYRUN) != 0) {
- *fout = best;
- *stop = 1;
- return (0);
- }
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- /* Disable clock during freq changes */
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
-
- k = aw_clk_factor_get_value(&sc->k, best_k);
- n = aw_clk_factor_get_value(&sc->n, best_n);
- m = aw_clk_factor_get_value(&sc->m, best_m);
- val &= ~sc->k.mask;
- val &= ~sc->m.mask;
- val &= ~sc->n.mask;
- val |= k << sc->k.shift;
- val |= m << sc->m.shift;
- val |= n << sc->n.shift;
-
- /* Write the clock changes */
- WRITE4(clk, sc->offset, val);
-
- /* Enable clock now that we've change it */
- val |= 1 << sc->gate_shift;
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- for (retry = 0; retry < sc->lock_retries; retry++) {
- READ4(clk, sc->offset, &val);
- if ((val & (1 << sc->lock_shift)) != 0)
- break;
- DELAY(1000);
- }
-
- *fout = best;
- *stop = 1;
-
- return (0);
-}
-
-static int
-aw_clk_mipi_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_mipi_sc *sc;
- uint32_t val, m, n, k;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- k = aw_clk_get_factor(val, &sc->k);
- m = aw_clk_get_factor(val, &sc->m);
- n = aw_clk_get_factor(val, &sc->n);
-
- *freq = (*freq * n * k) / m;
-
- return (0);
-}
-
-static clknode_method_t aw_mipi_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_mipi_init),
- CLKNODEMETHOD(clknode_set_gate, aw_clk_mipi_set_gate),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_mipi_recalc),
- CLKNODEMETHOD(clknode_set_freq, aw_clk_mipi_set_freq),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_mipi_clknode, aw_mipi_clknode_class, aw_mipi_clknode_methods,
- sizeof(struct aw_clk_mipi_sc), clknode_class);
-
-int
-aw_clk_mipi_register(struct clkdom *clkdom, struct aw_clk_mipi_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_mipi_sc *sc;
-
- clk = clknode_create(clkdom, &aw_mipi_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->k.shift = clkdef->k.shift;
- sc->k.width = clkdef->k.width;
- sc->k.mask = ((1 << sc->k.width) - 1) << sc->k.shift;
- sc->k.value = clkdef->k.value;
- sc->k.flags = clkdef->k.flags;
- sc->k.min_value = clkdef->k.min_value;
-
- sc->m.shift = clkdef->m.shift;
- sc->m.width = clkdef->m.width;
- sc->m.mask = ((1 << sc->m.width) - 1) << sc->m.shift;
- sc->m.value = clkdef->m.value;
- sc->m.flags = clkdef->m.flags;
- sc->m.min_value = clkdef->m.min_value;
-
- sc->n.shift = clkdef->n.shift;
- sc->n.width = clkdef->n.width;
- sc->n.mask = ((1 << sc->n.width) - 1) << sc->n.shift;
- sc->n.value = clkdef->n.value;
- sc->n.flags = clkdef->n.flags;
- sc->n.min_value = clkdef->n.min_value;
-
- sc->min_freq = clkdef->min_freq;
- sc->max_freq = clkdef->max_freq;
-
- sc->gate_shift = clkdef->gate_shift;
-
- sc->lock_shift = clkdef->lock_shift;
- sc->lock_retries = clkdef->lock_retries;
-
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_mipi.h b/sys/arm/allwinner/clkng/aw_clk_mipi.h
deleted file mode 100644
index e2fe50003e97..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_mipi.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_MIPI_H__
-#define __AW_CLK_MIPI_H__
-
-#include <dev/extres/clk/clk.h>
-
-struct aw_clk_mipi_def {
- struct clknode_init_def clkdef;
- uint32_t offset;
-
- struct aw_clk_factor k;
- struct aw_clk_factor m;
- struct aw_clk_factor n;
-
- uint64_t min_freq;
- uint64_t max_freq;
-
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-int aw_clk_mipi_register(struct clkdom *clkdom, struct aw_clk_mipi_def *clkdef);
-
-#endif /* __AW_CLK_MIPI_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_nkmp.c b/sys/arm/allwinner/clkng/aw_clk_nkmp.c
deleted file mode 100644
index 71afa3149a02..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_nkmp.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/*-
- * Copyright (c) 2017 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_nkmp.h>
-
-#include "clkdev_if.h"
-
-/*
- * clknode for clocks matching the formula :
- *
- * clk = (clkin * n * k) / (m * p)
- *
- */
-
-struct aw_clk_nkmp_sc {
- uint32_t offset;
-
- struct aw_clk_factor n;
- struct aw_clk_factor k;
- struct aw_clk_factor m;
- struct aw_clk_factor p;
-
- uint32_t mux_shift;
- uint32_t mux_mask;
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
- uint32_t update_shift;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define MODIFY4(_clk, off, clr, set ) \
- CLKDEV_MODIFY_4(clknode_get_device(_clk), off, clr, set)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-static int
-aw_clk_nkmp_init(struct clknode *clk, device_t dev)
-{
- struct aw_clk_nkmp_sc *sc;
- uint32_t val, idx;
-
- sc = clknode_get_softc(clk);
-
- idx = 0;
- if ((sc->flags & AW_CLK_HAS_MUX) != 0) {
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- idx = (val & sc->mux_mask) >> sc->mux_shift;
- }
-
- clknode_init_parent_idx(clk, idx);
- return (0);
-}
-
-static int
-aw_clk_nkmp_set_gate(struct clknode *clk, bool enable)
-{
- struct aw_clk_nkmp_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_GATE) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- if (enable)
- val |= (1 << sc->gate_shift);
- else
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static int
-aw_clk_nkmp_set_mux(struct clknode *clk, int index)
-{
- struct aw_clk_nkmp_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_MUX) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- val &= ~sc->mux_mask;
- val |= index << sc->mux_shift;
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static uint64_t
-aw_clk_nkmp_find_best(struct aw_clk_nkmp_sc *sc, uint64_t fparent, uint64_t *fout,
- uint32_t *factor_n, uint32_t *factor_k, uint32_t *factor_m, uint32_t *factor_p)
-{
- uint64_t cur, best;
- uint32_t n, k, m, p;
-
- best = 0;
- *factor_n = 0;
- *factor_k = 0;
- *factor_m = 0;
- *factor_p = 0;
-
- for (n = aw_clk_factor_get_min(&sc->n); n <= aw_clk_factor_get_max(&sc->n); ) {
- for (k = aw_clk_factor_get_min(&sc->k); k <= aw_clk_factor_get_max(&sc->k); ) {
- for (m = aw_clk_factor_get_min(&sc->m); m <= aw_clk_factor_get_max(&sc->m); ) {
- for (p = aw_clk_factor_get_min(&sc->p); p <= aw_clk_factor_get_max(&sc->p); ) {
- cur = (fparent * n * k) / (m * p);
- if ((*fout - cur) < (*fout - best)) {
- best = cur;
- *factor_n = n;
- *factor_k = k;
- *factor_m = m;
- *factor_p = p;
- }
- if (best == *fout)
- return (best);
- if ((sc->p.flags & AW_CLK_FACTOR_POWER_OF_TWO) != 0)
- p <<= 1;
- else
- p++;
- }
- if ((sc->m.flags & AW_CLK_FACTOR_POWER_OF_TWO) != 0)
- m <<= 1;
- else
- m++;
- }
- if ((sc->k.flags & AW_CLK_FACTOR_POWER_OF_TWO) != 0)
- k <<= 1;
- else
- k++;
- }
- if ((sc->n.flags & AW_CLK_FACTOR_POWER_OF_TWO) != 0)
- n <<= 1;
- else
- n++;
- }
-
- return best;
-}
-
-static void
-aw_clk_nkmp_set_freq_scale(struct clknode *clk, struct aw_clk_nkmp_sc *sc,
- uint32_t factor_n, uint32_t factor_k, uint32_t factor_m, uint32_t factor_p)
-{
- uint32_t val, m, p;
- int retry;
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
-
- m = aw_clk_get_factor(val, &sc->m);
- p = aw_clk_get_factor(val, &sc->p);
-
- if (p < factor_p) {
- val &= ~sc->p.mask;
- val |= aw_clk_factor_get_value(&sc->p, factor_p) << sc->p.shift;
- WRITE4(clk, sc->offset, val);
- DELAY(2000);
- }
-
- if (m < factor_m) {
- val &= ~sc->m.mask;
- val |= aw_clk_factor_get_value(&sc->m, factor_m) << sc->m.shift;
- WRITE4(clk, sc->offset, val);
- DELAY(2000);
- }
-
- val &= ~sc->n.mask;
- val &= ~sc->k.mask;
- val |= aw_clk_factor_get_value(&sc->n, factor_n) << sc->n.shift;
- val |= aw_clk_factor_get_value(&sc->k, factor_k) << sc->k.shift;
- WRITE4(clk, sc->offset, val);
- DELAY(2000);
-
- if (m > factor_m) {
- val &= ~sc->m.mask;
- val |= aw_clk_factor_get_value(&sc->m, factor_m) << sc->m.shift;
- WRITE4(clk, sc->offset, val);
- DELAY(2000);
- }
-
- if (p > factor_p) {
- val &= ~sc->p.mask;
- val |= aw_clk_factor_get_value(&sc->p, factor_p) << sc->p.shift;
- WRITE4(clk, sc->offset, val);
- DELAY(2000);
- }
-
- if ((sc->flags & AW_CLK_HAS_LOCK) != 0) {
- for (retry = 0; retry < sc->lock_retries; retry++) {
- READ4(clk, sc->offset, &val);
- if ((val & (1 << sc->lock_shift)) != 0)
- break;
- DELAY(1000);
- }
- }
-
- DEVICE_UNLOCK(clk);
-}
-
-static int
-aw_clk_nkmp_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
- int flags, int *stop)
-{
- struct aw_clk_nkmp_sc *sc;
- uint64_t best;
- uint32_t val, best_n, best_k, best_m, best_p;
- int retry;
-
- sc = clknode_get_softc(clk);
-
- best = aw_clk_nkmp_find_best(sc, fparent, fout,
- &best_n, &best_k, &best_m, &best_p);
- if ((flags & CLK_SET_DRYRUN) != 0) {
- *fout = best;
- *stop = 1;
- return (0);
- }
-
- if ((best < *fout) &&
- ((flags & CLK_SET_ROUND_DOWN) != 0)) {
- *stop = 1;
- return (ERANGE);
- }
- if ((best > *fout) &&
- ((flags & CLK_SET_ROUND_UP) != 0)) {
- *stop = 1;
- return (ERANGE);
- }
-
- if ((sc->flags & AW_CLK_SCALE_CHANGE) != 0)
- aw_clk_nkmp_set_freq_scale(clk, sc,
- best_n, best_k, best_m, best_p);
- else {
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- val &= ~sc->n.mask;
- val &= ~sc->k.mask;
- val &= ~sc->m.mask;
- val &= ~sc->p.mask;
- val |= aw_clk_factor_get_value(&sc->n, best_n) << sc->n.shift;
- val |= aw_clk_factor_get_value(&sc->k, best_k) << sc->k.shift;
- val |= aw_clk_factor_get_value(&sc->m, best_m) << sc->m.shift;
- val |= aw_clk_factor_get_value(&sc->p, best_p) << sc->p.shift;
- WRITE4(clk, sc->offset, val);
- DELAY(2000);
- DEVICE_UNLOCK(clk);
-
- if ((sc->flags & AW_CLK_HAS_UPDATE) != 0) {
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- val |= 1 << sc->update_shift;
- WRITE4(clk, sc->offset, val);
- DELAY(2000);
- DEVICE_UNLOCK(clk);
- }
-
- if ((sc->flags & AW_CLK_HAS_LOCK) != 0) {
- for (retry = 0; retry < sc->lock_retries; retry++) {
- READ4(clk, sc->offset, &val);
- if ((val & (1 << sc->lock_shift)) != 0)
- break;
- DELAY(1000);
- }
- }
- }
-
- *fout = best;
- *stop = 1;
-
- return (0);
-}
-
-static int
-aw_clk_nkmp_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_nkmp_sc *sc;
- uint32_t val, m, n, k, p;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- n = aw_clk_get_factor(val, &sc->n);
- k = aw_clk_get_factor(val, &sc->k);
- m = aw_clk_get_factor(val, &sc->m);
- p = aw_clk_get_factor(val, &sc->p);
-
- *freq = (*freq * n * k) / (m * p);
-
- return (0);
-}
-
-static clknode_method_t aw_nkmp_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_nkmp_init),
- CLKNODEMETHOD(clknode_set_gate, aw_clk_nkmp_set_gate),
- CLKNODEMETHOD(clknode_set_mux, aw_clk_nkmp_set_mux),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_nkmp_recalc),
- CLKNODEMETHOD(clknode_set_freq, aw_clk_nkmp_set_freq),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_nkmp_clknode, aw_nkmp_clknode_class, aw_nkmp_clknode_methods,
- sizeof(struct aw_clk_nkmp_sc), clknode_class);
-
-int
-aw_clk_nkmp_register(struct clkdom *clkdom, struct aw_clk_nkmp_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_nkmp_sc *sc;
-
- clk = clknode_create(clkdom, &aw_nkmp_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->n.shift = clkdef->n.shift;
- sc->n.width = clkdef->n.width;
- sc->n.mask = ((1 << clkdef->n.width) - 1) << sc->n.shift;
- sc->n.value = clkdef->n.value;
- sc->n.flags = clkdef->n.flags;
-
- sc->k.shift = clkdef->k.shift;
- sc->k.width = clkdef->k.width;
- sc->k.mask = ((1 << clkdef->k.width) - 1) << sc->k.shift;
- sc->k.value = clkdef->k.value;
- sc->k.flags = clkdef->k.flags;
-
- sc->m.shift = clkdef->m.shift;
- sc->m.width = clkdef->m.width;
- sc->m.mask = ((1 << clkdef->m.width) - 1) << sc->m.shift;
- sc->m.value = clkdef->m.value;
- sc->m.flags = clkdef->m.flags;
-
- sc->p.shift = clkdef->p.shift;
- sc->p.width = clkdef->p.width;
- sc->p.mask = ((1 << clkdef->p.width) - 1) << sc->p.shift;
- sc->p.value = clkdef->p.value;
- sc->p.flags = clkdef->p.flags;
-
- sc->mux_shift = clkdef->mux_shift;
- sc->mux_mask = ((1 << clkdef->mux_width) - 1) << sc->mux_shift;
-
- sc->gate_shift = clkdef->gate_shift;
- sc->lock_shift = clkdef->lock_shift;
- sc->lock_retries = clkdef->lock_retries;
- sc->update_shift = clkdef->update_shift;
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_nkmp.h b/sys/arm/allwinner/clkng/aw_clk_nkmp.h
deleted file mode 100644
index a0c381830eb4..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_nkmp.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 2017 Emmanuel Vadot <manu@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_NKMP_H__
-#define __AW_CLK_NKMP_H__
-
-#include <arm/allwinner/clkng/aw_clk.h>
-
-struct aw_clk_nkmp_def {
- struct clknode_init_def clkdef;
-
- uint32_t offset;
-
- struct aw_clk_factor m;
- struct aw_clk_factor k;
- struct aw_clk_factor n;
- struct aw_clk_factor p;
-
- uint32_t mux_shift;
- uint32_t mux_width;
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
- uint32_t update_shift;
-
- uint32_t flags;
-};
-
-int aw_clk_nkmp_register(struct clkdom *clkdom, struct aw_clk_nkmp_def *clkdef);
-
-#endif /* __AW_CLK_NKMP_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_nm.c b/sys/arm/allwinner/clkng/aw_clk_nm.c
deleted file mode 100644
index c7a302207b65..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_nm.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*-
- * Copyright (c) 2017 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_nm.h>
-
-#include "clkdev_if.h"
-
-/*
- * clknode for clocks matching the formula :
- *
- * clk = clkin / n / m
- *
- */
-
-struct aw_clk_nm_sc {
- uint32_t offset;
-
- struct aw_clk_factor m;
- struct aw_clk_factor n;
- struct aw_clk_factor prediv;
-
- uint32_t mux_shift;
- uint32_t mux_mask;
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-static int
-aw_clk_nm_init(struct clknode *clk, device_t dev)
-{
- struct aw_clk_nm_sc *sc;
- uint32_t val, idx;
-
- sc = clknode_get_softc(clk);
-
- idx = 0;
- if ((sc->flags & AW_CLK_HAS_MUX) != 0) {
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- idx = (val & sc->mux_mask) >> sc->mux_shift;
- }
-
- clknode_init_parent_idx(clk, idx);
- return (0);
-}
-
-static int
-aw_clk_nm_set_gate(struct clknode *clk, bool enable)
-{
- struct aw_clk_nm_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_GATE) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- if (enable)
- val |= (1 << sc->gate_shift);
- else
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static int
-aw_clk_nm_set_mux(struct clknode *clk, int index)
-{
- struct aw_clk_nm_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_MUX) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- val &= ~sc->mux_mask;
- val |= index << sc->mux_shift;
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static uint64_t
-aw_clk_nm_find_best(struct aw_clk_nm_sc *sc, uint64_t fparent, uint64_t *fout,
- uint32_t *factor_n, uint32_t *factor_m)
-{
- uint64_t cur, best;
- uint32_t m, n, max_m, max_n, min_m, min_n;
-
- *factor_n = *factor_m = 0;
-
- max_m = aw_clk_factor_get_max(&sc->m);
- max_n = aw_clk_factor_get_max(&sc->n);
- min_m = aw_clk_factor_get_min(&sc->m);
- min_n = aw_clk_factor_get_min(&sc->n);
-
- for (m = min_m; m <= max_m; ) {
- for (n = min_n; n <= max_n; ) {
- cur = fparent / n / m;
- if (clk_freq_diff(*fout, cur) <
- clk_freq_diff(*fout, best)) {
- best = cur;
- *factor_n = n;
- *factor_m = m;
- }
-
- if ((sc->n.flags & AW_CLK_FACTOR_POWER_OF_TWO) != 0)
- n <<= 1;
- else
- n++;
- }
- if ((sc->m.flags & AW_CLK_FACTOR_POWER_OF_TWO) != 0)
- m <<= 1;
- else
- m++;
- }
-
- return (best);
-}
-
-static int
-aw_clk_nm_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
- int flags, int *stop)
-{
- struct aw_clk_nm_sc *sc;
- struct clknode *p_clk;
- const char **p_names;
- uint64_t cur, best;
- uint32_t val, m, n, best_m, best_n;
- int p_idx, best_parent, retry;
-
- sc = clknode_get_softc(clk);
-
- best = cur = 0;
- best_parent = 0;
-
- if ((sc->flags & AW_CLK_REPARENT) != 0) {
- p_names = clknode_get_parent_names(clk);
- for (p_idx = 0; p_idx != clknode_get_parents_num(clk); p_idx++) {
- p_clk = clknode_find_by_name(p_names[p_idx]);
- clknode_get_freq(p_clk, &fparent);
-
- cur = aw_clk_nm_find_best(sc, fparent, fout, &n, &m);
- if (clk_freq_diff(*fout, cur) <
- clk_freq_diff(*fout, best)) {
- best = cur;
- best_parent = p_idx;
- best_n = n;
- best_m = m;
- }
- }
-
- p_idx = clknode_get_parent_idx(clk);
- p_clk = clknode_get_parent(clk);
- clknode_get_freq(p_clk, &fparent);
- } else {
- best = aw_clk_nm_find_best(sc, fparent, fout,
- &best_n, &best_m);
- }
-
- if ((flags & CLK_SET_DRYRUN) != 0) {
- *fout = best;
- *stop = 1;
- return (0);
- }
-
- if ((best < *fout) &&
- ((flags & CLK_SET_ROUND_DOWN) == 0)) {
- *stop = 1;
- printf("best freq (%ju) < requested freq(%ju)\n",
- best, *fout);
- return (ERANGE);
- }
- if ((best > *fout) &&
- ((flags & CLK_SET_ROUND_UP) == 0)) {
- *stop = 1;
- printf("best freq (%ju) > requested freq(%ju)\n",
- best, *fout);
- return (ERANGE);
- }
-
- if ((sc->flags & AW_CLK_REPARENT) != 0 && p_idx != best_parent)
- clknode_set_parent_by_idx(clk, best_parent);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
-
- n = aw_clk_factor_get_value(&sc->n, best_n);
- m = aw_clk_factor_get_value(&sc->m, best_m);
- val &= ~sc->n.mask;
- val &= ~sc->m.mask;
- val |= n << sc->n.shift;
- val |= m << sc->m.shift;
-
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- if ((sc->flags & AW_CLK_HAS_LOCK) != 0) {
- for (retry = 0; retry < sc->lock_retries; retry++) {
- READ4(clk, sc->offset, &val);
- if ((val & (1 << sc->lock_shift)) != 0)
- break;
- DELAY(1000);
- }
- }
-
- *fout = best;
- *stop = 1;
-
- return (0);
-}
-
-static int
-aw_clk_nm_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_nm_sc *sc;
- uint32_t val, m, n, prediv;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- m = aw_clk_get_factor(val, &sc->m);
- n = aw_clk_get_factor(val, &sc->n);
- if (sc->flags & AW_CLK_HAS_PREDIV)
- prediv = aw_clk_get_factor(val, &sc->prediv);
- else
- prediv = 1;
-
- *freq = *freq / prediv / n / m;
-
- return (0);
-}
-
-static clknode_method_t aw_nm_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_nm_init),
- CLKNODEMETHOD(clknode_set_gate, aw_clk_nm_set_gate),
- CLKNODEMETHOD(clknode_set_mux, aw_clk_nm_set_mux),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_nm_recalc),
- CLKNODEMETHOD(clknode_set_freq, aw_clk_nm_set_freq),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_nm_clknode, aw_nm_clknode_class, aw_nm_clknode_methods,
- sizeof(struct aw_clk_nm_sc), clknode_class);
-
-int
-aw_clk_nm_register(struct clkdom *clkdom, struct aw_clk_nm_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_nm_sc *sc;
-
- clk = clknode_create(clkdom, &aw_nm_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->m.shift = clkdef->m.shift;
- sc->m.width = clkdef->m.width;
- sc->m.mask = ((1 << sc->m.width) - 1) << sc->m.shift;
- sc->m.value = clkdef->m.value;
- sc->m.flags = clkdef->m.flags;
-
- sc->n.shift = clkdef->n.shift;
- sc->n.width = clkdef->n.width;
- sc->n.mask = ((1 << sc->n.width) - 1) << sc->n.shift;
- sc->n.value = clkdef->n.value;
- sc->n.flags = clkdef->n.flags;
-
- sc->prediv.shift = clkdef->prediv.shift;
- sc->prediv.width = clkdef->prediv.width;
- sc->prediv.mask = ((1 << sc->prediv.width) - 1) << sc->prediv.shift;
- sc->prediv.value = clkdef->prediv.value;
- sc->prediv.flags = clkdef->prediv.flags;
- sc->prediv.cond_shift = clkdef->prediv.cond_shift;
- if (clkdef->prediv.cond_width != 0)
- sc->prediv.cond_mask = ((1 << clkdef->prediv.cond_width) - 1) << sc->prediv.shift;
- else
- sc->prediv.cond_mask = clkdef->prediv.cond_mask;
- sc->prediv.cond_value = clkdef->prediv.cond_value;
-
- sc->mux_shift = clkdef->mux_shift;
- sc->mux_mask = ((1 << clkdef->mux_width) - 1) << sc->mux_shift;
-
- sc->gate_shift = clkdef->gate_shift;
-
- sc->lock_shift = clkdef->lock_shift;
- sc->lock_retries = clkdef->lock_retries;
-
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_nm.h b/sys/arm/allwinner/clkng/aw_clk_nm.h
deleted file mode 100644
index f71027b789d0..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_nm.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 2017 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_NM_H__
-#define __AW_CLK_NM_H__
-
-#include <dev/extres/clk/clk.h>
-
-struct aw_clk_nm_def {
- struct clknode_init_def clkdef;
- uint32_t offset;
-
- struct aw_clk_factor m;
- struct aw_clk_factor n;
- struct aw_clk_factor prediv;
-
- uint32_t mux_shift;
- uint32_t mux_width;
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-int aw_clk_nm_register(struct clkdom *clkdom, struct aw_clk_nm_def *clkdef);
-
-#endif /* __AW_CLK_NM_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_nmm.c b/sys/arm/allwinner/clkng/aw_clk_nmm.c
deleted file mode 100644
index e12e83e4fae5..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_nmm.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_nmm.h>
-
-#include "clkdev_if.h"
-
-/*
- * clknode for clocks matching the formula :
- *
- * clk = clkin * n / m0 / m1
- *
- */
-
-struct aw_clk_nmm_sc {
- uint32_t offset;
-
- struct aw_clk_factor n;
- struct aw_clk_factor m0;
- struct aw_clk_factor m1;
-
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-static int
-aw_clk_nmm_init(struct clknode *clk, device_t dev)
-{
-
- clknode_init_parent_idx(clk, 0);
- return (0);
-}
-
-static int
-aw_clk_nmm_set_gate(struct clknode *clk, bool enable)
-{
- struct aw_clk_nmm_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_GATE) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- if (enable)
- val |= (1 << sc->gate_shift);
- else
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static uint64_t
-aw_clk_nmm_find_best(struct aw_clk_nmm_sc *sc, uint64_t fparent, uint64_t *fout,
- uint32_t *factor_n, uint32_t *factor_m0, uint32_t *factor_m1)
-{
- uint64_t cur, best;
- uint32_t n, m0, m1;
- uint32_t max_n, max_m0, max_m1;
- uint32_t min_n, min_m0, min_m1;
-
- *factor_n = *factor_m0 = *factor_m1 = 0;
-
- max_n = aw_clk_factor_get_max(&sc->n);
- min_n = aw_clk_factor_get_min(&sc->n);
- max_m0 = aw_clk_factor_get_max(&sc->m0);
- min_m0 = aw_clk_factor_get_min(&sc->m0);
- max_m1 = aw_clk_factor_get_max(&sc->m1);
- min_m1 = aw_clk_factor_get_min(&sc->m1);
-
- for (m0 = min_m0; m0 <= max_m0; ) {
- for (m1 = min_m1; m1 <= max_m1; ) {
- for (n = min_n; n <= max_n; ) {
- cur = fparent * n / m0 / m1;
- if (abs(*fout - cur) < abs(*fout - best)) {
- best = cur;
- *factor_n = n;
- *factor_m0 = m0;
- *factor_m1 = m1;
- }
- n++;
- }
- m1++;
- }
- m0++;
- }
-
- return (best);
-}
-
-static int
-aw_clk_nmm_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
- int flags, int *stop)
-{
- struct aw_clk_nmm_sc *sc;
- uint64_t cur, best;
- uint32_t val, n, m0, m1, best_n, best_m0, best_m1;
- int retry;
-
- sc = clknode_get_softc(clk);
-
- best = cur = 0;
-
- best = aw_clk_nmm_find_best(sc, fparent, fout,
- &best_n, &best_m0, &best_m1);
-
- if ((flags & CLK_SET_DRYRUN) != 0) {
- *fout = best;
- *stop = 1;
- return (0);
- }
-
- if ((best < *fout) &&
- ((flags & CLK_SET_ROUND_DOWN) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
- if ((best > *fout) &&
- ((flags & CLK_SET_ROUND_UP) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
-
- n = aw_clk_factor_get_value(&sc->n, best_n);
- m0 = aw_clk_factor_get_value(&sc->m0, best_m0);
- m1 = aw_clk_factor_get_value(&sc->m1, best_m1);
- val &= ~sc->n.mask;
- val &= ~sc->m0.mask;
- val &= ~sc->m1.mask;
- val |= n << sc->n.shift;
- val |= m0 << sc->m0.shift;
- val |= m1 << sc->m1.shift;
-
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- if ((sc->flags & AW_CLK_HAS_LOCK) != 0) {
- for (retry = 0; retry < sc->lock_retries; retry++) {
- READ4(clk, sc->offset, &val);
- if ((val & (1 << sc->lock_shift)) != 0)
- break;
- DELAY(1000);
- }
- }
-
- *fout = best;
- *stop = 1;
-
- return (0);
-}
-
-static int
-aw_clk_nmm_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_nmm_sc *sc;
- uint32_t val, n, m0, m1;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- n = aw_clk_get_factor(val, &sc->n);
- m0 = aw_clk_get_factor(val, &sc->m0);
- m1 = aw_clk_get_factor(val, &sc->m1);
-
- *freq = *freq * n / m0 / m1;
-
- return (0);
-}
-
-static clknode_method_t aw_nmm_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_nmm_init),
- CLKNODEMETHOD(clknode_set_gate, aw_clk_nmm_set_gate),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_nmm_recalc),
- CLKNODEMETHOD(clknode_set_freq, aw_clk_nmm_set_freq),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_nmm_clknode, aw_nmm_clknode_class, aw_nmm_clknode_methods,
- sizeof(struct aw_clk_nmm_sc), clknode_class);
-
-int
-aw_clk_nmm_register(struct clkdom *clkdom, struct aw_clk_nmm_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_nmm_sc *sc;
-
- clk = clknode_create(clkdom, &aw_nmm_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->n.shift = clkdef->n.shift;
- sc->n.width = clkdef->n.width;
- sc->n.mask = ((1 << sc->n.width) - 1) << sc->n.shift;
- sc->n.value = clkdef->n.value;
- sc->n.flags = clkdef->n.flags;
-
- sc->m0.shift = clkdef->m0.shift;
- sc->m0.width = clkdef->m0.width;
- sc->m0.mask = ((1 << sc->m0.width) - 1) << sc->m0.shift;
- sc->m0.value = clkdef->m0.value;
- sc->m0.flags = clkdef->m0.flags;
-
- sc->m1.shift = clkdef->m1.shift;
- sc->m1.width = clkdef->m1.width;
- sc->m1.mask = ((1 << sc->m1.width) - 1) << sc->m1.shift;
- sc->m1.value = clkdef->m1.value;
- sc->m1.flags = clkdef->m1.flags;
-
- sc->gate_shift = clkdef->gate_shift;
-
- sc->lock_shift = clkdef->lock_shift;
- sc->lock_retries = clkdef->lock_retries;
-
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_nmm.h b/sys/arm/allwinner/clkng/aw_clk_nmm.h
deleted file mode 100644
index e53d44d3b612..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_nmm.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_NMM_H__
-#define __AW_CLK_NMM_H__
-
-#include <dev/extres/clk/clk.h>
-
-struct aw_clk_nmm_def {
- struct clknode_init_def clkdef;
- uint32_t offset;
-
- struct aw_clk_factor n;
- struct aw_clk_factor m0;
- struct aw_clk_factor m1;
-
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-int aw_clk_nmm_register(struct clkdom *clkdom, struct aw_clk_nmm_def *clkdef);
-
-#endif /* __AW_CLK_NMM_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_np.c b/sys/arm/allwinner/clkng/aw_clk_np.c
deleted file mode 100644
index 566f9c1d6f91..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_np.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_np.h>
-
-#include "clkdev_if.h"
-
-/*
- * clknode for clocks matching the formula :
- *
- * clk = clkin * n / p
- *
- */
-
-struct aw_clk_np_sc {
- uint32_t offset;
-
- struct aw_clk_factor n;
- struct aw_clk_factor p;
-
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-static int
-aw_clk_np_init(struct clknode *clk, device_t dev)
-{
-
- clknode_init_parent_idx(clk, 0);
- return (0);
-}
-
-static int
-aw_clk_np_set_gate(struct clknode *clk, bool enable)
-{
- struct aw_clk_np_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- if ((sc->flags & AW_CLK_HAS_GATE) == 0)
- return (0);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- if (enable)
- val |= (1 << sc->gate_shift);
- else
- val &= ~(1 << sc->gate_shift);
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static uint64_t
-aw_clk_np_find_best(struct aw_clk_np_sc *sc, uint64_t fparent, uint64_t *fout,
- uint32_t *factor_n, uint32_t *factor_p)
-{
- uint64_t cur, best;
- uint32_t n, p, max_n, max_p, min_n, min_p;
-
- *factor_n = *factor_p = 0;
-
- max_n = aw_clk_factor_get_max(&sc->n);
- max_p = aw_clk_factor_get_max(&sc->p);
- min_n = aw_clk_factor_get_min(&sc->n);
- min_p = aw_clk_factor_get_min(&sc->p);
-
- for (p = min_p; p <= max_p; ) {
- for (n = min_n; n <= max_n; ) {
- cur = fparent * n / p;
- if (abs(*fout - cur) < abs(*fout - best)) {
- best = cur;
- *factor_n = n;
- *factor_p = p;
- }
-
- n++;
- }
- p++;
- }
-
- return (best);
-}
-
-static int
-aw_clk_np_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
- int flags, int *stop)
-{
- struct aw_clk_np_sc *sc;
- uint64_t cur, best;
- uint32_t val, n, p, best_n, best_p;
- int retry;
-
- sc = clknode_get_softc(clk);
-
- best = cur = 0;
-
- best = aw_clk_np_find_best(sc, fparent, fout,
- &best_n, &best_p);
-
- if ((flags & CLK_SET_DRYRUN) != 0) {
- *fout = best;
- *stop = 1;
- return (0);
- }
-
- if ((best < *fout) &&
- ((flags & CLK_SET_ROUND_DOWN) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
- if ((best > *fout) &&
- ((flags & CLK_SET_ROUND_UP) == 0)) {
- *stop = 1;
- return (ERANGE);
- }
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
-
- n = aw_clk_factor_get_value(&sc->n, best_n);
- p = aw_clk_factor_get_value(&sc->p, best_p);
- val &= ~sc->n.mask;
- val &= ~sc->p.mask;
- val |= n << sc->n.shift;
- val |= p << sc->p.shift;
-
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- if ((sc->flags & AW_CLK_HAS_LOCK) != 0) {
- for (retry = 0; retry < sc->lock_retries; retry++) {
- READ4(clk, sc->offset, &val);
- if ((val & (1 << sc->lock_shift)) != 0)
- break;
- DELAY(1000);
- }
- }
-
- *fout = best;
- *stop = 1;
-
- return (0);
-}
-
-static int
-aw_clk_np_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_np_sc *sc;
- uint32_t val, n, p;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- n = aw_clk_get_factor(val, &sc->n);
- p = aw_clk_get_factor(val, &sc->p);
-
- *freq = *freq * n / p;
-
- return (0);
-}
-
-static clknode_method_t aw_np_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_np_init),
- CLKNODEMETHOD(clknode_set_gate, aw_clk_np_set_gate),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_np_recalc),
- CLKNODEMETHOD(clknode_set_freq, aw_clk_np_set_freq),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_np_clknode, aw_np_clknode_class, aw_np_clknode_methods,
- sizeof(struct aw_clk_np_sc), clknode_class);
-
-int
-aw_clk_np_register(struct clkdom *clkdom, struct aw_clk_np_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_np_sc *sc;
-
- clk = clknode_create(clkdom, &aw_np_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->n.shift = clkdef->n.shift;
- sc->n.width = clkdef->n.width;
- sc->n.mask = ((1 << sc->n.width) - 1) << sc->n.shift;
- sc->n.value = clkdef->n.value;
- sc->n.flags = clkdef->n.flags;
-
- sc->p.shift = clkdef->p.shift;
- sc->p.width = clkdef->p.width;
- sc->p.mask = ((1 << sc->p.width) - 1) << sc->p.shift;
- sc->p.value = clkdef->p.value;
- sc->p.flags = clkdef->p.flags;
-
- sc->gate_shift = clkdef->gate_shift;
-
- sc->lock_shift = clkdef->lock_shift;
- sc->lock_retries = clkdef->lock_retries;
-
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_np.h b/sys/arm/allwinner/clkng/aw_clk_np.h
deleted file mode 100644
index 4997adb19d9c..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_np.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_NP_H__
-#define __AW_CLK_NP_H__
-
-#include <dev/extres/clk/clk.h>
-
-struct aw_clk_np_def {
- struct clknode_init_def clkdef;
- uint32_t offset;
-
- struct aw_clk_factor n;
- struct aw_clk_factor p;
-
- uint32_t gate_shift;
- uint32_t lock_shift;
- uint32_t lock_retries;
-
- uint32_t flags;
-};
-
-int aw_clk_np_register(struct clkdom *clkdom, struct aw_clk_np_def *clkdef);
-
-#endif /* __AW_CLK_NP_H__ */
diff --git a/sys/arm/allwinner/clkng/aw_clk_prediv_mux.c b/sys/arm/allwinner/clkng/aw_clk_prediv_mux.c
deleted file mode 100644
index b27473b03e84..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_prediv_mux.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * Copyright (c) 2017 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk.h>
-
-#include <arm/allwinner/clkng/aw_clk.h>
-#include <arm/allwinner/clkng/aw_clk_prediv_mux.h>
-
-#include "clkdev_if.h"
-
-/*
- * clknode for clocks matching the formula :
- *
- * clk = clkin / prediv / div
- *
- * and where prediv is conditional
- *
- */
-
-struct aw_clk_prediv_mux_sc {
- uint32_t offset;
-
- uint32_t mux_shift;
- uint32_t mux_mask;
-
- struct aw_clk_factor div;
- struct aw_clk_factor prediv;
-
- uint32_t flags;
-};
-
-#define WRITE4(_clk, off, val) \
- CLKDEV_WRITE_4(clknode_get_device(_clk), off, val)
-#define READ4(_clk, off, val) \
- CLKDEV_READ_4(clknode_get_device(_clk), off, val)
-#define MODIFY4(_clk, off, clr, set ) \
- CLKDEV_MODIFY_4(clknode_get_device(_clk), off, clr, set)
-#define DEVICE_LOCK(_clk) \
- CLKDEV_DEVICE_LOCK(clknode_get_device(_clk))
-#define DEVICE_UNLOCK(_clk) \
- CLKDEV_DEVICE_UNLOCK(clknode_get_device(_clk))
-
-static int
-aw_clk_prediv_mux_init(struct clknode *clk, device_t dev)
-{
- struct aw_clk_prediv_mux_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- /* Init the current parent */
- val = (val & sc->mux_mask) >> sc->mux_shift;
- clknode_init_parent_idx(clk, val);
-
- return (0);
-}
-
-static int
-aw_clk_prediv_mux_set_mux(struct clknode *clk, int index)
-{
- struct aw_clk_prediv_mux_sc *sc;
- uint32_t val;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- val &= ~sc->mux_mask;
- val |= index << sc->mux_shift;
- WRITE4(clk, sc->offset, val);
- DEVICE_UNLOCK(clk);
-
- return (0);
-}
-
-static int
-aw_clk_prediv_mux_recalc(struct clknode *clk, uint64_t *freq)
-{
- struct aw_clk_prediv_mux_sc *sc;
- uint32_t val, div, prediv;
-
- sc = clknode_get_softc(clk);
-
- DEVICE_LOCK(clk);
- READ4(clk, sc->offset, &val);
- DEVICE_UNLOCK(clk);
-
- div = aw_clk_get_factor(val, &sc->div);
- prediv = aw_clk_get_factor(val, &sc->prediv);
-
- *freq = *freq / prediv / div;
- return (0);
-}
-
-static clknode_method_t aw_prediv_mux_clknode_methods[] = {
- /* Device interface */
- CLKNODEMETHOD(clknode_init, aw_clk_prediv_mux_init),
- CLKNODEMETHOD(clknode_set_mux, aw_clk_prediv_mux_set_mux),
- CLKNODEMETHOD(clknode_recalc_freq, aw_clk_prediv_mux_recalc),
- CLKNODEMETHOD_END
-};
-
-DEFINE_CLASS_1(aw_prediv_mux_clknode, aw_prediv_mux_clknode_class,
- aw_prediv_mux_clknode_methods, sizeof(struct aw_clk_prediv_mux_sc),
- clknode_class);
-
-int
-aw_clk_prediv_mux_register(struct clkdom *clkdom, struct aw_clk_prediv_mux_def *clkdef)
-{
- struct clknode *clk;
- struct aw_clk_prediv_mux_sc *sc;
-
- clk = clknode_create(clkdom, &aw_prediv_mux_clknode_class, &clkdef->clkdef);
- if (clk == NULL)
- return (1);
-
- sc = clknode_get_softc(clk);
-
- sc->offset = clkdef->offset;
-
- sc->mux_shift = clkdef->mux_shift;
- sc->mux_mask = ((1 << clkdef->mux_width) - 1) << sc->mux_shift;
-
- sc->div.shift = clkdef->div.shift;
- sc->div.mask = ((1 << clkdef->div.width) - 1) << sc->div.shift;
- sc->div.value = clkdef->div.value;
- sc->div.cond_shift = clkdef->div.cond_shift;
- sc->div.cond_mask = ((1 << clkdef->div.cond_width) - 1) << sc->div.shift;
- sc->div.cond_value = clkdef->div.cond_value;
- sc->div.flags = clkdef->div.flags;
-
- sc->prediv.shift = clkdef->prediv.shift;
- sc->prediv.mask = ((1 << clkdef->prediv.width) - 1) << sc->prediv.shift;
- sc->prediv.value = clkdef->prediv.value;
- sc->prediv.cond_shift = clkdef->prediv.cond_shift;
- if (clkdef->prediv.cond_width != 0)
- sc->prediv.cond_mask = ((1 << clkdef->prediv.cond_width) - 1) << sc->prediv.shift;
- else
- sc->prediv.cond_mask = clkdef->prediv.cond_mask;
- sc->prediv.cond_value = clkdef->prediv.cond_value;
- sc->prediv.flags = clkdef->prediv.flags;
-
- sc->flags = clkdef->flags;
-
- clknode_register(clkdom, clk);
-
- return (0);
-}
diff --git a/sys/arm/allwinner/clkng/aw_clk_prediv_mux.h b/sys/arm/allwinner/clkng/aw_clk_prediv_mux.h
deleted file mode 100644
index 1a6109b22d60..000000000000
--- a/sys/arm/allwinner/clkng/aw_clk_prediv_mux.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 2017 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef __AW_CLK_PREDIV_MUX_H__
-#define __AW_CLK_PREDIV_MUX_H__
-
-#include <arm/allwinner/clkng/aw_clk.h>
-
-struct aw_clk_prediv_mux_def {
- struct clknode_init_def clkdef;
- uint32_t offset;
-
- uint32_t mux_shift;
- uint32_t mux_width;
-
- struct aw_clk_factor div;
- struct aw_clk_factor prediv;
-
- uint32_t flags;
-};
-
-int aw_clk_prediv_mux_register(struct clkdom *clkdom, struct aw_clk_prediv_mux_def *clkdef);
-
-#endif /* __AW_CLK_PREDIV_MUX_H__ */
diff --git a/sys/arm/allwinner/clkng/ccu_a10.c b/sys/arm/allwinner/clkng/ccu_a10.c
deleted file mode 100644
index 7e4e268f7164..000000000000
--- a/sys/arm/allwinner/clkng/ccu_a10.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun4i-a10-ccu.h>
-#include <dt-bindings/clock/sun7i-a20-ccu.h>
-#include <dt-bindings/reset/sun4i-a10-ccu.h>
-
-/* Non-exported resets */
-/* Non-exported clocks */
-#define CLK_PLL_CORE 2
-#define CLK_AXI 3
-#define CLK_AHB 4
-#define CLK_APB0 5
-#define CLK_APB1 6
-#define CLK_PLL_VIDEO0 8
-#define CLK_PLL_DDR 12
-#define CLK_PLL_DDR_OTHER 13
-#define CLK_PLL6 14
-#define CLK_PLL_PERIPH 15
-#define CLK_PLL_SATA 16
-#define CLK_PLL_VIDEO1 17
-
-/* Non-exported fixed clocks */
-
-static struct aw_ccung_reset a10_ccu_resets[] = {
- CCU_RESET(RST_USB_PHY0, 0xcc, 0)
- CCU_RESET(RST_USB_PHY1, 0xcc, 1)
- CCU_RESET(RST_USB_PHY2, 0xcc, 2)
-
- CCU_RESET(RST_GPS, 0xd0, 0)
-
- CCU_RESET(RST_DE_BE0, 0x104, 30)
- CCU_RESET(RST_DE_BE1, 0x108, 30)
- CCU_RESET(RST_DE_FE0, 0x10c, 30)
- CCU_RESET(RST_DE_FE1, 0x110, 30)
- CCU_RESET(RST_DE_MP, 0x114, 30)
-
- CCU_RESET(RST_TVE0, 0x118, 29)
- CCU_RESET(RST_TCON0, 0x118, 30)
-
- CCU_RESET(RST_TVE1, 0x11c, 29)
- CCU_RESET(RST_TCON1, 0x11c, 30)
-
- CCU_RESET(RST_CSI0, 0x134, 30)
- CCU_RESET(RST_CSI1, 0x138, 30)
-
- CCU_RESET(RST_VE, 0x13c, 0)
-
- CCU_RESET(RST_ACE, 0x148, 16)
-
- CCU_RESET(RST_LVDS, 0x14c, 0)
-
- CCU_RESET(RST_GPU, 0x154, 30)
-
- CCU_RESET(RST_HDMI_H, 0x170, 0)
- CCU_RESET(RST_HDMI_SYS, 0x170, 1)
- CCU_RESET(RST_HDMI_AUDIO_DMA, 0x170, 2)
-};
-
-static struct aw_ccung_gate a10_ccu_gates[] = {
- CCU_GATE(CLK_HOSC, "hosc", "osc24M", 0x50, 0)
-
- CCU_GATE(CLK_AHB_OTG, "ahb-otg", "ahb", 0x60, 0)
- CCU_GATE(CLK_AHB_EHCI0, "ahb-ehci0", "ahb", 0x60, 1)
- CCU_GATE(CLK_AHB_OHCI0, "ahb-ohci0", "ahb", 0x60, 2)
- CCU_GATE(CLK_AHB_EHCI1, "ahb-ehci1", "ahb", 0x60, 3)
- CCU_GATE(CLK_AHB_OHCI1, "ahb-ohci1", "ahb", 0x60, 4)
- CCU_GATE(CLK_AHB_SS, "ahb-ss", "ahb", 0x60, 5)
- CCU_GATE(CLK_AHB_DMA, "ahb-dma", "ahb", 0x60, 6)
- CCU_GATE(CLK_AHB_BIST, "ahb-bist", "ahb", 0x60, 7)
- CCU_GATE(CLK_AHB_MMC0, "ahb-mmc0", "ahb", 0x60, 8)
- CCU_GATE(CLK_AHB_MMC1, "ahb-mmc1", "ahb", 0x60, 9)
- CCU_GATE(CLK_AHB_MMC2, "ahb-mmc2", "ahb", 0x60, 10)
- CCU_GATE(CLK_AHB_MMC3, "ahb-mmc3", "ahb", 0x60, 11)
- CCU_GATE(CLK_AHB_MS, "ahb-ms", "ahb", 0x60, 12)
- CCU_GATE(CLK_AHB_NAND, "ahb-nand", "ahb", 0x60, 13)
- CCU_GATE(CLK_AHB_SDRAM, "ahb-sdram", "ahb", 0x60, 14)
- CCU_GATE(CLK_AHB_ACE, "ahb-ace", "ahb", 0x60, 16)
- CCU_GATE(CLK_AHB_EMAC, "ahb-emac", "ahb", 0x60, 17)
- CCU_GATE(CLK_AHB_TS, "ahb-ts", "ahb", 0x60, 18)
- CCU_GATE(CLK_AHB_SPI0, "ahb-spi0", "ahb", 0x60, 20)
- CCU_GATE(CLK_AHB_SPI1, "ahb-spi1", "ahb", 0x60, 21)
- CCU_GATE(CLK_AHB_SPI2, "ahb-spi2", "ahb", 0x60, 22)
- CCU_GATE(CLK_AHB_SPI3, "ahb-spi3", "ahb", 0x60, 23)
- CCU_GATE(CLK_AHB_SATA, "ahb-sata", "ahb", 0x60, 25)
-
- CCU_GATE(CLK_AHB_VE, "ahb-ve", "ahb", 0x64, 0)
- CCU_GATE(CLK_AHB_TVD, "ahb-tvd", "ahb", 0x64, 1)
- CCU_GATE(CLK_AHB_TVE0, "ahb-tve0", "ahb", 0x64, 2)
- CCU_GATE(CLK_AHB_TVE1, "ahb-tve1", "ahb", 0x64, 3)
- CCU_GATE(CLK_AHB_LCD0, "ahb-lcd0", "ahb", 0x64, 4)
- CCU_GATE(CLK_AHB_LCD1, "ahb-lcd1", "ahb", 0x64, 5)
- CCU_GATE(CLK_AHB_CSI0, "ahb-csi0", "ahb", 0x64, 8)
- CCU_GATE(CLK_AHB_CSI1, "ahb-csi1", "ahb", 0x64, 9)
- CCU_GATE(CLK_AHB_HDMI1, "ahb-hdmi1", "ahb", 0x64, 10)
- CCU_GATE(CLK_AHB_HDMI0, "ahb-hdmi0", "ahb", 0x64, 11)
- CCU_GATE(CLK_AHB_DE_BE0, "ahb-de_be0", "ahb", 0x64, 12)
- CCU_GATE(CLK_AHB_DE_BE1, "ahb-de_be1", "ahb", 0x64, 13)
- CCU_GATE(CLK_AHB_DE_FE0, "ahb-de_fe0", "ahb", 0x64, 14)
- CCU_GATE(CLK_AHB_DE_FE1, "ahb-de_fe1", "ahb", 0x64, 15)
- CCU_GATE(CLK_AHB_GMAC, "ahb-gmac", "ahb", 0x64, 17)
- CCU_GATE(CLK_AHB_MP, "ahb-mp", "ahb", 0x64, 18)
- CCU_GATE(CLK_AHB_GPU, "ahb-gpu", "ahb", 0x64, 20)
-
- CCU_GATE(CLK_APB0_CODEC, "apb0-codec", "apb0", 0x68, 0)
- CCU_GATE(CLK_APB0_SPDIF, "apb0-spdif", "apb0", 0x68, 1)
- CCU_GATE(CLK_APB0_AC97, "apb0-ac97", "apb0", 0x68, 2)
- CCU_GATE(CLK_APB0_I2S0, "apb0-i2s0", "apb0", 0x68, 3)
- CCU_GATE(CLK_APB0_I2S1, "apb0-i2s1", "apb0", 0x68, 4)
- CCU_GATE(CLK_APB0_PIO, "apb0-pi0", "apb0", 0x68, 5)
- CCU_GATE(CLK_APB0_IR0, "apb0-ir0", "apb0", 0x68, 6)
- CCU_GATE(CLK_APB0_IR1, "apb0-ir1", "apb0", 0x68, 7)
- CCU_GATE(CLK_APB0_I2S2, "apb0-i2s2", "apb0",0x68, 8)
- CCU_GATE(CLK_APB0_KEYPAD, "apb0-keypad", "apb0", 0x68, 10)
-
- CCU_GATE(CLK_APB1_I2C0, "apb1-i2c0", "apb1", 0x6c, 0)
- CCU_GATE(CLK_APB1_I2C1, "apb1-i2c1", "apb1",0x6c, 1)
- CCU_GATE(CLK_APB1_I2C2, "apb1-i2c2", "apb1",0x6c, 2)
- CCU_GATE(CLK_APB1_I2C3, "apb1-i2c3", "apb1",0x6c, 3)
- CCU_GATE(CLK_APB1_CAN, "apb1-can", "apb1",0x6c, 4)
- CCU_GATE(CLK_APB1_SCR, "apb1-scr", "apb1",0x6c, 5)
- CCU_GATE(CLK_APB1_PS20, "apb1-ps20", "apb1",0x6c, 6)
- CCU_GATE(CLK_APB1_PS21, "apb1-ps21", "apb1",0x6c, 7)
- CCU_GATE(CLK_APB1_I2C4, "apb1-i2c4", "apb1", 0x6c, 15)
- CCU_GATE(CLK_APB1_UART0, "apb1-uart0", "apb1",0x6c, 16)
- CCU_GATE(CLK_APB1_UART1, "apb1-uart1", "apb1",0x6c, 17)
- CCU_GATE(CLK_APB1_UART2, "apb1-uart2", "apb1",0x6c, 18)
- CCU_GATE(CLK_APB1_UART3, "apb1-uart3", "apb1",0x6c, 19)
- CCU_GATE(CLK_APB1_UART4, "apb1-uart4", "apb1",0x6c, 20)
- CCU_GATE(CLK_APB1_UART5, "apb1-uart5", "apb1",0x6c, 21)
- CCU_GATE(CLK_APB1_UART6, "apb1-uart6", "apb1",0x6c, 22)
- CCU_GATE(CLK_APB1_UART7, "apb1-uart7", "apb1",0x6c, 23)
-
- CCU_GATE(CLK_USB_OHCI0, "usb-ohci0", "ahb", 0xcc, 6)
- CCU_GATE(CLK_USB_OHCI1, "usb-ohci1", "ahb", 0xcc, 7)
- CCU_GATE(CLK_USB_PHY, "usb-phy", "ahb", 0xcc, 8)
-
- CCU_GATE(CLK_DRAM_VE, "dram-ve", "pll_ddr", 0x100, 0)
- CCU_GATE(CLK_DRAM_CSI0, "dram-csi0", "pll_ddr", 0x100, 1)
- CCU_GATE(CLK_DRAM_CSI1, "dram-csi1", "pll_ddr", 0x100, 2)
- CCU_GATE(CLK_DRAM_TS, "dram-ts", "pll_ddr", 0x100, 3)
- CCU_GATE(CLK_DRAM_TVD, "dram-tvd", "pll_ddr", 0x100, 4)
- CCU_GATE(CLK_DRAM_TVE0, "dram-tve0", "pll_ddr", 0x100, 5)
- CCU_GATE(CLK_DRAM_TVE1, "dram-tve1", "pll_ddr", 0x100, 6)
- CCU_GATE(CLK_DRAM_OUT, "dram-out", "pll_ddr", 0x100, 15)
- CCU_GATE(CLK_DRAM_DE_FE1, "dram-de_fe1", "pll_ddr", 0x100, 24)
- CCU_GATE(CLK_DRAM_DE_FE0, "dram-de_fe0", "pll_ddr", 0x100, 25)
- CCU_GATE(CLK_DRAM_DE_BE0, "dram-de_be0", "pll_ddr", 0x100, 26)
- CCU_GATE(CLK_DRAM_DE_BE1, "dram-de_be1", "pll_ddr", 0x100, 27)
- CCU_GATE(CLK_DRAM_MP, "dram-de_mp", "pll_ddr", 0x100, 28)
- CCU_GATE(CLK_DRAM_ACE, "dram-ace", "pll_ddr", 0x100, 29)
-};
-
-static const char *pll_parents[] = {"osc24M"};
-NKMP_CLK(pll_core_clk,
- CLK_PLL_CORE, /* id */
- "pll_core", pll_parents, /* name, parents */
- 0x00, /* offset */
- 8, 5, 0, AW_CLK_FACTOR_ZERO_IS_ONE, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-FRAC_CLK(pll_video0_clk,
- CLK_PLL_VIDEO0, /* id */
- "pll_video0", pll_parents, /* name, parents */
- 0x10, /* offset */
- 0, 7, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 31, 0, 0, /* gate, lock, lock retries */
- AW_CLK_HAS_GATE, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 15, 14, /* mode sel, freq sel */
- 27000000, 381000000); /* min freq, max freq */
-static const char *pll_video0_2x_parents[] = {"pll_video0"};
-FIXED_CLK(pll_video0_2x_clk,
- CLK_PLL_VIDEO0_2X, /* id */
- "pll_video0-2x", pll_video0_2x_parents, /* name, parents */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-
-FRAC_CLK(pll_video1_clk,
- CLK_PLL_VIDEO1, /* id */
- "pll_video1", pll_parents, /* name, parents */
- 0x30, /* offset */
- 0, 7, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 31, 0, 0, /* gate, lock, lock retries */
- AW_CLK_HAS_GATE, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 15, 14, /* mode sel, freq sel */
- 27000000, 381000000); /* min freq, max freq */
-static const char *pll_video1_2x_parents[] = {"pll_video1"};
-FIXED_CLK(pll_video1_2x_clk,
- CLK_PLL_VIDEO1_2X, /* id */
- "pll_video1-2x", pll_video1_2x_parents, /* name, parents */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-
-static const char *cpu_parents[] = {"osc32k", "osc24M", "pll_core", "pll_periph"};
-static const char *axi_parents[] = {"cpu"};
-static const char *ahb_parents[] = {"axi", "pll_periph", "pll6"};
-static const char *apb0_parents[] = {"ahb"};
-static const char *apb1_parents[] = {"osc24M", "pll_periph", "osc32k"};
-MUX_CLK(cpu_clk,
- CLK_CPU, /* id */
- "cpu", cpu_parents, /* name, parents */
- 0x54, 16, 2); /* offset, shift, width */
-NM_CLK(axi_clk,
- CLK_AXI, /* id */
- "axi", axi_parents, /* name, parents */
- 0x54, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 2, 0, 0, /* m factor */
- 0, 0, /* mux */
- 0, /* gate */
- 0); /* flags */
-NM_CLK(ahb_clk,
- CLK_AHB, /* id */
- "ahb", ahb_parents, /* name, parents */
- 0x54, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* m factor */
- 6, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX); /* flags */
-NM_CLK(apb0_clk,
- CLK_APB0, /* id */
- "apb0", apb0_parents, /* name, parents */
- 0x54, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO |
- AW_CLK_FACTOR_ZERO_IS_ONE, /* m factor */
- 0, 0, /* mux */
- 0, /* gate */
- 0); /* flags */
-
-NM_CLK(apb1_clk,
- CLK_APB1, /* id */
- "apb1", apb1_parents, /* name, parents */
- 0x58, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 5, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX); /* flags */
-
-NKMP_CLK(pll_ddr_other_clk,
- CLK_PLL_DDR_OTHER, /* id */
- "pll_ddr_other", pll_parents, /* name, parents */
- 0x20, /* offset */
- 8, 5, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 2, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-NKMP_CLK(pll_ddr_clk,
- CLK_PLL_DDR, /* id */
- "pll_ddr", pll_parents, /* name, parents */
- 0x20, /* offset */
- 8, 5, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-NKMP_CLK(pll6_clk,
- CLK_PLL6, /* id */
- "pll6", pll_parents, /* name, parents */
- 0x28, /* offset */
- 8, 5, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll6_parents[] = {"pll6"};
-FIXED_CLK(pll_periph_clk,
- CLK_PLL_PERIPH, /* id */
- "pll_periph", pll6_parents, /* name, parents */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-NKMP_CLK(pll_periph_sata_clk,
- CLK_PLL_SATA, /* id */
- "pll_periph_sata", pll6_parents, /* name, parents */
- 0x28, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 0, 2, 0, 0, /* m factor */
- 0, 0, 6, AW_CLK_FACTOR_FIXED, /* p factor (fake, 6) */
- 14, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *mod_parents[] = {"osc24M", "pll_periph", "pll_ddr_other"};
-NM_CLK(nand_clk,
- CLK_NAND, /* id */
- "nand", mod_parents, /* name, parents */
- 0x80, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(ms_clk,
- CLK_MS, /* id */
- "ms", mod_parents, /* name, parents */
- 0x84, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(mmc0_clk,
- CLK_MMC0, /* id */
- "mmc0", mod_parents, /* name, parents */
- 0x88, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc1_clk,
- CLK_MMC1, /* id */
- "mmc1", mod_parents, /* name, parents */
- 0x8c, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc2_clk,
- CLK_MMC2, /* id */
- "mmc2", mod_parents, /* name, parents */
- 0x90, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc3_clk,
- CLK_MMC3, /* id */
- "mmc3", mod_parents, /* name, parents */
- 0x94, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(ts_clk,
- CLK_TS, /* id */
- "ts", mod_parents, /* name, parents */
- 0x94, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(ss_clk,
- CLK_SS, /* id */
- "ss", mod_parents, /* name, parents */
- 0x9c, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(spi0_clk,
- CLK_SPI0, /* id */
- "spi0", mod_parents, /* name, parents */
- 0xa0, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(spi1_clk,
- CLK_SPI1, /* id */
- "spi1", mod_parents, /* name, parents */
- 0xa4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(spi2_clk,
- CLK_SPI2, /* id */
- "spi2", mod_parents, /* name, parents */
- 0xa8, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-/* MISSING CLK_PATA */
-
-NM_CLK(ir0_clk,
- CLK_IR0, /* id */
- "ir0", mod_parents, /* name, parents */
- 0xb0, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(ir1_clk,
- CLK_IR1, /* id */
- "ir1", mod_parents, /* name, parents */
- 0xb4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-/* MISSING CLK_I2S0, CLK_AC97, CLK_SPDIF */
-
-static const char *keypad_parents[] = {"osc24M", "osc24M", "osc32k"};
-NM_CLK(keypad_clk,
- CLK_KEYPAD, /* id */
- "keypad", keypad_parents, /* name, parents */
- 0xc4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 5, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *sata_parents[] = {"pll_periph_sata", "osc32k"};
-NM_CLK(sata_clk,
- CLK_SATA, /* id */
- "sata", sata_parents, /* name, parents */
- 0xc8, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 24, 1, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(spi3_clk,
- CLK_SPI3, /* id */
- "spi3", mod_parents, /* name, parents */
- 0xd4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-/* MISSING CLK_I2S1, CLK_I2S2, DE Clocks */
-
-static struct aw_ccung_clk a10_ccu_clks[] = {
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_core_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr_other_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll6_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph_sata_clk},
- { .type = AW_CLK_NM, .clk.nm = &axi_clk},
- { .type = AW_CLK_NM, .clk.nm = &ahb_clk},
- { .type = AW_CLK_NM, .clk.nm = &apb0_clk},
- { .type = AW_CLK_NM, .clk.nm = &apb1_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_video0_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_video1_clk},
- { .type = AW_CLK_NM, .clk.nm = &nand_clk},
- { .type = AW_CLK_NM, .clk.nm = &ms_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc2_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc3_clk},
- { .type = AW_CLK_NM, .clk.nm = &ts_clk},
- { .type = AW_CLK_NM, .clk.nm = &ss_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi0_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi1_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi2_clk},
- { .type = AW_CLK_NM, .clk.nm = &ir0_clk},
- { .type = AW_CLK_NM, .clk.nm = &ir1_clk},
- { .type = AW_CLK_NM, .clk.nm = &keypad_clk},
- { .type = AW_CLK_NM, .clk.nm = &sata_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi3_clk},
- { .type = AW_CLK_MUX, .clk.mux = &cpu_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_periph_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_video0_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_video1_2x_clk},
-};
-
-static struct aw_clk_init a10_init_clks[] = {
-};
-
-static struct ofw_compat_data compat_data[] = {
-#if defined(SOC_ALLWINNER_A10)
- { "allwinner,sun4i-a10-ccu", 1 },
-#endif
-#if defined(SOC_ALLWINNER_A20)
- { "allwinner,sun7i-a20-ccu", 1 },
-#endif
- { NULL, 0},
-};
-
-static int
-ccu_a10_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner A10/A20 Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_a10_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = a10_ccu_resets;
- sc->nresets = nitems(a10_ccu_resets);
- sc->gates = a10_ccu_gates;
- sc->ngates = nitems(a10_ccu_gates);
- sc->clks = a10_ccu_clks;
- sc->nclks = nitems(a10_ccu_clks);
- sc->clk_init = a10_init_clks;
- sc->n_clk_init = nitems(a10_init_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_a10ng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_a10_probe),
- DEVMETHOD(device_attach, ccu_a10_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_a10ng, ccu_a10ng_driver, ccu_a10ng_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_a10ng, simplebus, ccu_a10ng_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_a13.c b/sys/arm/allwinner/clkng/ccu_a13.c
deleted file mode 100644
index 827cab1b7910..000000000000
--- a/sys/arm/allwinner/clkng/ccu_a13.c
+++ /dev/null
@@ -1,568 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun5i-ccu.h>
-#include <dt-bindings/reset/sun5i-ccu.h>
-
-/* Non-exported clocks */
-
-#define CLK_PLL_CORE 2
-#define CLK_PLL_AUDIO_BASE 3
-#define CLK_PLL_AUDIO 4
-#define CLK_PLL_AUDIO_2X 5
-#define CLK_PLL_AUDIO_4X 6
-#define CLK_PLL_AUDIO_8X 7
-#define CLK_PLL_VIDEO0 8
-
-#define CLK_PLL_VE 10
-#define CLK_PLL_DDR_BASE 11
-#define CLK_PLL_DDR 12
-#define CLK_PLL_DDR_OTHER 13
-#define CLK_PLL_PERIPH 14
-#define CLK_PLL_VIDEO1 15
-
-#define CLK_AXI 18
-#define CLK_AHB 19
-#define CLK_APB0 20
-#define CLK_APB1 21
-#define CLK_DRAM_AXI 22
-
-#define CLK_TCON_CH1_SCLK 91
-
-#define CLK_MBUS 99
-
-static struct aw_ccung_reset a13_ccu_resets[] = {
- CCU_RESET(RST_USB_PHY0, 0xcc, 0)
- CCU_RESET(RST_USB_PHY1, 0xcc, 1)
-
- CCU_RESET(RST_GPS, 0xd0, 30)
-
- CCU_RESET(RST_DE_BE, 0x104, 30)
-
- CCU_RESET(RST_DE_FE, 0x10c, 30)
-
- CCU_RESET(RST_TVE, 0x118, 29)
- CCU_RESET(RST_LCD, 0x118, 30)
-
- CCU_RESET(RST_CSI, 0x134, 30)
-
- CCU_RESET(RST_VE, 0x13c, 0)
- CCU_RESET(RST_GPU, 0x154, 30)
- CCU_RESET(RST_IEP, 0x160, 30)
-
-};
-
-static struct aw_ccung_gate a13_ccu_gates[] = {
- CCU_GATE(CLK_HOSC, "hosc", "osc24M", 0x50, 0)
-
- CCU_GATE(CLK_DRAM_AXI, "axi-dram", "axi", 0x5c, 0)
-
- CCU_GATE(CLK_AHB_OTG, "ahb-otg", "ahb", 0x60, 0)
- CCU_GATE(CLK_AHB_EHCI, "ahb-ehci", "ahb", 0x60, 1)
- CCU_GATE(CLK_AHB_OHCI, "ahb-ohci", "ahb", 0x60, 2)
- CCU_GATE(CLK_AHB_SS, "ahb-ss", "ahb", 0x60, 5)
- CCU_GATE(CLK_AHB_DMA, "ahb-dma", "ahb", 0x60, 6)
- CCU_GATE(CLK_AHB_BIST, "ahb-bist", "ahb", 0x60, 7)
- CCU_GATE(CLK_AHB_MMC0, "ahb-mmc0", "ahb", 0x60, 8)
- CCU_GATE(CLK_AHB_MMC1, "ahb-mmc1", "ahb", 0x60, 9)
- CCU_GATE(CLK_AHB_MMC2, "ahb-mmc2", "ahb", 0x60, 10)
- CCU_GATE(CLK_AHB_NAND, "ahb-nand", "ahb", 0x60, 13)
- CCU_GATE(CLK_AHB_SDRAM, "ahb-sdram", "ahb", 0x60, 14)
- CCU_GATE(CLK_AHB_SPI0, "ahb-spi0", "ahb", 0x60, 20)
- CCU_GATE(CLK_AHB_SPI1, "ahb-spi1", "ahb", 0x60, 21)
- CCU_GATE(CLK_AHB_SPI2, "ahb-spi2", "ahb", 0x60, 22)
- CCU_GATE(CLK_AHB_GPS, "ahb-gps", "ahb", 0x60, 26)
- CCU_GATE(CLK_AHB_HSTIMER, "ahb-hstimer", "ahb", 0x60, 28)
-
- CCU_GATE(CLK_AHB_VE, "ahb-ve", "ahb", 0x64, 0)
- CCU_GATE(CLK_AHB_LCD, "ahb-lcd", "ahb", 0x64, 4)
- CCU_GATE(CLK_AHB_CSI, "ahb-csi", "ahb", 0x64, 8)
- CCU_GATE(CLK_AHB_DE_BE, "ahb-de-be", "ahb", 0x64, 12)
- CCU_GATE(CLK_AHB_DE_FE, "ahb-de-fe", "ahb", 0x64, 14)
- CCU_GATE(CLK_AHB_IEP, "ahb-iep", "ahb", 0x64, 19)
- CCU_GATE(CLK_AHB_GPU, "ahb-gpu", "ahb", 0x64, 20)
-
- CCU_GATE(CLK_APB0_CODEC, "apb0-codec", "apb0", 0x68, 0)
- CCU_GATE(CLK_APB0_PIO, "apb0-pio", "apb0", 0x68, 5)
- CCU_GATE(CLK_APB0_IR, "apb0-ir", "apb0", 0x68, 6)
-
- CCU_GATE(CLK_APB1_I2C0, "apb1-i2c0", "apb1", 0x6c, 0)
- CCU_GATE(CLK_APB1_I2C1, "apb1-i2c1", "apb1", 0x6c, 1)
- CCU_GATE(CLK_APB1_I2C2, "apb1-i2c2", "apb1", 0x6c, 2)
- CCU_GATE(CLK_APB1_UART1, "apb1-uart1", "apb1", 0x6c, 17)
- CCU_GATE(CLK_APB1_UART3, "apb1-uart3", "apb1", 0x6c, 19)
-
- CCU_GATE(CLK_DRAM_VE, "dram-ve", "pll-ddr", 0x100, 0)
- CCU_GATE(CLK_DRAM_CSI, "dram-csi", "pll-ddr", 0x100, 1)
- CCU_GATE(CLK_DRAM_DE_FE, "dram-de-fe", "pll-ddr", 0x100, 25)
- CCU_GATE(CLK_DRAM_DE_BE, "dram-de-be", "pll-ddr", 0x100, 26)
- CCU_GATE(CLK_DRAM_ACE, "dram-ace", "pll-ddr", 0x100, 29)
- CCU_GATE(CLK_DRAM_IEP, "dram-iep", "pll-ddr", 0x100, 31)
-
- CCU_GATE(CLK_CODEC, "codec", "pll-audio", 0x140, 31)
-
- CCU_GATE(CLK_AVS, "avs", "hosc", 0x144, 31)
-};
-
-static const char *pll_parents[] = {"hosc"};
-static struct aw_clk_nkmp_def pll_core = {
- .clkdef = {
- .id = CLK_PLL_CORE,
- .name = "pll-core",
- .parent_names = pll_parents,
- .parent_cnt = nitems(pll_parents),
- },
- .offset = 0x00,
- .n = {.shift = 8, .width = 5},
- .k = {.shift = 4, .width = 2},
- .m = {.shift = 0, .width = 2},
- .p = {.shift = 16, .width = 2},
- .gate_shift = 31,
- .flags = AW_CLK_HAS_GATE,
-};
-
-/*
- * We only implement pll-audio for now
- * For pll-audio-2/4/8 x we need a way to change the frequency
- * of the parent clocks
- */
-static struct aw_clk_nkmp_def pll_audio = {
- .clkdef = {
- .id = CLK_PLL_AUDIO,
- .name = "pll-audio",
- .parent_names = pll_parents,
- .parent_cnt = nitems(pll_parents),
- },
- .offset = 0x08,
- .n = {.shift = 8, .width = 7},
- .k = {.value = 1, .flags = AW_CLK_FACTOR_FIXED},
- .m = {.shift = 0, .width = 5},
- .p = {.shift = 26, .width = 4},
- .gate_shift = 31,
- .flags = AW_CLK_HAS_GATE,
-};
-
-/* Missing PLL3-Video */
-/* Missing PLL4-VE */
-
-static struct aw_clk_nkmp_def pll_ddr_base = {
- .clkdef = {
- .id = CLK_PLL_DDR_BASE,
- .name = "pll-ddr-base",
- .parent_names = pll_parents,
- .parent_cnt = nitems(pll_parents),
- },
- .offset = 0x20,
- .n = {.shift = 8, .width = 5},
- .k = {.shift = 4, .width = 2},
- .m = {.value = 1, .flags = AW_CLK_FACTOR_FIXED},
- .p = {.value = 1, .flags = AW_CLK_FACTOR_FIXED},
- .gate_shift = 31,
- .flags = AW_CLK_HAS_GATE,
-};
-
-static const char *pll_ddr_parents[] = {"pll-ddr-base"};
-static struct clk_div_def pll_ddr = {
- .clkdef = {
- .id = CLK_PLL_DDR,
- .name = "pll-ddr",
- .parent_names = pll_ddr_parents,
- .parent_cnt = nitems(pll_ddr_parents),
- },
- .offset = 0x20,
- .i_shift = 0,
- .i_width = 2,
-};
-
-static const char *pll_ddr_other_parents[] = {"pll-ddr-base"};
-static struct clk_div_def pll_ddr_other = {
- .clkdef = {
- .id = CLK_PLL_DDR_OTHER,
- .name = "pll-ddr-other",
- .parent_names = pll_ddr_other_parents,
- .parent_cnt = nitems(pll_ddr_other_parents),
- },
- .offset = 0x20,
- .i_shift = 16,
- .i_width = 2,
-};
-
-static struct aw_clk_nkmp_def pll_periph = {
- .clkdef = {
- .id = CLK_PLL_PERIPH,
- .name = "pll-periph",
- .parent_names = pll_parents,
- .parent_cnt = nitems(pll_parents),
- },
- .offset = 0x28,
- .n = {.shift = 8, .width = 5},
- .k = {.shift = 4, .width = 2},
- .m = {.shift = 0, .width = 2},
- .p = {.value = 2, .flags = AW_CLK_FACTOR_FIXED},
- .gate_shift = 31,
- .flags = AW_CLK_HAS_GATE,
-};
-
-/* Missing PLL7-VIDEO1 */
-
-static const char *cpu_parents[] = {"osc32k", "hosc", "pll-core", "pll-periph"};
-static struct aw_clk_prediv_mux_def cpu_clk = {
- .clkdef = {
- .id = CLK_CPU,
- .name = "cpu",
- .parent_names = cpu_parents,
- .parent_cnt = nitems(cpu_parents),
- },
- .offset = 0x54,
- .mux_shift = 16, .mux_width = 2,
- .prediv = {
- .value = 6,
- .flags = AW_CLK_FACTOR_FIXED,
- .cond_shift = 16,
- .cond_width = 2,
- .cond_value = 3,
- },
-};
-
-static const char *axi_parents[] = {"cpu"};
-static struct clk_div_def axi_clk = {
- .clkdef = {
- .id = CLK_AXI,
- .name = "axi",
- .parent_names = axi_parents,
- .parent_cnt = nitems(axi_parents),
- },
- .offset = 0x50,
- .i_shift = 0, .i_width = 2,
-};
-
-static const char *ahb_parents[] = {"axi", "cpu", "pll-periph"};
-static struct aw_clk_prediv_mux_def ahb_clk = {
- .clkdef = {
- .id = CLK_AHB,
- .name = "ahb",
- .parent_names = ahb_parents,
- .parent_cnt = nitems(ahb_parents),
- },
- .offset = 0x54,
- .mux_shift = 6,
- .mux_width = 2,
- .div = {
- .shift = 4,
- .width = 2,
- .flags = AW_CLK_FACTOR_POWER_OF_TWO
- },
- .prediv = {
- .value = 2,
- .flags = AW_CLK_FACTOR_FIXED,
- .cond_shift = 6,
- .cond_width = 2,
- .cond_value = 2,
- },
-};
-
-static const char *apb0_parents[] = {"ahb"};
-static struct clk_div_table apb0_div_table[] = {
- { .value = 0, .divider = 2, },
- { .value = 1, .divider = 2, },
- { .value = 2, .divider = 4, },
- { .value = 3, .divider = 8, },
- { },
-};
-static struct clk_div_def apb0_clk = {
- .clkdef = {
- .id = CLK_APB0,
- .name = "apb0",
- .parent_names = apb0_parents,
- .parent_cnt = nitems(apb0_parents),
- },
- .offset = 0x54,
- .i_shift = 8, .i_width = 2,
- .div_flags = CLK_DIV_WITH_TABLE,
- .div_table = apb0_div_table,
-};
-
-static const char *apb1_parents[] = {"hosc", "pll-periph", "osc32k"};
-static struct aw_clk_nm_def apb1_clk = {
- .clkdef = {
- .id = CLK_APB1,
- .name = "apb1",
- .parent_names = apb1_parents,
- .parent_cnt = nitems(apb1_parents),
- },
- .offset = 0x58,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 5},
- .mux_shift = 24,
- .mux_width = 2,
- .flags = AW_CLK_HAS_MUX,
-};
-
-static const char *mod_parents[] = {"hosc", "pll-periph", "pll-ddr-other"};
-
-static struct aw_clk_nm_def nand_clk = {
- .clkdef = {
- .id = CLK_NAND,
- .name = "nand",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0x80,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def mmc0_clk = {
- .clkdef = {
- .id = CLK_MMC0,
- .name = "mmc0",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0x88,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def mmc1_clk = {
- .clkdef = {
- .id = CLK_MMC1,
- .name = "mmc1",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0x8C,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def mmc2_clk = {
- .clkdef = {
- .id = CLK_MMC2,
- .name = "mmc2",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0x90,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def ss_clk = {
- .clkdef = {
- .id = CLK_SS,
- .name = "ss",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0x9C,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def spi0_clk = {
- .clkdef = {
- .id = CLK_SPI0,
- .name = "spi0",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0xA0,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def spi1_clk = {
- .clkdef = {
- .id = CLK_SPI1,
- .name = "spi1",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0xA4,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def spi2_clk = {
- .clkdef = {
- .id = CLK_SPI2,
- .name = "spi2",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0xA8,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-static struct aw_clk_nm_def ir_clk = {
- .clkdef = {
- .id = CLK_IR,
- .name = "ir",
- .parent_names = mod_parents,
- .parent_cnt = nitems(mod_parents),
- },
- .offset = 0xB0,
- .n = {.shift = 16, .width = 2, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 0, .width = 4},
- .mux_shift = 24,
- .mux_width = 2,
- .gate_shift = 31,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_REPARENT
-};
-
-/* Missing DE-BE clock */
-/* Missing DE-FE clock */
-/* Missing LCD CH1 clock */
-/* Missing CSI clock */
-/* Missing VE clock */
-
-/* Clocks list */
-static struct aw_ccung_clk a13_ccu_clks[] = {
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_core},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_audio},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr_base},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph},
- { .type = AW_CLK_NM, .clk.nm = &apb1_clk},
- { .type = AW_CLK_NM, .clk.nm = &nand_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc2_clk},
- { .type = AW_CLK_NM, .clk.nm = &ss_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi0_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi1_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi2_clk},
- { .type = AW_CLK_NM, .clk.nm = &ir_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &cpu_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb_clk},
- { .type = AW_CLK_DIV, .clk.div = &pll_ddr},
- { .type = AW_CLK_DIV, .clk.div = &pll_ddr_other},
- { .type = AW_CLK_DIV, .clk.div = &axi_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb0_clk},
-};
-
-static int
-ccu_a13_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun5i-a13-ccu"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner A13 Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_a13_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = a13_ccu_resets;
- sc->nresets = nitems(a13_ccu_resets);
- sc->gates = a13_ccu_gates;
- sc->ngates = nitems(a13_ccu_gates);
- sc->clks = a13_ccu_clks;
- sc->nclks = nitems(a13_ccu_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_a13ng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_a13_probe),
- DEVMETHOD(device_attach, ccu_a13_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_a13ng, ccu_a13ng_driver, ccu_a13ng_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_a13ng, simplebus, ccu_a13ng_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_a31.c b/sys/arm/allwinner/clkng/ccu_a31.c
deleted file mode 100644
index d06cd0af3e1d..000000000000
--- a/sys/arm/allwinner/clkng/ccu_a31.c
+++ /dev/null
@@ -1,978 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun6i-a31-ccu.h>
-#include <dt-bindings/reset/sun6i-a31-ccu.h>
-
-/* Non-exported clocks */
-#define CLK_PLL_CPU 0
-#define CLK_PLL_AUDIO_BASE 1
-#define CLK_PLL_AUDIO 2
-#define CLK_PLL_AUDIO_2X 3
-#define CLK_PLL_AUDIO_4X 4
-#define CLK_PLL_AUDIO_8X 5
-#define CLK_PLL_VIDEO0 6
-#define CLK_PLL_VIDEO0_2X 7
-#define CLK_PLL_VE 8
-#define CLK_PLL_DDR 9
-
-#define CLK_PLL_PERIPH_2X 11
-#define CLK_PLL_VIDEO1 12
-#define CLK_PLL_VIDEO1_2X 13
-#define CLK_PLL_GPU 14
-#define CLK_PLL_MIPI 15
-#define CLK_PLL9 16
-#define CLK_PLL10 17
-
-#define CLK_AXI 19
-#define CLK_AHB1 20
-#define CLK_APB1 21
-#define CLK_APB2 22
-
-#define CLK_MDFS 107
-#define CLK_SDRAM0 108
-#define CLK_SDRAM1 109
-
-#define CLK_MBUS0 141
-#define CLK_MBUS1 142
-
-static struct aw_ccung_reset a31_ccu_resets[] = {
- CCU_RESET(RST_USB_PHY0, 0xcc, 0)
- CCU_RESET(RST_USB_PHY1, 0xcc, 1)
- CCU_RESET(RST_USB_PHY2, 0xcc, 2)
-
- CCU_RESET(RST_AHB1_MIPI_DSI, 0x2c0, 1)
- CCU_RESET(RST_AHB1_SS, 0x2c0, 5)
- CCU_RESET(RST_AHB1_DMA, 0x2c0, 6)
- CCU_RESET(RST_AHB1_MMC0, 0x2c0, 8)
- CCU_RESET(RST_AHB1_MMC1, 0x2c0, 9)
- CCU_RESET(RST_AHB1_MMC2, 0x2c0, 10)
- CCU_RESET(RST_AHB1_MMC3, 0x2c0, 11)
- CCU_RESET(RST_AHB1_NAND1, 0x2c0, 12)
- CCU_RESET(RST_AHB1_NAND0, 0x2c0, 13)
- CCU_RESET(RST_AHB1_SDRAM, 0x2c0, 14)
- CCU_RESET(RST_AHB1_EMAC, 0x2c0, 17)
- CCU_RESET(RST_AHB1_TS, 0x2c0, 18)
- CCU_RESET(RST_AHB1_HSTIMER, 0x2c0, 19)
- CCU_RESET(RST_AHB1_SPI0, 0x2c0, 20)
- CCU_RESET(RST_AHB1_SPI1, 0x2c0, 21)
- CCU_RESET(RST_AHB1_SPI2, 0x2c0, 22)
- CCU_RESET(RST_AHB1_SPI3, 0x2c0, 23)
- CCU_RESET(RST_AHB1_OTG, 0x2c0, 24)
- CCU_RESET(RST_AHB1_EHCI0, 0x2c0, 26)
- CCU_RESET(RST_AHB1_EHCI1, 0x2c0, 27)
- CCU_RESET(RST_AHB1_OHCI0, 0x2c0, 29)
- CCU_RESET(RST_AHB1_OHCI1, 0x2c0, 30)
- CCU_RESET(RST_AHB1_OHCI2, 0x2c0, 31)
-
- CCU_RESET(RST_AHB1_VE, 0x2c4, 0)
- CCU_RESET(RST_AHB1_LCD0, 0x2c4, 4)
- CCU_RESET(RST_AHB1_LCD1, 0x2c4, 5)
- CCU_RESET(RST_AHB1_CSI, 0x2c4, 8)
- CCU_RESET(RST_AHB1_HDMI, 0x2c4, 11)
- CCU_RESET(RST_AHB1_BE0, 0x2c4, 12)
- CCU_RESET(RST_AHB1_BE1, 0x2c4, 13)
- CCU_RESET(RST_AHB1_FE0, 0x2c4, 14)
- CCU_RESET(RST_AHB1_FE1, 0x2c4, 15)
- CCU_RESET(RST_AHB1_MP, 0x2c4, 18)
- CCU_RESET(RST_AHB1_GPU, 0x2c4, 20)
- CCU_RESET(RST_AHB1_DEU0, 0x2c4, 23)
- CCU_RESET(RST_AHB1_DEU1, 0x2c4, 24)
- CCU_RESET(RST_AHB1_DRC0, 0x2c4, 25)
- CCU_RESET(RST_AHB1_DRC1, 0x2c4, 26)
-
- CCU_RESET(RST_AHB1_LVDS, 0x2c8, 0)
-
- CCU_RESET(RST_APB1_CODEC, 0x2d0, 0)
- CCU_RESET(RST_APB1_SPDIF, 0x2d0, 1)
- CCU_RESET(RST_APB1_DIGITAL_MIC, 0x2d0, 4)
- CCU_RESET(RST_APB1_DAUDIO0, 0x2d0, 12)
- CCU_RESET(RST_APB1_DAUDIO1, 0x2d0, 13)
-
- CCU_RESET(RST_APB2_I2C0, 0x2d8, 0)
- CCU_RESET(RST_APB2_I2C1, 0x2d8, 1)
- CCU_RESET(RST_APB2_I2C2, 0x2d8, 2)
- CCU_RESET(RST_APB2_I2C3, 0x2d8, 3)
- CCU_RESET(RST_APB2_UART0, 0x2d8, 16)
- CCU_RESET(RST_APB2_UART1, 0x2d8, 17)
- CCU_RESET(RST_APB2_UART2, 0x2d8, 18)
- CCU_RESET(RST_APB2_UART3, 0x2d8, 19)
- CCU_RESET(RST_APB2_UART4, 0x2d8, 20)
- CCU_RESET(RST_APB2_UART5, 0x2d8, 21)
-};
-
-static struct aw_ccung_gate a31_ccu_gates[] = {
- CCU_GATE(CLK_AHB1_MIPIDSI, "ahb1-mipidsi", "ahb1", 0x60, 1)
- CCU_GATE(CLK_AHB1_SS, "ahb1-ss", "ahb1", 0x60, 5)
- CCU_GATE(CLK_AHB1_DMA, "ahb1-dma", "ahb1", 0x60, 6)
- CCU_GATE(CLK_AHB1_MMC0, "ahb1-mmc0", "ahb1", 0x60, 8)
- CCU_GATE(CLK_AHB1_MMC1, "ahb1-mmc1", "ahb1", 0x60, 9)
- CCU_GATE(CLK_AHB1_MMC2, "ahb1-mmc2", "ahb1", 0x60, 10)
- CCU_GATE(CLK_AHB1_MMC3, "ahb1-mmc3", "ahb1", 0x60, 11)
- CCU_GATE(CLK_AHB1_NAND1, "ahb1-nand1", "ahb1", 0x60, 12)
- CCU_GATE(CLK_AHB1_NAND0, "ahb1-nand0", "ahb1", 0x60, 13)
- CCU_GATE(CLK_AHB1_SDRAM, "ahb1-sdram", "ahb1", 0x60, 14)
- CCU_GATE(CLK_AHB1_EMAC, "ahb1-emac", "ahb1", 0x60, 17)
- CCU_GATE(CLK_AHB1_TS, "ahb1-ts", "ahb1", 0x60, 18)
- CCU_GATE(CLK_AHB1_HSTIMER, "ahb1-hstimer", "ahb1", 0x60, 19)
- CCU_GATE(CLK_AHB1_SPI0, "ahb1-spi0", "ahb1", 0x60, 20)
- CCU_GATE(CLK_AHB1_SPI1, "ahb1-spi1", "ahb1", 0x60, 21)
- CCU_GATE(CLK_AHB1_SPI2, "ahb1-spi2", "ahb1", 0x60, 22)
- CCU_GATE(CLK_AHB1_SPI3, "ahb1-spi3", "ahb1", 0x60, 23)
- CCU_GATE(CLK_AHB1_OTG, "ahb1-otg", "ahb1", 0x60, 24)
- CCU_GATE(CLK_AHB1_EHCI0, "ahb1-ehci0", "ahb1", 0x60, 26)
- CCU_GATE(CLK_AHB1_EHCI1, "ahb1-ehci1", "ahb1", 0x60, 27)
- CCU_GATE(CLK_AHB1_OHCI0, "ahb1-ohci0", "ahb1", 0x60, 29)
- CCU_GATE(CLK_AHB1_OHCI1, "ahb1-ohci1", "ahb1", 0x60, 30)
- CCU_GATE(CLK_AHB1_OHCI2, "ahb1-ohci2", "ahb1", 0x60, 31)
- CCU_GATE(CLK_AHB1_VE, "ahb1-ve", "ahb1", 0x64, 0)
- CCU_GATE(CLK_AHB1_LCD0, "ahb1-lcd0", "ahb1", 0x64, 4)
- CCU_GATE(CLK_AHB1_LCD1, "ahb1-lcd1", "ahb1", 0x64, 5)
- CCU_GATE(CLK_AHB1_CSI, "ahb1-csi", "ahb1", 0x64, 8)
- CCU_GATE(CLK_AHB1_HDMI, "ahb1-hdmi", "ahb1", 0x64, 11)
- CCU_GATE(CLK_AHB1_BE0, "ahb1-be0", "ahb1", 0x64, 12)
- CCU_GATE(CLK_AHB1_BE1, "ahb1-be1", "ahb1", 0x64, 13)
- CCU_GATE(CLK_AHB1_FE0, "ahb1-fe0", "ahb1", 0x64, 14)
- CCU_GATE(CLK_AHB1_FE1, "ahb1-fe1", "ahb1", 0x64, 15)
- CCU_GATE(CLK_AHB1_MP, "ahb1-mp", "ahb1", 0x64, 18)
- CCU_GATE(CLK_AHB1_GPU, "ahb1-gpu", "ahb1", 0x64, 20)
- CCU_GATE(CLK_AHB1_DEU0, "ahb1-deu0", "ahb1", 0x64, 23)
- CCU_GATE(CLK_AHB1_DEU1, "ahb1-deu1", "ahb1", 0x64, 24)
- CCU_GATE(CLK_AHB1_DRC0, "ahb1-drc0", "ahb1", 0x64, 25)
- CCU_GATE(CLK_AHB1_DRC1, "ahb1-drc1", "ahb1", 0x64, 26)
-
- CCU_GATE(CLK_APB1_CODEC, "apb1-codec", "apb1", 0x68, 0)
- CCU_GATE(CLK_APB1_SPDIF, "apb1-spdif", "apb1", 0x68, 1)
- CCU_GATE(CLK_APB1_DIGITAL_MIC, "apb1-digital-mic", "apb1", 0x68, 4)
- CCU_GATE(CLK_APB1_PIO, "apb1-pio", "apb1", 0x68, 5)
- CCU_GATE(CLK_APB1_DAUDIO0, "apb1-daudio0", "apb1", 0x68, 12)
- CCU_GATE(CLK_APB1_DAUDIO1, "apb1-daudio1", "apb1", 0x68, 13)
-
- CCU_GATE(CLK_APB2_I2C0, "apb2-i2c0", "apb2", 0x6c, 0)
- CCU_GATE(CLK_APB2_I2C1, "apb2-i2c1", "apb2", 0x6c, 1)
- CCU_GATE(CLK_APB2_I2C2, "apb2-i2c2", "apb2", 0x6c, 2)
- CCU_GATE(CLK_APB2_I2C3, "apb2-i2c3", "apb2", 0x6c, 3)
- CCU_GATE(CLK_APB2_UART0, "apb2-uart0", "apb2", 0x6c, 16)
- CCU_GATE(CLK_APB2_UART1, "apb2-uart1", "apb2", 0x6c, 17)
- CCU_GATE(CLK_APB2_UART2, "apb2-uart2", "apb2", 0x6c, 18)
- CCU_GATE(CLK_APB2_UART3, "apb2-uart3", "apb2", 0x6c, 19)
- CCU_GATE(CLK_APB2_UART4, "apb2-uart4", "apb2", 0x6c, 20)
- CCU_GATE(CLK_APB2_UART5, "apb2-uart5", "apb2", 0x6c, 21)
-
- CCU_GATE(CLK_DAUDIO0, "daudio0", "daudio0mux", 0xb0, 31)
- CCU_GATE(CLK_DAUDIO1, "daudio1", "daudio1mux", 0xb4, 31)
-
- CCU_GATE(CLK_USB_PHY0, "usb-phy0", "osc24M", 0xcc, 8)
- CCU_GATE(CLK_USB_PHY1, "usb-phy1", "osc24M", 0xcc, 9)
- CCU_GATE(CLK_USB_PHY2, "usb-phy2", "osc24M", 0xcc, 10)
- CCU_GATE(CLK_USB_OHCI0, "usb-ohci0", "osc24M", 0xcc, 16)
- CCU_GATE(CLK_USB_OHCI1, "usb-ohci1", "osc24M", 0xcc, 17)
- CCU_GATE(CLK_USB_OHCI2, "usb-ohci2", "osc24M", 0xcc, 18)
-
- CCU_GATE(CLK_DRAM_VE, "dram-ve", "mdfs", 0x100, 0)
- CCU_GATE(CLK_DRAM_CSI_ISP, "dram-csi_isp", "mdfs", 0x100, 1)
- CCU_GATE(CLK_DRAM_TS, "dram-ts", "mdfs", 0x100, 3)
- CCU_GATE(CLK_DRAM_DRC0, "dram-drc0", "mdfs", 0x100, 16)
- CCU_GATE(CLK_DRAM_DRC1, "dram-drc1", "mdfs", 0x100, 17)
- CCU_GATE(CLK_DRAM_DEU0, "dram-deu0", "mdfs", 0x100, 18)
- CCU_GATE(CLK_DRAM_DEU1, "dram-deu1", "mdfs", 0x100, 19)
- CCU_GATE(CLK_DRAM_FE0, "dram-fe0", "mdfs", 0x100, 24)
- CCU_GATE(CLK_DRAM_FE1, "dram-fe1", "mdfs", 0x100, 25)
- CCU_GATE(CLK_DRAM_BE0, "dram-be0", "mdfs", 0x100, 26)
- CCU_GATE(CLK_DRAM_BE1, "dram-be1", "mdfs", 0x100, 27)
- CCU_GATE(CLK_DRAM_MP, "dram-mp", "mdfs", 0x100, 28)
-
- CCU_GATE(CLK_CODEC, "codec", "pll_audio", 0x140, 31)
-
- CCU_GATE(CLK_AVS, "avs", "pll_audio", 0x144, 31)
-
- CCU_GATE(CLK_DIGITAL_MIC, "digital-mic", "pll_audio", 0x148, 31)
-
- CCU_GATE(CLK_HDMI_DDC, "hdmi-ddc", "osc24M", 0x150, 30)
-
- CCU_GATE(CLK_PS, "ps", "lcd1_ch1", 0x154, 31)
-};
-
-static const char *pll_parents[] = {"osc24M"};
-
-NKMP_CLK(pll_cpu_clk,
- CLK_PLL_CPU, /* id */
- "pll_cpu", pll_parents, /* name, parents */
- 0x00, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK | AW_CLK_SCALE_CHANGE); /* flags */
-
-NKMP_CLK(pll_audio_clk,
- CLK_PLL_AUDIO, /* id */
- "pll_audio", pll_parents, /* name, parents */
- 0x08, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 0, 4, 1, 0, /* m factor */
- 16, 3, 1, 0, /* p factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_audio_mult_parents[] = {"pll_audio"};
-FIXED_CLK(pll_audio_2x_clk,
- CLK_PLL_AUDIO_2X, /* id */
- "pll_audio-2x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-FIXED_CLK(pll_audio_4x_clk,
- CLK_PLL_AUDIO_4X, /* id */
- "pll_audio-4x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 4, /* mult */
- 1, /* div */
- 0); /* flags */
-FIXED_CLK(pll_audio_8x_clk,
- CLK_PLL_AUDIO_8X, /* id */
- "pll_audio-8x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 8, /* mult */
- 1, /* div */
- 0); /* flags */
-
-FRAC_CLK(pll_video0_clk,
- CLK_PLL_VIDEO0, /* id */
- "pll_video0", pll_parents, /* name, parents */
- 0x10, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 30000000, 600000000); /* min freq, max freq */
-static const char *pll_video0_2x_parents[] = {"pll_video0"};
-FIXED_CLK(pll_video0_2x_clk,
- CLK_PLL_VIDEO0_2X, /* id */
- "pll_video0-2x", /* name */
- pll_video0_2x_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-
-FRAC_CLK(pll_ve_clk,
- CLK_PLL_VE, /* id */
- "pll_ve", pll_parents, /* name, parents */
- 0x18, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 30000000, 600000000); /* min freq, max freq */
-
-NKMP_CLK_WITH_UPDATE(pll_ddr_clk,
- CLK_PLL_DDR, /* id */
- "pll_ddr", pll_parents, /* name, parents */
- 0x20, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- 20, /* update */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-NKMP_CLK(pll_periph_clk,
- CLK_PLL_PERIPH, /* id */
- "pll_periph", pll_parents, /* name, parents */
- 0x28, /* offset */
- 8, 4, 0, 0, /* n factor */
- 5, 2, 1, 0, /* k factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_periph_2x_parents[] = {"pll_periph"};
-FIXED_CLK(pll_periph_2x_clk,
- CLK_PLL_PERIPH_2X, /* id */
- "pll_periph-2x", /* name */
- pll_periph_2x_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-
-FRAC_CLK(pll_video1_clk,
- CLK_PLL_VIDEO1, /* id */
- "pll_video1", pll_parents, /* name, parents */
- 0x30, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 30000000, 600000000); /* min freq, max freq */
-
-static const char *pll_video1_2x_parents[] = {"pll_video1"};
-FIXED_CLK(pll_video1_2x_clk,
- CLK_PLL_VIDEO1_2X, /* id */
- "pll_video1-2x", /* name */
- pll_video1_2x_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-
-FRAC_CLK(pll_gpu_clk,
- CLK_PLL_GPU, /* id */
- "pll_gpu", pll_parents, /* name, parents */
- 0x38, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 30000000, 600000000); /* min freq, max freq */
-
-static const char *pll_mipi_parents[] = {"pll_video0", "pll_video1"};
-NKMP_CLK(pll_mipi_clk,
- CLK_PLL_MIPI, /* id */
- "pll_mipi", pll_mipi_parents, /* name, parents */
- 0x40, /* offset */
- 8, 4, 0, 0, /* n factor */
- 4, 2, 1, 0, /* k factor */
- 0, 2, 0, 0, /* m factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-FRAC_CLK(pll9_clk,
- CLK_PLL9, /* id */
- "pll9", pll_parents, /* name, parents */
- 0x44, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 30000000, 600000000); /* min freq, max freq */
-
-FRAC_CLK(pll10_clk,
- CLK_PLL10, /* id */
- "pll10", pll_parents, /* name, parents */
- 0x48, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 30000000, 600000000); /* min freq, max freq */
-
-static struct clk_div_table axi_div_table[] = {
- { .value = 0, .divider = 1, },
- { .value = 1, .divider = 2, },
- { .value = 2, .divider = 3, },
- { .value = 3, .divider = 4, },
- { .value = 4, .divider = 4, },
- { .value = 5, .divider = 4, },
- { .value = 6, .divider = 4, },
- { .value = 7, .divider = 4, },
- { },
-};
-static const char *axi_parents[] = {"cpu"};
-DIV_CLK(axi_clk,
- CLK_AXI, /* id */
- "axi", axi_parents, /* name, parents */
- 0x50, /* offset */
- 0, 2, /* shift, mask */
- 0, axi_div_table); /* flags, div table */
-
-static const char *cpu_parents[] = {"osc32k", "osc24M", "pll_cpu", "pll_cpu"};
-MUX_CLK(cpu_clk,
- CLK_CPU, /* id */
- "cpu", cpu_parents, /* name, parents */
- 0x50, 16, 2); /* offset, shift, width */
-
-static const char *ahb1_parents[] = {"osc32k", "osc24M", "axi", "pll_periph"};
-PREDIV_CLK(ahb1_clk,
- CLK_AHB1, /* id */
- "ahb1", ahb1_parents, /* name, parents */
- 0x54, /* offset */
- 12, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 6, 2, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- 12, 2, 3); /* prediv condition */
-
-static const char *apb1_parents[] = {"ahb1"};
-static struct clk_div_table apb1_div_table[] = {
- { .value = 0, .divider = 2, },
- { .value = 1, .divider = 2, },
- { .value = 2, .divider = 4, },
- { .value = 3, .divider = 8, },
- { },
-};
-DIV_CLK(apb1_clk,
- CLK_APB1, /* id */
- "apb1", apb1_parents, /* name, parents */
- 0x54, /* offset */
- 8, 2, /* shift, mask */
- CLK_DIV_WITH_TABLE, /* flags */
- apb1_div_table); /* div table */
-
-static const char *apb2_parents[] = {"osc32k", "osc24M", "pll_periph", "pll_periph"};
-NM_CLK(apb2_clk,
- CLK_APB2, /* id */
- "apb2", apb2_parents, /* name, parents */
- 0x58, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 5, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX);
-
-static const char *mod_parents[] = {"osc24M", "pll_periph"};
-NM_CLK(nand0_clk,
- CLK_NAND0, "nand0", mod_parents, /* id, name, parents */
- 0x80, /* offset */
- 16, 3, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(nand1_clk,
- CLK_NAND1, "nand1", mod_parents, /* id, name, parents */
- 0x80, /* offset */
- 16, 3, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(mmc0_clk,
- CLK_MMC0, "mmc0", mod_parents, /* id, name, parents */
- 0x88, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc1_clk,
- CLK_MMC1, "mmc1", mod_parents, /* id, name, parents */
- 0x8c, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc2_clk,
- CLK_MMC2, "mmc2", mod_parents, /* id, name, parents */
- 0x90, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc3_clk,
- CLK_MMC2, "mmc3", mod_parents, /* id, name, parents */
- 0x94, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-static const char *ts_parents[] = {"osc24M", "pll_periph"};
-NM_CLK(ts_clk,
- CLK_TS, "ts", ts_parents, /* id, name, parents */
- 0x98, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(ss_clk,
- CLK_SS, "ss", mod_parents, /* id, name, parents */
- 0x9C, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(spi0_clk,
- CLK_SPI0, "spi0", mod_parents, /* id, name, parents */
- 0xA0, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(spi1_clk,
- CLK_SPI1, "spi1", mod_parents, /* id, name, parents */
- 0xA4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(spi2_clk,
- CLK_SPI2, "spi2", mod_parents, /* id, name, parents */
- 0xA8, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(spi3_clk,
- CLK_SPI3, "spi3", mod_parents, /* id, name, parents */
- 0xAC, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-static const char *daudio_parents[] = {"pll_audio-8x", "pll_audio-4x", "pll_audio-2x", "pll_audio"};
-MUX_CLK(daudio0mux_clk,
- 0,
- "daudio0mux", daudio_parents,
- 0xb0, 16, 2);
-MUX_CLK(daudio1mux_clk,
- 0,
- "daudio1mux", daudio_parents,
- 0xb4, 16, 2);
-
-static const char *mdfs_parents[] = {"pll_ddr", "pll_periph"};
-NM_CLK(mdfs_clk,
- CLK_MDFS, "mdfs", mdfs_parents, /* id, name, parents */
- 0xF0, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-static const char *dram_parents[] = {"pll_ddr", "pll_periph"};
-NM_CLK(sdram0_clk,
- CLK_SDRAM0, "sdram0", dram_parents, /* id, name, parents */
- 0xF4, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 4, 1, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX); /* flags */
-NM_CLK(sdram1_clk,
- CLK_SDRAM1, "sdram1", dram_parents, /* id, name, parents */
- 0xF4, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 8, 4, 0, 0, /* m factor */
- 12, 1, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX); /* flags */
-
-static const char *befe_parents[] = {"pll_video0", "pll_video1", "pll_periph-2x", "pll_gpu", "pll9", "pll10"};
-NM_CLK(be0_clk,
- CLK_BE0, "be0", befe_parents, /* id, name, parents */
- 0x104, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(be1_clk,
- CLK_BE1, "be1", befe_parents, /* id, name, parents */
- 0x108, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(fe0_clk,
- CLK_FE0, "fe0", befe_parents, /* id, name, parents */
- 0x104, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-NM_CLK(fe1_clk,
- CLK_FE1, "fe1", befe_parents, /* id, name, parents */
- 0x108, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *mp_parents[] = {"pll_video0", "pll_video1", "pll9", "pll10"};
-NM_CLK(mp_clk,
- CLK_MP, "mp", mp_parents, /* id, name, parents */
- 0x108, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *lcd_ch0_parents[] = {"pll_video0", "pll_video1", "pll_video0-2x", "pll_video1-2x", "pll_mipi"};
-NM_CLK(lcd0_ch0_clk,
- CLK_LCD0_CH0, "lcd0_ch0", lcd_ch0_parents, /* id, name, parents */
- 0x118, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake )*/
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(lcd1_ch0_clk,
- CLK_LCD1_CH0, "lcd1_ch0", lcd_ch0_parents, /* id, name, parents */
- 0x11C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake )*/
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *lcd_ch1_parents[] = {"pll_video0", "pll_video1", "pll_video0-2x", "pll_video1-2x"};
-NM_CLK(lcd0_ch1_clk,
- CLK_LCD0_CH1, "lcd0_ch1", lcd_ch1_parents, /* id, name, parents */
- 0x12C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(lcd1_ch1_clk,
- CLK_LCD1_CH1, "lcd1_ch1", lcd_ch1_parents, /* id, name, parents */
- 0x130, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-/* CSI0 0x134 Need Mux table */
-/* CSI1 0x138 Need Mux table */
-
-static const char *ve_parents[] = {"pll_ve"};
-NM_CLK(ve_clk,
- CLK_VE, "ve", ve_parents, /* id, name, parents */
- 0x13C, /* offset */
- 16, 3, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(hdmi_clk,
- CLK_HDMI, "hdmi", lcd_ch1_parents, /* id, name, parents */
- 0x150, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *mbus_parents[] = {"osc24M", "pll_periph", "pll_ddr"};
-NM_CLK(mbus0_clk,
- CLK_MBUS0, "mbus0", mbus_parents, /* id, name, parents */
- 0x15C, /* offset */
- 16, 2, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(mbus1_clk,
- CLK_MBUS1, "mbus1", mbus_parents, /* id, name, parents */
- 0x160, /* offset */
- 16, 2, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *mipi_parents[] = {"pll_video0", "pll_video1", "pll_video0-2x", "pll_video1-2x"};
-NM_CLK(mipi_dsi_clk,
- CLK_MIPI_DSI, "mipi_dsi", mipi_parents, /* id, name, parents */
- 0x168, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 16, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(mipi_dsi_dphy_clk,
- CLK_MIPI_DSI_DPHY, "mipi_dsi_dphy", mipi_parents, /* id, name, parents */
- 0x168, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 8, 2, /* mux */
- 15, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(mipi_csi_dphy_clk,
- CLK_MIPI_CSI_DPHY, "mipi_csi_dphy", mipi_parents, /* id, name, parents */
- 0x16C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 8, 2, /* mux */
- 15, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *iep_parents[] = {"pll_video0", "pll_video1", "pll_periph-2x", "pll_gpu", "pll9", "pll10"};
-
-NM_CLK(iep_drc0_clk,
- CLK_IEP_DRC0, "iep_drc0", iep_parents, /* id, name, parents */
- 0x180, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(iep_drc1_clk,
- CLK_IEP_DRC1, "iep_drc1", iep_parents, /* id, name, parents */
- 0x184, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(iep_deu0_clk,
- CLK_IEP_DEU0, "iep_deu0", iep_parents, /* id, name, parents */
- 0x188, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-NM_CLK(iep_deu1_clk,
- CLK_IEP_DEU1, "iep_deu1", iep_parents, /* id, name, parents */
- 0x18C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *gpu_parents[] = {"pll_gpu", "pll_periph-2x", "pll_video0", "pll_video1", "pll9", "pll10"};
-PREDIV_CLK(gpu_core_clk,
- CLK_GPU_CORE, /* id */
- "gpu_core", gpu_parents, /* name, parents */
- 0x1A0, /* offset */
- 24, 3, /* mux */
- 0, 3, 0, 0, /* div */
- 0, 0, 3, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */
- 24, 2, 1); /* prediv condition */
-
-PREDIV_CLK(gpu_memory_clk,
- CLK_GPU_MEMORY, /* id */
- "gpu_memory", gpu_parents, /* name, parents */
- 0x1A4, /* offset */
- 24, 3, /* mux */
- 0, 3, 0, 0, /* div */
- 0, 0, 3, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */
- 24, 2, 1); /* prediv condition */
-
-PREDIV_CLK(gpu_hyd_clk,
- CLK_GPU_HYD, /* id */
- "gpu_hyd", gpu_parents, /* name, parents */
- 0x1A8, /* offset */
- 24, 3, /* mux */
- 0, 3, 0, 0, /* div */
- 0, 0, 3, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */
- 24, 2, 1); /* prediv condition */
-
-/* ATS 0x1B0 */
-/* Trace 0x1B4 */
-static struct aw_ccung_clk a31_ccu_clks[] = {
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_cpu_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_audio_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_mipi_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_video0_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_ve_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_video1_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_gpu_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll9_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll10_clk},
- { .type = AW_CLK_NM, .clk.nm = &apb2_clk},
- { .type = AW_CLK_NM, .clk.nm = &nand0_clk},
- { .type = AW_CLK_NM, .clk.nm = &nand1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc2_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc3_clk},
- { .type = AW_CLK_NM, .clk.nm = &ts_clk},
- { .type = AW_CLK_NM, .clk.nm = &ss_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi0_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi1_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi2_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi3_clk},
- { .type = AW_CLK_NM, .clk.nm = &mdfs_clk},
- { .type = AW_CLK_NM, .clk.nm = &sdram0_clk},
- { .type = AW_CLK_NM, .clk.nm = &sdram1_clk},
- { .type = AW_CLK_NM, .clk.nm = &be0_clk},
- { .type = AW_CLK_NM, .clk.nm = &be1_clk},
- { .type = AW_CLK_NM, .clk.nm = &fe0_clk},
- { .type = AW_CLK_NM, .clk.nm = &fe1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mp_clk},
- { .type = AW_CLK_NM, .clk.nm = &lcd0_ch0_clk},
- { .type = AW_CLK_NM, .clk.nm = &lcd1_ch0_clk},
- { .type = AW_CLK_NM, .clk.nm = &lcd0_ch1_clk},
- { .type = AW_CLK_NM, .clk.nm = &lcd1_ch1_clk},
- { .type = AW_CLK_NM, .clk.nm = &ve_clk},
- { .type = AW_CLK_NM, .clk.nm = &hdmi_clk},
- { .type = AW_CLK_NM, .clk.nm = &mbus0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mbus1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mipi_dsi_clk},
- { .type = AW_CLK_NM, .clk.nm = &mipi_dsi_dphy_clk},
- { .type = AW_CLK_NM, .clk.nm = &mipi_csi_dphy_clk},
- { .type = AW_CLK_NM, .clk.nm = &iep_drc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &iep_drc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &iep_deu0_clk},
- { .type = AW_CLK_NM, .clk.nm = &iep_deu1_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb1_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &gpu_core_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &gpu_memory_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &gpu_hyd_clk},
- { .type = AW_CLK_DIV, .clk.div = &axi_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb1_clk},
- { .type = AW_CLK_MUX, .clk.mux = &cpu_clk},
- { .type = AW_CLK_MUX, .clk.mux = &daudio0mux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &daudio1mux_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_4x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_8x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_video0_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_periph_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_video1_2x_clk},
-};
-
-static int
-ccu_a31_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun6i-a31-ccu"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner A31 Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_a31_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = a31_ccu_resets;
- sc->nresets = nitems(a31_ccu_resets);
- sc->gates = a31_ccu_gates;
- sc->ngates = nitems(a31_ccu_gates);
- sc->clks = a31_ccu_clks;
- sc->nclks = nitems(a31_ccu_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_a31ng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_a31_probe),
- DEVMETHOD(device_attach, ccu_a31_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_a31ng, ccu_a31ng_driver, ccu_a31ng_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_a31ng, simplebus, ccu_a31ng_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_a64.c b/sys/arm/allwinner/clkng/ccu_a64.c
deleted file mode 100644
index 75c8377b3238..000000000000
--- a/sys/arm/allwinner/clkng/ccu_a64.c
+++ /dev/null
@@ -1,841 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun50i-a64-ccu.h>
-#include <dt-bindings/reset/sun50i-a64-ccu.h>
-
-/* Non-exported clocks */
-
-#define CLK_OSC_12M 0
-#define CLK_PLL_CPUX 1
-#define CLK_PLL_AUDIO_BASE 2
-#define CLK_PLL_AUDIO 3
-#define CLK_PLL_AUDIO_2X 4
-#define CLK_PLL_AUDIO_4X 5
-#define CLK_PLL_AUDIO_8X 6
-#define CLK_PLL_VIDEO0 7
-#define CLK_PLL_VIDEO0_2X 8
-#define CLK_PLL_VE 9
-#define CLK_PLL_DDR0 10
-#define CLK_PLL_PERIPH0_2X 12
-#define CLK_PLL_PERIPH1 13
-#define CLK_PLL_PERIPH1_2X 14
-#define CLK_PLL_VIDEO1 15
-#define CLK_PLL_GPU 16
-#define CLK_PLL_MIPI 17
-#define CLK_PLL_HSIC 18
-#define CLK_PLL_DE 19
-#define CLK_PLL_DDR1 20
-#define CLK_CPUX 21
-#define CLK_AXI 22
-#define CLK_APB 23
-#define CLK_AHB1 24
-#define CLK_APB1 25
-#define CLK_APB2 26
-#define CLK_AHB2 27
-#define CLK_DRAM 94
-
-#define CLK_MBUS 112
-
-static struct aw_ccung_reset a64_ccu_resets[] = {
- CCU_RESET(RST_USB_PHY0, 0x0cc, 0)
- CCU_RESET(RST_USB_PHY1, 0x0cc, 1)
- CCU_RESET(RST_USB_HSIC, 0x0cc, 2)
-
- CCU_RESET(RST_BUS_MIPI_DSI, 0x2c0, 1)
- CCU_RESET(RST_BUS_CE, 0x2c0, 5)
- CCU_RESET(RST_BUS_DMA, 0x2c0, 6)
- CCU_RESET(RST_BUS_MMC0, 0x2c0, 8)
- CCU_RESET(RST_BUS_MMC1, 0x2c0, 9)
- CCU_RESET(RST_BUS_MMC2, 0x2c0, 10)
- CCU_RESET(RST_BUS_NAND, 0x2c0, 13)
- CCU_RESET(RST_BUS_DRAM, 0x2c0, 14)
- CCU_RESET(RST_BUS_EMAC, 0x2c0, 17)
- CCU_RESET(RST_BUS_TS, 0x2c0, 18)
- CCU_RESET(RST_BUS_HSTIMER, 0x2c0, 19)
- CCU_RESET(RST_BUS_SPI0, 0x2c0, 20)
- CCU_RESET(RST_BUS_SPI1, 0x2c0, 21)
- CCU_RESET(RST_BUS_OTG, 0x2c0, 23)
- CCU_RESET(RST_BUS_EHCI0, 0x2c0, 24)
- CCU_RESET(RST_BUS_EHCI1, 0x2c0, 25)
- CCU_RESET(RST_BUS_OHCI0, 0x2c0, 28)
- CCU_RESET(RST_BUS_OHCI1, 0x2c0, 29)
-
- CCU_RESET(RST_BUS_VE, 0x2c4, 0)
- CCU_RESET(RST_BUS_TCON0, 0x2c4, 3)
- CCU_RESET(RST_BUS_TCON1, 0x2c4, 4)
- CCU_RESET(RST_BUS_DEINTERLACE, 0x2c4, 5)
- CCU_RESET(RST_BUS_CSI, 0x2c4, 8)
- CCU_RESET(RST_BUS_HDMI0, 0x2c4, 10)
- CCU_RESET(RST_BUS_HDMI1, 0x2c4, 11)
- CCU_RESET(RST_BUS_DE, 0x2c4, 12)
- CCU_RESET(RST_BUS_GPU, 0x2c4, 20)
- CCU_RESET(RST_BUS_MSGBOX, 0x2c4, 21)
- CCU_RESET(RST_BUS_SPINLOCK, 0x2c4, 22)
- CCU_RESET(RST_BUS_DBG, 0x2c4, 31)
-
- CCU_RESET(RST_BUS_LVDS, 0x2C8, 31)
-
- CCU_RESET(RST_BUS_CODEC, 0x2D0, 0)
- CCU_RESET(RST_BUS_SPDIF, 0x2D0, 1)
- CCU_RESET(RST_BUS_THS, 0x2D0, 8)
- CCU_RESET(RST_BUS_I2S0, 0x2D0, 12)
- CCU_RESET(RST_BUS_I2S1, 0x2D0, 13)
- CCU_RESET(RST_BUS_I2S2, 0x2D0, 14)
-
- CCU_RESET(RST_BUS_I2C0, 0x2D8, 0)
- CCU_RESET(RST_BUS_I2C1, 0x2D8, 1)
- CCU_RESET(RST_BUS_I2C2, 0x2D8, 2)
- CCU_RESET(RST_BUS_SCR, 0x2D8, 5)
- CCU_RESET(RST_BUS_UART0, 0x2D8, 16)
- CCU_RESET(RST_BUS_UART1, 0x2D8, 17)
- CCU_RESET(RST_BUS_UART2, 0x2D8, 18)
- CCU_RESET(RST_BUS_UART3, 0x2D8, 19)
- CCU_RESET(RST_BUS_UART4, 0x2D8, 20)
-};
-
-static struct aw_ccung_gate a64_ccu_gates[] = {
- CCU_GATE(CLK_BUS_MIPI_DSI, "bus-mipi-dsi", "ahb1", 0x60, 1)
- CCU_GATE(CLK_BUS_CE, "bus-ce", "ahb1", 0x60, 5)
- CCU_GATE(CLK_BUS_DMA, "bus-dma", "ahb1", 0x60, 6)
- CCU_GATE(CLK_BUS_MMC0, "bus-mmc0", "ahb1", 0x60, 8)
- CCU_GATE(CLK_BUS_MMC1, "bus-mmc1", "ahb1", 0x60, 9)
- CCU_GATE(CLK_BUS_MMC2, "bus-mmc2", "ahb1", 0x60, 10)
- CCU_GATE(CLK_BUS_NAND, "bus-nand", "ahb1", 0x60, 13)
- CCU_GATE(CLK_BUS_DRAM, "bus-dram", "ahb1", 0x60, 14)
- CCU_GATE(CLK_BUS_EMAC, "bus-emac", "ahb2", 0x60, 16)
- CCU_GATE(CLK_BUS_TS, "bus-ts", "ahb1", 0x60, 18)
- CCU_GATE(CLK_BUS_HSTIMER, "bus-hstimer", "ahb1", 0x60, 19)
- CCU_GATE(CLK_BUS_SPI0, "bus-spi0", "ahb1", 0x60, 20)
- CCU_GATE(CLK_BUS_SPI1, "bus-spi1", "ahb1", 0x60, 21)
- CCU_GATE(CLK_BUS_OTG, "bus-otg", "ahb1", 0x60, 23)
- CCU_GATE(CLK_BUS_EHCI0, "bus-ehci0", "ahb1", 0x60, 24)
- CCU_GATE(CLK_BUS_EHCI1, "bus-ehci1", "ahb2", 0x60, 25)
- CCU_GATE(CLK_BUS_OHCI0, "bus-ohci0", "ahb1", 0x60, 28)
- CCU_GATE(CLK_BUS_OHCI1, "bus-ohci1", "ahb2", 0x60, 29)
-
- CCU_GATE(CLK_BUS_VE, "bus-ve", "ahb1", 0x64, 0)
- CCU_GATE(CLK_BUS_TCON0, "bus-tcon0", "ahb1", 0x64, 3)
- CCU_GATE(CLK_BUS_TCON1, "bus-tcon1", "ahb1", 0x64, 4)
- CCU_GATE(CLK_BUS_DEINTERLACE, "bus-deinterlace", "ahb1", 0x64, 5)
- CCU_GATE(CLK_BUS_CSI, "bus-csi", "ahb1", 0x64, 8)
- CCU_GATE(CLK_BUS_HDMI, "bus-hdmi", "ahb1", 0x64, 11)
- CCU_GATE(CLK_BUS_DE, "bus-de", "ahb1", 0x64, 12)
- CCU_GATE(CLK_BUS_GPU, "bus-gpu", "ahb1", 0x64, 20)
- CCU_GATE(CLK_BUS_MSGBOX, "bus-msgbox", "ahb1", 0x64, 21)
- CCU_GATE(CLK_BUS_SPINLOCK, "bus-spinlock", "ahb1", 0x64, 22)
-
- CCU_GATE(CLK_BUS_CODEC, "bus-codec", "apb1", 0x68, 0)
- CCU_GATE(CLK_BUS_SPDIF, "bus-spdif", "apb1", 0x68, 1)
- CCU_GATE(CLK_BUS_PIO, "bus-pio", "apb1", 0x68, 5)
- CCU_GATE(CLK_BUS_THS, "bus-ths", "apb1", 0x68, 8)
- CCU_GATE(CLK_BUS_I2S0, "bus-i2s0", "apb1", 0x68, 12)
- CCU_GATE(CLK_BUS_I2S1, "bus-i2s1", "apb1", 0x68, 13)
- CCU_GATE(CLK_BUS_I2S2, "bus-i2s2", "apb1", 0x68, 14)
-
- CCU_GATE(CLK_BUS_I2C0, "bus-i2c0", "apb2", 0x6C, 0)
- CCU_GATE(CLK_BUS_I2C1, "bus-i2c1", "apb2", 0x6C, 1)
- CCU_GATE(CLK_BUS_I2C2, "bus-i2c2", "apb2", 0x6C, 2)
- CCU_GATE(CLK_BUS_SCR, "bus-src", "apb2", 0x6C, 5)
- CCU_GATE(CLK_BUS_UART0, "bus-uart0", "apb2", 0x6C, 16)
- CCU_GATE(CLK_BUS_UART1, "bus-uart1", "apb2", 0x6C, 17)
- CCU_GATE(CLK_BUS_UART2, "bus-uart2", "apb2", 0x6C, 18)
- CCU_GATE(CLK_BUS_UART3, "bus-uart3", "apb2", 0x6C, 19)
- CCU_GATE(CLK_BUS_UART4, "bus-uart4", "apb2", 0x6C, 20)
-
- CCU_GATE(CLK_BUS_DBG, "bus-dbg", "ahb1", 0x70, 7)
-
- CCU_GATE(CLK_THS, "ths", "thsdiv", 0x74, 31)
-
- CCU_GATE(CLK_USB_PHY0, "usb-phy0", "osc24M", 0xcc, 8)
- CCU_GATE(CLK_USB_PHY1, "usb-phy1", "osc24M", 0xcc, 9)
- CCU_GATE(CLK_USB_HSIC, "usb-hsic", "pll_hsic", 0xcc, 10)
- CCU_GATE(CLK_USB_HSIC_12M, "usb-hsic-12M", "osc12M", 0xcc, 11)
- CCU_GATE(CLK_USB_OHCI0, "usb-ohci0", "osc12M", 0xcc, 16)
- CCU_GATE(CLK_USB_OHCI1, "usb-ohci1", "usb-ohci0", 0xcc, 17)
-
- CCU_GATE(CLK_DRAM_VE, "dram-ve", "dram", 0x100, 0)
- CCU_GATE(CLK_DRAM_CSI, "dram-csi", "dram", 0x100, 1)
- CCU_GATE(CLK_DRAM_DEINTERLACE, "dram-deinterlace", "dram", 0x100, 2)
- CCU_GATE(CLK_DRAM_TS, "dram-ts", "dram", 0x100, 3)
-
- CCU_GATE(CLK_CSI_MISC, "csi-misc", "osc24M", 0x130, 31)
-
- CCU_GATE(CLK_AC_DIG_4X, "ac-dig-4x", "pll_audio-4x", 0x140, 30)
- CCU_GATE(CLK_AC_DIG, "ac-dig", "pll_audio", 0x140, 31)
-
- CCU_GATE(CLK_AVS, "avs", "osc24M", 0x144, 31)
-
- CCU_GATE(CLK_HDMI_DDC, "hdmi-ddc", "osc24M", 0x154, 31)
-};
-
-static const char *osc12m_parents[] = {"osc24M"};
-FIXED_CLK(osc12m_clk,
- CLK_OSC_12M, /* id */
- "osc12M", /* name */
- osc12m_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-
-static const char *pll_cpux_parents[] = {"osc24M"};
-NKMP_CLK(pll_cpux_clk,
- CLK_PLL_CPUX, /* id */
- "pll_cpux", pll_cpux_parents, /* name, parents */
- 0x00, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK | AW_CLK_SCALE_CHANGE); /* flags */
-
-static const char *pll_audio_parents[] = {"osc24M"};
-NKMP_CLK(pll_audio_clk,
- CLK_PLL_AUDIO, /* id */
- "pll_audio", pll_audio_parents, /* name, parents */
- 0x08, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 0, 5, 0, 0, /* m factor */
- 16, 4, 0, 0, /* p factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_audio_mult_parents[] = {"pll_audio"};
-FIXED_CLK(pll_audio_2x_clk,
- CLK_PLL_AUDIO_2X, /* id */
- "pll_audio-2x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-FIXED_CLK(pll_audio_4x_clk,
- CLK_PLL_AUDIO_4X, /* id */
- "pll_audio-4x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 4, /* mult */
- 1, /* div */
- 0); /* flags */
-FIXED_CLK(pll_audio_8x_clk,
- CLK_PLL_AUDIO_8X, /* id */
- "pll_audio-8x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 8, /* mult */
- 1, /* div */
- 0); /* flags */
-
-static const char *pll_video0_parents[] = {"osc24M"};
-FRAC_CLK(pll_video0_clk,
- CLK_PLL_VIDEO0, /* id */
- "pll_video0", pll_video0_parents, /* name, parents */
- 0x10, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-static const char *pll_video0_2x_parents[] = {"pll_video0"};
-FIXED_CLK(pll_video0_2x_clk,
- CLK_PLL_VIDEO0_2X, /* id */
- "pll_video0-2x", /* name */
- pll_video0_2x_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-
-static const char *pll_ve_parents[] = {"osc24M"};
-FRAC_CLK(pll_ve_clk,
- CLK_PLL_VE, /* id */
- "pll_ve", pll_ve_parents, /* name, parents */
- 0x18, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_ddr0_parents[] = {"osc24M"};
-NKMP_CLK_WITH_UPDATE(pll_ddr0_clk,
- CLK_PLL_DDR0, /* id */
- "pll_ddr0", pll_ddr0_parents, /* name, parents */
- 0x20, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- 20, /* update */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_periph0_2x_parents[] = {"osc24M"};
-static const char *pll_periph0_parents[] = {"pll_periph0_2x"};
-NKMP_CLK(pll_periph0_2x_clk,
- CLK_PLL_PERIPH0_2X, /* id */
- "pll_periph0_2x", pll_periph0_2x_parents, /* name, parents */
- 0x28, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 0, 2, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-FIXED_CLK(pll_periph0_clk,
- CLK_PLL_PERIPH0, /* id */
- "pll_periph0", /* name */
- pll_periph0_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-
-static const char *pll_periph1_2x_parents[] = {"osc24M"};
-static const char *pll_periph1_parents[] = {"pll_periph1_2x"};
-NKMP_CLK(pll_periph1_2x_clk,
- CLK_PLL_PERIPH1_2X, /* id */
- "pll_periph1_2x", pll_periph1_2x_parents, /* name, parents */
- 0x2C, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 0, 2, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-FIXED_CLK(pll_periph1_clk,
- CLK_PLL_PERIPH1, /* id */
- "pll_periph1", /* name */
- pll_periph1_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-
-static const char *pll_video1_parents[] = {"osc24M"};
-FRAC_CLK(pll_video1_clk,
- CLK_PLL_VIDEO1, /* id */
- "pll_video1", pll_video1_parents, /* name, parents */
- 0x30, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_gpu_parents[] = {"osc24M"};
-FRAC_CLK(pll_gpu_clk,
- CLK_PLL_GPU, /* id */
- "pll_gpu", pll_gpu_parents, /* name, parents */
- 0x38, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_mipi_parents[] = {"pll_video0"};
-MIPI_CLK(pll_mipi_clk,
- CLK_PLL_MIPI,
- "pll_mipi", pll_mipi_parents,
- 0x40,
- 4, 2, AW_CLK_FACTOR_MIN_VALUE, 2,
- 0, 3,
- 8, 4,
- 31, 28);
-
-static const char *pll_hsic_parents[] = {"osc24M"};
-FRAC_CLK(pll_hsic_clk,
- CLK_PLL_HSIC, /* id */
- "pll_hsic", pll_hsic_parents, /* name, parents */
- 0x44, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_de_parents[] = {"osc24M"};
-FRAC_CLK(pll_de_clk,
- CLK_PLL_DE, /* id */
- "pll_de", pll_de_parents, /* name, parents */
- 0x48, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_ddr1_parents[] = {"osc24M"};
-NKMP_CLK_WITH_UPDATE(pll_ddr1_clk,
- CLK_PLL_DDR1, /* id */
- "pll_ddr1", pll_ddr1_parents, /* name, parents */
- 0x4C, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 0, 2, 0, 0, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- 20, /* update */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *cpux_parents[] = {"osc32k", "osc24M", "pll_cpux"};
-MUX_CLK(cpux_clk,
- CLK_CPUX, /* id */
- "cpux", cpux_parents, /* name, parents */
- 0x50, 16, 2); /* offset, shift, width */
-
-static const char *axi_parents[] = {"cpux"};
-DIV_CLK(axi_clk,
- CLK_AXI, /* id */
- "axi", axi_parents, /* name, parents */
- 0x50, /* offset */
- 0, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *apb_parents[] = {"cpux"};
-DIV_CLK(apb_clk,
- CLK_APB, /* id */
- "apb", apb_parents, /* name, parents */
- 0x50, /* offset */
- 8, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *ahb1_parents[] = {"osc32k", "osc24M", "axi", "pll_periph0"};
-PREDIV_CLK(ahb1_clk, CLK_AHB1, /* id */
- "ahb1", ahb1_parents, /* name, parents */
- 0x54, /* offset */
- 12, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 6, 2, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- 12, 2, 3); /* prediv condition */
-
-static const char *apb1_parents[] = {"ahb1"};
-static struct clk_div_table apb1_div_table[] = {
- { .value = 0, .divider = 2, },
- { .value = 1, .divider = 2, },
- { .value = 2, .divider = 4, },
- { .value = 3, .divider = 8, },
- { },
-};
-DIV_CLK(apb1_clk,
- CLK_APB1, /* id */
- "apb1", apb1_parents, /* name, parents */
- 0x54, /* offset */
- 8, 2, /* shift, width */
- CLK_DIV_WITH_TABLE, /* flags */
- apb1_div_table); /* div table */
-
-static const char *apb2_parents[] = {"osc32k", "osc24M", "pll_periph0_2x", "pll_periph0_2x"};
-NM_CLK(apb2_clk,
- CLK_APB2, /* id */
- "apb2", apb2_parents, /* name, parents */
- 0x58, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 5, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX);
-
-static const char *ahb2_parents[] = {"ahb1", "pll_periph0"};
-PREDIV_CLK(ahb2_clk, CLK_AHB2, /* id */
- "ahb2", ahb2_parents, /* name, parents */
- 0x5c, /* offset */
- 0, 2, /* mux */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* div */
- 0, 0, 2, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */
- 0, 2, 1); /* prediv condition */
-
-static const char *ths_parents[] = {"osc24M"};
-static struct clk_div_table ths_div_table[] = {
- { .value = 0, .divider = 1, },
- { .value = 1, .divider = 2, },
- { .value = 2, .divider = 4, },
- { .value = 3, .divider = 6, },
- { },
-};
-DIV_CLK(ths_clk,
- 0, /* id */
- "thsdiv", ths_parents, /* name, parents */
- 0x74, /* offset */
- 0, 2, /* div shift, div width */
- CLK_DIV_WITH_TABLE, /* flags */
- ths_div_table); /* div table */
-
-static const char *mod_parents[] = {"osc24M", "pll_periph0_2x", "pll_periph1_2x"};
-NM_CLK(nand_clk,
- CLK_NAND, "nand", mod_parents, /* id, name, parents */
- 0x80, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(mmc0_clk,
- CLK_MMC0, "mmc0", mod_parents, /* id, name, parents */
- 0x88, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc1_clk,
- CLK_MMC1, "mmc1", mod_parents, /* id, name, parents */
- 0x8c, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc2_clk,
- CLK_MMC2, "mmc2", mod_parents, /* id, name, parents */
- 0x90, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-static const char *ts_parents[] = {"osc24M", "pll_periph0"};
-NM_CLK(ts_clk,
- CLK_TS, "ts", ts_parents, /* id, name, parents */
- 0x98, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(ce_clk,
- CLK_CE, "ce", mod_parents, /* id, name, parents */
- 0x9C, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(spi0_clk,
- CLK_SPI0, "spi0", mod_parents, /* id, name, parents */
- 0xA0, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(spi1_clk,
- CLK_SPI1, "spi1", mod_parents, /* id, name, parents */
- 0xA4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-static const char *i2s_parents[] = {"pll_audio-8x", "pll_audio-4x", "pll_audio-2x", "pll_audio"};
-MUX_CLK(i2s0mux_clk,
- 0, "i2s0mux", i2s_parents, /* id, name, parents */
- 0xb0, 16, 2); /* offset, mux shift, mux width */
-MUX_CLK(i2s1mux_clk,
- 0, "i2s1mux", i2s_parents, /* id, name, parents */
- 0xb4, 16, 2); /* offset, mux shift, mux width */
-MUX_CLK(i2s2mux_clk,
- 0, "i2s2mux", i2s_parents, /* id, name, parents */
- 0xb8, 16, 2); /* offset, mux shift, mux width */
-
-static const char *spdif_parents[] = {"pll_audio"};
-M_CLK(spdif_clk,
- CLK_SPDIF, "spdif", spdif_parents, /* id, name, parents */
- 0xC0, /* offset */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-/* USBPHY clk sel */
-
-/* DRAM needs update bit */
-static const char *dram_parents[] = {"pll_ddr0", "pll_ddr1"};
-M_CLK(dram_clk,
- CLK_DRAM, "dram", dram_parents, /* id, name, parents */
- 0xF4, /* offset */
- 0, 2, 0, 0, /* m factor */
- 20, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX); /* flags */
-
-static const char *de_parents[] = {"pll_periph0_2x", "pll_de"};
-M_CLK(de_clk,
- CLK_DE, "de", de_parents, /* id, name, parents */
- 0x104, /* offset */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *tcon0_parents[] = {"pll_mipi", NULL, "pll_video0-2x"};
-MUX_CLK(tcon0_clk,
- CLK_TCON0, /* id */
- "tcon0", tcon0_parents, /* name, parents */
- 0x118, 24, 2); /* offset, shift, width */
-
-static const char *tcon1_parents[] = {"pll_video0", NULL, "pll_video1"};
-M_CLK(tcon1_clk,
- CLK_TCON1, "tcon1", tcon1_parents, /* id, name, parents */
- 0x11C, /* offset */
- 0, 5, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE |
- AW_CLK_SET_PARENT); /* flags */
-
-static const char *deinterlace_parents[] = {"pll_periph0", "pll_periph1"};
-M_CLK(deinterlace_clk,
- CLK_DEINTERLACE, "deinterlace", deinterlace_parents, /* id, name, parents */
- 0x124, /* offset */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *csi_sclk_parents[] = {"pll_periph0", "pll_periph1"};
-M_CLK(csi_sclk_clk,
- CLK_CSI_SCLK, "csi-sclk", csi_sclk_parents, /* id, name, parents */
- 0x134, /* offset */
- 16, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *csi_mclk_parents[] = {"osc24M", "pll_video0", "pll_periph1"};
-M_CLK(csi_mclk_clk,
- CLK_CSI_MCLK, "csi-mclk", csi_mclk_parents, /* id, name, parents */
- 0x134, /* offset */
- 0, 4, 0, 0, /* m factor */
- 8, 2, /* mux */
- 15, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *ve_parents[] = {"pll_ve"};
-M_CLK(ve_clk,
- CLK_VE, "ve", ve_parents, /* id, name, parents */
- 0x13C, /* offset */
- 16, 3, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *hdmi_parents[] = {"pll_video0"};
-M_CLK(hdmi_clk,
- CLK_HDMI, "hdmi", hdmi_parents, /* id, name, parents */
- 0x150, /* offset */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE | AW_CLK_SET_PARENT); /* flags */
-
-static const char *mbus_parents[] = {"osc24M", "pll_periph0_2x", "pll_ddr0"};
-M_CLK(mbus_clk,
- CLK_MBUS, "mbus", mbus_parents, /* id, name, parents */
- 0x15C, /* offset */
- 0, 3, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *gpu_parents[] = {"pll_gpu"};
-M_CLK(gpu_clk,
- CLK_GPU, "gpu", gpu_parents, /* id, name, parents */
- 0x1A0, /* offset */
- 0, 2, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-static struct aw_ccung_clk a64_ccu_clks[] = {
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_cpux_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_audio_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_video0_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_ve_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr0_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph0_2x_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph1_2x_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_video1_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_gpu_clk},
- { .type = AW_CLK_MIPI, .clk.mipi = &pll_mipi_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_hsic_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_de_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr1_clk},
-
- { .type = AW_CLK_NM, .clk.nm = &apb2_clk},
- { .type = AW_CLK_NM, .clk.nm = &nand_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc2_clk},
- { .type = AW_CLK_NM, .clk.nm = &ts_clk},
- { .type = AW_CLK_NM, .clk.nm = &ce_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi0_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi1_clk},
- { .type = AW_CLK_M, .clk.m = &spdif_clk},
- { .type = AW_CLK_M, .clk.m = &dram_clk},
- { .type = AW_CLK_M, .clk.m = &de_clk},
- { .type = AW_CLK_M, .clk.m = &tcon1_clk},
- { .type = AW_CLK_M, .clk.m = &deinterlace_clk},
- { .type = AW_CLK_M, .clk.m = &csi_sclk_clk},
- { .type = AW_CLK_M, .clk.m = &csi_mclk_clk},
- { .type = AW_CLK_M, .clk.m = &ve_clk},
- { .type = AW_CLK_M, .clk.m = &hdmi_clk},
- { .type = AW_CLK_M, .clk.m = &mbus_clk},
- { .type = AW_CLK_M, .clk.m = &gpu_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb1_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb2_clk},
- { .type = AW_CLK_MUX, .clk.mux = &cpux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &i2s0mux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &i2s1mux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &i2s2mux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &tcon0_clk},
- { .type = AW_CLK_DIV, .clk.div = &axi_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb1_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb_clk},
- { .type = AW_CLK_DIV, .clk.div = &ths_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &osc12m_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_periph0_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_periph1_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_4x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_8x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_video0_2x_clk},
-};
-
-static struct aw_clk_init a64_init_clks[] = {
- {"ahb1", "pll_periph0", 0, false},
- {"ahb2", "pll_periph0", 0, false},
- {"dram", "pll_ddr0", 0, false},
- {"pll_de", NULL, 432000000, true},
- {"de", "pll_de", 0, true},
-};
-
-static int
-ccu_a64_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun50i-a64-ccu"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner A64 Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_a64_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = a64_ccu_resets;
- sc->nresets = nitems(a64_ccu_resets);
- sc->gates = a64_ccu_gates;
- sc->ngates = nitems(a64_ccu_gates);
- sc->clks = a64_ccu_clks;
- sc->nclks = nitems(a64_ccu_clks);
- sc->clk_init = a64_init_clks;
- sc->n_clk_init = nitems(a64_init_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_a64ng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_a64_probe),
- DEVMETHOD(device_attach, ccu_a64_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_a64ng, ccu_a64ng_driver, ccu_a64ng_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_a64ng, simplebus, ccu_a64ng_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_a83t.c b/sys/arm/allwinner/clkng/ccu_a83t.c
deleted file mode 100644
index 6e004c2a4e89..000000000000
--- a/sys/arm/allwinner/clkng/ccu_a83t.c
+++ /dev/null
@@ -1,786 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017 Kyle Evans <kevans@FreeBSD.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun8i-a83t-ccu.h>
-#include <dt-bindings/reset/sun8i-a83t-ccu.h>
-
-/* Non-exported clocks */
-
-#define CLK_PLL_C0CPUX 0
-#define CLK_PLL_C1CPUX 1
-#define CLK_PLL_AUDIO 2
-#define CLK_PLL_VIDEO0 3
-#define CLK_PLL_VE 4
-#define CLK_PLL_DDR 5
-
-#define CLK_PLL_GPU 7
-#define CLK_PLL_HSIC 8
-#define CLK_PLL_VIDEO1 10
-
-#define CLK_AXI0 13
-#define CLK_AXI1 14
-#define CLK_AHB1 15
-#define CLK_APB1 16
-#define CLK_APB2 17
-#define CLK_AHB2 18
-
-#define CLK_CCI400 58
-
-#define CLK_DRAM 82
-
-#define CLK_MBUS 95
-
-/* Non-exported fixed clocks */
-#define CLK_OSC_12M 150
-
-static struct aw_ccung_reset a83t_ccu_resets[] = {
- CCU_RESET(RST_USB_PHY0, 0xcc, 0)
- CCU_RESET(RST_USB_PHY1, 0xcc, 1)
- CCU_RESET(RST_USB_HSIC, 0xcc, 2)
-
- CCU_RESET(RST_DRAM, 0xf4, 31)
- CCU_RESET(RST_MBUS, 0xfc, 31)
-
- CCU_RESET(RST_BUS_MIPI_DSI, 0x2c0, 1)
- CCU_RESET(RST_BUS_SS, 0x2c0, 5)
- CCU_RESET(RST_BUS_DMA, 0x2c0, 6)
- CCU_RESET(RST_BUS_MMC0, 0x2c0, 8)
- CCU_RESET(RST_BUS_MMC1, 0x2c0, 9)
- CCU_RESET(RST_BUS_MMC2, 0x2c0, 10)
- CCU_RESET(RST_BUS_NAND, 0x2c0, 13)
- CCU_RESET(RST_BUS_DRAM, 0x2c0, 14)
- CCU_RESET(RST_BUS_EMAC, 0x2c0, 17)
- CCU_RESET(RST_BUS_HSTIMER, 0x2c0, 19)
- CCU_RESET(RST_BUS_SPI0, 0x2c0, 20)
- CCU_RESET(RST_BUS_SPI1, 0x2c0, 21)
- CCU_RESET(RST_BUS_OTG, 0x2c0, 24)
- CCU_RESET(RST_BUS_EHCI0, 0x2c0, 26)
- CCU_RESET(RST_BUS_EHCI1, 0x2c0, 27)
- CCU_RESET(RST_BUS_OHCI0, 0x2c0, 29)
-
- CCU_RESET(RST_BUS_VE, 0x2c4, 0)
- CCU_RESET(RST_BUS_TCON0, 0x2c4, 4)
- CCU_RESET(RST_BUS_TCON1, 0x2c4, 5)
- CCU_RESET(RST_BUS_CSI, 0x2c4, 8)
- CCU_RESET(RST_BUS_HDMI0, 0x2c4, 10)
- CCU_RESET(RST_BUS_HDMI1, 0x2c4, 11)
- CCU_RESET(RST_BUS_DE, 0x2c4, 12)
- CCU_RESET(RST_BUS_GPU, 0x2c4, 20)
- CCU_RESET(RST_BUS_MSGBOX, 0x2c4, 21)
- CCU_RESET(RST_BUS_SPINLOCK, 0x2c4, 22)
-
- CCU_RESET(RST_BUS_LVDS, 0x2c8, 0)
-
- CCU_RESET(RST_BUS_SPDIF, 0x2d0, 1)
- CCU_RESET(RST_BUS_I2S0, 0x2d0, 12)
- CCU_RESET(RST_BUS_I2S1, 0x2d0, 13)
- CCU_RESET(RST_BUS_I2S2, 0x2d0, 14)
- CCU_RESET(RST_BUS_TDM, 0x2d0, 15)
-
- CCU_RESET(RST_BUS_I2C0, 0x2d8, 0)
- CCU_RESET(RST_BUS_I2C1, 0x2d8, 1)
- CCU_RESET(RST_BUS_I2C2, 0x2d8, 2)
- CCU_RESET(RST_BUS_UART0, 0x2d8, 16)
- CCU_RESET(RST_BUS_UART1, 0x2d8, 17)
- CCU_RESET(RST_BUS_UART2, 0x2d8, 18)
- CCU_RESET(RST_BUS_UART3, 0x2d8, 19)
- CCU_RESET(RST_BUS_UART4, 0x2d8, 20)
-};
-
-static struct aw_ccung_gate a83t_ccu_gates[] = {
- CCU_GATE(CLK_BUS_MIPI_DSI, "bus-mipi-dsi", "ahb1", 0x60, 1)
- CCU_GATE(CLK_BUS_SS, "bus-ss", "ahb1", 0x60, 5)
- CCU_GATE(CLK_BUS_DMA, "bus-dma", "ahb1", 0x60, 6)
- CCU_GATE(CLK_BUS_MMC0, "bus-mmc0", "ahb1", 0x60, 8)
- CCU_GATE(CLK_BUS_MMC1, "bus-mmc1", "ahb1", 0x60, 9)
- CCU_GATE(CLK_BUS_MMC2, "bus-mmc2", "ahb1", 0x60, 10)
- CCU_GATE(CLK_BUS_NAND, "bus-nand", "ahb1", 0x60, 13)
- CCU_GATE(CLK_BUS_DRAM, "bus-dram", "ahb1", 0x60, 14)
- CCU_GATE(CLK_BUS_EMAC, "bus-emac", "ahb1", 0x60, 17)
- CCU_GATE(CLK_BUS_HSTIMER, "bus-hstimer", "ahb1", 0x60, 19)
- CCU_GATE(CLK_BUS_SPI0, "bus-spi0", "ahb1", 0x60, 20)
- CCU_GATE(CLK_BUS_SPI1, "bus-spi1", "ahb1", 0x60, 21)
- CCU_GATE(CLK_BUS_OTG, "bus-otg", "ahb1", 0x60, 24)
- CCU_GATE(CLK_BUS_EHCI0, "bus-ehci0", "ahb2", 0x60, 26)
- CCU_GATE(CLK_BUS_EHCI1, "bus-ehci1", "ahb2", 0x60, 27)
- CCU_GATE(CLK_BUS_OHCI0, "bus-ohci0", "ahb2", 0x60, 29)
-
- CCU_GATE(CLK_BUS_VE, "bus-ve", "ahb1", 0x64, 0)
- CCU_GATE(CLK_BUS_TCON0, "bus-tcon0", "ahb1", 0x64, 4)
- CCU_GATE(CLK_BUS_TCON1, "bus-tcon1", "ahb1", 0x64, 5)
- CCU_GATE(CLK_BUS_CSI, "bus-csi", "ahb1", 0x64, 8)
- CCU_GATE(CLK_BUS_HDMI, "bus-hdmi", "ahb1", 0x64, 11)
- CCU_GATE(CLK_BUS_DE, "bus-de", "ahb1", 0x64, 12)
- CCU_GATE(CLK_BUS_GPU, "bus-gpu", "ahb1", 0x64, 20)
- CCU_GATE(CLK_BUS_MSGBOX, "bus-msgbox", "ahb1", 0x64, 21)
- CCU_GATE(CLK_BUS_SPINLOCK, "bus-spinlock", "ahb1", 0x64, 22)
-
- CCU_GATE(CLK_BUS_SPDIF, "bus-spdif", "apb1", 0x68, 1)
- CCU_GATE(CLK_BUS_PIO, "bus-pio", "apb1", 0x68, 5)
- CCU_GATE(CLK_BUS_I2S0, "bus-i2s0", "apb1", 0x68, 12)
- CCU_GATE(CLK_BUS_I2S1, "bus-i2s1", "apb1", 0x68, 13)
- CCU_GATE(CLK_BUS_I2S2, "bus-i2s2", "apb1", 0x68, 14)
- CCU_GATE(CLK_BUS_TDM, "bus-tdm", "apb1", 0x68, 15)
-
- CCU_GATE(CLK_BUS_I2C0, "bus-i2c0", "apb2", 0x6c, 0)
- CCU_GATE(CLK_BUS_I2C1, "bus-i2c1", "apb2", 0x6c, 1)
- CCU_GATE(CLK_BUS_I2C2, "bus-i2c2", "apb2", 0x6c, 2)
- CCU_GATE(CLK_BUS_UART0, "bus-uart0", "apb2", 0x6c, 16)
- CCU_GATE(CLK_BUS_UART1, "bus-uart1", "apb2", 0x6c, 17)
- CCU_GATE(CLK_BUS_UART2, "bus-uart2", "apb2", 0x6c, 18)
- CCU_GATE(CLK_BUS_UART3, "bus-uart3", "apb2", 0x6c, 19)
- CCU_GATE(CLK_BUS_UART4, "bus-uart4", "apb2", 0x6c, 20)
-
- CCU_GATE(CLK_USB_PHY0, "usb-phy0", "osc24M", 0xcc, 8)
- CCU_GATE(CLK_USB_PHY1, "usb-phy1", "osc24M", 0xcc, 9)
- CCU_GATE(CLK_USB_HSIC, "usb-hsic", "pll_hsic", 0xcc, 10)
- CCU_GATE(CLK_USB_HSIC_12M, "usb-hsic-12M", "osc12M", 0xcc, 11)
- CCU_GATE(CLK_USB_OHCI0, "usb-ohci0", "osc12M", 0xcc, 16)
-
- CCU_GATE(CLK_DRAM_VE, "dram-ve", "dram", 0x100, 0)
- CCU_GATE(CLK_DRAM_CSI, "dram-csi", "dram", 0x100, 1)
-
- CCU_GATE(CLK_CSI_MISC, "csi-misc", "osc24M", 0x130, 16)
- CCU_GATE(CLK_MIPI_CSI, "mipi-csi", "osc24M", 0x130, 31)
-
- CCU_GATE(CLK_AVS, "avs", "osc24M", 0x144, 31)
-
- CCU_GATE(CLK_HDMI_SLOW, "hdmi-ddc", "osc24M", 0x154, 31)
-};
-
-static const char *osc12m_parents[] = {"osc24M"};
-FIXED_CLK(osc12m_clk,
- CLK_OSC_12M, /* id */
- "osc12M", osc12m_parents, /* name, parents */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-
-/* CPU PLL are 24Mhz * N / P */
-static const char *pll_c0cpux_parents[] = {"osc24M"};
-static const char *pll_c1cpux_parents[] = {"osc24M"};
-NKMP_CLK(pll_c0cpux_clk,
- CLK_PLL_C0CPUX, /* id */
- "pll_c0cpux", pll_c0cpux_parents, /* name, parents */
- 0x00, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 0, 0, /* lock */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_SCALE_CHANGE); /* flags */
-NKMP_CLK(pll_c1cpux_clk,
- CLK_PLL_C1CPUX, /* id */
- "pll_c1cpux", pll_c1cpux_parents, /* name, parents */
- 0x04, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 0, 0, /* lock */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_SCALE_CHANGE); /* flags */
-
-static const char *pll_audio_parents[] = {"osc24M"};
-NKMP_CLK(pll_audio_clk,
- CLK_PLL_AUDIO, /* id */
- "pll_audio", pll_audio_parents, /* name, parents */
- 0x08, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 0, 0, /* m factor */
- 18, 1, 0, 0, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_video0_parents[] = {"osc24M"};
-NKMP_CLK(pll_video0_clk,
- CLK_PLL_VIDEO0, /* id */
- "pll_video0", pll_video0_parents, /* name, parents */
- 0x10, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 0, 0, /* m factor */
- 0, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_ve_parents[] = {"osc24M"};
-NKMP_CLK(pll_ve_clk,
- CLK_PLL_VE, /* id */
- "pll_ve", pll_ve_parents, /* name, parents */
- 0x18, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 0, 0, /* m factor */
- 18, 1, 0, 0, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_ddr_parents[] = {"osc24M"};
-NKMP_CLK(pll_ddr_clk,
- CLK_PLL_DDR, /* id */
- "pll_ddr", pll_ddr_parents, /* name, parents */
- 0x20, /* offset */
- 8, 5, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 0, 0, /* m factor */
- 18, 1, 0, 0, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_periph_parents[] = {"osc24M"};
-NKMP_CLK(pll_periph_clk,
- CLK_PLL_PERIPH, /* id */
- "pll_periph", pll_periph_parents, /* name, parents */
- 0x28, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 1, 0, /* m factor */
- 18, 1, 1, 0, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_gpu_parents[] = {"osc24M"};
-NKMP_CLK(pll_gpu_clk,
- CLK_PLL_GPU, /* id */
- "pll_gpu", pll_gpu_parents, /* name, parents */
- 0x38, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 1, 0, /* m factor */
- 18, 1, 1, 0, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_hsic_parents[] = {"osc24M"};
-NKMP_CLK(pll_hsic_clk,
- CLK_PLL_HSIC, /* id */
- "pll_hsic", pll_hsic_parents, /* name, parents */
- 0x44, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 1, 0, /* m factor */
- 18, 1, 1, 0, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_de_parents[] = {"osc24M"};
-NKMP_CLK(pll_de_clk,
- CLK_PLL_DE, /* id */
- "pll_de", pll_de_parents, /* name, parents */
- 0x48, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 1, 0, /* m factor */
- 18, 1, 1, 0, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *pll_video1_parents[] = {"osc24M"};
-NKMP_CLK(pll_video1_clk,
- CLK_PLL_VIDEO1, /* id */
- "pll_video1", pll_video1_parents, /* name, parents */
- 0x4c, /* offset */
- 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 16, 1, 1, 0, /* m factor */
- 0, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
- 31, /* gate */
- 0, 0, /* lock */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *c0cpux_parents[] = {"osc24M", "pll_c0cpux"};
-MUX_CLK(c0cpux_clk,
- CLK_C0CPUX, /* id */
- "c0cpux", c0cpux_parents, /* name, parents */
- 0x50, 12, 1); /* offset, shift, width */
-
-static const char *c1cpux_parents[] = {"osc24M", "pll_c1cpux"};
-MUX_CLK(c1cpux_clk,
- CLK_C1CPUX, /* id */
- "c1cpux", c1cpux_parents, /* name, parents */
- 0x50, 28, 1); /* offset, shift, width */
-
-static const char *axi0_parents[] = {"c0cpux"};
-DIV_CLK(axi0_clk,
- CLK_AXI0, /* id */
- "axi0", axi0_parents, /* name, parents */
- 0x50, /* offset */
- 0, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *axi1_parents[] = {"c1cpux"};
-DIV_CLK(axi1_clk,
- CLK_AXI1, /* id */
- "axi1", axi1_parents, /* name, parents */
- 0x50, /* offset */
- 16, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *ahb1_parents[] = {"osc16M-d512", "osc24M", "pll_periph", "pll_periph"};
-PREDIV_CLK_WITH_MASK(ahb1_clk,
- CLK_AHB1, /* id */
- "ahb1", ahb1_parents, /* name, parents */
- 0x54, /* offset */
- 12, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 6, 2, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- (2 << 12), (2 << 12)); /* prediv condition */
-
-static const char *apb1_parents[] = {"ahb1"};
-DIV_CLK(apb1_clk,
- CLK_APB1, /* id */
- "apb1", apb1_parents, /* name, parents */
- 0x54, /* offset */
- 8, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *apb2_parents[] = {"osc16M-d512", "osc24M", "pll_periph", "pll_periph"};
-NM_CLK(apb2_clk,
- CLK_APB2, /* id */
- "apb2", apb2_parents, /* name, parents */
- 0x58, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 5, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX);
-
-static const char *ahb2_parents[] = {"ahb1", "pll_periph"};
-PREDIV_CLK(ahb2_clk,
- CLK_AHB2, /* id */
- "ahb2", ahb2_parents, /* name, parents */
- 0x5c,
- 0, 2, /* mux */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* div (fake) */
- 0, 0, 2, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */
- 0, 2, 1); /* prediv cond */
-
-/* Actually has a divider, but we don't use it */
-static const char *cci400_parents[] = {"osc24M", "pll_periph", "pll_hsic"};
-MUX_CLK(cci400_clk,
- CLK_CCI400, /* id */
- "cci400", cci400_parents, /* name, parents */
- 0x78, 24, 2); /* offset, shift, width */
-
-static const char *mod_parents[] = {"osc24M", "pll_periph"};
-
-NM_CLK(nand_clk,
- CLK_NAND, /* id */
- "nand", mod_parents, /* name, parents */
- 0x80, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
-
-NM_CLK(mmc0_clk,
- CLK_MMC0, /* id */
- "mmc0", mod_parents, /* name, parents */
- 0x88, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT);
-NM_CLK(mmc1_clk,
- CLK_MMC1, /* id */
- "mmc1", mod_parents, /* name, parents */
- 0x8c, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT);
-NM_CLK(mmc2_clk,
- CLK_MMC2, /* id */
- "mmc2", mod_parents, /* name, parents */
- 0x90, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT);
-
-NM_CLK(ss_clk,
- CLK_SS, /* id */
- "ss", mod_parents, /* name, parents */
- 0x9c, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
-
-NM_CLK(spi0_clk,
- CLK_SPI0, /* id */
- "spi0", mod_parents, /* name, parents */
- 0xa0, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
-NM_CLK(spi1_clk,
- CLK_SPI1, /* id */
- "spi1", mod_parents, /* name, parents */
- 0xa4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX);
-
-static const char *daudio_parents[] = {"pll_audio"};
-NM_CLK(i2s0_clk,
- CLK_I2S0, /* id */
- "i2s0", daudio_parents, /* name, parents */
- 0xb0, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-NM_CLK(i2s1_clk,
- CLK_I2S1, /* id */
- "i2s1", daudio_parents, /* name, parents */
- 0xb4, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-NM_CLK(i2s2_clk,
- CLK_I2S2, /* id */
- "i2s2", daudio_parents, /* name, parents */
- 0xb8, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-
-static const char *tdm_parents[] = {"pll_audio"};
-NM_CLK(tdm_clk,
- CLK_TDM, /* id */
- "tdm", tdm_parents, /* name, parents */
- 0xbc, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-
-static const char *spdif_parents[] = {"pll_audio"};
-NM_CLK(spdif_clk,
- CLK_SPDIF, /* id */
- "spdif", spdif_parents, /* name, parents */
- 0xc0, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-
-static const char *dram_parents[] = {"pll_ddr"};
-NM_CLK(dram_clk,
- CLK_DRAM, /* id */
- "dram", dram_parents, /* name, parents */
- 0xf4, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 0, /* gate */
- 0);
-
-static const char *tcon0_parents[] = {"pll_video0"};
-MUX_CLK(tcon0_clk,
- CLK_TCON0, /* id */
- "tcon0", tcon0_parents, /* name, parents */
- 0x118, 24, 2); /* offset, shift, width */
-
-static const char *tcon1_parents[] = {"pll_video1"};
-NM_CLK(tcon1_clk,
- CLK_TCON1, /* id */
- "tcon1", tcon1_parents, /* name, parents */
- 0x11c, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-
-static const char *csi_mclk_parents[] = {"pll_de", "osc24M"};
-NM_CLK(csi_mclk_clk,
- CLK_CSI_MCLK, /* id */
- "csi-mclk", csi_mclk_parents, /* name, parents */
- 0x134, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 8, 3, /* mux */
- 15, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
-
-static const char *csi_sclk_parents[] = {"pll_periph", "pll_ve"};
-NM_CLK(csi_sclk_clk,
- CLK_CSI_SCLK, /* id */
- "csi-sclk", csi_sclk_parents, /* name, parents */
- 0x134, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 16, 4, 0, 0, /* m factor */
- 24, 3, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
-
-static const char *ve_parents[] = {"pll_ve"};
-NM_CLK(ve_clk,
- CLK_VE, /* id */
- "ve", ve_parents, /* name, parents */
- 0x13c, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 16, 3, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-
-static const char *hdmi_parents[] = {"pll_video1"};
-NM_CLK(hdmi_clk,
- CLK_HDMI, /* id */
- "hdmi", hdmi_parents, /* name, parents */
- 0x150, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
-
-static const char *mbus_parents[] = {"osc24M", "pll_periph", "pll_ddr"};
-NM_CLK(mbus_clk,
- CLK_MBUS, /* id */
- "mbus", mbus_parents, /* name, parents */
- 0x15c, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 3, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
-
-static const char *mipi_dsi0_parents[] = {"pll_video0"};
-NM_CLK(mipi_dsi0_clk,
- CLK_MIPI_DSI0, /* id */
- "mipi-dsi0", mipi_dsi0_parents, /* name, parents */
- 0x168, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
-
-static const char *mipi_dsi1_parents[] = {"osc24M", "pll_video0"};
-NM_CLK(mipi_dsi1_clk,
- CLK_MIPI_DSI1, /* id */
- "mipi-dsi1", mipi_dsi1_parents, /* name, parents */
- 0x16c, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 4, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
-
-static const char *gpu_core_parents[] = {"pll_gpu"};
-NM_CLK(gpu_core_clk,
- CLK_GPU_CORE, /* id */
- "gpu-core", gpu_core_parents, /* name, parents */
- 0x1a0, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 3, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-
-static const char *gpu_memory_parents[] = {"pll_gpu", "pll_periph"};
-NM_CLK(gpu_memory_clk,
- CLK_GPU_MEMORY, /* id */
- "gpu-memory", gpu_memory_parents, /* name, parents */
- 0x1a4, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 3, 0, 0, /* m factor */
- 24, 1, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE);
-
-static const char *gpu_hyd_parents[] = {"pll_gpu"};
-NM_CLK(gpu_hyd_clk,
- CLK_GPU_HYD, /* id */
- "gpu-hyd", gpu_hyd_parents, /* name, parents */
- 0x1a0, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 3, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE);
-
-static struct aw_ccung_clk a83t_clks[] = {
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_audio_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_video0_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ve_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_gpu_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_hsic_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_de_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_video1_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_c0cpux_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_c1cpux_clk},
- { .type = AW_CLK_NM, .clk.nm = &apb2_clk},
- { .type = AW_CLK_NM, .clk.nm = &nand_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc2_clk},
- { .type = AW_CLK_NM, .clk.nm = &ss_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi0_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi1_clk},
- { .type = AW_CLK_NM, .clk.nm = &i2s0_clk},
- { .type = AW_CLK_NM, .clk.nm = &i2s1_clk},
- { .type = AW_CLK_NM, .clk.nm = &i2s2_clk},
- { .type = AW_CLK_NM, .clk.nm = &tdm_clk},
- { .type = AW_CLK_NM, .clk.nm = &spdif_clk},
- { .type = AW_CLK_NM, .clk.nm = &dram_clk},
- { .type = AW_CLK_NM, .clk.nm = &tcon1_clk},
- { .type = AW_CLK_NM, .clk.nm = &csi_mclk_clk},
- { .type = AW_CLK_NM, .clk.nm = &csi_sclk_clk},
- { .type = AW_CLK_NM, .clk.nm = &ve_clk},
- { .type = AW_CLK_NM, .clk.nm = &hdmi_clk},
- { .type = AW_CLK_NM, .clk.nm = &mbus_clk},
- { .type = AW_CLK_NM, .clk.nm = &mipi_dsi0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mipi_dsi1_clk},
- { .type = AW_CLK_NM, .clk.nm = &gpu_core_clk},
- { .type = AW_CLK_NM, .clk.nm = &gpu_memory_clk},
- { .type = AW_CLK_NM, .clk.nm = &gpu_hyd_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb1_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb2_clk},
- { .type = AW_CLK_MUX, .clk.mux = &c0cpux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &c1cpux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &cci400_clk},
- { .type = AW_CLK_MUX, .clk.mux = &tcon0_clk},
- { .type = AW_CLK_DIV, .clk.div = &axi0_clk},
- { .type = AW_CLK_DIV, .clk.div = &axi1_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb1_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &osc12m_clk},
-};
-
-static struct aw_clk_init a83t_init_clks[] = {
- {"ahb1", "pll_periph", 0, false},
- {"ahb2", "ahb1", 0, false},
- {"dram", "pll_ddr", 0, false},
-};
-
-static int
-ccu_a83t_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun8i-a83t-ccu"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner A83T Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_a83t_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = a83t_ccu_resets;
- sc->nresets = nitems(a83t_ccu_resets);
- sc->gates = a83t_ccu_gates;
- sc->ngates = nitems(a83t_ccu_gates);
- sc->clks = a83t_clks;
- sc->nclks = nitems(a83t_clks);
- sc->clk_init = a83t_init_clks;
- sc->n_clk_init = nitems(a83t_init_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_a83tng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_a83t_probe),
- DEVMETHOD(device_attach, ccu_a83t_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_a83tng, ccu_a83tng_driver, ccu_a83tng_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_a83tng, simplebus, ccu_a83tng_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_de2.c b/sys/arm/allwinner/clkng/ccu_de2.c
deleted file mode 100644
index efcbbc524c83..000000000000
--- a/sys/arm/allwinner/clkng/ccu_de2.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#ifdef __aarch64__
-#include "opt_soc.h"
-#endif
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <dev/extres/hwreset/hwreset.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun8i-de2.h>
-#include <dt-bindings/reset/sun8i-de2.h>
-
-enum CCU_DE2 {
- H3_CCU = 1,
- A64_CCU,
-};
-
-/* Non exported clocks */
-#define CLK_MIXER0_DIV 3
-#define CLK_MIXER1_DIV 4
-#define CLK_WB_DIV 5
-
-static struct aw_ccung_reset h3_de2_ccu_resets[] = {
- CCU_RESET(RST_MIXER0, 0x08, 0)
- CCU_RESET(RST_WB, 0x08, 2)
-};
-
-static struct aw_ccung_reset a64_de2_ccu_resets[] = {
- CCU_RESET(RST_MIXER0, 0x08, 0)
- CCU_RESET(RST_MIXER1, 0x08, 1)
- CCU_RESET(RST_WB, 0x08, 2)
-};
-
-static struct aw_ccung_gate h3_de2_ccu_gates[] = {
- CCU_GATE(CLK_BUS_MIXER0, "mixer0", "mixer0-div", 0x00, 0)
- CCU_GATE(CLK_BUS_WB, "wb", "wb-div", 0x00, 2)
-
- CCU_GATE(CLK_MIXER0, "bus-mixer0", "bus-de", 0x04, 0)
- CCU_GATE(CLK_WB, "bus-wb", "bus-de", 0x04, 2)
-};
-
-static struct aw_ccung_gate a64_de2_ccu_gates[] = {
- CCU_GATE(CLK_BUS_MIXER0, "mixer0", "mixer0-div", 0x00, 0)
- CCU_GATE(CLK_BUS_MIXER1, "mixer1", "mixer1-div", 0x00, 1)
- CCU_GATE(CLK_BUS_WB, "wb", "wb-div", 0x00, 2)
-
- CCU_GATE(CLK_MIXER0, "bus-mixer0", "bus-de", 0x04, 0)
- CCU_GATE(CLK_MIXER1, "bus-mixer1", "bus-de", 0x04, 1)
- CCU_GATE(CLK_WB, "bus-wb", "bus-de", 0x04, 2)
-};
-
-static const char *div_parents[] = {"de"};
-
-NM_CLK(mixer0_div_clk,
- CLK_MIXER0_DIV, /* id */
- "mixer0-div", div_parents, /* names, parents */
- 0x0C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* N factor (fake)*/
- 0, 4, 0, 0, /* M flags */
- 0, 0, /* mux */
- 0, /* gate */
- AW_CLK_SCALE_CHANGE); /* flags */
-
-NM_CLK(mixer1_div_clk,
- CLK_MIXER1_DIV, /* id */
- "mixer1-div", div_parents, /* names, parents */
- 0x0C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* N factor (fake)*/
- 4, 4, 0, 0, /* M flags */
- 0, 0, /* mux */
- 0, /* gate */
- AW_CLK_SCALE_CHANGE); /* flags */
-
-NM_CLK(wb_div_clk,
- CLK_WB_DIV, /* id */
- "wb-div", div_parents, /* names, parents */
- 0x0C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* N factor (fake)*/
- 8, 4, 0, 0, /* M flags */
- 0, 0, /* mux */
- 0, /* gate */
- AW_CLK_SCALE_CHANGE); /* flags */
-
-static struct aw_ccung_clk h3_de2_ccu_clks[] = {
- { .type = AW_CLK_NM, .clk.nm = &mixer0_div_clk},
- { .type = AW_CLK_NM, .clk.nm = &wb_div_clk},
-};
-
-static struct aw_ccung_clk a64_de2_ccu_clks[] = {
- { .type = AW_CLK_NM, .clk.nm = &mixer0_div_clk},
- { .type = AW_CLK_NM, .clk.nm = &mixer1_div_clk},
- { .type = AW_CLK_NM, .clk.nm = &wb_div_clk},
-};
-
-static struct ofw_compat_data compat_data[] = {
- {"allwinner,sun8i-h3-de2-clk", H3_CCU},
- {"allwinner,sun50i-a64-de2-clk", A64_CCU},
- {NULL, 0}
-};
-
-static int
-ccu_de2_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner DE2 Clock Control Unit");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_de2_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
- phandle_t node;
- clk_t mod, bus;
- hwreset_t rst_de;
- enum CCU_DE2 type;
-
- sc = device_get_softc(dev);
- node = ofw_bus_get_node(dev);
-
- type = (enum CCU_DE2)ofw_bus_search_compatible(dev, compat_data)->ocd_data;
-
- switch (type) {
- case H3_CCU:
- sc->resets = h3_de2_ccu_resets;
- sc->nresets = nitems(h3_de2_ccu_resets);
- sc->gates = h3_de2_ccu_gates;
- sc->ngates = nitems(h3_de2_ccu_gates);
- sc->clks = h3_de2_ccu_clks;
- sc->nclks = nitems(h3_de2_ccu_clks);
- break;
- case A64_CCU:
- sc->resets = a64_de2_ccu_resets;
- sc->nresets = nitems(a64_de2_ccu_resets);
- sc->gates = a64_de2_ccu_gates;
- sc->ngates = nitems(a64_de2_ccu_gates);
- sc->clks = a64_de2_ccu_clks;
- sc->nclks = nitems(a64_de2_ccu_clks);
- break;
- }
-
- if (hwreset_get_by_ofw_idx(dev, node, 0, &rst_de) != 0) {
- device_printf(dev, "Cannot get de reset\n");
- return (ENXIO);
- }
- if (hwreset_deassert(rst_de) != 0) {
- device_printf(dev, "Cannot de-assert de reset\n");
- return (ENXIO);
- }
-
- if (clk_get_by_ofw_name(dev, node, "mod", &mod) != 0) {
- device_printf(dev, "Cannot get mod clock\n");
- return (ENXIO);
- }
- if (clk_enable(mod) != 0) {
- device_printf(dev, "Cannot enable mod clock\n");
- return (ENXIO);
- }
-
- if (clk_get_by_ofw_name(dev, node, "bus", &bus) != 0) {
- device_printf(dev, "Cannot get bus clock\n");
- return (ENXIO);
- }
- if (clk_enable(bus) != 0) {
- device_printf(dev, "Cannot enable bus clock\n");
- return (ENXIO);
- }
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_de2_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_de2_probe),
- DEVMETHOD(device_attach, ccu_de2_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_de2, ccu_de2_driver, ccu_de2_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_de2, simplebus, ccu_de2_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_LAST);
diff --git a/sys/arm/allwinner/clkng/ccu_h3.c b/sys/arm/allwinner/clkng/ccu_h3.c
deleted file mode 100644
index c911497b3d3c..000000000000
--- a/sys/arm/allwinner/clkng/ccu_h3.c
+++ /dev/null
@@ -1,792 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#if defined(__aarch64__)
-#include "opt_soc.h"
-#endif
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun8i-h3-ccu.h>
-#include <dt-bindings/reset/sun8i-h3-ccu.h>
-
-/* Non-exported resets */
-#define RST_BUS_SCR 53
-
-/* Non-exported clocks */
-#define CLK_PLL_CPUX 0
-#define CLK_PLL_AUDIO_BASE 1
-#define CLK_PLL_AUDIO 2
-#define CLK_PLL_AUDIO_2X 3
-#define CLK_PLL_AUDIO_4X 4
-#define CLK_PLL_AUDIO_8X 5
-#define CLK_PLL_VIDEO 6
-#define CLK_PLL_VE 7
-#define CLK_PLL_DDR 8
-#define CLK_PLL_PERIPH0_2X 10
-#define CLK_PLL_GPU 11
-#define CLK_PLL_PERIPH1 12
-#define CLK_PLL_DE 13
-
-#define CLK_AXI 15
-#define CLK_AHB1 16
-#define CLK_APB1 17
-#define CLK_APB2 18
-#define CLK_AHB2 19
-
-#define CLK_BUS_SCR 66
-
-#define CLK_USBPHY0 88
-#define CLK_USBPHY1 89
-#define CLK_USBPHY2 90
-#define CLK_USBPHY3 91
-#define CLK_USBOHCI0 92
-#define CLK_USBOHCI1 93
-#define CLK_USBOHCI2 94
-#define CLK_USBOHCI3 95
-#define CLK_DRAM 96
-
-#define CLK_MBUS 113
-
-static struct aw_ccung_reset h3_ccu_resets[] = {
- CCU_RESET(RST_USB_PHY0, 0xcc, 0)
- CCU_RESET(RST_USB_PHY1, 0xcc, 1)
- CCU_RESET(RST_USB_PHY2, 0xcc, 2)
- CCU_RESET(RST_USB_PHY3, 0xcc, 3)
-
- CCU_RESET(RST_MBUS, 0xfc, 31)
-
- CCU_RESET(RST_BUS_CE, 0x2c0, 5)
- CCU_RESET(RST_BUS_DMA, 0x2c0, 6)
- CCU_RESET(RST_BUS_MMC0, 0x2c0, 8)
- CCU_RESET(RST_BUS_MMC1, 0x2c0, 9)
- CCU_RESET(RST_BUS_MMC2, 0x2c0, 10)
- CCU_RESET(RST_BUS_NAND, 0x2c0, 13)
- CCU_RESET(RST_BUS_DRAM, 0x2c0, 14)
- CCU_RESET(RST_BUS_EMAC, 0x2c0, 17)
- CCU_RESET(RST_BUS_TS, 0x2c0, 18)
- CCU_RESET(RST_BUS_HSTIMER, 0x2c0, 19)
- CCU_RESET(RST_BUS_SPI0, 0x2c0, 20)
- CCU_RESET(RST_BUS_SPI1, 0x2c0, 21)
- CCU_RESET(RST_BUS_OTG, 0x2c0, 23)
- CCU_RESET(RST_BUS_EHCI0, 0x2c0, 24)
- CCU_RESET(RST_BUS_EHCI1, 0x2c0, 25)
- CCU_RESET(RST_BUS_EHCI2, 0x2c0, 26)
- CCU_RESET(RST_BUS_EHCI3, 0x2c0, 27)
- CCU_RESET(RST_BUS_OHCI0, 0x2c0, 28)
- CCU_RESET(RST_BUS_OHCI1, 0x2c0, 29)
- CCU_RESET(RST_BUS_OHCI2, 0x2c0, 30)
- CCU_RESET(RST_BUS_OHCI3, 0x2c0, 31)
-
- CCU_RESET(RST_BUS_VE, 0x2c4, 0)
- CCU_RESET(RST_BUS_TCON0, 0x2c4, 3)
- CCU_RESET(RST_BUS_TCON1, 0x2c4, 4)
- CCU_RESET(RST_BUS_DEINTERLACE, 0x2c4, 5)
- CCU_RESET(RST_BUS_CSI, 0x2c4, 8)
- CCU_RESET(RST_BUS_TVE, 0x2c4, 9)
- CCU_RESET(RST_BUS_HDMI0, 0x2c4, 10)
- CCU_RESET(RST_BUS_HDMI1, 0x2c4, 11)
- CCU_RESET(RST_BUS_DE, 0x2c4, 12)
- CCU_RESET(RST_BUS_GPU, 0x2c4, 20)
- CCU_RESET(RST_BUS_MSGBOX, 0x2c4, 21)
- CCU_RESET(RST_BUS_SPINLOCK, 0x2c4, 22)
- CCU_RESET(RST_BUS_DBG, 0x2c4, 31)
-
- CCU_RESET(RST_BUS_EPHY, 0x2c8, 2)
-
- CCU_RESET(RST_BUS_CODEC, 0x2d0, 0)
- CCU_RESET(RST_BUS_SPDIF, 0x2d0, 1)
- CCU_RESET(RST_BUS_THS, 0x2d0, 8)
- CCU_RESET(RST_BUS_I2S0, 0x2d0, 12)
- CCU_RESET(RST_BUS_I2S1, 0x2d0, 13)
- CCU_RESET(RST_BUS_I2S2, 0x2d0, 14)
-
- CCU_RESET(RST_BUS_I2C0, 0x2d8, 0)
- CCU_RESET(RST_BUS_I2C1, 0x2d8, 1)
- CCU_RESET(RST_BUS_I2C2, 0x2d8, 2)
- CCU_RESET(RST_BUS_UART0, 0x2d8, 16)
- CCU_RESET(RST_BUS_UART1, 0x2d8, 17)
- CCU_RESET(RST_BUS_UART2, 0x2d8, 18)
- CCU_RESET(RST_BUS_UART3, 0x2d8, 19)
- CCU_RESET(RST_BUS_SCR, 0x2d8, 20)
-};
-
-static struct aw_ccung_gate h3_ccu_gates[] = {
- CCU_GATE(CLK_BUS_CE, "bus-ce", "ahb1", 0x60, 5)
- CCU_GATE(CLK_BUS_DMA, "bus-dma", "ahb1", 0x60, 6)
- CCU_GATE(CLK_BUS_MMC0, "bus-mmc0", "ahb1", 0x60, 8)
- CCU_GATE(CLK_BUS_MMC1, "bus-mmc1", "ahb1", 0x60, 9)
- CCU_GATE(CLK_BUS_MMC2, "bus-mmc2", "ahb1", 0x60, 10)
- CCU_GATE(CLK_BUS_NAND, "bus-nand", "ahb1", 0x60, 13)
- CCU_GATE(CLK_BUS_DRAM, "bus-dram", "ahb1", 0x60, 14)
- CCU_GATE(CLK_BUS_EMAC, "bus-emac", "ahb2", 0x60, 17)
- CCU_GATE(CLK_BUS_TS, "bus-ts", "ahb1", 0x60, 18)
- CCU_GATE(CLK_BUS_HSTIMER, "bus-hstimer", "ahb1", 0x60, 19)
- CCU_GATE(CLK_BUS_SPI0, "bus-spi0", "ahb1", 0x60, 20)
- CCU_GATE(CLK_BUS_SPI1, "bus-spi1", "ahb1", 0x60, 21)
- CCU_GATE(CLK_BUS_OTG, "bus-otg", "ahb1", 0x60, 23)
- CCU_GATE(CLK_BUS_EHCI0, "bus-ehci0", "ahb1", 0x60, 24)
- CCU_GATE(CLK_BUS_EHCI1, "bus-ehci1", "ahb2", 0x60, 25)
- CCU_GATE(CLK_BUS_EHCI2, "bus-ehci2", "ahb2", 0x60, 26)
- CCU_GATE(CLK_BUS_EHCI3, "bus-ehci3", "ahb2", 0x60, 27)
- CCU_GATE(CLK_BUS_OHCI0, "bus-ohci0", "ahb1", 0x60, 28)
- CCU_GATE(CLK_BUS_OHCI1, "bus-ohci1", "ahb2", 0x60, 29)
- CCU_GATE(CLK_BUS_OHCI2, "bus-ohci2", "ahb2", 0x60, 30)
- CCU_GATE(CLK_BUS_OHCI3, "bus-ohci3", "ahb2", 0x60, 31)
-
- CCU_GATE(CLK_BUS_VE, "bus-ve", "ahb1", 0x64, 0)
- CCU_GATE(CLK_BUS_TCON0, "bus-tcon0", "ahb1", 0x64, 3)
- CCU_GATE(CLK_BUS_TCON1, "bus-tcon1", "ahb1", 0x64, 4)
- CCU_GATE(CLK_BUS_DEINTERLACE, "bus-deinterlace", "ahb1", 0x64, 5)
- CCU_GATE(CLK_BUS_CSI, "bus-csi", "ahb1", 0x64, 8)
- CCU_GATE(CLK_BUS_TVE, "bus-tve", "ahb1", 0x64, 9)
- CCU_GATE(CLK_BUS_HDMI, "bus-hdmi", "ahb1", 0x64, 11)
- CCU_GATE(CLK_BUS_DE, "bus-de", "ahb1", 0x64, 12)
- CCU_GATE(CLK_BUS_GPU, "bus-gpu", "ahb1", 0x64, 20)
- CCU_GATE(CLK_BUS_MSGBOX, "bus-msgbox", "ahb1", 0x64, 21)
- CCU_GATE(CLK_BUS_SPINLOCK, "bus-spinlock", "ahb1", 0x64, 22)
-
- CCU_GATE(CLK_BUS_CODEC, "bus-codec", "apb1", 0x68, 0)
- CCU_GATE(CLK_BUS_SPDIF, "bus-spdif", "apb1", 0x68, 1)
- CCU_GATE(CLK_BUS_PIO, "bus-pio", "apb1", 0x68, 5)
- CCU_GATE(CLK_BUS_THS, "bus-ths", "apb1", 0x68, 8)
- CCU_GATE(CLK_BUS_I2S0, "bus-i2s0", "apb1", 0x68, 12)
- CCU_GATE(CLK_BUS_I2S1, "bus-i2s1", "apb1", 0x68, 13)
- CCU_GATE(CLK_BUS_I2S2, "bus-i2s2", "apb1", 0x68, 14)
-
- CCU_GATE(CLK_BUS_I2C0, "bus-i2c0", "apb2", 0x6c, 0)
- CCU_GATE(CLK_BUS_I2C1, "bus-i2c1", "apb2", 0x6c, 1)
- CCU_GATE(CLK_BUS_I2C2, "bus-i2c2", "apb2", 0x6c, 2)
- CCU_GATE(CLK_BUS_UART0, "bus-uart0", "apb2", 0x6c, 16)
- CCU_GATE(CLK_BUS_UART1, "bus-uart1", "apb2", 0x6c, 17)
- CCU_GATE(CLK_BUS_UART2, "bus-uart2", "apb2", 0x6c, 18)
- CCU_GATE(CLK_BUS_UART3, "bus-uart3", "apb2", 0x6c, 19)
- CCU_GATE(CLK_BUS_SCR, "bus-scr", "apb2", 0x6c, 20)
-
- CCU_GATE(CLK_BUS_EPHY, "bus-ephy", "ahb1", 0x70, 0)
- CCU_GATE(CLK_BUS_DBG, "bus-dbg", "ahb1", 0x70, 7)
-
- CCU_GATE(CLK_USBPHY0, "usb-phy0", "osc24M", 0xcc, 8)
- CCU_GATE(CLK_USBPHY1, "usb-phy1", "osc24M", 0xcc, 9)
- CCU_GATE(CLK_USBPHY2, "usb-phy2", "osc24M", 0xcc, 10)
- CCU_GATE(CLK_USBPHY3, "usb-phy3", "osc24M", 0xcc, 11)
- CCU_GATE(CLK_USBOHCI0, "usb-ohci0", "osc24M", 0xcc, 16)
- CCU_GATE(CLK_USBOHCI1, "usb-ohci1", "osc24M", 0xcc, 17)
- CCU_GATE(CLK_USBOHCI2, "usb-ohci2", "osc24M", 0xcc, 18)
- CCU_GATE(CLK_USBOHCI3, "usb-ohci3", "osc24M", 0xcc, 19)
-
- CCU_GATE(CLK_THS, "ths", "thsdiv", 0x74, 31)
- CCU_GATE(CLK_I2S0, "i2s0", "i2s0mux", 0xB0, 31)
- CCU_GATE(CLK_I2S1, "i2s1", "i2s1mux", 0xB4, 31)
- CCU_GATE(CLK_I2S2, "i2s2", "i2s2mux", 0xB8, 31)
-
- CCU_GATE(CLK_DRAM_VE, "dram-ve", "dram", 0x100, 0)
- CCU_GATE(CLK_DRAM_CSI, "dram-csi", "dram", 0x100, 1)
- CCU_GATE(CLK_DRAM_DEINTERLACE, "dram-deinterlace", "dram", 0x100, 2)
- CCU_GATE(CLK_DRAM_TS, "dram-ts", "dram", 0x100, 3)
-
- CCU_GATE(CLK_AC_DIG, "ac-dig", "pll_audio", 0x140, 31)
-
- CCU_GATE(CLK_AVS, "avs", "osc24M", 0x144, 31)
-
- CCU_GATE(CLK_CSI_MISC, "csi-misc", "osc24M", 0x130, 31)
-
- CCU_GATE(CLK_HDMI_DDC, "hdmi-ddc", "osc24M", 0x154, 31)
-};
-
-static const char *pll_cpux_parents[] = {"osc24M"};
-NKMP_CLK(pll_cpux_clk,
- CLK_PLL_CPUX, /* id */
- "pll_cpux", pll_cpux_parents, /* name, parents */
- 0x00, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK | AW_CLK_SCALE_CHANGE); /* flags */
-
-static const char *pll_audio_parents[] = {"osc24M"};
-NKMP_CLK(pll_audio_clk,
- CLK_PLL_AUDIO, /* id */
- "pll_audio", pll_audio_parents, /* name, parents */
- 0x08, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */
- 0, 5, 0, 0, /* m factor */
- 16, 4, 0, 0, /* p factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_audio_mult_parents[] = {"pll_audio"};
-FIXED_CLK(pll_audio_2x_clk,
- CLK_PLL_AUDIO_2X, /* id */
- "pll_audio-2x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-FIXED_CLK(pll_audio_4x_clk,
- CLK_PLL_AUDIO_4X, /* id */
- "pll_audio-4x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 4, /* mult */
- 1, /* div */
- 0); /* flags */
-FIXED_CLK(pll_audio_8x_clk,
- CLK_PLL_AUDIO_8X, /* id */
- "pll_audio-8x", /* name */
- pll_audio_mult_parents, /* parent */
- 0, /* freq */
- 8, /* mult */
- 1, /* div */
- 0); /* flags */
-
-static const char *pll_video_parents[] = {"osc24M"};
-FRAC_CLK(pll_video_clk,
- CLK_PLL_VIDEO, /* id */
- "pll_video", pll_video_parents, /* name, parents */
- 0x10, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_ve_parents[] = {"osc24M"};
-FRAC_CLK(pll_ve_clk,
- CLK_PLL_VE, /* id */
- "pll_ve", pll_ve_parents, /* name, parents */
- 0x18, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_ddr_parents[] = {"osc24M"};
-NKMP_CLK_WITH_UPDATE(pll_ddr_clk,
- CLK_PLL_DDR, /* id */
- "pll_ddr", pll_ddr_parents, /* name, parents */
- 0x20, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 2, 0, 0, /* m factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- 20, /* update */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_periph0_parents[] = {"osc24M"};
-static const char *pll_periph0_2x_parents[] = {"pll_periph0"};
-NKMP_CLK(pll_periph0_clk,
- CLK_PLL_PERIPH0, /* id */
- "pll_periph0", pll_periph0_parents, /* name, parents */
- 0x28, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 0, 2, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-FIXED_CLK(pll_periph0_2x_clk,
- CLK_PLL_PERIPH0_2X, /* id */
- "pll_periph0-2x", /* name */
- pll_periph0_2x_parents, /* parent */
- 0, /* freq */
- 2, /* mult */
- 1, /* div */
- 0); /* flags */
-
-static const char *pll_gpu_parents[] = {"osc24M"};
-FRAC_CLK(pll_gpu_clk,
- CLK_PLL_GPU, /* id */
- "pll_gpu", pll_gpu_parents, /* name, parents */
- 0x38, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *pll_periph1_parents[] = {"osc24M"};
-NKMP_CLK(pll_periph1_clk,
- CLK_PLL_PERIPH1, /* id */
- "pll_periph1", pll_periph1_parents, /* name, parents */
- 0x44, /* offset */
- 8, 5, 0, 0, /* n factor */
- 4, 2, 0, 0, /* k factor */
- 0, 0, 2, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* p factor (fake) */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_de_parents[] = {"osc24M"};
-FRAC_CLK(pll_de_clk,
- CLK_PLL_DE, /* id */
- "pll_de", pll_de_parents, /* name, parents */
- 0x48, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 31, 28, 1000, /* gate, lock, lock retries */
- AW_CLK_HAS_LOCK, /* flags */
- 270000000, 297000000, /* freq0, freq1 */
- 24, 25, /* mode sel, freq sel */
- 192000000, 600000000); /* min freq, max freq */
-
-static const char *cpux_parents[] = {"osc32k", "osc24M", "pll_cpux", "pll_cpux"};
-MUX_CLK(cpux_clk,
- CLK_CPUX, /* id */
- "cpux", cpux_parents, /* name, parents */
- 0x50, 16, 2); /* offset, shift, width */
-
-static const char *axi_parents[] = {"cpux"};
-DIV_CLK(axi_clk,
- CLK_AXI, /* id */
- "axi", axi_parents, /* name, parents */
- 0x50, /* offset */
- 0, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *ahb1_parents[] = {"osc32k", "osc24M", "axi", "pll_periph0"};
-PREDIV_CLK(ahb1_clk, CLK_AHB1, /* id */
- "ahb1", ahb1_parents, /* name, parents */
- 0x54, /* offset */
- 12, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 6, 2, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- 12, 2, 3); /* prediv condition */
-
-static const char *apb1_parents[] = {"ahb1"};
-static struct clk_div_table apb1_div_table[] = {
- { .value = 0, .divider = 2, },
- { .value = 1, .divider = 2, },
- { .value = 2, .divider = 4, },
- { .value = 3, .divider = 8, },
- { },
-};
-DIV_CLK(apb1_clk,
- CLK_APB1, /* id */
- "apb1", apb1_parents, /* name, parents */
- 0x54, /* offset */
- 8, 2, /* shift, width */
- CLK_DIV_WITH_TABLE, /* flags */
- apb1_div_table); /* div table */
-
-static const char *apb2_parents[] = {"osc32k", "osc24M", "pll_periph0", "pll_periph0"};
-NM_CLK(apb2_clk,
- CLK_APB2, /* id */
- "apb2", apb2_parents, /* name, parents */
- 0x58, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 5, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX);
-
-static const char *ahb2_parents[] = {"ahb1", "pll_periph0"};
-PREDIV_CLK(ahb2_clk, CLK_AHB2, /* id */
- "ahb2", ahb2_parents, /* name, parents */
- 0x5c, /* offset */
- 0, 2, /* mux */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* div */
- 0, 0, 2, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */
- 0, 2, 1); /* prediv condition */
-
-static const char *ths_parents[] = {"osc24M"};
-static struct clk_div_table ths_div_table[] = {
- { .value = 0, .divider = 1, },
- { .value = 1, .divider = 2, },
- { .value = 2, .divider = 4, },
- { .value = 3, .divider = 6, },
- { },
-};
-DIV_CLK(thsdiv_clk,
- 0, /* id */
- "thsdiv", ths_parents, /* name, parents */
- 0x74, /* offset */
- 0, 2, /* shift, width */
- CLK_DIV_WITH_TABLE, /* flags */
- ths_div_table); /* div table */
-
-static const char *mod_parents[] = {"osc24M", "pll_periph0", "pll_periph1"};
-NM_CLK(nand_clk,
- CLK_NAND, "nand", mod_parents, /* id, name, parents */
- 0x80, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(mmc0_clk,
- CLK_MMC0, "mmc0", mod_parents, /* id, name, parents */
- 0x88, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc1_clk,
- CLK_MMC1, "mmc1", mod_parents, /* id, name, parents */
- 0x8c, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc2_clk,
- CLK_MMC2, "mmc2", mod_parents, /* id, name, parents */
- 0x90, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-static const char *ts_parents[] = {"osc24M", "pll_periph0"};
-NM_CLK(ts_clk,
- CLK_TS, "ts", ts_parents, /* id, name, parents */
- 0x98, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(ce_clk,
- CLK_CE, "ce", mod_parents, /* id, name, parents */
- 0x9C, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); /* flags */
-
-NM_CLK(spi0_clk,
- CLK_SPI0, "spi0", mod_parents, /* id, name, parents */
- 0xA0, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(spi1_clk,
- CLK_SPI1, "spi1", mod_parents, /* id, name, parents */
- 0xA4, /* offset */
- 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-static const char *i2s_parents[] = {"pll_audio-8x", "pll_audio-4x", "pll_audio-2x", "pll_audio"};
-MUX_CLK(i2s0mux_clk,
- 0, "i2s0mux", i2s_parents, /* id, name, parents */
- 0xb0, 16, 2); /* offset, mux shift, mux width */
-MUX_CLK(i2s1mux_clk,
- 0, "i2s1mux", i2s_parents, /* id, name, parents */
- 0xb4, 16, 2); /* offset, mux shift, mux width */
-MUX_CLK(i2s2mux_clk,
- 0, "i2s2mux", i2s_parents, /* id, name, parents */
- 0xb8, 16, 2); /* offset, mux shift, mux width */
-
-static const char *spdif_parents[] = {"pll_audio"};
-NM_CLK(spdif_clk,
- CLK_SPDIF, "spdif", spdif_parents, /* id, name, parents */
- 0xC0, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake); */
- 0, 4, 0, 0, /* m factor */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *dram_parents[] = {"pll_ddr", "pll_periph0-2x"};
-NM_CLK(dram_clk,
- CLK_DRAM, "dram", dram_parents, /* id, name, parents */
- 0xF4, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 20, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX); /* flags */
-
-static const char *de_parents[] = {"pll_periph0-2x", "pll_de"};
-NM_CLK(de_clk,
- CLK_DE, "de", de_parents, /* id, name, parents */
- 0x104, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *tcon0_parents[] = {"pll_video"};
-NM_CLK(tcon0_clk,
- CLK_TCON0, "tcon0", tcon0_parents, /* id, name, parents */
- 0x118, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *tve_parents[] = {"pll_de", "pll_periph1"};
-NM_CLK(tve_clk,
- CLK_TVE, "tve", tve_parents, /* id, name, parents */
- 0x120, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *deinterlace_parents[] = {"pll_periph0", "pll_periph1"};
-NM_CLK(deinterlace_clk,
- CLK_DEINTERLACE, "deinterlace", deinterlace_parents, /* id, name, parents */
- 0x124, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *csi_sclk_parents[] = {"pll_periph0", "pll_periph1"};
-NM_CLK(csi_sclk_clk,
- CLK_CSI_SCLK, "csi-sclk", csi_sclk_parents, /* id, name, parents */
- 0x134, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 16, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *csi_mclk_parents[] = {"osc24M", "pll_video", "pll_periph1"};
-NM_CLK(csi_mclk_clk,
- CLK_CSI_MCLK, "csi-mclk", csi_mclk_parents, /* id, name, parents */
- 0x134, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 8, 2, /* mux */
- 15, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *ve_parents[] = {"pll_ve"};
-NM_CLK(ve_clk,
- CLK_VE, "ve", ve_parents, /* id, name, parents */
- 0x13C, /* offset */
- 16, 3, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-static const char *hdmi_parents[] = {"pll_video"};
-NM_CLK(hdmi_clk,
- CLK_HDMI, "hdmi", hdmi_parents, /* id, name, parents */
- 0x150, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *mbus_parents[] = {"osc24M", "pll_periph0-2x", "pll_ddr"};
-NM_CLK(mbus_clk,
- CLK_MBUS, "mbus", mbus_parents, /* id, name, parents */
- 0x15C, /* offset */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */
- 0, 3, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); /* flags */
-
-static const char *gpu_parents[] = {"pll_gpu"};
-NM_CLK(gpu_clk,
- CLK_GPU, "gpu", gpu_parents, /* id, name, parents */
- 0x1A0, /* offset */
- 0, 2, 0, 0, /* n factor */
- 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */
- 0, 0, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE); /* flags */
-
-static struct aw_ccung_clk h3_ccu_clks[] = {
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_cpux_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_audio_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph0_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_periph1_clk},
- { .type = AW_CLK_NKMP, .clk.nkmp = &pll_ddr_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_video_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_ve_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_gpu_clk},
- { .type = AW_CLK_FRAC, .clk.frac = &pll_de_clk},
- { .type = AW_CLK_NM, .clk.nm = &apb2_clk},
- { .type = AW_CLK_NM, .clk.nm = &nand_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc2_clk},
- { .type = AW_CLK_NM, .clk.nm = &ts_clk},
- { .type = AW_CLK_NM, .clk.nm = &ce_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi0_clk},
- { .type = AW_CLK_NM, .clk.nm = &spi1_clk},
- { .type = AW_CLK_NM, .clk.nm = &spdif_clk},
- { .type = AW_CLK_NM, .clk.nm = &dram_clk},
- { .type = AW_CLK_NM, .clk.nm = &de_clk},
- { .type = AW_CLK_NM, .clk.nm = &tcon0_clk},
- { .type = AW_CLK_NM, .clk.nm = &tve_clk},
- { .type = AW_CLK_NM, .clk.nm = &deinterlace_clk},
- { .type = AW_CLK_NM, .clk.nm = &csi_sclk_clk},
- { .type = AW_CLK_NM, .clk.nm = &csi_mclk_clk},
- { .type = AW_CLK_NM, .clk.nm = &ve_clk},
- { .type = AW_CLK_NM, .clk.nm = &hdmi_clk},
- { .type = AW_CLK_NM, .clk.nm = &mbus_clk},
- { .type = AW_CLK_NM, .clk.nm = &gpu_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb1_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ahb2_clk},
- { .type = AW_CLK_MUX, .clk.mux = &cpux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &i2s0mux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &i2s1mux_clk},
- { .type = AW_CLK_MUX, .clk.mux = &i2s2mux_clk},
- { .type = AW_CLK_DIV, .clk.div = &axi_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb1_clk},
- { .type = AW_CLK_DIV, .clk.div = &thsdiv_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_periph0_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_4x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_audio_8x_clk},
-};
-
-static struct aw_clk_init h3_init_clks[] = {
- {"ahb1", "pll_periph0", 0, false},
- {"ahb2", "pll_periph0", 0, false},
- {"dram", "pll_ddr", 0, false},
-};
-
-static struct ofw_compat_data compat_data[] = {
-#if defined(SOC_ALLWINNER_H3)
- { "allwinner,sun8i-h3-ccu", 1 },
-#endif
-#if defined(SOC_ALLWINNER_H5)
- { "allwinner,sun50i-h5-ccu", 1 },
-#endif
- { NULL, 0},
-};
-
-static int
-ccu_h3_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner H3/H5 Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_h3_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = h3_ccu_resets;
- sc->nresets = nitems(h3_ccu_resets);
- sc->gates = h3_ccu_gates;
- sc->ngates = nitems(h3_ccu_gates);
- sc->clks = h3_ccu_clks;
- sc->nclks = nitems(h3_ccu_clks);
- sc->clk_init = h3_init_clks;
- sc->n_clk_init = nitems(h3_init_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_h3ng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_h3_probe),
- DEVMETHOD(device_attach, ccu_h3_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_h3ng, ccu_h3ng_driver, ccu_h3ng_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_h3ng, simplebus, ccu_h3ng_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_h6.c b/sys/arm/allwinner/clkng/ccu_h6.c
deleted file mode 100644
index 8ca8ba75f584..000000000000
--- a/sys/arm/allwinner/clkng/ccu_h6.c
+++ /dev/null
@@ -1,499 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun50i-h6-ccu.h>
-#include <dt-bindings/reset/sun50i-h6-ccu.h>
-
-/* Non-exported clocks */
-#define CLK_OSC_12M 0
-#define CLK_PLL_CPUX 1
-#define CLK_PLL_DDR0 2
-#define CLK_PLL_PERIPH0_2X 4
-#define CLK_PLL_PERIPH0_4X 5
-#define CLK_PLL_PERIPH1 6
-#define CLK_PLL_PERIPH1_2X 7
-#define CLK_PLL_PERIPH1_4X 8
-#define CLK_PLL_GPU 9
-#define CLK_PLL_VIDEO0 10
-#define CLK_PLL_VIDEO0_4X 11
-#define CLK_PLL_VIDEO1 12
-#define CLK_PLL_VIDEO1_4X 13
-#define CLK_PLL_VE 14
-#define CLK_PLL_DE 14
-#define CLK_PLL_HSIC 16
-
-#define CLK_PSI_AHB1_AHB2 24
-#define CLK_AHB3 25
-#define CLK_APB2 27
-
-static struct aw_ccung_reset h6_ccu_resets[] = {
- /* PSI_BGR_REG */
- CCU_RESET(RST_BUS_PSI, 0x79c, 16)
-
- /* SMHC_BGR_REG */
- CCU_RESET(RST_BUS_MMC0, 0x84c, 16)
- CCU_RESET(RST_BUS_MMC1, 0x84c, 17)
- CCU_RESET(RST_BUS_MMC2, 0x84c, 18)
-
- /* UART_BGR_REG */
- CCU_RESET(RST_BUS_UART0, 0x90c, 16)
- CCU_RESET(RST_BUS_UART1, 0x90c, 17)
- CCU_RESET(RST_BUS_UART2, 0x90c, 18)
- CCU_RESET(RST_BUS_UART3, 0x90c, 19)
-
- /* TWI_BGR_REG */
- CCU_RESET(RST_BUS_I2C0, 0x91c, 16)
- CCU_RESET(RST_BUS_I2C1, 0x91c, 17)
- CCU_RESET(RST_BUS_I2C2, 0x91c, 18)
- CCU_RESET(RST_BUS_I2C3, 0x91c, 19)
-
- /* EMAC_BGR_REG */
- CCU_RESET(RST_BUS_EMAC, 0x97c, 16)
-
- /* USB0_CLK_REG */
- CCU_RESET(RST_USB_PHY0, 0xa70, 30)
-
- /* USB1_CLK_REG */
- CCU_RESET(RST_USB_PHY1, 0xa74, 30)
-
- /* USB3_CLK_REG */
- CCU_RESET(RST_USB_HSIC, 0xa7c, 28)
- CCU_RESET(RST_USB_PHY3, 0xa7c, 30)
-
- /* USB_BGR_REG */
- CCU_RESET(RST_BUS_OHCI0, 0xa8c, 16)
- CCU_RESET(RST_BUS_OHCI3, 0xa8c, 19)
- CCU_RESET(RST_BUS_EHCI0, 0xa8c, 20)
- CCU_RESET(RST_BUS_XHCI, 0xa8c, 21)
- CCU_RESET(RST_BUS_EHCI3, 0xa8c, 23)
- CCU_RESET(RST_BUS_OTG, 0xa8c, 24)
-};
-
-static struct aw_ccung_gate h6_ccu_gates[] = {
- /* PSI_BGR_REG */
- CCU_GATE(CLK_BUS_PSI, "bus-psi", "psi_ahb1_ahb2", 0x79c, 0)
-
- /* SMHC_BGR_REG */
- CCU_GATE(CLK_BUS_MMC0, "bus-mmc0", "ahb3", 0x84c, 0)
- CCU_GATE(CLK_BUS_MMC1, "bus-mmc1", "ahb3", 0x84c, 1)
- CCU_GATE(CLK_BUS_MMC2, "bus-mmc2", "ahb3", 0x84c, 2)
-
- /* UART_BGR_REG Enabling the gate enable weir behavior ... */
- /* CCU_GATE(CLK_BUS_UART0, "bus-uart0", "apb2", 0x90c, 0) */
- /* CCU_GATE(CLK_BUS_UART1, "bus-uart1", "apb2", 0x90c, 1) */
- /* CCU_GATE(CLK_BUS_UART2, "bus-uart2", "apb2", 0x90c, 2) */
- /* CCU_GATE(CLK_BUS_UART3, "bus-uart3", "apb2", 0x90c, 3) */
-
- /* TWI_BGR_REG */
- CCU_GATE(CLK_BUS_I2C0, "bus-i2c0", "apb2", 0x91c, 0)
- CCU_GATE(CLK_BUS_I2C1, "bus-i2c1", "apb2", 0x91c, 1)
- CCU_GATE(CLK_BUS_I2C2, "bus-i2c2", "apb2", 0x91c, 2)
- CCU_GATE(CLK_BUS_I2C3, "bus-i2c3", "apb2", 0x91c, 3)
-
- /* EMAC_BGR_REG */
- CCU_GATE(CLK_BUS_EMAC, "bus-emac", "ahb3", 0x97c, 0)
-
- /* USB0_CLK_REG */
- CCU_GATE(CLK_USB_PHY0, "usb-phy0", "ahb3", 0xa70, 29)
- CCU_GATE(CLK_USB_OHCI0, "usb-ohci0", "ahb3", 0xa70, 31)
-
- /* USB1_CLK_REG */
- CCU_GATE(CLK_USB_PHY1, "usb-phy1", "ahb3", 0xa74, 29)
-
- /* USB3_CLK_REG */
- CCU_GATE(CLK_USB_HSIC, "usb-hsic", "ahb3", 0xa7c, 26)
- CCU_GATE(CLK_USB_HSIC_12M, "usb-hsic-12M", "ahb3", 0xa7c, 27)
- CCU_GATE(CLK_USB_PHY3, "usb-phy3", "ahb3", 0xa7c, 29)
- CCU_GATE(CLK_USB_OHCI3, "usb-ohci3", "ahb3", 0xa7c, 31)
-
- /* USB_BGR_REG */
- CCU_GATE(CLK_BUS_OHCI0, "bus-ohci0", "ahb3", 0xa8c, 0)
- CCU_GATE(CLK_BUS_OHCI3, "bus-ohci3", "ahb3", 0xa8c, 3)
- CCU_GATE(CLK_BUS_EHCI0, "bus-ehci0", "ahb3", 0xa8c, 4)
- CCU_GATE(CLK_BUS_XHCI, "bus-xhci", "ahb3", 0xa8c, 5)
- CCU_GATE(CLK_BUS_EHCI3, "bus-ehci3", "ahb3", 0xa8c, 7)
- CCU_GATE(CLK_BUS_OTG, "bus-otg", "ahb3", 0xa8c, 8)
-};
-
-static const char *osc12m_parents[] = {"osc24M"};
-FIXED_CLK(osc12m_clk,
- CLK_OSC_12M, /* id */
- "osc12M", /* name */
- osc12m_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-
-static const char *pll_cpux_parents[] = {"osc24M"};
-NP_CLK(pll_cpux_clk,
- CLK_PLL_CPUX, /* id */
- "pll_cpux", pll_cpux_parents, /* name, parents */
- 0x00, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 2, 0, 0, /* p factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_ddr0_parents[] = {"osc24M"};
-NMM_CLK(pll_ddr0_clk,
- CLK_PLL_DDR0, /* id */
- "pll_ddr0", pll_ddr0_parents, /* name, parents */
- 0x10, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_peri0_4x_parents[] = {"osc24M"};
-NMM_CLK(pll_peri0_4x_clk,
- CLK_PLL_PERIPH0_4X, /* id */
- "pll_periph0_4x", pll_peri0_4x_parents, /* name, parents */
- 0x20, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-static const char *pll_peri0_2x_parents[] = {"pll_periph0_4x"};
-FIXED_CLK(pll_peri0_2x_clk,
- CLK_PLL_PERIPH0_2X, /* id */
- "pll_periph0_2x", /* name */
- pll_peri0_2x_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-static const char *pll_peri0_parents[] = {"pll_periph0_4x"};
-FIXED_CLK(pll_peri0_clk,
- CLK_PLL_PERIPH0, /* id */
- "pll_periph0", /* name */
- pll_peri0_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 4, /* div */
- 0); /* flags */
-
-static const char *pll_peri1_4x_parents[] = {"osc24M"};
-NMM_CLK(pll_peri1_4x_clk,
- CLK_PLL_PERIPH1_4X, /* id */
- "pll_periph1_4x", pll_peri1_4x_parents, /* name, parents */
- 0x28, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-static const char *pll_peri1_2x_parents[] = {"pll_periph1_4x"};
-FIXED_CLK(pll_peri1_2x_clk,
- CLK_PLL_PERIPH1_2X, /* id */
- "pll_periph1_2x", /* name */
- pll_peri1_2x_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 2, /* div */
- 0); /* flags */
-static const char *pll_peri1_parents[] = {"pll_periph1_4x"};
-FIXED_CLK(pll_peri1_clk,
- CLK_PLL_PERIPH1, /* id */
- "pll_periph1", /* name */
- pll_peri1_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 4, /* div */
- 0); /* flags */
-
-static const char *pll_gpu_parents[] = {"osc24M"};
-NMM_CLK(pll_gpu_clk,
- CLK_PLL_GPU, /* id */
- "pll_gpu", pll_gpu_parents, /* name, parents */
- 0x30, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_video0_4x_parents[] = {"osc24M"};
-NMM_CLK(pll_video0_4x_clk,
- CLK_PLL_VIDEO0_4X, /* id */
- "pll_video0_4x", pll_video0_4x_parents, /* name, parents */
- 0x40, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-static const char *pll_video0_parents[] = {"pll_video0_4x"};
-FIXED_CLK(pll_video0_clk,
- CLK_PLL_VIDEO0, /* id */
- "pll_video0", /* name */
- pll_video0_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 4, /* div */
- 0); /* flags */
-
-static const char *pll_video1_4x_parents[] = {"osc24M"};
-NMM_CLK(pll_video1_4x_clk,
- CLK_PLL_VIDEO1_4X, /* id */
- "pll_video1_4x", pll_video1_4x_parents, /* name, parents */
- 0x48, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-static const char *pll_video1_parents[] = {"pll_video1_4x"};
-FIXED_CLK(pll_video1_clk,
- CLK_PLL_VIDEO1, /* id */
- "pll_video1", /* name */
- pll_video1_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 4, /* div */
- 0); /* flags */
-
-static const char *pll_ve_parents[] = {"osc24M"};
-NMM_CLK(pll_ve_clk,
- CLK_PLL_VE, /* id */
- "pll_ve", pll_ve_parents, /* name, parents */
- 0x58, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_de_parents[] = {"osc24M"};
-NMM_CLK(pll_de_clk,
- CLK_PLL_DE, /* id */
- "pll_de", pll_de_parents, /* name, parents */
- 0x60, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-static const char *pll_hsic_parents[] = {"osc24M"};
-NMM_CLK(pll_hsic_clk,
- CLK_PLL_HSIC, /* id */
- "pll_hsic", pll_hsic_parents, /* name, parents */
- 0x70, /* offset */
- 8, 7, 0, 0, /* n factor */
- 0, 1, 0, 0, /* m0 factor */
- 1, 1, 0, 0, /* m1 factor */
- 31, /* gate */
- 28, 1000, /* lock */
- AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK); /* flags */
-
-/* PLL_AUDIO missing */
-
-/* CPUX_AXI missing */
-
-static const char *psi_ahb1_ahb2_parents[] = {"osc24M", "osc32k", "iosc", "pll_periph0"};
-NM_CLK(psi_ahb1_ahb2_clk,
- CLK_PSI_AHB1_AHB2, "psi_ahb1_ahb2", psi_ahb1_ahb2_parents, /* id, name, parents */
- 0x510, /* offset */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 2, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_REPARENT); /* flags */
-
-static const char *ahb3_parents[] = {"osc24M", "osc32k", "psi_ahb1_ahb2", "pll_periph0"};
-NM_CLK(ahb3_clk,
- CLK_AHB3, "ahb3", ahb3_parents, /* id, name, parents */
- 0x51C, /* offset */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 2, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_REPARENT); /* flags */
-
-static const char *apb1_parents[] = {"osc24M", "osc32k", "psi_ahb1_ahb2", "pll_periph0"};
-NM_CLK(apb1_clk,
- CLK_APB1, "apb1", apb1_parents, /* id, name, parents */
- 0x520, /* offset */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 2, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_REPARENT); /* flags */
-
-static const char *apb2_parents[] = {"osc24M", "osc32k", "psi_ahb1_ahb2", "pll_periph0"};
-NM_CLK(apb2_clk,
- CLK_APB2, "apb2", apb2_parents, /* id, name, parents */
- 0x524, /* offset */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 2, 0, 0, /* m factor */
- 24, 2, /* mux */
- 0, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_REPARENT); /* flags */
-
-/* Missing MBUS clock */
-
-static const char *mod_parents[] = {"osc24M", "pll_periph0_2x", "pll_periph1_2x"};
-NM_CLK(mmc0_clk,
- CLK_MMC0, "mmc0", mod_parents, /* id, name, parents */
- 0x830, /* offset */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc1_clk,
- CLK_MMC1, "mmc1", mod_parents, /* id, name, parents */
- 0x834, /* offset */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-NM_CLK(mmc2_clk,
- CLK_MMC2, "mmc2", mod_parents, /* id, name, parents */
- 0x838, /* offset */
- 8, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */
- 0, 4, 0, 0, /* m factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_GATE | AW_CLK_HAS_MUX |
- AW_CLK_REPARENT); /* flags */
-
-static struct aw_ccung_clk h6_ccu_clks[] = {
- { .type = AW_CLK_NP, .clk.np = &pll_cpux_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_ddr0_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_peri0_4x_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_peri1_4x_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_gpu_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_video0_4x_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_video1_4x_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_ve_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_de_clk},
- { .type = AW_CLK_NMM, .clk.nmm = &pll_hsic_clk},
-
- { .type = AW_CLK_NM, .clk.nm = &psi_ahb1_ahb2_clk},
- { .type = AW_CLK_NM, .clk.nm = &ahb3_clk},
- { .type = AW_CLK_NM, .clk.nm = &apb1_clk},
- { .type = AW_CLK_NM, .clk.nm = &apb2_clk},
-
- { .type = AW_CLK_NM, .clk.nm = &mmc0_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc1_clk},
- { .type = AW_CLK_NM, .clk.nm = &mmc2_clk},
-
- { .type = AW_CLK_FIXED, .clk.fixed = &osc12m_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_peri0_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_peri0_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_peri1_2x_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_peri1_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_video0_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &pll_video1_clk},
-};
-
-static int
-ccu_h6_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun50i-h6-ccu"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner H6 Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_h6_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = h6_ccu_resets;
- sc->nresets = nitems(h6_ccu_resets);
- sc->gates = h6_ccu_gates;
- sc->ngates = nitems(h6_ccu_gates);
- sc->clks = h6_ccu_clks;
- sc->nclks = nitems(h6_ccu_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_h6ng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_h6_probe),
- DEVMETHOD(device_attach, ccu_h6_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_h6ng, ccu_h6ng_driver, ccu_h6ng_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_h6ng, simplebus, ccu_h6ng_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_h6_r.c b/sys/arm/allwinner/clkng/ccu_h6_r.c
deleted file mode 100644
index a7ef82f55092..000000000000
--- a/sys/arm/allwinner/clkng/ccu_h6_r.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2019 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun50i-h6-r-ccu.h>
-#include <dt-bindings/reset/sun50i-h6-r-ccu.h>
-
-/* Non-exported clocks */
-#define CLK_R_AHB 1
-#define CLK_R_APB2 3
-
-static struct aw_ccung_reset ccu_sun50i_h6_r_resets[] = {
- CCU_RESET(RST_R_APB1_TIMER, 0x11c, 16)
- CCU_RESET(RST_R_APB1_TWD, 0x12c, 16)
- CCU_RESET(RST_R_APB1_PWM, 0x13c, 16)
- CCU_RESET(RST_R_APB2_UART, 0x18c, 16)
- CCU_RESET(RST_R_APB2_I2C, 0x19c, 16)
- CCU_RESET(RST_R_APB1_IR, 0x1cc, 16)
- CCU_RESET(RST_R_APB1_W1, 0x1ec, 16)
-};
-
-static struct aw_ccung_gate ccu_sun50i_h6_r_gates[] = {
- CCU_GATE(CLK_R_APB1_TIMER, "r_apb1-timer", "r_apb1", 0x11c, 0)
- CCU_GATE(CLK_R_APB1_TWD, "r_apb1-twd", "r_apb1", 0x12c, 0)
- CCU_GATE(CLK_R_APB1_PWM, "r_apb1-pwm", "r_apb1", 0x13c, 0)
- CCU_GATE(CLK_R_APB2_UART, "r_apb1-uart", "r_apb2", 0x18c, 0)
- CCU_GATE(CLK_R_APB2_I2C, "r_apb1-i2c", "r_apb2", 0x19c, 0)
- CCU_GATE(CLK_R_APB1_IR, "r_apb1-ir", "r_apb1", 0x1cc, 0)
- CCU_GATE(CLK_R_APB1_W1, "r_apb1-w1", "r_apb1", 0x1ec, 0)
-};
-
-static const char *ar100_parents[] = {"osc24M", "osc32k", "pll_periph0", "iosc"};
-PREDIV_CLK(ar100_clk, CLK_AR100, /* id */
- "ar100", ar100_parents, /* name, parents */
- 0x00, /* offset */
- 16, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 8, 5, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- 16, 2, 2); /* prediv condition */
-
-static const char *r_ahb_parents[] = {"ar100"};
-FIXED_CLK(r_ahb_clk,
- CLK_R_AHB, /* id */
- "r_ahb", /* name */
- r_ahb_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 1, /* div */
- 0); /* flags */
-
-static const char *r_apb1_parents[] = {"r_ahb"};
-DIV_CLK(r_apb1_clk,
- CLK_R_APB1, /* id */
- "r_apb1", r_apb1_parents, /* name, parents */
- 0x0c, /* offset */
- 0, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *r_apb2_parents[] = {"osc24M", "osc32k", "pll_periph0", "iosc"};
-PREDIV_CLK(r_apb2_clk, CLK_R_APB2, /* id */
- "r_apb2", r_apb2_parents, /* name, parents */
- 0x10, /* offset */
- 16, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 8, 5, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- 16, 2, 2); /* prediv condition */
-
-static struct aw_ccung_clk clks[] = {
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ar100_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &r_ahb_clk},
- { .type = AW_CLK_DIV, .clk.div = &r_apb1_clk},
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &r_apb2_clk},
-};
-
-static struct ofw_compat_data compat_data[] = {
- { "allwinner,sun50i-h6-r-ccu", 1 },
- { NULL, 0},
-};
-
-static int
-ccu_sun50i_h6_r_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner SUN50I_H6_R Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_sun50i_h6_r_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = ccu_sun50i_h6_r_resets;
- sc->nresets = nitems(ccu_sun50i_h6_r_resets);
- sc->gates = ccu_sun50i_h6_r_gates;
- sc->ngates = nitems(ccu_sun50i_h6_r_gates);
- sc->clks = clks;
- sc->nclks = nitems(clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_sun50i_h6_r_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_sun50i_h6_r_probe),
- DEVMETHOD(device_attach, ccu_sun50i_h6_r_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_sun50i_h6_r, ccu_sun50i_h6_r_driver, ccu_sun50i_h6_r_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_sun50i_h6_r, simplebus, ccu_sun50i_h6_r_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/clkng/ccu_sun8i_r.c b/sys/arm/allwinner/clkng/ccu_sun8i_r.c
deleted file mode 100644
index c58375ab5184..000000000000
--- a/sys/arm/allwinner/clkng/ccu_sun8i_r.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-
-#include <dev/fdt/simplebus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#if defined(__aarch64__)
-#include "opt_soc.h"
-#endif
-
-#include <dev/extres/clk/clk_div.h>
-#include <dev/extres/clk/clk_fixed.h>
-#include <dev/extres/clk/clk_mux.h>
-
-#include <arm/allwinner/clkng/aw_ccung.h>
-
-#include <dt-bindings/clock/sun8i-r-ccu.h>
-#include <dt-bindings/reset/sun8i-r-ccu.h>
-
-/* Non-exported clocks */
-#define CLK_AHB0 1
-#define CLK_APB0 2
-
-static struct aw_ccung_reset ccu_sun8i_r_resets[] = {
- CCU_RESET(RST_APB0_IR, 0xb0, 1)
- CCU_RESET(RST_APB0_TIMER, 0xb0, 2)
- CCU_RESET(RST_APB0_RSB, 0xb0, 3)
- CCU_RESET(RST_APB0_UART, 0xb0, 4)
- CCU_RESET(RST_APB0_I2C, 0xb0, 6)
-};
-
-static struct aw_ccung_gate ccu_sun8i_r_gates[] = {
- CCU_GATE(CLK_APB0_PIO, "apb0-pio", "apb0", 0x28, 0)
- CCU_GATE(CLK_APB0_IR, "apb0-ir", "apb0", 0x28, 1)
- CCU_GATE(CLK_APB0_TIMER, "apb0-timer", "apb0", 0x28, 2)
- CCU_GATE(CLK_APB0_RSB, "apb0-rsb", "apb0", 0x28, 3)
- CCU_GATE(CLK_APB0_UART, "apb0-uart", "apb0", 0x28, 4)
- CCU_GATE(CLK_APB0_I2C, "apb0-i2c", "apb0", 0x28, 6)
- CCU_GATE(CLK_APB0_TWD, "apb0-twd", "apb0", 0x28, 7)
-};
-
-static const char *ar100_parents[] = {"osc32k", "osc24M", "pll_periph0", "iosc"};
-static const char *a83t_ar100_parents[] = {"osc16M-d512", "osc24M", "pll_periph", "osc16M"};
-PREDIV_CLK(ar100_clk, CLK_AR100, /* id */
- "ar100", ar100_parents, /* name, parents */
- 0x00, /* offset */
- 16, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 8, 5, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- 16, 2, 2); /* prediv condition */
-PREDIV_CLK(a83t_ar100_clk, CLK_AR100, /* id */
- "ar100", a83t_ar100_parents, /* name, parents */
- 0x00, /* offset */
- 16, 2, /* mux */
- 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */
- 8, 5, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */
- 16, 2, 2); /* prediv condition */
-
-static const char *ahb0_parents[] = {"ar100"};
-FIXED_CLK(ahb0_clk,
- CLK_AHB0, /* id */
- "ahb0", /* name */
- ahb0_parents, /* parent */
- 0, /* freq */
- 1, /* mult */
- 1, /* div */
- 0); /* flags */
-
-static const char *apb0_parents[] = {"ahb0"};
-DIV_CLK(apb0_clk,
- CLK_APB0, /* id */
- "apb0", apb0_parents, /* name, parents */
- 0x0c, /* offset */
- 0, 2, /* shift, width */
- 0, NULL); /* flags, div table */
-
-static const char *r_ccu_ir_parents[] = {"osc32k", "osc24M"};
-NM_CLK(r_ccu_ir_clk,
- CLK_IR, /* id */
- "ir", r_ccu_ir_parents, /* names, parents */
- 0x54, /* offset */
- 0, 4, 0, 0, /* N factor */
- 16, 2, 0, 0, /* M factor */
- 24, 2, /* mux */
- 31, /* gate */
- AW_CLK_HAS_MUX | AW_CLK_REPARENT | AW_CLK_HAS_GATE);/* flags */
-
-static const char *a83t_ir_parents[] = {"osc16M", "osc24M"};
-static struct aw_clk_nm_def a83t_ir_clk = {
- .clkdef = {
- .id = CLK_IR,
- .name = "ir",
- .parent_names = a83t_ir_parents,
- .parent_cnt = nitems(a83t_ir_parents),
- },
- .offset = 0x54,
- .n = {.shift = 0, .width = 4, .flags = AW_CLK_FACTOR_POWER_OF_TWO, },
- .m = {.shift = 16, .width = 2},
- .prediv = {
- .cond_shift = 24,
- .cond_width = 2,
- .cond_value = 0,
- .value = 16
- },
- .mux_shift = 24,
- .mux_width = 2,
- .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_PREDIV,
-};
-
-static struct aw_ccung_clk clks[] = {
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &ar100_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb0_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &ahb0_clk},
- { .type = AW_CLK_NM, .clk.nm = &r_ccu_ir_clk},
-};
-
-static struct aw_ccung_clk a83t_clks[] = {
- { .type = AW_CLK_PREDIV_MUX, .clk.prediv_mux = &a83t_ar100_clk},
- { .type = AW_CLK_DIV, .clk.div = &apb0_clk},
- { .type = AW_CLK_FIXED, .clk.fixed = &ahb0_clk},
- { .type = AW_CLK_NM, .clk.nm = &a83t_ir_clk},
-};
-
-static struct ofw_compat_data compat_data[] = {
-#if defined(SOC_ALLWINNER_H3) || defined(SOC_ALLWINNER_H5)
- { "allwinner,sun8i-h3-r-ccu", 1 },
-#endif
-#if defined(SOC_ALLWINNER_A64)
- { "allwinner,sun50i-a64-r-ccu", 1 },
-#endif
- { NULL, 0},
-};
-
-static int
-ccu_sun8i_r_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner SUN8I_R Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_sun8i_r_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = ccu_sun8i_r_resets;
- sc->nresets = nitems(ccu_sun8i_r_resets);
- sc->gates = ccu_sun8i_r_gates;
- sc->ngates = nitems(ccu_sun8i_r_gates);
- sc->clks = clks;
- sc->nclks = nitems(clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_sun8i_r_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_sun8i_r_probe),
- DEVMETHOD(device_attach, ccu_sun8i_r_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_sun8i_r, ccu_sun8i_r_driver, ccu_sun8i_r_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_sun8i_r, simplebus, ccu_sun8i_r_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
-
-static int
-ccu_a83t_r_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "allwinner,sun8i-a83t-r-ccu"))
- return (ENXIO);
-
- device_set_desc(dev, "Allwinner A83T_R Clock Control Unit NG");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-ccu_a83t_r_attach(device_t dev)
-{
- struct aw_ccung_softc *sc;
-
- sc = device_get_softc(dev);
-
- sc->resets = ccu_sun8i_r_resets;
- sc->nresets = nitems(ccu_sun8i_r_resets);
- sc->gates = ccu_sun8i_r_gates;
- sc->ngates = nitems(ccu_sun8i_r_gates);
- sc->clks = a83t_clks;
- sc->nclks = nitems(a83t_clks);
-
- return (aw_ccung_attach(dev));
-}
-
-static device_method_t ccu_a83t_r_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ccu_a83t_r_probe),
- DEVMETHOD(device_attach, ccu_a83t_r_attach),
-
- DEVMETHOD_END
-};
-
-DEFINE_CLASS_1(ccu_a83t_r, ccu_a83t_r_driver, ccu_a83t_r_methods,
- sizeof(struct aw_ccung_softc), aw_ccung_driver);
-
-EARLY_DRIVER_MODULE(ccu_a83t_r, simplebus, ccu_a83t_r_driver, 0, 0,
- BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/allwinner/files.allwinner b/sys/arm/allwinner/files.allwinner
index 40775ac3212b..ae5a7bb7403d 100644
--- a/sys/arm/allwinner/files.allwinner
+++ b/sys/arm/allwinner/files.allwinner
@@ -1,4 +1,3 @@
-# $FreeBSD$
arm/allwinner/a10_ahci.c optional ahci
arm/allwinner/a10_codec.c optional sound
@@ -6,7 +5,6 @@ arm/allwinner/a10_dmac.c optional a10_dmac
arm/allwinner/a31_dmac.c optional a31_dmac
arm/allwinner/a10_sramc.c optional SOC_ALLWINNER_A10
arm/allwinner/aw_gpio.c optional gpio
-arm/allwinner/aw_if_dwc.c optional dwc
arm/allwinner/aw_machdep.c standard
arm/allwinner/aw_mmc.c optional mmc | mmccam
arm/allwinner/aw_mp.c optional smp
@@ -23,7 +21,8 @@ arm/allwinner/axp81x.c optional axp81x
arm/allwinner/if_awg.c optional awg syscon
arm/allwinner/if_emac.c optional emac
arm/allwinner/sunxi_dma_if.m optional a10_dmac | a31_dmac
-dev/iicbus/twsi/a10_twsi.c optional twsi
+dev/dwc/if_dwc_aw.c optional dwc
+dev/iicbus/controller/twsi/a10_twsi.c optional twsi
dev/usb/controller/generic_ohci.c optional ohci
dev/usb/controller/generic_usb_if.m optional ohci
dev/usb/controller/generic_ehci.c optional ehci
@@ -34,16 +33,16 @@ arm/allwinner/aw_thermal.c optional aw_thermal
arm/allwinner/aw_cir.c optional aw_cir evdev
arm/allwinner/aw_reset.c standard
-arm/allwinner/aw_ccu.c standard
+dev/clk/allwinner/aw_ccu.c standard
arm/allwinner/aw_gmacclk.c standard
-arm/allwinner/clkng/aw_ccung.c standard
-arm/allwinner/clkng/aw_clk_frac.c standard
-arm/allwinner/clkng/aw_clk_m.c standard
-arm/allwinner/clkng/aw_clk_mipi.c standard
-arm/allwinner/clkng/aw_clk_nkmp.c standard
-arm/allwinner/clkng/aw_clk_nm.c standard
-arm/allwinner/clkng/aw_clk_np.c standard
-arm/allwinner/clkng/aw_clk_nmm.c standard
-arm/allwinner/clkng/aw_clk_prediv_mux.c standard
-arm/allwinner/clkng/ccu_de2.c standard
+dev/clk/allwinner/aw_ccung.c standard
+dev/clk/allwinner/aw_clk_frac.c standard
+dev/clk/allwinner/aw_clk_m.c standard
+dev/clk/allwinner/aw_clk_mipi.c standard
+dev/clk/allwinner/aw_clk_nkmp.c standard
+dev/clk/allwinner/aw_clk_nm.c standard
+dev/clk/allwinner/aw_clk_np.c standard
+dev/clk/allwinner/aw_clk_nmm.c standard
+dev/clk/allwinner/aw_clk_prediv_mux.c standard
+dev/clk/allwinner/ccu_de2.c standard
diff --git a/sys/arm/allwinner/files.allwinner_up b/sys/arm/allwinner/files.allwinner_up
index c776c3de791e..9944b5893dd5 100644
--- a/sys/arm/allwinner/files.allwinner_up
+++ b/sys/arm/allwinner/files.allwinner_up
@@ -1,3 +1,2 @@
-# $FreeBSD$
-arm/allwinner/a10_timer.c standard
+arm/allwinner/aw_timer.c standard
diff --git a/sys/arm/allwinner/h3/files.h3 b/sys/arm/allwinner/h3/files.h3
index bce6ca07c553..89c73165ff1a 100644
--- a/sys/arm/allwinner/h3/files.h3
+++ b/sys/arm/allwinner/h3/files.h3
@@ -1,6 +1,5 @@
-# $FreeBSD$
-arm/allwinner/clkng/ccu_h3.c standard
-arm/allwinner/clkng/ccu_sun8i_r.c standard
+dev/clk/allwinner/ccu_h3.c standard
+dev/clk/allwinner/ccu_sun8i_r.c standard
arm/allwinner/h3/h3_padconf.c standard
arm/allwinner/h3/h3_r_padconf.c standard
diff --git a/sys/arm/allwinner/h3/h3_padconf.c b/sys/arm/allwinner/h3/h3_padconf.c
index 4d2960ce4c9f..959daf35f1f2 100644
--- a/sys/arm/allwinner/h3/h3_padconf.c
+++ b/sys/arm/allwinner/h3/h3_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/h3/h3_r_padconf.c b/sys/arm/allwinner/h3/h3_r_padconf.c
index 64413ad46e66..aeb64f1b07a1 100644
--- a/sys/arm/allwinner/h3/h3_r_padconf.c
+++ b/sys/arm/allwinner/h3/h3_r_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/h6/h6_padconf.c b/sys/arm/allwinner/h6/h6_padconf.c
index 0b17632e495b..714f7ed36107 100644
--- a/sys/arm/allwinner/h6/h6_padconf.c
+++ b/sys/arm/allwinner/h6/h6_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/h6/h6_r_padconf.c b/sys/arm/allwinner/h6/h6_r_padconf.c
index 1ef6729a33c7..1d5f4942c1b1 100644
--- a/sys/arm/allwinner/h6/h6_r_padconf.c
+++ b/sys/arm/allwinner/h6/h6_r_padconf.c
@@ -24,9 +24,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
diff --git a/sys/arm/allwinner/if_awg.c b/sys/arm/allwinner/if_awg.c
index 7236bd94335d..98e879d22d3d 100644
--- a/sys/arm/allwinner/if_awg.c
+++ b/sys/arm/allwinner/if_awg.c
@@ -21,8 +21,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
@@ -31,9 +29,6 @@
#include "opt_device_polling.h"
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -64,10 +59,10 @@ __FBSDID("$FreeBSD$");
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
-#include <dev/extres/clk/clk.h>
-#include <dev/extres/hwreset/hwreset.h>
-#include <dev/extres/regulator/regulator.h>
-#include <dev/extres/syscon/syscon.h>
+#include <dev/clk/clk.h>
+#include <dev/hwreset/hwreset.h>
+#include <dev/regulator/regulator.h>
+#include <dev/syscon/syscon.h>
#include "syscon_if.h"
#include "miibus_if.h"
@@ -148,12 +143,14 @@ enum awg_type {
EMAC_A83T = 1,
EMAC_H3,
EMAC_A64,
+ EMAC_D1,
};
static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun8i-a83t-emac", EMAC_A83T },
{ "allwinner,sun8i-h3-emac", EMAC_H3 },
{ "allwinner,sun50i-a64-emac", EMAC_A64 },
+ { "allwinner,sun20i-d1-emac", EMAC_D1 },
{ NULL, 0 }
};
@@ -442,7 +439,7 @@ awg_setup_rxfilter(struct awg_softc *sc)
val |= HASH_MULTICAST;
/* Write our unicast address */
- eaddr = IF_LLADDR(ifp);
+ eaddr = if_getlladdr(ifp);
machi = (eaddr[5] << 8) | eaddr[4];
maclo = (eaddr[3] << 24) | (eaddr[2] << 16) | (eaddr[1] << 8) |
(eaddr[0] << 0);
@@ -988,7 +985,7 @@ awg_start_locked(struct awg_softc *sc)
if_sendq_prepend(ifp, m);
break;
}
- if_bpfmtap(ifp, m);
+ bpf_mtap_if(ifp, m);
}
if (cnt != 0) {
diff --git a/sys/arm/allwinner/if_awgreg.h b/sys/arm/allwinner/if_awgreg.h
index b71e05cb39de..77ea5b3260c3 100644
--- a/sys/arm/allwinner/if_awgreg.h
+++ b/sys/arm/allwinner/if_awgreg.h
@@ -21,8 +21,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c
index 8f2bd7222a6a..1fa6691ade1a 100644
--- a/sys/arm/allwinner/if_emac.c
+++ b/sys/arm/allwinner/if_emac.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
* All rights reserved.
@@ -24,15 +24,10 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/* A10/A20 EMAC driver */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -80,7 +75,7 @@ __FBSDID("$FreeBSD$");
#include <arm/allwinner/if_emacreg.h>
#include <arm/allwinner/aw_sid.h>
-#include <dev/extres/clk/clk.h>
+#include <dev/clk/clk.h>
#include "miibus_if.h"
@@ -89,7 +84,7 @@ __FBSDID("$FreeBSD$");
#include "a10_sramc.h"
struct emac_softc {
- struct ifnet *emac_ifp;
+ if_t emac_ifp;
device_t emac_dev;
device_t emac_miibus;
bus_space_handle_t emac_handle;
@@ -118,11 +113,11 @@ static int emac_sys_setup(struct emac_softc *);
static void emac_reset(struct emac_softc *);
static void emac_init_locked(struct emac_softc *);
-static void emac_start_locked(struct ifnet *);
+static void emac_start_locked(if_t);
static void emac_init(void *);
static void emac_stop_locked(struct emac_softc *);
static void emac_intr(void *);
-static int emac_ioctl(struct ifnet *, u_long, caddr_t);
+static int emac_ioctl(if_t, u_long, caddr_t);
static void emac_rxeof(struct emac_softc *, int);
static void emac_txeof(struct emac_softc *, uint32_t);
@@ -131,8 +126,8 @@ static int emac_miibus_readreg(device_t, int, int);
static int emac_miibus_writereg(device_t, int, int, int);
static void emac_miibus_statchg(device_t);
-static int emac_ifmedia_upd(struct ifnet *);
-static void emac_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int emac_ifmedia_upd(if_t);
+static void emac_ifmedia_sts(if_t, struct ifmediareq *);
static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int);
static int sysctl_hw_emac_proc_limit(SYSCTL_HANDLER_ARGS);
@@ -232,7 +227,7 @@ emac_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
static void
emac_set_rx_mode(struct emac_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
uint32_t hashes[2];
uint32_t rcr = 0;
@@ -248,7 +243,7 @@ emac_set_rx_mode(struct emac_softc *sc)
hashes[0] = 0;
hashes[1] = 0;
- if (ifp->if_flags & IFF_ALLMULTI) {
+ if (if_getflags(ifp) & IFF_ALLMULTI) {
hashes[0] = 0xffffffff;
hashes[1] = 0xffffffff;
} else
@@ -258,12 +253,12 @@ emac_set_rx_mode(struct emac_softc *sc)
EMAC_WRITE_REG(sc, EMAC_RX_HASH0, hashes[0]);
EMAC_WRITE_REG(sc, EMAC_RX_HASH1, hashes[1]);
- if (ifp->if_flags & IFF_BROADCAST) {
+ if (if_getflags(ifp) & IFF_BROADCAST) {
rcr |= EMAC_RX_BCO;
rcr |= EMAC_RX_MCO;
}
- if (ifp->if_flags & IFF_PROMISC)
+ if (if_getflags(ifp) & IFF_PROMISC)
rcr |= EMAC_RX_PA;
else
rcr |= EMAC_RX_UCAD;
@@ -292,7 +287,7 @@ emac_drain_rxfifo(struct emac_softc *sc)
static void
emac_txeof(struct emac_softc *sc, uint32_t status)
{
- struct ifnet *ifp;
+ if_t ifp;
EMAC_ASSERT_LOCKED(sc);
@@ -303,7 +298,7 @@ emac_txeof(struct emac_softc *sc, uint32_t status)
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 2);
else
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
/* Unarm watchdog timer if no TX */
sc->emac_watchdog_timer = 0;
@@ -312,7 +307,7 @@ emac_txeof(struct emac_softc *sc, uint32_t status)
static void
emac_rxeof(struct emac_softc *sc, int count)
{
- struct ifnet *ifp;
+ if_t ifp;
struct mbuf *m, *m0;
uint32_t reg_val, rxcount;
int16_t len;
@@ -321,7 +316,7 @@ emac_rxeof(struct emac_softc *sc, int count)
ifp = sc->emac_ifp;
for (; count > 0 &&
- (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; count--) {
+ (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0; count--) {
/*
* Race warning: The first packet might arrive with
* the interrupts disabled, but the second will fix
@@ -443,7 +438,7 @@ emac_rxeof(struct emac_softc *sc, int count)
}
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
EMAC_UNLOCK(sc);
- (*ifp->if_input)(ifp, m);
+ if_input(ifp, m);
EMAC_LOCK(sc);
}
}
@@ -451,7 +446,7 @@ emac_rxeof(struct emac_softc *sc, int count)
static void
emac_watchdog(struct emac_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
EMAC_ASSERT_LOCKED(sc);
@@ -468,9 +463,9 @@ emac_watchdog(struct emac_softc *sc)
if_printf(sc->emac_ifp, "watchdog timeout -- resetting\n");
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
emac_init_locked(sc);
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
emac_start_locked(ifp);
}
@@ -502,7 +497,7 @@ emac_init(void *xcs)
static void
emac_init_locked(struct emac_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
struct mii_data *mii;
uint32_t reg_val;
uint8_t *eaddr;
@@ -510,7 +505,7 @@ emac_init_locked(struct emac_softc *sc)
EMAC_ASSERT_LOCKED(sc);
ifp = sc->emac_ifp;
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
return;
/* Flush RX FIFO */
@@ -575,7 +570,7 @@ emac_init_locked(struct emac_softc *sc)
EMAC_WRITE_REG(sc, EMAC_MAC_MAXF, EMAC_MAC_MFL);
/* Setup ethernet address */
- eaddr = IF_LLADDR(ifp);
+ eaddr = if_getlladdr(ifp);
EMAC_WRITE_REG(sc, EMAC_MAC_A1, eaddr[0] << 16 |
eaddr[1] << 8 | eaddr[2]);
EMAC_WRITE_REG(sc, EMAC_MAC_A0, eaddr[3] << 16 |
@@ -589,8 +584,8 @@ emac_init_locked(struct emac_softc *sc)
reg_val |= EMAC_INT_EN;
EMAC_WRITE_REG(sc, EMAC_INT_CTL, reg_val);
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
+ if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
sc->emac_link = 0;
@@ -602,31 +597,31 @@ emac_init_locked(struct emac_softc *sc)
}
static void
-emac_start(struct ifnet *ifp)
+emac_start(if_t ifp)
{
struct emac_softc *sc;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
EMAC_LOCK(sc);
emac_start_locked(ifp);
EMAC_UNLOCK(sc);
}
static void
-emac_start_locked(struct ifnet *ifp)
+emac_start_locked(if_t ifp)
{
struct emac_softc *sc;
struct mbuf *m, *m0;
uint32_t fifo, reg;
- sc = ifp->if_softc;
- if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
+ sc = if_getsoftc(ifp);
+ if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE)
return;
if (sc->emac_fifo_mask == (EMAC_TX_FIFO0 | EMAC_TX_FIFO1))
return;
if (sc->emac_link == 0)
return;
- IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+ m = if_dequeue(ifp);
if (m == NULL)
return;
@@ -637,7 +632,7 @@ emac_start_locked(struct ifnet *ifp)
fifo = 0;
sc->emac_fifo_mask |= (1 << fifo);
if (sc->emac_fifo_mask == (EMAC_TX_FIFO0 | EMAC_TX_FIFO1))
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
EMAC_WRITE_REG(sc, EMAC_TX_INS, fifo);
/*
@@ -677,13 +672,13 @@ emac_start_locked(struct ifnet *ifp)
static void
emac_stop_locked(struct emac_softc *sc)
{
- struct ifnet *ifp;
+ if_t ifp;
uint32_t reg_val;
EMAC_ASSERT_LOCKED(sc);
ifp = sc->emac_ifp;
- ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+ if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
sc->emac_link = 0;
/* Disable all interrupt and clear interrupt status */
@@ -703,7 +698,7 @@ static void
emac_intr(void *arg)
{
struct emac_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
uint32_t reg_val;
sc = (struct emac_softc *)arg;
@@ -724,7 +719,7 @@ emac_intr(void *arg)
if (reg_val & EMAC_INT_STA_TX) {
emac_txeof(sc, reg_val);
ifp = sc->emac_ifp;
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
emac_start_locked(ifp);
}
@@ -736,37 +731,37 @@ emac_intr(void *arg)
}
static int
-emac_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+emac_ioctl(if_t ifp, u_long command, caddr_t data)
{
struct emac_softc *sc;
struct mii_data *mii;
struct ifreq *ifr;
int error = 0;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
ifr = (struct ifreq *)data;
switch (command) {
case SIOCSIFFLAGS:
EMAC_LOCK(sc);
- if (ifp->if_flags & IFF_UP) {
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
- if ((ifp->if_flags ^ sc->emac_if_flags) &
+ if (if_getflags(ifp) & IFF_UP) {
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
+ if ((if_getflags(ifp) ^ sc->emac_if_flags) &
(IFF_PROMISC | IFF_ALLMULTI))
emac_set_rx_mode(sc);
} else
emac_init_locked(sc);
} else {
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
emac_stop_locked(sc);
}
- sc->emac_if_flags = ifp->if_flags;
+ sc->emac_if_flags = if_getflags(ifp);
EMAC_UNLOCK(sc);
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
EMAC_LOCK(sc);
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
emac_set_rx_mode(sc);
}
EMAC_UNLOCK(sc);
@@ -803,7 +798,7 @@ emac_detach(device_t dev)
struct emac_softc *sc;
sc = device_get_softc(dev);
- sc->emac_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(sc->emac_ifp, 0, IFF_DRV_RUNNING);
if (device_is_attached(dev)) {
ether_ifdetach(sc->emac_ifp);
EMAC_LOCK(sc);
@@ -816,10 +811,7 @@ emac_detach(device_t dev)
bus_teardown_intr(sc->emac_dev, sc->emac_irq,
sc->emac_intrhand);
- if (sc->emac_miibus != NULL) {
- device_delete_child(sc->emac_dev, sc->emac_miibus);
- bus_generic_detach(sc->emac_dev);
- }
+ bus_generic_detach(sc->emac_dev);
if (sc->emac_clk != NULL)
clk_disable(sc->emac_clk);
@@ -850,13 +842,13 @@ static int
emac_suspend(device_t dev)
{
struct emac_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
sc = device_get_softc(dev);
EMAC_LOCK(sc);
ifp = sc->emac_ifp;
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
emac_stop_locked(sc);
EMAC_UNLOCK(sc);
@@ -867,14 +859,14 @@ static int
emac_resume(device_t dev)
{
struct emac_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
sc = device_get_softc(dev);
EMAC_LOCK(sc);
ifp = sc->emac_ifp;
- if ((ifp->if_flags & IFF_UP) != 0) {
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if ((if_getflags(ifp) & IFF_UP) != 0) {
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
emac_init_locked(sc);
}
EMAC_UNLOCK(sc);
@@ -886,7 +878,7 @@ static int
emac_attach(device_t dev)
{
struct emac_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
int error, rid;
uint8_t eaddr[ETHER_ADDR_LEN];
@@ -945,12 +937,7 @@ emac_attach(device_t dev)
emac_reset(sc);
ifp = sc->emac_ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL) {
- device_printf(dev, "unable to allocate ifp\n");
- error = ENOSPC;
- goto fail;
- }
- ifp->if_softc = sc;
+ if_setsoftc(ifp, sc);
/* Setup MII */
error = mii_attach(dev, &sc->emac_miibus, ifp, emac_ifmedia_upd,
@@ -961,21 +948,21 @@ emac_attach(device_t dev)
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_start = emac_start;
- ifp->if_ioctl = emac_ioctl;
- ifp->if_init = emac_init;
- IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
+ if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+ if_setstartfn(ifp, emac_start);
+ if_setioctlfn(ifp, emac_ioctl);
+ if_setinitfn(ifp, emac_init);
+ if_setsendqlen(ifp, IFQ_MAXLEN);
/* Get MAC address */
emac_get_hwaddr(sc, eaddr);
ether_ifattach(ifp, eaddr);
/* VLAN capability setup. */
- ifp->if_capabilities |= IFCAP_VLAN_MTU;
- ifp->if_capenable = ifp->if_capabilities;
+ if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
+ if_setcapenable(ifp, if_getcapabilities(ifp));
/* Tell the upper layer we support VLAN over-sized frames. */
- ifp->if_hdrlen = sizeof(struct ether_vlan_header);
+ if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
error = bus_setup_intr(dev, sc->emac_irq, INTR_TYPE_NET | INTR_MPSAFE,
NULL, emac_intr, sc, &sc->emac_intrhand);
@@ -991,7 +978,7 @@ fail:
return (error);
}
-static boolean_t
+static bool
emac_miibus_iowait(struct emac_softc *sc)
{
uint32_t timeout;
@@ -1060,7 +1047,7 @@ emac_miibus_statchg(device_t dev)
{
struct emac_softc *sc;
struct mii_data *mii;
- struct ifnet *ifp;
+ if_t ifp;
uint32_t reg_val;
sc = device_get_softc(dev);
@@ -1068,7 +1055,7 @@ emac_miibus_statchg(device_t dev)
mii = device_get_softc(sc->emac_miibus);
ifp = sc->emac_ifp;
if (mii == NULL || ifp == NULL ||
- (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ (if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
return;
sc->emac_link = 0;
@@ -1107,14 +1094,14 @@ emac_miibus_statchg(device_t dev)
}
static int
-emac_ifmedia_upd(struct ifnet *ifp)
+emac_ifmedia_upd(if_t ifp)
{
struct emac_softc *sc;
struct mii_data *mii;
struct mii_softc *miisc;
int error;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
mii = device_get_softc(sc->emac_miibus);
EMAC_LOCK(sc);
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
@@ -1126,12 +1113,12 @@ emac_ifmedia_upd(struct ifnet *ifp)
}
static void
-emac_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+emac_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
{
struct emac_softc *sc;
struct mii_data *mii;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
mii = device_get_softc(sc->emac_miibus);
EMAC_LOCK(sc);
diff --git a/sys/arm/allwinner/if_emacreg.h b/sys/arm/allwinner/if_emacreg.h
index f84e92c56e04..8a608adcf2d2 100644
--- a/sys/arm/allwinner/if_emacreg.h
+++ b/sys/arm/allwinner/if_emacreg.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
* All rights reserved.
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef __IF_EMACREG_H__
diff --git a/sys/arm/allwinner/std.allwinner b/sys/arm/allwinner/std.allwinner
index 4ba2ec7f0e1d..8679a53c03a3 100644
--- a/sys/arm/allwinner/std.allwinner
+++ b/sys/arm/allwinner/std.allwinner
@@ -1,5 +1,4 @@
# Allwinner common options
-#$FreeBSD$
cpu CPU_CORTEXA
machine arm armv7
diff --git a/sys/arm/allwinner/std.allwinner_up b/sys/arm/allwinner/std.allwinner_up
index 3fdfb7bba156..ffae48f35b67 100644
--- a/sys/arm/allwinner/std.allwinner_up
+++ b/sys/arm/allwinner/std.allwinner_up
@@ -1,5 +1,4 @@
# Allwinner Uniprocessor common options
-#$FreeBSD$
cpu CPU_CORTEXA
machine arm armv7
diff --git a/sys/arm/allwinner/sunxi_dma_if.m b/sys/arm/allwinner/sunxi_dma_if.m
index 6e283b93cf41..5302a12607fd 100644
--- a/sys/arm/allwinner/sunxi_dma_if.m
+++ b/sys/arm/allwinner/sunxi_dma_if.m
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
#include <sys/bus.h>