Skip to content

Commit 58284ff

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. Signed-off-by: Jan Zyczkowski <[email protected]>
1 parent a5782c6 commit 58284ff

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 6 additions & 0 deletions
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

Lines changed: 58 additions & 0 deletions
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_INF("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_INF("MRAM service initialized");
47+
}
48+
49+
LOG_INF("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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ config NRFS_RESET_SERVICE_ENABLED
7272
config NRFS_MRAM_SERVICE_ENABLED
7373
bool "MRAM latency service"
7474
depends on NRFS_HAS_MRAM_SERVICE
75+
default y
7576

7677
config NRFS_TEMP_SERVICE_ENABLED
7778
bool "Temperature service"

0 commit comments

Comments
 (0)