Skip to contentSkip to conversation

gpio: at91: Fix pullup/pulldown configuration on PIO3

PATCH In review Marek Vasut 2 participants 4 messages May 4, 2016 – Jun 12, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Cc Andreas Bie?mann <[email protected]>
Cc Josh Wu <[email protected]>
Cc Simon Glass <[email protected]>
---
 drivers/gpio/at91_gpio.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpio/at91_gpio.c +8 -3
index 75a32ee..8e52e3d 100644
@@ -59,6 +59,11 @@ int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup)
 {
 	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 @@ int at91_set_pio_pulldown(unsigned port, unsigned pin, int is_on)
 
 	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);
 	}
 
Signature · 1 line
2.7.0
#1 lore raw

PATCH 1/1 gpio: at91: Fix pullup/pulldown configuration on PIO3

Quoted 11 lines · Marek Vasut

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.

Cc Andreas Bie?mann <[email protected]>
Cc Josh Wu <[email protected]>
Cc Simon Glass <[email protected]>
#2 lore raw

PATCH 1/1 gpio: at91: Fix pullup/pulldown configuration on PIO3

In reply to Marek Vasut
Quoted 11 lines · Marek Vasut

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.

Cc Andreas Bie?mann <[email protected]>
Cc Josh Wu <[email protected]>
Cc Simon Glass <[email protected]>
Quoted 35 lines
---
 drivers/gpio/at91_gpio.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpio/at91_gpio.c +8 -3
index 75a32ee..8e52e3d 100644
@@ -59,6 +59,11 @@ int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup)
 {
 	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 @@ int at91_set_pio_pulldown(unsigned port, unsigned pin, int is_on)
 
 	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);
 	}
 
#3 lore raw
In reply to Marek Vasut

Dear Marek Vasut,

Quoted 7 lines · Marek Vasut

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.

Quoted 8 lines

---
drivers/gpio/at91_gpio.c | 11 ++++++++---

1 file changed, 8 insertions(+), 3 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann