diff mbox series

[v4,1/6] dt-bindings: adc: ad7173: add support for ad411x

Message ID 20240531-ad4111-v4-1-64607301c057@analog.com (mailing list archive)
State Changes Requested
Headers show
Series Add support for AD411x | expand

Commit Message

Dumitru Ceclan via B4 Relay May 31, 2024, 7:42 p.m. UTC
From: Dumitru Ceclan <dumitru.ceclan@analog.com>

Add support for: AD4111, AD4112, AD4114, AD4115, AD4116.

AD411x family ADCs support a VCOM pin. The purpose of this pin is to
offer a dedicated common-mode voltage input for single-ended channels.
This pin is specified as supporting a differential channel with VIN10 on
model AD4116.

AD4111/AD4112 support current channels. Support is implemented using
single-channel and "adi,current-channel".

Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>
---
 .../devicetree/bindings/iio/adc/adi,ad7173.yaml    | 192 ++++++++++++++++++++-
 1 file changed, 190 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron June 1, 2024, 6:35 p.m. UTC | #1
On Fri, 31 May 2024 22:42:27 +0300
Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote:

> From: Dumitru Ceclan <dumitru.ceclan@analog.com>
> 
> Add support for: AD4111, AD4112, AD4114, AD4115, AD4116.
> 
> AD411x family ADCs support a VCOM pin. The purpose of this pin is to
> offer a dedicated common-mode voltage input for single-ended channels.
> This pin is specified as supporting a differential channel with VIN10 on
> model AD4116.
> 
> AD4111/AD4112 support current channels. Support is implemented using
> single-channel and "adi,current-channel".
> 
> Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>
I like the common-mode-channel solution to the pseudo differential
description. It makes things explicit whilst avoiding an ugly differential
but not differential mess.

However, it feels like a general thing to me not a vendor specific one.
Perhaps makes sense to put in adc.yaml?

One other question that is more me being curious and failing to understand
the datasheet than a request to change anything.
> ---
>  .../devicetree/bindings/iio/adc/adi,ad7173.yaml    | 192 ++++++++++++++++++++-
>  1 file changed, 190 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> index ea6cfcd0aff4..d8474eee553e 100644
> --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> @@ -19,7 +19,18 @@ description: |
>    primarily for measurement of signals close to DC but also delivers
>    outstanding performance with input bandwidths out to ~10kHz.
>  
> +  Analog Devices AD411x ADC's:
> +  The AD411X family encompasses a series of low power, low noise, 24-bit,
> +  sigma-delta analog-to-digital converters that offer a versatile range of
> +  specifications. They integrate an analog front end suitable for processing
> +  fully differential/single-ended and bipolar voltage inputs.
> +
>    Datasheets for supported chips:
> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4111.pdf
> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4112.pdf
> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4114.pdf
> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4115.pdf
> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4116.pdf
>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-2.pdf
>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7173-8.pdf
> @@ -31,6 +42,11 @@ description: |
>  properties:
>    compatible:
>      enum:
> +      - adi,ad4111
> +      - adi,ad4112
> +      - adi,ad4114
> +      - adi,ad4115
> +      - adi,ad4116
>        - adi,ad7172-2
>        - adi,ad7172-4
>        - adi,ad7173-8
> @@ -129,10 +145,54 @@ patternProperties:
>          maximum: 15
>  
>        diff-channels:
> +        description: |
> +          This property is used for defining the inputs of a differential
> +          voltage channel. The first value is the positive input and the second
> +          value is the negative input of the channel.
> +
> +          Family AD411x supports a dedicated VINCOM voltage input.
> +          To select it set the second channel to 16.
> +            (VIN2, VINCOM) -> diff-channels = <2 16>
> +
> +          There are special values that can be selected besides the voltage
> +          analog inputs:
> +            21: REF+
> +            22: REF−
> +          Supported only by AD7172-2, AD7172-4, AD7175-2, AD7175-8, AD7177-2:
> +            19: ((AVDD1 − AVSS)/5)+
> +            20: ((AVDD1 − AVSS)/5)−

That's what it says on the datasheet (so fine to copy that here) but I'm curious, what does
that mean in practice?  How can we have negative and postive signals of the difference
between two power supply voltages where I'm fairly sure AVDD1 always greater than AVSS.

Anyhow, that's a problem for the person reading the datasheet to figure out :)
 
> +
>          items:
>            minimum: 0
>            maximum: 31
>  
> +      single-channel:
> +        description: |
> +          This property is used for defining a current channel or the positive
> +          input of a voltage channel (single-ended or pseudo-differential).
> +
> +          Models AD4111 and AD4112 support current channels.
> +            Example: (IIN2+, IIN2−) -> single-channel = <2>
> +          To correctly configure a current channel set the "adi,current-channel"
> +          property to true.
> +
> +          To configure a single-ended/pseudo-differential channel set the
> +          "adi,common-mode-channel" property to the desired negative voltage input.
> +
> +          When used as a voltage channel, special inputs are valid as well.
> +        minimum: 0
> +        maximum: 31
> +
> +      adi,common-mode-channel:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description:
> +          This property is used for defining the negative input of a
> +          single-ended or pseudo-differential voltage channel.
> +
> +          Special inputs are valid as well.
> +        minimum: 0
> +        maximum: 31
> +
Ceclan, Dumitru June 3, 2024, 9:46 a.m. UTC | #2
On 01/06/2024 21:35, Jonathan Cameron wrote:
> On Fri, 31 May 2024 22:42:27 +0300
> Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote:
> 
>> From: Dumitru Ceclan <dumitru.ceclan@analog.com>
>>
>> Add support for: AD4111, AD4112, AD4114, AD4115, AD4116.
>>
>> AD411x family ADCs support a VCOM pin. The purpose of this pin is to
>> offer a dedicated common-mode voltage input for single-ended channels.
>> This pin is specified as supporting a differential channel with VIN10 on
>> model AD4116.
>>
>> AD4111/AD4112 support current channels. Support is implemented using
>> single-channel and "adi,current-channel".
>>
>> Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>
> I like the common-mode-channel solution to the pseudo differential
> description. It makes things explicit whilst avoiding an ugly differential
> but not differential mess.
> 
> However, it feels like a general thing to me not a vendor specific one.
> Perhaps makes sense to put in adc.yaml?
> 

Sure

> One other question that is more me being curious and failing to understand
> the datasheet than a request to change anything.
>> ---
>>  .../devicetree/bindings/iio/adc/adi,ad7173.yaml    | 192 ++++++++++++++++++++-
>>  1 file changed, 190 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
>> index ea6cfcd0aff4..d8474eee553e 100644
>> --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
>> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
>> @@ -19,7 +19,18 @@ description: |
>>    primarily for measurement of signals close to DC but also delivers
>>    outstanding performance with input bandwidths out to ~10kHz.
>>  
>> +  Analog Devices AD411x ADC's:
>> +  The AD411X family encompasses a series of low power, low noise, 24-bit,
>> +  sigma-delta analog-to-digital converters that offer a versatile range of
>> +  specifications. They integrate an analog front end suitable for processing
>> +  fully differential/single-ended and bipolar voltage inputs.
>> +
>>    Datasheets for supported chips:
>> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4111.pdf
>> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4112.pdf
>> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4114.pdf
>> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4115.pdf
>> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4116.pdf
>>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-2.pdf
>>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
>>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7173-8.pdf
>> @@ -31,6 +42,11 @@ description: |
>>  properties:
>>    compatible:
>>      enum:
>> +      - adi,ad4111
>> +      - adi,ad4112
>> +      - adi,ad4114
>> +      - adi,ad4115
>> +      - adi,ad4116
>>        - adi,ad7172-2
>>        - adi,ad7172-4
>>        - adi,ad7173-8
>> @@ -129,10 +145,54 @@ patternProperties:
>>          maximum: 15
>>  
>>        diff-channels:
>> +        description: |
>> +          This property is used for defining the inputs of a differential
>> +          voltage channel. The first value is the positive input and the second
>> +          value is the negative input of the channel.
>> +
>> +          Family AD411x supports a dedicated VINCOM voltage input.
>> +          To select it set the second channel to 16.
>> +            (VIN2, VINCOM) -> diff-channels = <2 16>
>> +
>> +          There are special values that can be selected besides the voltage
>> +          analog inputs:
>> +            21: REF+
>> +            22: REF−
>> +          Supported only by AD7172-2, AD7172-4, AD7175-2, AD7175-8, AD7177-2:
>> +            19: ((AVDD1 − AVSS)/5)+
>> +            20: ((AVDD1 − AVSS)/5)−
> 
> That's what it says on the datasheet (so fine to copy that here) but I'm curious, what does
> that mean in practice?  How can we have negative and postive signals of the difference
> between two power supply voltages where I'm fairly sure AVDD1 always greater than AVSS.
>

I have not tested that as I do not have a model that supports this wired up.
If I had to guess they are the same signal but one should be connected to the
positive input, one to the negative input...but I could be wrong.
 
> Anyhow, that's a problem for the person reading the datasheet to figure out :)
>  
>> +
>>          items:
>>            minimum: 0
>>            maximum: 31
>>  
>> +      single-channel:
>> +        description: |
>> +          This property is used for defining a current channel or the positive
>> +          input of a voltage channel (single-ended or pseudo-differential).
>> +
>> +          Models AD4111 and AD4112 support current channels.
>> +            Example: (IIN2+, IIN2−) -> single-channel = <2>
>> +          To correctly configure a current channel set the "adi,current-channel"
>> +          property to true.
>> +
>> +          To configure a single-ended/pseudo-differential channel set the
>> +          "adi,common-mode-channel" property to the desired negative voltage input.
>> +
>> +          When used as a voltage channel, special inputs are valid as well.
>> +        minimum: 0
>> +        maximum: 31
>> +
>> +      adi,common-mode-channel:
>> +        $ref: /schemas/types.yaml#/definitions/uint32
>> +        description:
>> +          This property is used for defining the negative input of a
>> +          single-ended or pseudo-differential voltage channel.
>> +
>> +          Special inputs are valid as well.
>> +        minimum: 0
>> +        maximum: 31
>> +
>
Jonathan Cameron June 3, 2024, 8 p.m. UTC | #3
On Mon, 3 Jun 2024 12:46:10 +0300
"Ceclan, Dumitru" <mitrutzceclan@gmail.com> wrote:

> On 01/06/2024 21:35, Jonathan Cameron wrote:
> > On Fri, 31 May 2024 22:42:27 +0300
> > Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote:
> >   
> >> From: Dumitru Ceclan <dumitru.ceclan@analog.com>
> >>
> >> Add support for: AD4111, AD4112, AD4114, AD4115, AD4116.
> >>
> >> AD411x family ADCs support a VCOM pin. The purpose of this pin is to
> >> offer a dedicated common-mode voltage input for single-ended channels.
> >> This pin is specified as supporting a differential channel with VIN10 on
> >> model AD4116.
> >>
> >> AD4111/AD4112 support current channels. Support is implemented using
> >> single-channel and "adi,current-channel".
> >>
> >> Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>  
> > I like the common-mode-channel solution to the pseudo differential
> > description. It makes things explicit whilst avoiding an ugly differential
> > but not differential mess.
> > 
> > However, it feels like a general thing to me not a vendor specific one.
> > Perhaps makes sense to put in adc.yaml?
> >   
> 
> Sure
> 
> > One other question that is more me being curious and failing to understand
> > the datasheet than a request to change anything.  
> >> ---
> >>  .../devicetree/bindings/iio/adc/adi,ad7173.yaml    | 192 ++++++++++++++++++++-
> >>  1 file changed, 190 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> >> index ea6cfcd0aff4..d8474eee553e 100644
> >> --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> >> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> >> @@ -19,7 +19,18 @@ description: |
> >>    primarily for measurement of signals close to DC but also delivers
> >>    outstanding performance with input bandwidths out to ~10kHz.
> >>  
> >> +  Analog Devices AD411x ADC's:
> >> +  The AD411X family encompasses a series of low power, low noise, 24-bit,
> >> +  sigma-delta analog-to-digital converters that offer a versatile range of
> >> +  specifications. They integrate an analog front end suitable for processing
> >> +  fully differential/single-ended and bipolar voltage inputs.
> >> +
> >>    Datasheets for supported chips:
> >> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4111.pdf
> >> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4112.pdf
> >> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4114.pdf
> >> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4115.pdf
> >> +    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4116.pdf
> >>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-2.pdf
> >>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
> >>      https://www.analog.com/media/en/technical-documentation/data-sheets/AD7173-8.pdf
> >> @@ -31,6 +42,11 @@ description: |
> >>  properties:
> >>    compatible:
> >>      enum:
> >> +      - adi,ad4111
> >> +      - adi,ad4112
> >> +      - adi,ad4114
> >> +      - adi,ad4115
> >> +      - adi,ad4116
> >>        - adi,ad7172-2
> >>        - adi,ad7172-4
> >>        - adi,ad7173-8
> >> @@ -129,10 +145,54 @@ patternProperties:
> >>          maximum: 15
> >>  
> >>        diff-channels:
> >> +        description: |
> >> +          This property is used for defining the inputs of a differential
> >> +          voltage channel. The first value is the positive input and the second
> >> +          value is the negative input of the channel.
> >> +
> >> +          Family AD411x supports a dedicated VINCOM voltage input.
> >> +          To select it set the second channel to 16.
> >> +            (VIN2, VINCOM) -> diff-channels = <2 16>
> >> +
> >> +          There are special values that can be selected besides the voltage
> >> +          analog inputs:
> >> +            21: REF+
> >> +            22: REF−
> >> +          Supported only by AD7172-2, AD7172-4, AD7175-2, AD7175-8, AD7177-2:
> >> +            19: ((AVDD1 − AVSS)/5)+
> >> +            20: ((AVDD1 − AVSS)/5)−  
> > 
> > That's what it says on the datasheet (so fine to copy that here) but I'm curious, what does
> > that mean in practice?  How can we have negative and postive signals of the difference
> > between two power supply voltages where I'm fairly sure AVDD1 always greater than AVSS.
> >  
> 
> I have not tested that as I do not have a model that supports this wired up.
> If I had to guess they are the same signal but one should be connected to the
> positive input, one to the negative input...but I could be wrong.

If they are, then as far as I we are concerned is this one channel with two
representations depending on whether it is 1st or 2nd in the list?
Can we use one number and hide that detail in the driver?

Seems odd though if that is the case.

I guess if we find out later this is the case we can tighten the binding to
enforce the right one instead of squashing them to one value, but that
is a bit ugly.  Any chance of digging out the info?  If not we can go ahead
but ideally answering things like this make a our life easier in the long run.

Jonathan


>  
> > Anyhow, that's a problem for the person reading the datasheet to figure out :)
> >    
> >> +
> >>          items:
> >>            minimum: 0
> >>            maximum: 31
> >>  
> >> +      single-channel:
> >> +        description: |
> >> +          This property is used for defining a current channel or the positive
> >> +          input of a voltage channel (single-ended or pseudo-differential).
> >> +
> >> +          Models AD4111 and AD4112 support current channels.
> >> +            Example: (IIN2+, IIN2−) -> single-channel = <2>
> >> +          To correctly configure a current channel set the "adi,current-channel"
> >> +          property to true.
> >> +
> >> +          To configure a single-ended/pseudo-differential channel set the
> >> +          "adi,common-mode-channel" property to the desired negative voltage input.
> >> +
> >> +          When used as a voltage channel, special inputs are valid as well.
> >> +        minimum: 0
> >> +        maximum: 31
> >> +
> >> +      adi,common-mode-channel:
> >> +        $ref: /schemas/types.yaml#/definitions/uint32
> >> +        description:
> >> +          This property is used for defining the negative input of a
> >> +          single-ended or pseudo-differential voltage channel.
> >> +
> >> +          Special inputs are valid as well.
> >> +        minimum: 0
> >> +        maximum: 31
> >> +  
> >   
>
Ceclan, Dumitru June 5, 2024, 6:54 a.m. UTC | #4
On 03/06/2024 23:00, Jonathan Cameron wrote:
> On Mon, 3 Jun 2024 12:46:10 +0300
> "Ceclan, Dumitru" <mitrutzceclan@gmail.com> wrote:
> 
>> On 01/06/2024 21:35, Jonathan Cameron wrote:
>>> On Fri, 31 May 2024 22:42:27 +0300
>>> Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote:
>>>   
>>>> From: Dumitru Ceclan <dumitru.ceclan@analog.com>

...

>>>> +          Supported only by AD7172-2, AD7172-4, AD7175-2, AD7175-8, AD7177-2:
>>>> +            19: ((AVDD1 − AVSS)/5)+
>>>> +            20: ((AVDD1 − AVSS)/5)−  
>>>
>>> That's what it says on the datasheet (so fine to copy that here) but I'm curious, what does
>>> that mean in practice?  How can we have negative and postive signals of the difference
>>> between two power supply voltages where I'm fairly sure AVDD1 always greater than AVSS.
>>>  
>>
>> I have not tested that as I do not have a model that supports this wired up.
>> If I had to guess they are the same signal but one should be connected to the
>> positive input, one to the negative input...but I could be wrong.
> 
> If they are, then as far as I we are concerned is this one channel with two
> representations depending on whether it is 1st or 2nd in the list?
> Can we use one number and hide that detail in the driver?
> 
> Seems odd though if that is the case.
> 
> I guess if we find out later this is the case we can tighten the binding to
> enforce the right one instead of squashing them to one value, but that
> is a bit ugly.  Any chance of digging out the info?  If not we can go ahead
> but ideally answering things like this make a our life easier in the long run.
> 
> Jonathan
> 

"(Avdd1/Avss)/5+ as positive input and (Avdd/Avss)/5- as negative
  this is used for monitoring power supplies, the inputs must be selected in pair"
Perhaps it's an internal voltage divider...? I dunno

So it seems like this cannot be used as a common mode voltage input.
I'll restrict the driver to only allow these inputs paired together
and rename the define for these selections.
Jonathan Cameron June 6, 2024, 7:58 p.m. UTC | #5
On Wed, 5 Jun 2024 09:54:31 +0300
"Ceclan, Dumitru" <mitrutzceclan@gmail.com> wrote:

> On 03/06/2024 23:00, Jonathan Cameron wrote:
> > On Mon, 3 Jun 2024 12:46:10 +0300
> > "Ceclan, Dumitru" <mitrutzceclan@gmail.com> wrote:
> >   
> >> On 01/06/2024 21:35, Jonathan Cameron wrote:  
> >>> On Fri, 31 May 2024 22:42:27 +0300
> >>> Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote:
> >>>     
> >>>> From: Dumitru Ceclan <dumitru.ceclan@analog.com>  
> 
> ...
> 
> >>>> +          Supported only by AD7172-2, AD7172-4, AD7175-2, AD7175-8, AD7177-2:
> >>>> +            19: ((AVDD1 − AVSS)/5)+
> >>>> +            20: ((AVDD1 − AVSS)/5)−    
> >>>
> >>> That's what it says on the datasheet (so fine to copy that here) but I'm curious, what does
> >>> that mean in practice?  How can we have negative and postive signals of the difference
> >>> between two power supply voltages where I'm fairly sure AVDD1 always greater than AVSS.
> >>>    
> >>
> >> I have not tested that as I do not have a model that supports this wired up.
> >> If I had to guess they are the same signal but one should be connected to the
> >> positive input, one to the negative input...but I could be wrong.  
> > 
> > If they are, then as far as I we are concerned is this one channel with two
> > representations depending on whether it is 1st or 2nd in the list?
> > Can we use one number and hide that detail in the driver?
> > 
> > Seems odd though if that is the case.
> > 
> > I guess if we find out later this is the case we can tighten the binding to
> > enforce the right one instead of squashing them to one value, but that
> > is a bit ugly.  Any chance of digging out the info?  If not we can go ahead
> > but ideally answering things like this make a our life easier in the long run.
> > 
> > Jonathan
> >   
> 
> "(Avdd1/Avss)/5+ as positive input and (Avdd/Avss)/5- as negative
>   this is used for monitoring power supplies, the inputs must be selected in pair"
> Perhaps it's an internal voltage divider...? I dunno
> 
> So it seems like this cannot be used as a common mode voltage input.
> I'll restrict the driver to only allow these inputs paired together
> and rename the define for these selections.
Most mysterious :)  I'd be interested to know what value it reads
back if you ever get the part.

Ah well, great to have gotten that extra detail even if it leaves
more questions!

Jonathan

> 
> 
>
Ceclan, Dumitru June 7, 2024, 7:29 a.m. UTC | #6
On 06/06/2024 22:58, Jonathan Cameron wrote:
> On Wed, 5 Jun 2024 09:54:31 +0300
> "Ceclan, Dumitru" <mitrutzceclan@gmail.com> wrote:
> 
>> On 03/06/2024 23:00, Jonathan Cameron wrote:
>>> On Mon, 3 Jun 2024 12:46:10 +0300
>>> "Ceclan, Dumitru" <mitrutzceclan@gmail.com> wrote:
>>>   
>>>> On 01/06/2024 21:35, Jonathan Cameron wrote:  
>>>>> On Fri, 31 May 2024 22:42:27 +0300
>>>>> Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote:
>>>>>     
>>>>>> From: Dumitru Ceclan <dumitru.ceclan@analog.com>  
>>
>> ...
>>
>>>>>> +          Supported only by AD7172-2, AD7172-4, AD7175-2, AD7175-8, AD7177-2:
>>>>>> +            19: ((AVDD1 − AVSS)/5)+
>>>>>> +            20: ((AVDD1 − AVSS)/5)−    
>>>>>
>>>>> That's what it says on the datasheet (so fine to copy that here) but I'm curious, what does
>>>>> that mean in practice?  How can we have negative and postive signals of the difference
>>>>> between two power supply voltages where I'm fairly sure AVDD1 always greater than AVSS.
>>>>>    
>>>>
>>>> I have not tested that as I do not have a model that supports this wired up.
>>>> If I had to guess they are the same signal but one should be connected to the
>>>> positive input, one to the negative input...but I could be wrong.  
>>>
>>> If they are, then as far as I we are concerned is this one channel with two
>>> representations depending on whether it is 1st or 2nd in the list?
>>> Can we use one number and hide that detail in the driver?
>>>
>>> Seems odd though if that is the case.
>>>
>>> I guess if we find out later this is the case we can tighten the binding to
>>> enforce the right one instead of squashing them to one value, but that
>>> is a bit ugly.  Any chance of digging out the info?  If not we can go ahead
>>> but ideally answering things like this make a our life easier in the long run.
>>>
>>> Jonathan
>>>   
>>
>> "(Avdd1/Avss)/5+ as positive input and (Avdd/Avss)/5- as negative
>>   this is used for monitoring power supplies, the inputs must be selected in pair"
>> Perhaps it's an internal voltage divider...? I dunno
>>
>> So it seems like this cannot be used as a common mode voltage input.
>> I'll restrict the driver to only allow these inputs paired together
>> and rename the define for these selections.
> Most mysterious :)  I'd be interested to know what value it reads
> back if you ever get the part.
>

My best guess now is that the reason for /5 is so that you can measure
the AVDD AVSS difference using the internal 2.5V reference.
So for AVDD 5V, AVSS 0V using the internal ref it would read 1V

I'll let you know if I test this
 
> Ah well, great to have gotten that extra detail even if it leaves
> more questions!
> 
> Jonathan
>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
index ea6cfcd0aff4..d8474eee553e 100644
--- a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
@@ -19,7 +19,18 @@  description: |
   primarily for measurement of signals close to DC but also delivers
   outstanding performance with input bandwidths out to ~10kHz.
 
+  Analog Devices AD411x ADC's:
+  The AD411X family encompasses a series of low power, low noise, 24-bit,
+  sigma-delta analog-to-digital converters that offer a versatile range of
+  specifications. They integrate an analog front end suitable for processing
+  fully differential/single-ended and bipolar voltage inputs.
+
   Datasheets for supported chips:
+    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4111.pdf
+    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4112.pdf
+    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4114.pdf
+    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4115.pdf
+    https://www.analog.com/media/en/technical-documentation/data-sheets/AD4116.pdf
     https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-2.pdf
     https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
     https://www.analog.com/media/en/technical-documentation/data-sheets/AD7173-8.pdf
@@ -31,6 +42,11 @@  description: |
 properties:
   compatible:
     enum:
+      - adi,ad4111
+      - adi,ad4112
+      - adi,ad4114
+      - adi,ad4115
+      - adi,ad4116
       - adi,ad7172-2
       - adi,ad7172-4
       - adi,ad7173-8
@@ -129,10 +145,54 @@  patternProperties:
         maximum: 15
 
       diff-channels:
+        description: |
+          This property is used for defining the inputs of a differential
+          voltage channel. The first value is the positive input and the second
+          value is the negative input of the channel.
+
+          Family AD411x supports a dedicated VINCOM voltage input.
+          To select it set the second channel to 16.
+            (VIN2, VINCOM) -> diff-channels = <2 16>
+
+          There are special values that can be selected besides the voltage
+          analog inputs:
+            21: REF+
+            22: REF−
+          Supported only by AD7172-2, AD7172-4, AD7175-2, AD7175-8, AD7177-2:
+            19: ((AVDD1 − AVSS)/5)+
+            20: ((AVDD1 − AVSS)/5)−
+
         items:
           minimum: 0
           maximum: 31
 
+      single-channel:
+        description: |
+          This property is used for defining a current channel or the positive
+          input of a voltage channel (single-ended or pseudo-differential).
+
+          Models AD4111 and AD4112 support current channels.
+            Example: (IIN2+, IIN2−) -> single-channel = <2>
+          To correctly configure a current channel set the "adi,current-channel"
+          property to true.
+
+          To configure a single-ended/pseudo-differential channel set the
+          "adi,common-mode-channel" property to the desired negative voltage input.
+
+          When used as a voltage channel, special inputs are valid as well.
+        minimum: 0
+        maximum: 31
+
+      adi,common-mode-channel:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description:
+          This property is used for defining the negative input of a
+          single-ended or pseudo-differential voltage channel.
+
+          Special inputs are valid as well.
+        minimum: 0
+        maximum: 31
+
       adi,reference-select:
         description: |
           Select the reference source to use when converting on
@@ -154,9 +214,31 @@  patternProperties:
           - avdd
         default: refout-avss
 
+      adi,current-channel:
+        description: |
+          Signal that the selected inputs are current channels.
+          Only available on AD4111 and AD4112.
+        type: boolean
+
     required:
       - reg
-      - diff-channels
+
+    allOf:
+      - oneOf:
+          - required: [single-channel]
+            properties:
+              diff-channels: false
+          - required: [diff-channels]
+            properties:
+              single-channel: false
+              adi,current-channel: false
+              adi,common-mode-channel: false
+
+      - if:
+          required: ["adi,common-mode-channel"]
+        then:
+          properties:
+            adi,current-channel: false
 
 required:
   - compatible
@@ -166,7 +248,6 @@  allOf:
   - $ref: /schemas/spi/spi-peripheral-props.yaml#
 
   # Only ad7172-4, ad7173-8 and ad7175-8 support vref2
-  # Other models have [0-3] channel registers
   - if:
       properties:
         compatible:
@@ -187,6 +268,37 @@  allOf:
                 - vref
                 - refout-avss
                 - avdd
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - adi,ad4114
+              - adi,ad4115
+              - adi,ad4116
+              - adi,ad7173-8
+              - adi,ad7175-8
+    then:
+      patternProperties:
+        "^channel@[0-9a-f]$":
+          properties:
+            reg:
+              maximum: 15
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - adi,ad7172-2
+              - adi,ad7175-2
+              - adi,ad7176-2
+              - adi,ad7177-2
+    then:
+      patternProperties:
+        "^channel@[0-9a-f]$":
+          properties:
             reg:
               maximum: 3
 
@@ -210,6 +322,34 @@  allOf:
           required:
             - adi,reference-select
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - adi,ad4111
+              - adi,ad4112
+              - adi,ad4114
+              - adi,ad4115
+              - adi,ad4116
+    then:
+      properties:
+        avdd2-supply: false
+
+  - if:
+      properties:
+        compatible:
+          not:
+            contains:
+              enum:
+                - adi,ad4111
+                - adi,ad4112
+    then:
+      patternProperties:
+        "^channel@[0-9a-f]$":
+          properties:
+            adi,current-channel: false
+
   - if:
       anyOf:
         - required: [clock-names]
@@ -221,6 +361,7 @@  allOf:
 unevaluatedProperties: false
 
 examples:
+  # Example AD7173-8 with external reference connected to REF+/REF-:
   - |
     #include <dt-bindings/gpio/gpio.h>
     #include <dt-bindings/interrupt-controller/irq.h>
@@ -277,3 +418,50 @@  examples:
         };
       };
     };
+
+  # Example AD4111 with current channel and single-ended channel:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    spi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+       adc@0 {
+        compatible = "adi,ad4111";
+        reg = <0>;
+
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        interrupts = <25 IRQ_TYPE_EDGE_FALLING>;
+        interrupt-names = "rdy";
+        interrupt-parent = <&gpio>;
+        spi-max-frequency = <5000000>;
+        gpio-controller;
+        #gpio-cells = <2>;
+        #clock-cells = <0>;
+
+        channel@0 {
+          reg = <0>;
+          bipolar;
+          diff-channels = <4 5>;
+        };
+
+        // Single ended channel VIN2/VINCOM
+        channel@1 {
+          reg = <1>;
+          bipolar;
+          single-channel = <2>;
+          adi,common-mode-channel = <16>;
+        };
+
+        // Current channel IN2+/IN2-
+        channel@2 {
+          reg = <2>;
+          single-channel = <2>;
+          adi,current-channel;
+        };
+      };
+    };