summaryrefslogtreecommitdiff
path: root/target/linux/generic-2.6/files/include
diff options
context:
space:
mode:
authorClaudio Mignanti <c.mignanti@gmail.com>2010-06-13 13:27:06 +0000
committerClaudio Mignanti <c.mignanti@gmail.com>2010-06-13 13:27:06 +0000
commit35ff4c9aa8b3c0d8982512187a8112d51c533e85 (patch)
treef9692d7cf9f65cdcf00877a688e315dce0ba18ee /target/linux/generic-2.6/files/include
parentfb941964627b43473fa4dec2645ccc9f2df16f8a (diff)
downloadmtk-20170518-35ff4c9aa8b3c0d8982512187a8112d51c533e85.zip
mtk-20170518-35ff4c9aa8b3c0d8982512187a8112d51c533e85.tar.gz
mtk-20170518-35ff4c9aa8b3c0d8982512187a8112d51c533e85.tar.bz2
Extend the gpio device driver (#5671)
SVN-Revision: 21787
Diffstat (limited to 'target/linux/generic-2.6/files/include')
-rw-r--r--target/linux/generic-2.6/files/include/linux/gpio_dev.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/target/linux/generic-2.6/files/include/linux/gpio_dev.h b/target/linux/generic-2.6/files/include/linux/gpio_dev.h
index 3f3c9c7..a2a4b51 100644
--- a/target/linux/generic-2.6/files/include/linux/gpio_dev.h
+++ b/target/linux/generic-2.6/files/include/linux/gpio_dev.h
@@ -1,11 +1,42 @@
-#ifndef _GPIODEV_H__
-#define _GPIODEV_H__
+#ifndef _GPIO_DEV_H__
+#define _GPIO_DEV_H__
+
+/*********************************************************************
+ *
+ * This Linux kernel header is expanded from the original driver
+ * (gpio_dev) by John Crispin. It provides an ioctl based interface to
+ * GPIO pins via the /dev/gpio char device and gpiolib within the kernel.
+ * The third argument to each ioctl is the GPIO pin number.
+ *
+ * This driver has been tested with lk 2.6.31 and works. The original
+ * driver fails quietly with this version. The protocol is now a bit
+ * different: the ioctl(fd, GPIO_REQUEST, <pin>) should be called
+ * after the open("/dev/gpio", O_RDWR) to determine if the <pin> is
+ * already in use. If the ioctl is successful (i.e. returns 0 for not
+ * in use) then the <pin> is claimed by this driver and
+ * ioctl(fd, GPIO_FREE, <pin>) should be called prior to close(fd) .
+ *
+ * See <kernel_source>/Documentation/gpio.txt
+ * Note that kernel designers prefer the use of the sysfs gpio interface.
+ * This char driver is easier to use from code and faster.
+ ********************************************************************/
+
+/* This header can be included in both the user and kernel spaces */
+/* The _IO macro is defined in sys/ioctl.h */
#define IOC_GPIODEV_MAGIC 'B'
+
#define GPIO_GET _IO(IOC_GPIODEV_MAGIC, 10)
#define GPIO_SET _IO(IOC_GPIODEV_MAGIC, 11)
#define GPIO_CLEAR _IO(IOC_GPIODEV_MAGIC, 12)
#define GPIO_DIR_IN _IO(IOC_GPIODEV_MAGIC, 13)
#define GPIO_DIR_OUT _IO(IOC_GPIODEV_MAGIC, 14)
+ /* Sets the direction out and clears the <pin> (low) */
+
+#define GPIO_DIR_HIGH _IO(IOC_GPIODEV_MAGIC, 15)
+ /* Sets the direction out and sets the <pin> (high) */
+#define GPIO_REQUEST _IO(IOC_GPIODEV_MAGIC, 16)
+#define GPIO_FREE _IO(IOC_GPIODEV_MAGIC, 17)
+#define GPIO_CAN_SLEEP _IO(IOC_GPIODEV_MAGIC, 18)
#endif