On 10/5/19 11:50 AM, Eugeniu Rosca wrote:
Hi Stephen,
On Fri, Oct 04, 2019 at 01:07:23PM -0600, Stephen Warren wrote:
[..]
I think the DT should represent the device that's attached to the GPIOs.
That way, there's already a clear way to represent the GPIO polarity, as
described in the document linked by Eugenui in [2] below.
If for some reason that's not possible, then I think keeping track of the
GPIO polarity in user-space is entirely reasonable, and is the correct
approach. To claim that tracking GPIO polarity in user-space is too much
burden, yet to also allow user-space to control GPIOs at all, and hence to
know exactly which GPIOs must be controlled, is an inconsistent assertion.
Put another way: If a piece of user-space SW controls GPIOs, it must know
which GPIO number to use for each logical purpose. This information
presumably varies on different platforms, so the SW must have a list of GPIO
numbers and GPIO controller IDs per platform. Additionally storing a
polarity bit along with that information seems entirely trivial to me.
Is there some other issue that I'm overlooking?
Based on the discussions so far, the user who requested this feature
intends to (in fact already does) "mark" the userspace-relevant gpio
lines via the "gpio-line-names" [5] DT property, implemented by Linus
in v4.7 commit [6]. By keeping track of "gpio line name" both in DT and
in user-space, apparently the user is able to accurately map the
"line name" (visible in userspace) to the corresponding gpio chip/name
and gpio line offset in a "platform/board-independent" way.
Do you think this is unorthodox?
No, that sounds reasonable.
Given that, it might be plausible to extend that DT scheme to represent
more information, but it's still better to represent the actual end
device (that's connected to the GPIO) in DT, since that also represents
the semantics.
[6] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fd9c55315db9