diff mbox series

[v1,9/9] dt-bindings: iio: afe: add binding for temperature-sense-amplifier

Message ID 20210530005917.20953-10-liambeguin@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series iio: afe: add temperature rescaling support | expand

Commit Message

Liam Beguin May 30, 2021, 12:59 a.m. UTC
From: Liam Beguin <lvb@xiphos.com>

An ADC is often used to measure other quantities indirectly. This
binding describe one cases, the measurement of a temperature through a
voltage sense amplifier such as the LTC2997.

Signed-off-by: Liam Beguin <lvb@xiphos.com>
---
 .../iio/afe/temperature-sense-amplifier.yaml  | 55 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml

Comments

Peter Rosin May 31, 2021, 7:32 a.m. UTC | #1
Hi!

On 2021-05-30 02:59, Liam Beguin wrote:
> From: Liam Beguin <lvb@xiphos.com>
> 
> An ADC is often used to measure other quantities indirectly. This
> binding describe one cases, the measurement of a temperature through a
> voltage sense amplifier such as the LTC2997.
> 
> Signed-off-by: Liam Beguin <lvb@xiphos.com>

What's the significant difference between this and the RTD binding? Does
not both simply scale/offset a voltage to a temperature?

Cheers,
Peter
Liam Beguin May 31, 2021, 2:03 p.m. UTC | #2
Hi Peter,

On Mon May 31, 2021 at 3:32 AM EDT, Peter Rosin wrote:
> Hi!
>
> On 2021-05-30 02:59, Liam Beguin wrote:
> > From: Liam Beguin <lvb@xiphos.com>
> > 
> > An ADC is often used to measure other quantities indirectly. This
> > binding describe one cases, the measurement of a temperature through a
> > voltage sense amplifier such as the LTC2997.
> > 
> > Signed-off-by: Liam Beguin <lvb@xiphos.com>
>
> What's the significant difference between this and the RTD binding? Does
> not both simply scale/offset a voltage to a temperature?
>

The way I looked at it was one binding per sensor type (resistance
driven, current driven, and voltage driven).

Thinking about it more, these three bindings could be factorized into
one if the user is required to enter parameters "by hand".

These could become something like:
- sense-gain-mult
- sense-gain-div
- sense-offset

I like the idea of having the "datasheet parameters" in the devicetree,
but this would be a lot more versatile.

What do you think?

Cheers,
Liam

> Cheers,
> Peter
Jonathan Cameron June 1, 2021, 3:59 p.m. UTC | #3
On Sat, 29 May 2021 20:59:17 -0400
Liam Beguin <liambeguin@gmail.com> wrote:

> From: Liam Beguin <lvb@xiphos.com>
> 
> An ADC is often used to measure other quantities indirectly. This
> binding describe one cases, the measurement of a temperature through a
> voltage sense amplifier such as the LTC2997.
> 
> Signed-off-by: Liam Beguin <lvb@xiphos.com>
> ---
>  .../iio/afe/temperature-sense-amplifier.yaml  | 55 +++++++++++++++++++
>  MAINTAINERS                                   |  1 +
>  2 files changed, 56 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml b/Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml
> new file mode 100644
> index 000000000000..015413cbffbc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml
> @@ -0,0 +1,55 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/afe/temperature-sense-amplifier.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Temperature Sense Amplifier
> +
> +maintainers:
> +  - Liam Beguin <lvb@xiphos.com>
> +
> +description: |
> +  When an io-channel measures the output voltage of a temperature IC such as
> +  the LTC2997, the interesting measurement is almost always the corresponding
> +  temperature, not the voltage output. This binding describes such a circuit.
> +
> +properties:
> +  compatible:
> +    const: temperature-sense-amplifier
> +
> +  io-channels:
> +    maxItems: 1
> +    description: |
> +      Channel node of a voltage io-channel.
> +
> +  '#io-channel-cells':
> +    const: 1
> +
> +  alpha-micro-volts-per-degree:

Include units in the naming.

micro-volts-per-degree-celsius: perhaps?
That will then get the type from dt-schema/schema/property-units.
Though amusing it will identify it based on celsius, when the units are arguably
volts.


> +    description: |
> +      Output voltage gain of the temperature IC.
> +
> +  use-kelvin-scale:
> +    type: boolean
> +    description: |
> +      Boolean indicating if alpha uses Kelvin degrees instead of Celsius.

I'm not clear why that change would make any difference to alpha?  It would make
a difference to an offset though (and you should allow for one of those if
you want this to be generic).

Pick one and stick to it for all cases.  It might make the dts author do
some simple maths but that is preferable to having this flexibility
when we don't need it.

> +
> +additionalProperties: false
> +required:
> +  - compatible
> +  - io-channels
> +  - alpha-micro-volts-per-degree
> +
> +examples:
> +  - |
> +    znq_temp: iio-rescale0 {

The end result is a temperature sensor, so this should
have a name reflecting that.  Here that would be
temperature-sensor as per the dt schema specification:
https://www.devicetree.org/specifications/

> +        compatible = "temperature-sense-amplifier";
> +        #io-channel-cells = <1>;
> +        io-channels = <&temp_adc 3>;
> +
> +        use-kelvin-scale;
> +        alpha-micro-volts-per-degree = <4000>;
> +    };
> +
> +...
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0eb7fcd94b66..f224bd8e6125 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8721,6 +8721,7 @@ L:	linux-iio@vger.kernel.org
>  S:	Maintained
>  F:	Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml
>  F:	Documentation/devicetree/bindings/iio/afe/current-sense-shunt.yaml
> +F:	Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml
>  F:	Documentation/devicetree/bindings/iio/afe/temperature-sense-current.yaml
>  F:	Documentation/devicetree/bindings/iio/afe/temperature-sense-rtd.yaml
>  F:	Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml
Jonathan Cameron June 1, 2021, 4:02 p.m. UTC | #4
On Mon, 31 May 2021 10:03:23 -0400
"Liam Beguin" <liambeguin@gmail.com> wrote:

> Hi Peter,
> 
> On Mon May 31, 2021 at 3:32 AM EDT, Peter Rosin wrote:
> > Hi!
> >
> > On 2021-05-30 02:59, Liam Beguin wrote:  
> > > From: Liam Beguin <lvb@xiphos.com>
> > > 
> > > An ADC is often used to measure other quantities indirectly. This
> > > binding describe one cases, the measurement of a temperature through a
> > > voltage sense amplifier such as the LTC2997.
> > > 
> > > Signed-off-by: Liam Beguin <lvb@xiphos.com>  
> >
> > What's the significant difference between this and the RTD binding? Does
> > not both simply scale/offset a voltage to a temperature?

I'm lost: what RTD binding?

> >  
> 
> The way I looked at it was one binding per sensor type (resistance
> driven, current driven, and voltage driven).
> 
> Thinking about it more, these three bindings could be factorized into
> one if the user is required to enter parameters "by hand".

Don't. They are effectively different types of devices and we just end
up with a more complex binding if we try to cover them all.

There is an argument to go the other way and actually have bindings for
individual temperature sensors like the LTC2997.  Then the parameters
become a driver problem rather than one for the binding.

Jonathan


> 
> These could become something like:
> - sense-gain-mult
> - sense-gain-div
> - sense-offset
> 
> I like the idea of having the "datasheet parameters" in the devicetree,
> but this would be a lot more versatile.
> 
> What do you think?
> 
> Cheers,
> Liam
> 
> > Cheers,
> > Peter  
>
Jonathan Cameron June 1, 2021, 4:07 p.m. UTC | #5
On Tue, 1 Jun 2021 17:02:51 +0100
Jonathan Cameron <Jonathan.Cameron@Huawei.com> wrote:

> On Mon, 31 May 2021 10:03:23 -0400
> "Liam Beguin" <liambeguin@gmail.com> wrote:
> 
> > Hi Peter,
> > 
> > On Mon May 31, 2021 at 3:32 AM EDT, Peter Rosin wrote:  
> > > Hi!
> > >
> > > On 2021-05-30 02:59, Liam Beguin wrote:    
> > > > From: Liam Beguin <lvb@xiphos.com>
> > > > 
> > > > An ADC is often used to measure other quantities indirectly. This
> > > > binding describe one cases, the measurement of a temperature through a
> > > > voltage sense amplifier such as the LTC2997.
> > > > 
> > > > Signed-off-by: Liam Beguin <lvb@xiphos.com>    
> > >
> > > What's the significant difference between this and the RTD binding? Does
> > > not both simply scale/offset a voltage to a temperature?  
> 
> I'm lost: what RTD binding?
Ignore this email - I was reading the series backwards and thought we were
talking about a preexisting binding.

> 
> > >    
> > 
> > The way I looked at it was one binding per sensor type (resistance
> > driven, current driven, and voltage driven).
> > 
> > Thinking about it more, these three bindings could be factorized into
> > one if the user is required to enter parameters "by hand".  
> 
> Don't. They are effectively different types of devices and we just end
> up with a more complex binding if we try to cover them all.
Ignore that as well. If the bindings combine fairly easily it is nice
to do so, but be careful not to throw too many things in together and
make it very hard to write the binding. However, I'm not keen on entirely
generic bindings and would like the channel type at least to come from
the compatible.

> 
> There is an argument to go the other way and actually have bindings for
> individual temperature sensors like the LTC2997.  Then the parameters
> become a driver problem rather than one for the binding.
> 
> Jonathan
> 
> 
> > 
> > These could become something like:
> > - sense-gain-mult
> > - sense-gain-div
> > - sense-offset
> > 
> > I like the idea of having the "datasheet parameters" in the devicetree,
> > but this would be a lot more versatile.
> > 
> > What do you think?
> > 
> > Cheers,
> > Liam
> >   
> > > Cheers,
> > > Peter    
> >   
>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml b/Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml
new file mode 100644
index 000000000000..015413cbffbc
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml
@@ -0,0 +1,55 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/afe/temperature-sense-amplifier.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Temperature Sense Amplifier
+
+maintainers:
+  - Liam Beguin <lvb@xiphos.com>
+
+description: |
+  When an io-channel measures the output voltage of a temperature IC such as
+  the LTC2997, the interesting measurement is almost always the corresponding
+  temperature, not the voltage output. This binding describes such a circuit.
+
+properties:
+  compatible:
+    const: temperature-sense-amplifier
+
+  io-channels:
+    maxItems: 1
+    description: |
+      Channel node of a voltage io-channel.
+
+  '#io-channel-cells':
+    const: 1
+
+  alpha-micro-volts-per-degree:
+    description: |
+      Output voltage gain of the temperature IC.
+
+  use-kelvin-scale:
+    type: boolean
+    description: |
+      Boolean indicating if alpha uses Kelvin degrees instead of Celsius.
+
+additionalProperties: false
+required:
+  - compatible
+  - io-channels
+  - alpha-micro-volts-per-degree
+
+examples:
+  - |
+    znq_temp: iio-rescale0 {
+        compatible = "temperature-sense-amplifier";
+        #io-channel-cells = <1>;
+        io-channels = <&temp_adc 3>;
+
+        use-kelvin-scale;
+        alpha-micro-volts-per-degree = <4000>;
+    };
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 0eb7fcd94b66..f224bd8e6125 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8721,6 +8721,7 @@  L:	linux-iio@vger.kernel.org
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml
 F:	Documentation/devicetree/bindings/iio/afe/current-sense-shunt.yaml
+F:	Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml
 F:	Documentation/devicetree/bindings/iio/afe/temperature-sense-current.yaml
 F:	Documentation/devicetree/bindings/iio/afe/temperature-sense-rtd.yaml
 F:	Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml