Skip to content

Commit

Permalink
soc: nordic: nrf54h: gpd: align GPD domain names
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gmarull committed Nov 28, 2024
1 parent 71fe68c commit 63a15db
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
10 changes: 5 additions & 5 deletions include/zephyr/dt-bindings/power/nordic-nrf-gpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
42 changes: 39 additions & 3 deletions soc/nordic/nrf54h/gpd/gpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ manifest:
groups:
- hal
- name: hal_nordic
revision: ce87268bb5610b7e90acce3efa5c511e95aeeeae
revision: pull/261/head
path: modules/hal/nordic
groups:
- hal
Expand Down

0 comments on commit 63a15db

Please sign in to comment.