Linux Userspace GPIO Interrupts using sysfs

lgm42 picture lgm42 · Jan 4, 2012 · Viewed 9.9k times · Source

I would like to use interrupts with GPIO on userspace using sysfs. I use these commands :

[root@at91]:gpio109 > echo 109 > export
[root@at91]:gpio109 > cd gpio109/
[root@at91]:gpio109 > ll
-rw-r--r--    1 root     0            4096 Jan  1 00:17 direction
drwxr-xr-x    2 root     0               0 Jan  1 00:17 power
lrwxrwxrwx    1 root     0               0 Jan  1 00:17 subsystem -> ../../gpio
-rw-r--r--    1 root     0            4096 Jan  1 00:17 uevent
-rw-r--r--    1 root     0            4096 Jan  1 00:17 value

The gpio works well but I can't use interrupts. I read everywhere i must have an edge file to poll this file. But on my system this file doesn't exist. I made a lot of tries to find a solution but remain unsuccessfull.

My target is an AT91SAM9263 on linux kernel 2.6.30.

At the boot of my board I got this message on interrupts :

AT91: 160 gpio irqs in 5 banks

which show that the function at91_gpio_irq_setup() is well executed.

Have you any idea ?

Answer

gby picture gby · Jan 9, 2012

The "edge" file only exists if that GPIO pin can be configured as a an interrupt generting pin. See: http://www.mjmwired.net/kernel/Documentation/gpio.txt#634.

Since you don't see it, it means the driver and possibly the hardware do not support using that GPIO pin for interrupt source.