summaryrefslogtreecommitdiff
path: root/src/ec
diff options
context:
space:
mode:
Diffstat (limited to 'src/ec')
-rw-r--r--src/ec/google/chromeec/ec.c35
-rw-r--r--src/ec/google/chromeec/switches.c30
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) |