aboutsummaryrefslogtreecommitdiff
path: root/sys/arm/ti/ti_gpio.c
diff options
context:
space:
mode:
authorLuiz Otavio O Souza <loos@FreeBSD.org>2015-01-31 19:32:14 +0000
committerLuiz Otavio O Souza <loos@FreeBSD.org>2015-01-31 19:32:14 +0000
commit7836352b50ed9a6eb4dd72604e7cb42472a91484 (patch)
tree4edc5f6a6f697cb6c391fc6f0800ce835ba4024d /sys/arm/ti/ti_gpio.c
parent79215b4a3ddebcb7f81400259561970873716898 (diff)
downloadsrc-7836352b50ed9a6eb4dd72604e7cb42472a91484.tar.gz
src-7836352b50ed9a6eb4dd72604e7cb42472a91484.zip
Implement GPIO_GET_BUS() method for all GPIO drivers.
Add helper routines to deal with attach and detach of gpiobus and gpioc devices that are common to all drivers.
Notes
Notes: svn path=/head/; revision=277996
Diffstat (limited to 'sys/arm/ti/ti_gpio.c')
-rw-r--r--sys/arm/ti/ti_gpio.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c
index 8874ff35046e..63680c647157 100644
--- a/sys/arm/ti/ti_gpio.c
+++ b/sys/arm/ti/ti_gpio.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_prcm.h>
#include <dev/fdt/fdt_common.h>
+#include <dev/gpio/gpiobusvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -309,6 +310,16 @@ ti_gpio_intr_status(struct ti_gpio_softc *sc, unsigned int bank)
return (reg);
}
+static device_t
+ti_gpio_get_bus(device_t dev)
+{
+ struct ti_gpio_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ return (sc->sc_busdev);
+}
+
/**
* ti_gpio_pin_max - Returns the maximum number of GPIO pins
* @dev: gpio device handle
@@ -815,12 +826,13 @@ ti_gpio_attach(device_t dev)
}
}
}
+ sc->sc_busdev = gpiobus_attach_bus(dev);
+ if (sc->sc_busdev == NULL) {
+ ti_gpio_detach(dev);
+ return (ENXIO);
+ }
- /* Finish of the probe call */
- device_add_child(dev, "gpioc", -1);
- device_add_child(dev, "gpiobus", -1);
-
- return (bus_generic_attach(dev));
+ return (0);
}
/**
@@ -849,7 +861,7 @@ ti_gpio_detach(device_t dev)
if (sc->sc_mem_res[i] != NULL)
ti_gpio_intr_clr(sc, i, 0xffffffff);
}
- bus_generic_detach(dev);
+ gpiobus_detach_bus(dev);
if (sc->sc_events)
free(sc->sc_events, M_DEVBUF);
if (sc->sc_irq_polarity)
@@ -1065,6 +1077,7 @@ static device_method_t ti_gpio_methods[] = {
DEVMETHOD(device_detach, ti_gpio_detach),
/* GPIO protocol */
+ DEVMETHOD(gpio_get_bus, ti_gpio_get_bus),
DEVMETHOD(gpio_pin_max, ti_gpio_pin_max),
DEVMETHOD(gpio_pin_getname, ti_gpio_pin_getname),
DEVMETHOD(gpio_pin_getflags, ti_gpio_pin_getflags),