Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: nrf54h20: refactor MRAM board level code #2115

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions boards/nordic/nrf54h20dk/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions modules/hal_nordic/nrfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ config NRFS
SOC_NRF9280_CPUAPP || \
SOC_NRF9280_CPURAD
depends on HAS_NRFS
depends on !MISRA_SANE
Copy link
Contributor

@57300 57300 Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this is addressed? #1856 (comment)

(if not, maybe it should've been taken upstream)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case then this needs to be upstreamed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested with the option and I'm able to compile successfully, maybe it's not a problem anymore?

default y if !ZTEST
help
This option enables the nRF Services library.

Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions soc/nordic/nrf54h/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions soc/nordic/nrf54h/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 19 additions & 18 deletions boards/nordic/nrf54h20dk/board.c → soc/nordic/nrf54h/mram.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,55 @@
*/

#include <zephyr/init.h>

#define MODULE mram_suspend_off
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(MODULE);
#include <zephyr/toolchain.h>

#include <services/nrfs_mram.h>
#include <nrfs_backend_ipc_service.h>

#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);

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);
Loading