From: kettenis Date: Sun, 10 Jul 2016 14:01:10 +0000 (+0000) Subject: Dynamically attach imxgpio(4) using the FDT. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fffc75382f4c2e839186445c1a43965565bfea86;p=openbsd Dynamically attach imxgpio(4) using the FDT. --- diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index 1ddd24fba9d..349ef3a91c3 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.28 2016/07/09 12:32:50 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.29 2016/07/10 14:01:10 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -44,7 +44,7 @@ imxccm* at imx? # clock control module imxiomuxc* at imx? # iomux controller imxdog* at fdt? # watchdog timer imxocotp* at imx? # on-chip otp controller -imxgpio* at imx? # user-visible GPIO pins? +imxgpio* at fdt? # user-visible GPIO pins? fec* at fdt? # Ethernet imxuart* at fdt? # onboard uarts imxiic* at fdt? # i2c diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index ecf7a2d0529..77fbce4f375 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.25 2016/07/09 12:32:50 kettenis Exp $ +# $OpenBSD: RAMDISK,v 1.26 2016/07/10 14:01:10 kettenis Exp $ machine armv7 arm @@ -43,7 +43,7 @@ imxccm* at imx? # clock control module imxiomuxc* at imx? # iomux controller imxdog* at fdt? # watchdog timer imxocotp* at imx? # on-chip otp controller -imxgpio* at imx? # user-visible GPIO pins? +imxgpio* at fdt? # user-visible GPIO pins? fec* at fdt? # Ethernet imxuart* at fdt? # onboard uarts imxiic* at fdt? # i2c diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx index ac30e0f4bb8..952f0515cfd 100644 --- a/sys/arch/armv7/imx/files.imx +++ b/sys/arch/armv7/imx/files.imx @@ -1,4 +1,4 @@ -# $OpenBSD: files.imx,v 1.12 2016/07/09 12:32:50 kettenis Exp $ +# $OpenBSD: files.imx,v 1.13 2016/07/10 14:01:10 kettenis Exp $ define imx {} device imx: imx @@ -29,7 +29,7 @@ attach imxocotp at imx file arch/armv7/imx/imxocotp.c imxocotp device imxgpio -attach imxgpio at imx +attach imxgpio at fdt file arch/armv7/imx/imxgpio.c imxgpio device imxiic: i2cbus diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c index 935279464fd..8b0ae33d7f1 100644 --- a/sys/arch/armv7/imx/imx.c +++ b/sys/arch/armv7/imx/imx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx.c,v 1.22 2016/07/09 18:14:18 kettenis Exp $ */ +/* $OpenBSD: imx.c,v 1.23 2016/07/10 14:01:10 kettenis Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -41,13 +41,6 @@ struct board_dev imx_devs[] = { { "imxccm", 0 }, { "imxiomuxc", 0 }, { "imxocotp", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, { NULL, 0 } }; diff --git a/sys/arch/armv7/imx/imxgpio.c b/sys/arch/armv7/imx/imxgpio.c index c00cfbd58a6..7a22f635cff 100644 --- a/sys/arch/armv7/imx/imxgpio.c +++ b/sys/arch/armv7/imx/imxgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxgpio.c,v 1.7 2015/05/14 03:13:20 jsg Exp $ */ +/* $OpenBSD: imxgpio.c,v 1.8 2016/07/10 14:01:10 kettenis Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -26,11 +26,14 @@ #include #include +#include #include #include #include +#include + /* iMX6 registers */ #define GPIO_DR 0x00 #define GPIO_GDIR 0x04 @@ -76,10 +79,8 @@ struct imxgpio_softc { #define GPIO_PIN_TO_INST(x) ((x) >> 5) #define GPIO_PIN_TO_OFFSET(x) ((x) & 0x1f) -void imxgpio_attach(struct device *parent, struct device *self, void *args); -void imxgpio_recalc_interrupts(struct imxgpio_softc *sc); -int imxgpio_irq(void *); -int imxgpio_irq_dummy(void *); +int imxgpio_match(struct device *, void *, void *); +void imxgpio_attach(struct device *, struct device *, void *); unsigned int imxgpio_v6_get_bit(struct imxgpio_softc *, unsigned int); void imxgpio_v6_set_bit(struct imxgpio_softc *, unsigned int); @@ -89,22 +90,33 @@ unsigned int imxgpio_v6_get_dir(struct imxgpio_softc *, unsigned int); struct cfattach imxgpio_ca = { - sizeof (struct imxgpio_softc), NULL, imxgpio_attach + sizeof (struct imxgpio_softc), imxgpio_match, imxgpio_attach }; struct cfdriver imxgpio_cd = { NULL, "imxgpio", DV_DULL }; +int +imxgpio_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "fsl,imx35-gpio"); +} + void -imxgpio_attach(struct device *parent, struct device *self, void *args) +imxgpio_attach(struct device *parent, struct device *self, void *aux) { - struct armv7_attach_args *aa = args; - struct imxgpio_softc *sc = (struct imxgpio_softc *) self; + struct imxgpio_softc *sc = (struct imxgpio_softc *)self; + struct fdt_attach_args *faa = aux; + + if (faa->fa_nreg < 2) + 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], + faa->fa_reg[1], 0, &sc->sc_ioh)) panic("imxgpio_attach: bus_space_map failed!"); sc->sc_get_bit = imxgpio_v6_get_bit;