Skip to content

Commit f3186c3

Browse files
zyczrlubos
authored andcommitted
[nrf noup] soc: nordic: nrf54h20: Turn off MRAM suspend
Turn off suspending MRAM for nRF54H20 SoC. This change is required so sections of code depending on critical timings will not have unacceptable latency. Signed-off-by: Jan Zyczkowski <[email protected]> Signed-off-by: Gerard Marull-Paretas <[email protected]> (cherry picked from commit 58284ff) (cherry picked from commit 9b6cae8) (cherry picked from commit 2c2f60d) (cherry picked from commit a70d6bd)
1 parent 5e068b8 commit f3186c3

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

soc/nordic/nrf54h/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ zephyr_library_sources_ifdef(CONFIG_PM_S2RAM pm_s2ram.c)
1212

1313
zephyr_include_directories(.)
1414

15+
zephyr_library_sources_ifdef(CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY mram.c)
16+
1517
# Ensure that image size aligns with 16 bytes so that MRAMC finalizes all writes
1618
# for the image correctly
1719
zephyr_linker_sources(SECTIONS SORT_KEY zzz_place_align_at_end align.ld)

soc/nordic/nrf54h/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,9 @@ config SOC_NRF54H20_ENGB_CPUFLPR
7777
depends on RISCV_CORE_NORDIC_VPR
7878

7979
rsource "gpd/Kconfig"
80+
81+
config SOC_NRF54H20_NO_MRAM_LATENCY
82+
bool "Disallow MRAM latency"
83+
imply NRFS
84+
imply NRFS_MRAM_SERVICE_ENABLED
85+
default y if SOC_NRF54H20_CPUAPP || SOC_NRF54H20_ENGB_CPUAPP

soc/nordic/nrf54h/mram.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/init.h>
8+
#include <zephyr/kernel.h>
9+
#include <zephyr/logging/log.h>
10+
#include <zephyr/toolchain.h>
11+
12+
#include <services/nrfs_mram.h>
13+
#include <nrfs_backend_ipc_service.h>
14+
15+
LOG_MODULE_REGISTER(mram, CONFIG_SOC_LOG_LEVEL);
16+
17+
static void mram_latency_handler(nrfs_mram_latency_evt_t const *p_evt, void *context)
18+
{
19+
ARG_UNUSED(context);
20+
21+
switch (p_evt->type) {
22+
case NRFS_MRAM_LATENCY_REQ_APPLIED:
23+
LOG_DBG("MRAM latency not allowed setting applied");
24+
break;
25+
case NRFS_MRAM_LATENCY_REQ_REJECTED:
26+
LOG_ERR("MRAM latency not allowed setting rejected");
27+
k_panic();
28+
break;
29+
default:
30+
LOG_WRN("Unexpected event: %d", p_evt->type);
31+
}
32+
}
33+
34+
/* Turn off mram automatic suspend as it causes delays in time depended code sections. */
35+
static int turn_off_suspend_mram(void)
36+
{
37+
nrfs_err_t err;
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+
return -EIO;
46+
}
47+
48+
LOG_DBG("MRAM service initialized, disallow latency");
49+
50+
err = nrfs_mram_set_latency(MRAM_LATENCY_NOT_ALLOWED, NULL);
51+
if (err != NRFS_SUCCESS) {
52+
LOG_ERR("MRAM: set latency failed (%d)", err);
53+
return -EIO;
54+
}
55+
56+
return 0;
57+
}
58+
59+
SYS_INIT(turn_off_suspend_mram, APPLICATION, 90);

0 commit comments

Comments
 (0)