GPIO pin is reset to default value after release.

Patrick Williams patrick at stwcx.xyz
Fri Jan 8 04:03:14 AEDT 2021


On Wed, Jan 06, 2021 at 11:42:26AM +1030, Andrew Jeffery wrote:
> > Do we have any gpio lib which don't reset the GPIO when the handler is 
> > released?
> 
> No. This is a property of the GPIO chardev interface provided by the kernel. libgpiod makes the kernel interface a bit nicer to consume in user space, but isn't where this behaviour is contracted (i.e. any use of the chardev interface might result in this behaviour, libgpiod or otherwise).
> 
> At the moment the way to get the behaviour you desire is to keep the line handle open.
> 
> The deprecated approach is to use the sysfs interface instead, but that's strongly discouraged.
> 
> That said, your problem is something I have on my to-do list to address with upstream. I'll Cc the openbmc list whenever I get to it.

Glad you're looking to fix this.

I'm sure you are already aware but this makes usage value of libgpiod pretty
low for a lot of BMC function.  There are many cases where we need to preserve
GPIO state even through a BMC reset, but certainly in the event that the app
holding the GPIO crashed.  If we don't retain the state adverse side-effects
happen to the host.

I had a similar issue on the last non-BMC embedded device I worked on as well
and we couldn't use libgpiod as a result.  It is unfortunate the current
state of affairs because officially the sysfs gpio interfaces were
suppose to be removed last year.

https://github.com/torvalds/linux/commit/fe95046e960b4b76e73dc1486955d93f47276134

-- 
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20210107/3d48d846/attachment-0001.sig>


More information about the openbmc mailing list