Skip to content

Commit 30b9463

Browse files
decsnykartben
authored andcommitted
spi_nxp_lpspi: Use default RTIO submit
For the CPU-based drivers, delete the old MCUX based RTIO driver and use the default RTIO submit implementation instead. Rationale: - 300 LOC -> 1 LOC to maintain. - MCUX SDK based driver cannot control the chip select for the transfer properly, but the new spi_nxp_lpspi.c driver can. So this fixes the bug with the PCS when using RTIO. Also enable the default RTIO implementation for DMA based driver. In the future a DMA based RTIO driver with custom implementation can be designed, but for CPU based transfer, which is already not optimal performance, code maintenance is more important. Only requirement is asynchronous submit, which is accomplished by p4wq in rtio workq. Signed-off-by: Declan Snyder <[email protected]>
1 parent 1bb6e58 commit 30b9463

File tree

6 files changed

+7
-277
lines changed

6 files changed

+7
-277
lines changed

drivers/spi/spi_nxp_lpspi/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
zephyr_library_sources_ifdef(CONFIG_SPI_MCUX_LPSPI spi_nxp_lpspi_common.c)
44
zephyr_library_sources_ifdef(CONFIG_SPI_MCUX_LPSPI_NORMAL spi_nxp_lpspi.c)
55
zephyr_library_sources_ifdef(CONFIG_SPI_MCUX_LPSPI_DMA spi_nxp_lpspi_dma.c)
6-
zephyr_library_sources_ifdef(CONFIG_SPI_MCUX_LPSPI_RTIO spi_mcux_lpspi_rtio.c)

drivers/spi/spi_nxp_lpspi/Kconfig

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ config SPI_MCUX_LPSPI
1212

1313
if SPI_MCUX_LPSPI
1414

15-
if !SPI_RTIO
1615
config SPI_MCUX_LPSPI_DMA
1716
bool "MCUX LPSPI SPI DMA Support"
1817
select DMA
@@ -27,25 +26,5 @@ config SPI_MCUX_LPSPI_NORMAL
2726
depends on $(dt_compat_any_not_has_prop,$(DT_COMPAT_NXP_LPSPI),dmas) || !SPI_MCUX_LPSPI_DMA
2827
help
2928
Use the traditional (non-RTIO) SPI driver for NXP LPSPI.
30-
endif # !SPI_RTIO
31-
32-
if SPI_RTIO
33-
config SPI_MCUX_LPSPI_RTIO
34-
bool "NXP MCUX LPSPI RTIO based driver"
35-
default y
36-
help
37-
Use the RTIO-based SPI driver for the NXP LPSPI.
38-
39-
config SPI_MCUX_RTIO_SQ_SIZE
40-
int "number of available submission queue entries"
41-
default 8 # sensible default that covers most common spi transactions
42-
help
43-
when rtio is use with spi each driver holds a context with which blocking
44-
api calls use to perform spi transactions. this queue needs to be as deep
45-
as the longest set of spi_buf_sets used, where normal spi operations are
46-
used (equal length buffers). it may need to be slightly deeper where the
47-
spi buffer sets for transmit/receive are not always matched equally in
48-
length as these are transformed into normal transceives.
49-
endif # SPI_RTIO
5029

5130
endif # SPI_MCUX_LPSPI

drivers/spi/spi_nxp_lpspi/spi_mcux_lpspi_rtio.c

Lines changed: 0 additions & 255 deletions
This file was deleted.

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ static DEVICE_API(spi, spi_mcux_driver_api) = {
319319
.transceive = spi_mcux_transceive_sync,
320320
#ifdef CONFIG_SPI_ASYNC
321321
.transceive_async = spi_mcux_transceive_async,
322+
#endif
323+
#ifdef CONFIG_SPI_RTIO
324+
.iodev_submit = spi_rtio_iodev_default_submit,
322325
#endif
323326
.release = spi_mcux_release,
324327
};

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_dma.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ static DEVICE_API(spi, spi_mcux_driver_api) = {
388388
.transceive = spi_nxp_dma_transceive_sync,
389389
#ifdef CONFIG_SPI_ASYNC
390390
.transceive_async = spi_nxp_dma_transceive_async,
391+
#endif
392+
#ifdef CONFIG_SPI_RTIO
393+
.iodev_submit = spi_rtio_iodev_default_submit,
391394
#endif
392395
.release = spi_mcux_release,
393396
};

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <zephyr/drivers/spi.h>
8+
#include <zephyr/drivers/spi/rtio.h>
89
#include <zephyr/drivers/pinctrl.h>
910
#include <zephyr/drivers/clock_control.h>
1011
#include <zephyr/irq.h>

0 commit comments

Comments
 (0)