Still struggling with Xilinx GPIO...

John Bonesio john.bonesio at xilinx.com
Thu May 29 02:09:34 EST 2008


Hi Guillaume,

gpio_ioctl.chan = x;

That's what determines which gpio device gets used. Since using 1 at
least doesn't give you a core dump, I would guess that 1 is the correct
value to use there.

So the next thing to check is to make sure that the ioctl command codes
being used are right.

The only way I know how to do this is to look in the linux kernel source
for the gpio device. Try looking here:
    linux/drivers/char/xilinx_gpio

Then you find the routine that is handling the ioctl commands. It'll
probably be called xgpio_ioctl. In this routine you'll see something
like:
    switch(cmd) {
    case XGPIO_IN:
        ...

The value for XGPIO_IN is defined in a header file (probably). The
header file might be called xgpio_ioctl.h.

So here's the key:
    Make sure the value for XGPIO_IN used in the user application is the
same as the one used in the kernel.

At one point I had see a case where the values in the kernel had
changed, but the user application was still trying to use the old
values.

Hope this helps,

- John



On Wed, 2008-05-28 at 11:51 +0200, Guillaume Dargaud wrote:
> Hi John,
> 
> > Try using channel 1. It may be set up where the first channel is 1 and not 
> > 0.
> 
> Not sure what you mean...
> 
> I'm actually not clear how many devices I should have:
> 
> $ grep "GPIO.*BASEADDR" 
> arch/ppc/platforms/4xx/xparameters/xparameters_ml405.h
> #define XPAR_GPIO_0_BASEADDR XPAR_LEDS_4BIT_BASEADDR
> #define XPAR_GPIO_1_BASEADDR XPAR_LEDS_POSITIONS_BASEADDR
> #define XPAR_GPIO_2_BASEADDR XPAR_PUSH_BUTTONS_POSITION_BASEADDR
> 
> But depending on the examples I look at, they define either:
> 
> crw-rw-rw-    1 root     root      10, 185 May 26 13:49 xgpio
> or:
> crw-rw-rw-    1 root     root      10, 185 May 26 13:18 xgpio0
> crw-rw-rw-    1 root     root      10, 186 May 26 13:18 xgpio1
> crw-rw-rw-    1 root     root      10, 187 May 26 13:18 xgpio2
> 
> If that is the former, I see the code uses:
>  gpio_ioctl.chan=0;
> And I guess that's what you are refering to, right ?
> 
> Putting 1 gives me a working program, but no LED lights up and the buttons 
> are always shown at 0.
> Putting 0 gives a nice core dump as in my previous msg.
> Putting 2 locks up the system.
> 
> And... I don't see how the code manages to read/wite all 3 GPIOs with only 
> two IOCTL calls. Shouldn't they be 3 different calls using different 
> addresses ?!? Argh, this complete lack of documentation in maddening. Not 
> everything can be understood from reading the source.
> 
> Thanks.

________________________________________________________________________

John Bonesio
Commercial Linux Solutions
john.bonesio at xilinx.com
(408) 879-5569

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.





More information about the Linuxppc-dev mailing list