From b1bb8314bd852dea40bc7514486ce4e781e14f88 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 18 May 2012 15:56:30 -0700 Subject: Add LM4 support for hard reset (And add STM32 support for disabling interrupts before reset, which got missed before.) Signed-off-by: Randall Spangler BUG=chrome-os-partner:7470 TEST=from console, "reboot", then "reboot hard" Change-Id: Ib98792abc0c91a01e2230b419fc876052380655a --- chip/stm32/system.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'chip/stm32/system.c') diff --git a/chip/stm32/system.c b/chip/stm32/system.c index 8515a4bff3..1f7a66b5a7 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -8,35 +8,29 @@ #include "cpu.h" #include "registers.h" #include "system.h" +#include "task.h" #include "version.h" static void check_reset_cause(void) { - enum system_image_copy_t copy = system_get_image_copy(); enum system_reset_cause_t reset_cause = SYSTEM_RESET_UNKNOWN; uint32_t raw_cause = STM32_RCC_CSR; /* Clear the hardware reset cause by setting the RMVF bit */ STM32_RCC_CSR |= 1 << 24; - if (copy == SYSTEM_IMAGE_RW_A || copy == SYSTEM_IMAGE_RW_B) { - /* If we're in image A or B, the only way we can get there is - * via a warm reset. */ - reset_cause = SYSTEM_RESET_SOFT_WARM; - } else if (raw_cause & 0x60000000) { + if (raw_cause & 0x60000000) { /* IWDG pr WWDG */ reset_cause = SYSTEM_RESET_WATCHDOG; } else if (raw_cause & 0x10000000) { - reset_cause = SYSTEM_RESET_SOFT_COLD; + 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; - } else { - reset_cause = SYSTEM_RESET_UNKNOWN; } system_set_reset_cause(reset_cause); } @@ -87,19 +81,18 @@ int system_pre_init(void) } -int system_reset(int is_cold) +void system_reset(int is_hard) { - /* TODO: (crosbug.com/p/7470) support cold boot; this is a - warm boot. */ + /* Disable interrupts to avoid task swaps during reboot */ + interrupt_disable(); + + /* TODO: (crosbug.com/p/7470) support hard boot; this is a + * soft boot. */ CPU_NVIC_APINT = 0x05fa0004; /* Spin and wait for reboot; should never return */ - /* TODO: (crosbug.com/p/7471) should disable task swaps while - waiting */ while (1) ; - - return EC_ERROR_UNKNOWN; } -- cgit v1.2.1