ti: k3: abstract common fdt api for reserved mem fixups
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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user