From: Jonathan Cameron <jic23@kernel.org>
To: Fabrice Gasnier <fabrice.gasnier@st.com>
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,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 3/8] iio: adc: stm32-dfsdm: move dma enable from start_conv() to start_dma()
Date: Sun, 24 Mar 2019 16:44:14 +0000 [thread overview]
Message-ID: <20190324164414.03f4bb01@archlinux> (raw)
In-Reply-To: <1553186849-6261-4-git-send-email-fabrice.gasnier@st.com>
On Thu, 21 Mar 2019 17:47:24 +0100
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:
> Move DMA enable (e.g. set RDMAEN bit) away from start_conv() that is used
> for both buffer and single conversions. Thus, single conv rely on
> interrupt, not dma.
> Note: take care to prepare all DMA stuff and set RDMAEN before starting
> filter (can be set only when DFEN=0).
>
> This is precursor patch to ease support of triggered buffer mode.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied,
Thanks,
Jonathan
> ---
> drivers/iio/adc/stm32-dfsdm-adc.c | 77 +++++++++++++++++++--------------------
> 1 file changed, 38 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
> index 8690672..818627f 100644
> --- a/drivers/iio/adc/stm32-dfsdm-adc.c
> +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
> @@ -429,12 +429,10 @@ static ssize_t dfsdm_adc_audio_set_spiclk(struct iio_dev *indio_dev,
> }
>
> static int stm32_dfsdm_start_conv(struct stm32_dfsdm_adc *adc,
> - const struct iio_chan_spec *chan,
> - bool dma)
> + const struct iio_chan_spec *chan)
> {
> struct regmap *regmap = adc->dfsdm->regmap;
> int ret;
> - unsigned int dma_en = 0;
>
> ret = stm32_dfsdm_start_channel(adc->dfsdm, chan->channel);
> if (ret < 0)
> @@ -444,25 +442,12 @@ static int stm32_dfsdm_start_conv(struct stm32_dfsdm_adc *adc,
> if (ret < 0)
> goto stop_channels;
>
> - if (dma) {
> - /* Enable DMA transfer*/
> - dma_en = DFSDM_CR1_RDMAEN(1);
> - }
> - /* Enable DMA transfer*/
> - ret = regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
> - DFSDM_CR1_RDMAEN_MASK, dma_en);
> - if (ret < 0)
> - goto filter_unconfigure;
> -
> ret = stm32_dfsdm_start_filter(adc->dfsdm, adc->fl_id);
> if (ret < 0)
> - goto stop_dma;
> + goto filter_unconfigure;
>
> return 0;
>
> -stop_dma:
> - regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
> - DFSDM_CR1_RDMAEN_MASK, 0);
> filter_unconfigure:
> regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
> DFSDM_CR1_CFG_MASK, 0);
> @@ -479,10 +464,6 @@ static void stm32_dfsdm_stop_conv(struct stm32_dfsdm_adc *adc,
>
> stm32_dfsdm_stop_filter(adc->dfsdm, adc->fl_id);
>
> - /* Clean conversion options */
> - regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
> - DFSDM_CR1_RDMAEN_MASK, 0);
> -
> regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
> DFSDM_CR1_CFG_MASK, 0);
>
> @@ -599,15 +580,36 @@ static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev)
>
> cookie = dmaengine_submit(desc);
> ret = dma_submit_error(cookie);
> - if (ret) {
> - dmaengine_terminate_all(adc->dma_chan);
> - return ret;
> - }
> + if (ret)
> + goto err_stop_dma;
>
> /* Issue pending DMA requests */
> dma_async_issue_pending(adc->dma_chan);
>
> + /* Enable DMA transfer*/
> + ret = regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR1(adc->fl_id),
> + DFSDM_CR1_RDMAEN_MASK, DFSDM_CR1_RDMAEN_MASK);
> + if (ret < 0)
> + goto err_stop_dma;
> +
> return 0;
> +
> +err_stop_dma:
> + dmaengine_terminate_all(adc->dma_chan);
> +
> + return ret;
> +}
> +
> +static void stm32_dfsdm_adc_dma_stop(struct iio_dev *indio_dev)
> +{
> + struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
> +
> + if (!adc->dma_chan)
> + return;
> +
> + regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR1(adc->fl_id),
> + DFSDM_CR1_RDMAEN_MASK, 0);
> + dmaengine_terminate_all(adc->dma_chan);
> }
>
> static int stm32_dfsdm_postenable(struct iio_dev *indio_dev)
> @@ -623,24 +625,22 @@ static int stm32_dfsdm_postenable(struct iio_dev *indio_dev)
> if (ret < 0)
> return ret;
>
> - ret = stm32_dfsdm_start_conv(adc, chan, true);
> + ret = stm32_dfsdm_adc_dma_start(indio_dev);
> if (ret) {
> - dev_err(&indio_dev->dev, "Can't start conversion\n");
> + dev_err(&indio_dev->dev, "Can't start DMA\n");
> goto stop_dfsdm;
> }
>
> - if (adc->dma_chan) {
> - ret = stm32_dfsdm_adc_dma_start(indio_dev);
> - if (ret) {
> - dev_err(&indio_dev->dev, "Can't start DMA\n");
> - goto err_stop_conv;
> - }
> + ret = stm32_dfsdm_start_conv(adc, chan);
> + if (ret) {
> + dev_err(&indio_dev->dev, "Can't start conversion\n");
> + goto err_stop_dma;
> }
>
> return 0;
>
> -err_stop_conv:
> - stm32_dfsdm_stop_conv(adc, chan);
> +err_stop_dma:
> + stm32_dfsdm_adc_dma_stop(indio_dev);
> stop_dfsdm:
> stm32_dfsdm_stop_dfsdm(adc->dfsdm);
>
> @@ -652,11 +652,10 @@ static int stm32_dfsdm_predisable(struct iio_dev *indio_dev)
> struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
> const struct iio_chan_spec *chan = &indio_dev->channels[0];
>
> - if (adc->dma_chan)
> - dmaengine_terminate_all(adc->dma_chan);
> -
> stm32_dfsdm_stop_conv(adc, chan);
>
> + stm32_dfsdm_adc_dma_stop(indio_dev);
> +
> stm32_dfsdm_stop_dfsdm(adc->dfsdm);
>
> return 0;
> @@ -736,7 +735,7 @@ static int stm32_dfsdm_single_conv(struct iio_dev *indio_dev,
> if (ret < 0)
> goto stop_dfsdm;
>
> - ret = stm32_dfsdm_start_conv(adc, chan, false);
> + ret = stm32_dfsdm_start_conv(adc, chan);
> if (ret < 0) {
> regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id),
> DFSDM_CR2_REOCIE_MASK, DFSDM_CR2_REOCIE(0));
_______________________________________________
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-24 16:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 16:47 [PATCH v2 0/8] iio: adc: stm32-dfsdm: add buffer modes Fabrice Gasnier
2019-03-21 16:47 ` [PATCH v2 1/8] iio: adc: stm32-dfsdm: make spi_master_freq more accurate Fabrice Gasnier
2019-03-24 16:41 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 2/8] iio: adc: stm32-dfsdm: continuous mode depends on current mode Fabrice Gasnier
2019-03-24 16:43 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 3/8] iio: adc: stm32-dfsdm: move dma enable from start_conv() to start_dma() Fabrice Gasnier
2019-03-24 16:44 ` Jonathan Cameron [this message]
2019-03-21 16:47 ` [PATCH v2 4/8] iio: adc: stm32-dfsdm: move dma slave config to start routine Fabrice Gasnier
2019-03-24 16:45 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 5/8] iio: adc: stm32-dfsdm: enable hw consumer Fabrice Gasnier
2019-03-24 16:45 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 6/8] iio: adc: stm32-dfsdm: add support for scan mode Fabrice Gasnier
2019-03-24 16:46 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 7/8] iio: adc: stm32-dfsdm: add support for buffer modes Fabrice Gasnier
2019-03-24 17:11 ` Jonathan Cameron
2019-03-21 16:47 ` [PATCH v2 8/8] iio: adc: stm32-dfsdm: claim direct mode for raw read and settings Fabrice Gasnier
2019-03-24 17:12 ` Jonathan Cameron
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=20190324164414.03f4bb01@archlinux \
--to=jic23@kernel.org \
--cc=alexandre.torgue@st.com \
--cc=arnaud.pouliquen@st.com \
--cc=fabrice.gasnier@st.com \
--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: 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).