chromeec: add function to reboot on unexpected image
It's helpful to have a generic function that will tell the EC to reboot if the EC isn't running a specified image. Add that and implement google_chromeec_early_init() to utilize the new function still maintaing its semantics of if recvoery mode is enabled the EC should be running its RO image. There is a slight change in that no communication is done with the EC if not in recovery mode. BUG=chrome-os-partner:24133 BRANCH=rambi,squawks TEST=Built and boot with recovery request. Noted EC reboot. Change-Id: I22240f6a11231e39c33fd79796a52ec76b119397 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/182060 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: http://review.coreboot.org/5039 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
This commit is contained in:
parent
b376ea632f
commit
9f1a7cffab
|
@ -100,8 +100,7 @@ u32 google_chromeec_get_events_b(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __SMM__
|
#ifndef __SMM__
|
||||||
/* Check for recovery mode and ensure EC is in RO */
|
void google_chromeec_check_ec_image(int expected_type)
|
||||||
void google_chromeec_early_init(void)
|
|
||||||
{
|
{
|
||||||
struct chromeec_command cec_cmd;
|
struct chromeec_command cec_cmd;
|
||||||
struct ec_response_get_version cec_resp = {{0}};
|
struct ec_response_get_version cec_resp = {{0}};
|
||||||
|
@ -113,9 +112,7 @@ void google_chromeec_early_init(void)
|
||||||
cec_cmd.cmd_size_out = sizeof(cec_resp);
|
cec_cmd.cmd_size_out = sizeof(cec_resp);
|
||||||
google_chromeec_command(&cec_cmd);
|
google_chromeec_command(&cec_cmd);
|
||||||
|
|
||||||
if (cec_cmd.cmd_code ||
|
if (cec_cmd.cmd_code || cec_resp.current_image != expected_type) {
|
||||||
(recovery_mode_enabled() &&
|
|
||||||
(cec_resp.current_image != EC_IMAGE_RO))) {
|
|
||||||
struct ec_params_reboot_ec reboot_ec;
|
struct ec_params_reboot_ec reboot_ec;
|
||||||
/* Reboot the EC and make it come back in RO mode */
|
/* Reboot the EC and make it come back in RO mode */
|
||||||
reboot_ec.cmd = EC_REBOOT_COLD;
|
reboot_ec.cmd = EC_REBOOT_COLD;
|
||||||
|
@ -133,6 +130,15 @@ void google_chromeec_early_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for recovery mode and ensure EC is in RO */
|
||||||
|
void google_chromeec_early_init(void)
|
||||||
|
{
|
||||||
|
/* If in recovery ensure EC is running RO firmware. */
|
||||||
|
if (recovery_mode_enabled()) {
|
||||||
|
google_chromeec_check_ec_image(EC_IMAGE_RO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u16 google_chromeec_get_board_version(void)
|
u16 google_chromeec_get_board_version(void)
|
||||||
{
|
{
|
||||||
struct chromeec_command cmd;
|
struct chromeec_command cmd;
|
||||||
|
|
|
@ -36,7 +36,10 @@ int google_ec_running_ro(void);
|
||||||
void google_chromeec_init(void);
|
void google_chromeec_init(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* If recovery mode is enabled and EC is not running RO firmware reboot. */
|
||||||
void google_chromeec_early_init(void);
|
void google_chromeec_early_init(void);
|
||||||
|
/* Reboot if EC firmware is not expected type. */
|
||||||
|
void google_chromeec_check_ec_image(int expected_type);
|
||||||
uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size);
|
uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size);
|
||||||
u16 google_chromeec_get_board_version(void);
|
u16 google_chromeec_get_board_version(void);
|
||||||
u32 google_chromeec_get_events_b(void);
|
u32 google_chromeec_get_events_b(void);
|
||||||
|
|
Loading…
Reference in New Issue