Skip to contentSkip to conversation

Latest gpio gumph

DISCUSSION Applied Ben Nizette 3 participants 8 messages May 28, 2008 – Jun 10, 2008

lore
Share & tools
lore
#0 lore raw

Hey David,

Have you got a git/quilt repo somewhere with all the latest gpiolib (and gpio framework) stuff glued in? I've seen most of it hit -mm but developing against -mm on (especially on obscure archs like AVR32 as I do) is always fraught.

Of course I do build and test -mm on avr32 as regularly as I can (and submit patches for the inevitable munging it's taken) but I don't really want to develop against it.

Thx,

	--Ben.
#1 lore raw
Quoted 6 lines · Ben Nizette

Hey David,

Have you got a git/quilt repo somewhere with all the latest gpiolib (and gpio framework) stuff glued in? I've seen most of it hit -mm but developing against -mm on (especially on obscure archs like AVR32 as I do) is always fraught.

All the relevant stuff is now upstream (2.6.26-rc4) except:

- the userspace sysfs interface (which is in MM, and ISTR you were cc'd on that)

- an avr32 patch, appended (no response on the avr32 list)

Nothing else touches core code; if you're using AVR32, then you won't care about at91 gpiolib and inlining support, or the patch sent this AM on LKML (which I've not yet reviewed).

- Dave

====== CUT HERE
From: David Brownell <[email protected]>
Subject: AVR32: minor GPIO handling updates

* gpio_direction_output() should disable the pullups just like at32_select_gpio(... AT32_GPIOF_OUTPUT) does, for consistency between those alternative initialization paths.

* On the odd chance some code uses a pin as a GPIO IRQ without calling gpio_request() or gpio_direction_input(), the debug dump should still show its pin status.

---
 arch/avr32/mach-at32ap/pio.c |    3 +++
 1 files changed, 3 insertions(+)
arch/avr32/mach-at32ap/pio.c +3 -0
@@ -191,6 +191,7 @@ static int direction_output(struct gpio_
 		return -EINVAL;
 
 	gpio_set(chip, offset, value);
+	pio_writel(pio, PUDR, mask);
 	pio_writel(pio, OER, mask);
 	return 0;
 }
@@ -318,6 +319,8 @@ static void pio_bank_show(struct seq_fil
 		const char *label;
 
 		label = gpiochip_is_requested(chip, i);
+		if (!label && (imr & mask))
+			label = "[irq]";
 		if (!label)
 			continue;
 
#2 lore raw
Quoted 8 lines · David Brownell
Quoted 6 lines · Ben Nizette

Hey David,

Have you got a git/quilt repo somewhere with all the latest gpiolib (and gpio framework) stuff glued in? I've seen most of it hit -mm but developing against -mm on (especially on obscure archs like AVR32 as I do) is always fraught.

Quoted 4 lines

All the relevant stuff is now upstream (2.6.26-rc4) except:

- the userspace sysfs interface (which is in MM, and ISTR you were cc'd on that)

Yup, indeed.

Quoted 6 lines

- an avr32 patch, appended (no response on the avr32 list)

Nothing else touches core code; if you're using AVR32, then you won't care about at91 gpiolib and inlining support, or the patch sent this AM on LKML (which I've not yet reviewed).

Righteo, thanks.

	--Ben.
Quoted 41 lines

- Dave

====== CUT HERE
From: David Brownell <[email protected]>
Subject: AVR32: minor GPIO handling updates

* gpio_direction_output() should disable the pullups just like at32_select_gpio(... AT32_GPIOF_OUTPUT) does, for consistency between those alternative initialization paths.

* On the odd chance some code uses a pin as a GPIO IRQ without calling gpio_request() or gpio_direction_input(), the debug dump should still show its pin status.

---
 arch/avr32/mach-at32ap/pio.c |    3 +++
 1 files changed, 3 insertions(+)
arch/avr32/mach-at32ap/pio.c +3 -0
@@ -191,6 +191,7 @@ static int direction_output(struct gpio_
 		return -EINVAL;
 
 	gpio_set(chip, offset, value);
+	pio_writel(pio, PUDR, mask);
 	pio_writel(pio, OER, mask);
 	return 0;
 }
@@ -318,6 +319,8 @@ static void pio_bank_show(struct seq_fil
 		const char *label;
 
 		label = gpiochip_is_requested(chip, i);
+		if (!label && (imr & mask))
+			label = "[irq]";
 		if (!label)
 			continue;
 
#3 lore raw
In reply to David Brownell
Quoted 1 line · David Brownell

- an avr32 patch, appended (no response on the avr32 list)

Sorry about the lack of response.

I'm not all that enthusiastic about this patch though...

Quoted 6 lines

From: David Brownell <[email protected]>
Subject: AVR32: minor GPIO handling updates

* gpio_direction_output() should disable the pullups just like at32_select_gpio(... AT32_GPIOF_OUTPUT) does, for consistency between those alternative initialization paths.

But then we need to keep track of whether pullups used to be enabled so that we can re-enable it in gpio_direction_input(), don't we?

I can't see the harm of keeping the pullup enabled while the port is configured as output. For consistency, I'd rather honor the pullup flag in at32_select_gpio() regardless of AT32_GPIOF_OUTPUT.

Quoted 3 lines

* On the odd chance some code uses a pin as a GPIO IRQ without calling gpio_request() or gpio_direction_input(), the debug dump should still show its pin status.

Hmm. I guess that makes sense, though I would be lying if I said I care all that much. I think gpiolib is going pretty far to accommodate buggy drivers that don't call gpio_request() as it is.

Haavard

#4 lore raw
Quoted 7 lines · Haavard Skinnemoen
Quoted 4 lines

* gpio_direction_output() should disable the pullups just like at32_select_gpio(... AT32_GPIOF_OUTPUT) does, for consistency between those alternative initialization paths.

But then we need to keep track of whether pullups used to be enabled so that we can re-enable it in gpio_direction_input(), don't we?

"Need"? I'd figure that changing direction like that would be uncommon without something determining signal level (like an external driver or pullup) ... and if nothing did so, then it'd be important to use the AVR32-private API with pullup control.

Quoted 3 lines

I can't see the harm of keeping the pullup enabled while the port is configured as output. For consistency, I'd rather honor the pullup flag in at32_select_gpio() regardless of AT32_GPIOF_OUTPUT.

I guess I don't like the idea of facilitating the constant current waste that implies if output is being driven low. Even if it's not a huge current waste! (These pullups being a lot weaker than I'd have expected, at typically 190 kOhm.) No big deal here I guess.

For an open drain output it's probably less of an issue, unless there are too many pullups.

Quoted 7 lines
Quoted 3 lines

* On the odd chance some code uses a pin as a GPIO IRQ without calling gpio_request() or gpio_direction_input(), the debug dump should still show its pin status.

Hmm. I guess that makes sense, though I would be lying if I said I care all that much. I think gpiolib is going pretty far to accommodate buggy drivers that don't call gpio_request() as it is.

For diagnostic/debug code, I'd say it's reasonably useful to cope with buglets like that.

I actually observed that happening. Setup code was passing the irq to the driver, and everything worked fine because the reset default was fine. I happened to notice that /sys/kernel/debug/gpio output didn't match up to /proc/interrupts (bug) ... but it would have been much faster to see the bug if the listing for that pin had a "?" label showing that it hadn't been requested.

- Dave

#5 lore raw
Quoted 6 lines · David Brownell
Quoted 5 lines · Haavard Skinnemoen
Quoted 4 lines

* gpio_direction_output() should disable the pullups just like at32_select_gpio(... AT32_GPIOF_OUTPUT) does, for consistency between those alternative initialization paths.

Quoted 7 lines
Quoted 2 lines

But then we need to keep track of whether pullups used to be enabled so that we can re-enable it in gpio_direction_input(), don't we?

"Need"? I'd figure that changing direction like that would be uncommon without something determining signal level (like an external driver or pullup) ... and if nothing did so, then it'd be important to use the AVR32-private API with pullup control.

If you enable the internal pullup during port configuration, it should stay that way, I think. But I think at32_select_gpio() should be fixed so that when the user specifies AT32_GPIOF_OUTPUT | AT32_GPIOF_PULLUP, the pullup will be turned on.

Quoted 8 lines
Quoted 3 lines

I can't see the harm of keeping the pullup enabled while the port is configured as output. For consistency, I'd rather honor the pullup flag in at32_select_gpio() regardless of AT32_GPIOF_OUTPUT.

I guess I don't like the idea of facilitating the constant current waste that implies if output is being driven low. Even if it's not a huge current waste! (These pullups being a lot weaker than I'd have expected, at typically 190 kOhm.) No big deal here I guess.

I don't think we're talking about a lot of pins that need to switch direction on the fly, and the pullup is very weak as you say. And a floating input might waste a lot more power than the pullup ever will.

Quoted 2 lines

For an open drain output it's probably less of an issue, unless there are too many pullups.

The board designer should know this and set the AT32_GPIOF_PULLUP flag as appropriate.

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

* On the odd chance some code uses a pin as a GPIO IRQ without calling gpio_request() or gpio_direction_input(), the debug dump should still show its pin status.

Hmm. I guess that makes sense, though I would be lying if I said I care all that much. I think gpiolib is going pretty far to accommodate buggy drivers that don't call gpio_request() as it is.

For diagnostic/debug code, I'd say it's reasonably useful to cope with buglets like that.

Quoted 6 lines

I actually observed that happening. Setup code was passing the irq to the driver, and everything worked fine because the reset default was fine. I happened to notice that /sys/kernel/debug/gpio output didn't match up to /proc/interrupts (bug) ... but it would have been much faster to see the bug if the listing for that pin had a "?" label showing that it hadn't been requested.

Yes, but it will only catch that particular case, not missing gpio_request() calls in general.

I'm not really opposed to the second change; I would have applied it if it came separately. But I think the first change is wrong.

Haavard

#6 lore raw

[ Re that one avr32 patch: ]

Quoted 2 lines · Haavard Skinnemoen

I'm not really opposed to the second change; I would have applied it if it came separately. But I think the first change is wrong.

OK, then feel free to strip out the first chunk and just take that.

- Dave

#7 lore raw
Quoted 7 lines · David Brownell

[ Re that one avr32 patch: ]

Quoted 2 lines · Haavard Skinnemoen

I'm not really opposed to the second change; I would have applied it if it came separately. But I think the first change is wrong.

OK, then feel free to strip out the first chunk and just take that.

Applied the patch below. Thanks.

Haavard

Quoted 1 line

From bab0d89419e2d30199420da0af29a8b5662af018 Mon Sep 17 00:00:00 2001

From: David Brownell <[email protected]>
Date: Tue, 10 Jun 2008 13:55:52 +0200
Subject: [PATCH] avr32: minor GPIO handling updates

On the odd chance some code uses a pin as a GPIO IRQ without calling gpio_request() or gpio_direction_input(), the debug dump should still show its pin status.

---
 arch/avr32/mach-at32ap/pio.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/avr32/mach-at32ap/pio.c +2 -0
index 38a8fa3..60da03b 100644
@@ -318,6 +318,8 @@ static void pio_bank_show(struct seq_file *s, struct gpio_chip *chip)
 		const char *label;
 
 		label = gpiochip_is_requested(chip, i);
+		if (!label && (imr & mask))
+			label = "[irq]";
 		if (!label)
 			continue;
 
Signature · 1 line
1.5.5.3