Skip to content

Commit fdfa32e

Browse files
committed
modules: TF-M: Add TF-M HAL function to enable system off
Add the tfm_platform_hal_system_off function which puts the device in system off. This only needed for nRF54L devices at the moment and only in TF-M SFN mode. Signed-off-by: Georgios Vasilakis <[email protected]>
1 parent dc286e8 commit fdfa32e

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

modules/trusted-firmware-m/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ set_property(TARGET zephyr_property_target
103103
$<$<BOOL:${CONFIG_NRF_SECURE_APPROTECT_USER_HANDLING}>:-DCONFIG_NRF_SECURE_APPROTECT_USER_HANDLING=ON>
104104
$<$<BOOL:${CONFIG_IDENTITY_KEY_TFM}>:-DCONFIG_IDENTITY_KEY_TFM=ON>
105105
$<$<BOOL:${CONFIG_TFM_PS_SUPPORT_FORMAT_TRANSITION}>:-DPS_SUPPORT_FORMAT_TRANSITION=ON>
106+
$<$<BOOL:${CONFIG_TFM_NRF_SYSTEM_OFF_SERVICE}>:-DTFM_NRF_SYSTEM_OFF_SERVICE=ON>
106107
)
107108

108109
if(CONFIG_TFM_PROFILE_TYPE_MINIMAL)

modules/trusted-firmware-m/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,4 +538,18 @@ config TFM_PSA_FRAMEWORK_HAS_MM_IOVEC
538538
Memory-mapped iovecs provide direct mapping of client input and output vectors into
539539
the Secure Partition.
540540

541+
config TFM_NRF_SYSTEM_OFF_SERVICE
542+
bool "TF-M NRF System Off Service [EXPERIMENTAL]"
543+
depends on TFM_ISOLATION_LEVEL = 1
544+
depends on TFM_SFN
545+
depends on SOC_SERIES_NRF54LX
546+
depends on !RETAINED_MEM_NRF_RAM_CTRL
547+
select EXPERIMENTAL
548+
help
549+
Provide a system off service for the nRF54L series SoCs.
550+
This service allows the non-secure application to request
551+
the system to enter system off mode via a secure service call.
552+
This service will disable RAM retention for all RAM blocks
553+
before entering system off mode.
554+
541555
endif # BUILD_WITH_TFM

modules/trusted-firmware-m/tfm_boards/src/tfm_platform_system.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include <tfm_hal_isolation.h>
1717

1818
#include <hal/nrf_gpio.h>
19+
#include <hal/nrf_regulators.h>
20+
#include <helpers/nrfx_ram_ctrl.h>
21+
1922
#include "handle_attr.h"
2023

2124
#if NRF_ALLOW_NON_SECURE_FAULT_HANDLING
@@ -28,6 +31,20 @@ void tfm_platform_hal_system_reset(void)
2831
NVIC_SystemReset();
2932
}
3033

34+
#if TFM_NRF_SYSTEM_OFF_SERVICE
35+
enum tfm_platform_err_t tfm_platform_hal_system_off(void)
36+
{
37+
__disable_irq();
38+
39+
nrfx_ram_ctrl_retention_enable_all_set(false);
40+
41+
nrf_regulators_system_off(NRF_REGULATORS);
42+
43+
/* This should be unreachable */
44+
return TFM_PLATFORM_ERR_SYSTEM_ERROR;
45+
}
46+
#endif /* TFM_NRF_SYSTEM_OFF_SERVICE */
47+
3148
#if CONFIG_FW_INFO
3249
static enum tfm_platform_err_t tfm_platform_hal_fw_info_service(psa_invec *in_vec,
3350
psa_outvec *out_vec)

0 commit comments

Comments
 (0)