Re: [PATCH] gpio: pxa: make controllers without pinctrl work again

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

 



Hi,

I have to get back to this one. The fall-out that made me implement the patch below in the first place was fixed with the following patch:

  e41f76830d (ARM: pxa: dts: add gpio-ranges to gpio controller)

... but now another issue came up.

To recap, the pxa3xx driver uses the pinctrl-single driver since a while which does not implement a .gpio_set_direction() callback. The pinmux core will simply return 0 in this case, and the pxa3xx gpio driver hence thinks the pinctrl driver did its job and returns as well.

This effectively makes pxa_gpio_direction_{input,output} no-ops. Interestingly, I only noticed that when I tried to use the w1-gpio driver which makes use of gpiolib's open-drain emulation. All other use-cases work just fine.

So the question is how this is supposed to work. I see two options:

1) Apply the patch below, so we don't use use the pinctrl driver on PXA3xx.

2) Change pinmux_gpio_direction() and make it return -ENOSYS or something in case there is no .gpio_set_direction() implementation. I'm not sure whether that's a good idea though, and what the side-effects would be.

Any other ideas?


Thanks,
Daniel


On Friday, May 18, 2018 11:34 PM, Daniel Mack wrote:
Commit a770d946371ec7 ("gpio: pxa: add pin control gpio direction and
request") changed the driver to always call out to the pinctrl generic
functions when a GPIO is requested or its direction is configured.

This is fine as long as the platform facilitates a pinctrl driver or
CONFIG_PINCTRL is not set.

On PXA3xx however, we are now using CONFIG_PINCTRL_SINGLE which is not
linked to the gpio subsystem.

To fix this, introduce a small helper function that tells us whether the
platform may expect a pinctrl driver to be present.

Signed-off-by: Daniel Mack <daniel@xxxxxxxxxx>
Fixes: a770d946371ec7
Cc: Robert Jarzmik <robert.jarzmik@xxxxxxx>
Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
  drivers/gpio/gpio-pxa.c | 35 +++++++++++++++++++++++++++--------
  1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index f480fb896963..e217ebccb0c0 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -241,6 +241,17 @@ int pxa_irq_to_gpio(int irq)
  	return irq_gpio0;
  }
+static bool pxa_gpio_has_pinctrl(void)
+{
+	switch (gpio_type) {
+	case PXA3XX_GPIO:
+		return false;
+
+	default:
+		return true;
+	}
+}
+
  static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
  {
  	struct pxa_gpio_chip *pchip = chip_to_pxachip(chip);
@@ -255,9 +266,11 @@ static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
  	unsigned long flags;
  	int ret;
- ret = pinctrl_gpio_direction_input(chip->base + offset);
-	if (!ret)
-		return 0;
+	if (pxa_gpio_has_pinctrl()) {
+		ret = pinctrl_gpio_direction_input(chip->base + offset);
+		if (!ret)
+			return 0;
+	}
spin_lock_irqsave(&gpio_lock, flags); @@ -282,9 +295,11 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip, writel_relaxed(mask, base + (value ? GPSR_OFFSET : GPCR_OFFSET)); - ret = pinctrl_gpio_direction_output(chip->base + offset);
-	if (ret)
-		return ret;
+	if (pxa_gpio_has_pinctrl()) {
+		ret = pinctrl_gpio_direction_output(chip->base + offset);
+		if (ret)
+			return ret;
+	}
spin_lock_irqsave(&gpio_lock, flags); @@ -348,8 +363,12 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
  	pchip->chip.set = pxa_gpio_set;
  	pchip->chip.to_irq = pxa_gpio_to_irq;
  	pchip->chip.ngpio = ngpio;
-	pchip->chip.request = gpiochip_generic_request;
-	pchip->chip.free = gpiochip_generic_free;
+
+	if (pxa_gpio_has_pinctrl()) {
+		pchip->chip.request = gpiochip_generic_request;
+		pchip->chip.free = gpiochip_generic_free;
+	}
+
  #ifdef CONFIG_OF_GPIO
  	pchip->chip.of_node = np;
  	pchip->chip.of_xlate = pxa_gpio_of_xlate;


--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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