]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
ti: k3: abstract common fdt api for reserved mem fixups
authorAnshul Dalal <anshuld@ti.com>
Thu, 4 Dec 2025 11:11:55 +0000 (16:41 +0530)
committerTom Rini <trini@konsulko.com>
Tue, 16 Dec 2025 17:36:48 +0000 (11:36 -0600)
The usage of fdt_fixup_reserved is repeated for ATF and OP-TEE for
multiple platforms, this patch creates a single fdt API for fixing up
the reserved-memory node with added error handling.

All k3 platforms already share a common tispl template which ensures
binaries are loaded as per the respective CONFIG_*_LOAD_ADDR. And the
provided new_size for the fixup is overridden by the size from fdt node
anyways. This allows for safe abstraction of the reserved memory fixups
for all current platforms.

fdt_fixup_reserved now abstracts the ATF and OP-TEE fixups by calling
the renamed static fdt_fixup_reserved_memory function with the required
parameters.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
arch/arm/mach-k3/am62ax/am62a7_fdt.c
arch/arm/mach-k3/am62px/am62p5_fdt.c
arch/arm/mach-k3/am62x/am625_fdt.c
arch/arm/mach-k3/common.c
arch/arm/mach-k3/common_fdt.c
arch/arm/mach-k3/include/mach/k3-common-fdt.h
arch/arm/mach-k3/j722s/j722s_fdt.c

index c7c5d2f0885a432ab521df7080306d0c50691cfa..bdc1747fd75c1bc25094704e64a5a05feaafd291 100644 (file)
@@ -9,8 +9,5 @@
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
-       fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
-       fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
-
-       return 0;
+       return fdt_fixup_reserved(blob);
 }
index 03f56cfd9fc404a114b444a482706b579cd1878e..68172ae9a5d7641ddb854c2e349f6ea24bb789ad 100644 (file)
@@ -81,8 +81,6 @@ int ft_system_setup(void *blob, struct bd_info *bd)
        fdt_fixup_canfd_nodes_am62p(blob, k3_has_canfd());
        fdt_fixup_thermal_critical_trips_k3(blob, k3_get_max_temp());
        fdt_fixup_thermal_cooling_device_cpus_am62p(blob, k3_get_core_nr());
-       fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
-       fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
-       return 0;
+       return fdt_fixup_reserved(blob);
 }
index e5d95ab7dd1bb2ea8b5d6469673a0b2566fd411c..d666d88b7f4324ff2a29957e72f6c06c4d89fad5 100644 (file)
@@ -80,8 +80,6 @@ int ft_system_setup(void *blob, struct bd_info *bd)
        fdt_fixup_pru_node_am625(blob, k3_has_pru());
        fdt_fixup_thermal_critical_trips_k3(blob, k3_get_max_temp());
        fdt_fixup_thermal_cooling_device_cpus_am625(blob, k3_get_core_nr());
-       fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
-       fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
-       return 0;
+       return fdt_fixup_reserved(blob);
 }
index 8d804f18a1f3c8acda4d3498ebe9a6ea604b293a..0a686efa13197511259408665103bc7e2d5392d3 100644 (file)
@@ -273,14 +273,14 @@ void enable_caches(void)
        if (ret)
                debug("%s: Failed to setup dram banks\n", __func__);
 
+       ret = fdt_fixup_reserved(fdt);
+       if (ret)
+               printf("%s: Failed to perform reserved-memory fixups (%s)\n",
+                      __func__, fdt_strerror(ret));
+
        mmu_setup();
 
        if (CONFIG_K3_ATF_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
-               ret = fdt_fixup_reserved(fdt, "tfa", CONFIG_K3_ATF_LOAD_ADDR,
-                                        0x80000);
-               if (ret)
-                       printf("%s: Failed to perform tfa fixups (%s)\n",
-                              __func__, fdt_strerror(ret));
                ret = mmu_unmap_reserved_mem("tfa", true);
                if (ret)
                        printf("%s: Failed to unmap tfa reserved mem (%d)\n",
@@ -288,11 +288,6 @@ void enable_caches(void)
        }
 
        if (CONFIG_K3_OPTEE_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
-               ret = fdt_fixup_reserved(fdt, "optee",
-                                        CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
-               if (ret)
-                       printf("%s: Failed to perform optee fixups (%s)\n",
-                              __func__, fdt_strerror(ret));
                ret = mmu_unmap_reserved_mem("optee", true);
                if (ret)
                        printf("%s: Failed to unmap optee reserved mem (%d)\n",
@@ -463,8 +458,7 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)
        if (!fdt)
                return;
 
-       fdt_fixup_reserved(fdt, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
-       fdt_fixup_reserved(fdt, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
+       fdt_fixup_reserved(fdt);
 }
 
 void spl_board_prepare_for_boot(void)
index 1e6786f6c200b0061e904341dd01ef2b29d193b6..cb0fb8274a5bf0f17305f1c7d22b9428e8f99b1d 100644 (file)
@@ -114,8 +114,9 @@ int fdt_del_node_path(void *blob, const char *path)
        return ret;
 }
 
-int fdt_fixup_reserved(void *blob, const char *name,
-                      unsigned int new_address, unsigned int new_size)
+static int fdt_fixup_reserved_memory(void *blob, const char *name,
+                                    unsigned int new_address,
+                                    unsigned int new_size)
 {
        int nodeoffset, subnode;
        int ret;
@@ -167,6 +168,19 @@ add_carveout:
        return 0;
 }
 
+int fdt_fixup_reserved(void *blob)
+{
+       int ret;
+
+       ret = fdt_fixup_reserved_memory(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR,
+                                       0x80000);
+       if (ret)
+               return ret;
+
+       return fdt_fixup_reserved_memory(blob, "optee",
+                                        CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
+}
+
 static int fdt_fixup_critical_trips(void *blob, int zoneoffset, int maxc)
 {
        int node, trip;
index 38a5bb82d954fa3060c41c50c08c54aec49fb3f2..de4d5d117c5dd4b85ca978ffde94fa7168176ffa 100644 (file)
@@ -8,8 +8,7 @@
 
 int fdt_fixup_msmc_ram_k3(void *blob);
 int fdt_del_node_path(void *blob, const char *path);
-int fdt_fixup_reserved(void *blob, const char *name,
-                      unsigned int new_address, unsigned int new_size);
+int fdt_fixup_reserved(void *blob);
 void fdt_fixup_thermal_critical_trips_k3(void *blob, int maxc);
 
 #endif /* _K3_COMMON_FDT_H */
index c7c5d2f0885a432ab521df7080306d0c50691cfa..bdc1747fd75c1bc25094704e64a5a05feaafd291 100644 (file)
@@ -9,8 +9,5 @@
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
-       fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
-       fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
-
-       return 0;
+       return fdt_fixup_reserved(blob);
 }