ec/google/chromeec: Add EC driver support for software sync

Quite a few new functions added here in order to support the use-case
of performing EC software sync within coreboot.

Most of these functions are related to retrieving the EC's hash, and
writing a new image into the EC's flash.

BUG=b:112198832
BRANCH=none
TEST=With whole patch series, successfully performed EC software sync

Change-Id: I0d3c5184dbe96f04b92878f2c19c7875503a910a
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36207
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Tim Wawrzynczak
2019-10-21 13:09:09 -06:00
committed by Patrick Georgi
parent 5ce66da1b5
commit 1966b5c800
2 changed files with 432 additions and 20 deletions

View File

@@ -35,6 +35,7 @@ uint8_t google_chromeec_get_event(void);
/* Check if EC supports feature EC_FEATURE_UNIFIED_WAKE_MASKS */
bool google_chromeec_is_uhepi_supported(void);
int google_ec_running_ro(void);
enum ec_current_image google_chromeec_get_current_image(void);
void google_chromeec_init(void);
int google_chromeec_pd_get_amode(uint16_t svid);
int google_chromeec_wait_for_displayport(long timeout);
@@ -149,6 +150,13 @@ typedef int (*crosec_io_t)(size_t req_size, size_t resp_size, void *context);
int crosec_command_proto(struct chromeec_command *cec_command,
crosec_io_t crosec_io, void *context);
/**
* Performs light verification of the EC<->AP communcation channel.
*
* @return 0 on success, -1 on error
*/
int google_chromeec_hello(void);
/**
* Send a command to a CrOS EC
*
@@ -178,4 +186,117 @@ int google_chromeec_get_mkbp_event(struct ec_response_get_next_event *event);
/* Log host events to eventlog based on the mask provided. */
void google_chromeec_log_events(uint64_t mask);
/**
* Protect/un-protect EC flash regions.
*
* @param mask Set/clear the requested bits in 'flags'
* @param flags Flash protection flags
* @param resp Pointer to response structure
* @return 0 on success, -1 on error
*/
int google_chromeec_flash_protect(uint32_t mask, uint32_t flags,
struct ec_response_flash_protect *resp);
/**
* Calculate image hash for vboot.
*
* @param hash_type The hash types supported by the EC for vboot
* @param offset The offset to start hashing in flash
* @param resp Pointer to response structure
* @return 0 on success, -1 on error
*/
int google_chromeec_start_vboot_hash(enum ec_vboot_hash_type hash_type,
uint32_t offset,
struct ec_response_vboot_hash *resp);
/**
* Return the EC's vboot image hash.
*
* @param offset Get hash for flash region beginning here
* @param resp Pointer to response structure
* @return 0 on success, -1 on error
*
*/
int google_chromeec_get_vboot_hash(uint32_t offset,
struct ec_response_vboot_hash *resp);
/**
* Get offset and size of the specified EC flash region.
*
* @param region Which region of EC flash
* @param offset Gets filled with region's offset
* @param size Gets filled with region's size
* @return 0 on success, -1 on error
*/
int google_chromeec_flash_region_info(enum ec_flash_region region,
uint32_t *offset, uint32_t *size);
/**
* Erase a region of EC flash.
*
* @param offset Where to begin erasing
* @param size Size of area to erase
* @return 0 on success, -1 on error
*/
int google_chromeec_flash_erase(uint32_t region_offset, uint32_t region_size);
/**
* Return information about the entire flash.
*
* @param info Pointer to response structure
* @return 0 on success, -1 on error
*/
int google_chromeec_flash_info(struct ec_response_flash_info *info);
/**
* Write a block into EC flash.
*
* @param data Pointer to data to write to flash, prefixed by a
* struct ec_params_flash_write
* @param offset Offset to begin writing data
* @param size Number of bytes to be written to flash from data
* @return 0 on success, -1 on error
*/
int google_chromeec_flash_write_block(const uint8_t *data, uint32_t size);
/**
* Verify flash using EFS if available.
*
* @param region Which flash region to verify
* @return 0 on success, -1 on error
*/
int google_chromeec_efs_verify(enum ec_flash_region region);
/**
* Command EC to perform battery cutoff.
*
* @param flags Flags to pass to the EC
* @return 0 on success, -1 on error
*/
int google_chromeec_battery_cutoff(uint8_t flags);
/**
* Check if the EC is requesting the system to limit input power.
*
* @param limit_power If successful, limit_power is 1 if EC is requesting
* input power limits, otherwise 0.
* @return 0 on success, -1 on error
*/
int google_chromeec_read_limit_power_request(int *limit_power);
/**
* Get information about the protocol that the EC speaks.
*
* @param resp Filled with host command protocol information.
* @return 0 on success, -1 on error
*/
int google_chromeec_get_protocol_info(
struct ec_response_get_protocol_info *resp);
/**
* Get available versions of the specified command.
*
* @param command Command ID
* @param pmask Pointer to version mask
* @return 0 on success, -1 on error
*/
int google_chromeec_get_cmd_versions(int command, uint32_t *pmask);
#endif /* _EC_GOOGLE_CHROMEEC_EC_H */