[PATCH 1/2] gpio: bgpio: Teach gpio-generic about the pinctrl subsystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The basic MMIO gpio driver is unaware of the pinctrl subsystem,
and this lack of pinctrl awareness extends to drivers using bgpio
unless the drivers handle pinctrl interaction by overriding the
request and free methods of gpiochip.

Since pinctrl consumer interfaces are stubbed when pinctrl is not
enabled this implementation is very simple, and there is no
behaviour change when pinctrl is not enabled.

Tested on picoXcell pc3x3 using gpio-dwapb.

Signed-off-by: Michael van der Westhuizen <michael@xxxxxxxxxxxxxxxx>
---
 drivers/gpio/gpio-generic.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index b92a690..be28ba2 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -58,6 +58,7 @@ o        `                     ~~~~\___/~~~~    ` controller in FPGA is ,.`
 #include <linux/io.h>
 #include <linux/gpio.h>
 #include <linux/slab.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/basic_mmio_gpio.h>
@@ -467,11 +468,17 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc,
 static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin)
 {
 	if (gpio_pin < chip->ngpio)
-		return 0;
+		return pinctrl_request_gpio(chip->base + gpio_pin);
 
 	return -EINVAL;
 }
 
+static void bgpio_free(struct gpio_chip *chip, unsigned gpio_pin)
+{
+	if (gpio_pin < chip->ngpio)
+		pinctrl_free_gpio(chip->base + gpio_pin);
+}
+
 int bgpio_remove(struct bgpio_chip *bgc)
 {
 	gpiochip_remove(&bgc->gc);
@@ -499,6 +506,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,
 	bgc->gc.base = -1;
 	bgc->gc.ngpio = bgc->bits;
 	bgc->gc.request = bgpio_request;
+	bgc->gc.free = bgpio_free;
 
 	ret = bgpio_setup_io(bgc, dat, set, clr);
 	if (ret)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux