summaryrefslogtreecommitdiff
path: root/chip/mt_scp/rv32i_common/watchdog.c
diff options
context:
space:
mode:
Diffstat (limited to 'chip/mt_scp/rv32i_common/watchdog.c')
-rw-r--r--chip/mt_scp/rv32i_common/watchdog.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/chip/mt_scp/rv32i_common/watchdog.c b/chip/mt_scp/rv32i_common/watchdog.c
index 72ca5edad8..05acf6ea29 100644
--- a/chip/mt_scp/rv32i_common/watchdog.c
+++ b/chip/mt_scp/rv32i_common/watchdog.c
@@ -8,6 +8,7 @@
#include "common.h"
#include "hooks.h"
#include "registers.h"
+#include "scp_watchdog.h"
#include "watchdog.h"
void watchdog_reload(void)
@@ -16,7 +17,15 @@ void watchdog_reload(void)
}
DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT);
-int watchdog_init(void)
+void disable_watchdog(void)
+{
+ /* disable watchdog */
+ SCP_CORE0_WDT_CFG &= ~WDT_EN;
+ /* clear watchdog irq */
+ SCP_CORE0_WDT_IRQ |= BIT(0);
+}
+
+void enable_watchdog(void)
{
const uint32_t timeout = WDT_PERIOD(CONFIG_WATCHDOG_PERIOD_MS);
@@ -28,6 +37,11 @@ int watchdog_init(void)
SCP_CORE0_WDT_CFG = WDT_EN | timeout;
/* reload watchdog */
watchdog_reload();
+}
+
+int watchdog_init(void)
+{
+ enable_watchdog();
return EC_SUCCESS;
}