From: jic23@kernel.org (Jonathan Cameron)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 1/5] iio: adc: meson-saradc: fix the bit_idx of the adc_en clock
Date: Sun, 19 Nov 2017 15:43:55 +0000 [thread overview]
Message-ID: <20171119154355.5809ed79@archlinux> (raw)
In-Reply-To: <20171031200147.14660-2-martin.blumenstingl@googlemail.com>
On Tue, 31 Oct 2017 21:01:43 +0100
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
> Meson8 and Meson8b SoCs use the the SAR ADC gate clock provided by the
> MESON_SAR_ADC_REG3 register within the SAR ADC register area.
> According to the datasheet (and the existing MESON_SAR_ADC_REG3_CLK_EN
> definition) the gate is on bit 30.
> The fls() function returns the last set bit, which is "bit index + 1"
> (fls(MESON_SAR_ADC_REG3_CLK_EN) returns 31). Fix this by switching to
> __ffs() which returns the first set bit, which is bit 30 in our case.
>
> This off by one error results in the ADC not being usable on devices
> where the bootloader did not enable the clock.
>
> Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
> ---
> drivers/iio/adc/meson_saradc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 2e8dbb89c8c9..55611244c799 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -600,7 +600,7 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev,
> init.num_parents = 1;
>
> priv->clk_gate.reg = base + MESON_SAR_ADC_REG3;
> - priv->clk_gate.bit_idx = fls(MESON_SAR_ADC_REG3_CLK_EN);
> + priv->clk_gate.bit_idx = __ffs(MESON_SAR_ADC_REG3_CLK_EN);
> priv->clk_gate.hw.init = &init;
>
> priv->adc_clk = devm_clk_register(&indio_dev->dev, &priv->clk_gate.hw);
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-iio@vger.kernel.org, knaack.h@gmx.de, lars@metafoo.de,
pmeerw@pmeerw.net, linux-amlogic@lists.infradead.org
Subject: Re: [PATCH 1/5] iio: adc: meson-saradc: fix the bit_idx of the adc_en clock
Date: Sun, 19 Nov 2017 15:43:55 +0000 [thread overview]
Message-ID: <20171119154355.5809ed79@archlinux> (raw)
In-Reply-To: <20171031200147.14660-2-martin.blumenstingl@googlemail.com>
On Tue, 31 Oct 2017 21:01:43 +0100
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
> Meson8 and Meson8b SoCs use the the SAR ADC gate clock provided by the
> MESON_SAR_ADC_REG3 register within the SAR ADC register area.
> According to the datasheet (and the existing MESON_SAR_ADC_REG3_CLK_EN
> definition) the gate is on bit 30.
> The fls() function returns the last set bit, which is "bit index + 1"
> (fls(MESON_SAR_ADC_REG3_CLK_EN) returns 31). Fix this by switching to
> __ffs() which returns the first set bit, which is bit 30 in our case.
>
> This off by one error results in the ADC not being usable on devices
> where the bootloader did not enable the clock.
>
> Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
> ---
> drivers/iio/adc/meson_saradc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 2e8dbb89c8c9..55611244c799 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -600,7 +600,7 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev,
> init.num_parents = 1;
>
> priv->clk_gate.reg = base + MESON_SAR_ADC_REG3;
> - priv->clk_gate.bit_idx = fls(MESON_SAR_ADC_REG3_CLK_EN);
> + priv->clk_gate.bit_idx = __ffs(MESON_SAR_ADC_REG3_CLK_EN);
> priv->clk_gate.hw.init = &init;
>
> priv->adc_clk = devm_clk_register(&indio_dev->dev, &priv->clk_gate.hw);
next prev parent reply other threads:[~2017-11-19 15:43 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 20:01 [PATCH 0/5] meson_saradc fixes and minor improvements Martin Blumenstingl
2017-10-31 20:01 ` Martin Blumenstingl
2017-10-31 20:01 ` [PATCH 1/5] iio: adc: meson-saradc: fix the bit_idx of the adc_en clock Martin Blumenstingl
2017-10-31 20:01 ` Martin Blumenstingl
2017-11-19 15:43 ` Jonathan Cameron [this message]
2017-11-19 15:43 ` Jonathan Cameron
2017-10-31 20:01 ` [PATCH 2/5] iio: adc: meson-saradc: initialize the bandgap correctly on older SoCs Martin Blumenstingl
2017-10-31 20:01 ` Martin Blumenstingl
2017-11-19 15:44 ` Jonathan Cameron
2017-11-19 15:44 ` Jonathan Cameron
2017-10-31 20:01 ` [PATCH 3/5] iio: adc: meson-saradc: Meson8 and Meson8b do not have REG11 and REG13 Martin Blumenstingl
2017-10-31 20:01 ` Martin Blumenstingl
2017-11-19 15:46 ` Jonathan Cameron
2017-11-19 15:46 ` Jonathan Cameron
2017-10-31 20:01 ` [PATCH 4/5] iio: adc: meson-saradc: fix the clock frequency on Meson8 and Meson8b Martin Blumenstingl
2017-10-31 20:01 ` Martin Blumenstingl
2017-11-19 15:55 ` Jonathan Cameron
2017-11-19 15:55 ` Jonathan Cameron
2017-12-10 19:47 ` Jonathan Cameron
2017-12-10 19:47 ` Jonathan Cameron
2017-10-31 20:01 ` [PATCH 5/5] iio: adc: meson-saradc: program the channel muxes during initialization Martin Blumenstingl
2017-10-31 20:01 ` Martin Blumenstingl
2017-11-19 15:57 ` Jonathan Cameron
2017-11-19 15:57 ` Jonathan Cameron
2017-12-10 19:49 ` Jonathan Cameron
2017-12-10 19:49 ` Jonathan Cameron
2017-11-02 15:05 ` [PATCH 0/5] meson_saradc fixes and minor improvements Jonathan Cameron
2017-11-02 15:05 ` Jonathan Cameron
2017-11-27 23:47 ` Kevin Hilman
2017-11-27 23:47 ` Kevin Hilman
2017-12-02 11:30 ` Jonathan Cameron
2017-12-02 11:30 ` Jonathan Cameron
2017-12-10 17:48 ` Martin Blumenstingl
2017-12-10 17:48 ` Martin Blumenstingl
2017-12-10 19:50 ` Jonathan Cameron
2017-12-10 19:50 ` Jonathan Cameron
2017-12-10 22:27 ` Martin Blumenstingl
2017-12-10 22:27 ` Martin Blumenstingl
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=20171119154355.5809ed79@archlinux \
--to=jic23@kernel.org \
--cc=linus-amlogic@lists.infradead.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 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.