From 92d02878139d7489427532e733de701626ae9567 Mon Sep 17 00:00:00 2001 From: Declan Snyder Date: Fri, 8 Nov 2024 14:50:16 -0600 Subject: [PATCH] drivers: spi_mcux_lpspi: Fix DMA path on RT Apparently, the previous change to fix the chip select only works on some newer revisions of the LPSPI, and the behavior is different on older parts like RT. For now put some #ifdef to keep the fixed CS on MCXN but have the old behavior on RT and other platforms. Signed-off-by: Declan Snyder --- drivers/spi/spi_mcux_lpspi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/spi/spi_mcux_lpspi.c b/drivers/spi/spi_mcux_lpspi.c index 39535e6808f..11deabce1d3 100644 --- a/drivers/spi/spi_mcux_lpspi.c +++ b/drivers/spi/spi_mcux_lpspi.c @@ -483,7 +483,9 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi return ret; } +#ifdef CONFIG_SOC_SERIES_MCXN base->TCR |= LPSPI_TCR_CONT_MASK; +#endif /* DMA is fast enough watermarks are not required */ LPSPI_SetFifoWatermarks(base, 0U, 0U); @@ -500,9 +502,11 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi goto out; } +#ifdef CONFIG_SOC_SERIES_MCXN while (!(LPSPI_GetStatusFlags(base) & kLPSPI_TxDataRequestFlag)) { /* wait until previous tx finished */ } +#endif /* Enable DMA Requests */ LPSPI_EnableDMA(base, kLPSPI_TxDmaEnable | kLPSPI_RxDmaEnable); @@ -513,6 +517,12 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi goto out; } +#ifndef CONFIG_SOC_SERIES_MCXN + while ((LPSPI_GetStatusFlags(base) & kLPSPI_ModuleBusyFlag)) { + /* wait until module is idle */ + } +#endif + /* Disable DMA */ LPSPI_DisableDMA(base, kLPSPI_TxDmaEnable | kLPSPI_RxDmaEnable);