[beagleboard] GPIO - how to ?

How can I access GPIO pins from userspace, so read or write?
Is there already a kernel driver for Omap35xx and how to work with that?
Help is very much welcome!

Take a look at:

http://source.mvista.com/git/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/gpio.txt;h=18022e249c53dc1ad991d74d160551fa32f32070;hb=HEAD

Philip

On the Ångström demo I've been able to use mmap() and /dev/mem to map
OMAP peripheral memory into my user space application. This way I can
access OMAP registers directly instead of having to go through device
drivers. So far I've
only accessed the GPIO registers so I could play with the user LEDs.

The C code looks something like this:

    int fd = open("/dev/mem", O_RDWR); volatile ulong *A;
    if (fd < 0) {printf("Could not open file\n"); return;}
    A = (ulong*) mmap(NULL, 0x10000, PROT_READ | PROT_WRITE,
            MAP_SHARED, fd, 0x49050000);
    if (A == MAP_FAILED) {printf("Mapping failed\n"); close(fd);
return;}
    A[0x603C / 4] |= 0x600000; // Turn on LEDs

John Beetem wrote:

On the Ångström demo I've been able to use mmap() and /dev/mem to map
OMAP peripheral memory into my user space application. This way I can
access OMAP registers directly instead of having to go through device
drivers. So far I've
only accessed the GPIO registers so I could play with the user LEDs.

Be careful of that if something kernel-side is using those same registers--- you
might interrupt each other, and end up with incoherent values in the registers.

The sysfs interface to gpiolib (see gpio.txt) is pretty lightweight, avoids
having to interact with GPIO peripheral control registers directly from
userspace, and thereby avoids the risk of clobbering register values due to
contention with kernel context. But that interface only works for
machines/platforms that use gpiolib (which I think includes Beagleboard).

Where nothing kernel-side is touching the area being mmap'ed, then your code
works fine--- for any peripheral, not just gpio.

b.g.