Linux IIO development
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support
@ 2025-04-22  8:55 Antoniu Miclaus
  2025-04-22  8:55 ` [PATCH 2/2] iio: dac: ad7293: add adc reference configuration Antoniu Miclaus
  2025-04-25 20:09 ` [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support Rob Herring (Arm)
  0 siblings, 2 replies; 5+ messages in thread
From: Antoniu Miclaus @ 2025-04-22  8:55 UTC (permalink / raw)
  To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel
  Cc: Antoniu Miclaus

Add support for vrefin supply responsible for providing external
reference to the SAR ADC within the part.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 Documentation/devicetree/bindings/iio/dac/adi,ad7293.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad7293.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad7293.yaml
index 5ee80bf6aa11..f994c1ef6d41 100644
--- a/Documentation/devicetree/bindings/iio/dac/adi,ad7293.yaml
+++ b/Documentation/devicetree/bindings/iio/dac/adi,ad7293.yaml
@@ -27,6 +27,8 @@ properties:
 
   vdrive-supply: true
 
+  vrefin-supply: true
+
   reset-gpios:
     maxItems: 1
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] iio: dac: ad7293: add adc reference configuration
  2025-04-22  8:55 [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support Antoniu Miclaus
@ 2025-04-22  8:55 ` Antoniu Miclaus
  2025-04-22 11:41   ` Nuno Sá
  2025-04-25 20:09 ` [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support Rob Herring (Arm)
  1 sibling, 1 reply; 5+ messages in thread
From: Antoniu Miclaus @ 2025-04-22  8:55 UTC (permalink / raw)
  To: jic23, robh, conor+dt, linux-iio, devicetree, linux-kernel
  Cc: Antoniu Miclaus

Add support for configurating the ADC reference (internal/external).

According to the datasheet, the external reference is enabled by
default.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/dac/ad7293.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/iio/dac/ad7293.c b/drivers/iio/dac/ad7293.c
index 99fa2d1f8299..c3797e40cdd9 100644
--- a/drivers/iio/dac/ad7293.c
+++ b/drivers/iio/dac/ad7293.c
@@ -114,6 +114,7 @@
 #define AD7293_REG_DATA_RAW_MSK			GENMASK(15, 4)
 #define AD7293_REG_VINX_RANGE_GET_CH_MSK(x, ch)	(((x) >> (ch)) & 0x1)
 #define AD7293_REG_VINX_RANGE_SET_CH_MSK(x, ch)	(((x) & 0x1) << (ch))
+#define AD7293_GENERAL_ADC_REF_MSK			BIT(7)
 #define AD7293_CHIP_ID				0x18
 
 enum ad7293_ch_type {
@@ -141,6 +142,7 @@ struct ad7293_state {
 	/* Protect against concurrent accesses to the device, page selection and data content */
 	struct mutex lock;
 	struct gpio_desc *gpio_reset;
+	bool vrefin_en;
 	u8 page_select;
 	u8 data[3] __aligned(IIO_DMA_MINALIGN);
 };
@@ -785,6 +787,12 @@ static int ad7293_properties_parse(struct ad7293_state *st)
 	if (ret)
 		return dev_err_probe(&spi->dev, ret, "failed to enable VDRIVE\n");
 
+	ret = devm_regulator_get_enable_optional(&spi->dev, "vrefin");
+	if (ret < 0 && ret != -ENODEV)
+		return dev_err_probe(&spi->dev, ret, "failed to enable VREFIN\n");
+
+	st->vrefin_en = ret != -ENODEV;
+
 	st->gpio_reset = devm_gpiod_get_optional(&st->spi->dev, "reset",
 						 GPIOD_OUT_HIGH);
 	if (IS_ERR(st->gpio_reset))
@@ -818,6 +826,11 @@ static int ad7293_init(struct ad7293_state *st)
 		return -EINVAL;
 	}
 
+	if (!st->vrefin_en)
+		return __ad7293_spi_update_bits(st, AD7293_REG_GENERAL,
+						AD7293_GENERAL_ADC_REF_MSK,
+						AD7293_GENERAL_ADC_REF_MSK);
+
 	return 0;
 }
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] iio: dac: ad7293: add adc reference configuration
  2025-04-22  8:55 ` [PATCH 2/2] iio: dac: ad7293: add adc reference configuration Antoniu Miclaus
@ 2025-04-22 11:41   ` Nuno Sá
  2025-04-26 15:37     ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Nuno Sá @ 2025-04-22 11:41 UTC (permalink / raw)
  To: Antoniu Miclaus, jic23, robh, conor+dt, linux-iio, devicetree,
	linux-kernel

On Tue, 2025-04-22 at 11:55 +0300, Antoniu Miclaus wrote:
> Add support for configurating the ADC reference (internal/external).
> 
> According to the datasheet, the external reference is enabled by
> default.
> 
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---

LGTM:

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

>  drivers/iio/dac/ad7293.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/iio/dac/ad7293.c b/drivers/iio/dac/ad7293.c
> index 99fa2d1f8299..c3797e40cdd9 100644
> --- a/drivers/iio/dac/ad7293.c
> +++ b/drivers/iio/dac/ad7293.c
> @@ -114,6 +114,7 @@
>  #define AD7293_REG_DATA_RAW_MSK			GENMASK(15, 4)
>  #define AD7293_REG_VINX_RANGE_GET_CH_MSK(x, ch)	(((x) >> (ch)) & 0x1)
>  #define AD7293_REG_VINX_RANGE_SET_CH_MSK(x, ch)	(((x) & 0x1) << (ch))
> +#define AD7293_GENERAL_ADC_REF_MSK			BIT(7)
>  #define AD7293_CHIP_ID				0x18
>  
>  enum ad7293_ch_type {
> @@ -141,6 +142,7 @@ struct ad7293_state {
>  	/* Protect against concurrent accesses to the device, page selection
> and data content */
>  	struct mutex lock;
>  	struct gpio_desc *gpio_reset;
> +	bool vrefin_en;
>  	u8 page_select;
>  	u8 data[3] __aligned(IIO_DMA_MINALIGN);
>  };
> @@ -785,6 +787,12 @@ static int ad7293_properties_parse(struct ad7293_state
> *st)
>  	if (ret)
>  		return dev_err_probe(&spi->dev, ret, "failed to enable
> VDRIVE\n");
>  
> +	ret = devm_regulator_get_enable_optional(&spi->dev, "vrefin");
> +	if (ret < 0 && ret != -ENODEV)
> +		return dev_err_probe(&spi->dev, ret, "failed to enable
> VREFIN\n");
> +
> +	st->vrefin_en = ret != -ENODEV;
> +
>  	st->gpio_reset = devm_gpiod_get_optional(&st->spi->dev, "reset",
>  						 GPIOD_OUT_HIGH);
>  	if (IS_ERR(st->gpio_reset))
> @@ -818,6 +826,11 @@ static int ad7293_init(struct ad7293_state *st)
>  		return -EINVAL;
>  	}
>  
> +	if (!st->vrefin_en)
> +		return __ad7293_spi_update_bits(st, AD7293_REG_GENERAL,
> +						AD7293_GENERAL_ADC_REF_MSK,
> +						AD7293_GENERAL_ADC_REF_MSK);
> +
>  	return 0;
>  }
>  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support
  2025-04-22  8:55 [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support Antoniu Miclaus
  2025-04-22  8:55 ` [PATCH 2/2] iio: dac: ad7293: add adc reference configuration Antoniu Miclaus
@ 2025-04-25 20:09 ` Rob Herring (Arm)
  1 sibling, 0 replies; 5+ messages in thread
From: Rob Herring (Arm) @ 2025-04-25 20:09 UTC (permalink / raw)
  To: Antoniu Miclaus; +Cc: conor+dt, linux-iio, devicetree, jic23, linux-kernel


On Tue, 22 Apr 2025 11:55:28 +0300, Antoniu Miclaus wrote:
> Add support for vrefin supply responsible for providing external
> reference to the SAR ADC within the part.
> 
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
>  Documentation/devicetree/bindings/iio/dac/adi,ad7293.yaml | 2 ++
>  1 file changed, 2 insertions(+)
> 

Acked-by: Rob Herring (Arm) <robh@kernel.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] iio: dac: ad7293: add adc reference configuration
  2025-04-22 11:41   ` Nuno Sá
@ 2025-04-26 15:37     ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2025-04-26 15:37 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Antoniu Miclaus, robh, conor+dt, linux-iio, devicetree,
	linux-kernel

On Tue, 22 Apr 2025 12:41:44 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Tue, 2025-04-22 at 11:55 +0300, Antoniu Miclaus wrote:
> > Add support for configurating the ADC reference (internal/external).
> > 
> > According to the datasheet, the external reference is enabled by
> > default.
> > 
> > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> > ---  
> 
> LGTM:
> 
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Series applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-26 15:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22  8:55 [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support Antoniu Miclaus
2025-04-22  8:55 ` [PATCH 2/2] iio: dac: ad7293: add adc reference configuration Antoniu Miclaus
2025-04-22 11:41   ` Nuno Sá
2025-04-26 15:37     ` Jonathan Cameron
2025-04-25 20:09 ` [PATCH 1/2] dt-bindings: iio: dac: ad7293: add vrefin support Rob Herring (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox