GPIO offsets used by userspace

Joel Stanley joel at jms.id.au
Wed Feb 1 10:25:43 AEDT 2017


On Wed, Feb 1, 2017 at 8:45 AM, Xo Wang <xow at google.com> wrote:
> However I don't actually see a /sys/class/gpio/gpiochipN directory on
> the BMCs I touched. Any ideas?

That's strange. On the machines I looked at we do have that. I double
checked on a Zaius running the v1.99.1 tag:

root at zaius5:~# ls /sys/class/gpio/gpiochip320/
base       device     label      ngpio      subsystem  uevent

> I mentioned this on GitHub, but in theory we should have at least one
> /sys/class/gpio/gpiochipN directory, where N is the offset for GPIOs
> provided by that GPIO device.
>
> On a BMC not attached to GPIO expanders this directory name could be
> parsed by the Python currently in use. Not foolproof, but it could be
> a working stopgap.

You're right, we could find this one. This would break on Witherspoon
though which will soon gain a driver for a GPIO expander.

We could write some python to iterate through the gpiochipN
directories, and match against the label:

root at zaius5:~# cat /sys/class/gpio/gpiochip320/label
1e780000.gpio

This would be a stopgap until we could get something saner, like sysfs
files named after the net or function.

Cheers,

Joel


More information about the openbmc mailing list