From 63a15dbb32d6fb9ddc14d9756a82dc3f1416695c Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Thu, 28 Nov 2024 09:49:42 +0100 Subject: [PATCH] soc: nordic: nrf54h: gpd: align GPD domain names nRFs exposes now all power domains, following their actual name in the specification. Add support for all of them in the GPD service. Note that this is a breaking change: running this code requires a new SCFW as IDs have changed in nRFs and so SCFW. Signed-off-by: Gerard Marull-Paretas --- .../zephyr/dt-bindings/power/nordic-nrf-gpd.h | 10 ++--- soc/nordic/nrf54h/gpd/gpd.c | 42 +++++++++++++++++-- west.yml | 2 +- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/include/zephyr/dt-bindings/power/nordic-nrf-gpd.h b/include/zephyr/dt-bindings/power/nordic-nrf-gpd.h index 7f6952f6f0bcbc..e4a5b83a304189 100644 --- a/include/zephyr/dt-bindings/power/nordic-nrf-gpd.h +++ b/include/zephyr/dt-bindings/power/nordic-nrf-gpd.h @@ -8,10 +8,10 @@ #define ZEPHYR_INCLUDE_DT_BINDINGS_POWER_NORDIC_NRF_GLOBAL_PD /* numbers aligned to nrfs service identifiers */ -#define NRF_GPD_SLOW_MAIN 2U -#define NRF_GPD_SLOW_ACTIVE 1U -#define NRF_GPD_FAST_MAIN 3U -#define NRF_GPD_FAST_ACTIVE1 0U -#define NRF_GPD_FAST_ACTIVE0 4U +#define NRF_GPD_FAST_ACTIVE0 0U +#define NRF_GPD_FAST_ACTIVE1 1U +#define NRF_GPD_FAST_MAIN 2U +#define NRF_GPD_SLOW_ACTIVE 3U +#define NRF_GPD_SLOW_MAIN 4U #endif /* ZEPHYR_INCLUDE_DT_BINDINGS_POWER_NORDIC_NRF_GLOBAL_PD */ diff --git a/soc/nordic/nrf54h/gpd/gpd.c b/soc/nordic/nrf54h/gpd/gpd.c index 540c1cb03bd489..5c7efcf543a663 100644 --- a/soc/nordic/nrf54h/gpd/gpd.c +++ b/soc/nordic/nrf54h/gpd/gpd.c @@ -20,9 +20,11 @@ LOG_MODULE_REGISTER(gpd, CONFIG_SOC_LOG_LEVEL); /* enforce alignment between DT<->nrfs */ -BUILD_ASSERT(GDPWR_POWER_DOMAIN_ACTIVE_FAST == NRF_GPD_FAST_ACTIVE1); -BUILD_ASSERT(GDPWR_POWER_DOMAIN_ACTIVE_SLOW == NRF_GPD_SLOW_ACTIVE); -BUILD_ASSERT(GDPWR_POWER_DOMAIN_MAIN_SLOW == NRF_GPD_SLOW_MAIN); +BUILD_ASSERT(GDPWR_GD_FAST_ACTIVE_0 == NRF_GPD_FAST_ACTIVE0); +BUILD_ASSERT(GDPWR_GD_FAST_ACTIVE_1 == NRF_GPD_FAST_ACTIVE1); +BUILD_ASSERT(GDPWR_GD_FAST_MAIN == NRF_GPD_FAST_MAIN); +BUILD_ASSERT(GDPWR_GD_SLOW_ACTIVE == NRF_GPD_SLOW_ACTIVE); +BUILD_ASSERT(GDPWR_GD_SLOW_MAIN == NRF_GPD_SLOW_MAIN); struct gpd_onoff_manager { struct onoff_manager mgr; @@ -44,11 +46,21 @@ static void stop(struct onoff_manager *mgr, onoff_notify_fn notify); #define GPD_SERVICE_REQ_ERR BIT(3) static atomic_t gpd_service_status = ATOMIC_INIT(0); +static struct gpd_onoff_manager fast_active0 = { + .id = NRF_GPD_FAST_ACTIVE0, + .lock = Z_MUTEX_INITIALIZER(fast_active0.lock), + .sem = Z_SEM_INITIALIZER(fast_active0.sem, 0, 1), +}; static struct gpd_onoff_manager fast_active1 = { .id = NRF_GPD_FAST_ACTIVE1, .lock = Z_MUTEX_INITIALIZER(fast_active1.lock), .sem = Z_SEM_INITIALIZER(fast_active1.sem, 0, 1), }; +static struct gpd_onoff_manager fast_main = { + .id = NRF_GPD_FAST_MAIN, + .lock = Z_MUTEX_INITIALIZER(fast_main.lock), + .sem = Z_SEM_INITIALIZER(fast_main.sem, 0, 1), +}; static struct gpd_onoff_manager slow_active = { .id = NRF_GPD_SLOW_ACTIVE, .lock = Z_MUTEX_INITIALIZER(slow_active.lock), @@ -66,8 +78,12 @@ static const struct onoff_transitions transitions = static struct gpd_onoff_manager *get_mgr(uint8_t id) { switch (id) { + case NRF_GPD_FAST_ACTIVE0: + return &fast_active0; case NRF_GPD_FAST_ACTIVE1: return &fast_active1; + case NRF_GPD_FAST_MAIN: + return &fast_main; case NRF_GPD_SLOW_ACTIVE: return &slow_active; case NRF_GPD_SLOW_MAIN: @@ -285,11 +301,21 @@ static int nrf_gpd_pre_init(void) { int ret; + ret = onoff_manager_init(&fast_active0.mgr, &transitions); + if (ret < 0) { + return ret; + } + ret = onoff_manager_init(&fast_active1.mgr, &transitions); if (ret < 0) { return ret; } + ret = onoff_manager_init(&fast_main.mgr, &transitions); + if (ret < 0) { + return ret; + } + ret = onoff_manager_init(&slow_active.mgr, &transitions); if (ret < 0) { return ret; @@ -321,11 +347,21 @@ static int nrf_gpd_post_init(void) } /* submit GD requests now to align collected statuses */ + ret = nrf_gpd_sync(&fast_active0); + if (ret < 0) { + goto err; + } + ret = nrf_gpd_sync(&fast_active1); if (ret < 0) { goto err; } + ret = nrf_gpd_sync(&fast_main); + if (ret < 0) { + goto err; + } + ret = nrf_gpd_sync(&slow_active); if (ret < 0) { goto err; diff --git a/west.yml b/west.yml index 673e9017c53e57..4830dff290b2e9 100644 --- a/west.yml +++ b/west.yml @@ -188,7 +188,7 @@ manifest: groups: - hal - name: hal_nordic - revision: ce87268bb5610b7e90acce3efa5c511e95aeeeae + revision: pull/261/head path: modules/hal/nordic groups: - hal