From 10c0de0d0cc5dd0ac71466aef69cc7e6188c8b4c Mon Sep 17 00:00:00 2001 From: Jan Zyczkowski Date: Mon, 24 Jun 2024 13:20:33 +0200 Subject: [PATCH] [nrf noup] boards: nordic: Turn off MRAM suspend for NRF54H20 DK Turn off suspending MRAM for NRF54H20 DK This change is required so sections of code depending on critical timings will not have unacceptable latency. Turn on NRFS globally so turning off suspending MRAM for NRF54H20 DK will work. Signed-off-by: Jan Zyczkowski (cherry picked from commit 58284ff0e1b85f24d1be928860e9e6eb0e86b4e5) (cherry picked from commit 9b6cae8d899a67341963671963d58fb161462edb) (cherry picked from commit 2c2f60d1ebd959900405e448cee45c03ecdc6646) --- boards/nordic/nrf54h20dk/CMakeLists.txt | 6 +++ boards/nordic/nrf54h20dk/board.c | 58 +++++++++++++++++++++++++ modules/hal_nordic/nrfs/Kconfig | 3 ++ 3 files changed, 67 insertions(+) create mode 100644 boards/nordic/nrf54h20dk/CMakeLists.txt create mode 100644 boards/nordic/nrf54h20dk/board.c diff --git a/boards/nordic/nrf54h20dk/CMakeLists.txt b/boards/nordic/nrf54h20dk/CMakeLists.txt new file mode 100644 index 00000000000..a5a06d8805a --- /dev/null +++ b/boards/nordic/nrf54h20dk/CMakeLists.txt @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() +if(CONFIG_NRFS_MRAM_SERVICE_ENABLED) + zephyr_library_sources(board.c) +endif() diff --git a/boards/nordic/nrf54h20dk/board.c b/boards/nordic/nrf54h20dk/board.c new file mode 100644 index 00000000000..0699e93a7c3 --- /dev/null +++ b/boards/nordic/nrf54h20dk/board.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#define MODULE mram_suspend_off +#include +LOG_MODULE_REGISTER(MODULE); + +#include +#include + +#define MRAM_SUSPEND_OFF_INIT_PRIO 90 + +void mram_latency_handler(nrfs_mram_latency_evt_t const *p_evt, void *context) +{ + switch (p_evt->type) { + case NRFS_MRAM_LATENCY_REQ_APPLIED: + LOG_DBG("MRAM latency handler: response received"); + break; + case NRFS_MRAM_LATENCY_REQ_REJECTED: + LOG_ERR("MRAM latency handler - request rejected!"); + break; + default: + LOG_ERR("MRAM latency handler - unexpected event: 0x%x", p_evt->type); + break; + } +} + +static int turn_off_suspend_mram(void) +{ + /* Turn off mram automatic suspend as it causes delays in time depended code sections. */ + + nrfs_err_t err = NRFS_SUCCESS; + + /* Wait for ipc initialization */ + nrfs_backend_wait_for_connection(K_FOREVER); + + err = nrfs_mram_init(mram_latency_handler); + if (err != NRFS_SUCCESS) { + LOG_ERR("MRAM service init failed: %d", err); + } else { + LOG_DBG("MRAM service initialized"); + } + + LOG_DBG("MRAM: set latency: NOT ALLOWED"); + err = nrfs_mram_set_latency(MRAM_LATENCY_NOT_ALLOWED, NULL); + if (err) { + LOG_ERR("MRAM: set latency failed (%d)", err); + } + + return err; +} + +SYS_INIT(turn_off_suspend_mram, APPLICATION, MRAM_SUSPEND_OFF_INIT_PRIO); diff --git a/modules/hal_nordic/nrfs/Kconfig b/modules/hal_nordic/nrfs/Kconfig index b4f6715fdd2..d9031f85b68 100644 --- a/modules/hal_nordic/nrfs/Kconfig +++ b/modules/hal_nordic/nrfs/Kconfig @@ -38,6 +38,8 @@ config NRFS bool "nRF Services Support" select NRFS_LOCAL_DOMAIN if (SOC_NRF54H20_CPUAPP || SOC_NRF54H20_CPURAD) depends on HAS_NRFS + depends on !MISRA_SANE + default y if !ZTEST help This option enables the nRF Services library. @@ -72,6 +74,7 @@ config NRFS_RESET_SERVICE_ENABLED config NRFS_MRAM_SERVICE_ENABLED bool "MRAM latency service" depends on NRFS_HAS_MRAM_SERVICE + default y config NRFS_TEMP_SERVICE_ENABLED bool "Temperature service"