Skip to content

Commit 09ca52f

Browse files
committed
drivers: flash: Read/write arbitary commands via ex_op API
Allow users to write flash-vendor-specific drivers with the commands particular to their flash part using the existing Zephyr flash drivers. Signed-off-by: Utsav Munendra <[email protected]>
1 parent 3af17bf commit 09ca52f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

include/zephyr/drivers/flash.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,54 @@ enum flash_ex_op_types {
697697
* Reset flash device.
698698
*/
699699
FLASH_EX_OP_RESET = 0,
700+
/*
701+
* Issue a command to read from flash device.
702+
*/
703+
FLASH_EX_OP_CMD_READ = 1,
704+
/*
705+
* Issue a command to write to flash device.
706+
*/
707+
FLASH_EX_OP_CMD_WRITE = 2,
708+
};
709+
710+
/**
711+
* @brief Input for FLASH_EX_OP_CMD_READ extra flash operations
712+
*/
713+
struct flash_ex_op_cmd_read_in {
714+
/* register or command to read */
715+
uint8_t cmd;
716+
/* buffer to write the read data to */
717+
uint8_t *read_buffer;
718+
/* length of above buffer */
719+
size_t buffer_len;
720+
};
721+
722+
/**
723+
* @brief Output from FLASH_EX_OP_CMD_READ extra flash operations
724+
*/
725+
struct flash_ex_op_cmd_read_out {
726+
/* bytes actually read and stored in the input buffer */
727+
size_t read_len;
728+
};
729+
730+
/**
731+
* @brief Input for FLASH_EX_OP_CMD_WRITE extra flash operations
732+
*/
733+
struct flash_ex_op_cmd_write_in {
734+
/* register or command to write */
735+
uint8_t cmd;
736+
/* buffer with the data to write */
737+
uint8_t *write_buffer;
738+
/* length of above buffer */
739+
size_t buffer_len;
740+
};
741+
742+
/**
743+
* @brief Output from FLASH_EX_OP_CMD_WRITE extra flash operations
744+
*/
745+
struct flash_ex_op_cmd_write_out {
746+
/* bytes actually written from input buffer */
747+
size_t write_len;
700748
};
701749

702750
static inline int z_impl_flash_ex_op(const struct device *dev, uint16_t code,

0 commit comments

Comments
 (0)