gpio: pxa: disable pinctrl calls for PXA3xx
diff mbox series

Message ID 20180713161538.6622-1-daniel@zonque.org
State New
Headers show
Series
  • gpio: pxa: disable pinctrl calls for PXA3xx
Related show

Commit Message

Daniel Mack July 13, 2018, 4:15 p.m. UTC
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
believes the pinctrl driver did its job and returns as well.

This effectively makes pxa_gpio_direction_{input,output} no-ops.

To fix this, do not call into the pinctrl subsystem for the PXA3xx
platform for now. We can revert this once the pinctrl-single driver
learned to support setting pin directions.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 drivers/gpio/gpio-pxa.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

Comments

Robert Jarzmik July 15, 2018, 8:13 p.m. UTC | #1
Daniel Mack <daniel@zonque.org> writes:

> 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
> believes the pinctrl driver did its job and returns as well.
>
> This effectively makes pxa_gpio_direction_{input,output} no-ops.
>
> To fix this, do not call into the pinctrl subsystem for the PXA3xx
> platform for now. We can revert this once the pinctrl-single driver
> learned to support setting pin directions.
>
> Signed-off-by: Daniel Mack <daniel@zonque.org>
Mmmm yes, too bad a patch to pinctrl-single is not available so far ...
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.

--
Robert
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Daniel Mack July 24, 2018, 2:10 p.m. UTC | #2
On Sunday, July 15, 2018 10:13 PM, Robert Jarzmik wrote:
> Daniel Mack <daniel@zonque.org> writes:
> 
>> 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
>> believes the pinctrl driver did its job and returns as well.
>>
>> This effectively makes pxa_gpio_direction_{input,output} no-ops.
>>
>> To fix this, do not call into the pinctrl subsystem for the PXA3xx
>> platform for now. We can revert this once the pinctrl-single driver
>> learned to support setting pin directions.
>>
>> Signed-off-by: Daniel Mack <daniel@zonque.org>
> Mmmm yes, too bad a patch to pinctrl-single is not available so far ...
> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Linus, WDYT?


Thanks,
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij July 29, 2018, 9:19 p.m. UTC | #3
On Fri, Jul 13, 2018 at 6:15 PM Daniel Mack <daniel@zonque.org> wrote:

> 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
> believes the pinctrl driver did its job and returns as well.
>
> This effectively makes pxa_gpio_direction_{input,output} no-ops.
>
> To fix this, do not call into the pinctrl subsystem for the PXA3xx
> platform for now. We can revert this once the pinctrl-single driver
> learned to support setting pin directions.
>
> Signed-off-by: Daniel Mack <daniel@zonque.org>

Patch applied!

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

Patch
diff mbox series

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 1e66f808051c..2e33fd552899 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;