Skip to content

Commit e330b55

Browse files
ydamigosnashif
authored andcommitted
soc/da1469x: Update sys_arch_reboot() function
Update sys_arch_reboot() function Signed-off-by: Ioannis Damigos <[email protected]>
1 parent a6c1f80 commit e330b55

File tree

1 file changed

+21
-3
lines changed
  • soc/renesas/smartbond/da1469x

1 file changed

+21
-3
lines changed

soc/renesas/smartbond/da1469x/soc.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <zephyr/init.h>
88
#include <zephyr/linker/linker-defs.h>
99
#include <zephyr/logging/log.h>
10+
#include <zephyr/sys/reboot.h>
1011
#include <string.h>
1112
#include <DA1469xAB.h>
1213
#include <da1469x_clock.h>
@@ -36,9 +37,26 @@ static uint32_t z_renesas_cache_configured;
3637

3738
void sys_arch_reboot(int type)
3839
{
39-
ARG_UNUSED(type);
40-
41-
NVIC_SystemReset();
40+
if (type == SYS_REBOOT_WARM) {
41+
NVIC_SystemReset();
42+
} else if (type == SYS_REBOOT_COLD) {
43+
if ((SYS_WDOG->WATCHDOG_REG & SYS_WDOG_WATCHDOG_REG_WDOG_VAL_NEG_Msk) == 0) {
44+
/* Cannot write WATCHDOG_REG while WRITE_BUSY */
45+
while ((SYS_WDOG->WATCHDOG_REG &
46+
SYS_WDOG_WATCHDOG_CTRL_REG_WRITE_BUSY_Msk) != 0) {
47+
}
48+
/* Write WATCHDOG_REG */
49+
SYS_WDOG->WATCHDOG_REG = BIT(SYS_WDOG_WATCHDOG_REG_WDOG_VAL_Pos);
50+
51+
GPREG->RESET_FREEZE_REG = GPREG_SET_FREEZE_REG_FRZ_SYS_WDOG_Msk;
52+
SYS_WDOG->WATCHDOG_CTRL_REG &=
53+
~SYS_WDOG_WATCHDOG_CTRL_REG_WDOG_FREEZE_EN_Msk;
54+
}
55+
/* Wait */
56+
for (;;) {
57+
__NOP();
58+
}
59+
}
4260
}
4361

4462
#if defined(CONFIG_BOOTLOADER_MCUBOOT)

0 commit comments

Comments
 (0)