From e330b55f811e58c821f9ca8676e829b65de4a099 Mon Sep 17 00:00:00 2001 From: Ioannis Damigos Date: Wed, 23 Oct 2024 16:44:28 +0300 Subject: [PATCH] soc/da1469x: Update sys_arch_reboot() function Update sys_arch_reboot() function Signed-off-by: Ioannis Damigos --- soc/renesas/smartbond/da1469x/soc.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/soc/renesas/smartbond/da1469x/soc.c b/soc/renesas/smartbond/da1469x/soc.c index 79b191cb596..4186dab86e3 100644 --- a/soc/renesas/smartbond/da1469x/soc.c +++ b/soc/renesas/smartbond/da1469x/soc.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -36,9 +37,26 @@ static uint32_t z_renesas_cache_configured; void sys_arch_reboot(int type) { - ARG_UNUSED(type); + if (type == SYS_REBOOT_WARM) { + NVIC_SystemReset(); + } else if (type == SYS_REBOOT_COLD) { + if ((SYS_WDOG->WATCHDOG_REG & SYS_WDOG_WATCHDOG_REG_WDOG_VAL_NEG_Msk) == 0) { + /* Cannot write WATCHDOG_REG while WRITE_BUSY */ + while ((SYS_WDOG->WATCHDOG_REG & + SYS_WDOG_WATCHDOG_CTRL_REG_WRITE_BUSY_Msk) != 0) { + } + /* Write WATCHDOG_REG */ + SYS_WDOG->WATCHDOG_REG = BIT(SYS_WDOG_WATCHDOG_REG_WDOG_VAL_Pos); - NVIC_SystemReset(); + GPREG->RESET_FREEZE_REG = GPREG_SET_FREEZE_REG_FRZ_SYS_WDOG_Msk; + SYS_WDOG->WATCHDOG_CTRL_REG &= + ~SYS_WDOG_WATCHDOG_CTRL_REG_WDOG_FREEZE_EN_Msk; + } + /* Wait */ + for (;;) { + __NOP(); + } + } } #if defined(CONFIG_BOOTLOADER_MCUBOOT)