From: cezary.gapinski@gmail.com
To: Mark Brown <broonie@kernel.org>,
linux-spi@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org,
Amelie Delaunay <amelie.delaunay@st.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Mark Rutland <mark.rutland@arm.com>,
Cezary Gapinski <cezary.gapinski@gmail.com>
Subject: [PATCH v2 10/14] spi: stm32: add start dma transfer function
Date: Mon, 24 Dec 2018 23:00:36 +0100 [thread overview]
Message-ID: <1545688840-23992-11-git-send-email-cezary.gapinski@gmail.com> (raw)
In-Reply-To: <1545688840-23992-1-git-send-email-cezary.gapinski@gmail.com>
From: Cezary Gapinski <cezary.gapinski@gmail.com>
Add transfer_one_dma_start function to be more generic for other
stm32 SPI family drivers.
Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com>
---
drivers/spi/spi-stm32.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index bc8513f..b19d02b 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -748,6 +748,23 @@ static int stm32_spi_transfer_one_irq(struct stm32_spi *spi)
}
/**
+ * 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
*
* It must returns 0 if the transfer is finished or 1 if the transfer is still
@@ -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_async_tx_descriptor *tx_dma_desc, *rx_dma_desc;
unsigned long flags;
- u32 ier = 0;
spin_lock_irqsave(&spi->lock, flags);
@@ -829,14 +845,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
STM32H7_SPI_CFG1_TXDMAEN);
}
- /* Enable the interrupts relative to the end of transfer */
- 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);
+ stm32_spi_transfer_one_dma_start(spi);
spin_unlock_irqrestore(&spi->lock, flags);
--
2.7.4
next prev parent reply other threads:[~2018-12-24 22:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-24 22:00 [PATCH v2 00/14] Add support for STM32F4 SPI cezary.gapinski
2018-12-24 22:00 ` [PATCH v2 01/14] spi: stm32: switch to SPDX identifier cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: switch to SPDX identifier" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 02/14] spi: stm32: use NULL pointer instead of plain integer cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: use NULL pointer instead of plain integer" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 03/14] spi: stm32: fix DMA configuration with only one channel cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: fix DMA configuration with only one channel" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 04/14] spi: fix typo in SPI_STM32 help text cezary.gapinski
2019-01-07 18:59 ` Applied "spi: fix typo in SPI_STM32 help text" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 05/14] spi: stm32: use explicit CPOL and CPHA mode bits cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: use explicit CPOL and CPHA mode bits" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 06/14] spi: stm32: remove SPI LOOP mode cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: remove SPI LOOP mode" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 07/14] spi: stm32: rename STM32 SPI registers to STM32H7 cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: rename STM32 SPI registers to STM32H7" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 08/14] spi: stm32: rename interrupt function cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: rename interrupt function" to the spi tree Mark Brown
2018-12-24 22:00 ` [PATCH v2 09/14] spi: stm32: split transfer one setup function cezary.gapinski
2019-01-07 18:59 ` Applied "spi: stm32: split transfer one setup function" to the spi tree Mark Brown
2018-12-24 22:00 ` cezary.gapinski [this message]
2018-12-24 22:00 ` [PATCH v2 11/14] spi: stm32: introduce compatible data cfg cezary.gapinski
2018-12-24 22:00 ` [PATCH v2 12/14] spi: stm32: add support for STM32F4 cezary.gapinski
2018-12-24 22:00 ` [PATCH v2 13/14] ARM: dts: stm32: add SPI support on STM32F429 SoC cezary.gapinski
2018-12-24 22:00 ` [PATCH v2 14/14] spi: stm32: add description about STM32F4 bindings cezary.gapinski
2018-12-27 21:09 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1545688840-23992-11-git-send-email-cezary.gapinski@gmail.com \
--to=cezary.gapinski@gmail.com \
--cc=alexandre.torgue@st.com \
--cc=amelie.delaunay@st.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).