RE: [PATCH v4 1/2] pinctrl: Add RZ/A2 pin and gpio controller

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

 



Hi Geert,

Just in case you were wondering...

On Monday, November 12, 2018, Geert Uytterhoeven wrote:
> > +       "PJ_0", "PJ_1", "PJ_2", "PJ_3", "PJ_4", "PJ_5", "PJ_6", "PJ_7",
> > +       "PK_0", "PK_1", "PK_2", "PK_3", "PK_4", "PK_5", "PK_6", "PK_7",
> > +       "PL_0", "PL_1", "PL_2", "PL_3", "PL_4", "PL_5", "PL_6", "PL_7",
> > +       "PM_0", "PM_1", "PM_2", "PM_3", "PM_4", "PM_5", "PM_6", "PM_7",
> > +};
> > +
> > +static struct gpio_chip chip = {
> > +       .names = rza2_gpio_names,
> 
> BTW, is their much value in filling gpio_chip.names[]?
> I had never seen that before.


On Tuesday, November 13, 2018, Geert Uytterhoeven wrote:
>   2. Userspace library libgpiod, incl. a few tools like
> gpioinfo/gpioset/gpioget.
>      These accept whatever reference to identify a GPIO.
>      As your driver fills in pins[i].name, I expect you can pass names
> like P5_6.


Actually, just filling in pins[i].name is not enough. You really need to
pass an array of strings to gpio_chip.name.

When struct gpio_chip.names = NULL, you get this:

$ gpioinfo
gpiochip0 - 176 lines:
        line   0:      unnamed       unused   input  active-high
        line   1:      unnamed       unused   input  active-high
        line   2:      unnamed       unused   input  active-high
        line   3:      unnamed       unused   input  active-high
        line   4:      unnamed       unused   input  active-high
        line   5:      unnamed       unused   input  active-high
        line   6:      unnamed       unused   input  active-high
        line   7:      unnamed       unused   input  active-high
        line   8:      unnamed       unused   input  active-high
        line   9:      unnamed       unused   input  active-high
        line  10:      unnamed       unused   input  active-high
        line  11:      unnamed       unused   input  active-high
        line  12:      unnamed       unused   input  active-high


When struct gpio_chip.names = rza2_gpio_names, you get this:

$ gpioinfo
gpiochip0 - 176 lines:
        line   0:       "P0_0"       unused   input  active-high
        line   1:       "P0_1"       unused   input  active-high
        line   2:       "P0_2"       unused   input  active-high
        line   3:       "P0_3"       unused   input  active-high
        line   4:       "P0_4"       unused   input  active-high
        line   5:       "P0_5"       unused   input  active-high
        line   6:       "P0_6"       unused   input  active-high
        line   7:       "P0_7"       unused   input  active-high
        line   8:       "P1_0"       unused   input  active-high
        line   9:       "P1_1"       unused   input  active-high
        line  10:       "P1_2"       unused   input  active-high
        line  11:       "P1_3"       unused   input  active-high
        line  12:       "P1_4"       unused   input  active-high

Then you can use gpiofind to convert a name into an ID.

$ gpiofind P6_0
gpiochip0 48


But to your point, libgpiod is way better than using /sys directly.

Chris





[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