ARM: tegra: Copy memory-region-names property
authorThierry Reding <treding@nvidia.com>
Fri, 3 Sep 2021 13:16:25 +0000 (15:16 +0200)
committerTom Warren <twarren@nvidia.com>
Wed, 13 Oct 2021 21:18:30 +0000 (14:18 -0700)
If multiple entries are present in the memory-region property, this new
memory-region-names property can be used to specify names for each of
them so that they can be more easily distinguished.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>
arch/arm/mach-tegra/dt-setup.c

index 894a635..c114947 100644 (file)
@@ -78,9 +78,11 @@ void ft_mac_address_setup(void *fdt)
 
 static int ft_copy_carveout(void *dst, const void *src, const char *node)
 {
+       const char *names = "memory-region-names";
        struct fdt_memory carveout;
        unsigned int index = 0;
-       int err;
+       int err, offset, len;
+       const void *prop;
 
        while (true) {
                const char **compatibles = NULL;
@@ -96,6 +98,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
                        if (err != -FDT_ERR_NOTFOUND)
                                printf("failed to get carveout for %s: %d\n",
                                       node, err);
+                       else
+                               break;
 
                        return err;
                }
@@ -126,6 +130,31 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
                index++;
        }
 
+       offset = fdt_path_offset(src, node);
+       if (offset < 0) {
+               debug("failed to find source offset for %s: %s\n", node,
+                     fdt_strerror(err));
+               return err;
+       }
+
+       prop = fdt_getprop(src, offset, names, &len);
+       if (prop) {
+               offset = fdt_path_offset(dst, node);
+               if (offset < 0) {
+                       debug("failed to find destination offset for %s: %s\n",
+                             node, fdt_strerror(err));
+                       return err;
+               }
+
+               err = fdt_setprop(dst, offset, "memory-region-names", prop,
+                                 len);
+               if (err < 0) {
+                       debug("failed to copy \"%s\" property: %s\n", names,
+                             fdt_strerror(err));
+                       return err;
+               }
+       }
+
        return 0;
 }