summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Barnaś <mb@semihalf.com>2021-09-27 19:04:23 +0200
committerCommit Bot <commit-bot@chromium.org>2021-10-01 18:15:47 +0000
commit603cc1060149b7e5bc90b9e73ad8687b082f387b (patch)
tree2e8bbb98dc35cee678f9686f332d6bb11f400c2c
parent4c30c4c5b79cc5a2bb3748b991b7eb2c275abff7 (diff)
downloadchrome-ec-603cc1060149b7e5bc90b9e73ad8687b082f387b.tar.gz
zephyr: npcx: add get_jedec_id and get_status functions
This commit implements get_jedec_id and get_status functions for npcx. BRANCH=main BUG=b:190224781 TEST=Execute flashchip command in EC console on eg. lazor. Values should be the same as in CrOS version. Change-Id: Ie1ad596b793492dcdb72b1b99c8b7623776490f3 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3187910 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/drivers/cros_flash/cros_flash_npcx.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/zephyr/drivers/cros_flash/cros_flash_npcx.c b/zephyr/drivers/cros_flash/cros_flash_npcx.c
index bb1bd12d89..cd9b491fe3 100644
--- a/zephyr/drivers/cros_flash/cros_flash_npcx.c
+++ b/zephyr/drivers/cros_flash/cros_flash_npcx.c
@@ -774,6 +774,38 @@ static int cros_flash_npcx_protect_now(const struct device *dev, int all)
return EC_SUCCESS;
}
+static int cros_flash_npcx_get_jedec_id(const struct device *dev,
+ uint8_t *manufacturer,
+ uint16_t *device)
+{
+ struct fiu_reg *const inst = HAL_INSTANCE(dev);
+
+ /* Lock physical flash operations */
+ crec_flash_lock_mapped_storage(1);
+
+ /* Read manufacturer and device ID */
+ cros_flash_npcx_exec_cmd(dev,
+ SPI_NOR_CMD_RDID,
+ UMA_CODE_CMD_RD_BYTE(3));
+
+ *manufacturer = inst->UMA_DB0;
+ *device = (inst->UMA_DB1 << 8) | inst->UMA_DB2;
+
+ /* Unlock physical flash operations */
+ crec_flash_lock_mapped_storage(0);
+
+ return EC_SUCCESS;
+}
+
+static int cros_flash_npcx_get_status(const struct device *dev,
+ uint8_t *sr1, uint8_t *sr2)
+{
+ *sr1 = flash_get_status1(dev);
+ *sr2 = flash_get_status2(dev);
+
+ return EC_SUCCESS;
+}
+
/* cros ec flash driver registration */
static const struct cros_flash_driver_api cros_flash_npcx_driver_api = {
.init = cros_flash_npcx_init,
@@ -784,6 +816,8 @@ static const struct cros_flash_driver_api cros_flash_npcx_driver_api = {
.physical_get_protect_flags = cros_flash_npcx_get_protect_flags,
.physical_protect_at_boot = cros_flash_npcx_protect_at_boot,
.physical_protect_now = cros_flash_npcx_protect_now,
+ .physical_get_jedec_id = cros_flash_npcx_get_jedec_id,
+ .physical_get_status = cros_flash_npcx_get_status,
};
static int flash_npcx_init(const struct device *dev)