diff options
author | Aaron Durbin <adurbin@chromium.org> | 2017-05-04 12:32:52 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2017-05-05 23:23:58 +0200 |
commit | e68d22fbbc8bd1e2644e3fb75ec76b356502604a (patch) | |
tree | 904b963756776781554da50b36f33a6705188d8e /src | |
parent | 44526cd1fc06f1a037fc74053db6ab6c7866d20e (diff) | |
download | coreboot-e68d22fbbc8bd1e2644e3fb75ec76b356502604a.tar.xz |
ec/google/chromeec: provide reboot function
Provide a common function to issue reboot commands to the EC.
Expose that function for external use and use it internal to
the module.
BUG=b:35580805
Change-Id: I1458bd7119b0df626a043ff3806c15ffb5446c9a
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/19573
Reviewed-by: Furquan Shaikh <furquan@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/ec/google/chromeec/ec.c | 53 | ||||
-rw-r--r-- | src/ec/google/chromeec/ec.h | 4 |
2 files changed, 27 insertions, 30 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 3c90b9229c..e62241003d 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -202,6 +202,26 @@ int rtc_get(struct rtc_time *time) } #endif +int google_chromeec_reboot(int dev_idx, enum ec_reboot_cmd type, uint8_t flags) +{ + struct ec_params_reboot_ec reboot_ec = { + .cmd = type, + .flags = flags, + }; + struct ec_response_get_version cec_resp = { }; + struct chromeec_command cec_cmd = { + .cmd_code = EC_CMD_REBOOT_EC, + .cmd_version = 0, + .cmd_data_in = &reboot_ec, + .cmd_data_out = &cec_resp, + .cmd_size_in = sizeof(reboot_ec), + .cmd_size_out = 0, /* ignore response, if any */ + .cmd_dev_index = dev_idx, + }; + + return google_chromeec_command(&cec_cmd); +} + #ifndef __SMM__ #ifdef __PRE_RAM__ void google_chromeec_check_ec_image(int expected_type) @@ -218,22 +238,13 @@ void google_chromeec_check_ec_image(int expected_type) google_chromeec_command(&cec_cmd); if (cec_cmd.cmd_code || cec_resp.current_image != expected_type) { - struct ec_params_reboot_ec reboot_ec; /* Reboot the EC and make it come back in RO mode */ - reboot_ec.cmd = EC_REBOOT_COLD; - reboot_ec.flags = 0; - cec_cmd.cmd_code = EC_CMD_REBOOT_EC; - cec_cmd.cmd_version = 0; - cec_cmd.cmd_data_in = &reboot_ec; - cec_cmd.cmd_size_in = sizeof(reboot_ec); - cec_cmd.cmd_size_out = 0; /* ignore response, if any */ - cec_cmd.cmd_dev_index = 0; printk(BIOS_DEBUG, "Rebooting with EC in RO mode:\n"); post_code(0); /* clear current post code */ /* Let the platform prepare for the EC taking out the system power. */ if (IS_ENABLED(CONFIG_VBOOT)) vboot_platform_prepare_reboot(); - google_chromeec_command(&cec_cmd); + google_chromeec_reboot(0, EC_REBOOT_COLD, 0); udelay(1000); hard_reset(); halt(); @@ -268,18 +279,9 @@ void google_chromeec_check_pd_image(int expected_type) google_chromeec_command(&cec_cmd); if (cec_cmd.cmd_code || cec_resp.current_image != expected_type) { - struct ec_params_reboot_ec reboot_ec; /* Reboot the PD and make it come back in RO mode */ - reboot_ec.cmd = EC_REBOOT_COLD; - reboot_ec.flags = 0; - cec_cmd.cmd_code = EC_CMD_REBOOT_EC; - cec_cmd.cmd_version = 0; - cec_cmd.cmd_data_in = &reboot_ec; - cec_cmd.cmd_size_in = sizeof(reboot_ec); - cec_cmd.cmd_size_out = 0; /* ignore response, if any */ - cec_cmd.cmd_dev_index = 1; /* PD */ printk(BIOS_DEBUG, "Rebooting PD to RO mode\n"); - google_chromeec_command(&cec_cmd); + google_chromeec_reboot(1 /* PD */, EC_REBOOT_COLD, 0); udelay(1000); } } @@ -578,19 +580,10 @@ void google_chromeec_init(void) if (cec_cmd.cmd_code || (vboot_recovery_mode_enabled() && (cec_resp.current_image != EC_IMAGE_RO))) { - struct ec_params_reboot_ec reboot_ec; /* Reboot the EC and make it come back in RO mode */ - reboot_ec.cmd = EC_REBOOT_COLD; - reboot_ec.flags = 0; - cec_cmd.cmd_code = EC_CMD_REBOOT_EC; - cec_cmd.cmd_version = 0; - cec_cmd.cmd_data_in = &reboot_ec; - cec_cmd.cmd_size_in = sizeof(reboot_ec); - cec_cmd.cmd_size_out = 0; /* ignore response, if any */ - cec_cmd.cmd_dev_index = 0; printk(BIOS_DEBUG, "Rebooting with EC in RO mode:\n"); post_code(0); /* clear current post code */ - google_chromeec_command(&cec_cmd); + google_chromeec_reboot(0, EC_REBOOT_COLD, 0); udelay(1000); hard_reset(); halt(); diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 71cea7ea8a..4a45f7f4ab 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -57,6 +57,10 @@ int google_chromeec_vstore_info(uint32_t *locked); int google_chromeec_vstore_read(int slot, uint8_t *data); int google_chromeec_vstore_write(int slot, uint8_t *data, size_t size); +/* Issue reboot command to EC with specified type and flags. Returns 0 on + success, < 0 otherwise. */ +int google_chromeec_reboot(int dev_idx, enum ec_reboot_cmd type, uint8_t flags); + /* MEC uses 0x800/0x804 as register/index pair, thus an 8-byte resource. */ #define MEC_EMI_BASE 0x800 #define MEC_EMI_SIZE 8 |