From: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
drivers/char/Kconfig | 14 ++
drivers/char/Makefile | 1 +
drivers/char/simple-gpio.c | 308 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 323 insertions(+), 0 deletions(-)
create mode 100644 drivers/char/simple-gpio.c
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 47c6be8..dd17d06 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -4,6 +4,20 @@
menu "Character devices"
+config SIMPLE_GPIO
+ tristate "Simple GPIO char interface"
+ depends on GENERIC_GPIO
+ default n
+ help
+ If you say Y here, you will get support for a character device
+ interface to the GPIO pins which will allow you to read and
+ write GPIO values from userspace.
+
+ To compile this driver as a module, choose M here: the module
+ will be called simple-gpio.
+
+ If unsure, it is safe to say Y.
+
config VT
bool "Virtual terminal" if EMBEDDED
depends on !S390
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 5407b76..e087ec1 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
obj-$(CONFIG_GPIO_TB0219) += tb0219.o
obj-$(CONFIG_TELCLOCK) += tlclk.o
+obj-$(CONFIG_SIMPLE_GPIO) += simple-gpio.o
obj-$(CONFIG_MWAVE) += mwave/
obj-$(CONFIG_AGP) += agp/
diff --git a/drivers/char/simple-gpio.c b/drivers/char/simple-gpio.c
new file mode 100644
index 0000000..36204ca
--- /dev/null
+++ b/drivers/char/simple-gpio.c
@@ -0,0 +1,308 @@
+/*
+ * Simple character interface to GPIOs. Allows you to read/write values and
+ * control the direction. Maybe add wakeup when gpio framework supports it ...
+ *
+ * To use, just declare in your board resources:
+ * static struct resource foo_resources[] = {
+ * .start = 0,
+ * ...Hi, Considered putting this in drivers/gpio? Not a real problem, up to you Userspace notification of a GPIO IRQ? Not too 'simple' but very worthwhile. If you're feeling keen (and it doesn't violate the 'simple' in the name) then I think it would be well worth being able to attach a string to each gpio entry in the platform_data and make them available through sysfs. Very few userspace users will know what gpio_id they actually want unless they can see a "PortA-05" tag attached to it somewhere. This is extra-especially true for dynamically allocated gpio ids This don't sit right with me; I reckon an IORESOURCE_GPIO may not be a bad move but that's for a different patch. In the mean time getting the Hmm, a bit of a cleanup regarding messaging is needed IMO. Should your pr_*init macros be accepted somewhere higher up the tree? Either that or dropped, it doesn't seem right wedging them in here. Sure it might cost you a few hundred bytes of RAM but would be nice to Hmm, coding style question marks around a 2- or even 3-entry switch Was it a conscious thing to only allow 1 range of gpios per device? I can imagine that it's quite likely that people are going to want to expose all unused gpios on a SoC to userspace. This is going to mean lots of small ranges split either side of pre-reserved pins and one Making assumptions about the format of a dev_t is Bad. Sure it's a bit of a pain constructing the correct node with MKDEV/MAJOR macros but it's --
I'd expect to see a generic GPIO mechanism like this in drivers/gpio, yes. But it should be a bit more As I said in the other thread, this is what I most dislike about this particular driver: the need for board-specific setup. The need for a character device inode per GPIO could probably be lived with, if that bigger issue were resolved. The userspace GPIO access scenarios which seem most compelling to me involve filling in gaps in board support. Expecting the folk who created those gaps (by overlooking them, or not knowing enough about the system's eventual usage mode) to have enabled resolving them in this way ... seems unwise. :) Building on Ben's comment, it's not just unused SOC GPIOs, it's all the GPIOs on a board, some of which will be from a SOC and others of which will be from external chips. - Dave --
Me, I'm all in favor of getting rid of structural code bloat. A few hundred bytes of such stuff shaved out a dozen drivers on a given platforms would be almost free page saved! :) So I'd be interested in seeing those get submitted ... but as inline functions, not fancy macros. (Once they're submitted, then let the flamage begin ... much less than kernel I18N!) - Dave --
| Francois Romieu | Re: PROBLEM: 2.6.23-rc "NETDEV WATCHDOG: eth0: transmit timed out" |
| Greg Kroah-Hartman | [PATCH 040/196] kobject: add kobject_add_ng function |
| Dave Airlie | [git pull] drm patches for 2.6.27 final |
| john stultz | [PATCH] correct inconsistent ntp interval/tick_length usage |
| Krzysztof Halasa | Re: [PATCH v2] Re: WAN: new PPP code for generic HDLC |
| Dave Jones | odd RTL8139 quirk. |
| Allan Stephens | [PATCH 0/9 net-next-2.6] [TIPC]: System & debug output modifications |
| Francois Romieu | [RFT 0/6] sis190 branch info |
git: | |
| Miklos Vajna | [rfc] git submodules howto |
| Ben Collins | Re: [kernel.org users] [RFD] On deprecating "git-foo" for builtins |
| Jon Smirl | ! [rejected] master -> master (non-fast forward) |
| Evan Carroll | Git-submodule questions |
| Pieter Verberne | File collision while using pkg_add |
| Greg Thomas | Re: Is it possible to fix a stale NFS hadle without rebooting? |
| Didier Wiroth | win32-codecs, avi and amd64 question |
| rancor | How to copy/pipe console buffert to file? |
| Netfilter kernel module | 9 hours ago | Linux kernel |
| serial driver xmit problem | 11 hours ago | Linux kernel |
| Why Windows is better than Linux | 11 hours ago | Linux general |
| How can I see my kernel messages in vt12? | 18 hours ago | Linux kernel |
| Grub | 1 day ago | Linux general |
| vmalloc_fault handling in x86_64 | 1 day ago | Linux kernel |
| epoll_wait()ing on epoll FD | 1 day ago | Linux kernel |
| Framebuffer in x86_64 causes problems to multiseat | 1 day ago | Linux kernel |
| Difference between 2.4 and 2.6 regarding thread creation | 1 day ago | Linux general |
| Compiling gfs2 on kernel 2.6.27 | 2 days ago | Linux kernel |
