From ff77c352ae17768c61cfc36357f0a3904552f11c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= Date: Tue, 22 Sep 2009 16:46:38 -0700 Subject: gpiolib: allow poll() on value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many gpio chips allow to generate interrupts when the value of a pin changes. This patch gives usermode application the opportunity to make use of this feature by calling poll(2) on the /sys/class/gpio/gpioN/value sysfs file. The edge to trigger can be set in the edge file in the same directory. Possible values are "none", "rising", "falling", and "both". Using level triggers is not possible with current sysfs since nothing changes the GPIO value (and the IRQ keeps triggering). Edge triggering will "just work". Note that if there was an event between read() and poll(), the poll() returns immediately. Also note that this version only supports true GPIO interrupts. Some later patch might be able to synthesize this behavior by timer-driven polling; some systems seem to need that. [dbrownell@users.sourceforge.net: align ids to 16 bit ids; whitespace] Signed-off-by: Daniel Glöckner Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/gpio.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Documentation/gpio.txt') diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt index 566edaa56a53..fa4dc077ae0e 100644 --- a/Documentation/gpio.txt +++ b/Documentation/gpio.txt @@ -524,6 +524,13 @@ and have the following read/write attributes: is configured as an output, this value may be written; any nonzero value is treated as high. + "edge" ... reads as either "none", "rising", "falling", or + "both". Write these strings to select the signal edge(s) + that will make poll(2) on the "value" file return. + + This file exists only if the pin can be configured as an + interrupt generating input pin. + GPIO controllers have paths like /sys/class/gpio/chipchip42/ (for the controller implementing GPIOs starting at #42) and have the following read-only attributes: -- cgit v1.2.2