From b9d97aba2127bfe34b33673126a2702ef860e3bb Mon Sep 17 00:00:00 2001 From: Marcin Szymczyk Date: Tue, 22 Apr 2025 15:33:44 +0200 Subject: [PATCH] drivers: misc: nordic_vpr_launcher: move SoC-specific config to DT Targets that require setting secure attribute to VPR should specify it in devicetree. Signed-off-by: Marcin Szymczyk --- .../misc/nordic_vpr_launcher/nordic_vpr_launcher.c | 13 +++++++++---- dts/bindings/riscv/nordic,nrf-vpr-coprocessor.yaml | 5 +++++ dts/vendor/nordic/nrf54l09.dtsi | 1 + dts/vendor/nordic/nrf54l20.dtsi | 1 + dts/vendor/nordic/nrf54l_05_10_15.dtsi | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/misc/nordic_vpr_launcher/nordic_vpr_launcher.c b/drivers/misc/nordic_vpr_launcher/nordic_vpr_launcher.c index b28ebec6b5c..aaf3f0d4474 100644 --- a/drivers/misc/nordic_vpr_launcher/nordic_vpr_launcher.c +++ b/drivers/misc/nordic_vpr_launcher/nordic_vpr_launcher.c @@ -15,7 +15,7 @@ #include #include -#if defined(CONFIG_SOC_NRF54L_CPUAPP_COMMON) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) +#if DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_secure) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) #include #endif @@ -24,6 +24,7 @@ LOG_MODULE_REGISTER(nordic_vpr_launcher, CONFIG_NORDIC_VPR_LAUNCHER_LOG_LEVEL); struct nordic_vpr_launcher_config { NRF_VPR_Type *vpr; uintptr_t exec_addr; + bool enable_secure; #if DT_ANY_INST_HAS_PROP_STATUS_OKAY(source_memory) uintptr_t src_addr; size_t size; @@ -52,9 +53,12 @@ static int nordic_vpr_launcher_init(const struct device *dev) } #endif -#if defined(CONFIG_SOC_NRF54L_CPUAPP_COMMON) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) - nrf_spu_periph_perm_secattr_set(NRF_SPU00, nrf_address_slave_get((uint32_t)config->vpr), - true); +#if DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_secure) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) + if (config->enable_secure) { + nrf_spu_periph_perm_secattr_set(NRF_SPU00, + nrf_address_slave_get((uint32_t)config->vpr), + true); + } #endif LOG_DBG("Launching VPR (%p) from %p", config->vpr, (void *)config->exec_addr); nrf_vpr_initpc_set(config->vpr, config->exec_addr); @@ -81,6 +85,7 @@ static int nordic_vpr_launcher_init(const struct device *dev) .vpr = (NRF_VPR_Type *)DT_INST_REG_ADDR(inst), \ IF_ENABLED(DT_INST_NODE_HAS_PROP(inst, execution_memory), \ (.exec_addr = VPR_ADDR(DT_INST_PHANDLE(inst, execution_memory)),)) \ + .enable_secure = DT_INST_PROP(inst, enable_secure), \ IF_ENABLED(NEEDS_COPYING(inst), \ (.src_addr = VPR_ADDR(DT_INST_PHANDLE(inst, source_memory)), \ .size = DT_REG_SIZE(DT_INST_PHANDLE(inst, execution_memory)),))}; \ diff --git a/dts/bindings/riscv/nordic,nrf-vpr-coprocessor.yaml b/dts/bindings/riscv/nordic,nrf-vpr-coprocessor.yaml index 8760e828880..f204d1679a4 100644 --- a/dts/bindings/riscv/nordic,nrf-vpr-coprocessor.yaml +++ b/dts/bindings/riscv/nordic,nrf-vpr-coprocessor.yaml @@ -25,3 +25,8 @@ properties: type: phandle description: | Memory area or partition from which the VPR code will be loaded. + + enable-secure: + type: boolean + description: | + Enables setting VPR core's secure attribute to secure. diff --git a/dts/vendor/nordic/nrf54l09.dtsi b/dts/vendor/nordic/nrf54l09.dtsi index 3e6770fdcad..3dc17dabd9b 100644 --- a/dts/vendor/nordic/nrf54l09.dtsi +++ b/dts/vendor/nordic/nrf54l09.dtsi @@ -146,6 +146,7 @@ #address-cells = <1>; #size-cells = <1>; status = "disabled"; + enable-secure; cpuflpr_clic: interrupt-controller@f0000000 { compatible = "nordic,nrf-clic"; diff --git a/dts/vendor/nordic/nrf54l20.dtsi b/dts/vendor/nordic/nrf54l20.dtsi index 3f92b6e9dde..5b43bf36009 100644 --- a/dts/vendor/nordic/nrf54l20.dtsi +++ b/dts/vendor/nordic/nrf54l20.dtsi @@ -141,6 +141,7 @@ #address-cells = <1>; #size-cells = <1>; status = "disabled"; + enable-secure; cpuflpr_clic: interrupt-controller@f0000000 { compatible = "nordic,nrf-clic"; diff --git a/dts/vendor/nordic/nrf54l_05_10_15.dtsi b/dts/vendor/nordic/nrf54l_05_10_15.dtsi index a536363b760..c11184cdc1f 100644 --- a/dts/vendor/nordic/nrf54l_05_10_15.dtsi +++ b/dts/vendor/nordic/nrf54l_05_10_15.dtsi @@ -165,6 +165,7 @@ #address-cells = <1>; #size-cells = <1>; status = "disabled"; + enable-secure; cpuflpr_clic: interrupt-controller@f0000000 { compatible = "nordic,nrf-clic";