From f393beedba7917ef8aaaedd67d143cd7b7440ae2 Mon Sep 17 00:00:00 2001 From: Bryan Brattlof Date: Mon, 14 Apr 2025 15:20:02 -0500 Subject: arm: mach-k3: support disabling a single firewall region During boot some firewall regions could contain the R5's code which if we change the firewalls settings will crash the core. To get around this issue, define a new function which allows us to specify specific regions we want unlocked. Signed-off-by: Bryan Brattlof --- arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/r5/common.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index 7bd72da1de8..2ec60c7879a 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -35,6 +35,7 @@ enum k3_device_type { void setup_k3_mpu_regions(void); int early_console_init(void); void disable_linefill_optimization(void); +int remove_fwl_region(struct fwl_data *fwl); void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size); int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr); void k3_sysfw_print_ver(void); diff --git a/arch/arm/mach-k3/r5/common.c b/arch/arm/mach-k3/r5/common.c index 0f6c294f1eb..0d97e7f5537 100644 --- a/arch/arm/mach-k3/r5/common.c +++ b/arch/arm/mach-k3/r5/common.c @@ -253,6 +253,31 @@ void disable_linefill_optimization(void) asm("mcr p15, 0, %0, c1, c0, 1" : : "r" (actlr)); } +int remove_fwl_region(struct fwl_data *fwl) +{ + struct ti_sci_handle *sci = get_ti_sci_handle(); + struct ti_sci_fwl_ops *ops = &sci->ops.fwl_ops; + struct ti_sci_msg_fwl_region region; + int ret; + + region.fwl_id = fwl->fwl_id; + region.region = fwl->regions; + region.n_permission_regs = 3; + + ops->get_fwl_region(sci, ®ion); + + /* zero out the enable field of the firewall */ + region.control = region.control & ~0xF; + + pr_debug("Disabling firewall id: %d region: %d\n", + region.fwl_id, region.region); + + ret = ops->set_fwl_region(sci, ®ion); + if (ret) + pr_err("Could not disable firewall\n"); + return ret; +} + static void remove_fwl_regions(struct fwl_data fwl_data, size_t num_regions, enum k3_firewall_region_type fwl_type) { -- cgit v1.2.3 From 33b191997fc215e32cd51ffd979c5f6d1189c46e Mon Sep 17 00:00:00 2001 From: Bryan Brattlof Date: Mon, 14 Apr 2025 15:20:03 -0500 Subject: arm: mach-k3: am625: remove any firewalls ROM has configured for HSRAM ROM will configure a firewall to only allow HSRAM to be touched by the R5 core. Any outside entity like DMA or the A53s will not have access to this region. This can be problematic when U-Boot, running on the A53, loads firmware that runs out of this region. To simplify things remove the firewall here and let the remote core firmware place a new firewall themselves if they wish for the memory region. Signed-off-by: Bryan Brattlof --- arch/arm/mach-k3/am62x/am625_init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/mach-k3/am62x/am625_init.c b/arch/arm/mach-k3/am62x/am625_init.c index 595fc391ac5..a422919fab1 100644 --- a/arch/arm/mach-k3/am62x/am625_init.c +++ b/arch/arm/mach-k3/am62x/am625_init.c @@ -29,6 +29,12 @@ /* TISCI DEV ID for A53 Clock */ #define AM62X_DEV_A53SS0_CORE_0_DEV_ID 135 +struct fwl_data rom_fwls[] = { + { "SOC_DEVGRP_MAIN", 641, 1 }, + { "SOC_DEVGRP_MAIN", 642, 1 }, + { "SOC_DEVGRP_MAIN", 642, 2 }, +}; + /* * This uninitialized global variable would normal end up in the .bss section, * but the .bss is cleared between writing and reading this variable, so move @@ -177,6 +183,7 @@ void board_init_f(ulong dummy) { struct udevice *dev; int ret; + int i; if (IS_ENABLED(CONFIG_CPU_V7R)) { setup_k3_mpu_regions(); @@ -261,6 +268,11 @@ void board_init_f(ulong dummy) /* Output System Firmware version info */ k3_sysfw_print_ver(); + /* Disable firewalls ROM has configured. */ + if (IS_ENABLED(CONFIG_CPU_V7R)) + for (i = 0; i < ARRAY_SIZE(rom_fwls); i++) + remove_fwl_region(&rom_fwls[i]); + if (IS_ENABLED(CONFIG_ESM_K3)) { /* Probe/configure ESM0 */ ret = uclass_get_device_by_name(UCLASS_MISC, "esm@420000", &dev); -- cgit v1.2.3