How to use GPIO signals
References
GPIO Usage from a Linux Application
Configure the kernel for GPIO support in sysfs
Symbol: GPIO_SYSFS [=y] Prompt: /sys/class/gpio/... (sysfs interface) Defined at drivers/gpio/Kconfig:51 Depends on: GPIOLIB && SYSFS && EXPERIMENTAL Location: -> Kernel configuration -> Device Drivers -> GPIO Support (GPIOLIB [=y])
Enable GPIO from user space
GPIO=22 cd /sys/class/gpio ls echo $GPIO > export ls
Notice on the first ls that gpio22 doesn't exist, but does after you export GPIO 22 to user space.
cd /sys/class/gpio/gpio$GPIO ls
There are files to set the direction and retrieve the current value.
echo "in" > direction cat value
Viewing GPIO Configuration
You can use debugfs to videw the current GPIO configuration.
Configure the kernel to enable debugfs:
Symbol: DEBUG_FS [=y] Prompt: Debug Filesystem Defined at lib/Kconfig.debug:77 Depends on: SYSFS Location: -> Kernel configuration -> Kernel hacking
Boot the target hardware and mount debugfs:
mount -t debugfs none /sys/kernel/debug
Dump the GPIO configuration.
cat /sys/kernel/debug/gpio