Commit f8bb12f2 authored by Cezary Gapinski's avatar Cezary Gapinski Committed by Mark Brown

spi: stm32: add start dma transfer function

Add transfer_one_dma_start function to be more generic for other
stm32 SPI family drivers.
Signed-off-by: default avatarCezary Gapinski <cezary.gapinski@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9d5fce16
...@@ -747,6 +747,23 @@ static int stm32_spi_transfer_one_irq(struct stm32_spi *spi) ...@@ -747,6 +747,23 @@ static int stm32_spi_transfer_one_irq(struct stm32_spi *spi)
return 1; return 1;
} }
/**
* stm32_spi_transfer_one_dma_start - Set SPI driver registers to start transfer
* using DMA
*/
static void stm32_spi_transfer_one_dma_start(struct stm32_spi *spi)
{
/* Enable the interrupts relative to the end of transfer */
stm32_spi_set_bits(spi, STM32H7_SPI_IER, STM32H7_SPI_IER_EOTIE |
STM32H7_SPI_IER_TXTFIE |
STM32H7_SPI_IER_OVRIE |
STM32H7_SPI_IER_MODFIE);
stm32_spi_enable(spi);
stm32_spi_set_bits(spi, STM32H7_SPI_CR1, STM32H7_SPI_CR1_CSTART);
}
/** /**
* stm32_spi_transfer_one_dma - transfer a single spi_transfer using DMA * stm32_spi_transfer_one_dma - transfer a single spi_transfer using DMA
* *
...@@ -759,7 +776,6 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi, ...@@ -759,7 +776,6 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
struct dma_slave_config tx_dma_conf, rx_dma_conf; struct dma_slave_config tx_dma_conf, rx_dma_conf;
struct dma_async_tx_descriptor *tx_dma_desc, *rx_dma_desc; struct dma_async_tx_descriptor *tx_dma_desc, *rx_dma_desc;
unsigned long flags; unsigned long flags;
u32 ier = 0;
spin_lock_irqsave(&spi->lock, flags); spin_lock_irqsave(&spi->lock, flags);
...@@ -829,14 +845,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi, ...@@ -829,14 +845,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
STM32H7_SPI_CFG1_TXDMAEN); STM32H7_SPI_CFG1_TXDMAEN);
} }
/* Enable the interrupts relative to the end of transfer */ stm32_spi_transfer_one_dma_start(spi);
ier |= STM32H7_SPI_IER_EOTIE | STM32H7_SPI_IER_TXTFIE |
STM32H7_SPI_IER_OVRIE | STM32H7_SPI_IER_MODFIE;
writel_relaxed(ier, spi->base + STM32H7_SPI_IER);
stm32_spi_enable(spi);
stm32_spi_set_bits(spi, STM32H7_SPI_CR1, STM32H7_SPI_CR1_CSTART);
spin_unlock_irqrestore(&spi->lock, flags); spin_unlock_irqrestore(&spi->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment