summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@google.com>2019-09-12 05:37:12 +0000
committerCommit Bot <commit-bot@chromium.org>2019-09-12 09:32:38 +0000
commita0e7e66ebd384455041b99d99cce30dea771ddfa (patch)
tree3ffa6a9272b1d0ea3cb5c2bfbed5a523dabf7d28
parent614bfa8ed0066866f6e8136b186b552f57f67ea9 (diff)
downloadchrome-ec-a0e7e66ebd384455041b99d99cce30dea771ddfa.tar.gz
Revert "npcx: ensure we don't unlock watchdog too soon"
This reverts commit 031c5d2d62dd891622ded885756c03021e934ef2. Reason for revert: introduced compilation errors: chip/npcx/spiflashfw/npcx_monitor.c: In function 'sspi_flash_upload': chip/npcx/spiflashfw/npcx_monitor.c:290:2: error: implicit declaration of function 'watchdog_stop_and_unlock' [-Werror=implicit-function-declaration] watchdog_stop_and_unlock(); ^~~~~~~~~~~~~~~~~~~~~~~~ Original change's description: > npcx: ensure we don't unlock watchdog too soon > > We cannot unlock the watchdog timer with 3 watch dog ticks of touching > it per the datasheet. This is actually around 100ms so we should protect > against this. > > BRANCH=none > BUG=b:140207603 > TEST=eliminates cold reset issue. > > Change-Id: Iaef59dad9f5640d64d5d430aea87bd16c2efd30d > Signed-off-by: Jett Rink <jettrink@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1790302 > Reviewed-by: Scott Collyer <scollyer@chromium.org> > Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> > Reviewed-by: ML Chao <mlchao@nuvoton.corp-partner.google.com> > Reviewed-by: Furquan Shaikh <furquan@chromium.org> > Tested-by: Furquan Shaikh <furquan@chromium.org> > Commit-Queue: Furquan Shaikh <furquan@chromium.org> Bug: b:140207603 Change-Id: I540fa53c2c568cb789400d55b807a672b182302a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1799293 Reviewed-by: Caveh Jalali <caveh@google.com> Commit-Queue: Caveh Jalali <caveh@google.com> Tested-by: Caveh Jalali <caveh@google.com>
-rw-r--r--chip/npcx/spiflashfw/npcx_monitor.c4
-rw-r--r--chip/npcx/system.c8
-rw-r--r--chip/npcx/system_chip.h5
-rw-r--r--chip/npcx/watchdog.c28
4 files changed, 13 insertions, 32 deletions
diff --git a/chip/npcx/spiflashfw/npcx_monitor.c b/chip/npcx/spiflashfw/npcx_monitor.c
index cc327e3440..a0b011476d 100644
--- a/chip/npcx/spiflashfw/npcx_monitor.c
+++ b/chip/npcx/spiflashfw/npcx_monitor.c
@@ -287,7 +287,9 @@ sspi_flash_upload(int spi_offset, int spi_size)
}
/* Unlock & stop watchdog */
- watchdog_stop_and_unlock();
+ NPCX_WDSDM = 0x87;
+ NPCX_WDSDM = 0x61;
+ NPCX_WDSDM = 0x63;
/* UMA Unlock */
CLEAR_BIT(NPCX_UMA_ECTS, NPCX_UMA_ECTS_UMA_LOCK);
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index e7895dc3dc..ff18334533 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -44,7 +44,9 @@
void system_watchdog_reset(void)
{
/* Unlock & stop watchdog registers */
- watchdog_stop_and_unlock();
+ NPCX_WDSDM = 0x87;
+ NPCX_WDSDM = 0x61;
+ NPCX_WDSDM = 0x63;
/* Reset TWCFG */
NPCX_TWCFG = 0;
@@ -498,7 +500,9 @@ void __enter_hibernate(uint32_t seconds, uint32_t microseconds)
CLEAR_BIT(NPCX_ITCTS(ITIM_WDG_NO), NPCX_ITCTS_ITEN);
/* Unlock & stop watchdog */
- watchdog_stop_and_unlock();
+ NPCX_WDSDM = 0x87;
+ NPCX_WDSDM = 0x61;
+ NPCX_WDSDM = 0x63;
/* Initialize watchdog */
NPCX_TWCFG = 0; /* Select T0IN clock as watchdog prescaler clock */
diff --git a/chip/npcx/system_chip.h b/chip/npcx/system_chip.h
index 2836a1e4f7..5ca686a86f 100644
--- a/chip/npcx/system_chip.h
+++ b/chip/npcx/system_chip.h
@@ -30,12 +30,9 @@ enum bbram_data_index {
BBRM_DATA_INDEX_PANIC_BKUP = 36, /* Panic data (index 35-63)*/
};
-/* Issue a watchdog reset */
+/* Issue a watchdog reset*/
void system_watchdog_reset(void);
-/* Stops the watchdog timer and unlocks configuration. */
-void watchdog_stop_and_unlock(void);
-
/*
* Configure the specific memory addresses in the the MPU
* (Memory Protection Unit) for Nuvoton different chip series.
diff --git a/chip/npcx/watchdog.c b/chip/npcx/watchdog.c
index 233c875643..44a980326b 100644
--- a/chip/npcx/watchdog.c
+++ b/chip/npcx/watchdog.c
@@ -58,27 +58,6 @@ static uint8_t watchdog_count(void)
return cnt;
}
-static timestamp_t last_watchdog_touch;
-void watchdog_stop_and_unlock(void)
-{
- /*
- * Ensure we have waited at least 3 watchdog ticks since touching WD
- * timer. 3 / (32768 / 1024) HZ = 93.75ms
- */
- while (time_since32(last_watchdog_touch) < (100 * MSEC))
- continue;
-
- NPCX_WDSDM = 0x87;
- NPCX_WDSDM = 0x61;
- NPCX_WDSDM = 0x63;
-}
-
-static void touch_watchdog_count(void)
-{
- NPCX_WDSDM = 0x5C;
- last_watchdog_touch = get_time();
-}
-
void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp)
{
int wd_cnt;
@@ -96,8 +75,7 @@ void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp)
* Touch watchdog to let UART have enough time
* to print panic info
*/
- touch_watchdog_count();
-
+ NPCX_WDSDM = 0x5C;
/* Print panic info */
watchdog_trace(excep_lr, excep_sp);
cflush();
@@ -134,7 +112,7 @@ void watchdog_reload(void)
#if 1 /* mark this for testing watchdog */
/* Touch watchdog & reset software counter */
- touch_watchdog_count();
+ NPCX_WDSDM = 0x5C;
#endif
/* Enable watchdog interrupt */
@@ -147,7 +125,7 @@ int watchdog_init(void)
#if SUPPORT_WDG
/* Touch watchdog before init if it is already running */
if (IS_BIT_SET(NPCX_T0CSR, NPCX_T0CSR_WD_RUN))
- touch_watchdog_count();
+ NPCX_WDSDM = 0x5C;
/* Keep prescaler ratio timer0 clock to 1:1024 */
NPCX_TWCP = 0x0A;