Skip to content

Commit cf847ae

Browse files
committed
spi_nxp_lpspi: Fix DMA Async API
Fix the ASYNC DMA API on the lpspi driver and actually make the entire driver go through that path. Rather than having an orthogonal internally synchronous path we can just have both APIs go through the same asynchronous path and just use wait_for_completion from spi context to implement either sync or async. Also make DMA driver default y if dependency (an lpspi having dmas property) is met. And lpspi_wait_tx_fifo_empty can be shared between drivers. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent ed45960 commit cf847ae

File tree

5 files changed

+134
-232
lines changed

5 files changed

+134
-232
lines changed

drivers/spi/spi_nxp_lpspi/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ if SPI_MCUX_LPSPI
1414

1515
config SPI_MCUX_LPSPI_DMA
1616
bool "MCUX LPSPI SPI DMA Support"
17+
default y
1718
select DMA
1819
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_NXP_LPSPI),dmas)
1920
help

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ struct lpspi_driver_data {
1616
uint8_t word_size_bytes;
1717
};
1818

19-
static inline void lpspi_wait_tx_fifo_empty(const struct device *dev)
20-
{
21-
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
22-
23-
while (LPSPI_GetTxFifoCount(base) != 0) {
24-
}
25-
}
26-
2719
static inline uint8_t rx_fifo_cur_len(LPSPI_Type *base)
2820
{
2921
return (base->FSR & LPSPI_FSR_RXCOUNT_MASK) >> LPSPI_FSR_RXCOUNT_SHIFT;

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_common.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ LOG_MODULE_REGISTER(spi_mcux_lpspi_common, CONFIG_SPI_LOG_LEVEL);
99

1010
#include "spi_nxp_lpspi_priv.h"
1111

12+
void lpspi_wait_tx_fifo_empty(const struct device *dev)
13+
{
14+
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
15+
16+
while (LPSPI_GetTxFifoCount(base) != 0) {
17+
}
18+
}
19+
1220
int spi_mcux_release(const struct device *dev, const struct spi_config *spi_cfg)
1321
{
1422
struct spi_mcux_data *data = dev->data;

0 commit comments

Comments
 (0)