Skip to content

Commit 7ab138a

Browse files
gmarullbjarki-andreasen
authored andcommitted
[nrf fromlist] 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. Upstream PR #: 81735 Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 2522ec4 commit 7ab138a

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

include/zephyr/dt-bindings/power/nordic-nrf-gpd.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#define ZEPHYR_INCLUDE_DT_BINDINGS_POWER_NORDIC_NRF_GLOBAL_PD
99

1010
/* numbers aligned to nrfs service identifiers */
11-
#define NRF_GPD_SLOW_MAIN 2U
12-
#define NRF_GPD_SLOW_ACTIVE 1U
13-
#define NRF_GPD_FAST_MAIN 3U
14-
#define NRF_GPD_FAST_ACTIVE1 0U
15-
#define NRF_GPD_FAST_ACTIVE0 4U
11+
#define NRF_GPD_FAST_ACTIVE0 0U
12+
#define NRF_GPD_FAST_ACTIVE1 1U
13+
#define NRF_GPD_FAST_MAIN 2U
14+
#define NRF_GPD_SLOW_ACTIVE 3U
15+
#define NRF_GPD_SLOW_MAIN 4U
1616

1717
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_POWER_NORDIC_NRF_GLOBAL_PD */

soc/nordic/nrf54h/gpd/gpd.c

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
LOG_MODULE_REGISTER(gpd, CONFIG_SOC_LOG_LEVEL);
2121

2222
/* enforce alignment between DT<->nrfs */
23-
BUILD_ASSERT(GDPWR_POWER_DOMAIN_ACTIVE_FAST == NRF_GPD_FAST_ACTIVE1);
24-
BUILD_ASSERT(GDPWR_POWER_DOMAIN_ACTIVE_SLOW == NRF_GPD_SLOW_ACTIVE);
25-
BUILD_ASSERT(GDPWR_POWER_DOMAIN_MAIN_SLOW == NRF_GPD_SLOW_MAIN);
23+
BUILD_ASSERT(GDPWR_GD_FAST_ACTIVE_0 == NRF_GPD_FAST_ACTIVE0);
24+
BUILD_ASSERT(GDPWR_GD_FAST_ACTIVE_1 == NRF_GPD_FAST_ACTIVE1);
25+
BUILD_ASSERT(GDPWR_GD_FAST_MAIN == NRF_GPD_FAST_MAIN);
26+
BUILD_ASSERT(GDPWR_GD_SLOW_ACTIVE == NRF_GPD_SLOW_ACTIVE);
27+
BUILD_ASSERT(GDPWR_GD_SLOW_MAIN == NRF_GPD_SLOW_MAIN);
2628

2729
struct gpd_onoff_manager {
2830
struct onoff_manager mgr;
@@ -44,11 +46,21 @@ static void stop(struct onoff_manager *mgr, onoff_notify_fn notify);
4446
#define GPD_SERVICE_REQ_ERR BIT(3)
4547
static atomic_t gpd_service_status = ATOMIC_INIT(0);
4648

49+
static struct gpd_onoff_manager fast_active0 = {
50+
.id = NRF_GPD_FAST_ACTIVE0,
51+
.lock = Z_MUTEX_INITIALIZER(fast_active0.lock),
52+
.sem = Z_SEM_INITIALIZER(fast_active0.sem, 0, 1),
53+
};
4754
static struct gpd_onoff_manager fast_active1 = {
4855
.id = NRF_GPD_FAST_ACTIVE1,
4956
.lock = Z_MUTEX_INITIALIZER(fast_active1.lock),
5057
.sem = Z_SEM_INITIALIZER(fast_active1.sem, 0, 1),
5158
};
59+
static struct gpd_onoff_manager fast_main = {
60+
.id = NRF_GPD_FAST_MAIN,
61+
.lock = Z_MUTEX_INITIALIZER(fast_main.lock),
62+
.sem = Z_SEM_INITIALIZER(fast_main.sem, 0, 1),
63+
};
5264
static struct gpd_onoff_manager slow_active = {
5365
.id = NRF_GPD_SLOW_ACTIVE,
5466
.lock = Z_MUTEX_INITIALIZER(slow_active.lock),
@@ -66,8 +78,12 @@ static const struct onoff_transitions transitions =
6678
static struct gpd_onoff_manager *get_mgr(uint8_t id)
6779
{
6880
switch (id) {
81+
case NRF_GPD_FAST_ACTIVE0:
82+
return &fast_active0;
6983
case NRF_GPD_FAST_ACTIVE1:
7084
return &fast_active1;
85+
case NRF_GPD_FAST_MAIN:
86+
return &fast_main;
7187
case NRF_GPD_SLOW_ACTIVE:
7288
return &slow_active;
7389
case NRF_GPD_SLOW_MAIN:
@@ -286,11 +302,21 @@ static int nrf_gpd_pre_init(void)
286302
{
287303
int ret;
288304

305+
ret = onoff_manager_init(&fast_active0.mgr, &transitions);
306+
if (ret < 0) {
307+
return ret;
308+
}
309+
289310
ret = onoff_manager_init(&fast_active1.mgr, &transitions);
290311
if (ret < 0) {
291312
return ret;
292313
}
293314

315+
ret = onoff_manager_init(&fast_main.mgr, &transitions);
316+
if (ret < 0) {
317+
return ret;
318+
}
319+
294320
ret = onoff_manager_init(&slow_active.mgr, &transitions);
295321
if (ret < 0) {
296322
return ret;
@@ -322,11 +348,21 @@ static int nrf_gpd_post_init(void)
322348
}
323349

324350
/* submit GD requests now to align collected statuses */
351+
ret = nrf_gpd_sync(&fast_active0);
352+
if (ret < 0) {
353+
goto err;
354+
}
355+
325356
ret = nrf_gpd_sync(&fast_active1);
326357
if (ret < 0) {
327358
goto err;
328359
}
329360

361+
ret = nrf_gpd_sync(&fast_main);
362+
if (ret < 0) {
363+
goto err;
364+
}
365+
330366
ret = nrf_gpd_sync(&slow_active);
331367
if (ret < 0) {
332368
goto err;

0 commit comments

Comments
 (0)