@@ -644,6 +644,65 @@ static int api_read_jedec_id(const struct device *dev, uint8_t *id)
644644}
645645#endif /* CONFIG_FLASH_JESD216_API */
646646
647+ #if defined(CONFIG_FLASH_EX_OP_ENABLED )
648+ static int ex_op_cmd_read (const struct device * dev ,
649+ const struct flash_ex_op_cmd_read_in * in ,
650+ struct flash_ex_op_cmd_read_out * out )
651+ {
652+ struct flash_mspi_nor_data * dev_data = dev -> data ;
653+
654+ int rc = acquire (dev );
655+ if (rc < 0 ) {
656+ return rc ;
657+ }
658+
659+ set_up_xfer (dev , MSPI_RX );
660+ dev_data -> packet .data_buf = in -> read_buffer ;
661+ dev_data -> packet .num_bytes = in -> buffer_len ;
662+ rc = perform_xfer (dev , in -> cmd );
663+ out -> read_len = (rc < 0 ) ? 0 : in -> buffer_len ;
664+
665+ release (dev );
666+
667+ return rc ;
668+ }
669+
670+ static int ex_op_cmd_write (const struct device * dev ,
671+ const struct flash_ex_op_cmd_write_in * in ,
672+ struct flash_ex_op_cmd_write_out * out )
673+ {
674+ struct flash_mspi_nor_data * dev_data = dev -> data ;
675+
676+ int rc = acquire (dev );
677+ if (rc < 0 ) {
678+ return rc ;
679+ }
680+
681+ set_up_xfer (dev , MSPI_TX );
682+ dev_data -> packet .data_buf = in -> write_buffer ;
683+ dev_data -> packet .num_bytes = in -> buffer_len ;
684+ rc = perform_xfer (dev , in -> cmd );
685+ out -> write_len = (rc < 0 ) ? 0 : in -> buffer_len ;
686+
687+ release (dev );
688+
689+ return rc ;
690+ }
691+
692+ static int api_ex_op (const struct device * dev ,
693+ uint16_t code , const uintptr_t in , void * out )
694+ {
695+ switch (code ) {
696+ case FLASH_EX_OP_CMD_READ :
697+ return ex_op_cmd_read (dev , (const struct flash_ex_op_cmd_read_in * )in , out );
698+ case FLASH_EX_OP_CMD_WRITE :
699+ return ex_op_cmd_write (dev , (const struct flash_ex_op_cmd_write_in * )in , out );
700+ default :
701+ return - ENOTSUP ;
702+ };
703+ }
704+ #endif /* CONFIG_FLASH_EX_OP_ENABLED */
705+
647706static int dev_pm_action_cb (const struct device * dev ,
648707 enum pm_device_action action )
649708{
@@ -1259,6 +1318,9 @@ static DEVICE_API(flash, drv_api) = {
12591318 .sfdp_read = api_sfdp_read ,
12601319 .read_jedec_id = api_read_jedec_id ,
12611320#endif
1321+ #if defined(CONFIG_FLASH_EX_OP_ENABLED )
1322+ .ex_op = api_ex_op ,
1323+ #endif
12621324};
12631325
12641326#define FLASH_INITIAL_CONFIG (inst ) \
0 commit comments