summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-06-01 21:43:25 -0700
committerGerrit <chrome-bot@google.com>2012-06-05 09:30:21 -0700
commitfb425cf11f5a0f9ea2a1a7dc19789b328b3bc859 (patch)
tree7af3ade8e5bf3820b288ad7bd7ddc0a9db7f40da
parent76abf8f8cc3003fa3bb00d5c4902335a933707e8 (diff)
downloadchrome-ec-fb425cf11f5a0f9ea2a1a7dc19789b328b3bc859.tar.gz
Unify the watchdog API over stm32 and lm4
Use the same prototype for watchdog_init() everywhere. One version takes a parameters and one doesn't. We don't need the parameter since we have a #define. Tidy this up. Also move watchdog defines into watchdog.h. BUG=chrome-os-partner:10145 TEST=build for all boards Change-Id: I38ae63d7cc137b93017c850e767703d5f90f56ad Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24394 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--chip/lm4/watchdog.c6
-rw-r--r--chip/stm32/watchdog.c6
-rw-r--r--common/main.c2
-rw-r--r--include/watchdog.h10
4 files changed, 15 insertions, 9 deletions
diff --git a/chip/lm4/watchdog.c b/chip/lm4/watchdog.c
index 6591de64ac..915c7e3489 100644
--- a/chip/lm4/watchdog.c
+++ b/chip/lm4/watchdog.c
@@ -16,6 +16,7 @@
#include "timer.h"
#include "uart.h"
#include "util.h"
+#include "watchdog.h"
/*
* We use watchdog 0 which is clocked on the system clock
@@ -25,11 +26,6 @@
/* magic value to unlock the watchdog registers */
#define LM4_WATCHDOG_MAGIC_WORD 0x1ACCE551
-#define WATCHDOG_PERIOD_MS 1100 /* Watchdog period in ms */
-#define WATCHDOG_RELOAD_MS 500 /* Interval in ms between reloads of the
- * watchdog timer. Should be less than half
- * of the watchdog period. */
-
static uint32_t watchdog_period; /* Watchdog counter initial value */
/* Watchdog debug trace. This is triggered if the watchdog has not been
diff --git a/chip/stm32/watchdog.c b/chip/stm32/watchdog.c
index ae5442f471..d23d12edbe 100644
--- a/chip/stm32/watchdog.c
+++ b/chip/stm32/watchdog.c
@@ -13,6 +13,7 @@
#include "task.h"
#include "timer.h"
#include "util.h"
+#include "watchdog.h"
/* LSI oscillator frequency is typically 38 kHz
* but might vary from 28 to 56kHz.
@@ -33,12 +34,13 @@ void watchdog_reload(void)
}
-int watchdog_init(int period_ms)
+int watchdog_init(void)
{
uint32_t watchdog_period;
/* set the time-out period */
- watchdog_period = period_ms * (LSI_CLOCK / IWDG_PRESCALER_DIV) / 1000;
+ watchdog_period = WATCHDOG_PERIOD_MS *
+ (LSI_CLOCK / IWDG_PRESCALER_DIV) / 1000;
/* Unlock watchdog registers */
STM32_IWDG_KR = 0x5555;
diff --git a/common/main.c b/common/main.c
index 74a698460e..d807f17101 100644
--- a/common/main.c
+++ b/common/main.c
@@ -86,7 +86,7 @@ int main(void)
* triggering a watchdog reboot. (This pretty much applies only to
* verified boot, because all *other* lengthy operations should be done
* by tasks.) */
- watchdog_init(1100);
+ watchdog_init();
#endif
/* Verified boot needs to read the initial keyboard state and EEPROM
diff --git a/include/watchdog.h b/include/watchdog.h
index 68ac7b917e..b4d0a1e2f6 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -8,9 +8,17 @@
#ifndef __CROS_EC_WATCHDOG_H
#define __CROS_EC_WATCHDOG_H
+#define WATCHDOG_PERIOD_MS 1100 /* Watchdog period in ms */
+
+/*
+ * Interval in ms between reloads of the watchdog timer. Should be less
+ * than half of the watchdog period.
+ */
+#define WATCHDOG_RELOAD_MS 500
+
/* Initialize the watchdog. This will cause the CPU to reboot if it has been
* more than 2 watchdog periods since watchdog_reload() has been called. */
-int watchdog_init(int period_ms);
+int watchdog_init(void);
/* Reload the watchdog counter */
void watchdog_reload(void);