aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/Kconfig
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-07-25 04:46:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:30 -0400
commitd8f388d8dc8d4f36539dd37c1fff62cc404ea0fc (patch)
treedf8603775c889f29f8a03c77b9f7913bfd90d296 /drivers/gpio/Kconfig
parent8b6dd986823a8d92ed9f54baa5cef8604d9d9d44 (diff)
gpio: sysfs interface
This adds a simple sysfs interface for GPIOs. /sys/class/gpio /export ... asks the kernel to export a GPIO to userspace /unexport ... to return a GPIO to the kernel /gpioN ... for each exported GPIO #N /value ... always readable, writes fail for input GPIOs /direction ... r/w as: in, out (default low); write high, low /gpiochipN ... for each gpiochip; #N is its first GPIO /base ... (r/o) same as N /label ... (r/o) descriptive, not necessarily unique /ngpio ... (r/o) number of GPIOs; numbered N .. N+(ngpio - 1) GPIOs claimed by kernel code may be exported by its owner using a new gpio_export() call, which should be most useful for driver debugging. Such exports may optionally be done without a "direction" attribute. Userspace may ask to take over a GPIO by writing to a sysfs control file, helping to cope with incomplete board support or other "one-off" requirements that don't merit full kernel support: echo 23 > /sys/class/gpio/export ... will gpio_request(23, "sysfs") and gpio_export(23); use /sys/class/gpio/gpio-23/direction to (re)configure it, when that GPIO can be used as both input and output. echo 23 > /sys/class/gpio/unexport ... will gpio_free(23), when it was exported as above The extra D-space footprint is a few hundred bytes, except for the sysfs resources associated with each exported GPIO. The additional I-space footprint is about two thirds of the current size of gpiolib (!). Since no /dev node creation is involved, no "udev" support is needed. Related changes: * This adds a device pointer to "struct gpio_chip". When GPIO providers initialize that, sysfs gpio class devices become children of that device instead of being "virtual" devices. * The (few) gpio_chip providers which have such a device node have been updated. * Some gpio_chip drivers also needed to update their module "owner" field ... for which missing kerneldoc was added. * Some gpio_chips don't support input GPIOs. Those GPIOs are now flagged appropriately when the chip is registered. Based on previous patches, and discussion both on and off LKML. A Documentation/ABI/testing/sysfs-gpio update is ready to submit once this merges to mainline. [akpm@linux-foundation.org: a few maintenance build fixes] Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> Cc: Greg KH <greg@kroah.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpio/Kconfig')
-rw-r--r--drivers/gpio/Kconfig15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index fced1909cbba..6ec0e35b98e3 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -23,6 +23,21 @@ config DEBUG_GPIO
23 slower. The diagnostics help catch the type of setup errors 23 slower. The diagnostics help catch the type of setup errors
24 that are most common when setting up new platforms or boards. 24 that are most common when setting up new platforms or boards.
25 25
26config GPIO_SYSFS
27 bool "/sys/class/gpio/... (sysfs interface)"
28 depends on SYSFS && EXPERIMENTAL
29 help
30 Say Y here to add a sysfs interface for GPIOs.
31
32 This is mostly useful to work around omissions in a system's
33 kernel support. Those are common in custom and semicustom
34 hardware assembled using standard kernels with a minimum of
35 custom patches. In those cases, userspace code may import
36 a given GPIO from the kernel, if no kernel driver requested it.
37
38 Kernel drivers may also request that a particular GPIO be
39 exported to userspace; this can be useful when debugging.
40
26# put expanders in the right section, in alphabetical order 41# put expanders in the right section, in alphabetical order
27 42
28comment "I2C GPIO expanders:" 43comment "I2C GPIO expanders:"