Re: [PATCH] dt-bindings: iio: adc: add adi,ad7780.yaml binding

From: Ardelean, Alexandru
Date: Mon May 20 2019 - 04:35:12 EST


On Sun, 2019-05-19 at 12:32 +0100, Jonathan Cameron wrote:
> [External]
>
>
> On Sat, 18 May 2019 19:41:12 -0300
> Renato Lui Geh <renatogeh@xxxxxxxxx> wrote:
>
> > This patch adds a YAML binding for the Analog Devices AD7780/1 and
> > AD7170/1 analog-to-digital converters.
> >
> > Signed-off-by: Renato Lui Geh <renatogeh@xxxxxxxxx>
>
> One comment inline. I'll also be needing an ack from Analog on this,
> preferably Michael's.
>
> Thanks,
>
> Jonathan
> > ---
> > .../bindings/iio/adc/adi,ad7780.txt | 48 -----------
> > .../bindings/iio/adc/adi,ad7780.yaml | 85 +++++++++++++++++++

You should also update the MAINTAINERS file.
Maybe in a following patch.
It looks like there is not entry in there, so maybe you need to add a new
one.

Something like:


ANALOG DEVICES INC AD7780 DRIVER
M: Michael Hennerich <Michael.Hennerich@xxxxxxxxxx>
M: Renato Lui Geh <renatogeh@xxxxxxxxx>
L: linux-iio@xxxxxxxxxxxxxxx
W: http://ez.analog.com/community/linux-device-drivers
S: Supported
F: drivers/iio/adc/ad7780.c
F: Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml

This should be after this block
ANALOG DEVICES INC AD7768-1 DRIVER

Note that I added you as a co-maintainer.
If you want, you do not need to add that line.

> > 2 files changed, 85 insertions(+), 48 deletions(-)
> > delete mode 100644
> > Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt
> > create mode 100644
> > Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt
> > b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt
> > deleted file mode 100644
> > index 440e52555349..000000000000
> > --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt
> > +++ /dev/null
> > @@ -1,48 +0,0 @@
> > -* Analog Devices AD7170/AD7171/AD7780/AD7781
> > -
> > -Data sheets:
> > -
> > -- AD7170:
> > - *
> > https://www.analog.com/media/en/technical-documentation/data-sheets/AD7170.pdf
> > -- AD7171:
> > - *
> > https://www.analog.com/media/en/technical-documentation/data-sheets/AD7171.pdf
> > -- AD7780:
> > - *
> > https://www.analog.com/media/en/technical-documentation/data-sheets/ad7780.pdf
> > -- AD7781:
> > - *
> > https://www.analog.com/media/en/technical-documentation/data-sheets/AD7781.pdf
> > -
> > -Required properties:
> > -
> > -- compatible: should be one of
> > - * "adi,ad7170"
> > - * "adi,ad7171"
> > - * "adi,ad7780"
> > - * "adi,ad7781"
> > -- reg: spi chip select number for the device
> > -- vref-supply: the regulator supply for the ADC reference voltage
> > -
> > -Optional properties:
> > -
> > -- powerdown-gpios: must be the device tree identifier of the PDRST
> > pin. If
> > - specified, it will be asserted during driver probe.
> > As the
> > - line is active high, it should be marked
> > GPIO_ACTIVE_HIGH.
> > -- adi,gain-gpios: must be the device tree identifier of the GAIN
> > pin. Only for
> > - the ad778x chips. If specified, it will be asserted
> > during
> > - driver probe. As the line is active low, it should be
> > marked
> > - GPIO_ACTIVE_LOW.
> > -- adi,filter-gpios: must be the device tree identifier of the FILTER
> > pin. Only
> > - for the ad778x chips. If specified, it will be
> > asserted
> > - during driver probe. As the line is active low, it
> > should be
> > - marked GPIO_ACTIVE_LOW.
> > -
> > -Example:
> > -
> > -adc@0 {
> > - compatible = "adi,ad7780";
> > - reg = <0>;
> > - vref-supply = <&vdd_supply>
> > -
> > - powerdown-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
> > - adi,gain-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
> > - adi,filter-gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
> > -};
> > diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml
> > b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml
> > new file mode 100644
> > index 000000000000..931bc4f8ec04
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml
> > @@ -0,0 +1,85 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/iio/adc/adi,ad7780.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Analog Devices AD7170/AD7171/AD7780/AD7781 analog to digital
> > converters
> > +
> > +maintainers:
> > + - Michael Hennerich <michael.hennerich@xxxxxxxxxx>
> > +
> > +description: |
> > + The ad7780 is a sigma-delta analog to digital converter. This driver
> > provides
> > + reading voltage values and status bits from both the ad778x and
> > ad717x series.
> > + Its interface also allows writing on the FILTER and GAIN GPIO pins
> > on the
> > + ad778x.
> > +
> > + Specifications on the converters can be found at:
> > + AD7170:
> > +
> > https://www.analog.com/media/en/technical-documentation/data-sheets/AD7170.pdf
> > + AD7171:
> > +
> > https://www.analog.com/media/en/technical-documentation/data-sheets/AD7171.pdf
> > + AD7780:
> > +
> > https://www.analog.com/media/en/technical-documentation/data-sheets/ad7780.pdf
> > + AD7781:
> > +
> > https://www.analog.com/media/en/technical-documentation/data-sheets/AD7781.pdf
> > +
> > +properties:
> > + compatible:
> > + enum:
> > + - adi,ad7170
> > + - adi,ad7171
> > + - adi,ad7780
> > + - adi,ad7781
> > +
> > + reg:
> > + description:
> > + Chip select number for the device

No need to add a description.
This is pretty standard.

> > + maxItems: 1
> > +
> > + vref-supply:
> > + description:
> > + The regulator supply for the ADC reference voltage
> > + maxItems: 1
> > +

As I see in the driver, it's not vref-supply, it's avdd-supply.

> > + powerdown-gpios:
> > + description:
> > + Must be the device tree identifier of the PDRST pin. If
> > + specified, it will be asserted during driver probe. As the
> > + line is active high, it should be marked GPIO_ACTIVE_HIGH.
> > + maxItems: 1
> > +
> > + adi,gain-gpios:
> > + description:
> > + Must be the device tree identifier of the GAIN pin. Only for
> > + the ad778x chips. If specified, it will be asserted during
> > + driver probe. As the line is active low, it should be marked
> > + GPIO_ACTIVE_LOW.
> > + maxItems: 1
> > +
> > + adi,filter-gpios:
> > + description:
> > + Must be the device tree identifier of the FILTER pin. Only
> > + for the ad778x chips. If specified, it will be asserted
> > + during driver probe. As the line is active low, it should be
> > + marked GPIO_ACTIVE_LOW.
> > + maxItems: 1
> > +
> > +required:
> > + - compatible
> > + - reg
> > + - vref-supply
>
> Is that actually true? I'd imagine it'll use a stub regulator if
> it isn't supplied.

Hmm, I also think this can be omitted as required.
devm_regulator_get() is used.
devm_regulator_get_exclusive() would be needed to make this required.

>
> > +
> > +examples:
> > + - |
> > + #include <dt-bindings/gpio/gpio.h>
> > + adc@0 {

The adc@0 block should be included in a spi block.

So, something like

spi0 {
adc@0 {
compatible = "adi,ad7780";
reg = <0>;
avdd-supply = <&vdd_supply>

powerdown-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
adi,gain-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
adi,filter-gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
};
};

I know this wasn't the case before, but it should be (from what I recall).

> > + compatible = "adi,ad7780";
> > + reg = <0>;
> > + vref-supply = <&vdd_supply>;
> > +
> > + powerdown-gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
> > + adi,gain-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
> > + adi,filter-gpios = <&gpio2 15 GPIO_ACTIVE_LOW>;

Rest looks good.

Thanks
Alex

> > + };
>
>