From 4bf88ba76abb224b3ca258a2f502384ec6c86bd6 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 3 Sep 2021 15:16:18 +0200 Subject: fdtdec: Support retrieving the name of a carveout 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 Reviewed-by: Simon Glass Signed-off-by: Tom Warren --- include/fdtdec.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index 23efbe710cb..f961f030124 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -1038,14 +1038,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 -- cgit v1.2.3 From 46cb067803bef50cb8a1334a56897d05b5f85e02 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 3 Sep 2021 15:16:19 +0200 Subject: fdtdec: Support compatible string list for reserved memory 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 Reviewed-by: Simon Glass Signed-off-by: Tom Warren --- include/fdtdec.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index f961f030124..5a6a7cbd995 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -995,7 +995,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: @@ -1020,6 +1021,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 @@ -1027,6 +1030,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); /** @@ -1043,11 +1047,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 @@ -1065,7 +1072,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 @@ -1104,10 +1112,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); /** -- cgit v1.2.3 From 9019487608c8afe7d3fc34cb5192df064b60cdb7 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 3 Sep 2021 15:16:20 +0200 Subject: fdtdec: Reorder fdtdec_set_carveout() parameters for consistency 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 Reviewed-by: Simon Glass Signed-off-by: Tom Warren --- include/fdtdec.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index 5a6a7cbd995..d360d7bce4e 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -1110,16 +1110,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 -- cgit v1.2.3 From b9aad375917d4ae0dec5aedcdfa79929e1dbb730 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 3 Sep 2021 15:16:21 +0200 Subject: fdtdec: Support reserved-memory flags 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 Reviewed-by: Simon Glass Signed-off-by: Tom Warren --- include/fdtdec.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index d360d7bce4e..f94d1f4f3ab 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -977,6 +977,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 * @@ -996,7 +999,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: @@ -1025,13 +1028,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 @@ -1048,13 +1051,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 @@ -1073,7 +1078,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 @@ -1114,12 +1119,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 -- cgit v1.2.3 From f814ff5e0b10a0b6a1b303a849e68f302f0d8627 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Wed, 13 Oct 2021 13:06:02 -0700 Subject: ARM: tegra: Support EMC frequency tables on Tegra210 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 Signed-off-by: Tom Warren --- include/configs/tegra210-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/configs/tegra210-common.h b/include/configs/tegra210-common.h index b9e04147be3..e1b91f62505 100644 --- a/include/configs/tegra210-common.h +++ b/include/configs/tegra210-common.h @@ -44,7 +44,7 @@ "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\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 -- cgit v1.2.3