Lines Matching full:flash
27 #include <zephyr/drivers/flash.h>
110 static int flash_mspi_atxp032_command_write(const struct device *flash, uint8_t cmd, uint32_t addr, in flash_mspi_atxp032_command_write() argument
114 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_command_write()
115 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_command_write()
142 static int flash_mspi_atxp032_command_read(const struct device *flash, uint8_t cmd, uint32_t addr, in flash_mspi_atxp032_command_read() argument
146 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_command_read()
147 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_command_read()
174 static void acquire(const struct device *flash) in acquire() argument
176 const struct flash_mspi_atxp032_config *cfg = flash->config; in acquire()
177 struct flash_mspi_atxp032_data *data = flash->data; in acquire()
194 static void release(const struct device *flash) in release() argument
196 const struct flash_mspi_atxp032_config *cfg = flash->config; in release()
197 struct flash_mspi_atxp032_data *data = flash->data; in release()
206 static int flash_mspi_atxp032_write_enable(const struct device *flash) in flash_mspi_atxp032_write_enable() argument
211 ret = flash_mspi_atxp032_command_write(flash, SPI_NOR_CMD_WREN, 0, 0, 0, NULL, 0); in flash_mspi_atxp032_write_enable()
216 static int flash_mspi_atxp032_write_disable(const struct device *flash) in flash_mspi_atxp032_write_disable() argument
221 ret = flash_mspi_atxp032_command_write(flash, SPI_NOR_CMD_WRDI, 0, 0, 0, NULL, 0); in flash_mspi_atxp032_write_disable()
226 static int flash_mspi_atxp032_reset(const struct device *flash) in flash_mspi_atxp032_reset() argument
230 ret = flash_mspi_atxp032_write_enable(flash); in flash_mspi_atxp032_reset()
236 ret = flash_mspi_atxp032_command_write(flash, 0xFF, 0, 0, 0, NULL, 0); in flash_mspi_atxp032_reset()
241 ret = flash_mspi_atxp032_write_disable(flash); in flash_mspi_atxp032_reset()
249 static int flash_mspi_atxp032_get_vendor_id(const struct device *flash, uint8_t *vendor_id) in flash_mspi_atxp032_get_vendor_id() argument
251 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_get_vendor_id()
261 ret = flash_mspi_atxp032_command_read(flash, SPI_NOR_CMD_RDID, 0, 0, 0, buffer, 11); in flash_mspi_atxp032_get_vendor_id()
269 static int flash_mspi_atxp032_unprotect_sector(const struct device *flash, off_t addr) in flash_mspi_atxp032_unprotect_sector() argument
275 ret = flash_mspi_atxp032_command_write(flash, 0x39, addr, 4, 0, NULL, 0); in flash_mspi_atxp032_unprotect_sector()
280 static int flash_mspi_atxp032_erase_sector(const struct device *flash, off_t addr) in flash_mspi_atxp032_erase_sector() argument
286 ret = flash_mspi_atxp032_command_write(flash, SPI_NOR_CMD_SE, addr, 4, 0, NULL, 0); in flash_mspi_atxp032_erase_sector()
291 static int flash_mspi_atxp032_erase_block(const struct device *flash, off_t addr) in flash_mspi_atxp032_erase_block() argument
297 ret = flash_mspi_atxp032_command_write(flash, SPI_NOR_CMD_BE, addr, 4, 0, NULL, 0); in flash_mspi_atxp032_erase_block()
302 static int flash_mspi_atxp032_erase_chip(const struct device *flash) in flash_mspi_atxp032_erase_chip() argument
308 ret = flash_mspi_atxp032_command_write(flash, SPI_NOR_CMD_CE, 0, 0, 0, NULL, 0); in flash_mspi_atxp032_erase_chip()
313 static int flash_mspi_atxp032_page_program(const struct device *flash, off_t offset, void *wdata, in flash_mspi_atxp032_page_program() argument
316 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_page_program()
317 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_page_program()
347 static int flash_mspi_atxp032_busy_wait(const struct device *flash) in flash_mspi_atxp032_busy_wait() argument
349 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_busy_wait()
350 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_busy_wait()
371 ret = flash_mspi_atxp032_command_read(flash, SPI_NOR_CMD_RDSR, 0, 0, rx_dummy, in flash_mspi_atxp032_busy_wait()
392 static int flash_mspi_atxp032_read(const struct device *flash, off_t offset, void *rdata, in flash_mspi_atxp032_read() argument
395 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_read()
396 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_read()
400 acquire(flash); in flash_mspi_atxp032_read()
427 release(flash); in flash_mspi_atxp032_read()
432 static int flash_mspi_atxp032_write(const struct device *flash, off_t offset, const void *wdata, in flash_mspi_atxp032_write() argument
439 acquire(flash); in flash_mspi_atxp032_write()
448 ret = flash_mspi_atxp032_write_enable(flash); in flash_mspi_atxp032_write()
453 ret = flash_mspi_atxp032_page_program(flash, offset, src, i); in flash_mspi_atxp032_write()
458 ret = flash_mspi_atxp032_busy_wait(flash); in flash_mspi_atxp032_write()
468 ret = flash_mspi_atxp032_write_disable(flash); in flash_mspi_atxp032_write()
473 release(flash); in flash_mspi_atxp032_write()
478 static int flash_mspi_atxp032_erase(const struct device *flash, off_t offset, size_t size) in flash_mspi_atxp032_erase() argument
480 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_erase()
487 acquire(flash); in flash_mspi_atxp032_erase()
500 ret = flash_mspi_atxp032_write_enable(flash); in flash_mspi_atxp032_erase()
505 ret = flash_mspi_atxp032_erase_chip(flash); in flash_mspi_atxp032_erase()
510 ret = flash_mspi_atxp032_busy_wait(flash); in flash_mspi_atxp032_erase()
517 ret = flash_mspi_atxp032_write_enable(flash); in flash_mspi_atxp032_erase()
522 ret = flash_mspi_atxp032_unprotect_sector(flash, offset); in flash_mspi_atxp032_erase()
527 ret = flash_mspi_atxp032_write_enable(flash); in flash_mspi_atxp032_erase()
532 ret = flash_mspi_atxp032_erase_block(flash, offset); in flash_mspi_atxp032_erase()
537 ret = flash_mspi_atxp032_busy_wait(flash); in flash_mspi_atxp032_erase()
546 ret = flash_mspi_atxp032_write_enable(flash); in flash_mspi_atxp032_erase()
551 ret = flash_mspi_atxp032_unprotect_sector(flash, offset); in flash_mspi_atxp032_erase()
556 ret = flash_mspi_atxp032_write_enable(flash); in flash_mspi_atxp032_erase()
561 ret = flash_mspi_atxp032_erase_sector(flash, offset); in flash_mspi_atxp032_erase()
566 ret = flash_mspi_atxp032_busy_wait(flash); in flash_mspi_atxp032_erase()
575 release(flash); in flash_mspi_atxp032_erase()
580 static const struct flash_parameters *flash_mspi_atxp032_get_parameters(const struct device *flash) in flash_mspi_atxp032_get_parameters() argument
582 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_get_parameters()
588 static void flash_mspi_atxp032_pages_layout(const struct device *flash, in flash_mspi_atxp032_pages_layout() argument
592 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_pages_layout()
599 static int flash_mspi_atxp032_init(const struct device *flash) in flash_mspi_atxp032_init() argument
601 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_init()
602 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_init()
627 if (flash_mspi_atxp032_reset(flash)) { in flash_mspi_atxp032_init()
628 LOG_ERR("Could not reset Flash/%u", __LINE__); in flash_mspi_atxp032_init()
632 if (flash_mspi_atxp032_get_vendor_id(flash, &vendor_id)) { in flash_mspi_atxp032_init()
646 if (flash_mspi_atxp032_write_enable(flash)) { in flash_mspi_atxp032_init()
650 if (flash_mspi_atxp032_command_write(flash, 0x71, 0x3, 1, 0, (uint8_t *)&CRB3, 1)) { in flash_mspi_atxp032_init()
664 if (flash_mspi_atxp032_write_enable(flash)) { in flash_mspi_atxp032_init()
667 if (flash_mspi_atxp032_command_write(flash, cmd, 0, 0, 0, NULL, 0)) { in flash_mspi_atxp032_init()
700 release(flash); in flash_mspi_atxp032_init()
706 static int flash_mspi_atxp032_read_sfdp(const struct device *flash, off_t addr, void *rdata, in flash_mspi_atxp032_read_sfdp() argument
709 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_read_sfdp()
710 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_read_sfdp()
713 acquire(flash); in flash_mspi_atxp032_read_sfdp()
741 release(flash); in flash_mspi_atxp032_read_sfdp()
744 static int flash_mspi_atxp032_read_jedec_id(const struct device *flash, uint8_t *id) in flash_mspi_atxp032_read_jedec_id() argument
746 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_read_jedec_id()
754 static int flash_mspi_atxp032_pm_action(const struct device *flash, enum pm_device_action action) in flash_mspi_atxp032_pm_action() argument
758 acquire(flash); in flash_mspi_atxp032_pm_action()
760 release(flash); in flash_mspi_atxp032_pm_action()
764 acquire(flash); in flash_mspi_atxp032_pm_action()
766 release(flash); in flash_mspi_atxp032_pm_action()
777 static DEVICE_API(flash, flash_mspi_atxp032_api) = {