Re: setting gpio-line-names in dts for sama5d2 SoC

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

 



+Cc: Kent (sorry, forgot to include you earlier)

On Thu, Mar 18, 2021 at 11:50 AM Alexander Dahl <ada@xxxxxxxxxxx> wrote:
> > Andy Shevchenko <andy.shevchenko@xxxxxxxxx> hat am 17.03.2021 13:33 geschrieben:
> > On Wed, Mar 17, 2021 at 1:22 AM Andy Shevchenko
> > <andy.shevchenko@xxxxxxxxx> wrote:
> > > On Tuesday, March 16, 2021, Alexander Dahl <ada@xxxxxxxxxxx> wrote:

...

> > >> for a Microchip SAMA5D2 SoC based device I try to set gpio-line-names in .dts file like this:
> > >>
> > >> 257 &pioA {
> > >> 258         gpio-line-names = "",                   /* PA0  */
> > >> 259                           "",                   /* PA1  */
> > >> 260                           "",                   /* PA2  */
> > >> 261                           "FOO",                /* PA3  */
> > >> 262                           "BAR",                /* PA4  */
> > >> 263                           "",                   /* PA5  */
> > >>
> > >> … and so on for all 4 * 32 GPIO Pins. However when calling `gpioinfo` in userspace, I always get this:
> > >>
> > >> $ gpioinfo
> > >> gpiochip0 - 128 lines:
> > >>         line   0:        "PA0"       unused   input  active-high
> > >>         line   1:        "PA1"       unused   input  active-high
> > >>         line   2:        "PA2"       unused   input  active-high
> > >>         line   3:        "PA3"       unused   input  active-high
> > >>         line   4:        "PA4"       unused   input  active-high
> > >>         line   5:        "PA5"       unused   input  active-high
> > >>
> > >> … and so on. Those "PA0" line names are set by the pinctrl driver in drivers/pinctrl/pinctrl-at91-pio4.c before calling gpiochip_add_data() and from reading the code in drivers/gpio/gpiolib.c I suspect devprop_gpiochip_set_names() is never called then, so those names in .dts are simply ignored.
> > >>
> > >> Those default names from the at91 pio4 pinctrl driver are certainly correct speaking of pin names, but from a userspace point of view it would be better if I could override those from dts, so an application using libgpiod could look for a name like e.g. "VALVE7_EN" without caring to which pin that's actually connected. Can I override those with a currently present kernel?
>
> I don't think I can override with a recent kernel.
>
> >>> Or is it a problem in either the at91 pio4 driver or the gpiolib core? Or is that no real usecase and should I do it differently?
>
> If I disable the name assignment in the pinctrl-at91-pio4 driver, I get the line names from the dts. I used the following diff:

...

> Now gpioinfo shows what I set in dts, more or less similar to this:
>
> gpiochip0 - 128 lines:
>         line   0:      unnamed       unused   input  active-high
>         line   1:      unnamed       unused   input  active-high
>         line   2:      unnamed       unused   input  active-high
>         line   3:        "FOO"       unused   input  active-high
>         line   4:        "BAR"       unused   input  active-high
>         line   5:      unnamed       unused   input  active-high
>
> > > I would like to know the consequences if allow this, but to me it sounds like a bug in the gpiolib.c.
>
> At least the documentation recommends to not use pin names: https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt
>
> If anyone has an idea how to fix this, let me know. I can try to make a patch then. Currently however, I'm not familiar enough with the gpio subsystem to just start that.

You may look into the commit
7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for
device properties")
which unifies the logic, but at the same time removed one comment:

-       /* If the chip defines names itself, these take precedence */

So, logic was that for a long time. And unfortunately I don't see how
we may change this without breakage. This backs us to the discussion
if the name of the line is ABI or not.

-- 
With Best Regards,
Andy Shevchenko




[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