Skip to content

Commit 0f1acc2

Browse files
nordic-krchlstnl
authored andcommitted
wip
1 parent eb35b31 commit 0f1acc2

File tree

7 files changed

+51
-24
lines changed

7 files changed

+51
-24
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
&uart135 {
2+
zephyr,pm-device-runtime-auto;
3+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
CONFIG_PM=y
12
CONFIG_PM_DEVICE=y
3+
CONFIG_PM_DEVICE_RUNTIME=y
4+
CONFIG_UART_ASYNC_API=y
25
CONFIG_GPIO=y
6+
CONFIG_NRF_REGTOOL_VERBOSITY=2
37
CONFIG_CRC=y
48
CONFIG_POWEROFF=y
59
CONFIG_HWINFO=y
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
&uart135 {
2+
status = "disabled";
3+
zephyr,pm-device-runtime-auto;
4+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
CONFIG_PM=y
12
CONFIG_PM_DEVICE=y
3+
CONFIG_PM_DEVICE_RUNTIME=y
24
CONFIG_POWEROFF=y
5+
CONFIG_UART_ASYNC_API=y
6+
CONFIG_SERIAL=n
7+
CONFIG_CONSOLE=n
8+
CONFIG_UART_CONSOLE=n
9+
CONFIG_NRF_REGTOOL_VERBOSITY=2

samples/boards/nordic/system_off/remote/src/main.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
#include <zephyr/kernel.h>
77
#include <zephyr/device.h>
88
#include <zephyr/pm/device.h>
9+
#include <zephyr/pm/device_runtime.h>
910
#include <zephyr/sys/poweroff.h>
1011
#include <hal/nrf_memconf.h>
1112

1213
int main(void)
1314
{
14-
int rc;
15-
const struct device *const cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
16-
17-
printf("%s system off demo. Ready for system off.\n", CONFIG_BOARD);
18-
19-
rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
20-
if (rc < 0) {
21-
printf("Could not suspend console (%d)\n", rc);
22-
return 0;
15+
if (IS_ENABLED(CONFIG_CONSOLE)) {
16+
printf("%s system off demo. Ready for system off.\n", CONFIG_BOARD);
2317
}
2418

25-
nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 0, RAMBLOCK_RET_MASK, false);
26-
nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 1, RAMBLOCK_RET_MASK, false);
19+
if (0) {
20+
/*nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 0, RAMBLOCK_RET_MASK, false);*/
21+
/*nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 1, RAMBLOCK_RET_MASK, false);*/
22+
k_sleep(K_FOREVER);
23+
} else {
24+
/*nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 0, RAMBLOCK_RET_MASK, false);*/
25+
/*nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 1, RAMBLOCK_RET_MASK, false);*/
2726

28-
sys_poweroff();
27+
sys_poweroff();
28+
}
2929

3030
return 0;
3131
}

samples/boards/nordic/system_off/src/main.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <zephyr/sys/util.h>
2020

2121
#define NON_WAKEUP_RESET_REASON (RESET_PIN | RESET_SOFTWARE | RESET_POR | RESET_DEBUG)
22+
#include <zephyr/pm/device_runtime.h>
23+
#include <hal/nrf_gpio.h>
24+
#include <hal/nrf_memconf.h>
2225

2326
#if defined(CONFIG_GRTC_WAKEUP_ENABLE)
2427
#include <zephyr/drivers/timer/nrf_grtc_timer.h>
@@ -28,16 +31,18 @@
2831
static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
2932
#endif
3033
#if defined(CONFIG_LPCOMP_WAKEUP_ENABLE)
31-
static const uint32_t port_sw1 = DT_PROP(DT_GPIO_CTLR_BY_IDX(DT_ALIAS(sw1), gpios, 0), port);
3234
static const struct device *comp_dev = DEVICE_DT_GET(DT_NODELABEL(comp));
3335
#endif
3436

37+
static const struct gpio_dt_spec sw1 = GPIO_DT_SPEC_GET(DT_ALIAS(sw1), gpios);
38+
static const uint32_t port_sw1 = DT_PROP(DT_GPIO_CTLR_BY_IDX(DT_ALIAS(sw1), gpios, 0), port);
39+
3540
int print_reset_cause(uint32_t reset_cause)
3641
{
3742
int32_t ret;
3843
uint32_t supported;
3944

40-
ret = hwinfo_get_supported_reset_cause((uint32_t *) &supported);
45+
ret = hwinfo_get_supported_reset_cause((uint32_t *)&supported);
4146

4247
if (ret || !(reset_cause & supported)) {
4348
return -ENOTSUP;
@@ -109,9 +114,9 @@ int main(void)
109114
int err = z_nrf_grtc_wakeup_prepare(DEEP_SLEEP_TIME_S * USEC_PER_SEC);
110115

111116
if (err < 0) {
112-
printk("Unable to prepare GRTC as a wake up source (err = %d).\n", err);
117+
printf("Unable to prepare GRTC as a wake up source (err = %d).\n", err);
113118
} else {
114-
printk("Entering system off; wait %u seconds to restart\n", DEEP_SLEEP_TIME_S);
119+
printf("Entering system off; wait %u seconds to restart\n", DEEP_SLEEP_TIME_S);
115120
}
116121
#endif
117122
#if defined(CONFIG_GPIO_WAKEUP_ENABLE)
@@ -122,24 +127,22 @@ int main(void)
122127
return 0;
123128
}
124129

125-
rc = gpio_pin_configure_dt(&sw1, GPIO_INPUT);
126-
if (rc < 0) {
127-
printf("Could not configure sw1 GPIO (%d)\n", rc);
128-
return 0;
129-
}
130-
131130
rc = gpio_pin_interrupt_configure_dt(&sw0, GPIO_INT_LEVEL_ACTIVE);
132131
if (rc < 0) {
133132
printf("Could not configure sw0 GPIO interrupt (%d)\n", rc);
134133
return 0;
135134
}
136-
//code reorder needed
137135
#endif
138136
#if defined(CONFIG_LPCOMP_WAKEUP_ENABLE)
139137
comparator_set_trigger(comp_dev, COMPARATOR_TRIGGER_BOTH_EDGES);
140138
comparator_trigger_is_pending(comp_dev);
141139
printf("Entering system off; change signal level at comparator input to restart\n");
142140
#endif
141+
rc = gpio_pin_configure_dt(&sw1, GPIO_INPUT);
142+
if (rc < 0) {
143+
printf("Could not configure sw1 GPIO (%d)\n", rc);
144+
return 0;
145+
}
143146

144147
rc = gpio_pin_interrupt_configure_dt(&sw1, GPIO_INT_LEVEL_ACTIVE);
145148
if (rc < 0) {
@@ -165,6 +168,7 @@ int main(void)
165168
retained_update();
166169
}
167170

171+
k_sleep(K_MSEC(4000));
168172
if (do_poweroff) {
169173
#if CONFIG_SOC_NRF54H20_CPUAPP
170174
/* Local RAM0 (TCM) is currently not used so retention can be disabled. */

soc/nordic/nrf54h/power.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ void nrf_poweroff(void)
7070
nrf_resetinfo_resetreas_local_set(NRF_RESETINFO, 0);
7171
nrf_resetinfo_restore_valid_set(NRF_RESETINFO, false);
7272

73-
#if !defined(CONFIG_SOC_NRF54H20_CPURAD)
73+
#if defined(CONFIG_SOC_NRF54H20_CPURAD)
74+
nrf_lrcconf_retain_set(NRF_LRCCONF010,
75+
NRF_LRCCONF_POWER_DOMAIN_0 | NRF_LRCCONF_POWER_DOMAIN_1, false);
76+
nrf_lrcconf_poweron_force_set(NRF_LRCCONF010,
77+
NRF_LRCCONF_POWER_DOMAIN_0 | NRF_LRCCONF_POWER_DOMAIN_1, false);
78+
#else
7479
/* Disable retention */
7580
nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_MAIN, false);
7681
nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false);

0 commit comments

Comments
 (0)