-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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)
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/init.h> | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/toolchain.h> | ||
|
||
#include <services/nrfs_mram.h> | ||
#include <nrfs_backend_ipc_service.h> | ||
|
||
LOG_MODULE_REGISTER(mram, CONFIG_SOC_LOG_LEVEL); | ||
|
||
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 not allowed setting applied"); | ||
break; | ||
case NRFS_MRAM_LATENCY_REQ_REJECTED: | ||
LOG_ERR("MRAM latency not allowed setting rejected"); | ||
k_panic(); | ||
break; | ||
default: | ||
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) | ||
{ | ||
nrfs_err_t err; | ||
|
||
/* 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); | ||
return -EIO; | ||
} | ||
|
||
LOG_DBG("MRAM service initialized, disallow latency"); | ||
|
||
err = nrfs_mram_set_latency(MRAM_LATENCY_NOT_ALLOWED, NULL); | ||
if (err != NRFS_SUCCESS) { | ||
LOG_ERR("MRAM: set latency failed (%d)", err); | ||
return -EIO; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
SYS_INIT(turn_off_suspend_mram, APPLICATION, 90); |