summaryrefslogtreecommitdiffstats
path: root/sys/arm
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2015-02-14 21:16:19 +0000
committerloos <loos@FreeBSD.org>2015-02-14 21:16:19 +0000
commita7a8c39e00df26eda21597ddbe0f587ced4375a8 (patch)
treea2bdaaa92bec82c663e0a841ddfdce165ac2ebf1 /sys/arm
parentfd8cd0a9634bc701a7e4e2431a43432b23767400 (diff)
downloadFreeBSD-src-a7a8c39e00df26eda21597ddbe0f587ced4375a8.zip
FreeBSD-src-a7a8c39e00df26eda21597ddbe0f587ced4375a8.tar.gz
MFC r274670, r274671, r276168:
Moves all the duplicate code to a single function. Verify for invalid modes and unwanted flags before pass the new flags to driver. Make gpio_default_map_gpios() static. No functional changes. Improves the GPIO API description a little bit. gpio_pin_max must return the maximum supported pin number and not the total number of pins on the system.
Diffstat (limited to 'sys/arm')
-rw-r--r--sys/arm/allwinner/a10_gpio.c14
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_gpio.c14
-rw-r--r--sys/arm/freescale/imx/imx_gpio.c10
-rw-r--r--sys/arm/freescale/vybrid/vf_gpio.c9
-rw-r--r--sys/arm/rockchip/rk30xx_gpio.c14
-rw-r--r--sys/arm/samsung/exynos/exynos5_pad.c9
-rw-r--r--sys/arm/ti/ti_gpio.c10
-rw-r--r--sys/arm/xscale/ixp425/avila_gpio.c10
-rw-r--r--sys/arm/xscale/ixp425/cambria_gpio.c9
9 files changed, 1 insertions, 98 deletions
diff --git a/sys/arm/allwinner/a10_gpio.c b/sys/arm/allwinner/a10_gpio.c
index a532106..23bf399 100644
--- a/sys/arm/allwinner/a10_gpio.c
+++ b/sys/arm/allwinner/a10_gpio.c
@@ -302,20 +302,6 @@ a10_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (i >= sc->sc_gpio_npins)
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->sc_gpio_pins[i].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together. */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
- /* Can't mix pull-up/pull-down together. */
- if ((flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) ==
- (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN))
- return (EINVAL);
-
a10_gpio_pin_configure(sc, &sc->sc_gpio_pins[i], flags);
return (0);
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
index a8903ee..48f45de 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
@@ -399,20 +399,6 @@ bcm_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (bcm_gpio_pin_is_ro(sc, pin))
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->sc_gpio_pins[i].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together. */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
- /* Can't mix pull-up/pull-down together. */
- if ((flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) ==
- (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN))
- return (EINVAL);
-
bcm_gpio_pin_configure(sc, &sc->sc_gpio_pins[i], flags);
return (0);
diff --git a/sys/arm/freescale/imx/imx_gpio.c b/sys/arm/freescale/imx/imx_gpio.c
index b365489..c23f75b 100644
--- a/sys/arm/freescale/imx/imx_gpio.c
+++ b/sys/arm/freescale/imx/imx_gpio.c
@@ -268,18 +268,8 @@ imx51_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (i >= sc->gpio_npins)
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->gpio_pins[i].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
imx51_gpio_pin_configure(sc, &sc->gpio_pins[i], flags);
-
return (0);
}
diff --git a/sys/arm/freescale/vybrid/vf_gpio.c b/sys/arm/freescale/vybrid/vf_gpio.c
index ab6274e..ab4a18b 100644
--- a/sys/arm/freescale/vybrid/vf_gpio.c
+++ b/sys/arm/freescale/vybrid/vf_gpio.c
@@ -312,15 +312,6 @@ vf_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (i >= sc->gpio_npins)
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->gpio_pins[i].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
vf_gpio_pin_configure(sc, &sc->gpio_pins[i], flags);
return (0);
diff --git a/sys/arm/rockchip/rk30xx_gpio.c b/sys/arm/rockchip/rk30xx_gpio.c
index fc24947c..5c7dc99 100644
--- a/sys/arm/rockchip/rk30xx_gpio.c
+++ b/sys/arm/rockchip/rk30xx_gpio.c
@@ -318,20 +318,6 @@ rk30_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (i >= sc->sc_gpio_npins)
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->sc_gpio_pins[i].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together. */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
- /* Can't mix pull-up/pull-down together. */
- if ((flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) ==
- (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN))
- return (EINVAL);
-
rk30_gpio_pin_configure(sc, &sc->sc_gpio_pins[i], flags);
return (0);
diff --git a/sys/arm/samsung/exynos/exynos5_pad.c b/sys/arm/samsung/exynos/exynos5_pad.c
index 73435fa..a00e458 100644
--- a/sys/arm/samsung/exynos/exynos5_pad.c
+++ b/sys/arm/samsung/exynos/exynos5_pad.c
@@ -643,15 +643,6 @@ pad_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (i >= sc->gpio_npins)
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->gpio_pins[i].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
pad_pin_configure(sc, &sc->gpio_pins[i], flags);
return (0);
diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c
index 707634e..ee38247 100644
--- a/sys/arm/ti/ti_gpio.c
+++ b/sys/arm/ti/ti_gpio.c
@@ -456,16 +456,6 @@ ti_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
uint32_t mask = (1UL << (pin % PINS_PER_BANK));
uint32_t reg_val;
- /* Sanity check the flags supplied are valid, i.e. not input and output */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) == 0x0000)
- return (EINVAL);
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
- if ((flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) ==
- (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN))
- return (EINVAL);
-
TI_GPIO_LOCK(sc);
/* Sanity check the pin number is valid */
diff --git a/sys/arm/xscale/ixp425/avila_gpio.c b/sys/arm/xscale/ixp425/avila_gpio.c
index 48f970d..4a2d1e9 100644
--- a/sys/arm/xscale/ixp425/avila_gpio.c
+++ b/sys/arm/xscale/ixp425/avila_gpio.c
@@ -220,16 +220,8 @@ avila_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (pin >= IXP4XX_GPIO_PINS || !(sc->sc_valid & mask))
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->sc_pins[pin].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
avila_gpio_pin_configure(sc, &sc->sc_pins[pin], flags);
+
return (0);
}
diff --git a/sys/arm/xscale/ixp425/cambria_gpio.c b/sys/arm/xscale/ixp425/cambria_gpio.c
index baa3483..7a773db 100644
--- a/sys/arm/xscale/ixp425/cambria_gpio.c
+++ b/sys/arm/xscale/ixp425/cambria_gpio.c
@@ -317,15 +317,6 @@ cambria_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
if (pin >= GPIO_PINS)
return (EINVAL);
- /* Check for unwanted flags. */
- if ((flags & sc->sc_pins[pin].gp_caps) != flags)
- return (EINVAL);
-
- /* Can't mix input/output together */
- if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
- (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
- return (EINVAL);
-
GPIO_LOCK(sc);
sc->sc_pins[pin].gp_flags = flags;
OpenPOWER on IntegriCloud