summaryrefslogtreecommitdiff
path: root/chip/stm32/system.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-13 14:24:33 -0700
committerRandall Spangler <rspangler@chromium.org>2012-07-16 10:17:09 -0700
commit0e933d1ce987cb68e4c5682508aba47f925613ae (patch)
treeae26d125c16a10073a4936318ffb90a7ccb582bb /chip/stm32/system.c
parent1dc7241e3a32635b3e3563fd5ddae482478dd92c (diff)
downloadchrome-ec-0e933d1ce987cb68e4c5682508aba47f925613ae.tar.gz
Refactor reset reasons
Reasons are really bitflags, not a single reason. This will make it easier to implement flash protection on LM4, where hibernate is a subset of power-on reasons. Also added some additional flags we pass in a hibernate register so... 1) We don't recognize spurious RTC wake reasons 2) Hard reset via system_reset(1) is detected as a hard reset, not a RTC wake BUG=chrome-os-partner:11368 TEST=manual 1. Keyboard reset = power-on reset-pin 2. Pull battery = power-on 3. reboot = soft 4. reboot hard = power-on rtc-alarm 5. hibernate 10 then push power button = power-on wake-pin 6. reboot 3 sec later = soft 7. hibernate 1 = power-on rtc-alarm Change-Id: Icbbdbcf6dfd13c8a6a4f80a23f64cebebbfba26e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27417
Diffstat (limited to 'chip/stm32/system.c')
-rw-r--r--chip/stm32/system.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/chip/stm32/system.c b/chip/stm32/system.c
index 1f7a66b5a7..8f72fb04b5 100644
--- a/chip/stm32/system.c
+++ b/chip/stm32/system.c
@@ -14,25 +14,30 @@
static void check_reset_cause(void)
{
- enum system_reset_cause_t reset_cause = SYSTEM_RESET_UNKNOWN;
+ uint32_t flags = 0;
uint32_t raw_cause = STM32_RCC_CSR;
/* Clear the hardware reset cause by setting the RMVF bit */
STM32_RCC_CSR |= 1 << 24;
if (raw_cause & 0x60000000) {
- /* IWDG pr WWDG */
- reset_cause = SYSTEM_RESET_WATCHDOG;
- } else if (raw_cause & 0x10000000) {
- reset_cause = SYSTEM_RESET_SOFT;
- } else if (raw_cause & 0x08000000) {
- reset_cause = SYSTEM_RESET_POWER_ON;
- } else if (raw_cause & 0x04000000) {
- reset_cause = SYSTEM_RESET_RESET_PIN;
- } else if (raw_cause & 0xFE000000) {
- reset_cause = SYSTEM_RESET_OTHER;
+ /* IWDG or WWDG */
+ flags |= RESET_FLAG_WATCHDOG;
}
- system_set_reset_cause(reset_cause);
+
+ if (raw_cause & 0x10000000)
+ flags |= RESET_FLAG_SOFT;
+
+ if (raw_cause & 0x08000000)
+ flags |= RESET_FLAG_POWER_ON;
+
+ if (raw_cause & 0x04000000)
+ flags |= RESET_FLAG_RESET_PIN;
+
+ if (!flags && (raw_cause & 0xfe000000))
+ flags |= RESET_FLAG_OTHER;
+
+ system_set_reset_flags(flags);
}