Xilinx GPIO API and kernel GPIO API differences

Guillaume Dargaud dargaud at lpsc.in2p3.fr
Wed Sep 3 23:50:51 EST 2008


Hello all,
I can't fully understand the differences in what should be simple I/O 
read/writes.

If I write a standalone program using the Xilinx API calls, I have access to 
the following functions to control the direction of GPIO bits. For instance:

XGpio Input, Output;
XGpio_Initialize(&Input, InputDev);
XGpio_Initialize(&Output, OutputDev));
XGpio_SetDataDirection(&Input,  1, 0xFFFFFFFF);
XGpio_SetDataDirection(&Output, 1, 0);
Data = XGpio_DiscreteRead(&Input, 1);
XGpio_DiscreteWrite(&Output, 1, 0x12345678);

Now the equivalent using usermode linux calls _seems_ to be the following:

struct xgpio_ioctl_data Input, Output;
Input = open(GPIO_IN, O_RDWR);
Output = open(GPIO_OUT, O_RDWR);
gpio_info.chan = 1;
gpio_info.mask = 0xFFFFFFFF;
ioctl(Input, XGPIO_IN, &gpio_info);
Data=gpio_info.data;
gpio_info.data=0x12345678;
ioctl(Output, XGPIO_OUT, &gpio_info);

But where it all breaks down is if I have input and output bits mixed on the 
same GPIO, particularly if reading the outputs makes no sense like in my 
case (always return 0).
Using those ioctl calls, how do I specify which bits are input and which 
ones are output ?
In other words, the equivalent to this:

XGpio IO;
XGpio_Initialize(&IO, Dev);
XGpio_SetDataDirection(&Input,  1, 0x00FFFF00);
Data = XGpio_DiscreteRead(&Input, 1);
XGpio_DiscreteWrite(&Output, 1, 0x12000078);

Is there anything available from usermode besides those ioctl calls ?
This makes me regret assembly...
-- 
Guillaume Dargaud
http://www.gdargaud.net/





More information about the Linuxppc-dev mailing list