diff options
-rw-r--r-- | share/man/man4/Makefile | 4 | ||||
-rw-r--r-- | share/man/man4/mvdog.4 | 44 | ||||
-rw-r--r-- | sys/arch/arm64/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/arm64/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/dev/fdt/files.fdt | 6 | ||||
-rw-r--r-- | sys/dev/fdt/mvdog.c | 102 |
6 files changed, 157 insertions, 5 deletions
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index eaa18fb8967..21d2661bceb 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.727 2019/09/03 21:02:51 kettenis Exp $ +# $OpenBSD: Makefile,v 1.728 2019/09/05 18:38:30 patrick Exp $ MAN= aac.4 abcrtc.4 ac97.4 acphy.4 acrtc.4 \ acpi.4 acpiac.4 acpials.4 acpiasus.4 acpibat.4 \ @@ -48,7 +48,7 @@ MAN= aac.4 abcrtc.4 ac97.4 acphy.4 acrtc.4 \ midi.4 mii.4 mfi.4 \ mfii.4 mlphy.4 mobileip.4 moscom.4 mos.4 mpe.4 mpath.4 mpi.4 mpii.4 \ mpip.4 mpu.4 msk.4 mpw.4 msts.4 mtd.4 mtdphy.4 mtio.4 mue.4 \ - multicast.4 mvclock.4 mvgicp.4 mvgpio.4 mvicu.4 mvneta.4 \ + multicast.4 mvclock.4 mvdog.4 mvgicp.4 mvgpio.4 mvicu.4 mvneta.4 \ mvpinctrl.4 mvrng.4 mvrtc.4 mvtemp.4 mvuart.4 myx.4 \ ne.4 neo.4 nep.4 netintro.4 nfe.4 nge.4 nmea.4 \ nsclpcsio.4 nsgphy.4 nsphy.4 nsphyter.4 null.4 nviic.4 nvme.4 nvt.4 \ diff --git a/share/man/man4/mvdog.4 b/share/man/man4/mvdog.4 new file mode 100644 index 00000000000..a8e9b0ed960 --- /dev/null +++ b/share/man/man4/mvdog.4 @@ -0,0 +1,44 @@ +.\" $OpenBSD: mvdog.4,v 1.1 2019/09/05 18:38:30 patrick Exp $ +.\" +.\" Copyright (c) 2019 Patrick Wildt <patrick@blueri.se> +.\" +.\" 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. +.\" +.Dd $Mdocdate: September 5 2019 $ +.Dt MVDOG 4 +.Os +.Sh NAME +.Nm mvdog +.Nd Marvell Armada 3700 watchdog timer +.Sh SYNOPSIS +.Cd "mvdog* at fdt?" +.Sh DESCRIPTION +The +.Nm +driver provides support for the integrated watchdog timer in the Marvell +Armada 3700 SoC. +.Sh SEE ALSO +.Xr intro 4 , +.Xr watchdog 4 , +.Xr watchdogd 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 6.6 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Patrick Wildt Aq Mt patrick@blueri.se . diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index 82e71aca864..337f6a0e961 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.120 2019/09/04 14:29:41 cheloha Exp $ +# $OpenBSD: GENERIC,v 1.121 2019/09/05 18:38:30 patrick Exp $ # # GENERIC machine description file # @@ -163,6 +163,7 @@ mvclock* at fdt? early 1 mvgicp* at fdt? early 1 mvicu* at fdt? early 1 mvpinctrl* at fdt? early 1 +mvdog* at fdt? mvgpio* at fdt? mvmdio* at fdt? mvneta* at fdt? diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK index 7c5541871fc..7e868cb253b 100644 --- a/sys/arch/arm64/conf/RAMDISK +++ b/sys/arch/arm64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.98 2019/09/04 14:29:41 cheloha Exp $ +# $OpenBSD: RAMDISK,v 1.99 2019/09/05 18:38:30 patrick Exp $ # # GENERIC machine description file # @@ -152,6 +152,7 @@ mvclock* at fdt? early 1 mvgicp* at fdt? early 1 mvicu* at fdt? early 1 mvpinctrl* at fdt? early 1 +mvdog* at fdt? mvgpio* at fdt? mvmdio* at fdt? mvneta* at fdt? diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt index 94be22725fd..fcd8f77b4df 100644 --- a/sys/dev/fdt/files.fdt +++ b/sys/dev/fdt/files.fdt @@ -1,4 +1,4 @@ -# $OpenBSD: files.fdt,v 1.89 2019/09/01 16:01:43 kettenis Exp $ +# $OpenBSD: files.fdt,v 1.90 2019/09/05 18:38:30 patrick Exp $ # # Config file and device description for machine-independent FDT code. # Included by ports that need it. @@ -230,6 +230,10 @@ device mvclock attach mvclock at fdt file dev/fdt/mvclock.c mvclock +device mvdog +attach mvdog at fdt +file dev/fdt/mvdog.c mvdog + device mvgicp attach mvgicp at fdt file dev/fdt/mvgicp.c mvgicp diff --git a/sys/dev/fdt/mvdog.c b/sys/dev/fdt/mvdog.c new file mode 100644 index 00000000000..cef0bfe1159 --- /dev/null +++ b/sys/dev/fdt/mvdog.c @@ -0,0 +1,102 @@ +/* $OpenBSD: mvdog.c,v 1.1 2019/09/05 18:38:30 patrick Exp $ */ +/* + * Copyright (c) 2019 Patrick Wildt <patrick@blueri.se> + * + * 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> + +#define CNTR_RETRIGGER 0 +#define CNTR_WDOG 1 + +#define CNTR_CTRL(x) ((x) * 0x10) +#define CNTR_CTRL_ENABLE (1 << 0) + +#define WDT_TIMER_SELECT 0x64 + +#define HREAD4(sc, reg) \ + (bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg))) +#define HWRITE4(sc, reg, val) \ + bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, (reg), (val)) +#define HSET4(sc, reg, bits) \ + HWRITE4((sc), (reg), HREAD4((sc), (reg)) | (bits)) +#define HCLR4(sc, reg, bits) \ + HWRITE4((sc), (reg), HREAD4((sc), (reg)) & ~(bits)) + +struct mvdog_softc { + struct device sc_dev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + struct regmap *sc_rm; +}; + +int mvdog_match(struct device *, void *, void *); +void mvdog_attach(struct device *, struct device *, void *); + +struct cfattach mvdog_ca = { + sizeof (struct mvdog_softc), mvdog_match, mvdog_attach +}; + +struct cfdriver mvdog_cd = { + NULL, "mvdog", DV_DULL +}; + +int +mvdog_match(struct device *parent, void *cfdata, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "marvell,armada-3700-wdt"); +} + +void +mvdog_attach(struct device *parent, struct device *self, void *aux) +{ + struct mvdog_softc *sc = (struct mvdog_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; + } + + sc->sc_rm = regmap_byphandle(OF_getpropint(faa->fa_node, + "marvell,system-controller", 0)); + if (sc->sc_rm == NULL) { + printf(": can't get regmap\n"); + return; + } + + printf("\n"); + + /* Disable watchdog timer. */ + HCLR4(sc, CNTR_CTRL(CNTR_WDOG), CNTR_CTRL_ENABLE); + HCLR4(sc, CNTR_CTRL(CNTR_RETRIGGER), CNTR_CTRL_ENABLE); + regmap_write_4(sc->sc_rm, WDT_TIMER_SELECT, 0); +} |