This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[OMAP35x] How to add a GPIO Sysfs Interface for Userspace



Hi,

We are using AM35x-OMAP35x-PSP 03.00.01.06 and I'd like to create a userspace interface to three GPIOs.

Can someone please point me to the Linux source code where I can indicate which GPIO to create a userpsace interface?

I see that gpio.c in plat-omap initializes most GPIOs but I can't figure out which part/structure to modify.

 

  • In theory, your Linux kernel already supports a userspace interface to any GPIO. Search for "/sys/class/gpio" in this forum or on the internet. The GPIO capabilities of your specific kernel is in the kernel source at "Documentation/gpio.txt". The latest kernels also have edge detection. Check that the GPIO file system is enabled in the kernel configuration. It will be CONFIG_GPIO_SYSFS in your config file. Under menu config it will be called "/sys/class/gpio/... (sysfs interface)". Example commands for configuring, toggling GPIO 11.

    cd /sys/class/gpio/
    echo 11 > export
    cd gpio11
    echo out > direction
    echo 0 > value
    echo 1 > value
    echo 0 > value

    You might have configure the MUX to make a particular pin into a GPIO. That might be done is u-boot or might be done in linux. Depends on your situation.

  • thank you for that. that's exactly what i need.