linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] iio: afe: add temperature rescaling support
@ 2021-06-07 14:47 Liam Beguin
  2021-06-07 14:47 ` [PATCH v2 1/8] iio: inkern: apply consumer scale on IIO_VAL_INT cases Liam Beguin
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Liam Beguin @ 2021-06-07 14:47 UTC (permalink / raw)
  To: liambeguin, peda, jic23, lars, pmeerw
  Cc: linux-kernel, linux-iio, devicetree, robh+dt

From: Liam Beguin <lvb@xiphos.com>

Add temperature rescaling support to the IIO Analog Front End driver.

This series includes minor bugfixes and adds support for a generic
temperature front end circuit.

As Peter suggested in v1, if the upstream channel has an offset, the
rescaler will default to using the processed value. This was done to
avoid having to process all supported offset an scale type combinations.

At first I tried to use iio_convert_raw_to_processed() to get more
precision out of processed values but ran into issues when one of my
ADCs didn't provide a scale. I tried to address this in the first two
patches.

When adding offset support to iio-rescale, I also noticed that
iio_read_channel_processed() assumes that the offset is always an
integer which I tried to address in the third patch without breaking
valid implicit truncations.

Related to: https://patchwork.kernel.org/project/linux-iio/list/?series=483087

Changes since v1:
- rebase on latest iio `testing` branch
- also apply consumer scale on integer channel scale types
- don't break implicit truncation in processed channel offset
  calculation
- drop temperature AFE flavors in favor of a simpler generic
  implementation

Thanks for your time

Liam Beguin (8):
  iio: inkern: apply consumer scale on IIO_VAL_INT cases
  iio: inkern: apply consumer scale when no channel scale is available
  iio: inkern: error out on unsupported offset type
  iio: inkern: return valid type on raw to processed conversion
  iio: afe: rescale: add upstream offset support
  iio: afe: rescale: add offset support
  iio: afe: rescale: add temperature sensor support
  dt-bindings: iio: afe: add binding for temperature-sense-amplifier

 .../iio/afe/temperature-sense-amplifier.yaml  | 57 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 drivers/iio/afe/iio-rescale.c                 | 39 ++++++++++++-
 drivers/iio/inkern.c                          | 46 +++++++++++----
 4 files changed, 131 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml

Range-diff against v1:
 1:  36f038f93537 <  -:  ------------ iio: inkern: always apply scale requested by consumer
 2:  fd3e9a69841a <  -:  ------------ iio: inkern: error out on unsupported offset type
 3:  91c473be7098 <  -:  ------------ iio: afe: rescale: use core to get processed value
 4:  1097973f3bf7 <  -:  ------------ iio: afe: rescale: add offset support
 5:  786badf92421 <  -:  ------------ iio: afe: rescale: add support for temperature sensors
 6:  0cae8abf6a06 <  -:  ------------ dt-bindings: iio: afe: update MAINTAINERS file
 7:  e806c73122f8 <  -:  ------------ dt-bindings: iio: afe: add binding for temperature-sense-rtd
 8:  f156b16ba01a <  -:  ------------ dt-bindings: iio: afe: add binding for temperature-sense-current
 -:  ------------ >  1:  8ebae9e606a2 iio: inkern: apply consumer scale on IIO_VAL_INT cases
 -:  ------------ >  2:  4d6e4d772f94 iio: inkern: apply consumer scale when no channel scale is available
 -:  ------------ >  3:  dd26ddb49658 iio: inkern: error out on unsupported offset type
 -:  ------------ >  4:  56e9e00cab9d iio: inkern: return valid type on raw to processed conversion
 -:  ------------ >  5:  d86fabc43985 iio: afe: rescale: add upstream offset support
 -:  ------------ >  6:  332fdb2d59ae iio: afe: rescale: add offset support
 -:  ------------ >  7:  3eabc81fb9aa iio: afe: rescale: add temperature sensor support
 9:  9bfdfe7d86b7 !  8:  37980da320b2 dt-bindings: iio: afe: add binding for temperature-sense-amplifier
    @@ Commit message
         dt-bindings: iio: afe: add binding for temperature-sense-amplifier
     
         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.
    +    binding describe such a use case, the measurement of a temperature
    +    through an analog front end connected to a voltage channel.
     
         Signed-off-by: Liam Beguin <lvb@xiphos.com>
     
    @@ Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml (new)
     +  - 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
    ++  When an io-channel measures the output voltage of a temperature analog front
    ++  end such as an RTD (resistance thermometer) or a temperature to current
    ++  sensor, the interesting measurement is almost always the corresponding
     +  temperature, not the voltage output. This binding describes such a circuit.
     +
     +properties:
    @@ Documentation/devicetree/bindings/iio/afe/temperature-sense-amplifier.yaml (new)
     +  '#io-channel-cells':
     +    const: 1
     +
    -+  alpha-micro-volts-per-degree:
    -+    description: |
    -+      Output voltage gain of the temperature IC.
    ++  sense-gain-mult:
    ++    $ref: /schemas/types.yaml#/definitions/uint32
    ++    description: Amplifier gain multiplier. The default is <1>.
     +
    -+  use-kelvin-scale:
    -+    type: boolean
    -+    description: |
    -+      Boolean indicating if alpha uses Kelvin degrees instead of Celsius.
    ++  sense-gain-div:
    ++    $ref: /schemas/types.yaml#/definitions/uint32
    ++    description: Amplifier gain divider. The default is <1>.
    ++
    ++  sense-offset-millicelsius:
    ++    description: Amplifier offset. The default is <0>.
     +
     +additionalProperties: false
     +required:
     +  - compatible
     +  - io-channels
    -+  - alpha-micro-volts-per-degree
     +
     +examples:
     +  - |
    -+    znq_temp: iio-rescale0 {
    ++    pt1000_1: temperature-sensor {
     +        compatible = "temperature-sense-amplifier";
     +        #io-channel-cells = <1>;
     +        io-channels = <&temp_adc 3>;
     +
    -+        use-kelvin-scale;
    -+        alpha-micro-volts-per-degree = <4000>;
    ++        sense-gain-mult = <1000000>;
    ++        sense-gain-div = <3908>;
    ++        sense-offset-millicelsius = <(-255885)>;
     +    };
    -+
     +...
     
      ## MAINTAINERS ##
    @@ MAINTAINERS: L:	linux-iio@vger.kernel.org
      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
    + F:	drivers/iio/afe/iio-rescale.c
    + 

base-commit: 41340965b4f8055f975f73e1e3d23eff8038f013
-- 
2.30.1.489.g328c10930387


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

end of thread, other threads:[~2021-06-11 16:12 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 14:47 [PATCH v2 0/8] iio: afe: add temperature rescaling support Liam Beguin
2021-06-07 14:47 ` [PATCH v2 1/8] iio: inkern: apply consumer scale on IIO_VAL_INT cases Liam Beguin
2021-06-07 14:47 ` [PATCH v2 2/8] iio: inkern: apply consumer scale when no channel scale is available Liam Beguin
2021-06-07 14:47 ` [PATCH v2 3/8] iio: inkern: error out on unsupported offset type Liam Beguin
2021-06-09 20:28   ` Jonathan Cameron
2021-06-09 21:40     ` Liam Beguin
2021-06-10  9:06       ` Jonathan Cameron
2021-06-10 20:42         ` Peter Rosin
2021-06-07 14:47 ` [PATCH v2 4/8] iio: inkern: return valid type on raw to processed conversion Liam Beguin
2021-06-09 20:32   ` Jonathan Cameron
2021-06-09 21:46     ` Liam Beguin
2021-06-10  9:08       ` Jonathan Cameron
2021-06-07 14:47 ` [PATCH v2 5/8] iio: afe: rescale: add upstream offset support Liam Beguin
2021-06-07 14:47 ` [PATCH v2 6/8] iio: afe: rescale: add " Liam Beguin
2021-06-07 14:47 ` [PATCH v2 7/8] iio: afe: rescale: add temperature sensor support Liam Beguin
2021-06-10 21:23   ` Peter Rosin
2021-06-07 14:47 ` [PATCH v2 8/8] dt-bindings: iio: afe: add binding for temperature-sense-amplifier Liam Beguin
2021-06-09 20:52   ` Jonathan Cameron
2021-06-09 21:50     ` Liam Beguin
2021-06-11  7:37   ` Peter Rosin
2021-06-11 16:12     ` Liam Beguin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).