]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: tegra: Support multiple reserved memory regions
authorThierry Reding <treding@nvidia.com>
Fri, 3 Sep 2021 13:16:22 +0000 (15:16 +0200)
committerTom Warren <twarren@nvidia.com>
Wed, 13 Oct 2021 21:18:30 +0000 (14:18 -0700)
Support multiple reserved memory regions per device to support platforms
that use both a framebuffer and color conversion lookup table for early
boot display splash.

While at it, also pass along the name, compatible strings and flags of
the carveouts.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>
board/nvidia/p2371-2180/p2371-2180.c
board/nvidia/p2771-0000/p2771-0000.c
board/nvidia/p3450-0000/p3450-0000.c

index 137c7d3b12c3b1db00194282f243a3dfbebd018c..f5126c552b00dd5223edb99c93229a3392e929ca 100644 (file)
@@ -10,6 +10,7 @@
 #include <i2c.h>
 #include <log.h>
 #include <net.h>
+#include <stdlib.h>
 #include <linux/bitops.h>
 #include <linux/libfdt.h>
 #include <asm/arch/gpio.h>
@@ -125,24 +126,52 @@ static void ft_mac_address_setup(void *fdt)
 
 static int ft_copy_carveout(void *dst, const void *src, const char *node)
 {
-       struct fdt_memory fb;
+       unsigned int index = 0;
        int err;
 
-       err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
-                                 NULL, NULL, NULL);
-       if (err < 0) {
-               if (err != -FDT_ERR_NOTFOUND)
-                       printf("failed to get carveout for %s: %d\n", node,
+       while (true) {
+               const char **compatibles = NULL;
+               unsigned int num_compatibles;
+               struct fdt_memory carveout;
+               unsigned long flags;
+               char *copy = NULL;
+               const char *name;
+
+               err = fdtdec_get_carveout(src, node, "memory-region", index,
+                                         &carveout, &name, &compatibles,
+                                         &num_compatibles, &flags);
+               if (err < 0) {
+                       if (err != -FDT_ERR_NOTFOUND)
+                               printf("failed to get carveout for %s: %d\n",
+                                      node, err);
+
+                       return err;
+               }
+
+               if (name) {
+                       const char *ptr = strchr(name, '@');
+
+                       if (ptr) {
+                               copy = strndup(name, ptr - name);
+                               name = copy;
+                       }
+               } else {
+                       name = "carveout";
+               }
+
+               err = fdtdec_set_carveout(dst, node, "memory-region", index,
+                                         &carveout, name, compatibles,
+                                         num_compatibles, flags);
+               if (err < 0) {
+                       printf("failed to set carveout for %s: %d\n", node,
                               err);
+                       return err;
+               }
 
-               return err;
-       }
+               if (copy)
+                       free(copy);
 
-       err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
-                                 "framebuffer", NULL, 0, 0);
-       if (err < 0) {
-               printf("failed to set carveout for %s: %d\n", node, err);
-               return err;
+               index++;
        }
 
        return 0;
index 3d2653d1f075f802f74dedf0b5fe52d747703e64..46c36a22db5ecd0fdb069a3f52527bbf0ac9e760 100644 (file)
@@ -9,6 +9,7 @@
 #include <i2c.h>
 #include <log.h>
 #include <net.h>
+#include <stdlib.h>
 #include <linux/libfdt.h>
 #include <asm/arch-tegra/cboot.h>
 #include "../p2571/max77620_init.h"
@@ -101,24 +102,52 @@ static void ft_mac_address_setup(void *fdt)
 
 static int ft_copy_carveout(void *dst, const void *src, const char *node)
 {
-       struct fdt_memory fb;
+       unsigned int index = 0;
        int err;
 
-       err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
-                                 NULL, NULL, NULL);
-       if (err < 0) {
-               if (err != -FDT_ERR_NOTFOUND)
-                       printf("failed to get carveout for %s: %d\n", node,
+       while (true) {
+               const char **compatibles = NULL;
+               unsigned int num_compatibles;
+               struct fdt_memory carveout;
+               unsigned long flags;
+               char *copy = NULL;
+               const char *name;
+
+               err = fdtdec_get_carveout(src, node, "memory-region", index,
+                                         &carveout, &name, &compatibles,
+                                         &num_compatibles, &flags);
+               if (err < 0) {
+                       if (err != -FDT_ERR_NOTFOUND)
+                               printf("failed to get carveout for %s: %d\n",
+                                      node, err);
+
+                       return err;
+               }
+
+               if (name) {
+                       const char *ptr = strchr(name, '@');
+
+                       if (ptr) {
+                               copy = strndup(name, ptr - name);
+                               name = copy;
+                       }
+               } else {
+                       name = "carveout";
+               }
+
+               err = fdtdec_set_carveout(dst, node, "memory-region", index,
+                                         &carveout, name, compatibles,
+                                         num_compatibles, flags);
+               if (err < 0) {
+                       printf("failed to set carveout for %s: %d\n", node,
                               err);
+                       return err;
+               }
 
-               return err;
-       }
+               if (copy)
+                       free(copy);
 
-       err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
-                                 "framebuffer", NULL, 0, 0);
-       if (err < 0) {
-               printf("failed to set carveout for %s: %d\n", node, err);
-               return err;
+               index++;
        }
 
        return 0;
index 2770862a49543e8baf127ea1d14d7ef6092bfe5c..97b99001a93d15ec11f74092bfd6d984ab92f03f 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/bitops.h>
 #include <linux/libfdt.h>
 #include <pca953x.h>
+#include <stdlib.h>
 #include <asm/arch-tegra/cboot.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
@@ -124,24 +125,52 @@ static void ft_mac_address_setup(void *fdt)
 
 static int ft_copy_carveout(void *dst, const void *src, const char *node)
 {
-       struct fdt_memory fb;
+       unsigned int index = 0;
        int err;
 
-       err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
-                                 NULL, NULL, NULL);
-       if (err < 0) {
-               if (err != -FDT_ERR_NOTFOUND)
-                       printf("failed to get carveout for %s: %d\n", node,
+       while (true) {
+               const char **compatibles = NULL;
+               unsigned int num_compatibles;
+               struct fdt_memory carveout;
+               unsigned long flags;
+               char *copy = NULL;
+               const char *name;
+
+               err = fdtdec_get_carveout(src, node, "memory-region", index,
+                                         &carveout, &name, &compatibles,
+                                         &num_compatibles, &flags);
+               if (err < 0) {
+                       if (err != -FDT_ERR_NOTFOUND)
+                               printf("failed to get carveout for %s: %d\n",
+                                      node, err);
+
+                       return err;
+               }
+
+               if (name) {
+                       const char *ptr = strchr(name, '@');
+
+                       if (ptr) {
+                               copy = strndup(name, ptr - name);
+                               name = copy;
+                       }
+               } else {
+                       name = "carveout";
+               }
+
+               err = fdtdec_set_carveout(dst, node, "memory-region", index,
+                                         &carveout, name, compatibles,
+                                         num_compatibles, flags);
+               if (err < 0) {
+                       printf("failed to set carveout for %s: %d\n", node,
                               err);
+                       return err;
+               }
 
-               return err;
-       }
+               if (copy)
+                       free(copy);
 
-       err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
-                                 "framebuffer", NULL, 0, 0);
-       if (err < 0) {
-               printf("failed to set carveout for %s: %d\n", node, err);
-               return err;
+               index++;
        }
 
        return 0;