Skip to content

Commit df7b1a1

Browse files
ubiedakartben
authored andcommitted
spi: lpspi: rtio: Re-introduce native RTIO support
This version is based on the CPU LPSPI driver, directly implementing the submit call following the non-blocking asynchronous pattern. This has been re-introduced after struggling to keep up with data streaming applications, which demands reduced and controlled latency, which for the default implementation (using RTIO workqueue) is not guaranteed, due to being serviced by a thread-pool vs directly in the ISR context. This version includes limited feature-set, yet stress-tested: - Required both rx-fifo and tx-fifo to be equal. - 8-byte words supported only. - SPI Controller-only supported (target mode not included). - SPI_HOLD_ON_CS only supported with CS GPIOs. Signed-off-by: Luis Ubieda <[email protected]>
1 parent 9304035 commit df7b1a1

File tree

3 files changed

+524
-0
lines changed

3 files changed

+524
-0
lines changed

drivers/spi/spi_nxp_lpspi/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
zephyr_library_sources_ifdef(CONFIG_SPI_NXP_LPSPI spi_nxp_lpspi_common.c)
44
zephyr_library_sources_ifdef(CONFIG_SPI_NXP_LPSPI_CPU spi_nxp_lpspi.c)
5+
zephyr_library_sources_ifdef(CONFIG_SPI_NXP_LPSPI_CPU_RTIO spi_nxp_lpspi_rtio.c)
56
zephyr_library_sources_ifdef(CONFIG_SPI_NXP_LPSPI_DMA spi_nxp_lpspi_dma.c)

drivers/spi/spi_nxp_lpspi/Kconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,23 @@ config SPI_NXP_LPSPI_CPU
3131
bool "NXP LPSPI CPU-based driver"
3232
default y
3333
depends on $(dt_compat_any_not_has_prop,$(DT_COMPAT_NXP_LPSPI),dmas) || !SPI_NXP_LPSPI_DMA
34+
depends on !SPI_NXP_LPSPI_CPU_RTIO
3435
help
3536
Enable "normal" CPU based SPI driver for LPSPI.
3637
This has lower latency than DMA-based driver but over the
3738
longer transfers will likely have less bandwidth and use more CPU time.
3839

40+
config SPI_NXP_LPSPI_CPU_RTIO
41+
bool "NXP LPSPI RTIO-based driver"
42+
default y
43+
depends on $(dt_compat_any_not_has_prop,$(DT_COMPAT_NXP_LPSPI),dmas) || !SPI_NXP_LPSPI_DMA
44+
depends on SPI_RTIO
45+
help
46+
Enable native RTIO-based driver for LPSPI.
47+
This driver optimizes latency by starting/resuming transfers directly
48+
from the ISR context in a non-blocking and asynchronous fashion. However,
49+
it does not include DMA usage.
50+
3951
config SPI_NXP_LPSPI_TXFIFO_WAIT_CYCLES
4052
int "Number of CPU cycles to wait on TX fifo empty"
4153
default 0 if DEBUG
@@ -49,4 +61,19 @@ config SPI_NXP_LPSPI_TXFIFO_WAIT_CYCLES
4961
for if there is some programming error that causes TX fifo not to empty.
5062
The default of 10000 is arbitrary.
5163

64+
if SPI_NXP_LPSPI_CPU_RTIO
65+
66+
config SPI_NXP_RTIO_SQ_SIZE
67+
int "Number of available submission queue entries"
68+
default 8 # Sensible default that covers most common spi transactions
69+
help
70+
When RTIO is use with SPI each driver holds a context with which blocking
71+
API calls use to perform SPI transactions. This queue needs to be as deep
72+
as the longest set of spi_buf_sets used, where normal SPI operations are
73+
used (equal length buffers). It may need to be slightly deeper where the
74+
spi buffer sets for transmit/receive are not always matched equally in
75+
length as these are transformed into normal transceives.
76+
77+
endif # SPI_NXP_LPSPI_CPU_RTIO
78+
5279
endif # SPI_NXP_LPSPI

0 commit comments

Comments
 (0)