From 85bb874c9c4cd48b9aad050a4232f5e8d6a7bbad Mon Sep 17 00:00:00 2001 From: You-Cheng Syu Date: Tue, 12 Mar 2019 13:02:18 +0800 Subject: google/chromeos: Support AP watchdog flag from Chrome EC After ChromiumOS CL:1293132 and CL:1295890, Chrome EC can store the flag telling if the last reboot was triggered by AP watchdog for some boards (e.g., Kukui). This CL adds a new function google_chromeec_get_ap_watchdog_flag(), which reads the AP watchdog flag from Chrome EC, and updates the tables of reset causes and reset flags. A new Kconfig option CHROMEOS_USE_EC_WATCHDOG_FLAG is added for elog_handle_watchdog_tombstone() to determine if watchdog reset was triggered by the AP watchdog flag from EC instead of the tombstone in AP. BUG=b:109900671,b:118654976 BRANCH=none TEST=test with https://review.coreboot.org/c/coreboot/+/31843 Change-Id: I7a970666a8c6da32ac1c6af8280e808fe7fc106d Signed-off-by: You-Cheng Syu Reviewed-on: https://review.coreboot.org/c/coreboot/+/31834 Tested-by: build bot (Jenkins) Reviewed-by: Hung-Te Lin --- src/ec/google/chromeec/ec.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'src/ec/google/chromeec/ec.c') diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index c34faaaade..1b0f7eee03 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -704,6 +704,29 @@ retry: return cec_cmd.cmd_code; } +static uint16_t google_chromeec_get_uptime_info( + struct ec_response_uptime_info *rsp) +{ + struct chromeec_command cmd = { + .cmd_code = EC_CMD_GET_UPTIME_INFO, + .cmd_version = 0, + .cmd_data_in = NULL, + .cmd_size_in = 0, + .cmd_data_out = rsp, + .cmd_size_out = sizeof(*rsp), + .cmd_dev_index = 0, + }; + google_chromeec_command(&cmd); + return cmd.cmd_code; +} + +bool google_chromeec_get_ap_watchdog_flag(void) +{ + struct ec_response_uptime_info rsp; + return (!google_chromeec_get_uptime_info(&rsp) && + (rsp.ec_reset_flags & EC_RESET_FLAG_AP_WATCHDOG)); +} + int google_chromeec_i2c_xfer(uint8_t chip, uint8_t addr, int alen, uint8_t *buffer, int len, int is_read) { @@ -944,6 +967,7 @@ static const char *reset_cause_to_str(uint16_t cause) "reset: debug warm reboot", "reset: at AP's request", "reset: during EC initialization", + "reset: AP watchdog", }; static const size_t shutdown_cause_begin = 1 << 15; @@ -997,22 +1021,13 @@ static void google_chromeec_log_uptimeinfo(void) "usb-resume", "rdd", "rbox", - "security" + "security", + "ap-watchdog", }; struct ec_response_uptime_info cmd_resp; int i, flag, flag_count; - struct chromeec_command get_uptime_cmd = { - .cmd_code = EC_CMD_GET_UPTIME_INFO, - .cmd_version = 0, - .cmd_data_in = NULL, - .cmd_size_in = 0, - .cmd_data_out = &cmd_resp, - .cmd_size_out = sizeof(cmd_resp), - .cmd_dev_index = 0, - }; - google_chromeec_command(&get_uptime_cmd); - if (get_uptime_cmd.cmd_code) { + if (google_chromeec_get_uptime_info(&cmd_resp)) { /* * Deliberately say nothing for EC's that don't support this * command -- cgit v1.2.3