summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-02-12 00:53:11 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 09:48:34 -0800
commit4c20386c8d0719b42503efe65abe47ad3fb3d711 (patch)
tree9ec169c4c8548a9c2ac5c258c15020c346b969e1 /include
parent9794f33ddedd878dd92fcf8b4834391840366919 (diff)
downloadlinux-3.10-4c20386c8d0719b42503efe65abe47ad3fb3d711.tar.gz
linux-3.10-4c20386c8d0719b42503efe65abe47ad3fb3d711.tar.bz2
linux-3.10-4c20386c8d0719b42503efe65abe47ad3fb3d711.zip
[PATCH] GPIO core
This defines a simple and minimalist programming interface for GPIO APIs: - Documentation/gpio.txt ... describes things (read it) - include/asm-arm/gpio.h ... defines the ARM hook, which just punts to <asm/arch/gpio.h> for any implementation - include/asm-generic/gpio.h ... implement "can sleep" variants as calling the normal ones, for systems that don't handle i2c expanders. The immediate need for such a cross-architecture API convention is to support drivers that work the same on AT91 ARM and AVR32 AP7000 chips, which embed many of the same controllers but have different CPUs. However, several other users have been reported, including a driver for a hardware watchdog chip and some handhelds.org multi-CPU button drivers. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/asm-arm/gpio.h7
-rw-r--r--include/asm-generic/gpio.h25
2 files changed, 32 insertions, 0 deletions
diff --git a/include/asm-arm/gpio.h b/include/asm-arm/gpio.h
new file mode 100644
index 00000000000..fff4f800ee4
--- /dev/null
+++ b/include/asm-arm/gpio.h
@@ -0,0 +1,7 @@
+#ifndef _ARCH_ARM_GPIO_H
+#define _ARCH_ARM_GPIO_H
+
+/* not all ARM platforms necessarily support this API ... */
+#include <asm/arch/gpio.h>
+
+#endif /* _ARCH_ARM_GPIO_H */
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
new file mode 100644
index 00000000000..2d0aab1d861
--- /dev/null
+++ b/include/asm-generic/gpio.h
@@ -0,0 +1,25 @@
+#ifndef _ASM_GENERIC_GPIO_H
+#define _ASM_GENERIC_GPIO_H
+
+/* platforms that don't directly support access to GPIOs through I2C, SPI,
+ * or other blocking infrastructure can use these wrappers.
+ */
+
+static inline int gpio_cansleep(unsigned gpio)
+{
+ return 0;
+}
+
+static inline int gpio_get_value_cansleep(unsigned gpio)
+{
+ might_sleep();
+ return gpio_get_value(gpio);
+}
+
+static inline void gpio_set_value_cansleep(unsigned gpio, int value)
+{
+ might_sleep();
+ gpio_set_value(gpio, value);
+}
+
+#endif /* _ASM_GENERIC_GPIO_H */