]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
dm: core: Fix address translation in devfdt_get_addr_index()
authorJonas Karlman <jonas@kwiboo.se>
Sat, 17 Feb 2024 13:19:41 +0000 (13:19 +0000)
committerTom Rini <trini@konsulko.com>
Mon, 4 Mar 2024 15:25:47 +0000 (10:25 -0500)
During address translation #address/size-cells props are expected to
apply to child nodes. However, devfdt_get_addr_index() incorrectly use
the parent offset of the udevice parent instead of getting the offset of
the node parent. This will work in most cases when there is only one
udevice tied to a node.

On e.g. an Orange Pi R1 Plus TLS board the dwc3-generic (parent) and
dwc3-generic-host (child) udevice is tied to the same node.

In that case both the offset and parent values end up being the same.
As a result, the #address/size-cells props intended for child nodes
incorrectly gets applied to the node itself resulting in wrong addr
being returned, 0x0 instead of 0xff600000.

The following can be seen on console:

  dwc3-generic-host usb@ff600000: this is not a DesignWare USB3 DRD Core
  dwc3-generic-host usb@ff600000: failed to initialize core

Fix this by using the offset of the parent node and not the offset to
the node the parent udevice is tied to.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
drivers/core/fdtaddr.c

index 8e774d49ce6e18f22c44c0813f8d68f3a335fb8e..5f27d25114851192a7fcc90ce3be9da0a500f6b3 100644 (file)
@@ -23,7 +23,7 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
 {
 #if CONFIG_IS_ENABLED(OF_REAL)
        int offset = dev_of_offset(dev);
-       int parent = dev_of_offset(dev->parent);
+       int parent = fdt_parent_offset(gd->fdt_blob, offset);
        fdt_addr_t addr;
 
        if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {