GPIO offsets used by userspace

Xo Wang xow at google.com
Wed Feb 1 09:15:41 AEDT 2017


On Mon, Jan 30, 2017 at 5:15 PM, Andrew Jeffery <andrew at aj.id.au> wrote:
> On Tue, 2017-01-31 at 10:55 +1030, Joel Stanley wrote:
>> > On Mon, Jan 30, 2017 at 12:04 PM, Andrew Jeffery <andrew at aj.id.au> wrote:
>> > Hi all,
>> >
>> > Just a heads up that when the linked patch is pulled into the OpenBMC
>> > kernel it will break our userspace. We will need to synchronise the
>> > kernel bump with the fixes for the machine configs to update the magic
>> > GPIO offset number.
>> >
>> > https://lkml.org/lkml/2017/1/26/786
>> >
>> > The magic offset is essentially 512-(ngpios) (I don't know why, but
>> > that's the behaviour), and this now varies between AST2400 and AST2500
>> > systems due to the AST2500 having an extra bank, and also because the
>> > AST2400 has a "hole" at the end of its GPIO number space.
>>
>> Can you suggest a way to detect this from userspace?
>
> Not off the top of my head.
>

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.

However I don't actually see a /sys/class/gpio/gpiochipN directory on
the BMCs I touched. Any ideas?

cheers
xo


More information about the openbmc mailing list