From: jsg Date: Sun, 26 Jun 2016 05:16:33 +0000 (+0000) Subject: Dynamically attach omdog(4) using the FDT. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7f0748eb5ff551bb4e315b51cf43c93bc9d76e15;p=openbsd Dynamically attach omdog(4) using the FDT. --- diff --git a/share/man/man4/man4.armv7/omdog.4 b/share/man/man4/man4.armv7/omdog.4 index 4ce95fed784..3962c0514a3 100644 --- a/share/man/man4/man4.armv7/omdog.4 +++ b/share/man/man4/man4.armv7/omdog.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: omdog.4,v 1.3 2014/09/19 17:17:04 jmc Exp $ +.\" $OpenBSD: omdog.4,v 1.4 2016/06/26 05:16:33 jsg Exp $ .\" Copyright (c) 2014 Raphael Graf .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -13,14 +13,14 @@ .\" 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 19 2014 $ +.Dd $Mdocdate: June 26 2016 $ .Dt OMDOG 4 armv7 .Os .Sh NAME .Nm omdog .Nd Texas Instruments watchdog timer device .Sh SYNOPSIS -.Cd "omdog* at omap?" +.Cd "omdog* at fdt?" .Sh DESCRIPTION The .Nm diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index 7fb791b975d..b6600cf9827 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.23 2016/06/19 14:27:35 jsg Exp $ +# $OpenBSD: GENERIC,v 1.24 2016/06/26 05:16:33 jsg Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -64,7 +64,7 @@ intc* at omap? # OMAP3 interrupt controller edma* at omap? # OMAP3 dma controller prcm* at omap? # power/clock controller sitaracm* at omap? # sitara control module -omdog* at omap? # watchdog timer +omdog* at fdt? # watchdog timer omgpio* at omap? # user-visible GPIO pins? gpio* at omgpio? #tiiic* at omap? diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index 6ed438c009d..33c82d19989 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.20 2016/06/19 14:27:35 jsg Exp $ +# $OpenBSD: RAMDISK,v 1.21 2016/06/26 05:16:33 jsg Exp $ machine armv7 arm @@ -63,7 +63,7 @@ intc* at omap? # OMAP3 interrupt controller edma* at omap? # OMAP3 dma controller prcm* at omap? # power/clock controller sitaracm* at omap? # sitara control module -omdog* at omap? # watchdog timer +omdog* at fdt? # watchdog timer omgpio* at omap? # user-visible GPIO pins? gpio* at omgpio? #tiiic* at omap? diff --git a/sys/arch/armv7/omap/files.omap b/sys/arch/armv7/omap/files.omap index 092b27e67b5..961b9a394e7 100644 --- a/sys/arch/armv7/omap/files.omap +++ b/sys/arch/armv7/omap/files.omap @@ -1,4 +1,4 @@ -# $OpenBSD: files.omap,v 1.10 2016/06/19 14:27:35 jsg Exp $ +# $OpenBSD: files.omap,v 1.11 2016/06/26 05:16:33 jsg Exp $ define omap {} device omap: omap @@ -55,7 +55,7 @@ attach omapid at omap file arch/armv7/omap/omapid.c omapid device omdog -attach omdog at omap +attach omdog at fdt file arch/armv7/omap/omdog.c omdog attach ohci at omap with omohci diff --git a/sys/arch/armv7/omap/omap.c b/sys/arch/armv7/omap/omap.c index 67d407f60b7..6065124283d 100644 --- a/sys/arch/armv7/omap/omap.c +++ b/sys/arch/armv7/omap/omap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap.c,v 1.12 2016/06/19 14:27:35 jsg Exp $ */ +/* $OpenBSD: omap.c,v 1.13 2016/06/26 05:16:33 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * @@ -41,7 +41,6 @@ struct board_dev beagleboard_devs[] = { { "intc", 0 }, { "gptimer", 0 }, { "gptimer", 1 }, - { "omdog", 0 }, { "omgpio", 0 }, { "omgpio", 1 }, { "omgpio", 2 }, @@ -58,7 +57,6 @@ struct board_dev beaglebone_devs[] = { { "edma", 0 }, { "dmtimer", 0 }, { "dmtimer", 1 }, - { "omdog", 0 }, { "omgpio", 0 }, { "omgpio", 1 }, { "omgpio", 2 }, @@ -75,7 +73,6 @@ struct board_dev overo_devs[] = { { "intc", 0 }, { "gptimer", 0 }, { "gptimer", 1 }, - { "omdog", 0 }, { "omgpio", 0 }, { "omgpio", 1 }, { "omgpio", 2 }, @@ -88,7 +85,6 @@ struct board_dev overo_devs[] = { struct board_dev pandaboard_devs[] = { { "omapid", 0 }, { "prcm", 0 }, - { "omdog", 0 }, { "omgpio", 0 }, { "omgpio", 1 }, { "omgpio", 2 }, diff --git a/sys/arch/armv7/omap/omdog.c b/sys/arch/armv7/omap/omdog.c index d3d54a5e073..f4df5c4452d 100644 --- a/sys/arch/armv7/omap/omdog.c +++ b/sys/arch/armv7/omap/omdog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omdog.c,v 1.5 2014/12/10 12:27:56 mikeb Exp $ */ +/* $OpenBSD: omdog.c,v 1.6 2016/06/26 05:16:33 jsg Exp $ */ /* * Copyright (c) 2013 Federico G. Schwindt * Copyright (c) 2007,2009 Dale Rahn @@ -24,8 +24,13 @@ #include #include #include + #include #include +#include + +#include + #include #define WIDR 0x00 /* Identification Register */ @@ -56,6 +61,7 @@ struct omdog_softc { struct omdog_softc *omdog_sc; +int omdog_match(struct device *, void *, void *); void omdog_attach(struct device *, struct device *, void *); int omdog_activate(struct device *, int); void omdog_start(struct omdog_softc *); @@ -65,23 +71,35 @@ int omdog_cb(void *, int); void omdog_reset(void); struct cfattach omdog_ca = { - sizeof (struct omdog_softc), NULL, omdog_attach, NULL, omdog_activate + sizeof (struct omdog_softc), omdog_match, omdog_attach, NULL, + omdog_activate }; struct cfdriver omdog_cd = { NULL, "omdog", DV_DULL }; +int +omdog_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "ti,omap3-wdt"); +} + void -omdog_attach(struct device *parent, struct device *self, void *args) +omdog_attach(struct device *parent, struct device *self, void *aux) { - struct armv7_attach_args *aa = args; + struct fdt_attach_args *faa = aux; struct omdog_softc *sc = (struct omdog_softc *) self; u_int32_t rev; - sc->sc_iot = aa->aa_iot; - if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr, - aa->aa_dev->mem[0].size, 0, &sc->sc_ioh)) + if (faa->fa_nreg < 2) + return; + + sc->sc_iot = faa->fa_iot; + if (bus_space_map(sc->sc_iot, faa->fa_reg[0], + faa->fa_reg[1], 0, &sc->sc_ioh)) panic("%s: bus_space_map failed!", __func__); rev = bus_space_read_4(sc->sc_iot, sc->sc_ioh, WIDR);