* [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999.
@ 2021-09-08 15:25 Florian Boor
2021-09-08 15:25 ` [PATCH v2 2/2] dt-binding: iio: Add documentation for AD799x driver Florian Boor
2021-09-11 16:43 ` [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Jonathan Cameron
0 siblings, 2 replies; 5+ messages in thread
From: Florian Boor @ 2021-09-08 15:25 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Jonathan.Cameron, Michael.Hennerich, Florian Boor
Make use of the AD7991_REF_SEL bit and support using the external
reference voltage if 'vref-supply' is present.
Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
---
Changes in v2:
- Check if a provided external vref regulator is provided.
- Drop unused setting
- Add ad79xx documentation (second patch)
drivers/iio/adc/ad799x.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index 18bf8386d50a..2ff926a4e9b3 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -770,6 +770,8 @@ static int ad799x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int ret;
+ int extra_config = 0;
+ bool vref_external = true;
struct ad799x_state *st;
struct iio_dev *indio_dev;
const struct ad799x_chip_info *chip_info =
@@ -797,7 +799,15 @@ static int ad799x_probe(struct i2c_client *client,
ret = regulator_enable(st->reg);
if (ret)
return ret;
- st->vref = devm_regulator_get(&client->dev, "vref");
+
+ /* check if an external reference is supplied */
+ st->vref = devm_regulator_get_optional(&client->dev, "vref");
+
+ if (PTR_ERR(st->vref) == -ENODEV) {
+ vref_external = false;
+ /* get dummy */
+ st->vref = devm_regulator_get(&client->dev, "vref");
+ }
if (IS_ERR(st->vref)) {
ret = PTR_ERR(st->vref);
goto error_disable_reg;
@@ -806,6 +816,13 @@ static int ad799x_probe(struct i2c_client *client,
if (ret)
goto error_disable_reg;
+ /* use external reference voltage, optional if regulator present */
+ if (vref_external &&
+ ((st->id == ad7991) || (st->id == ad7995) || (st->id == ad7999))) {
+ dev_info(&client->dev, "Using external reference voltage\n");
+ extra_config |= AD7991_REF_SEL;
+ }
+
st->client = client;
indio_dev->name = id->name;
@@ -815,7 +832,7 @@ static int ad799x_probe(struct i2c_client *client,
indio_dev->channels = st->chip_config->channel;
indio_dev->num_channels = chip_info->num_channels;
- ret = ad799x_update_config(st, st->chip_config->default_config);
+ ret = ad799x_update_config(st, st->chip_config->default_config | extra_config);
if (ret)
goto error_disable_vref;
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] dt-binding: iio: Add documentation for AD799x driver
2021-09-08 15:25 [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Florian Boor
@ 2021-09-08 15:25 ` Florian Boor
2021-09-11 16:34 ` Jonathan Cameron
2021-09-11 16:43 ` [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Jonathan Cameron
1 sibling, 1 reply; 5+ messages in thread
From: Florian Boor @ 2021-09-08 15:25 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Jonathan.Cameron, Michael.Hennerich, Florian Boor
New documentation for AD799x series of I²C ADC ICs.
Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
---
.../bindings/iio/adc/adi,ad799x.yaml | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml
diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml
new file mode 100644
index 000000000000..90b3b01482fe
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/adi,ad799x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AD7991, AD7992, AD7993, AD7994, AD7995, AD7997, AD7998,
+ AD7999 and similar analog to digital converters
+
+maintainers:
+ - Michael Hennerich, Analog Devices Inc. <Michael.Hennerich@analog.com>
+
+description: |
+ Specifications on the converters can be found at:
+ AD7991, AD7995, AD7999:
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD7991_7995_7999.pdf
+ AD7992:
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD7992.pdf
+ AD7993, AD7994:
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD7993_7994.pdf
+ AD7997, AD7998:
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD7997_7998.pdf
+
+properties:
+ compatible:
+ enum:
+ - adi,ad7991
+ - adi,ad7992
+ - adi,ad7993
+ - adi,ad7994
+ - adi,ad7995
+ - adi,ad7997
+ - adi,ad7998
+ - adi,ad7999
+
+ reg:
+ maxItems: 1
+
+ vcc-supply:
+ description:
+ ADC power supply
+
+ vref-supply:
+ description:
+ ADC reference voltage supply, optional for AD7991, AD7995 and AD7999
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ adc1: ad7991@28 {
+ reg = <0x28>;
+ compatible = "adi,ad7991";
+ vcc-supply = <&vcc_3v3>;
+ vref-supply = <&adc_vref>;
+ };
+...
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] dt-binding: iio: Add documentation for AD799x driver
2021-09-08 15:25 ` [PATCH v2 2/2] dt-binding: iio: Add documentation for AD799x driver Florian Boor
@ 2021-09-11 16:34 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2021-09-11 16:34 UTC (permalink / raw)
To: Florian Boor; +Cc: linux-iio, Jonathan.Cameron, Michael.Hennerich
On Wed, 8 Sep 2021 17:25:25 +0200
Florian Boor <florian.boor@kernelconcepts.de> wrote:
> New documentation for AD799x series of I²C ADC ICs.
interrupts?
Otherwise seems to match what the driver support.
Thanks,
Jonathan
>
> Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
> ---
> .../bindings/iio/adc/adi,ad799x.yaml | 61 +++++++++++++++++++
> 1 file changed, 61 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml
> new file mode 100644
> index 000000000000..90b3b01482fe
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad799x.yaml
> @@ -0,0 +1,61 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/adc/adi,ad799x.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices AD7991, AD7992, AD7993, AD7994, AD7995, AD7997, AD7998,
> + AD7999 and similar analog to digital converters
> +
> +maintainers:
> + - Michael Hennerich, Analog Devices Inc. <Michael.Hennerich@analog.com>
> +
> +description: |
> + Specifications on the converters can be found at:
> + AD7991, AD7995, AD7999:
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7991_7995_7999.pdf
> + AD7992:
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7992.pdf
> + AD7993, AD7994:
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7993_7994.pdf
> + AD7997, AD7998:
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7997_7998.pdf
> +
> +properties:
> + compatible:
> + enum:
> + - adi,ad7991
> + - adi,ad7992
> + - adi,ad7993
> + - adi,ad7994
> + - adi,ad7995
> + - adi,ad7997
> + - adi,ad7998
> + - adi,ad7999
> +
> + reg:
> + maxItems: 1
> +
> + vcc-supply:
> + description:
> + ADC power supply
> +
> + vref-supply:
> + description:
> + ADC reference voltage supply, optional for AD7991, AD7995 and AD7999
> +
> +required:
> + - compatible
> + - reg
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + adc1: ad7991@28 {
> + reg = <0x28>;
> + compatible = "adi,ad7991";
> + vcc-supply = <&vcc_3v3>;
> + vref-supply = <&adc_vref>;
> + };
> +...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999.
2021-09-08 15:25 [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Florian Boor
2021-09-08 15:25 ` [PATCH v2 2/2] dt-binding: iio: Add documentation for AD799x driver Florian Boor
@ 2021-09-11 16:43 ` Jonathan Cameron
2021-09-14 13:21 ` Florian Boor
1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2021-09-11 16:43 UTC (permalink / raw)
To: Florian Boor; +Cc: linux-iio, Jonathan.Cameron, Michael.Hennerich
On Wed, 8 Sep 2021 17:25:24 +0200
Florian Boor <florian.boor@kernelconcepts.de> wrote:
> Make use of the AD7991_REF_SEL bit and support using the external
> reference voltage if 'vref-supply' is present.
>
> Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
Hi Florian,
> ---
>
> Changes in v2:
> - Check if a provided external vref regulator is provided.
> - Drop unused setting
> - Add ad79xx documentation (second patch)
>
> drivers/iio/adc/ad799x.c | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
> index 18bf8386d50a..2ff926a4e9b3 100644
> --- a/drivers/iio/adc/ad799x.c
> +++ b/drivers/iio/adc/ad799x.c
> @@ -770,6 +770,8 @@ static int ad799x_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> int ret;
> + int extra_config = 0;
> + bool vref_external = true;
> struct ad799x_state *st;
> struct iio_dev *indio_dev;
> const struct ad799x_chip_info *chip_info =
> @@ -797,7 +799,15 @@ static int ad799x_probe(struct i2c_client *client,
> ret = regulator_enable(st->reg);
> if (ret)
> return ret;
> - st->vref = devm_regulator_get(&client->dev, "vref");
> +
> + /* check if an external reference is supplied */
> + st->vref = devm_regulator_get_optional(&client->dev, "vref");
> +
> + if (PTR_ERR(st->vref) == -ENODEV) {
> + vref_external = false;
> + /* get dummy */
> + st->vref = devm_regulator_get(&client->dev, "vref");
Why? Instead of doing this add if (st->vref) around the regulator
enable and disable. We don't want to pretend there is a regulator when
there isn't one connected and we are using VDD as the reference.
If we are in that mode, we need to change which regulator is read in
read_raw()
> + }
> if (IS_ERR(st->vref)) {
> ret = PTR_ERR(st->vref);
> goto error_disable_reg;
> @@ -806,6 +816,13 @@ static int ad799x_probe(struct i2c_client *client,
> if (ret)
> goto error_disable_reg;
>
> + /* use external reference voltage, optional if regulator present */
> + if (vref_external &&
> + ((st->id == ad7991) || (st->id == ad7995) || (st->id == ad7999))) {
> + dev_info(&client->dev, "Using external reference voltage\n");
> + extra_config |= AD7991_REF_SEL;
> + }
> +
> st->client = client;
>
> indio_dev->name = id->name;
> @@ -815,7 +832,7 @@ static int ad799x_probe(struct i2c_client *client,
> indio_dev->channels = st->chip_config->channel;
> indio_dev->num_channels = chip_info->num_channels;
>
> - ret = ad799x_update_config(st, st->chip_config->default_config);
> + ret = ad799x_update_config(st, st->chip_config->default_config | extra_config);
> if (ret)
> goto error_disable_vref;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999.
2021-09-11 16:43 ` [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Jonathan Cameron
@ 2021-09-14 13:21 ` Florian Boor
0 siblings, 0 replies; 5+ messages in thread
From: Florian Boor @ 2021-09-14 13:21 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Jonathan.Cameron, Michael.Hennerich
Hi Jonathan,
On 11.09.21 18:43, Jonathan Cameron wrote:
> On Wed, 8 Sep 2021 17:25:24 +0200
> Florian Boor <florian.boor@kernelconcepts.de> wrote:
>
>> Make use of the AD7991_REF_SEL bit and support using the external
>> reference voltage if 'vref-supply' is present.
>>
>> Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
>
> Hi Florian,
>
>> ---
>>
>> Changes in v2:
>> - Check if a provided external vref regulator is provided.
>> - Drop unused setting
>> - Add ad79xx documentation (second patch)
>>
>> drivers/iio/adc/ad799x.c | 21 +++++++++++++++++++--
>> 1 file changed, 19 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
>> index 18bf8386d50a..2ff926a4e9b3 100644
>> --- a/drivers/iio/adc/ad799x.c
>> +++ b/drivers/iio/adc/ad799x.c
>> @@ -770,6 +770,8 @@ static int ad799x_probe(struct i2c_client *client,
>> const struct i2c_device_id *id)
>> {
>> int ret;
>> + int extra_config = 0;
>> + bool vref_external = true;
>> struct ad799x_state *st;
>> struct iio_dev *indio_dev;
>> const struct ad799x_chip_info *chip_info =
>> @@ -797,7 +799,15 @@ static int ad799x_probe(struct i2c_client *client,
>> ret = regulator_enable(st->reg);
>> if (ret)
>> return ret;
>> - st->vref = devm_regulator_get(&client->dev, "vref");
>> +
>> + /* check if an external reference is supplied */
>> + st->vref = devm_regulator_get_optional(&client->dev, "vref");
>> +
>> + if (PTR_ERR(st->vref) == -ENODEV) {
>> + vref_external = false;
>> + /* get dummy */
>> + st->vref = devm_regulator_get(&client->dev, "vref");
>
> Why? Instead of doing this add if (st->vref) around the regulator
> enable and disable. We don't want to pretend there is a regulator when
> there isn't one connected and we are using VDD as the reference.
>
> If we are in that mode, we need to change which regulator is read in
> read_raw()
I have to admit I wondered about how this is handled as well. My idea was not to
change it at this point and improve this later in a separate patch.
But I see the point - I'll add this change as well.
Greetings
Florian
--
The dream of yesterday Florian Boor
is the hope of today Tel: +49(0) 271-338857-15
and the reality of tomorrow. Fax: +49(0) 271-338857-29
[Robert Hutchings Goddard, 1904] florian.boor@kernelconcepts.de
http://www.kernelconcepts.de/en
kernel concepts GmbH
Hauptstraße 16
57074 Siegen
Deutschland
Geschäftsführer: Ole Reinhardt
HR Siegen, HR B 9613
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-14 13:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 15:25 [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Florian Boor
2021-09-08 15:25 ` [PATCH v2 2/2] dt-binding: iio: Add documentation for AD799x driver Florian Boor
2021-09-11 16:34 ` Jonathan Cameron
2021-09-11 16:43 ` [PATCH v2 1/2] iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999 Jonathan Cameron
2021-09-14 13:21 ` Florian Boor
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.