From: Jonathan Cameron <jic23@kernel.org>
To: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <linux@armlinux.org.uk>, <robh+dt@kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-iio@vger.kernel.org>, <mark.rutland@arm.com>,
<mcoquelin.stm32@gmail.com>, <alexandre.torgue@st.com>,
<lars@metafoo.de>, <knaack.h@gmx.de>, <pmeerw@pmeerw.net>,
<benjamin.gaignard@linaro.org>, <benjamin.gaignard@st.com>
Subject: Re: [PATCH v2 4/5] iio: adc: stm32: make per instance bus clock optional
Date: Sat, 3 Jun 2017 10:29:10 +0100 [thread overview]
Message-ID: <20170603102910.521cab86@kernel.org> (raw)
In-Reply-To: <1496050100-25854-5-git-send-email-fabrice.gasnier@st.com>
On Mon, 29 May 2017 11:28:19 +0200
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:
> STM32F4 requires one clock per ADC instance for register access. But,
> newer version of ADC hardware block have common bus clock for all
> instances (per instance driver isn't responsible for getting it).
> So, make it optional by default. Still, enforce it's required on STM32F4.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied.
> ---
> drivers/iio/adc/stm32-adc.c | 28 ++++++++++++++++++++--------
> 1 file changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> index 50b2538..2ba9ca9 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -160,6 +160,7 @@ struct stm32_adc_regspec {
> * @regs: registers descriptions
> * @adc_info: per instance input channels definitions
> * @trigs: external trigger sources
> + * @clk_required: clock is required
> * @start_conv: routine to start conversions
> * @stop_conv: routine to stop conversions
> */
> @@ -167,6 +168,7 @@ struct stm32_adc_cfg {
> const struct stm32_adc_regspec *regs;
> const struct stm32_adc_info *adc_info;
> struct stm32_adc_trig_info *trigs;
> + bool clk_required;
> void (*start_conv)(struct stm32_adc *, bool dma);
> void (*stop_conv)(struct stm32_adc *);
> };
> @@ -1145,14 +1147,21 @@ static int stm32_adc_probe(struct platform_device *pdev)
>
> adc->clk = devm_clk_get(&pdev->dev, NULL);
> if (IS_ERR(adc->clk)) {
> - dev_err(&pdev->dev, "Can't get clock\n");
> - return PTR_ERR(adc->clk);
> + ret = PTR_ERR(adc->clk);
> + if (ret == -ENOENT && !adc->cfg->clk_required) {
> + adc->clk = NULL;
> + } else {
> + dev_err(&pdev->dev, "Can't get clock\n");
> + return ret;
> + }
> }
>
> - ret = clk_prepare_enable(adc->clk);
> - if (ret < 0) {
> - dev_err(&pdev->dev, "clk enable failed\n");
> - return ret;
> + if (adc->clk) {
> + ret = clk_prepare_enable(adc->clk);
> + if (ret < 0) {
> + dev_err(&pdev->dev, "clk enable failed\n");
> + return ret;
> + }
> }
>
> ret = stm32_adc_of_get_resolution(indio_dev);
> @@ -1196,7 +1205,8 @@ static int stm32_adc_probe(struct platform_device *pdev)
> dma_release_channel(adc->dma_chan);
> }
> err_clk_disable:
> - clk_disable_unprepare(adc->clk);
> + if (adc->clk)
> + clk_disable_unprepare(adc->clk);
>
> return ret;
> }
> @@ -1214,7 +1224,8 @@ static int stm32_adc_remove(struct platform_device *pdev)
> adc->rx_buf, adc->rx_dma_buf);
> dma_release_channel(adc->dma_chan);
> }
> - clk_disable_unprepare(adc->clk);
> + if (adc->clk)
> + clk_disable_unprepare(adc->clk);
>
> return 0;
> }
> @@ -1223,6 +1234,7 @@ static int stm32_adc_remove(struct platform_device *pdev)
> .regs = &stm32f4_adc_regspec,
> .adc_info = &stm32f4_adc_info,
> .trigs = stm32f4_adc_trigs,
> + .clk_required = true,
> .start_conv = stm32f4_adc_start_conv,
> .stop_conv = stm32f4_adc_stop_conv,
> };
next prev parent reply other threads:[~2017-06-03 9:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 9:28 [PATCH v2 0/5] iio: add support for STM32H7 ADC Fabrice Gasnier
2017-05-29 9:28 ` [PATCH v2 1/5] dt-bindings: iio: stm32-adc: add support for STM32H7 Fabrice Gasnier
2017-06-03 9:27 ` Jonathan Cameron
2017-06-07 20:09 ` Rob Herring
2017-05-29 9:28 ` [PATCH v2 2/5] iio: adc: stm32: make core adc clock optional by default Fabrice Gasnier
2017-06-03 9:28 ` Jonathan Cameron
2017-05-29 9:28 ` [PATCH v2 3/5] iio: adc: stm32: introduce compatible data cfg Fabrice Gasnier
2017-06-03 9:28 ` Jonathan Cameron
2017-05-29 9:28 ` [PATCH v2 4/5] iio: adc: stm32: make per instance bus clock optional Fabrice Gasnier
2017-06-03 9:29 ` Jonathan Cameron [this message]
2017-05-29 9:28 ` [PATCH v2 5/5] iio: adc: stm32: add support for STM32H7 Fabrice Gasnier
2017-06-03 9:32 ` 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=20170603102910.521cab86@kernel.org \
--to=jic23@kernel.org \
--cc=alexandre.torgue@st.com \
--cc=benjamin.gaignard@linaro.org \
--cc=benjamin.gaignard@st.com \
--cc=devicetree@vger.kernel.org \
--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@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=pmeerw@pmeerw.net \
--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).