All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210
@ 2021-09-03 13:16 Thierry Reding
  2021-09-03 13:16 ` [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops Thierry Reding
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

Hi,

The first handful of patches are preparatory work to make the fdtdec
carveout helpers a bit more flexible and clean them up a little bit
while the final 4 patches make use of the improved helpers to copy
the EMC frequency tables that can be passed to U-Boot from earlier
bootloaders.

Thanks,
Thierry

Thierry Reding (9):
  fdtdec: Allow using fdtdec_get_carveout() in loops
  fdtdec: Support retrieving the name of a carveout
  fdtdec: Support compatible string list for reserved memory
  fdtdec: Reorder fdtdec_set_carveout() parameters for consistency
  fdtdec: Support reserved-memory flags
  ARM: tegra: Support multiple reserved memory regions
  ARM: tegra: Support EMC frequency tables on Tegra210
  ARM: tegra: Refactor DT update helpers
  ARM: tegra: Copy memory-region-names property

 arch/arm/cpu/armv8/fsl-layerscape/soc.c |   3 +-
 arch/arm/include/asm/arch-tegra/board.h |  10 ++
 arch/arm/mach-tegra/dt-setup.c          | 147 ++++++++++++++++++++++++
 arch/riscv/lib/fdt_fixup.c              |   2 +-
 board/nvidia/p2371-2180/p2371-2180.c    |  94 ++-------------
 board/nvidia/p2771-0000/p2771-0000.c    |  98 ++--------------
 board/nvidia/p3450-0000/p3450-0000.c    |  96 ++--------------
 include/configs/tegra210-common.h       |   2 +-
 include/fdtdec.h                        |  39 +++++--
 lib/fdtdec.c                            |  99 ++++++++++++++--
 lib/fdtdec_test.c                       |   7 +-
 lib/optee/optee.c                       |   4 +-
 test/dm/fdtdec.c                        |  28 +++--
 13 files changed, 321 insertions(+), 308 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:09   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 2/9] fdtdec: Support retrieving the name of a carveout Thierry Reding
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

In order make it possible to use fdtdec_get_carveout() in loops, return
FDT_ERR_NOTFOUND when the passed-in index exceeds the number of phandles
present in the given property.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 337c4443b032..7f6b6d523232 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1469,7 +1469,7 @@ int fdtdec_get_carveout(const void *blob, const char *node, const char *name,
 
 	if (len < (sizeof(phandle) * (index + 1))) {
 		debug("invalid phandle index\n");
-		return -FDT_ERR_BADPHANDLE;
+		return -FDT_ERR_NOTFOUND;
 	}
 
 	phandle = fdt32_to_cpu(prop[index]);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/9] fdtdec: Support retrieving the name of a carveout
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
  2021-09-03 13:16 ` [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:09   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 3/9] fdtdec: Support compatible string list for reserved memory Thierry Reding
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

When retrieving a given carveout for a device, allow callers to query
the name. This helps differentiating between carveouts when there are
more than one.

This is also useful when copying carveouts to help assign a meaningful
name that cannot always be guessed.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 board/nvidia/p2371-2180/p2371-2180.c |  2 +-
 board/nvidia/p2771-0000/p2771-0000.c |  2 +-
 board/nvidia/p3450-0000/p3450-0000.c |  2 +-
 include/fdtdec.h                     |  8 +++++---
 lib/fdtdec.c                         | 12 ++++++++----
 lib/fdtdec_test.c                    |  3 ++-
 6 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index 7423a97ad0e3..1f7aa0050cde 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -128,7 +128,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	struct fdt_memory fb;
 	int err;
 
-	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb);
+	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c
index 508c4d27b7fb..aca86c342680 100644
--- a/board/nvidia/p2771-0000/p2771-0000.c
+++ b/board/nvidia/p2771-0000/p2771-0000.c
@@ -104,7 +104,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	struct fdt_memory fb;
 	int err;
 
-	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb);
+	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c
index f4741cfd1e4a..132eb824c675 100644
--- a/board/nvidia/p3450-0000/p3450-0000.c
+++ b/board/nvidia/p3450-0000/p3450-0000.c
@@ -128,7 +128,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	struct fdt_memory fb;
 	int err;
 
-	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb);
+	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 8ac20c9a64f7..265ee54d41be 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1071,14 +1071,16 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
  *
  * @param blob		FDT blob
  * @param node		name of a node
- * @param name		name of the property in the given node that contains
+ * @param prop_name	name of the property in the given node that contains
  *			the phandle for the carveout
  * @param index		index of the phandle for which to read the carveout
  * @param carveout	return location for the carveout information
+ * @param name		return location for the carveout name
  * @return 0 on success or a negative error code on failure
  */
-int fdtdec_get_carveout(const void *blob, const char *node, const char *name,
-			unsigned int index, struct fdt_memory *carveout);
+int fdtdec_get_carveout(const void *blob, const char *node,
+			const char *prop_name, unsigned int index,
+			struct fdt_memory *carveout, const char **name);
 
 /**
  * fdtdec_set_carveout() - sets a carveout region for a given node
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 7f6b6d523232..19b8efb0d302 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1444,8 +1444,9 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
 	return 0;
 }
 
-int fdtdec_get_carveout(const void *blob, const char *node, const char *name,
-			unsigned int index, struct fdt_memory *carveout)
+int fdtdec_get_carveout(const void *blob, const char *node,
+			const char *prop_name, unsigned int index,
+			struct fdt_memory *carveout, const char **name)
 {
 	const fdt32_t *prop;
 	uint32_t phandle;
@@ -1456,9 +1457,9 @@ int fdtdec_get_carveout(const void *blob, const char *node, const char *name,
 	if (offset < 0)
 		return offset;
 
-	prop = fdt_getprop(blob, offset, name, &len);
+	prop = fdt_getprop(blob, offset, prop_name, &len);
 	if (!prop) {
-		debug("failed to get %s for %s\n", name, node);
+		debug("failed to get %s for %s\n", prop_name, node);
 		return -FDT_ERR_NOTFOUND;
 	}
 
@@ -1480,6 +1481,9 @@ int fdtdec_get_carveout(const void *blob, const char *node, const char *name,
 		return offset;
 	}
 
+	if (name)
+		*name = fdt_get_name(blob, offset, NULL);
+
 	carveout->start = fdtdec_get_addr_size_auto_noparent(blob, offset,
 							     "reg", 0, &size,
 							     true);
diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c
index e0c6e0971cd9..760aca2669dc 100644
--- a/lib/fdtdec_test.c
+++ b/lib/fdtdec_test.c
@@ -214,7 +214,8 @@ static int check_fdt_carveout(void *fdt, uint32_t address_cells,
 	printf("carveout: %pap-%pap na=%u ns=%u: ", &expected.start,
 	       &expected.end, address_cells, size_cells);
 
-	CHECK(fdtdec_get_carveout(fdt, name, "memory-region", 0, &carveout));
+	CHECK(fdtdec_get_carveout(fdt, name, "memory-region", 0, &carveout,
+				  NULL));
 
 	if ((carveout.start != expected.start) ||
 	    (carveout.end != expected.end)) {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/9] fdtdec: Support compatible string list for reserved memory
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
  2021-09-03 13:16 ` [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops Thierry Reding
  2021-09-03 13:16 ` [PATCH 2/9] fdtdec: Support retrieving the name of a carveout Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:09   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 4/9] fdtdec: Reorder fdtdec_set_carveout() parameters for consistency Thierry Reding
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

Reserved memory nodes can have a compatible string list to identify the
type of reserved memory that they represent. Support specifying an
optional compatible string list when creating these nodes.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c |  3 +-
 arch/riscv/lib/fdt_fixup.c              |  2 +-
 board/nvidia/p2371-2180/p2371-2180.c    |  5 +-
 board/nvidia/p2771-0000/p2771-0000.c    |  5 +-
 board/nvidia/p3450-0000/p3450-0000.c    |  5 +-
 include/fdtdec.h                        | 17 ++++--
 lib/fdtdec.c                            | 69 ++++++++++++++++++++++++-
 lib/fdtdec_test.c                       |  4 +-
 lib/optee/optee.c                       |  1 +
 test/dm/fdtdec.c                        | 18 +++----
 10 files changed, 105 insertions(+), 24 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 42a096854629..faac618dc48a 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -54,7 +54,8 @@ int ls_gic_rd_tables_init(void *blob)
 
 	lpi_base.start = addr;
 	lpi_base.end = addr + size - 1;
-	ret = fdtdec_add_reserved_memory(blob, "lpi_rd_table", &lpi_base, NULL, false);
+	ret = fdtdec_add_reserved_memory(blob, "lpi_rd_table", &lpi_base, NULL,
+					 NULL, 0, false);
 	if (ret) {
 		debug("%s: failed to add reserved memory\n", __func__);
 		return ret;
diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index f636b2844978..96c78baeb47d 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -76,7 +76,7 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
 		pmp_mem.start = addr;
 		pmp_mem.end = addr + size - 1;
 		err = fdtdec_add_reserved_memory(dst, basename, &pmp_mem,
-						 &phandle, false);
+						 NULL, 0, &phandle, false);
 		if (err < 0 && err != -FDT_ERR_EXISTS) {
 			log_err("failed to add reserved memory: %d\n", err);
 			return err;
diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index 1f7aa0050cde..58077255d073 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -128,7 +128,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	struct fdt_memory fb;
 	int err;
 
-	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL);
+	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
+				  NULL, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
@@ -138,7 +139,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	}
 
 	err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer",
-				  &fb);
+				  NULL, 0, &fb);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c
index aca86c342680..e35e6b6f48dc 100644
--- a/board/nvidia/p2771-0000/p2771-0000.c
+++ b/board/nvidia/p2771-0000/p2771-0000.c
@@ -104,7 +104,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	struct fdt_memory fb;
 	int err;
 
-	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL);
+	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
+				  NULL, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
@@ -114,7 +115,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	}
 
 	err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer",
-				  &fb);
+				  NULL, 0, &fb);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c
index 132eb824c675..d9ef45af5eea 100644
--- a/board/nvidia/p3450-0000/p3450-0000.c
+++ b/board/nvidia/p3450-0000/p3450-0000.c
@@ -128,7 +128,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	struct fdt_memory fb;
 	int err;
 
-	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL);
+	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
+				  NULL, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
@@ -138,7 +139,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	}
 
 	err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer",
-				  &fb);
+				  NULL, 0, &fb);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 265ee54d41be..489f5063763b 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1028,7 +1028,8 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
  *     };
  *     uint32_t phandle;
  *
- *     fdtdec_add_reserved_memory(fdt, "framebuffer", &fb, &phandle, false);
+ *     fdtdec_add_reserved_memory(fdt, "framebuffer", &fb, NULL, 0, &phandle,
+ *                                false);
  *
  * This results in the following subnode being added to the top-level
  * /reserved-memory node:
@@ -1053,6 +1054,8 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
  * @param blob		FDT blob
  * @param basename	base name of the node to create
  * @param carveout	information about the carveout region
+ * @param compatibles	list of compatible strings for the carveout region
+ * @param count		number of compatible strings for the carveout region
  * @param phandlep	return location for the phandle of the carveout region
  *			can be NULL if no phandle should be added
  * @param no_map	add "no-map" property if true
@@ -1060,6 +1063,7 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
  */
 int fdtdec_add_reserved_memory(void *blob, const char *basename,
 			       const struct fdt_memory *carveout,
+			       const char **compatibles, unsigned int count,
 			       uint32_t *phandlep, bool no_map);
 
 /**
@@ -1076,11 +1080,14 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
  * @param index		index of the phandle for which to read the carveout
  * @param carveout	return location for the carveout information
  * @param name		return location for the carveout name
+ * @param compatiblesp	return location for compatible strings
+ * @param countp		return location for the number of compatible strings
  * @return 0 on success or a negative error code on failure
  */
 int fdtdec_get_carveout(const void *blob, const char *node,
 			const char *prop_name, unsigned int index,
-			struct fdt_memory *carveout, const char **name);
+			struct fdt_memory *carveout, const char **name,
+			const char ***compatiblesp, unsigned int *countp);
 
 /**
  * fdtdec_set_carveout() - sets a carveout region for a given node
@@ -1098,7 +1105,8 @@ int fdtdec_get_carveout(const void *blob, const char *node,
  *         .end = 0x934b2fff,
  *     };
  *
- *     fdtdec_set_carveout(fdt, node, "memory-region", 0, "framebuffer", &fb);
+ *     fdtdec_set_carveout(fdt, node, "memory-region", 0, "framebuffer", NULL,
+ *                         0, &fb);
  *
  * dc@54200000 is a display controller and was set up by the bootloader to
  * scan out the framebuffer specified by "fb". This would cause the following
@@ -1137,10 +1145,13 @@ int fdtdec_get_carveout(const void *blob, const char *node,
  * @param index		index of the phandle to store
  * @param name		base name of the reserved-memory node to create
  * @param carveout	information about the carveout to add
+ * @param compatibles	compatible strings to set for the carveout
+ * @param count		number of compatible strings
  * @return 0 on success or a negative error code on failure
  */
 int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
 			unsigned int index, const char *name,
+			const char **compatibles, unsigned int count,
 			const struct fdt_memory *carveout);
 
 /**
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 19b8efb0d302..ba1fefaeef9d 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1331,6 +1331,7 @@ static int fdtdec_init_reserved_memory(void *blob)
 
 int fdtdec_add_reserved_memory(void *blob, const char *basename,
 			       const struct fdt_memory *carveout,
+			       const char **compatibles, unsigned int count,
 			       uint32_t *phandlep, bool no_map)
 {
 	fdt32_t cells[4] = {}, *ptr = cells;
@@ -1437,6 +1438,28 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
 			return err;
 	}
 
+	if (compatibles && count > 0) {
+		size_t length = 0, len = 0;
+		unsigned int i;
+		char *buffer;
+
+		for (i = 0; i < count; i++)
+			length += strlen(compatibles[i]) + 1;
+
+		buffer = malloc(length);
+		if (!buffer)
+			return -FDT_ERR_INTERNAL;
+
+		for (i = 0; i < count; i++)
+			len += strlcpy(buffer + len, compatibles[i],
+				       length - len) + 1;
+
+		err = fdt_setprop(blob, node, "compatible", buffer, length);
+		free(buffer);
+		if (err < 0)
+			return err;
+	}
+
 	/* return the phandle for the new node for the caller to use */
 	if (phandlep)
 		*phandlep = phandle;
@@ -1446,7 +1469,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
 
 int fdtdec_get_carveout(const void *blob, const char *node,
 			const char *prop_name, unsigned int index,
-			struct fdt_memory *carveout, const char **name)
+			struct fdt_memory *carveout, const char **name,
+			const char ***compatiblesp, unsigned int *countp)
 {
 	const fdt32_t *prop;
 	uint32_t phandle;
@@ -1484,6 +1508,45 @@ int fdtdec_get_carveout(const void *blob, const char *node,
 	if (name)
 		*name = fdt_get_name(blob, offset, NULL);
 
+	if (compatiblesp) {
+		const char **compatibles = NULL;
+		const char *start, *end, *ptr;
+		unsigned int count = 0;
+
+		prop = fdt_getprop(blob, offset, "compatible", &len);
+		if (!prop)
+			goto skip_compat;
+
+		start = ptr = (const char *)prop;
+		end = start + len;
+
+		while (ptr < end) {
+			ptr = strchrnul(ptr, '\0');
+			count++;
+			ptr++;
+		}
+
+		compatibles = malloc(sizeof(ptr) * count);
+		if (!compatibles)
+			return -FDT_ERR_INTERNAL;
+
+		ptr = start;
+		count = 0;
+
+		while (ptr < end) {
+			compatibles[count] = ptr;
+			ptr = strchrnul(ptr, '\0');
+			count++;
+			ptr++;
+		}
+
+skip_compat:
+		*compatiblesp = compatibles;
+
+		if (countp)
+			*countp = count;
+	}
+
 	carveout->start = fdtdec_get_addr_size_auto_noparent(blob, offset,
 							     "reg", 0, &size,
 							     true);
@@ -1499,6 +1562,7 @@ int fdtdec_get_carveout(const void *blob, const char *node,
 
 int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
 			unsigned int index, const char *name,
+			const char **compatibles, unsigned int count,
 			const struct fdt_memory *carveout)
 {
 	uint32_t phandle;
@@ -1506,7 +1570,8 @@ int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
 	fdt32_t value;
 	void *prop;
 
-	err = fdtdec_add_reserved_memory(blob, name, carveout, &phandle, false);
+	err = fdtdec_add_reserved_memory(blob, name, carveout, compatibles,
+					 count, &phandle, false);
 	if (err < 0) {
 		debug("failed to add reserved memory: %d\n", err);
 		return err;
diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c
index 760aca2669dc..72c3001a2105 100644
--- a/lib/fdtdec_test.c
+++ b/lib/fdtdec_test.c
@@ -190,7 +190,7 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns)
 	CHECK(fdt_setprop(fdt, offset, "reg", cells, (na + ns) * sizeof(*cells)));
 
 	return fdtdec_set_carveout(fdt, name, "memory-region", 0,
-				   "framebuffer", &carveout);
+				   "framebuffer", NULL, 0, &carveout);
 }
 
 static int check_fdt_carveout(void *fdt, uint32_t address_cells,
@@ -215,7 +215,7 @@ static int check_fdt_carveout(void *fdt, uint32_t address_cells,
 	       &expected.end, address_cells, size_cells);
 
 	CHECK(fdtdec_get_carveout(fdt, name, "memory-region", 0, &carveout,
-				  NULL));
+				  NULL, NULL, NULL));
 
 	if ((carveout.start != expected.start) ||
 	    (carveout.end != expected.end)) {
diff --git a/lib/optee/optee.c b/lib/optee/optee.c
index 672690dc5389..763d7057287d 100644
--- a/lib/optee/optee.c
+++ b/lib/optee/optee.c
@@ -184,6 +184,7 @@ int optee_copy_fdt_nodes(void *new_blob)
 				ret = fdtdec_add_reserved_memory(new_blob,
 								 nodename,
 								 &carveout,
+								 NULL, 0,
 								 NULL, true);
 				free(oldname);
 
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
index 1f630ea3eee1..7b543e7b998e 100644
--- a/test/dm/fdtdec.c
+++ b/test/dm/fdtdec.c
@@ -30,19 +30,19 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
 	resv.end = 0x2000;
 	ut_assertok(fdtdec_set_carveout(blob, "/a-test",
 					"memory-region", 2, "test_resv1",
-					&resv));
+					NULL, 0, &resv));
 
 	resv.start = 0x10000;
 	resv.end = 0x20000;
 	ut_assertok(fdtdec_set_carveout(blob, "/a-test",
 					"memory-region", 1, "test_resv2",
-					&resv));
+					NULL, 0, &resv));
 
 	resv.start = 0x100000;
 	resv.end = 0x200000;
 	ut_assertok(fdtdec_set_carveout(blob, "/a-test",
 					"memory-region", 0, "test_resv3",
-					&resv));
+					NULL, 0, &resv));
 
 	offset = fdt_path_offset(blob, "/a-test");
 	ut_assert(offset > 0);
@@ -80,8 +80,8 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
 	/* Insert a memory region in /reserved-memory node */
 	resv.start = 0x1000;
 	resv.end = 0x1fff;
-	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region",
-					       &resv, &phandle, false));
+	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region", &resv,
+					       NULL, 0, &phandle, false));
 
 	/* Test /reserve-memory and its subnode should exist */
 	parent = fdt_path_offset(blob, "/reserved-memory");
@@ -101,8 +101,8 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
 
 	resv.start = 0x2000;
 	resv.end = 0x2fff;
-	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region1",
-					       &resv, &phandle1, true));
+	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region1", &resv,
+					       NULL, 0, &phandle1, true));
 	subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region1");
 	ut_assert(subnode > 0);
 
@@ -118,8 +118,8 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
 	 */
 	resv.start = 0x1000;
 	resv.end = 0x1fff;
-	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region2",
-					       &resv, &phandle1, false));
+	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region2", &resv,
+					       NULL, 0, &phandle1, false));
 	subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region2");
 	ut_assert(subnode < 0);
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/9] fdtdec: Reorder fdtdec_set_carveout() parameters for consistency
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
                   ` (2 preceding siblings ...)
  2021-09-03 13:16 ` [PATCH 3/9] fdtdec: Support compatible string list for reserved memory Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:09   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 5/9] fdtdec: Support reserved-memory flags Thierry Reding
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

The fdtdec_set_carveout() function's parameters are inconsistent with
the parameters passed to fdtdec_add_reserved_memory(). Fix up the order
to make it more consistent.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 board/nvidia/p2371-2180/p2371-2180.c |  4 ++--
 board/nvidia/p2771-0000/p2771-0000.c |  4 ++--
 board/nvidia/p3450-0000/p3450-0000.c |  4 ++--
 include/fdtdec.h                     |  8 ++++----
 lib/fdtdec.c                         |  6 +++---
 lib/fdtdec_test.c                    |  4 ++--
 test/dm/fdtdec.c                     | 15 ++++++---------
 7 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index 58077255d073..bc0a133725ed 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -138,8 +138,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 		return err;
 	}
 
-	err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer",
-				  NULL, 0, &fb);
+	err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
+				  "framebuffer", NULL, 0);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c
index e35e6b6f48dc..cde5eff02f2a 100644
--- a/board/nvidia/p2771-0000/p2771-0000.c
+++ b/board/nvidia/p2771-0000/p2771-0000.c
@@ -114,8 +114,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 		return err;
 	}
 
-	err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer",
-				  NULL, 0, &fb);
+	err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
+				  "framebuffer", NULL, 0);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c
index d9ef45af5eea..541863cef361 100644
--- a/board/nvidia/p3450-0000/p3450-0000.c
+++ b/board/nvidia/p3450-0000/p3450-0000.c
@@ -138,8 +138,8 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 		return err;
 	}
 
-	err = fdtdec_set_carveout(dst, node, "memory-region", 0, "framebuffer",
-				  NULL, 0, &fb);
+	err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
+				  "framebuffer", NULL, 0);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 489f5063763b..6d56c67d111c 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1143,16 +1143,16 @@ int fdtdec_get_carveout(const void *blob, const char *node,
  * @param prop_name	name of the property in which to store the phandle of
  *			the carveout
  * @param index		index of the phandle to store
- * @param name		base name of the reserved-memory node to create
  * @param carveout	information about the carveout to add
+ * @param name		base name of the reserved-memory node to create
  * @param compatibles	compatible strings to set for the carveout
  * @param count		number of compatible strings
  * @return 0 on success or a negative error code on failure
  */
 int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
-			unsigned int index, const char *name,
-			const char **compatibles, unsigned int count,
-			const struct fdt_memory *carveout);
+			unsigned int index, const struct fdt_memory *carveout,
+			const char *name, const char **compatibles,
+			unsigned int count);
 
 /**
  * Set up the device tree ready for use
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index ba1fefaeef9d..60e537b8d61e 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1561,9 +1561,9 @@ skip_compat:
 }
 
 int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
-			unsigned int index, const char *name,
-			const char **compatibles, unsigned int count,
-			const struct fdt_memory *carveout)
+			unsigned int index, const struct fdt_memory *carveout,
+			const char *name, const char **compatibles,
+			unsigned int count)
 {
 	uint32_t phandle;
 	int err, offset, len;
diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c
index 72c3001a2105..3af9fb5da604 100644
--- a/lib/fdtdec_test.c
+++ b/lib/fdtdec_test.c
@@ -189,8 +189,8 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns)
 	offset = CHECK(fdt_add_subnode(fdt, 0, name + 1));
 	CHECK(fdt_setprop(fdt, offset, "reg", cells, (na + ns) * sizeof(*cells)));
 
-	return fdtdec_set_carveout(fdt, name, "memory-region", 0,
-				   "framebuffer", NULL, 0, &carveout);
+	return fdtdec_set_carveout(fdt, name, "memory-region", 0, &carveout,
+				   "framebuffer", NULL, 0);
 }
 
 static int check_fdt_carveout(void *fdt, uint32_t address_cells,
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
index 7b543e7b998e..385aa77a686f 100644
--- a/test/dm/fdtdec.c
+++ b/test/dm/fdtdec.c
@@ -28,21 +28,18 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
 
 	resv.start = 0x1000;
 	resv.end = 0x2000;
-	ut_assertok(fdtdec_set_carveout(blob, "/a-test",
-					"memory-region", 2, "test_resv1",
-					NULL, 0, &resv));
+	ut_assertok(fdtdec_set_carveout(blob, "/a-test", "memory-region", 2,
+					&resv, "test_resv1", NULL, 0));
 
 	resv.start = 0x10000;
 	resv.end = 0x20000;
-	ut_assertok(fdtdec_set_carveout(blob, "/a-test",
-					"memory-region", 1, "test_resv2",
-					NULL, 0, &resv));
+	ut_assertok(fdtdec_set_carveout(blob, "/a-test", "memory-region", 1,
+					&resv, "test_resv2", NULL, 0));
 
 	resv.start = 0x100000;
 	resv.end = 0x200000;
-	ut_assertok(fdtdec_set_carveout(blob, "/a-test",
-					"memory-region", 0, "test_resv3",
-					NULL, 0, &resv));
+	ut_assertok(fdtdec_set_carveout(blob, "/a-test", "memory-region", 0,
+					&resv, "test_resv3", NULL, 0));
 
 	offset = fdt_path_offset(blob, "/a-test");
 	ut_assert(offset > 0);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5/9] fdtdec: Support reserved-memory flags
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
                   ` (3 preceding siblings ...)
  2021-09-03 13:16 ` [PATCH 4/9] fdtdec: Reorder fdtdec_set_carveout() parameters for consistency Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:09   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 6/9] ARM: tegra: Support multiple reserved memory regions Thierry Reding
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

Reserved memory nodes can have additional flags. Support reading and
writing these flags to ensure that reserved memory nodes can be properly
parsed and emitted.

This converts support for the existing "no-map" flag to avoid extending
the argument list for fdtdec_add_reserved_memory() to excessive length.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c |  2 +-
 arch/riscv/lib/fdt_fixup.c              |  2 +-
 board/nvidia/p2371-2180/p2371-2180.c    |  4 ++--
 board/nvidia/p2771-0000/p2771-0000.c    |  4 ++--
 board/nvidia/p3450-0000/p3450-0000.c    |  4 ++--
 include/fdtdec.h                        | 20 +++++++++++-------
 lib/fdtdec.c                            | 28 ++++++++++++++++---------
 lib/fdtdec_test.c                       |  4 ++--
 lib/optee/optee.c                       |  3 ++-
 test/dm/fdtdec.c                        | 13 ++++++------
 10 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index faac618dc48a..6cebd8259a58 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -55,7 +55,7 @@ int ls_gic_rd_tables_init(void *blob)
 	lpi_base.start = addr;
 	lpi_base.end = addr + size - 1;
 	ret = fdtdec_add_reserved_memory(blob, "lpi_rd_table", &lpi_base, NULL,
-					 NULL, 0, false);
+					 NULL, 0, 0);
 	if (ret) {
 		debug("%s: failed to add reserved memory\n", __func__);
 		return ret;
diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index 96c78baeb47d..8858b1bac870 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -76,7 +76,7 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
 		pmp_mem.start = addr;
 		pmp_mem.end = addr + size - 1;
 		err = fdtdec_add_reserved_memory(dst, basename, &pmp_mem,
-						 NULL, 0, &phandle, false);
+						 NULL, 0, &phandle, 0);
 		if (err < 0 && err != -FDT_ERR_EXISTS) {
 			log_err("failed to add reserved memory: %d\n", err);
 			return err;
diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index bc0a133725ed..137c7d3b12c3 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -129,7 +129,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	int err;
 
 	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
-				  NULL, NULL);
+				  NULL, NULL, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
@@ -139,7 +139,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	}
 
 	err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
-				  "framebuffer", NULL, 0);
+				  "framebuffer", NULL, 0, 0);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c
index cde5eff02f2a..3d2653d1f075 100644
--- a/board/nvidia/p2771-0000/p2771-0000.c
+++ b/board/nvidia/p2771-0000/p2771-0000.c
@@ -105,7 +105,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	int err;
 
 	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
-				  NULL, NULL);
+				  NULL, NULL, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
@@ -115,7 +115,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	}
 
 	err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
-				  "framebuffer", NULL, 0);
+				  "framebuffer", NULL, 0, 0);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c
index 541863cef361..cdedea18a176 100644
--- a/board/nvidia/p3450-0000/p3450-0000.c
+++ b/board/nvidia/p3450-0000/p3450-0000.c
@@ -129,7 +129,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	int err;
 
 	err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL,
-				  NULL, NULL);
+				  NULL, NULL, NULL);
 	if (err < 0) {
 		if (err != -FDT_ERR_NOTFOUND)
 			printf("failed to get carveout for %s: %d\n", node,
@@ -139,7 +139,7 @@ static int ft_copy_carveout(void *dst, const void *src, const char *node)
 	}
 
 	err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb,
-				  "framebuffer", NULL, 0);
+				  "framebuffer", NULL, 0, 0);
 	if (err < 0) {
 		printf("failed to set carveout for %s: %d\n", node, err);
 		return err;
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 6d56c67d111c..a548fe8290e2 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1010,6 +1010,9 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
 	return fdt_setprop_u32(blob, node, "phandle", phandle);
 }
 
+/* add "no-map" property */
+#define FDTDEC_RESERVED_MEMORY_NO_MAP (1 << 0)
+
 /**
  * fdtdec_add_reserved_memory() - add or find a reserved-memory node
  *
@@ -1029,7 +1032,7 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
  *     uint32_t phandle;
  *
  *     fdtdec_add_reserved_memory(fdt, "framebuffer", &fb, NULL, 0, &phandle,
- *                                false);
+ *                                0);
  *
  * This results in the following subnode being added to the top-level
  * /reserved-memory node:
@@ -1058,13 +1061,13 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
  * @param count		number of compatible strings for the carveout region
  * @param phandlep	return location for the phandle of the carveout region
  *			can be NULL if no phandle should be added
- * @param no_map	add "no-map" property if true
+ * @param flags		bitmask of flags to set for the carveout region
  * @return 0 on success or a negative error code on failure
  */
 int fdtdec_add_reserved_memory(void *blob, const char *basename,
 			       const struct fdt_memory *carveout,
 			       const char **compatibles, unsigned int count,
-			       uint32_t *phandlep, bool no_map);
+			       uint32_t *phandlep, unsigned long flags);
 
 /**
  * fdtdec_get_carveout() - reads a carveout from an FDT
@@ -1081,13 +1084,15 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
  * @param carveout	return location for the carveout information
  * @param name		return location for the carveout name
  * @param compatiblesp	return location for compatible strings
- * @param countp		return location for the number of compatible strings
+ * @param countp	return location for the number of compatible strings
+ * @param flags		return location for the flags of the carveout
  * @return 0 on success or a negative error code on failure
  */
 int fdtdec_get_carveout(const void *blob, const char *node,
 			const char *prop_name, unsigned int index,
 			struct fdt_memory *carveout, const char **name,
-			const char ***compatiblesp, unsigned int *countp);
+			const char ***compatiblesp, unsigned int *countp,
+			unsigned long *flags);
 
 /**
  * fdtdec_set_carveout() - sets a carveout region for a given node
@@ -1106,7 +1111,7 @@ int fdtdec_get_carveout(const void *blob, const char *node,
  *     };
  *
  *     fdtdec_set_carveout(fdt, node, "memory-region", 0, "framebuffer", NULL,
- *                         0, &fb);
+ *                         0, &fb, 0);
  *
  * dc@54200000 is a display controller and was set up by the bootloader to
  * scan out the framebuffer specified by "fb". This would cause the following
@@ -1147,12 +1152,13 @@ int fdtdec_get_carveout(const void *blob, const char *node,
  * @param name		base name of the reserved-memory node to create
  * @param compatibles	compatible strings to set for the carveout
  * @param count		number of compatible strings
+ * @param flags		bitmask of flags to set for the carveout
  * @return 0 on success or a negative error code on failure
  */
 int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
 			unsigned int index, const struct fdt_memory *carveout,
 			const char *name, const char **compatibles,
-			unsigned int count);
+			unsigned int count, unsigned long flags);
 
 /**
  * Set up the device tree ready for use
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 60e537b8d61e..6e0f51a1a7a4 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1332,7 +1332,7 @@ static int fdtdec_init_reserved_memory(void *blob)
 int fdtdec_add_reserved_memory(void *blob, const char *basename,
 			       const struct fdt_memory *carveout,
 			       const char **compatibles, unsigned int count,
-			       uint32_t *phandlep, bool no_map)
+			       uint32_t *phandlep, unsigned long flags)
 {
 	fdt32_t cells[4] = {}, *ptr = cells;
 	uint32_t upper, lower, phandle;
@@ -1402,6 +1402,12 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
 	if (node < 0)
 		return node;
 
+	if (flags & FDTDEC_RESERVED_MEMORY_NO_MAP) {
+		err = fdt_setprop(blob, node, "no-map", NULL, 0);
+		if (err < 0)
+			return err;
+	}
+
 	if (phandlep) {
 		err = fdt_generate_phandle(blob, &phandle);
 		if (err < 0)
@@ -1432,12 +1438,6 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
 	if (err < 0)
 		return err;
 
-	if (no_map) {
-		err = fdt_setprop(blob, node, "no-map", NULL, 0);
-		if (err < 0)
-			return err;
-	}
-
 	if (compatibles && count > 0) {
 		size_t length = 0, len = 0;
 		unsigned int i;
@@ -1470,7 +1470,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
 int fdtdec_get_carveout(const void *blob, const char *node,
 			const char *prop_name, unsigned int index,
 			struct fdt_memory *carveout, const char **name,
-			const char ***compatiblesp, unsigned int *countp)
+			const char ***compatiblesp, unsigned int *countp,
+			unsigned long *flags)
 {
 	const fdt32_t *prop;
 	uint32_t phandle;
@@ -1557,13 +1558,20 @@ skip_compat:
 
 	carveout->end = carveout->start + size - 1;
 
+	if (flags) {
+		*flags = 0;
+
+		if (fdtdec_get_bool(blob, offset, "no-map"))
+			*flags |= FDTDEC_RESERVED_MEMORY_NO_MAP;
+	}
+
 	return 0;
 }
 
 int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
 			unsigned int index, const struct fdt_memory *carveout,
 			const char *name, const char **compatibles,
-			unsigned int count)
+			unsigned int count, unsigned long flags)
 {
 	uint32_t phandle;
 	int err, offset, len;
@@ -1571,7 +1579,7 @@ int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name,
 	void *prop;
 
 	err = fdtdec_add_reserved_memory(blob, name, carveout, compatibles,
-					 count, &phandle, false);
+					 count, &phandle, flags);
 	if (err < 0) {
 		debug("failed to add reserved memory: %d\n", err);
 		return err;
diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c
index 3af9fb5da604..85351c75ca29 100644
--- a/lib/fdtdec_test.c
+++ b/lib/fdtdec_test.c
@@ -190,7 +190,7 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns)
 	CHECK(fdt_setprop(fdt, offset, "reg", cells, (na + ns) * sizeof(*cells)));
 
 	return fdtdec_set_carveout(fdt, name, "memory-region", 0, &carveout,
-				   "framebuffer", NULL, 0);
+				   "framebuffer", NULL, 0, 0);
 }
 
 static int check_fdt_carveout(void *fdt, uint32_t address_cells,
@@ -215,7 +215,7 @@ static int check_fdt_carveout(void *fdt, uint32_t address_cells,
 	       &expected.end, address_cells, size_cells);
 
 	CHECK(fdtdec_get_carveout(fdt, name, "memory-region", 0, &carveout,
-				  NULL, NULL, NULL));
+				  NULL, NULL, NULL, NULL));
 
 	if ((carveout.start != expected.start) ||
 	    (carveout.end != expected.end)) {
diff --git a/lib/optee/optee.c b/lib/optee/optee.c
index 763d7057287d..863eb0dd237a 100644
--- a/lib/optee/optee.c
+++ b/lib/optee/optee.c
@@ -168,6 +168,7 @@ int optee_copy_fdt_nodes(void *new_blob)
 					.start = res.start,
 					.end = res.end,
 				};
+				unsigned long flags = FDTDEC_RESERVED_MEMORY_NO_MAP;
 				char *oldname, *nodename, *tmp;
 
 				oldname = strdup(name);
@@ -185,7 +186,7 @@ int optee_copy_fdt_nodes(void *new_blob)
 								 nodename,
 								 &carveout,
 								 NULL, 0,
-								 NULL, true);
+								 NULL, flags);
 				free(oldname);
 
 				if (ret < 0)
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
index 385aa77a686f..087d4846da89 100644
--- a/test/dm/fdtdec.c
+++ b/test/dm/fdtdec.c
@@ -29,17 +29,17 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
 	resv.start = 0x1000;
 	resv.end = 0x2000;
 	ut_assertok(fdtdec_set_carveout(blob, "/a-test", "memory-region", 2,
-					&resv, "test_resv1", NULL, 0));
+					&resv, "test_resv1", NULL, 0, 0));
 
 	resv.start = 0x10000;
 	resv.end = 0x20000;
 	ut_assertok(fdtdec_set_carveout(blob, "/a-test", "memory-region", 1,
-					&resv, "test_resv2", NULL, 0));
+					&resv, "test_resv2", NULL, 0, 0));
 
 	resv.start = 0x100000;
 	resv.end = 0x200000;
 	ut_assertok(fdtdec_set_carveout(blob, "/a-test", "memory-region", 0,
-					&resv, "test_resv3", NULL, 0));
+					&resv, "test_resv3", NULL, 0, 0));
 
 	offset = fdt_path_offset(blob, "/a-test");
 	ut_assert(offset > 0);
@@ -64,6 +64,7 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
 	fdt_addr_t addr;
 	fdt_size_t size;
 	void *blob;
+	unsigned long flags = FDTDEC_RESERVED_MEMORY_NO_MAP;
 	int blob_sz, parent, subnode;
 	uint32_t phandle, phandle1;
 
@@ -78,7 +79,7 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
 	resv.start = 0x1000;
 	resv.end = 0x1fff;
 	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region", &resv,
-					       NULL, 0, &phandle, false));
+					       NULL, 0, &phandle, 0));
 
 	/* Test /reserve-memory and its subnode should exist */
 	parent = fdt_path_offset(blob, "/reserved-memory");
@@ -99,7 +100,7 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
 	resv.start = 0x2000;
 	resv.end = 0x2fff;
 	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region1", &resv,
-					       NULL, 0, &phandle1, true));
+					       NULL, 0, &phandle1, flags));
 	subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region1");
 	ut_assert(subnode > 0);
 
@@ -116,7 +117,7 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
 	resv.start = 0x1000;
 	resv.end = 0x1fff;
 	ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region2", &resv,
-					       NULL, 0, &phandle1, false));
+					       NULL, 0, &phandle1, 0));
 	subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region2");
 	ut_assert(subnode < 0);
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6/9] ARM: tegra: Support multiple reserved memory regions
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
                   ` (4 preceding siblings ...)
  2021-09-03 13:16 ` [PATCH 5/9] fdtdec: Support reserved-memory flags Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:08   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 7/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

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>
---
 board/nvidia/p2371-2180/p2371-2180.c | 55 +++++++++++++++++++++-------
 board/nvidia/p2771-0000/p2771-0000.c | 55 +++++++++++++++++++++-------
 board/nvidia/p3450-0000/p3450-0000.c | 55 +++++++++++++++++++++-------
 3 files changed, 126 insertions(+), 39 deletions(-)

diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index 137c7d3b12c3..f5126c552b00 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -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;
diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c
index 3d2653d1f075..46c36a22db5e 100644
--- a/board/nvidia/p2771-0000/p2771-0000.c
+++ b/board/nvidia/p2771-0000/p2771-0000.c
@@ -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;
diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c
index cdedea18a176..2c709d9b8117 100644
--- a/board/nvidia/p3450-0000/p3450-0000.c
+++ b/board/nvidia/p3450-0000/p3450-0000.c
@@ -12,6 +12,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>
@@ -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;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 7/9] ARM: tegra: Support EMC frequency tables on Tegra210
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
                   ` (5 preceding siblings ...)
  2021-09-03 13:16 ` [PATCH 6/9] ARM: tegra: Support multiple reserved memory regions Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:08   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 8/9] ARM: tegra: Refactor DT update helpers Thierry Reding
  2021-09-03 13:16 ` [PATCH 9/9] ARM: tegra: Copy memory-region-names property Thierry Reding
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

The EMC frequency tables are created from a training sequence performed
during early boot and passed in via a reserved memory region by nvtboot.
Copy this table to the kernel DTB so that the kernel can use it to scale
the EMC frequency at runtime.

Note that early bootloaders store the EMC table at an address that
currently intersects with the load address of the initial ramdisk. In
order to avoid copying the table to a different address, simply change
the load address for the initial ramdisk in U-Boot.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 board/nvidia/p2371-2180/p2371-2180.c | 1 +
 board/nvidia/p3450-0000/p3450-0000.c | 1 +
 include/configs/tegra210-common.h    | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index f5126c552b00..cd5dc2de629e 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -183,6 +183,7 @@ static void ft_carveout_setup(void *fdt)
 	static const char * const nodes[] = {
 		"/host1x@50000000/dc@54200000",
 		"/host1x@50000000/dc@54240000",
+		"/external-memory-controller@7001b000",
 	};
 	unsigned int i;
 	int err;
diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c
index 2c709d9b8117..dd408d2ebbf8 100644
--- a/board/nvidia/p3450-0000/p3450-0000.c
+++ b/board/nvidia/p3450-0000/p3450-0000.c
@@ -183,6 +183,7 @@ static void ft_carveout_setup(void *fdt)
 	static const char * const nodes[] = {
 		"/host1x@50000000/dc@54200000",
 		"/host1x@50000000/dc@54240000",
+		"/external-memory-controller@7001b000",
 	};
 	unsigned int i;
 	int err;
diff --git a/include/configs/tegra210-common.h b/include/configs/tegra210-common.h
index 2226effe16ab..c38d0f831835 100644
--- a/include/configs/tegra210-common.h
+++ b/include/configs/tegra210-common.h
@@ -48,7 +48,7 @@
 	"kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
 	"fdtfile=" FDTFILE "\0" \
 	"fdt_addr_r=0x83000000\0" \
-	"ramdisk_addr_r=0x83200000\0"
+	"ramdisk_addr_r=0x83420000\0"
 
 /* For USB EHCI controller */
 #define CONFIG_EHCI_IS_TDI
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 8/9] ARM: tegra: Refactor DT update helpers
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
                   ` (6 preceding siblings ...)
  2021-09-03 13:16 ` [PATCH 7/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:08   ` Simon Glass
  2021-09-03 13:16 ` [PATCH 9/9] ARM: tegra: Copy memory-region-names property Thierry Reding
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

Rather than duplicate the Ethernet MAC address and carveout updating
code for each board, move it to a common location and make it more
reusable.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 arch/arm/include/asm/arch-tegra/board.h |  10 ++
 arch/arm/mach-tegra/dt-setup.c          | 118 ++++++++++++++++++++++
 board/nvidia/p2371-2180/p2371-2180.c    | 123 ++---------------------
 board/nvidia/p2771-0000/p2771-0000.c    | 126 ++---------------------
 board/nvidia/p3450-0000/p3450-0000.c    | 127 ++----------------------
 5 files changed, 149 insertions(+), 355 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra/board.h b/arch/arm/include/asm/arch-tegra/board.h
index 24d0db8ced83..cd4d0ee3c953 100644
--- a/arch/arm/include/asm/arch-tegra/board.h
+++ b/arch/arm/include/asm/arch-tegra/board.h
@@ -30,4 +30,14 @@ void pin_mux_nand(void);     /* overridable NAND pinmux setup    */
 void pin_mux_mmc(void);      /* overridable mmc pinmux setup     */
 void pin_mux_display(void);  /* overridable DISPLAY pinmux setup */
 
+/*
+ * Helpers for various standard DT update mechanisms.
+ */
+
+#if defined(CONFIG_ARM64)
+void ft_mac_address_setup(void *fdt);
+void ft_carveout_setup(void *fdt, const char *const *nodes,
+		       unsigned int count);
+#endif
+
 #endif
diff --git a/arch/arm/mach-tegra/dt-setup.c b/arch/arm/mach-tegra/dt-setup.c
index 602b20e6b7e9..894a6358a2c4 100644
--- a/arch/arm/mach-tegra/dt-setup.c
+++ b/arch/arm/mach-tegra/dt-setup.c
@@ -4,6 +4,9 @@
  */
 
 #include <common.h>
+#include <fdtdec.h>
+#include <stdlib.h>
+#include <asm/arch-tegra/cboot.h>
 #include <asm/arch-tegra/gpu.h>
 
 /*
@@ -31,3 +34,118 @@ int ft_system_setup(void *blob, struct bd_info *bd)
 
 	return 0;
 }
+
+#if defined(CONFIG_ARM64)
+void ft_mac_address_setup(void *fdt)
+{
+	const void *cboot_fdt = (const void *)cboot_boot_x0;
+	uint8_t mac[ETH_ALEN], local_mac[ETH_ALEN];
+	const char *path;
+	int offset, err;
+
+	err = cboot_get_ethaddr(cboot_fdt, local_mac);
+	if (err < 0)
+		memset(local_mac, 0, ETH_ALEN);
+
+	path = fdt_get_alias(fdt, "ethernet");
+	if (!path)
+		return;
+
+	debug("ethernet alias found: %s\n", path);
+
+	offset = fdt_path_offset(fdt, path);
+	if (offset < 0) {
+		printf("ethernet alias points to absent node %s\n", path);
+		return;
+	}
+
+	if (is_valid_ethaddr(local_mac)) {
+		err = fdt_setprop(fdt, offset, "local-mac-address", local_mac,
+				  ETH_ALEN);
+		if (!err)
+			debug("Local MAC address set: %pM\n", local_mac);
+	}
+
+	if (eth_env_get_enetaddr("ethaddr", mac)) {
+		if (memcmp(local_mac, mac, ETH_ALEN) != 0) {
+			err = fdt_setprop(fdt, offset, "mac-address", mac,
+					  ETH_ALEN);
+			if (!err)
+				debug("MAC address set: %pM\n", mac);
+		}
+	}
+}
+
+static int ft_copy_carveout(void *dst, const void *src, const char *node)
+{
+	struct fdt_memory carveout;
+	unsigned int index = 0;
+	int err;
+
+	while (true) {
+		const char **compatibles = NULL;
+		unsigned int num_compatibles;
+		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;
+		}
+
+		if (copy)
+			free(copy);
+
+		index++;
+	}
+
+	return 0;
+}
+
+void ft_carveout_setup(void *fdt, const char * const *nodes, unsigned int count)
+{
+	const void *cboot_fdt = (const void *)cboot_boot_x0;
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < count; i++) {
+		printf("copying carveout for %s...\n", nodes[i]);
+
+		err = ft_copy_carveout(fdt, cboot_fdt, nodes[i]);
+		if (err < 0) {
+			if (err != -FDT_ERR_NOTFOUND)
+				printf("failed to copy carveout for %s: %d\n",
+				       nodes[i], err);
+
+			continue;
+		}
+	}
+}
+#endif
diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
index cd5dc2de629e..816c7bec6ae4 100644
--- a/board/nvidia/p2371-2180/p2371-2180.c
+++ b/board/nvidia/p2371-2180/p2371-2180.c
@@ -15,7 +15,7 @@
 #include <linux/libfdt.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
-#include <asm/arch-tegra/cboot.h>
+#include <asm/arch-tegra/board.h>
 #include "../p2571/max77620_init.h"
 
 void pin_mux_mmc(void)
@@ -84,125 +84,16 @@ int tegra_pcie_board_init(void)
 }
 #endif /* PCI */
 
-static void ft_mac_address_setup(void *fdt)
-{
-	const void *cboot_fdt = (const void *)cboot_boot_x0;
-	uint8_t mac[ETH_ALEN], local_mac[ETH_ALEN];
-	const char *path;
-	int offset, err;
-
-	err = cboot_get_ethaddr(cboot_fdt, local_mac);
-	if (err < 0)
-		memset(local_mac, 0, ETH_ALEN);
-
-	path = fdt_get_alias(fdt, "ethernet");
-	if (!path)
-		return;
-
-	debug("ethernet alias found: %s\n", path);
-
-	offset = fdt_path_offset(fdt, path);
-	if (offset < 0) {
-		printf("ethernet alias points to absent node %s\n", path);
-		return;
-	}
-
-	if (is_valid_ethaddr(local_mac)) {
-		err = fdt_setprop(fdt, offset, "local-mac-address", local_mac,
-				  ETH_ALEN);
-		if (!err)
-			debug("Local MAC address set: %pM\n", local_mac);
-	}
-
-	if (eth_env_get_enetaddr("ethaddr", mac)) {
-		if (memcmp(local_mac, mac, ETH_ALEN) != 0) {
-			err = fdt_setprop(fdt, offset, "mac-address", mac,
-					  ETH_ALEN);
-			if (!err)
-				debug("MAC address set: %pM\n", mac);
-		}
-	}
-}
-
-static int ft_copy_carveout(void *dst, const void *src, const char *node)
-{
-	unsigned int index = 0;
-	int err;
-
-	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;
-		}
-
-		if (copy)
-			free(copy);
-
-		index++;
-	}
-
-	return 0;
-}
-
-static void ft_carveout_setup(void *fdt)
-{
-	const void *cboot_fdt = (const void *)cboot_boot_x0;
-	static const char * const nodes[] = {
-		"/host1x@50000000/dc@54200000",
-		"/host1x@50000000/dc@54240000",
-		"/external-memory-controller@7001b000",
-	};
-	unsigned int i;
-	int err;
-
-	for (i = 0; i < ARRAY_SIZE(nodes); i++) {
-		err = ft_copy_carveout(fdt, cboot_fdt, nodes[i]);
-		if (err < 0) {
-			if (err != -FDT_ERR_NOTFOUND)
-				printf("failed to copy carveout for %s: %d\n",
-				       nodes[i], err);
-			continue;
-		}
-	}
-}
+static const char * const nodes[] = {
+	"/host1x@50000000/dc@54200000",
+	"/host1x@50000000/dc@54240000",
+	"/external-memory-controller@7001b000",
+};
 
 int ft_board_setup(void *fdt, struct bd_info *bd)
 {
 	ft_mac_address_setup(fdt);
-	ft_carveout_setup(fdt);
+	ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
 
 	return 0;
 }
diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c
index 46c36a22db5e..5ff89c45423e 100644
--- a/board/nvidia/p2771-0000/p2771-0000.c
+++ b/board/nvidia/p2771-0000/p2771-0000.c
@@ -11,7 +11,7 @@
 #include <net.h>
 #include <stdlib.h>
 #include <linux/libfdt.h>
-#include <asm/arch-tegra/cboot.h>
+#include <asm/arch-tegra/board.h>
 #include "../p2571/max77620_init.h"
 
 void pin_mux_mmc(void)
@@ -60,128 +60,16 @@ int tegra_pcie_board_init(void)
 }
 #endif
 
-static void ft_mac_address_setup(void *fdt)
-{
-	const void *cboot_fdt = (const void *)cboot_boot_x0;
-	uint8_t mac[ETH_ALEN], local_mac[ETH_ALEN];
-	const char *path;
-	int offset, err;
-
-	err = cboot_get_ethaddr(cboot_fdt, local_mac);
-	if (err < 0)
-		memset(local_mac, 0, ETH_ALEN);
-
-	path = fdt_get_alias(fdt, "ethernet");
-	if (!path)
-		return;
-
-	debug("ethernet alias found: %s\n", path);
-
-	offset = fdt_path_offset(fdt, path);
-	if (offset < 0) {
-		printf("ethernet alias points to absent node %s\n", path);
-		return;
-	}
-
-	if (is_valid_ethaddr(local_mac)) {
-		err = fdt_setprop(fdt, offset, "local-mac-address", local_mac,
-				  ETH_ALEN);
-		if (!err)
-			debug("Local MAC address set: %pM\n", local_mac);
-	}
-
-	if (eth_env_get_enetaddr("ethaddr", mac)) {
-		if (memcmp(local_mac, mac, ETH_ALEN) != 0) {
-			err = fdt_setprop(fdt, offset, "mac-address", mac,
-					  ETH_ALEN);
-			if (!err)
-				debug("MAC address set: %pM\n", mac);
-		}
-	}
-}
-
-static int ft_copy_carveout(void *dst, const void *src, const char *node)
-{
-	unsigned int index = 0;
-	int err;
-
-	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;
-		}
-
-		if (copy)
-			free(copy);
-
-		index++;
-	}
-
-	return 0;
-}
-
-static void ft_carveout_setup(void *fdt)
-{
-	const void *cboot_fdt = (const void *)cboot_boot_x0;
-	static const char * const nodes[] = {
-		"/host1x@13e00000/display-hub@15200000/display@15200000",
-		"/host1x@13e00000/display-hub@15200000/display@15210000",
-		"/host1x@13e00000/display-hub@15200000/display@15220000",
-	};
-	unsigned int i;
-	int err;
-
-	for (i = 0; i < ARRAY_SIZE(nodes); i++) {
-		printf("copying carveout for %s...\n", nodes[i]);
-
-		err = ft_copy_carveout(fdt, cboot_fdt, nodes[i]);
-		if (err < 0) {
-			if (err != -FDT_ERR_NOTFOUND)
-				printf("failed to copy carveout for %s: %d\n",
-				       nodes[i], err);
-
-			continue;
-		}
-	}
-}
+static const char * const nodes[] = {
+	"/host1x@13e00000/display-hub@15200000/display@15200000",
+	"/host1x@13e00000/display-hub@15200000/display@15210000",
+	"/host1x@13e00000/display-hub@15200000/display@15220000",
+};
 
 int ft_board_setup(void *fdt, struct bd_info *bd)
 {
 	ft_mac_address_setup(fdt);
-	ft_carveout_setup(fdt);
+	ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
 
 	return 0;
 }
diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c
index dd408d2ebbf8..cad36f56cff8 100644
--- a/board/nvidia/p3450-0000/p3450-0000.c
+++ b/board/nvidia/p3450-0000/p3450-0000.c
@@ -12,10 +12,9 @@
 #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>
+#include <asm/arch-tegra/board.h>
 #include "../p2571/max77620_init.h"
 
 void pin_mux_mmc(void)
@@ -84,128 +83,16 @@ int tegra_pcie_board_init(void)
 }
 #endif /* PCI */
 
-static void ft_mac_address_setup(void *fdt)
-{
-	const void *cboot_fdt = (const void *)cboot_boot_x0;
-	uint8_t mac[ETH_ALEN], local_mac[ETH_ALEN];
-	const char *path;
-	int offset, err;
-
-	err = cboot_get_ethaddr(cboot_fdt, local_mac);
-	if (err < 0)
-		memset(local_mac, 0, ETH_ALEN);
-
-	path = fdt_get_alias(fdt, "ethernet");
-	if (!path)
-		return;
-
-	debug("ethernet alias found: %s\n", path);
-
-	offset = fdt_path_offset(fdt, path);
-	if (offset < 0) {
-		printf("ethernet alias points to absent node %s\n", path);
-		return;
-	}
-
-	if (is_valid_ethaddr(local_mac)) {
-		err = fdt_setprop(fdt, offset, "local-mac-address", local_mac,
-				  ETH_ALEN);
-		if (!err)
-			debug("Local MAC address set: %pM\n", local_mac);
-	}
-
-	if (eth_env_get_enetaddr("ethaddr", mac)) {
-		if (memcmp(local_mac, mac, ETH_ALEN) != 0) {
-			err = fdt_setprop(fdt, offset, "mac-address", mac,
-					  ETH_ALEN);
-			if (!err)
-				debug("MAC address set: %pM\n", mac);
-		}
-	}
-}
-
-static int ft_copy_carveout(void *dst, const void *src, const char *node)
-{
-	unsigned int index = 0;
-	int err;
-
-	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;
-		}
-
-		if (copy)
-			free(copy);
-
-		index++;
-	}
-
-	return 0;
-}
-
-static void ft_carveout_setup(void *fdt)
-{
-	const void *cboot_fdt = (const void *)cboot_boot_x0;
-	static const char * const nodes[] = {
-		"/host1x@50000000/dc@54200000",
-		"/host1x@50000000/dc@54240000",
-		"/external-memory-controller@7001b000",
-	};
-	unsigned int i;
-	int err;
-
-	for (i = 0; i < ARRAY_SIZE(nodes); i++) {
-		printf("copying carveout for %s...\n", nodes[i]);
-
-		err = ft_copy_carveout(fdt, cboot_fdt, nodes[i]);
-		if (err < 0) {
-			if (err != -FDT_ERR_NOTFOUND)
-				printf("failed to copy carveout for %s: %d\n",
-				       nodes[i], err);
-
-			continue;
-		}
-	}
-}
+static const char * const nodes[] = {
+	"/host1x@50000000/dc@54200000",
+	"/host1x@50000000/dc@54240000",
+	"/external-memory-controller@7001b000",
+};
 
 int ft_board_setup(void *fdt, struct bd_info *bd)
 {
 	ft_mac_address_setup(fdt);
-	ft_carveout_setup(fdt);
+	ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
 
 	return 0;
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 9/9] ARM: tegra: Copy memory-region-names property
  2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
                   ` (7 preceding siblings ...)
  2021-09-03 13:16 ` [PATCH 8/9] ARM: tegra: Refactor DT update helpers Thierry Reding
@ 2021-09-03 13:16 ` Thierry Reding
  2021-09-30  4:08   ` Simon Glass
  8 siblings, 1 reply; 19+ messages in thread
From: Thierry Reding @ 2021-09-03 13:16 UTC (permalink / raw)
  To: Tom Warren; +Cc: Simon Glass, u-boot

From: Thierry Reding <treding@nvidia.com>

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>
---
 arch/arm/mach-tegra/dt-setup.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-tegra/dt-setup.c b/arch/arm/mach-tegra/dt-setup.c
index 894a6358a2c4..c11494722bc7 100644
--- a/arch/arm/mach-tegra/dt-setup.c
+++ b/arch/arm/mach-tegra/dt-setup.c
@@ -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;
 }
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 7/9] ARM: tegra: Support EMC frequency tables on Tegra210
  2021-09-03 13:16 ` [PATCH 7/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
@ 2021-09-30  4:08   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:08 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> The EMC frequency tables are created from a training sequence performed
> during early boot and passed in via a reserved memory region by nvtboot.
> Copy this table to the kernel DTB so that the kernel can use it to scale
> the EMC frequency at runtime.
>
> Note that early bootloaders store the EMC table at an address that
> currently intersects with the load address of the initial ramdisk. In
> order to avoid copying the table to a different address, simply change
> the load address for the initial ramdisk in U-Boot.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  board/nvidia/p2371-2180/p2371-2180.c | 1 +
>  board/nvidia/p3450-0000/p3450-0000.c | 1 +
>  include/configs/tegra210-common.h    | 2 +-
>  3 files changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c
> index f5126c552b00..cd5dc2de629e 100644
> --- a/board/nvidia/p2371-2180/p2371-2180.c
> +++ b/board/nvidia/p2371-2180/p2371-2180.c
> @@ -183,6 +183,7 @@ static void ft_carveout_setup(void *fdt)
>         static const char * const nodes[] = {
>                 "/host1x@50000000/dc@54200000",
>                 "/host1x@50000000/dc@54240000",
> +               "/external-memory-controller@7001b000",
>         };

This would be better added to the DT in 'sysinfo' driver or something
like that. It is not nice to have DT paths in the C code.


- Simon

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 6/9] ARM: tegra: Support multiple reserved memory regions
  2021-09-03 13:16 ` [PATCH 6/9] ARM: tegra: Support multiple reserved memory regions Thierry Reding
@ 2021-09-30  4:08   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:08 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> 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>
> ---
>  board/nvidia/p2371-2180/p2371-2180.c | 55 +++++++++++++++++++++-------
>  board/nvidia/p2771-0000/p2771-0000.c | 55 +++++++++++++++++++++-------
>  board/nvidia/p3450-0000/p3450-0000.c | 55 +++++++++++++++++++++-------
>  3 files changed, 126 insertions(+), 39 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 8/9] ARM: tegra: Refactor DT update helpers
  2021-09-03 13:16 ` [PATCH 8/9] ARM: tegra: Refactor DT update helpers Thierry Reding
@ 2021-09-30  4:08   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:08 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> Rather than duplicate the Ethernet MAC address and carveout updating
> code for each board, move it to a common location and make it more
> reusable.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  arch/arm/include/asm/arch-tegra/board.h |  10 ++
>  arch/arm/mach-tegra/dt-setup.c          | 118 ++++++++++++++++++++++
>  board/nvidia/p2371-2180/p2371-2180.c    | 123 ++---------------------
>  board/nvidia/p2771-0000/p2771-0000.c    | 126 ++---------------------
>  board/nvidia/p3450-0000/p3450-0000.c    | 127 ++----------------------
>  5 files changed, 149 insertions(+), 355 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 9/9] ARM: tegra: Copy memory-region-names property
  2021-09-03 13:16 ` [PATCH 9/9] ARM: tegra: Copy memory-region-names property Thierry Reding
@ 2021-09-30  4:08   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:08 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> 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>
> ---
>  arch/arm/mach-tegra/dt-setup.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops
  2021-09-03 13:16 ` [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops Thierry Reding
@ 2021-09-30  4:09   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> In order make it possible to use fdtdec_get_carveout() in loops, return
> FDT_ERR_NOTFOUND when the passed-in index exceeds the number of phandles
> present in the given property.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  lib/fdtdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/9] fdtdec: Support retrieving the name of a carveout
  2021-09-03 13:16 ` [PATCH 2/9] fdtdec: Support retrieving the name of a carveout Thierry Reding
@ 2021-09-30  4:09   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> When retrieving a given carveout for a device, allow callers to query
> the name. This helps differentiating between carveouts when there are
> more than one.
>
> This is also useful when copying carveouts to help assign a meaningful
> name that cannot always be guessed.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  board/nvidia/p2371-2180/p2371-2180.c |  2 +-
>  board/nvidia/p2771-0000/p2771-0000.c |  2 +-
>  board/nvidia/p3450-0000/p3450-0000.c |  2 +-
>  include/fdtdec.h                     |  8 +++++---
>  lib/fdtdec.c                         | 12 ++++++++----
>  lib/fdtdec_test.c                    |  3 ++-
>  6 files changed, 18 insertions(+), 11 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/9] fdtdec: Support compatible string list for reserved memory
  2021-09-03 13:16 ` [PATCH 3/9] fdtdec: Support compatible string list for reserved memory Thierry Reding
@ 2021-09-30  4:09   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

Hi,

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> Reserved memory nodes can have a compatible string list to identify the
> type of reserved memory that they represent. Support specifying an
> optional compatible string list when creating these nodes.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  arch/arm/cpu/armv8/fsl-layerscape/soc.c |  3 +-
>  arch/riscv/lib/fdt_fixup.c              |  2 +-
>  board/nvidia/p2371-2180/p2371-2180.c    |  5 +-
>  board/nvidia/p2771-0000/p2771-0000.c    |  5 +-
>  board/nvidia/p3450-0000/p3450-0000.c    |  5 +-
>  include/fdtdec.h                        | 17 ++++--
>  lib/fdtdec.c                            | 69 ++++++++++++++++++++++++-
>  lib/fdtdec_test.c                       |  4 +-
>  lib/optee/optee.c                       |  1 +
>  test/dm/fdtdec.c                        | 18 +++----
>  10 files changed, 105 insertions(+), 24 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/9] fdtdec: Reorder fdtdec_set_carveout() parameters for consistency
  2021-09-03 13:16 ` [PATCH 4/9] fdtdec: Reorder fdtdec_set_carveout() parameters for consistency Thierry Reding
@ 2021-09-30  4:09   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> The fdtdec_set_carveout() function's parameters are inconsistent with
> the parameters passed to fdtdec_add_reserved_memory(). Fix up the order
> to make it more consistent.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  board/nvidia/p2371-2180/p2371-2180.c |  4 ++--
>  board/nvidia/p2771-0000/p2771-0000.c |  4 ++--
>  board/nvidia/p3450-0000/p3450-0000.c |  4 ++--
>  include/fdtdec.h                     |  8 ++++----
>  lib/fdtdec.c                         |  6 +++---
>  lib/fdtdec_test.c                    |  4 ++--
>  test/dm/fdtdec.c                     | 15 ++++++---------
>  7 files changed, 21 insertions(+), 24 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 5/9] fdtdec: Support reserved-memory flags
  2021-09-03 13:16 ` [PATCH 5/9] fdtdec: Support reserved-memory flags Thierry Reding
@ 2021-09-30  4:09   ` Simon Glass
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2021-09-30  4:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Tom Warren, U-Boot Mailing List

On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> Reserved memory nodes can have additional flags. Support reading and
> writing these flags to ensure that reserved memory nodes can be properly
> parsed and emitted.
>
> This converts support for the existing "no-map" flag to avoid extending
> the argument list for fdtdec_add_reserved_memory() to excessive length.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  arch/arm/cpu/armv8/fsl-layerscape/soc.c |  2 +-
>  arch/riscv/lib/fdt_fixup.c              |  2 +-
>  board/nvidia/p2371-2180/p2371-2180.c    |  4 ++--
>  board/nvidia/p2771-0000/p2771-0000.c    |  4 ++--
>  board/nvidia/p3450-0000/p3450-0000.c    |  4 ++--
>  include/fdtdec.h                        | 20 +++++++++++-------
>  lib/fdtdec.c                            | 28 ++++++++++++++++---------
>  lib/fdtdec_test.c                       |  4 ++--
>  lib/optee/optee.c                       |  3 ++-
>  test/dm/fdtdec.c                        | 13 ++++++------
>  10 files changed, 50 insertions(+), 34 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-09-30  4:16 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 13:16 [PATCH 0/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
2021-09-03 13:16 ` [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops Thierry Reding
2021-09-30  4:09   ` Simon Glass
2021-09-03 13:16 ` [PATCH 2/9] fdtdec: Support retrieving the name of a carveout Thierry Reding
2021-09-30  4:09   ` Simon Glass
2021-09-03 13:16 ` [PATCH 3/9] fdtdec: Support compatible string list for reserved memory Thierry Reding
2021-09-30  4:09   ` Simon Glass
2021-09-03 13:16 ` [PATCH 4/9] fdtdec: Reorder fdtdec_set_carveout() parameters for consistency Thierry Reding
2021-09-30  4:09   ` Simon Glass
2021-09-03 13:16 ` [PATCH 5/9] fdtdec: Support reserved-memory flags Thierry Reding
2021-09-30  4:09   ` Simon Glass
2021-09-03 13:16 ` [PATCH 6/9] ARM: tegra: Support multiple reserved memory regions Thierry Reding
2021-09-30  4:08   ` Simon Glass
2021-09-03 13:16 ` [PATCH 7/9] ARM: tegra: Support EMC frequency tables on Tegra210 Thierry Reding
2021-09-30  4:08   ` Simon Glass
2021-09-03 13:16 ` [PATCH 8/9] ARM: tegra: Refactor DT update helpers Thierry Reding
2021-09-30  4:08   ` Simon Glass
2021-09-03 13:16 ` [PATCH 9/9] ARM: tegra: Copy memory-region-names property Thierry Reding
2021-09-30  4:08   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.