diff options
author | Wei-Ning Huang <wnhuang@google.com> | 2017-07-24 14:34:55 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-27 04:22:42 -0700 |
commit | b9c8dcb9f6b113d35f9da7a218df0507d4a492c2 (patch) | |
tree | e5ebec26f978df8689faf2ae12b9eeca51231bb0 /common/flash.c | |
parent | 381fc5912c6b528c5dbc4509feeade07a1332694 (diff) | |
download | chrome-ec-b9c8dcb9f6b113d35f9da7a218df0507d4a492c2.tar.gz |
flash: add flash selection support
Some chips require special operations before flash can be accessed
(read, write, erase), without it the flash operations could be
corrupted. The chip that requires this should enable the
CONFIG_FLASH_SELECT_REQUIRED config, which exposes
EC_FLASH_INFO_SELECT_REQUIRED in flashinfo flags. Before any flash
operations is executed on the chip, EC_CMD_FLASH_SELECT should be issued
to notify the chip to prepare for the flash operations.
BRANCH=none
BUG=b:63685022
TEST=with depended CLs, touchpad interrupt should be disabled when
flashrom is in progress.
CQ-DEPEND=CL:*416548
Change-Id: I96455adbe739d5f924edf382a2752404a7c5ad04
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/582374
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Diffstat (limited to 'common/flash.c')
-rw-r--r-- | common/flash.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/common/flash.c b/common/flash.c index 99dea9ee98..976c402b24 100644 --- a/common/flash.c +++ b/common/flash.c @@ -1092,6 +1092,9 @@ static int flash_command_get_info(struct host_cmd_handler_args *args) #else r_2->flags = 0; #endif +#ifdef CONFIG_FLASH_SELECT_REQUIRED + r_2->flags |= EC_FLASH_INFO_SELECT_REQUIRED; +#endif r_2->write_ideal_size = ideal_size; r_2->num_banks_total = banks_size; r_2->num_banks_desc = MIN(banks_size, p_2->num_banks_desc); @@ -1118,6 +1121,9 @@ static int flash_command_get_info(struct host_cmd_handler_args *args) #if (CONFIG_FLASH_ERASED_VALUE32 == 0) r_1->flags |= EC_FLASH_INFO_ERASE_TO_0; #endif +#ifdef CONFIG_FLASH_SELECT_REQUIRED + r_1->flags |= EC_FLASH_INFO_SELECT_REQUIRED; +#endif } return EC_RES_SUCCESS; #endif /* CONFIG_FLASH_MULTIPLE_REGION */ @@ -1332,3 +1338,18 @@ static int flash_command_region_info(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_FLASH_REGION_INFO, flash_command_region_info, EC_VER_MASK(EC_VER_FLASH_REGION_INFO)); + + +#ifdef CONFIG_FLASH_SELECT_REQUIRED + +static int flash_command_select(struct host_cmd_handler_args *args) +{ + const struct ec_params_flash_select *p = args->params; + + return board_flash_select(p->select); +} +DECLARE_HOST_COMMAND(EC_CMD_FLASH_SELECT, + flash_command_select, + EC_VER_MASK(0)); + +#endif /* CONFIG_FLASH_SELECT_REQUIRED */ |