diff options
author | Vic (Chun-Ju) Yang <victoryang@chromium.org> | 2013-11-25 17:35:34 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-11-26 18:19:10 +0000 |
commit | 3f82ac35797b730b98d2bebeed4240b3439800ee (patch) | |
tree | e4b4ca79272d5c32e8ec12c6a1b7ca55140a46bd /chip/mec1322 | |
parent | 7f3ed512dbb250f946fa62dd2ee5781b170fee48 (diff) | |
download | chrome-ec-3f82ac35797b730b98d2bebeed4240b3439800ee.tar.gz |
mec1322: Add watchdog support
This implements the basic watchdog support. For now, the watchdog
doesn't warn us before it expires. This functionality will be added
later using a basic timer.
BUG=chrome-os-partner:24107
TEST='waitms 700' and the EC stays alive.
TEST='waitms 1200' and the EC reboots.
BRANCH=None
Change-Id: I1cc48978ed09577ae88cc2f7a6087867e5854973
Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/177736
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; +} |