Re: [RFC] gpio: expose pull-up/pull-down line flags to userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



czw., 3 paź 2019 o 14:47 Linus Walleij <linus.walleij@xxxxxxxxxx> napisał(a):
>
> On Mon, Sep 23, 2019 at 10:38 AM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>
> > I remember discussing it with Linus some time ago. This may not be as
> > straightforward as simply adding new flags. Since PULL-UP/DOWN
> > resistors can - among other parameters - also have configurable
> > resistance, we'll probably need some kind of a structure for this
> > ioctl() to pass any additional information to the kernel. Since we
> > can't change ABI this may require adding a whole new ioctl() for
> > extended configuration. This in turn has to be as future-proof as
> > possible - if someone asks for user-space-configurable drive-strength,
> > the new ioctl() should be ready for it.
> >
> > I should have some bandwidth in the coming days, so I'll try to give it a try.
>
> What we did for the in-kernel API and the Device Tree ABI
> was to simply say that if you need such elaborate control over
> the line, it needs to be done with a proper pin control driver.
>
> So for lines that just have the GPIO_PULL_UP or
> GPIO_PULL_DOWN set as a (one-bit) flag, what you will
> get is "typical" pull down/up (whatever the hardware default
> is, or what the driver thinks is default, which should be safe
> so the highest possible pull resistance I suppose).
>
> So one option is to just go with these flags and explicitly
> say that it will give a "system default (high resistance)
> pull up/down".
>
> That said, the pin controller back-end is fully capable of
> accepting more elaborate configuration, so if we prefer then
> we can make the more complex userspace ABI that can
> set it to a desired-or-default resistance.
>
> I lean toward simplicity here. I haven't seen that these
> userspace consumers need very elaborate control of this
> resistance, they are for one-off hacks and as such should
> be fine with just default pull up/down I think?
>
> I  think that specifying "this line will use pull up/down"
> at request time and having the driver set a safe default
> pull-up/down as response, (and pretty much what this
> patch does) and then add another explicit
> ioctl to refine it the day we need it is a viable way forward.
>
>  in the future something like:
> #define GPIOHANDLE_SET_LINE_CONFIG_IOCTL _IOWR(0xB4, 0x0a, struct
> gpiohandle_config)
>
> And then, when we need it, try to come up with some
> really flexible ABI for the config, based on
> include/linux/pinctrl/pinconf-generic.h
>

Thanks for your input Linus. I'm good with that. The config ioctl (or
something similar) you're mentioning may appear sooner actually -
users of libgpiod have been requesting a way of changing the direction
of a line without releasing it - something that's possible in the
kernel, but not from user-space at the moment. I'll submit something
that allows to change the configuration of a requested line soon.

Bart

> But no upfront code for that right now as it is not needed.
> A practical usecase must come first.
>
> Yours,
> Linus Walleij




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux