Commit 8053d23c authored by Dhanoo Surasarang's avatar Dhanoo Surasarang Committed by Benjamin Cabé
Browse files

drivers: misc: nordic_vpr_launcher: add DMA secure attribute support



Extend vpr_launcher and device tree bindings to support configuring
the DMA secure attribute.

Signed-off-by: default avatarDhanoo Surasarang <dhanoo.surasarang@nordicsemi.no>
parent 26fd9a69
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@
#include <zephyr/toolchain.h>

#include <hal/nrf_vpr.h>
#if DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_secure) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
#if (DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_secure) || \
	 DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_dma_secure)) && \
	!defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
#include <hal/nrf_spu.h>
#endif

@@ -25,6 +27,7 @@ struct nordic_vpr_launcher_config {
	NRF_VPR_Type *vpr;
	uintptr_t exec_addr;
	bool enable_secure;
	bool enable_dma_secure;
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(source_memory)
	uintptr_t src_addr;
	size_t size;
@@ -53,12 +56,21 @@ static int nordic_vpr_launcher_init(const struct device *dev)
	}
#endif

#if DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_secure) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
#if DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_secure)
	if (config->enable_secure) {
		nrf_spu_periph_perm_secattr_set(NRF_SPU00,
						nrf_address_slave_get((uint32_t)config->vpr),
						true);
	}
#endif
#if DT_ANY_INST_HAS_BOOL_STATUS_OKAY(enable_dma_secure)
	if (config->enable_dma_secure) {
		nrf_spu_periph_perm_dmasec_set(NRF_SPU00,
						nrf_address_slave_get((uint32_t)config->vpr),
						true);
	}
#endif
#endif
	LOG_DBG("Launching VPR (%p) from %p", config->vpr, (void *)config->exec_addr);
	nrf_vpr_initpc_set(config->vpr, config->exec_addr);
@@ -86,6 +98,7 @@ static int nordic_vpr_launcher_init(const struct device *dev)
		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),                                \
		.enable_dma_secure = DT_INST_PROP(inst, enable_dma_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)),))};      \
+5 −0
Original line number Diff line number Diff line
@@ -30,3 +30,8 @@ properties:
    type: boolean
    description: |
      Enables setting VPR core's secure attribute to secure.

  enable-dma-secure:
    type: boolean
    description: |
      Enables setting VPR core's DMA secure attribute to secure.