diff options
Diffstat (limited to 'zephyr/drivers/cros_flash/cros_flash_npcx.c')
-rw-r--r-- | zephyr/drivers/cros_flash/cros_flash_npcx.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/zephyr/drivers/cros_flash/cros_flash_npcx.c b/zephyr/drivers/cros_flash/cros_flash_npcx.c index 4c6a6e5e3c..d6ecd950e1 100644 --- a/zephyr/drivers/cros_flash/cros_flash_npcx.c +++ b/zephyr/drivers/cros_flash/cros_flash_npcx.c @@ -34,7 +34,7 @@ struct cros_flash_npcx_data { static struct spi_config spi_cfg; -#define FLASH_DEV DT_NODELABEL(int_flash) +#define FLASH_DEV DT_CHOSEN(zephyr_flash_controller) #define SPI_CONTROLLER_DEV DT_NODELABEL(spi_fiu0) #define DRV_DATA(dev) ((struct cros_flash_npcx_data *)(dev)->data) @@ -435,15 +435,6 @@ static int cros_flash_npcx_init(const struct device *dev) return 0; } -/* TODO(b/205175314): Migrate cros-flash driver to Zephyr flash driver) */ -static int cros_flash_npcx_read(const struct device *dev, int offset, int size, - char *dst_data) -{ - struct cros_flash_npcx_data *data = DRV_DATA(dev); - - return flash_read(data->flash_dev, offset, dst_data, size); -} - static int cros_flash_npcx_write(const struct device *dev, int offset, int size, const char *src_data) { @@ -463,8 +454,14 @@ static int cros_flash_npcx_write(const struct device *dev, int offset, int size, return -EINVAL; } + /* Lock physical flash operations */ + crec_flash_lock_mapped_storage(1); + ret = flash_write(data->flash_dev, offset, src_data, size); + /* Unlock physical flash operations */ + crec_flash_lock_mapped_storage(0); + return ret; } @@ -491,8 +488,14 @@ static int cros_flash_npcx_erase(const struct device *dev, int offset, int size) return -EINVAL; } + /* Lock physical flash operations */ + crec_flash_lock_mapped_storage(1); + ret = flash_erase(data->flash_dev, offset, size); + /* Unlock physical flash operations */ + crec_flash_lock_mapped_storage(0); + return ret; } @@ -609,7 +612,6 @@ static int cros_flash_npcx_get_status(const struct device *dev, uint8_t *sr1, /* cros ec flash driver registration */ static const struct cros_flash_driver_api cros_flash_npcx_driver_api = { .init = cros_flash_npcx_init, - .physical_read = cros_flash_npcx_read, .physical_write = cros_flash_npcx_write, .physical_erase = cros_flash_npcx_erase, .physical_get_protect = cros_flash_npcx_get_protect, |