Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO lines set consumer instead of name #49

Open
ThirteenFish opened this issue Jul 14, 2024 · 0 comments
Open

GPIO lines set consumer instead of name #49

ThirteenFish opened this issue Jul 14, 2024 · 0 comments

Comments

@ThirteenFish
Copy link

GPIO in modern Linux have two strings associated with them: name (or label) and consumer. The name is typically set at boot and remains stable, whereas the consumer is expected to be set by whatever application is currently using that specific line. Our current devicetrees configure GPIO in such a way where name is unset and consumer contains what should be in name. This is inconvenient because applications which try to look up the lines by name (e.g. oresat-c3-software) can crash if another program got to the line first and accidentally reset or changed the consumer (e.g. the AX5043 driver).

The devicetrees configure GPIO in this way because they use gpio-of-helper to set up the lines. gpio-of-helper is an out-of-tree TI kernel module that was rejected a decade ago by upstream and hasn't been maintained since. It was built for the version 1 GPIO interface, but Linux has since moved on to version 2, which is where the name/consumer split took place.

The solution to this comes in three parts:

  • Setting the names
  • Hogging
  • Fixing userspace.

Setting the names

I think this in isolation should be fairly easy. Using the standard devicetree GPIO configuration we can just set gpio-line-names for each gpio-controller (see for example this similar devicetree). I don't think this should conflict with gpio-of-helper but I've not tested it but I don't know for sure.

Hogging

Since gpio-of-helper is deprecated, how do we go about configuring lines at boot? Hogging. See this doc again for a description. That will reserve the lines for userspace, allow you to set default levels, pull-up/down resisters, and other things. We should eventually update our devicetrees to use hogging instead of gpio-of-helper. What hogging won't do on the other hand is set up the sysfs interface. The sysfs interface is deprecated so we should move away from it but that will require fixing up userspace.

Fixing userspace

olaf has a basic GPIO library built atop the sysfs interface. If we move to hogging this will either need to be replaced with the standard gpiod library or some userspace thing to re-set up sysfs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant