linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 2/5] iio: adc: meson-saradc: initialize the bandgap correctly on older SoCs
Date: Sun, 19 Nov 2017 15:44:22 +0000	[thread overview]
Message-ID: <20171119154422.3716b00e@archlinux> (raw)
In-Reply-To: <20171031200147.14660-3-martin.blumenstingl@googlemail.com>

On Tue, 31 Oct 2017 21:01:44 +0100
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> Meson8 and Meson8b do not have the MESON_SAR_ADC_REG11 register. The
> bandgap setting for these SoCs is configured in the
> MESON_SAR_ADC_DELTA_10 register instead.
> Make the driver aware of this difference and use the correct bandgap
> register depending on the SoC.
> This has worked fine on Meson8 and Meson8b because the bootloader is
> already initializing the bandgap setting.
> 
> Fixes: 6c76ed31cd05 ("iio: adc: meson-saradc: add Meson8b SoC compatibility")
> 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 | 33 ++++++++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 55611244c799..abe9df879b2a 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -221,6 +221,7 @@ enum meson_sar_adc_chan7_mux_sel {
>  
>  struct meson_sar_adc_data {
>  	bool					has_bl30_integration;
> +	u32					bandgap_reg;
>  	unsigned int				resolution;
>  	const char				*name;
>  };
> @@ -685,6 +686,20 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
>  	return 0;
>  }
>  
> +static void meson_sar_adc_set_bandgap(struct iio_dev *indio_dev, bool on_off)
> +{
> +	struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
> +	u32 enable_mask;
> +
> +	if (priv->data->bandgap_reg == MESON_SAR_ADC_REG11)
> +		enable_mask = MESON_SAR_ADC_REG11_BANDGAP_EN;
> +	else
> +		enable_mask = MESON_SAR_ADC_DELTA_10_TS_VBG_EN;
> +
> +	regmap_update_bits(priv->regmap, priv->data->bandgap_reg, enable_mask,
> +			   on_off ? enable_mask : 0);
> +}
> +
>  static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
>  {
>  	struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
> @@ -717,9 +732,9 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
>  	regval = FIELD_PREP(MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, 1);
>  	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0,
>  			   MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, regval);
> -	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11,
> -			   MESON_SAR_ADC_REG11_BANDGAP_EN,
> -			   MESON_SAR_ADC_REG11_BANDGAP_EN);
> +
> +	meson_sar_adc_set_bandgap(indio_dev, true);
> +
>  	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
>  			   MESON_SAR_ADC_REG3_ADC_EN,
>  			   MESON_SAR_ADC_REG3_ADC_EN);
> @@ -739,8 +754,7 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
>  err_adc_clk:
>  	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
>  			   MESON_SAR_ADC_REG3_ADC_EN, 0);
> -	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11,
> -			   MESON_SAR_ADC_REG11_BANDGAP_EN, 0);
> +	meson_sar_adc_set_bandgap(indio_dev, false);
>  	clk_disable_unprepare(priv->sana_clk);
>  err_sana_clk:
>  	clk_disable_unprepare(priv->core_clk);
> @@ -765,8 +779,8 @@ static int meson_sar_adc_hw_disable(struct iio_dev *indio_dev)
>  
>  	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
>  			   MESON_SAR_ADC_REG3_ADC_EN, 0);
> -	regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11,
> -			   MESON_SAR_ADC_REG11_BANDGAP_EN, 0);
> +
> +	meson_sar_adc_set_bandgap(indio_dev, false);
>  
>  	clk_disable_unprepare(priv->sana_clk);
>  	clk_disable_unprepare(priv->core_clk);
> @@ -845,30 +859,35 @@ static const struct iio_info meson_sar_adc_iio_info = {
>  
>  static const struct meson_sar_adc_data meson_sar_adc_meson8_data = {
>  	.has_bl30_integration = false,
> +	.bandgap_reg = MESON_SAR_ADC_DELTA_10,
>  	.resolution = 10,
>  	.name = "meson-meson8-saradc",
>  };
>  
>  static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = {
>  	.has_bl30_integration = false,
> +	.bandgap_reg = MESON_SAR_ADC_DELTA_10,
>  	.resolution = 10,
>  	.name = "meson-meson8b-saradc",
>  };
>  
>  static const struct meson_sar_adc_data meson_sar_adc_gxbb_data = {
>  	.has_bl30_integration = true,
> +	.bandgap_reg = MESON_SAR_ADC_REG11,
>  	.resolution = 10,
>  	.name = "meson-gxbb-saradc",
>  };
>  
>  static const struct meson_sar_adc_data meson_sar_adc_gxl_data = {
>  	.has_bl30_integration = true,
> +	.bandgap_reg = MESON_SAR_ADC_REG11,
>  	.resolution = 12,
>  	.name = "meson-gxl-saradc",
>  };
>  
>  static const struct meson_sar_adc_data meson_sar_adc_gxm_data = {
>  	.has_bl30_integration = true,
> +	.bandgap_reg = MESON_SAR_ADC_REG11,
>  	.resolution = 12,
>  	.name = "meson-gxm-saradc",
>  };


  reply	other threads:[~2017-11-19 15:44 UTC|newest]

Thread overview: 19+ 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 ` [PATCH 1/5] iio: adc: meson-saradc: fix the bit_idx of the adc_en clock Martin Blumenstingl
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-11-19 15:44   ` Jonathan Cameron [this message]
2017-10-31 20:01 ` [PATCH 3/5] iio: adc: meson-saradc: Meson8 and Meson8b do not have REG11 and REG13 Martin Blumenstingl
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-11-19 15:55   ` 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-11-19 15:57   ` 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-27 23:47   ` Kevin Hilman
2017-12-02 11:30     ` Jonathan Cameron
2017-12-10 17:48       ` Martin Blumenstingl
2017-12-10 19:50         ` Jonathan Cameron
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=20171119154422.3716b00e@archlinux \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.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).