Re: [PATCH 1/4 resend] [x86] Add generic GPIO support to x86

David Brownell
2008-02-13T23:25:26Z

On Wednesday 13 February 2008, Andrew Morton wrote:
> Someone please fix.

This is what I was using purely for test builds ... most x86 hardware
actually has no GPIOs, and I sure don't have any of the "unusual" x86
platforms here, so I'd not want to see this version merge. Someone
more clued in on how x86 handles what ARM does with e.g. <asm/arch/...>
should make a better patch.

(And my vote is to **NOT** use the "-I..." magic that PowerPC uses,
that's just confusing as all get-out. And not needed.)

> It would be more modern to have a <linux/gpio.h> which takes care of
> cruddy details, but it's getting too late for that.

That could be added eventually ... if the platform has GPIO support
it could include the <asm/gpio.h> else it could define all the calls
as error-returning inlines.

- Dave

========= CUT HERE
DEBUG ONLY -- make X86_PC use gpiolib.

It's not clear to me how the various x86-ish platforms should
be made to work here, since there seems to be no convention
that each platform type has its own <asm/arch/...> subdir.

---
arch/x86/Kconfig | 2 ++
include/asm-x86/gpio.h | 19 ++++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)

--- g26.orig/arch/x86/Kconfig 2008-02-10 16:06:30.000000000 -0800
+++ g26/arch/x86/Kconfig 2008-02-10 16:09:44.000000000 -0800
@@ -228,6 +228,8 @@ choice

config X86_PC
bool "PC-compatible"
+ select GENERIC_GPIO
+ select HAVE_GPIO_LIB
help
Choose this option if your computer is a standard PC or compatible.

--- g26.orig/include/asm-x86/gpio.h 2008-02-10 16:06:30.000000000 -0800
+++ g26/include/asm-x86/gpio.h 2008-02-10 16:09:44.000000000 -0800
@@ -1,6 +1,23 @@
#ifndef _ASM_I386_GPIO_H
#define _ASM_I386_GPIO_H

-#include <gpio.h>
+// #include <gpio.h>
+
+#include <asm-generic/gpio.h> /* cansleep wrappers */
+
+#define gpio_get_value __gpio_get_value
+#define gpio_set_value __gpio_set_value
+#define gpio_cansleep __gpio_cansleep
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+ return -ENOSYS;
+}
+
+static inline int irq_to_gpio(unsigned irq)
+{
+ return -EINVAL;
+}
+

#endif /* _ASM_I386_GPIO_H */