Changes between Version 19 and Version 20 of gpio


Ignore:
Timestamp:
04/07/2021 06:22:31 PM (17 months ago)
Author:
Tim Harvey
Comment:

add example for finding gpio base via sysfs

Legend:

Unmodified
Added
Removed
Modified
  • gpio

    v19 v20  
    398398cat /sys/kernel/debug/gpio
    399399}}}
     400 * to determine the Linux GPIO for a specific offset of a controller you can look for GPIO controller devices that match the bus address of the controller you are interested in. For example if you are trying to find the Linux gpio for the 3rd gpio of an i2c based GPIO controller on i2c0@0x23:
     401{{{#!bash
     402bus="0-0023"
     403for i in $(ls -1d /sys/class/gpio/gpiochip*); do \
     404     [ "$1" = "$(basename $(readlink $i/device))" ] && base=$(cat $i/base);
     405done
     406gpio=$((base+3))
     407}}}
    400408 * to export a GPIO that is available to userspace (ie provided by a gpio controller, not in-use by a kernel driver, and not already exported):
    401409{{{#!bash