Accessing to GPIO on a At91rm9200EK based board

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

Location: Valence, France
Posts: 22
Joined: Tue Mar 01, 2005 12:54 pm

Accessing to GPIO on a At91rm9200EK based board

Tue Aug 09, 2005 2:27 pm

Hi all

i'm actually looking for some information about how to access to particular GPIO pin from Linux User Space

Indeed i would like to read data from PC14 and PC2, and to send a clock signal to PC0 and PC1.

i've found on the internet an exemple of access to gpio using /dev/mem ( but an adress (the virtual address of PCx) is needed to access to a pin.
i don't understand how i can found this adress in /dev/mem...does anyone know how it can be found?
or does anyone know a simple solution to read/write through the gpio?

i've looked in /proc/iomem but i haven't found interessant things
[root@EmbeddedLinux /proc]$more iomem
20000000-21ffffff : System RAM
2001b000-20175f27 : Kernel code
20175f28-201c2097 : Kernel data
fefc4000-fefc7fff : at91_serial
fefff200-fefff3ff : at91_serial
i'm using Linux 2.4.27 vrs1, in whom i've add gpio.c (that manage gpio interrupts) and my board is based on a rm9200, with 8MByte o flash memory and 32 MB of ram

with regards

Frederic 'katolecho' Kwiatkowski
Location: Switzerland
Posts: 18
Joined: Fri Mar 11, 2005 2:46 pm

Mon Aug 22, 2005 1:06 pm

have a look at the at91rm9200 docs (doc1768.pdf).
all peripherals are memory-mapped at the last 256M segment in linear address space (0xf0000000-0xffffffff).

to access PIOC, open and mmap /dev/mem, then construct a pointer to 0xfffff800 and see the chapter about the PIO controller user interface in the docs.
i suggest you create a bitfield structure. it's makes the code much more readable. oh, and don't forget to declare the pointer as volatile or the compiler might optimize things away.

it would be much better to write a kernel driver though...

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 3 guests