On Oct 26, 2005, at 7:20 AM, <elynum@...> <elynum@...> wrote:
> I'm currently using a xilinx fpga with a powerpc core inside of
> it. I'm trying to figure out how to toggle an LED from the
> operating system. Basically how to hook up my low level driver to a
> high level driver. I expect to use a gumstix board soon, so this
> is good practice for me. I know doing this should be similar to
> how people do these things on the gumstix board. On the FPGA board
> it seems you have to put this in your makefile for building the
> kernel. Is it the same for gumstix? Are there any documentation
> as far as if you have a gumstix board and you want to toggle LED
> lines or switches from a linux OS how would you go about achieving
> this that gives a great explanation of this.
The "normal" way to do this with a gumstix would be to use the CPU's
GPIO lines. The CPU has a handful of registers which control the
GPIO lines, broken into 3 functions: mode, direction, and level.
Mode basically is to tell the CPU whether you want to control the
line directly, or whether you want some controller on the CPU to
control the line (eg a UART). Direction is whether you're sending
data on the line, or listening for a signal on the line; and then
level is high or low.
You can directly program these registers from the kernel by just
poking a value into the correct memory address. Or, on a gumstix,
you can make use from userspace of the driver I wrote which creates
an entry /proc/gpio with a bunch of pseudo-files under that for each
GPIO line. You can read/write those pseudo-files from userspace to
change the GPIO settings, eg:
# echo "GPIO out set" > /proc/gpio/GPIO42
which will set the gpio to GPIO mode, direction out, level high
# echo "GPIO in" > /proc/gpio/GPIO42
sets the mode to in
# cat /proc/gpio/GPIO42
42 GPIO in clear
prints info about that GPIO line -- in this case showing that the
line level is being read as low.
If you want to see sample code, the driver which implements /proc/
gpio is a good place to read. The patch against 2.6.13 kernels is:
You can read the C code from the patch file pretty easily.