diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-08-11 11:19:42 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-08-11 11:19:42 +0000 |
commit | 9e3108be56945c4e93f59c4068bebd20afc9cddd (patch) | |
tree | d96a4ffd5b0a0f558c95a53c333832b2877c8d9e | |
parent | 2d8a4444feb9950e8ad9725353134e47a1e022d4 (diff) |
Add sxisyscon(4) a driver for the system controller found on various
Allwinner SoCs.
This is basically a stripped down syscon(4) and is needed because the
Linux device trees dropped the "syscon" compatible.
ok patrick@
-rw-r--r-- | sys/arch/arm64/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/arm64/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/arch/armv7/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/armv7/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/dev/fdt/files.fdt | 6 | ||||
-rw-r--r-- | sys/dev/fdt/sxisyscon.c | 83 |
6 files changed, 96 insertions, 5 deletions
diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index 89557e2120d..3b2435c3079 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.107 2019/08/04 15:44:17 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.108 2019/08/11 11:19:41 kettenis Exp $ # # GENERIC machine description file # @@ -179,6 +179,7 @@ axppmic* at rsb? sxirtc* at fdt? # Real Time Clock sximmc* at fdt? # SD/MMC card controller sdmmc* at sximmc? # SD/MMC bus +sxisyscon* at fdt? early 1 # System controller sxitemp* at fdt? # Temperature sensor sxitwi* at fdt? # I2C controller iic* at sxitwi? # I2C bus diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK index 7f102ef5c06..1bf6cfe0aa2 100644 --- a/sys/arch/arm64/conf/RAMDISK +++ b/sys/arch/arm64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.88 2019/06/07 04:03:04 jmatthew Exp $ +# $OpenBSD: RAMDISK,v 1.89 2019/08/11 11:19:41 kettenis Exp $ # # GENERIC machine description file # @@ -170,6 +170,7 @@ sxirsb* at fdt? early 1 # Reduced Serial Bus sxirtc* at fdt? # Real Time Clock sximmc* at fdt? # SD/MMC card controller sdmmc* at sximmc? # SD/MMC bus +sxisyscon* at fdt? early 1 # System controller sxitwi* at fdt? # I2C controller iic* at sxitwi? # I2C bus dwxe* at fdt? diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index e44db78545f..4f51de02e54 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.122 2019/05/08 23:54:39 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.123 2019/08/11 11:19:41 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -114,6 +114,7 @@ ehci* at fdt? # EHCI (shim) usb* at ehci? #flags 0x1 ohci* at fdt? usb* at ohci? +sxisyscon* at fdt? early 1 # System controller sxitemp* at fdt? # Temperature sensor sxits* at fdt? # Touchpad controller sxitwi* at fdt? # Two-Wire Serial Interface diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index 2e8a11bd544..dd99a7ca39e 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.107 2019/01/12 19:37:16 kettenis Exp $ +# $OpenBSD: RAMDISK,v 1.108 2019/08/11 11:19:41 kettenis Exp $ machine armv7 arm @@ -107,6 +107,7 @@ ehci* at fdt? # EHCI (shim) usb* at ehci? #flags 0x1 ohci* at fdt? usb* at ohci? +sxisyscon* at fdt? early 1 # System controller sxitwi* at fdt? # Two-Wire Serial Interface iic* at sxitwi? # I2C bus diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt index 21dac8c7194..cb11e40c3b5 100644 --- a/sys/dev/fdt/files.fdt +++ b/sys/dev/fdt/files.fdt @@ -1,4 +1,4 @@ -# $OpenBSD: files.fdt,v 1.80 2019/05/11 14:43:27 patrick Exp $ +# $OpenBSD: files.fdt,v 1.81 2019/08/11 11:19:41 kettenis Exp $ # # Config file and device description for machine-independent FDT code. # Included by ports that need it. @@ -32,6 +32,10 @@ device sximmc: sdmmcbus attach sximmc at fdt file dev/fdt/sximmc.c sximmc +device sxisyscon: fdt +attach sxisyscon at fdt +file dev/fdt/sxisyscon.c sxisyscon + device sxitemp attach sxitemp at fdt file dev/fdt/sxitemp.c sxitemp diff --git a/sys/dev/fdt/sxisyscon.c b/sys/dev/fdt/sxisyscon.c new file mode 100644 index 00000000000..30021d9f6aa --- /dev/null +++ b/sys/dev/fdt/sxisyscon.c @@ -0,0 +1,83 @@ +/* $OpenBSD: sxisyscon.c,v 1.1 2019/08/11 11:19:41 kettenis Exp $ */ +/* + * Copyright (c) 2019 Mark Kettenis <kettenis@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> + +#include <machine/bus.h> +#include <machine/fdt.h> + +#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_misc.h> +#include <dev/ofw/fdt.h> + +struct sxisyscon_softc { + struct device sc_dev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; +}; + +int sxisyscon_match(struct device *, void *, void *); +void sxisyscon_attach(struct device *, struct device *, void *); + +struct cfattach sxisyscon_ca = { + sizeof(struct sxisyscon_softc), sxisyscon_match, sxisyscon_attach +}; + +struct cfdriver sxisyscon_cd = { + NULL, "sxisyscon", DV_DULL +}; + +int +sxisyscon_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + int node = faa->fa_node; + + if (OF_is_compatible(node, "allwinner,sun8i-h3-system-control") || + OF_is_compatible(node, "allwinner,sun50i-a64-system-control") || + OF_is_compatible(node, "allwinner,sun50i-h5-system-control") || + OF_is_compatible(node, "allwinner,sun50i-h6-system-control")) + return 10; /* Must beat syscon(4). */ + + return 0; +} + +void +sxisyscon_attach(struct device *parent, struct device *self, void *aux) +{ + struct sxisyscon_softc *sc = (struct sxisyscon_softc *)self; + struct fdt_attach_args *faa = aux; + + if (faa->fa_nreg < 1) { + printf(": no registers\n"); + return; + } + + sc->sc_iot = faa->fa_iot; + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, + faa->fa_reg[0].size, 0, &sc->sc_ioh)) { + printf(": can't map registers\n"); + return; + } + + regmap_register(faa->fa_node, sc->sc_iot, sc->sc_ioh, + faa->fa_reg[0].size); + + printf("\n"); +} |