summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWei-Ning Huang <wnhuang@google.com>2017-07-24 14:34:55 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-07-27 04:22:42 -0700
commitb9c8dcb9f6b113d35f9da7a218df0507d4a492c2 (patch)
treee5ebec26f978df8689faf2ae12b9eeca51231bb0 /include
parent381fc5912c6b528c5dbc4509feeade07a1332694 (diff)
downloadchrome-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 'include')
-rw-r--r--include/config.h2
-rw-r--r--include/ec_commands.h17
-rw-r--r--include/flash.h10
3 files changed, 29 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h
index 7cfd089ade..7a0270f498 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1030,6 +1030,8 @@
#undef CONFIG_FLASH_ROW_SIZE
/* Allow deferred (async) flash erase */
#undef CONFIG_FLASH_DEFERRED_ERASE
+/* Flash must be selected for write/erase operations to succeed. */
+#undef CONFIG_FLASH_SELECT_REQUIRED
/* Base address of program memory */
#undef CONFIG_PROGRAM_MEMORY_BASE
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 68ba1df59f..811627776f 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1129,6 +1129,13 @@ struct __ec_align4 ec_response_flash_info {
/* EC flash erases bits to 0 instead of 1 */
#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
+/* Flash must be selected for read/write/erase operations to succeed. This may
+ * be necessary on a chip where write/erase can be corrupted by other board
+ * activity, or where the chip needs to enable some sort of programming voltage,
+ * or where the read/write/erase operations require cleanly suspending other
+ * chip functionality. */
+#define EC_FLASH_INFO_SELECT_REQUIRED (1 << 1)
+
/*
* Version 1 returns the same initial fields as version 0, with additional
* fields following.
@@ -1399,6 +1406,16 @@ struct __ec_align1 ec_response_flash_spi_info {
uint8_t sr1, sr2;
};
+
+/* Select flash during flash operations */
+#define EC_CMD_FLASH_SELECT 0x0019
+
+struct __ec_align4 ec_params_flash_select {
+ /* 1 to select flash, 0 to deselect flash */
+ uint8_t select;
+};
+
+
/*****************************************************************************/
/* PWM commands */
diff --git a/include/flash.h b/include/flash.h
index cdd8148d03..2637f9066c 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -342,4 +342,14 @@ void flash_lock_mapped_storage(int lock);
#else
static inline void flash_lock_mapped_storage(int lock) { };
#endif /* CONFIG_EXTERNAL_STORAGE */
+
+/**
+ * Select flash for performing flash operations. Board should implement this
+ * if some steps needed be done before flash operation can succeed.
+ *
+ * @param select 1 to select flash, 0 to deselect (disable).
+ * @return EC_RES_* status code.
+ */
+int board_flash_select(int select);
+
#endif /* __CROS_EC_FLASH_H */