@@ -85,6 +85,13 @@ struct spi_mcux_data {
85
85
#endif
86
86
};
87
87
88
+ #ifdef CONFIG_SPI_RTIO
89
+ static void spi_mcux_iodev_complete (const struct device * dev , int status );
90
+ static inline int transceive_rtio (const struct device * dev , const struct spi_config * spi_cfg ,
91
+ const struct spi_buf_set * tx_bufs ,
92
+ const struct spi_buf_set * rx_bufs );
93
+ #endif
94
+
88
95
static int spi_mcux_transfer_next_packet (const struct device * dev )
89
96
{
90
97
/* const struct spi_mcux_config *config = dev->config; */
@@ -161,10 +168,6 @@ static void spi_mcux_isr(const struct device *dev)
161
168
#endif
162
169
}
163
170
164
- #ifdef CONFIG_SPI_RTIO
165
- static void spi_mcux_iodev_complete (const struct device * dev , int status );
166
- #endif
167
-
168
171
static void spi_mcux_master_transfer_callback (LPSPI_Type * base , lpspi_master_handle_t * handle ,
169
172
status_t status , void * userData )
170
173
{
@@ -557,27 +560,6 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi
557
560
#define lpspi_inst_has_dma (arg ) arg != arg
558
561
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
559
562
560
- #ifdef CONFIG_SPI_RTIO
561
-
562
- static inline int transceive_rtio (const struct device * dev , const struct spi_config * spi_cfg ,
563
- const struct spi_buf_set * tx_bufs ,
564
- const struct spi_buf_set * rx_bufs )
565
- {
566
- struct spi_mcux_data * data = dev -> data ;
567
- struct spi_rtio * rtio_ctx = data -> rtio_ctx ;
568
- int ret ;
569
-
570
- spi_context_lock (& data -> ctx , false, NULL , NULL , spi_cfg );
571
-
572
- ret = spi_rtio_transceive (rtio_ctx , spi_cfg , tx_bufs , rx_bufs );
573
-
574
- spi_context_release (& data -> ctx , ret );
575
-
576
- return ret ;
577
- }
578
-
579
- #endif /* CONFIG_SPI_RTIO */
580
-
581
563
static int transceive (const struct device * dev , const struct spi_config * spi_cfg ,
582
564
const struct spi_buf_set * tx_bufs , const struct spi_buf_set * rx_bufs ,
583
565
bool asynchronous , spi_callback_t cb , void * userdata )
@@ -614,7 +596,6 @@ static int spi_mcux_transceive(const struct device *dev, const struct spi_config
614
596
#ifdef CONFIG_SPI_RTIO
615
597
return transceive_rtio (dev , spi_cfg , tx_bufs , rx_bufs );
616
598
#endif /* CONFIG_SPI_RTIO */
617
-
618
599
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
619
600
const struct spi_mcux_data * data = dev -> data ;
620
601
@@ -656,6 +637,22 @@ static int spi_mcux_release(const struct device *dev, const struct spi_config *s
656
637
}
657
638
658
639
#ifdef CONFIG_SPI_RTIO
640
+ static inline int transceive_rtio (const struct device * dev , const struct spi_config * spi_cfg ,
641
+ const struct spi_buf_set * tx_bufs ,
642
+ const struct spi_buf_set * rx_bufs )
643
+ {
644
+ struct spi_mcux_data * data = dev -> data ;
645
+ struct spi_rtio * rtio_ctx = data -> rtio_ctx ;
646
+ int ret ;
647
+
648
+ spi_context_lock (& data -> ctx , false, NULL , NULL , spi_cfg );
649
+
650
+ ret = spi_rtio_transceive (rtio_ctx , spi_cfg , tx_bufs , rx_bufs );
651
+
652
+ spi_context_release (& data -> ctx , ret );
653
+
654
+ return ret ;
655
+ }
659
656
660
657
static inline void spi_mcux_iodev_prepare_start (const struct device * dev )
661
658
{
@@ -741,18 +738,18 @@ static void spi_mcux_iodev_complete(const struct device *dev, int status)
741
738
if (!status && rtio_ctx -> txn_curr -> sqe .flags & RTIO_SQE_TRANSACTION ) {
742
739
rtio_ctx -> txn_curr = rtio_txn_next (rtio_ctx -> txn_curr );
743
740
spi_mcux_iodev_start (dev );
744
- } else {
745
- /** De-assert CS-line to space from next transaction */
746
- spi_context_cs_control (& data -> ctx , false);
741
+ return ;
742
+ }
747
743
748
- if (spi_rtio_complete (rtio_ctx , status )) {
749
- spi_mcux_iodev_prepare_start (dev );
750
- spi_mcux_iodev_start (dev );
751
- }
744
+ /** De-assert CS-line to space from next transaction */
745
+ spi_context_cs_control (& data -> ctx , false);
746
+
747
+ if (spi_rtio_complete (rtio_ctx , status )) {
748
+ spi_mcux_iodev_prepare_start (dev );
749
+ spi_mcux_iodev_start (dev );
752
750
}
753
751
}
754
-
755
- #endif
752
+ #endif /* CONFIG_SPI_RTIO */
756
753
757
754
#if defined(CONFIG_SPI_MCUX_LPSPI_DMA )
758
755
static int lpspi_dma_dev_ready (const struct device * dma_dev )
0 commit comments