summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic (Chun-Ju) Yang <victoryang@chromium.org>2013-11-28 12:08:40 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-12-02 04:54:18 +0000
commit3f02192460f5c647f6539de161e36d5b4392567b (patch)
tree179812c57fcd6bb2d433035582cb297dc4253c3d
parent0e0bc8bbbdfd29e6e6e4efc43b60e0ac42e1dd77 (diff)
downloadchrome-ec-3f02192460f5c647f6539de161e36d5b4392567b.tar.gz
mec1322: Check/save reset cause
So far we can only reliably sense a watchdog reset, but this saving/checking reset cause will at least make 'ap-off' flag work. BUG=chrome-os-partner:24107 TEST='waitms 2000' and see reset cause = 'watchdog' TEST='reboot ap-off' and see reset cause includes 'ap-off' TEST='reboot preserve' and see previous reset cause is preserved. BRANCH=None Change-Id: Id47a72d615489c9d9cd0b8761cfa699f08c724df Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/178277 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/mec1322/system.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c
index 62c08e028d..7425ccc30f 100644
--- a/chip/mec1322/system.c
+++ b/chip/mec1322/system.c
@@ -22,7 +22,25 @@ enum hibdata_index {
HIBDATA_INDEX_SAVED_RESET_FLAGS /* Saved reset flags */
};
+static void check_reset_cause(void)
+{
+ uint32_t status = MEC1322_VBAT_STS;
+ uint32_t flags = 0;
+
+ /* Clear the reset causes now that we've read them */
+ MEC1322_VBAT_STS |= status;
+
+ if (status & (1 << 7))
+ flags |= RESET_FLAG_POWER_ON;
+
+ if (status & (1 << 5))
+ flags |= RESET_FLAG_WATCHDOG;
+ flags |= MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS);
+ MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = 0;
+
+ system_set_reset_flags(flags);
+}
void system_pre_init(void)
{
@@ -31,13 +49,33 @@ void system_pre_init(void)
/* Deassert nSIO_RESET */
MEC1322_PCR_PWR_RST_CTL &= ~(1 << 0);
+
+ check_reset_cause();
}
void system_reset(int flags)
{
+ uint32_t save_flags = 0;
+
+ /* Disable interrupts to avoid task swaps during reboot */
+ interrupt_disable();
+
+ /* Save current reset reasons if necessary */
+ if (flags & SYSTEM_RESET_PRESERVE_FLAGS)
+ save_flags = system_get_reset_flags() | RESET_FLAG_PRESERVED;
+
+ if (flags & SYSTEM_RESET_LEAVE_AP_OFF)
+ save_flags |= RESET_FLAG_AP_OFF;
+
+ MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = save_flags;
+
/* Trigger watchdog in 1ms */
MEC1322_WDG_LOAD = 1;
MEC1322_WDG_CTL |= 1;
+
+ /* Spin and wait for reboot; should never return */
+ while (1)
+ ;
}
const char *system_get_chip_vendor(void)