@@ -91,9 +91,6 @@ struct spi_mcux_data {
9191};
9292
9393static int spi_mcux_transfer_next_packet (const struct device * dev );
94- #ifdef CONFIG_SPI_RTIO
95- static void spi_mcux_iodev_complete (const struct device * dev , int status );
96- #endif
9794
9895static void spi_mcux_isr (const struct device * dev )
9996{
@@ -108,14 +105,6 @@ static void spi_mcux_master_callback(LPSPI_Type *base, lpspi_master_handle_t *ha
108105{
109106 struct spi_mcux_data * data = userData ;
110107
111- #ifdef CONFIG_SPI_RTIO
112- struct spi_rtio * rtio_ctx = data -> rtio_ctx ;
113-
114- if (rtio_ctx -> txn_head != NULL ) {
115- spi_mcux_iodev_complete (data -> dev , status );
116- return ;
117- }
118- #endif
119108 spi_context_update_tx (& data -> ctx , 1 , data -> transfer_len );
120109 spi_context_update_rx (& data -> ctx , 1 , data -> transfer_len );
121110
@@ -226,7 +215,6 @@ static int spi_mcux_configure(const struct device *dev, const struct spi_config
226215 master_config .pinCfg = config -> data_pin_config ;
227216
228217 LPSPI_MasterInit (base , & master_config , clock_freq );
229- LPSPI_MasterTransferCreateHandle (base , & data -> handle , spi_mcux_master_callback , data );
230218 LPSPI_SetDummyData (base , 0 );
231219
232220 if (IS_ENABLED (CONFIG_DEBUG )) {
@@ -537,6 +525,22 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi
537525#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
538526
539527#ifdef CONFIG_SPI_RTIO
528+ static void spi_mcux_iodev_complete (const struct device * dev , int status );
529+
530+ static void spi_mcux_master_rtio_callback (LPSPI_Type * base , lpspi_master_handle_t * handle ,
531+ status_t status , void * userData )
532+ {
533+ struct spi_mcux_data * data = userData ;
534+ struct spi_rtio * rtio_ctx = data -> rtio_ctx ;
535+
536+ if (rtio_ctx -> txn_head != NULL ) {
537+ spi_mcux_iodev_complete (data -> dev , status );
538+ return ;
539+ }
540+
541+ spi_mcux_master_callback (base , handle , status , userData );
542+ }
543+
540544static void spi_mcux_iodev_start (const struct device * dev )
541545{
542546 struct spi_mcux_data * data = dev -> data ;
@@ -554,6 +558,8 @@ static void spi_mcux_iodev_start(const struct device *dev)
554558 return ;
555559 }
556560
561+ LPSPI_MasterTransferCreateHandle (base , & data -> handle , spi_mcux_master_rtio_callback , data );
562+
557563 transfer .configFlags = LPSPI_MASTER_XFER_CFG_FLAGS (spi_cfg -> slave );
558564
559565 switch (sqe -> op ) {
@@ -647,6 +653,7 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
647653 const struct spi_buf_set * tx_bufs , const struct spi_buf_set * rx_bufs ,
648654 bool asynchronous , spi_callback_t cb , void * userdata )
649655{
656+ LPSPI_Type * base = (LPSPI_Type * )DEVICE_MMIO_NAMED_GET (dev , reg_base );
650657 struct spi_mcux_data * data = dev -> data ;
651658 int ret ;
652659
@@ -657,6 +664,8 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
657664 goto out ;
658665 }
659666
667+ LPSPI_MasterTransferCreateHandle (base , & data -> handle , spi_mcux_master_callback , data );
668+
660669 spi_context_buffers_setup (& data -> ctx , tx_bufs , rx_bufs , 1 );
661670
662671 spi_context_cs_control (& data -> ctx , true);
0 commit comments