From: Alexander Sverdlin <alexander.sverdlin@gmail.com> Date: 2021-03-02 07:47:23
Currently the naming of the GPIO chips depends on their order in the DT,
but also on the kernel version (I've noticed the change from v5.10.x to
v5.11). Honor the persistent enumeration in the "aliases" node like other
GPIO drivers do.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Yes, I noticed checkpatch "WARNING: DT binding docs and includes should be
a separate patch."
However, the parts below are tiny and barely make sense separately.
Documentation/devicetree/bindings/gpio/gpio-omap.txt | 6 ++++++
drivers/gpio/gpio-omap.c | 5 +++++
2 files changed, 11 insertions(+)
@@ -30,9 +30,15 @@ OMAP specific properties: - ti,gpio-always-on: Indicates if a GPIO bank is always powered and so will never lose its logic state.+Note: GPIO ports can have an alias correctly numbered in "aliases" node for+persistent enumeration. Example:+aliases {+ gpio0 = &gpio0;+};+ gpio0: gpio@44e07000 { compatible = "ti,omap4-gpio"; reg = <0x44e07000 0x1000>;
Currently the naming of the GPIO chips depends on their order in the DT,
but also on the kernel version (I've noticed the change from v5.10.x to
v5.11). Honor the persistent enumeration in the "aliases" node like other
GPIO drivers do.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Yes, I noticed checkpatch "WARNING: DT binding docs and includes should be
a separate patch."
However, the parts below are tiny and barely make sense separately.
Documentation/devicetree/bindings/gpio/gpio-omap.txt | 6 ++++++
drivers/gpio/gpio-omap.c | 5 +++++
2 files changed, 11 insertions(+)
@@ -30,9 +30,15 @@ OMAP specific properties: - ti,gpio-always-on: Indicates if a GPIO bank is always powered and so will never lose its logic state.+Note: GPIO ports can have an alias correctly numbered in "aliases" node for+persistent enumeration. Example:+aliases {+ gpio0 = &gpio0;+};+ gpio0: gpio@44e07000 { compatible = "ti,omap4-gpio"; reg = <0x44e07000 0x1000>;
On Tue, Mar 2, 2021 at 2:18 AM Alexander Sverdlin
[off-list ref] wrote:
Currently the naming of the GPIO chips depends on their order in the DT,
but also on the kernel version (I've noticed the change from v5.10.x to
v5.11). Honor the persistent enumeration in the "aliases" node like other
GPIO drivers do.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Yes, I noticed checkpatch "WARNING: DT binding docs and includes should be
a separate patch."
However, the parts below are tiny and barely make sense separately.
I've shut it down in the past because the instance ordering is a
linuxism and the needs are in the Linux userspace somehow.
It is different from a UART for example, which always need to
be at the same place on any operating system, hence it has an
alias.
For kernelspace the instance order should not matter, since
all resources are obtained from the device tree anyway
by phandle.
For userspace:
The way to determine topology in Linux userspace is to use sysfs,
and combined with the GPIO character device this provides a
unique ID for each GPIO chip and line on the system.
/sys/bus/gpio/devices/gpiochip0/
/sys/bus/gpio/devices/gpiochip1/
etc can change, but these appear as PCI, I2C, SPI, platform
etc nodes as well. On my PC:
/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5:1.0/gpiochip0
It's pretty clear where that gpiochip sits.
Yours,
Linus Walleij
From: Rob Herring <robh@kernel.org> Date: 2021-03-08 18:38:05
On Tue, Mar 02, 2021 at 05:21:23PM +0100, Linus Walleij wrote:
On Tue, Mar 2, 2021 at 2:18 AM Alexander Sverdlin
[off-list ref] wrote:
quoted
Currently the naming of the GPIO chips depends on their order in the DT,
but also on the kernel version (I've noticed the change from v5.10.x to
v5.11). Honor the persistent enumeration in the "aliases" node like other
GPIO drivers do.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Yes, I noticed checkpatch "WARNING: DT binding docs and includes should be
a separate patch."
However, the parts below are tiny and barely make sense separately.
I've shut it down in the past because the instance ordering is a
linuxism and the needs are in the Linux userspace somehow.
It is different from a UART for example, which always need to
be at the same place on any operating system, hence it has an
alias.
For kernelspace the instance order should not matter, since
all resources are obtained from the device tree anyway
by phandle.
Thank you!
Can we remove the ones we have already for GPIO?
BTW, It's been on my todo list for a while to start requiring
documentation of alias names so we can reject new ones and get rid of
some of the unused existing ones. Some platforms have numbered
everything...
Rob
On Mon, Mar 8, 2021 at 7:37 PM Rob Herring [off-list ref] wrote:
Can we remove the ones we have already for GPIO?
I think we would get pretty hard pushback if we attempt that.
We have all these drivers that utilize it:
gpio-clps711x.c: id = of_alias_get_id(np, "gpio");
gpio-mvebu.c: id = of_alias_get_id(pdev->dev.of_node, "gpio");
gpio-mxc.c: port->gc.base = (pdev->id < 0) ? of_alias_get_id(np,
"gpio") * 32 :
gpio-mxs.c: port->id = of_alias_get_id(np, "gpio");
gpio-vf610.c: gc->base = of_alias_get_id(np, "gpio") * VF610_GPIO_PER_PORT;
gpio-zynq.c: chip->base = of_alias_get_id(pdev->dev.of_node, "gpio");
pinctrl-at91.c: int alias_idx = of_alias_get_id(np, "gpio");
pinctrl-st.c: int bank_num = of_alias_get_id(np, "gpio");
samsung/pinctrl-samsung.c: id = of_alias_get_id(node, "pinctrl");
Predictably it is so many bad examples that new driver authors will claim
something along the line of
"why can't I have a lollipop when all other kids got one".
Several of those have this by a claim one way or another that
the DT boot need to look like the boardfile boot. Some of these
have been migrated from board files so could possible drop
this id/base coding.
I don't know what the maintainers would say, should we send
attack patches? :D At least some kind of motivation would come
out of it.
Yours,
Linus Walleij