diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-06-13 23:43:59 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-06-13 23:43:59 +0000 |
commit | 0ac695749d5b0507d61bdc1b35feae2f5b1dc197 (patch) | |
tree | 18fccee517cbc26d185f78fbf83a61ba59dd4ed1 /sys/arch/armv7/imx | |
parent | af679c1db978876131a39dc7e81e16cda681d46e (diff) |
Dynamically attach imxdog(4) using the FDT.
Diffstat (limited to 'sys/arch/armv7/imx')
-rw-r--r-- | sys/arch/armv7/imx/files.imx | 4 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imx.c | 9 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxdog.c | 35 |
3 files changed, 29 insertions, 19 deletions
diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx index 4b907a68908..b38221dce13 100644 --- a/sys/arch/armv7/imx/files.imx +++ b/sys/arch/armv7/imx/files.imx @@ -1,4 +1,4 @@ -# $OpenBSD: files.imx,v 1.10 2016/06/12 13:02:06 kettenis Exp $ +# $OpenBSD: files.imx,v 1.11 2016/06/13 23:43:58 kettenis Exp $ define imx {} device imx: imx @@ -21,7 +21,7 @@ attach imxiomuxc at imx file arch/armv7/imx/imxiomuxc.c imxiomuxc device imxdog -attach imxdog at imx +attach imxdog at fdt file arch/armv7/imx/imxdog.c imxdog device imxocotp diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c index 4a7d4a6840c..56b6743e8b7 100644 --- a/sys/arch/armv7/imx/imx.c +++ b/sys/arch/armv7/imx/imx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx.c,v 1.19 2016/06/12 13:02:06 kettenis Exp $ */ +/* $OpenBSD: imx.c,v 1.20 2016/06/13 23:43:58 kettenis Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -40,7 +40,6 @@ struct board_dev hummingboard_devs[] = { { "imxocotp", 0 }, { "imxccm", 0 }, { "imxiomuxc", 0 }, - { "imxdog", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, { "imxgpio", 2 }, @@ -56,7 +55,6 @@ struct board_dev hummingboard_devs[] = { struct board_dev sabrelite_devs[] = { { "imxccm", 0 }, { "imxiomuxc", 0 }, - { "imxdog", 0 }, { "imxocotp", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, @@ -74,7 +72,6 @@ struct board_dev sabresd_devs[] = { { "imxccm", 0 }, { "imxtemp", 0 }, { "imxiomuxc", 0 }, - { "imxdog", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, { "imxgpio", 2 }, @@ -90,7 +87,6 @@ struct board_dev udoo_devs[] = { { "imxocotp", 0 }, { "imxccm", 0 }, { "imxiomuxc", 0 }, - { "imxdog", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, { "imxgpio", 2 }, @@ -106,7 +102,6 @@ struct board_dev utilite_devs[] = { { "imxocotp", 0 }, { "imxccm", 0 }, { "imxiomuxc", 0 }, - { "imxdog", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, { "imxgpio", 2 }, @@ -121,7 +116,6 @@ struct board_dev utilite_devs[] = { struct board_dev novena_devs[] = { { "imxccm", 0 }, { "imxiomuxc", 0 }, - { "imxdog", 0 }, { "imxocotp", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, @@ -137,7 +131,6 @@ struct board_dev novena_devs[] = { struct board_dev wandboard_devs[] = { { "imxccm", 0 }, { "imxiomuxc", 0 }, - { "imxdog", 0 }, { "imxocotp", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, diff --git a/sys/arch/armv7/imx/imxdog.c b/sys/arch/armv7/imx/imxdog.c index 9498cbb9350..f3040d8fc09 100644 --- a/sys/arch/armv7/imx/imxdog.c +++ b/sys/arch/armv7/imx/imxdog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxdog.c,v 1.2 2013/11/06 19:03:07 syl Exp $ */ +/* $OpenBSD: imxdog.c,v 1.3 2016/06/13 23:43:58 kettenis Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -23,8 +23,13 @@ #include <sys/evcount.h> #include <sys/socket.h> #include <sys/timeout.h> + #include <machine/intr.h> #include <machine/bus.h> +#include <machine/fdt.h> + +#include <dev/ofw/openfirm.h> + #include <armv7/armv7/armv7var.h> /* registers */ @@ -42,26 +47,38 @@ struct imxdog_softc { struct imxdog_softc *imxdog_sc; -void imxdog_attach(struct device *parent, struct device *self, void *args); -void imxdog_reset(void); +int imxdog_match(struct device *, void *, void *); +void imxdog_attach(struct device *, struct device *, void *); +void imxdog_reset(void); struct cfattach imxdog_ca = { - sizeof (struct imxdog_softc), NULL, imxdog_attach + sizeof (struct imxdog_softc), imxdog_match, imxdog_attach }; struct cfdriver imxdog_cd = { NULL, "imxdog", DV_DULL }; +int +imxdog_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "fsl,imx21-wdt"); +} + void -imxdog_attach(struct device *parent, struct device *self, void *args) +imxdog_attach(struct device *parent, struct device *self, void *aux) { - struct armv7_attach_args *aa = args; + struct fdt_attach_args *faa = aux; struct imxdog_softc *sc = (struct imxdog_softc *) self; - 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("imxdog_attach: bus_space_map failed!"); printf("\n"); |