summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-03-30 17:13:03 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-03-31 12:59:16 -0700
commitc76f9852c4e62d134f57f134c30d73289e4a72a7 (patch)
tree1debc9b6c3099782be42d54d9b2b9ae5f7722000
parentf7f3f249ee14785e0f5164c290521dd7f331859c (diff)
downloadchrome-ec-c76f9852c4e62d134f57f134c30d73289e4a72a7.tar.gz
cr50: wp: Only use RAM val on wake from hibernate.
When Cr50 resumes from hibernate, it should use the WP state that was stored in the long life scratch registers. All other boots should simply follow the state of the BATT_PRES_L pin. BUG=b:36659750 BRANCH=master,cr50 TEST=Power on Cr50 via battery, verify that WP_L remains asserted. Change-Id: I516d43b6540d7c543e7629f8709ce63515bb7f76 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/464258 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--board/cr50/wp.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/board/cr50/wp.c b/board/cr50/wp.c
index c381f81b3b..63ca909c9b 100644
--- a/board/cr50/wp.c
+++ b/board/cr50/wp.c
@@ -207,14 +207,15 @@ static void init_console_lock_and_wp(void)
uint8_t key;
const struct tuple *t;
uint8_t lock_state;
+ uint32_t reset_flags;
+ reset_flags = system_get_reset_flags();
/*
* On an unexpected reboot or a system rollback reset the console lock
* and write protect states.
*/
if (system_rollback_detected() ||
- !(system_get_reset_flags() &
- (RESET_FLAG_HIBERNATE | RESET_FLAG_POWER_ON))) {
+ !(reset_flags & (RESET_FLAG_HIBERNATE | RESET_FLAG_POWER_ON))) {
/* Reset the console lock to the default value */
CPRINTS("Setting console lock to default.");
set_console_lock_state(console_restricted_state);
@@ -238,10 +239,15 @@ static void init_console_lock_and_wp(void)
set_console_lock_state(lock_state);
}
- if (GREG32(PMU, LONG_LIFE_SCRATCH1) & BOARD_WP_ASSERTED)
- set_wp_state(1);
- else
- set_wp_state(0);
+ if (reset_flags & RESET_FLAG_HIBERNATE) {
+ if (GREG32(PMU, LONG_LIFE_SCRATCH1) & BOARD_WP_ASSERTED)
+ set_wp_state(1);
+ else
+ set_wp_state(0);
+ } else if (reset_flags & RESET_FLAG_POWER_ON) {
+ /* Use BATT_PRES_L as the source for write protect. */
+ set_wp_state(!gpio_get_level(GPIO_BATT_PRES_L));
+ }
}
/* This must run after initializing the NVMem partitions. */
DECLARE_HOOK(HOOK_INIT, init_console_lock_and_wp, HOOK_PRIO_DEFAULT+1);