From: Fabrice Gasnier <fabrice.gasnier@st.com> To: <jic23@kernel.org> Cc: <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <mcoquelin.stm32@gmail.com>, <alexandre.torgue@st.com>, <fabrice.gasnier@st.com>, <linux-iio@vger.kernel.org>, <lars@metafoo.de>, <knaack.h@gmx.de>, <pmeerw@pmeerw.net>, <linux-stm32@st-md-mailman.stormreply.com>, <arnaud.pouliquen@st.com>, <olivier.moysan@st.com> Subject: [PATCH 4/8] iio: adc: stm32-dfsdm: move dma slave config to start routine Date: Wed, 6 Mar 2019 09:55:20 +0100 [thread overview] Message-ID: <1551862524-25098-5-git-send-email-fabrice.gasnier@st.com> (raw) In-Reply-To: <1551862524-25098-1-git-send-email-fabrice.gasnier@st.com> Move DMA slave configuration to start routine: depending on regular or injected mode is in use, DMA needs to read resp. RDATAR or JDATAR. This is precursor patch to introduce injected mode (used for scan). Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> --- drivers/iio/adc/stm32-dfsdm-adc.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 818627f..66e2ea0 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -556,6 +556,11 @@ static void stm32_dfsdm_audio_dma_buffer_done(void *data) static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + struct dma_slave_config config = { + .src_addr = (dma_addr_t)adc->dfsdm->phys_base + + DFSDM_RDATAR(adc->fl_id), + .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, + }; struct dma_async_tx_descriptor *desc; dma_cookie_t cookie; int ret; @@ -566,6 +571,10 @@ static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) dev_dbg(&indio_dev->dev, "%s size=%d watermark=%d\n", __func__, adc->buf_sz, adc->buf_sz / 2); + ret = dmaengine_slave_config(adc->dma_chan, &config); + if (ret) + return ret; + /* Prepare a DMA cyclic transaction */ desc = dmaengine_prep_dma_cyclic(adc->dma_chan, adc->dma_buf, @@ -925,12 +934,6 @@ static void stm32_dfsdm_dma_release(struct iio_dev *indio_dev) static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); - struct dma_slave_config config = { - .src_addr = (dma_addr_t)adc->dfsdm->phys_base + - DFSDM_RDATAR(adc->fl_id), - .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, - }; - int ret; adc->dma_chan = dma_request_slave_channel(&indio_dev->dev, "rx"); if (!adc->dma_chan) @@ -940,23 +943,11 @@ static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev) DFSDM_DMA_BUFFER_SIZE, &adc->dma_buf, GFP_KERNEL); if (!adc->rx_buf) { - ret = -ENOMEM; - goto err_release; + dma_release_channel(adc->dma_chan); + return -ENOMEM; } - ret = dmaengine_slave_config(adc->dma_chan, &config); - if (ret) - goto err_free; - return 0; - -err_free: - dma_free_coherent(adc->dma_chan->device->dev, DFSDM_DMA_BUFFER_SIZE, - adc->rx_buf, adc->dma_buf); -err_release: - dma_release_channel(adc->dma_chan); - - return ret; } static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Fabrice Gasnier <fabrice.gasnier@st.com> To: <jic23@kernel.org> Cc: lars@metafoo.de, olivier.moysan@st.com, alexandre.torgue@st.com, linux-iio@vger.kernel.org, pmeerw@pmeerw.net, arnaud.pouliquen@st.com, linux-kernel@vger.kernel.org, mcoquelin.stm32@gmail.com, knaack.h@gmx.de, fabrice.gasnier@st.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/8] iio: adc: stm32-dfsdm: move dma slave config to start routine Date: Wed, 6 Mar 2019 09:55:20 +0100 [thread overview] Message-ID: <1551862524-25098-5-git-send-email-fabrice.gasnier@st.com> (raw) In-Reply-To: <1551862524-25098-1-git-send-email-fabrice.gasnier@st.com> Move DMA slave configuration to start routine: depending on regular or injected mode is in use, DMA needs to read resp. RDATAR or JDATAR. This is precursor patch to introduce injected mode (used for scan). Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> --- drivers/iio/adc/stm32-dfsdm-adc.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 818627f..66e2ea0 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -556,6 +556,11 @@ static void stm32_dfsdm_audio_dma_buffer_done(void *data) static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + struct dma_slave_config config = { + .src_addr = (dma_addr_t)adc->dfsdm->phys_base + + DFSDM_RDATAR(adc->fl_id), + .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, + }; struct dma_async_tx_descriptor *desc; dma_cookie_t cookie; int ret; @@ -566,6 +571,10 @@ static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) dev_dbg(&indio_dev->dev, "%s size=%d watermark=%d\n", __func__, adc->buf_sz, adc->buf_sz / 2); + ret = dmaengine_slave_config(adc->dma_chan, &config); + if (ret) + return ret; + /* Prepare a DMA cyclic transaction */ desc = dmaengine_prep_dma_cyclic(adc->dma_chan, adc->dma_buf, @@ -925,12 +934,6 @@ static void stm32_dfsdm_dma_release(struct iio_dev *indio_dev) static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); - struct dma_slave_config config = { - .src_addr = (dma_addr_t)adc->dfsdm->phys_base + - DFSDM_RDATAR(adc->fl_id), - .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, - }; - int ret; adc->dma_chan = dma_request_slave_channel(&indio_dev->dev, "rx"); if (!adc->dma_chan) @@ -940,23 +943,11 @@ static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev) DFSDM_DMA_BUFFER_SIZE, &adc->dma_buf, GFP_KERNEL); if (!adc->rx_buf) { - ret = -ENOMEM; - goto err_release; + dma_release_channel(adc->dma_chan); + return -ENOMEM; } - ret = dmaengine_slave_config(adc->dma_chan, &config); - if (ret) - goto err_free; - return 0; - -err_free: - dma_free_coherent(adc->dma_chan->device->dev, DFSDM_DMA_BUFFER_SIZE, - adc->rx_buf, adc->dma_buf); -err_release: - dma_release_channel(adc->dma_chan); - - return ret; } static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-03-06 8:56 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-06 8:55 [PATCH 0/8] iio: adc: stm32-dfsdm: add buffer modes Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier 2019-03-06 8:55 ` [PATCH 1/8] iio: adc: stm32-dfsdm: make spi_master_freq more accurate Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier 2019-03-10 10:09 ` Jonathan Cameron 2019-03-10 10:09 ` Jonathan Cameron 2019-03-21 13:41 ` Fabrice Gasnier 2019-03-21 13:41 ` Fabrice Gasnier 2019-03-06 8:55 ` [PATCH 2/8] iio: adc: stm32-dfsdm: continuous mode depends on current mode Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier 2019-03-06 8:55 ` [PATCH 3/8] iio: adc: stm32-dfsdm: move dma enable from start_conv() to start_dma() Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier [this message] 2019-03-06 8:55 ` [PATCH 4/8] iio: adc: stm32-dfsdm: move dma slave config to start routine Fabrice Gasnier 2019-03-06 8:55 ` [PATCH 5/8] iio: adc: stm32-dfsdm: enable hw consumer Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier 2019-03-06 8:55 ` [PATCH 6/8] iio: adc: stm32-dfsdm: add support for scan mode Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier 2019-03-06 8:55 ` [PATCH 7/8] iio: adc: stm32-dfsdm: add support for buffer modes Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier 2019-03-10 10:21 ` Jonathan Cameron 2019-03-10 10:21 ` Jonathan Cameron 2019-03-15 18:01 ` Fabrice Gasnier 2019-03-15 18:01 ` Fabrice Gasnier 2019-03-16 14:10 ` Jonathan Cameron 2019-03-16 14:10 ` Jonathan Cameron 2019-03-21 13:41 ` Fabrice Gasnier 2019-03-21 13:41 ` Fabrice Gasnier 2019-03-06 8:55 ` [PATCH 8/8] iio: adc: stm32-dfsdm: claim direct mode for raw read and settings Fabrice Gasnier 2019-03-06 8:55 ` Fabrice Gasnier
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=1551862524-25098-5-git-send-email-fabrice.gasnier@st.com \ --to=fabrice.gasnier@st.com \ --cc=alexandre.torgue@st.com \ --cc=arnaud.pouliquen@st.com \ --cc=jic23@kernel.org \ --cc=knaack.h@gmx.de \ --cc=lars@metafoo.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-iio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=mcoquelin.stm32@gmail.com \ --cc=olivier.moysan@st.com \ --cc=pmeerw@pmeerw.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.