summaryrefslogtreecommitdiff
path: root/common/main.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-16 14:19:59 -0700
committerGerrit <chrome-bot@google.com>2012-07-16 17:49:10 -0700
commitacf6f963a160f045d6b4c58f0ee3e249ded76b4e (patch)
tree1c724e7480104f9fa1284f6a3f013cbd44501c12 /common/main.c
parenta42edb86c59cbc145eb99bd5b65bbd1f5567320e (diff)
downloadchrome-ec-acf6f963a160f045d6b4c58f0ee3e249ded76b4e.tar.gz
Flash pre-init reboots if it needs to clear protection registers
BUG=chrome-os-partner:11171 TEST=manual 1. Clear some of the writable-bits in the flash registers > ww 0x400fe40c 0xffff1234 write 0x400fe40c = 0xffff1234 > rw 0x400fe40c read 0x400fe40c = 0xffff1234 2. Reset using power+refresh 3. Register should be clear again > rw 0x400fe40c read 0x400fe40c = 0xffffffff 4. Sysinfo should indicate reset-pin reason AND hard-reset reason > sysinfo Reset flags: 0x0000000a (reset-pin power-on) 5. Reset using power+refresh 6. Sysinfo should indicate reset-pin reason only > sysinfo Reset flags: 0x00000002 (reset-pin) 7. Clear writable-bits again > ww 0x400fe40c 0xffff1234 write 0x400fe40c = 0xffff1234 8. Jump to another image. This should NOT trigger a hard reset. > sysjump A > sysinfo Reset flags: 0x00000402 (reset-pin sysjump) Change-Id: Ie1d6af2acc68217bb82faae464798ee85d63d1ea Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27540 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/main.c')
-rw-r--r--common/main.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/common/main.c b/common/main.c
index febebb2a0b..682ecf1e5c 100644
--- a/common/main.c
+++ b/common/main.c
@@ -6,8 +6,8 @@
*/
#include "clock.h"
+#include "common.h"
#include "cpu.h"
-#include "config.h"
#include "eeprom.h"
#include "eoption.h"
#include "flash.h"
@@ -44,18 +44,6 @@ int main(void)
*/
task_pre_init();
-#ifdef CONFIG_FLASH
- flash_pre_init();
-#endif
-
-#ifdef CONFIG_VBOOT
- /*
- * Verified boot pre-init. This write-protects flash if necessary.
- * Flash and GPIOs must be initialized first.
- */
- vboot_pre_init();
-#endif
-
/*
* Initialize the system module. This enables the hibernate clock
* source we need to calibrate the internal oscillator.
@@ -63,6 +51,14 @@ int main(void)
system_pre_init();
system_common_pre_init();
+#ifdef CONFIG_FLASH
+ /*
+ * Initialize flash and apply write protecte if necessary. Requires
+ * the reset flags calculated by system initialization.
+ */
+ flash_pre_init();
+#endif
+
/* Set the CPU clocks / PLLs. System is now running at full speed. */
clock_init();