summaryrefslogtreecommitdiff
path: root/chip/mec1322/watchdog.c
diff options
context:
space:
mode:
authorVic (Chun-Ju) Yang <victoryang@chromium.org>2013-11-25 17:35:34 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-11-26 18:19:10 +0000
commit3f82ac35797b730b98d2bebeed4240b3439800ee (patch)
treee4b4ca79272d5c32e8ec12c6a1b7ca55140a46bd /chip/mec1322/watchdog.c
parent7f3ed512dbb250f946fa62dd2ee5781b170fee48 (diff)
downloadchrome-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/watchdog.c')
-rw-r--r--chip/mec1322/watchdog.c32
1 files changed, 32 insertions, 0 deletions
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;
+}