Skip to content

Commit b0732f5

Browse files
committed
spi_nxp_lpspi: Convert DMA version to native code
Convert the DMA-based LPSPI driver to native code. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent cf847ae commit b0732f5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_dma.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ static int spi_mcux_dma_tx_load(const struct device *dev, const uint8_t *buf, si
6464
stream->dma_cfg.channel_direction = MEMORY_TO_PERIPHERAL;
6565
}
6666

67-
/* Dest is always LPSPI tx fifo */
68-
blk_cfg->dest_address = LPSPI_GetTxRegisterAddress(base);
67+
blk_cfg->dest_address = (uint32_t) &(base->TDR);
6968

7069
return dma_config(stream->dma_dev, stream->channel, &stream->dma_cfg);
7170
}
@@ -87,7 +86,7 @@ static int spi_mcux_dma_rx_load(const struct device *dev, uint8_t *buf, size_t l
8786
blk_cfg->dest_address = (uint32_t)buf;
8887
}
8988

90-
blk_cfg->source_address = LPSPI_GetRxRegisterAddress(base);
89+
blk_cfg->source_address = (uint32_t) &(base->RDR);
9190

9291
return dma_config(stream->dma_dev, stream->channel, &stream->dma_cfg);
9392
}
@@ -173,7 +172,7 @@ static void spi_mcux_dma_callback(const struct device *dev, void *arg, uint32_t
173172
}
174173

175174
while (IS_ENABLED(CONFIG_SOC_FAMILY_NXP_IMXRT) &&
176-
(LPSPI_GetStatusFlags(base) & kLPSPI_ModuleBusyFlag)) {
175+
(base->SR & LPSPI_SR_MBF_MASK)) {
177176
/* wait until module is idle */
178177
}
179178

@@ -190,11 +189,11 @@ static void spi_mcux_dma_callback(const struct device *dev, void *arg, uint32_t
190189
error:
191190
LOG_ERR("DMA callback error with channel %d err %d.", channel, status);
192191
done:
193-
LPSPI_DisableDMA(base, kLPSPI_TxDmaEnable | kLPSPI_RxDmaEnable);
192+
base->DER &= ~(LPSPI_DER_TDDE_MASK | LPSPI_DER_RDDE_MASK);
194193
base->TCR &= ~LPSPI_TCR_CONT_MASK;
195194
lpspi_wait_tx_fifo_empty(spi_dev);
196195
spi_context_cs_control(ctx, false);
197-
LPSPI_FlushFifo(base, true, true);
196+
base->CR |= LPSPI_CR_RTF_MASK | LPSPI_CR_RRF_MASK;
198197
spi_context_complete(ctx, spi_dev, status);
199198
}
200199

@@ -227,9 +226,9 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi
227226
return ret;
228227
}
229228

230-
LPSPI_FlushFifo(base, true, true);
229+
base->CR |= LPSPI_CR_RTF_MASK | LPSPI_CR_RRF_MASK;
231230

232-
LPSPI_EnableDMA(base, kLPSPI_TxDmaEnable | kLPSPI_RxDmaEnable);
231+
base->DER |= LPSPI_DER_TDDE_MASK | LPSPI_DER_RDDE_MASK;
233232

234233
ret = spi_context_wait_for_completion(ctx);
235234
out:

0 commit comments

Comments
 (0)