gpio: at91: Fix pullup/pulldown configuration on PIO3
On systems with PIO3 (SAMA5D3/D4/..), the pullup and pulldown configuration
is mutualy exclusive. This patch assures that the opposite pull resistor gets
disabled before the requested pull resistor is enabled. This changes behavior
of at91_set_pio_pulldown() such that the pullup is only disabled if pulldown
is to be enabled. This changes behavior of at91_set_pio_pullup() such that
the pulldown is only disabled if pullup is to be enabled.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Andreas Bießmann <andreas.devel@googlemail.com>
Cc: Josh Wu <josh.wu@atmel.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Andreas Bießmann <andreas@biessmann.org>
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 75a32ee..8e52e3d 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -59,6 +59,11 @@
{
struct at91_port *at91_port = at91_pio_get_port(port);
+#if defined(CPU_HAS_PIO3)
+ if (use_pullup)
+ at91_set_pio_pulldown(port, pin, 0);
+#endif
+
if (at91_port && (pin < GPIO_PER_BANK))
at91_set_port_pullup(at91_port, pin, use_pullup);
@@ -305,10 +310,10 @@
if (at91_port && (pin < GPIO_PER_BANK)) {
mask = 1 << pin;
- writel(mask, &at91_port->pudr);
- if (is_on)
+ if (is_on) {
+ at91_set_pio_pullup(port, pin, 0);
writel(mask, &at91_port->ppder);
- else
+ } else
writel(mask, &at91_port->ppddr);
}