diff options
author | Joel Kitching <kitching@google.com> | 2020-02-08 12:23:23 +0800 |
---|---|---|
committer | Joel Kitching <kitching@google.com> | 2020-02-17 08:08:19 +0000 |
commit | 81726663bcfe07234eb286ec5eddbff5e55be813 (patch) | |
tree | c07bb1a1272808b2d606c63ad5e219fa52c63bea /src/ec/google/chromeec | |
parent | e921911f1008169d236c4d2bd3e169a176cdf45c (diff) |
vboot: push clear recovery mode switch until BS_WRITE_TABLES
Serves two purposes:
(1) On some platforms, FSP initialization may cause a reboot.
Push clearing the recovery mode switch until after FSP code runs,
so that a manual recovery request (three-finger salute) will
function correctly under this condition.
(2) The recovery mode switch value is needed at BS_WRITE_TABLES
for adding an event to elog. (Previously this was done by
stashing the value in CBMEM_ID_EC_HOSTEVENT.)
BUG=b:124141368, b:35576380
TEST=make clean && make test-abuild
BRANCH=none
Change-Id: I30c02787c620b937e5a50a5ed94ac906e3112dad
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38779
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/ec/google/chromeec')
-rw-r--r-- | src/ec/google/chromeec/ec.c | 35 | ||||
-rw-r--r-- | src/ec/google/chromeec/switches.c | 30 |
2 files changed, 17 insertions, 48 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 4bf41ac119..1d351c5875 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -81,41 +81,6 @@ static const struct { }, }; -void log_recovery_mode_switch(void) -{ - uint64_t *events; - - if (cbmem_find(CBMEM_ID_EC_HOSTEVENT)) - return; - - events = cbmem_add(CBMEM_ID_EC_HOSTEVENT, sizeof(*events)); - if (!events) - return; - - *events = google_chromeec_get_events_b(); -} - -static void google_chromeec_elog_add_recovery_event(void *unused) -{ - uint64_t *events = cbmem_find(CBMEM_ID_EC_HOSTEVENT); - uint8_t event_byte = EC_HOST_EVENT_KEYBOARD_RECOVERY; - - if (!events) - return; - - if (!(*events & EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY))) - return; - - if (*events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)) - event_byte = EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT; - - elog_add_event_byte(ELOG_TYPE_EC_EVENT, event_byte); -} - -BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, - google_chromeec_elog_add_recovery_event, NULL); - uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size) { int csum; diff --git a/src/ec/google/chromeec/switches.c b/src/ec/google/chromeec/switches.c index 3fd38084f6..1eb2f2f6ef 100644 --- a/src/ec/google/chromeec/switches.c +++ b/src/ec/google/chromeec/switches.c @@ -14,8 +14,8 @@ */ #include <bootmode.h> -#include <cbmem.h> #include <ec/google/chromeec/ec.h> +#include <elog.h> #if CONFIG(EC_GOOGLE_CHROMEEC_LPC) int get_lid_switch(void) @@ -41,29 +41,33 @@ int get_recovery_mode_switch(void) int get_recovery_mode_retrain_switch(void) { - uint64_t events; - const uint64_t mask = - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT); - /* * Check if the EC has posted the keyboard recovery event with memory * retrain. */ - events = google_chromeec_get_events_b(); + return !!(google_chromeec_get_events_b() & + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)); +} - if (cbmem_possibly_online()) { - const uint64_t *events_save; +static void elog_add_recovery_mode_switch_event(void) +{ + uint64_t events = google_chromeec_get_events_b(); + uint8_t event_byte = EC_HOST_EVENT_KEYBOARD_RECOVERY; + + if (!(events & EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY))) + return; - events_save = cbmem_find(CBMEM_ID_EC_HOSTEVENT); - if (events_save != NULL) - events |= *events_save; - } + if (events & EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)) + event_byte = EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT; - return !!(events & mask); + elog_add_event_byte(ELOG_TYPE_EC_EVENT, event_byte); } int clear_recovery_mode_switch(void) { + /* Log elog event before clearing */ + elog_add_recovery_mode_switch_event(); + /* Clear all host event bits requesting recovery mode. */ return google_chromeec_clear_events_b( EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY) | |