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>
This commit is contained in:
Aseda Aboagye
2017-03-30 17:13:03 -07:00
committed by chrome-bot
parent f7f3f249ee
commit c76f9852c4

View File

@@ -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);