public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: John Keeping <john@metanate.com>
To: Peter Cai <peter@typeblog.net>
Cc: u-boot@lists.denx.de, Simon Glass <sjg@chromium.org>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Kever Yang <kever.yang@rock-chips.com>
Subject: Re: [PATCH] adc: rockchip-saradc: add support for getting reference voltage value
Date: Thu, 3 Feb 2022 17:42:01 +0000	[thread overview]
Message-ID: <YfwT6THRwF/3+Os+@donbot> (raw)
In-Reply-To: <20220202181254.300829-1-peter@typeblog.net>

On Wed, Feb 02, 2022 at 01:12:54PM -0500, Peter Cai wrote:
> Mirroring commit 97ab802aa36f ("adc: meson-saradc: add support for
> getting reference voltage value") for meson-saradc, this adds support
> for getting the "vref-supply" regulator and register it as the ADC's
> reference voltage regulator, so clients can translate sampled ADC values
> to voltage.
> 
> Signed-off-by: Peter Cai <peter@typeblog.net>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Kever Yang <kever.yang@rock-chips.com>

One code style nit below, but:

Reviewed-by: John Keeping <john@metanate.com>
Tested-by: John Keeping <john@metanate.com>

The results from this look good on RK3288.

> ---
>  drivers/adc/rockchip-saradc.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
> index e464d33f2267..67c11d896e8d 100644
> --- a/drivers/adc/rockchip-saradc.c
> +++ b/drivers/adc/rockchip-saradc.c
> @@ -13,6 +13,7 @@
>  #include <asm/io.h>
>  #include <linux/bitops.h>
>  #include <linux/err.h>
> +#include <power/regulator.h>
>  
>  #define SARADC_CTRL_CHN_MASK		GENMASK(2, 0)
>  #define SARADC_CTRL_POWER_CTRL		BIT(3)
> @@ -100,8 +101,11 @@ int rockchip_saradc_stop(struct udevice *dev)
>  
>  int rockchip_saradc_probe(struct udevice *dev)
>  {
> +	struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev);
>  	struct rockchip_saradc_priv *priv = dev_get_priv(dev);
>  	struct clk clk;
> +	struct udevice *vref;

Should vref be above clk to keep the reverse Christmas tree order of
decreasing line length?

> +	int vref_uv;
>  	int ret;
>  
>  	ret = clk_get_by_index(dev, 0, &clk);
> @@ -114,6 +118,23 @@ int rockchip_saradc_probe(struct udevice *dev)
>  
>  	priv->active_channel = -1;
>  
> +	ret = device_get_supply_regulator(dev, "vref-supply", &vref);
> +	if (ret) {
> +		printf("can't get vref-supply: %d\n", ret);
> +		return ret;
> +	}
> +
> +	vref_uv = regulator_get_value(vref);
> +	if (vref_uv < 0) {
> +		printf("can't get vref-supply value: %d\n", vref_uv);
> +		return vref_uv;
> +	}
> +
> +	/* VDD supplied by common vref pin */
> +	uc_pdata->vdd_supply = vref;
> +	uc_pdata->vdd_microvolts = vref_uv;
> +	uc_pdata->vss_microvolts = 0;
> +
>  	return 0;
>  }
>  
> -- 
> 2.35.0
> 

      reply	other threads:[~2022-02-03 17:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 18:12 [PATCH] adc: rockchip-saradc: add support for getting reference voltage value Peter Cai
2022-02-03 17:42 ` John Keeping [this message]

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=YfwT6THRwF/3+Os+@donbot \
    --to=john@metanate.com \
    --cc=kever.yang@rock-chips.com \
    --cc=peter@typeblog.net \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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