cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dargaud
Adventurer
Adventurer
6,594 Views
Registered: ‎02-26-2008

XGPIO use on new architecture

Jump to solution
Hello all, I want to use GPIOs from a user program (not a kernel module). In the past I was using the PPC architecture and doing ioctl() calls. I actually added some functionalities in the files xgpio_ioctl.h and adapter.c, but those files are now gone in the PowerPC kernel architecture. Have ioctl calls been replaced by something else ? I see fairly basic calls in xilinx_gpio.c, but I cannot call that from userland, and the file gpio/xilinx.h is empty... Are there examples of GPIO use from user programs ? Thanks
0 Kudos
Reply
1 Solution

Accepted Solutions
8,214 Views
Registered: ‎10-05-2010

You exported one pin of the GPIO Port

echo out > direction

sets this one pin to an output pin.

echo 1 > value sets then the pin

 

This is now common under many platform, for example on some ARM platforms the GPIOs are also accessed that way.

-Marco

View solution in original post

0 Kudos
Reply
7 Replies
Anonymous
Not applicable
6,592 Views

please search for "gpio" at xilinx.wikidot.com

 

0 Kudos
Reply
dargaud
Adventurer
Adventurer
6,582 Views
Registered: ‎02-26-2008

Thanks, but I don't see 'value' in there:


# ll /sys/class/gpio/gpiochip195/ total 0 drwxr-xr-x 2 root root 0 Oct 4 14:26 ./ drwxr-xr-x 7 root root 0 Oct 4 14:26 ../ -r--r--r-- 1 root root 4.0K Oct 4 14:26 base -r--r--r-- 1 root root 4.0K Oct 4 14:26 label -r--r--r-- 1 root root 4.0K Oct 4 14:26 ngpio lrwxrwxrwx 1 root root 0 Oct 4 14:26 subsystem -> ../../../../class/gpio/ -rw-r--r-- 1 root root 4.0K Oct 4 14:26 uevent

 

 

0 Kudos
Reply
6,575 Views
Registered: ‎10-05-2010

Hello,

you need to export the GPIO pins first:

echo 195 > /sys/class/gpio/export

 

then there should be a new folder which contains value, direction etc.

 

0 Kudos
Reply
dargaud
Adventurer
Adventurer
6,541 Views
Registered: ‎02-26-2008

OK, when I do that /sys/class/gpio/gpio195/ indeed appears, but the whole process seems rather 'magical'. I guess that's the way the driver is written, but still...>
The problem now is thus:

# cat /sys/class/gpio/gpio195/direction
in

Does this mean that the GPIO can only have all bits as input or all bits as output ? Where did the direction mask used by the old ioctl go ?!? All my GPIOs (and I have dozens of them) have a mix of input and output bits. So how can I interact with them in user mode ? Do I need to rewrite the driver (which file?) or is there another way besides sysfs ?

Thanks.

0 Kudos
Reply
8,215 Views
Registered: ‎10-05-2010

You exported one pin of the GPIO Port

echo out > direction

sets this one pin to an output pin.

echo 1 > value sets then the pin

 

This is now common under many platform, for example on some ARM platforms the GPIOs are also accessed that way.

-Marco

View solution in original post

0 Kudos
Reply
dargaud
Adventurer
Adventurer
6,513 Views
Registered: ‎02-26-2008

Thanks.

I decided to use the 'mmap' way of accessing the GPIO, as it is closer to my needs (and probably faster). Seems to be working OK so far.

0 Kudos
Reply
dargaud
Adventurer
Adventurer
6,433 Views
Registered: ‎02-26-2008

Actually I have an additional question.

 

So I use the user mode pseudo driver (mmap) to do direct read/write in the GPIOs value and direction registers. It works partially, but I don't find the values I expect when I first boot, so I wonder if there may be some conflict with the sysfs kernel driver (I have left  CONFIG_GPIO_SYSFS=y / CONFIG_SYSFS=y / CONFIG_EXPERIMENTAL=y / CONFIG_GPIO_XILINX=y in my kernel, should I remove them ?)

0 Kudos
Reply