summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-30 12:16:54 -0700
committerGerrit <chrome-bot@google.com>2012-10-30 15:33:24 -0700
commit8b3a242ff0b8398b37378c67fe2c63beec1fa827 (patch)
treebb647b1ae48da03ccdb8efb290add7575145f691 /chip
parenta21ea56e76ff71849d45f59608c0beb7bede4c02 (diff)
downloadchrome-ec-8b3a242ff0b8398b37378c67fe2c63beec1fa827.tar.gz
Watchdog is reloaded by HOOK_TICK, not its own task
This reduces memory footprint. BUG=chrome-os-partner:15714 BRANCH=none TEST=system still boots; 'waitms 1500' prints watchdog error dump Change-Id: Ieb0248a34655514b03d919cc36c2b369691da716 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36937 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/lm4/build.mk3
-rw-r--r--chip/lm4/config.h2
-rw-r--r--chip/lm4/flash.c4
-rw-r--r--chip/lm4/watchdog.c3
-rw-r--r--chip/stm32/build.mk2
-rw-r--r--chip/stm32/config.h3
-rw-r--r--chip/stm32/flash-stm32f100.c4
-rw-r--r--chip/stm32/flash-stm32l15x.c4
-rw-r--r--chip/stm32/watchdog.c6
9 files changed, 17 insertions, 14 deletions
diff --git a/chip/lm4/build.mk b/chip/lm4/build.mk
index d627409afb..c1405aeeb4 100644
--- a/chip/lm4/build.mk
+++ b/chip/lm4/build.mk
@@ -10,7 +10,7 @@
CORE:=cortex-m
# Required chip modules
-chip-y=clock.o gpio.o hwtimer.o jtag.o system.o uart.o watchdog.o
+chip-y=clock.o gpio.o hwtimer.o jtag.o system.o uart.o
# Optional chip modules
chip-$(CONFIG_ADC)+=adc.o
@@ -25,3 +25,4 @@ chip-$(CONFIG_TASK_PWM)+=pwm.o
chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o keyboard_scan_stub.o
chip-$(CONFIG_TASK_SWITCH)+=switch.o
chip-$(CONFIG_TASK_TEMPSENSOR)+=chip_temp_sensor.o
+chip-$(CONFIG_WATCHDOG)+=watchdog.o
diff --git a/chip/lm4/config.h b/chip/lm4/config.h
index aa40382b42..b82c74eae7 100644
--- a/chip/lm4/config.h
+++ b/chip/lm4/config.h
@@ -29,7 +29,6 @@
/* non-standard task stack sizes */
#define IDLE_TASK_STACK_SIZE 384
-#define WATCHDOG_TASK_STACK_SIZE 256
#define LARGER_TASK_STACK_SIZE 640
/* Default task stack size */
@@ -89,6 +88,7 @@
#define CONFIG_FLASH
#define CONFIG_FPU
#define CONFIG_I2C
+#define CONFIG_WATCHDOG
/* Compile for running from RAM instead of flash */
/* #define COMPILE_FOR_RAM */
diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c
index e599fa5a96..51d9a46577 100644
--- a/chip/lm4/flash.c
+++ b/chip/lm4/flash.c
@@ -171,7 +171,7 @@ static int write_buffer(void)
/* Start write operation at page boundary */
LM4_FLASH_FMC2 = 0xa4420001;
-#ifdef CONFIG_TASK_WATCHDOG
+#ifdef CONFIG_WATCHDOG
/* Reload the watchdog timer, so that writing a large amount of flash
* doesn't cause a watchdog reset. */
watchdog_reload();
@@ -240,7 +240,7 @@ int flash_physical_erase(int offset, int size)
LM4_FLASH_FMA = offset;
-#ifdef CONFIG_TASK_WATCHDOG
+#ifdef CONFIG_WATCHDOG
/* Reload the watchdog timer, so that erasing many flash pages
* doesn't cause a watchdog reset. May not need this now that
* we're using msleep() below. */
diff --git a/chip/lm4/watchdog.c b/chip/lm4/watchdog.c
index 58cabf80f9..7bc7aa8a60 100644
--- a/chip/lm4/watchdog.c
+++ b/chip/lm4/watchdog.c
@@ -5,10 +5,8 @@
/* Watchdog driver */
-#include "board.h"
#include "clock.h"
#include "common.h"
-#include "config.h"
#include "registers.h"
#include "gpio.h"
#include "hooks.h"
@@ -79,6 +77,7 @@ void watchdog_reload(void)
/* Re-lock watchdog registers */
LM4_WATCHDOG_LOCK(0) = 0xdeaddead;
}
+DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT);
static void watchdog_freq_changed(void)
{
diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk
index b58953e995..36496ba411 100644
--- a/chip/stm32/build.mk
+++ b/chip/stm32/build.mk
@@ -13,7 +13,7 @@ chip-y=dma.o gpio.o hwtimer.o system.o uart.o
chip-y+=jtag-$(CHIP_VARIANT).o clock-$(CHIP_VARIANT).o gpio-$(CHIP_VARIANT).o
chip-$(CONFIG_SPI)+=spi.o
chip-$(CONFIG_I2C)+=i2c.o
-chip-$(CONFIG_TASK_WATCHDOG)+=watchdog.o
+chip-$(CONFIG_WATCHDOG)+=watchdog.o
chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o
chip-$(CONFIG_TASK_POWERLED)+=power_led.o
chip-$(CONFIG_FLASH)+=flash-$(CHIP_VARIANT).o
diff --git a/chip/stm32/config.h b/chip/stm32/config.h
index bc7283396a..5a1ab1e449 100644
--- a/chip/stm32/config.h
+++ b/chip/stm32/config.h
@@ -33,6 +33,9 @@
/* build with assertions and debug messages */
#define CONFIG_DEBUG
+/* Enable watchdog timer */
+#define CONFIG_WATCHDOG
+
/* Compile for running from RAM instead of flash */
/* #define COMPILE_FOR_RAM */
diff --git a/chip/stm32/flash-stm32f100.c b/chip/stm32/flash-stm32f100.c
index 907b246e84..7932a85df4 100644
--- a/chip/stm32/flash-stm32f100.c
+++ b/chip/stm32/flash-stm32f100.c
@@ -314,7 +314,7 @@ int flash_physical_write(int offset, int size, const char *data)
STM32_FLASH_CR |= PG;
for ( ; size > 0; size -= sizeof(uint16_t)) {
-#ifdef CONFIG_TASK_WATCHDOG
+#ifdef CONFIG_WATCHDOG
/* Reload the watchdog timer to avoid watchdog reset when doing
* long writing with interrupt disabled.
*/
@@ -383,7 +383,7 @@ int flash_physical_erase(int offset, int size)
/* set STRT bit : start erase */
STM32_FLASH_CR |= STRT;
-#ifdef CONFIG_TASK_WATCHDOG
+#ifdef CONFIG_WATCHDOG
/*
* Reload the watchdog timer to avoid watchdog reset during a
* long erase operation.
diff --git a/chip/stm32/flash-stm32l15x.c b/chip/stm32/flash-stm32l15x.c
index cbe7953797..046c106820 100644
--- a/chip/stm32/flash-stm32l15x.c
+++ b/chip/stm32/flash-stm32l15x.c
@@ -189,7 +189,7 @@ int flash_physical_write(int offset, int size, const char *data)
for (address = (uint32_t *)(CONFIG_FLASH_BASE + offset) ;
size > 0; size -= CONFIG_FLASH_WRITE_SIZE) {
-#ifdef CONFIG_TASK_WATCHDOG
+#ifdef CONFIG_WATCHDOG
/*
* Reload the watchdog timer to avoid watchdog reset when doing
* long writing with interrupt disabled.
@@ -249,7 +249,7 @@ int flash_physical_erase(int offset, int size)
/* Start erase */
*address = 0x00000000;
-#ifdef CONFIG_TASK_WATCHDOG
+#ifdef CONFIG_WATCHDOG
/*
* Reload the watchdog timer to avoid watchdog reset during
* multi-page erase operations.
diff --git a/chip/stm32/watchdog.c b/chip/stm32/watchdog.c
index d93d0a6b96..774768ad36 100644
--- a/chip/stm32/watchdog.c
+++ b/chip/stm32/watchdog.c
@@ -5,12 +5,11 @@
/* Watchdog driver */
-#include "board.h"
#include "common.h"
-#include "config.h"
-#include "registers.h"
#include "gpio.h"
+#include "hooks.h"
#include "hwtimer.h"
+#include "registers.h"
#include "task.h"
#include "timer.h"
#include "util.h"
@@ -56,6 +55,7 @@ void watchdog_reload(void)
hwtimer_reset_watchdog();
#endif
}
+DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT);
int watchdog_init(void)
{