Skip to content

Commit 10c0de0

Browse files
zyczanangl
authored andcommitted
[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 <[email protected]> (cherry picked from commit 58284ff) (cherry picked from commit 9b6cae8) (cherry picked from commit 2c2f60d)
1 parent d74e0b5 commit 10c0de0

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
if(CONFIG_NRFS_MRAM_SERVICE_ENABLED)
5+
zephyr_library_sources(board.c)
6+
endif()

boards/nordic/nrf54h20dk/board.c

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/init.h>
8+
9+
#define MODULE mram_suspend_off
10+
#include <zephyr/logging/log.h>
11+
LOG_MODULE_REGISTER(MODULE);
12+
13+
#include <services/nrfs_mram.h>
14+
#include <nrfs_backend_ipc_service.h>
15+
16+
#define MRAM_SUSPEND_OFF_INIT_PRIO 90
17+
18+
void mram_latency_handler(nrfs_mram_latency_evt_t const *p_evt, void *context)
19+
{
20+
switch (p_evt->type) {
21+
case NRFS_MRAM_LATENCY_REQ_APPLIED:
22+
LOG_DBG("MRAM latency handler: response received");
23+
break;
24+
case NRFS_MRAM_LATENCY_REQ_REJECTED:
25+
LOG_ERR("MRAM latency handler - request rejected!");
26+
break;
27+
default:
28+
LOG_ERR("MRAM latency handler - unexpected event: 0x%x", p_evt->type);
29+
break;
30+
}
31+
}
32+
33+
static int turn_off_suspend_mram(void)
34+
{
35+
/* Turn off mram automatic suspend as it causes delays in time depended code sections. */
36+
37+
nrfs_err_t err = NRFS_SUCCESS;
38+
39+
/* Wait for ipc initialization */
40+
nrfs_backend_wait_for_connection(K_FOREVER);
41+
42+
err = nrfs_mram_init(mram_latency_handler);
43+
if (err != NRFS_SUCCESS) {
44+
LOG_ERR("MRAM service init failed: %d", err);
45+
} else {
46+
LOG_DBG("MRAM service initialized");
47+
}
48+
49+
LOG_DBG("MRAM: set latency: NOT ALLOWED");
50+
err = nrfs_mram_set_latency(MRAM_LATENCY_NOT_ALLOWED, NULL);
51+
if (err) {
52+
LOG_ERR("MRAM: set latency failed (%d)", err);
53+
}
54+
55+
return err;
56+
}
57+
58+
SYS_INIT(turn_off_suspend_mram, APPLICATION, MRAM_SUSPEND_OFF_INIT_PRIO);

modules/hal_nordic/nrfs/Kconfig

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ config NRFS
3838
bool "nRF Services Support"
3939
select NRFS_LOCAL_DOMAIN if (SOC_NRF54H20_CPUAPP || SOC_NRF54H20_CPURAD)
4040
depends on HAS_NRFS
41+
depends on !MISRA_SANE
42+
default y if !ZTEST
4143
help
4244
This option enables the nRF Services library.
4345

@@ -72,6 +74,7 @@ config NRFS_RESET_SERVICE_ENABLED
7274
config NRFS_MRAM_SERVICE_ENABLED
7375
bool "MRAM latency service"
7476
depends on NRFS_HAS_MRAM_SERVICE
77+
default y
7578

7679
config NRFS_TEMP_SERVICE_ENABLED
7780
bool "Temperature service"

0 commit comments

Comments
 (0)