From: kettenis Date: Fri, 5 Aug 2016 21:45:37 +0000 (+0000) Subject: Dynamically attach sxidog(4). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=aa6fca31335f848b2a868ba533c5c0f8f74e035b;p=openbsd Dynamically attach sxidog(4). --- diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index 41ca54fbef0..58c66056405 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.35 2016/08/05 21:29:23 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.36 2016/08/05 21:45:37 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -90,7 +90,7 @@ sxipio* at sunxi? # GPIO pins for leds & PHYs gpio* at sxipio? sxiccmu* at sunxi? # Clock Control Module/Unit sxitimer* at sunxi? -sxidog* at sunxi? # watchdog timer +sxidog* at fdt? # watchdog timer sxirtc* at fdt? # Real Time Clock sxiuart* at fdt? # onboard UARTs sxie* at fdt? diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index a4a3cf8351f..156956a1438 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.32 2016/08/05 21:29:23 kettenis Exp $ +# $OpenBSD: RAMDISK,v 1.33 2016/08/05 21:45:37 kettenis Exp $ machine armv7 arm @@ -89,7 +89,7 @@ sxipio* at sunxi? # GPIO pins for leds & PHYs gpio* at sxipio? sxiccmu* at sunxi? # Clock Control Module/Unit sxitimer* at sunxi? -sxidog* at sunxi? # watchdog timer +sxidog* at fdt? # watchdog timer sxirtc* at fdt? # Real Time Clock sxiuart* at fdt? # onboard UARTs sxie* at fdt? diff --git a/sys/arch/armv7/sunxi/files.sunxi b/sys/arch/armv7/sunxi/files.sunxi index fc6417affcf..9a9c7a41996 100644 --- a/sys/arch/armv7/sunxi/files.sunxi +++ b/sys/arch/armv7/sunxi/files.sunxi @@ -1,4 +1,4 @@ -# $OpenBSD: files.sunxi,v 1.9 2016/08/05 21:29:23 kettenis Exp $ +# $OpenBSD: files.sunxi,v 1.10 2016/08/05 21:45:37 kettenis Exp $ define sunxi {} device sunxi: sunxi @@ -25,7 +25,7 @@ attach sxitimer at sunxi file arch/armv7/sunxi/sxitimer.c sxitimer device sxidog -attach sxidog at sunxi +attach sxidog at fdt file arch/armv7/sunxi/sxidog.c sxidog device sxirtc diff --git a/sys/arch/armv7/sunxi/sunxi.c b/sys/arch/armv7/sunxi/sunxi.c index 2f1b96b314a..edfa4fd8fa7 100644 --- a/sys/arch/armv7/sunxi/sunxi.c +++ b/sys/arch/armv7/sunxi/sunxi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunxi.c,v 1.16 2016/08/05 21:39:02 kettenis Exp $ */ +/* $OpenBSD: sunxi.c,v 1.17 2016/08/05 21:45:37 kettenis Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * @@ -45,7 +45,6 @@ struct board_dev sun4i_devs[] = { { "sxitimer", 0 }, { "sxitimer", 1 }, { "sxitimer", 2 }, - { "sxidog", 0 }, { NULL, 0 } }; @@ -55,14 +54,12 @@ struct board_dev sun5i_devs[] = { { "sxitimer", 0 }, { "sxitimer", 1 }, { "sxitimer", 2 }, - { "sxidog", 0 }, { NULL, 0 } }; struct board_dev sun7i_devs[] = { { "sxipio", 0 }, { "sxiccmu", 0 }, - { "sxidog", 0 }, { NULL, 0 } }; diff --git a/sys/arch/armv7/sunxi/sxidog.c b/sys/arch/armv7/sunxi/sxidog.c index 8350fe8cc2d..18cb2a40c18 100644 --- a/sys/arch/armv7/sunxi/sxidog.c +++ b/sys/arch/armv7/sunxi/sxidog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxidog.c,v 1.7 2016/02/02 21:40:47 jsg Exp $ */ +/* $OpenBSD: sxidog.c,v 1.8 2016/08/05 21:45:37 kettenis Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn * @@ -26,10 +26,14 @@ #include #include +#include #include #include +#include +#include + /* registers */ #define WDOG_CR 0x00 #define WDOG_MR 0x04 @@ -62,6 +66,7 @@ struct sxidog_softc { struct sxidog_softc *sxidog_sc = NULL; /* for sxidog_reset() */ +int sxidog_match(struct device *, void *, void *); void sxidog_attach(struct device *, struct device *, void *); int sxidog_activate(struct device *, int); int sxidog_callback(void *, int); @@ -71,7 +76,7 @@ int sxidog_intr(void *); void sxidog_reset(void); struct cfattach sxidog_ca = { - sizeof (struct sxidog_softc), NULL, sxidog_attach, + sizeof (struct sxidog_softc), sxidog_match, sxidog_attach, NULL, sxidog_activate }; @@ -79,15 +84,26 @@ struct cfdriver sxidog_cd = { NULL, "sxidog", DV_DULL }; +int +sxidog_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "allwinner,sun4i-a10-wdt"); +} + void -sxidog_attach(struct device *parent, struct device *self, void *args) +sxidog_attach(struct device *parent, struct device *self, void *aux) { - struct armv7_attach_args *aa = args; struct sxidog_softc *sc = (struct sxidog_softc *)self; + struct fdt_attach_args *faa = aux; + + if (faa->fa_nreg < 1) + return; - 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)) + 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)) panic("sxidog_attach: bus_space_map failed!"); #ifdef DEBUG @@ -95,7 +111,7 @@ sxidog_attach(struct device *parent, struct device *self, void *args) SXIREAD4(sc, WDOG_MR)); #endif #if 0 - (void)intc_intr_establish(aa->aa_dev->irq[0], IPL_HIGH, /* XXX */ + (void)intc_intr_establish_fdt(faa->fa_node, IPL_HIGH, /* XXX */ sxidog_intr, sc, sc->sc_dev.dv_xname); #endif sxidog_sc = sc;