diff options
Diffstat (limited to 'chip/mec1322')
-rw-r--r-- | chip/mec1322/build.mk | 1 | ||||
-rw-r--r-- | chip/mec1322/watchdog.c | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/chip/mec1322/build.mk b/chip/mec1322/build.mk index ae435bf8c6..f47014ef89 100644 --- a/chip/mec1322/build.mk +++ b/chip/mec1322/build.mk @@ -13,3 +13,4 @@ CFLAGS_CPU+=-march=armv7e-m -mcpu=cortex-m4 # Required chip modules chip-y=clock.o gpio.o hwtimer.o system.o uart.o jtag.o +chip-$(CONFIG_WATCHDOG)+=watchdog.o diff --git a/chip/mec1322/watchdog.c b/chip/mec1322/watchdog.c new file mode 100644 index 0000000000..f46360f152 --- /dev/null +++ b/chip/mec1322/watchdog.c @@ -0,0 +1,32 @@ +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Watchdog driver */ + +/* + * TODO(crosbug.com/p/24107): Use independent timer for warning before watchdog + * timer expires. + */ + +#include "hooks.h" +#include "registers.h" +#include "watchdog.h" + +void watchdog_reload(void) +{ + MEC1322_WDG_KICK = 1; +} +DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT); + +int watchdog_init(void) +{ + /* Set timeout. It takes 1007us to decrement WDG_CNT by 1. */ + MEC1322_WDG_LOAD = WATCHDOG_PERIOD_MS * 1000 / 1007; + + /* Start watchdog */ + MEC1322_WDG_CTL |= 1; + + return EC_SUCCESS; +} |