[PATCH v2 2/2] iio: adc: ad7606: add enabling of optional Vrefin voltage

Angelo Dureghello posted 2 patches 6 months, 2 weeks ago
[PATCH v2 2/2] iio: adc: ad7606: add enabling of optional Vrefin voltage
Posted by Angelo Dureghello 6 months, 2 weeks ago
From: Angelo Dureghello <adureghello@baylibre.com>

Add optional refin voltage enabling. The property "refin-supply" is
already available and optional in the current fdt dt_schema.

Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
 drivers/iio/adc/ad7606.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..4fd9638eb6e56f800c7c97425e45e04f269e3df7 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -1335,6 +1335,11 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
 		return dev_err_probe(dev, ret,
 				     "Failed to enable Vdrive supply\n");
 
+	ret = devm_regulator_get_enable_optional(dev, "refin");
+	if (ret && ret != -ENODEV)
+		return dev_err_probe(dev, ret,
+				     "failed to enable REFIN voltage\n");
+
 	st->chip_info = chip_info;
 
 	if (st->chip_info->oversampling_num) {

-- 
2.49.0
Re: [PATCH v2 2/2] iio: adc: ad7606: add enabling of optional Vrefin voltage
Posted by Jonathan Cameron 6 months, 2 weeks ago
On Fri, 30 May 2025 16:27:57 +0200
Angelo Dureghello <adureghello@baylibre.com> wrote:

> From: Angelo Dureghello <adureghello@baylibre.com>
> 
> Add optional refin voltage enabling. The property "refin-supply" is
> already available and optional in the current fdt dt_schema.

Good to call out either as a comment and/or in the patch description
that we don't need to do anything 'different' dependent on whether
this exists or not because it is coupled with an external pin that
should be tied low to use this supply.

> 
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
>  drivers/iio/adc/ad7606.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..4fd9638eb6e56f800c7c97425e45e04f269e3df7 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -1335,6 +1335,11 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
>  		return dev_err_probe(dev, ret,
>  				     "Failed to enable Vdrive supply\n");
>  
> +	ret = devm_regulator_get_enable_optional(dev, "refin");
> +	if (ret && ret != -ENODEV)
> +		return dev_err_probe(dev, ret,
> +				     "failed to enable REFIN voltage\n");
> +
>  	st->chip_info = chip_info;
>  
>  	if (st->chip_info->oversampling_num) {
>
Re: [PATCH v2 2/2] iio: adc: ad7606: add enabling of optional Vrefin voltage
Posted by David Lechner 6 months, 2 weeks ago
On 5/30/25 9:27 AM, Angelo Dureghello wrote:
> From: Angelo Dureghello <adureghello@baylibre.com>
> 
> Add optional refin voltage enabling. The property "refin-supply" is
> already available and optional in the current fdt dt_schema.
> 
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
>  drivers/iio/adc/ad7606.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..4fd9638eb6e56f800c7c97425e45e04f269e3df7 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -1335,6 +1335,11 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
>  		return dev_err_probe(dev, ret,
>  				     "Failed to enable Vdrive supply\n");
>  
> +	ret = devm_regulator_get_enable_optional(dev, "refin");
> +	if (ret && ret != -ENODEV)
> +		return dev_err_probe(dev, ret,
> +				     "failed to enable REFIN voltage\n");

s/failed/Failed/
s/voltage/supply/

to be consistent with AVcc and Vdrive messages

> +
>  	st->chip_info = chip_info;
>  
>  	if (st->chip_info->oversampling_num) {
>
Re: [PATCH v2 2/2] iio: adc: ad7606: add enabling of optional Vrefin voltage
Posted by Jonathan Cameron 6 months, 2 weeks ago
On Fri, 30 May 2025 10:39:27 -0500
David Lechner <dlechner@baylibre.com> wrote:

> On 5/30/25 9:27 AM, Angelo Dureghello wrote:
> > From: Angelo Dureghello <adureghello@baylibre.com>
> > 
> > Add optional refin voltage enabling. The property "refin-supply" is
> > already available and optional in the current fdt dt_schema.
> > 
> > Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Tweaked and applied. 

I also added:

Note that the driver does not need to take any actions if the supply
is not present because a pin strap is used to change the behavior
of the device if an external reference is connected.

To the description

(applied patch 1 as well)

> > ---
> >  drivers/iio/adc/ad7606.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> > index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..4fd9638eb6e56f800c7c97425e45e04f269e3df7 100644
> > --- a/drivers/iio/adc/ad7606.c
> > +++ b/drivers/iio/adc/ad7606.c
> > @@ -1335,6 +1335,11 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
> >  		return dev_err_probe(dev, ret,
> >  				     "Failed to enable Vdrive supply\n");
> >  
> > +	ret = devm_regulator_get_enable_optional(dev, "refin");
> > +	if (ret && ret != -ENODEV)
> > +		return dev_err_probe(dev, ret,
> > +				     "failed to enable REFIN voltage\n");  
> 
> s/failed/Failed/
> s/voltage/supply/
> 
> to be consistent with AVcc and Vdrive messages
> 
> > +
> >  	st->chip_info = chip_info;
> >  
> >  	if (st->chip_info->oversampling_num) {
> >   
>