It looks like the device tree property gpio-line-names is not taken into account anymore for naming the gpio lines in Linux. Instead they are all now just named with the GPIO port and pin like for example PA.00.
We used these names to lookup GPIO pins for different hardware versions. Is there a way to make these names use the gpio-line-names property of the device tree again?
Partial output of gpioinfo:
...
gpiochip1 - 169 lines:
line 0: "PA.00" unused input active-high
line 1: "PA.01" unused input active-high
line 2: "PA.02" unused input active-high
line 3: "PA.03" unused input active-high
line 4: "PA.04" unused input active-high
...
ya, it’s changed since kernel version is now moving to k-5.10.
how about using the GPIO numbers, please see-also GPIO changes section for the steps to check the GPIO number.
Thank you for your answer. The naming allows us to get the GPIO line even if they are on different physical pins in different devices. We cannot use the numbers for that, because they will always refer to the same physical pin.
Is there a way to bring back the old behavior? Could we apply a patch such that the line names are taken from the device tree again? Where in the code would I have to look for this?
We have userspace applications that need to toggle some GPIOs. These userspace don’t know which exact pin to toggle and we don’t want to hardcode that, so they lookup the GPIO pin using the line name (in the style of gpiofind). We use the device tree to map that pin. This is also recommended by the kernel documentation (https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt).
Optionally, a GPIO controller may have a “gpio-line-names” property. This is
an array of strings defining the names of the GPIO lines going out of the
GPIO controller. This name should be the most meaningful producer name
for the system, such as a rail name indicating the usage. Package names
such as pin name are discouraged: such lines have opaque names (since they
are by definition generic purpose) and such names are usually not very
helpful. For example “MMC-CD”, “Red LED Vdd” and “ethernet reset” are
reasonable line names as they describe what the line is used for. “GPIO0”
is not a good name to give to a GPIO line.
please test your use-cases which uses gpio-line-names property in device tree with the attach kernel patch,
i.e. Topic244693_Mar09_fb83a52.diff (3.2 KB)
thanks
Thanks for the patch! The names are assigned now, but unfortunately they are shifted. It looks like it is not taking into account that some ports have a different number of pins. That’s a different behavior than before, where it assumed a standard of 8 pins per port. The gpio-line-names of the Xavier NX devkit in tegra194-p3509-0000-a00.dtsi are also still like that in the Jetpack 5 device trees.
Can you confirm that the new behavior is correct and the name assignment will be stable? In that case I will adapt my device tree to match the new numbering.
The numbering of the GPIO pins has changed w.r.t. Jetpack 4, therefore the gpio-line-names of the Jetpack 4 device tree do not correspond to the correct pins anymore. This is also not adapted yet in the gpio-line-names of the devkit device tree.
My main question is just if this new GPIO line numbering is stable or if it will change again with the next update? I will adapt my gpio-line-names for the new numbering now, that seems the fastest approach. Do you happen to have a table that maps old number to new ones?
it’s major kernel release update for changing that. i.e. kernel-4.9 to kernel-5.10.
there’s no table for mapping old GPIO number to new ones.
you may refer to GPIO Changes session for GPIO mapping formula to translated GPIO numbers.