diff --git a/boards/nordic/nrf54h20dk/CMakeLists.txt b/boards/nordic/nrf54h20dk/CMakeLists.txt deleted file mode 100644 index a5a06d8805a..00000000000 --- a/boards/nordic/nrf54h20dk/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -zephyr_library() -if(CONFIG_NRFS_MRAM_SERVICE_ENABLED) - zephyr_library_sources(board.c) -endif() diff --git a/modules/hal_nordic/nrfs/Kconfig b/modules/hal_nordic/nrfs/Kconfig index 8325c8db3bc..eafe0616764 100644 --- a/modules/hal_nordic/nrfs/Kconfig +++ b/modules/hal_nordic/nrfs/Kconfig @@ -46,8 +46,6 @@ config NRFS SOC_NRF9280_CPUAPP || \ SOC_NRF9280_CPURAD depends on HAS_NRFS - depends on !MISRA_SANE - default y if !ZTEST help This option enables the nRF Services library. @@ -82,7 +80,6 @@ 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" diff --git a/soc/nordic/nrf54h/CMakeLists.txt b/soc/nordic/nrf54h/CMakeLists.txt index 7edc4d43ea1..10c59b04583 100644 --- a/soc/nordic/nrf54h/CMakeLists.txt +++ b/soc/nordic/nrf54h/CMakeLists.txt @@ -12,6 +12,8 @@ zephyr_library_sources_ifdef(CONFIG_PM_S2RAM pm_s2ram.c) zephyr_include_directories(.) +zephyr_library_sources_ifdef(CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY mram.c) + # Ensure that image size aligns with 16 bytes so that MRAMC finalizes all writes # for the image correctly zephyr_linker_sources(SECTIONS SORT_KEY zzz_place_align_at_end align.ld) diff --git a/soc/nordic/nrf54h/Kconfig b/soc/nordic/nrf54h/Kconfig index 1b667e25985..a92b176fa9d 100644 --- a/soc/nordic/nrf54h/Kconfig +++ b/soc/nordic/nrf54h/Kconfig @@ -77,3 +77,9 @@ config SOC_NRF54H20_ENGB_CPUFLPR depends on RISCV_CORE_NORDIC_VPR rsource "gpd/Kconfig" + +config SOC_NRF54H20_NO_MRAM_LATENCY + bool "Disallow MRAM latency" + imply NRFS + imply NRFS_MRAM_SERVICE_ENABLED + default y if SOC_NRF54H20_CPUAPP || SOC_NRF54H20_ENGB_CPUAPP diff --git a/boards/nordic/nrf54h20dk/board.c b/soc/nordic/nrf54h/mram.c similarity index 51% rename from boards/nordic/nrf54h20dk/board.c rename to soc/nordic/nrf54h/mram.c index 0699e93a7c3..5549a2437df 100644 --- a/boards/nordic/nrf54h20dk/board.c +++ b/soc/nordic/nrf54h/mram.c @@ -5,36 +5,36 @@ */ #include - -#define MODULE mram_suspend_off +#include #include -LOG_MODULE_REGISTER(MODULE); +#include #include #include -#define MRAM_SUSPEND_OFF_INIT_PRIO 90 +LOG_MODULE_REGISTER(mram, CONFIG_SOC_LOG_LEVEL); -void mram_latency_handler(nrfs_mram_latency_evt_t const *p_evt, void *context) +static void mram_latency_handler(nrfs_mram_latency_evt_t const *p_evt, void *context) { + ARG_UNUSED(context); + switch (p_evt->type) { case NRFS_MRAM_LATENCY_REQ_APPLIED: - LOG_DBG("MRAM latency handler: response received"); + LOG_DBG("MRAM latency not allowed setting applied"); break; case NRFS_MRAM_LATENCY_REQ_REJECTED: - LOG_ERR("MRAM latency handler - request rejected!"); + LOG_ERR("MRAM latency not allowed setting rejected"); + k_panic(); break; default: - LOG_ERR("MRAM latency handler - unexpected event: 0x%x", p_evt->type); - break; + LOG_WRN("Unexpected event: %d", p_evt->type); } } +/* Turn off mram automatic suspend as it causes delays in time depended code sections. */ 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; + nrfs_err_t err; /* Wait for ipc initialization */ nrfs_backend_wait_for_connection(K_FOREVER); @@ -42,17 +42,18 @@ static int turn_off_suspend_mram(void) 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"); + return -EIO; } - LOG_DBG("MRAM: set latency: NOT ALLOWED"); + LOG_DBG("MRAM service initialized, disallow latency"); + err = nrfs_mram_set_latency(MRAM_LATENCY_NOT_ALLOWED, NULL); - if (err) { + if (err != NRFS_SUCCESS) { LOG_ERR("MRAM: set latency failed (%d)", err); + return -EIO; } - return err; + return 0; } -SYS_INIT(turn_off_suspend_mram, APPLICATION, MRAM_SUSPEND_OFF_INIT_PRIO); +SYS_INIT(turn_off_suspend_mram, APPLICATION, 90);