summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-04-24 10:45:41 -0600
committerTom Rini <trini@konsulko.com>2025-04-24 10:45:41 -0600
commit629f089387adf7b0c39b77ac8d337cff7989f81d (patch)
tree4b53a852e9273c0324215377c6cdb536d1c88228
parentb0a300ad14323532ee88196c4dfb5658b644df82 (diff)
parent33b191997fc215e32cd51ffd979c5f6d1189c46e (diff)
Merge patch series "arm: mach-k3: remove some firewalls left over by ROM"
Bryan Brattlof <bb@ti.com> says: This small series is here to remove some firewalls setup by ROM during their boot and clean things up for Linux later on. Ideally this would be a simple call to remove_fwl_configs() however the location of the firewall is problematic (could potentially crash the core) when we're currently executing from the memory region protected by the firewall. So we need to introduce a function which allows us to disable specific firewall regions and skip others to ensure boot stability. Link: https://lore.kernel.org/r/20250414-firewalls-v1-0-89090085c08b@ti.com
-rw-r--r--arch/arm/mach-k3/am62x/am625_init.c12
-rw-r--r--arch/arm/mach-k3/common.h1
-rw-r--r--arch/arm/mach-k3/r5/common.c25
3 files changed, 38 insertions, 0 deletions
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);
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 fd188e7c90e..0b6604039f3 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, &region);
+
+ /* 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, &region);
+ 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)
{