diff mbox series

[1/2] dt-bindings: iio: pressure: honeywell,mprls0025pa

Message ID 20231219130230.32584-2-petre.rodan@subdimension.ro
State New
Headers show
Series [1/2] dt-bindings: iio: pressure: honeywell,mprls0025pa | expand

Commit Message

Petre Rodan Dec. 19, 2023, 1:02 p.m. UTC
ChangeLog
 - add honeywell,pressure-triplet property that autoconfigures pmin, pmax
    just like the hsc030pa sensor driver
 - add support for spi-based sensors

Datasheet:
https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf
Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
---
 .../iio/pressure/honeywell,mprls0025pa.yaml   | 60 ++++++++++++++++---
 1 file changed, 52 insertions(+), 8 deletions(-)

Comments

Jonathan Cameron Dec. 20, 2023, 3:16 p.m. UTC | #1
On Tue, 19 Dec 2023 15:02:20 +0200
Petre Rodan <petre.rodan@subdimension.ro> wrote:

> ChangeLog

The whole patch description describes changes, so no need for a Changelog heading.

>  - add honeywell,pressure-triplet property that autoconfigures pmin, pmax
>     just like the hsc030pa sensor driver

Why?  Needs an explanation of why this binding is better and easier to use
+ how backwards compatibility is maintained.

>  - add support for spi-based sensors
> 
Two things, two patches.

> Datasheet:

It's a formal tag, so no line break (Even if checkpatch complains!)

> https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf
> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
> ---
>  .../iio/pressure/honeywell,mprls0025pa.yaml   | 60 ++++++++++++++++---
>  1 file changed, 52 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml
> index d9e903fbfd99..7c4be2dec174 100644
> --- a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml
> +++ b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml
> @@ -53,33 +53,59 @@ properties:
>    honeywell,pmin-pascal:
>      description:
>        Minimum pressure value the sensor can measure in pascal.
> +      To be specified only if honeywell,pressure-triplet is set to "NA".
That just added a backwards compatibility break.  It would be fine
if there was a default: NA for honeywell,pressure-triplet or a check that either
one or the other was supplied (which I'd prefer).  Thus old bindings will work
and new ones also supported.

>  
>    honeywell,pmax-pascal:
>      description:
>        Maximum pressure value the sensor can measure in pascal.
> +      To be specified only if honeywell,pressure-triplet is set to "NA".
>  
>    honeywell,transfer-function:
>      description: |
> -      Transfer function which defines the range of valid values delivered by the
> -      sensor.
> +      Transfer function which defines the range of valid values delivered by
> +      the sensor.
>        1 - A, 10% to 90% of 2^24 (1677722 .. 15099494)
>        2 - B, 2.5% to 22.5% of 2^24 (419430 .. 3774874)
>        3 - C, 20% to 80% of 2^24 (3355443 .. 13421773)
> +    enum: [1, 2, 3]
>      $ref: /schemas/types.yaml#/definitions/uint32
>  
> +  honeywell,pressure-triplet:
> +    description: |
> +      Case-sensitive five character string that defines pressure range, unit
> +      and type as part of the device nomenclature. In the unlikely case of a
> +      custom chip, set to "NA" and provide pmin-pascal and pmax-pascal.

Should not need to set to NA, just don't provide it.

> +    enum: [0001BA, 01.6BA, 02.5BA, 0060MG, 0100MG, 0160MG, 0250MG, 0400MG,
> +           0600MG, 0001BG, 01.6BG, 02.5BG, 0100KA, 0160KA, 0250KA, 0006KG,
> +           0010KG, 0016KG, 0025KG, 0040KG, 0060KG, 0100KG, 0160KG, 0250KG,
> +           0015PA, 0025PA, 0030PA, 0001PG, 0005PG, 0015PG, 0030PG, 0300YG,
> +           NA]
> +    $ref: /schemas/types.yaml#/definitions/string
> +
> +  spi-max-frequency:
> +    maximum: 800000
> +
>    vdd-supply:
>      description: provide VDD power to the sensor.
>  
>  required:
>    - compatible
>    - reg
> -  - honeywell,pmin-pascal
> -  - honeywell,pmax-pascal
> +  - honeywell,pressure-triplet
>    - honeywell,transfer-function
> -  - vdd-supply
>  
>  additionalProperties: false
>  
> +dependentSchemas:
> +  honeywell,pmin-pascal:
> +    properties:
> +      honeywell,pressure-triplet:
> +        const: NA
> +  honeywell,pmax-pascal:
> +    properties:
> +      honeywell,pressure-triplet:
> +        const: NA
> +
>  examples:
>    - |
>      #include <dt-bindings/gpio/gpio.h>
> @@ -93,10 +119,28 @@ examples:
>              reg = <0x18>;
>              reset-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>;
>              interrupt-parent = <&gpio3>;
> -            interrupts = <21 IRQ_TYPE_EDGE_FALLING>;
> -            honeywell,pmin-pascal = <0>;
> -            honeywell,pmax-pascal = <172369>;
> +            interrupts = <21 IRQ_TYPE_EDGE_RISING>;
> +
> +            honeywell,pressure-triplet = "0025PA";
>              honeywell,transfer-function = <1>;
>              vdd-supply = <&vcc_3v3>;
>          };
>      };
> +  - |
> +    spi {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        pressure@0 {
> +            compatible = "honeywell,mprls0025pa";
> +            reg = <0>;
> +            spi-max-frequency = <800000>;
> +            reset-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
> +            interrupt-parent = <&gpio0>;
> +            interrupts = <30 IRQ_TYPE_EDGE_RISING>;
> +
> +            honeywell,pressure-triplet = "0015PA";
> +            honeywell,transfer-function = <1>;
> +        };
> +    };
> +...
Petre Rodan Dec. 20, 2023, 5:25 p.m. UTC | #2
hi Jonathan,

On Wed, Dec 20, 2023 at 03:16:45PM +0000, Jonathan Cameron wrote:
> On Tue, 19 Dec 2023 15:02:20 +0200
> Petre Rodan <petre.rodan@subdimension.ro> wrote:
> >    honeywell,pmin-pascal:
> >      description:
> >        Minimum pressure value the sensor can measure in pascal.
> > +      To be specified only if honeywell,pressure-triplet is set to "NA".
> That just added a backwards compatibility break.  It would be fine
> if there was a default: NA for honeywell,pressure-triplet or a check that either
> one or the other was supplied (which I'd prefer).  Thus old bindings will work
> and new ones also supported.

ok, I see your reasoning. but in this second scenario that you prefer how can we
propery define the 'required:' block? an equivalent to

required:
  - compatible
  - reg
  - (honeywell,pmin-pascal && honeywell,pmax-pascal) || honeywell,pressure-triplet
  - honeywell,transfer-function


thanks,
peter
Jonathan Cameron Dec. 21, 2023, 11:04 a.m. UTC | #3
On Wed, 20 Dec 2023 19:25:25 +0200
Petre Rodan <petre.rodan@subdimension.ro> wrote:

> hi Jonathan,
> 
> On Wed, Dec 20, 2023 at 03:16:45PM +0000, Jonathan Cameron wrote:
> > On Tue, 19 Dec 2023 15:02:20 +0200
> > Petre Rodan <petre.rodan@subdimension.ro> wrote:  
> > >    honeywell,pmin-pascal:
> > >      description:
> > >        Minimum pressure value the sensor can measure in pascal.
> > > +      To be specified only if honeywell,pressure-triplet is set to "NA".  
> > That just added a backwards compatibility break.  It would be fine
> > if there was a default: NA for honeywell,pressure-triplet or a check that either
> > one or the other was supplied (which I'd prefer).  Thus old bindings will work
> > and new ones also supported.  
> 
> ok, I see your reasoning. but in this second scenario that you prefer how can we
> propery define the 'required:' block? an equivalent to
> 
> required:
>   - compatible
>   - reg
>   - (honeywell,pmin-pascal && honeywell,pmax-pascal) || honeywell,pressure-triplet
>   - honeywell,transfer-function

Yes, it would end up something like that.  There are exclusive or examples in tree.
I think something like dac/adi,ad3552r.yaml
 should work.

oneOf:
  - required:
      - honeywell,pmin-pascal
      - honeywell,pmax-pascal
  - required:
      - honeywell,pressure-triplet

but you will want to try all the cases to make sure that works (my ability to
figure these ones out is tricky).

+ you ideally want to exclude them all being set which is fiddlier.

Some similar examples but they are based on a value in the property. I'm not
sure how you check for it just being defined.

Something along lines of.

allOf:
  - if:
      properties:
        honeywell,pressure-triplet
    then:
      properties:
        honeywell,pmin-pascal: false
        honeywell,pmax-pascal: false

Might work?  I always end up trawling the kernel to find a similar example for cases but
can't find anything closer right now.

Jonathan

   



> 
> 
> thanks,
> peter
Conor Dooley Dec. 22, 2023, 3:27 p.m. UTC | #4
On Thu, Dec 21, 2023 at 11:04:17AM +0000, Jonathan Cameron wrote:
> On Wed, 20 Dec 2023 19:25:25 +0200
> Petre Rodan <petre.rodan@subdimension.ro> wrote:
> 
> > hi Jonathan,
> > 
> > On Wed, Dec 20, 2023 at 03:16:45PM +0000, Jonathan Cameron wrote:
> > > On Tue, 19 Dec 2023 15:02:20 +0200
> > > Petre Rodan <petre.rodan@subdimension.ro> wrote:  
> > > >    honeywell,pmin-pascal:
> > > >      description:
> > > >        Minimum pressure value the sensor can measure in pascal.
> > > > +      To be specified only if honeywell,pressure-triplet is set to "NA".  
> > > That just added a backwards compatibility break.  It would be fine
> > > if there was a default: NA for honeywell,pressure-triplet or a check that either
> > > one or the other was supplied (which I'd prefer).  Thus old bindings will work
> > > and new ones also supported.  
> > 
> > ok, I see your reasoning. but in this second scenario that you prefer how can we
> > propery define the 'required:' block? an equivalent to
> > 
> > required:
> >   - compatible
> >   - reg
> >   - (honeywell,pmin-pascal && honeywell,pmax-pascal) || honeywell,pressure-triplet
> >   - honeywell,transfer-function
> 
> Yes, it would end up something like that.  There are exclusive or examples in tree.
> I think something like dac/adi,ad3552r.yaml
>  should work.
> 
> oneOf:
>   - required:
>       - honeywell,pmin-pascal
>       - honeywell,pmax-pascal
>   - required:
>       - honeywell,pressure-triplet
> 
> but you will want to try all the cases to make sure that works (my ability to
> figure these ones out is tricky).
> 
> + you ideally want to exclude them all being set which is fiddlier.
> 
> Some similar examples but they are based on a value in the property. I'm not
> sure how you check for it just being defined.
> 
> Something along lines of.
> 
> allOf:
>   - if:
>       properties:
>         honeywell,pressure-triplet
>     then:
>       properties:
>         honeywell,pmin-pascal: false
>         honeywell,pmax-pascal: false
> 
> Might work?  I always end up trawling the kernel to find a similar example for cases but
> can't find anything closer right now.

I hate to admit it, but I'm not great at expressing these in the minimum
forms either, but I think you're missing a "required" from here, in place
of the "properties":
allOf:
  - if:
      required:
        - honeywell,pressure-triplet
    then:
      properties:
        honeywell,pmin-pascal: false
        honeywell,pmax-pascal: false

Cheers,
Conor.
Petre Rodan Dec. 23, 2023, 11:28 a.m. UTC | #5
hello Conor,

On Fri, Dec 22, 2023 at 03:27:36PM +0000, Conor Dooley wrote:
> > >   - (honeywell,pmin-pascal && honeywell,pmax-pascal) || honeywell,pressure-triplet
> > Yes, it would end up something like that.  There are exclusive or examples in tree.

> > oneOf:
> >   - required:
> >       - honeywell,pmin-pascal
> >       - honeywell,pmax-pascal
> >   - required:
> >       - honeywell,pressure-triplet
> > 
> > but you will want to try all the cases to make sure that works (my ability to
> > figure these ones out is tricky).
> > 
> > + you ideally want to exclude them all being set which is fiddlier.
> > 
> > Some similar examples but they are based on a value in the property. I'm not
> > sure how you check for it just being defined.
> > 
> > Something along lines of.
> > 
> > allOf:
> >   - if:
> >       properties:
> >         honeywell,pressure-triplet
> >     then:
> >       properties:
> >         honeywell,pmin-pascal: false
> >         honeywell,pmax-pascal: false
> > 
> > Might work?  I always end up trawling the kernel to find a similar example for cases but
> > can't find anything closer right now.
> 
> I hate to admit it, but I'm not great at expressing these in the minimum
> forms either, but I think you're missing a "required" from here, in place
> of the "properties":
> allOf:
>   - if:
>       required:
>         - honeywell,pressure-triplet
>     then:
>       properties:
>         honeywell,pmin-pascal: false
>         honeywell,pmax-pascal: false

thank you both for the above ruleset, it works like magic.

I spent hours trying to figure out the proper syntax but never got it right.

Merry Christmas!
peter
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml
index d9e903fbfd99..7c4be2dec174 100644
--- a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml
+++ b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml
@@ -53,33 +53,59 @@  properties:
   honeywell,pmin-pascal:
     description:
       Minimum pressure value the sensor can measure in pascal.
+      To be specified only if honeywell,pressure-triplet is set to "NA".
 
   honeywell,pmax-pascal:
     description:
       Maximum pressure value the sensor can measure in pascal.
+      To be specified only if honeywell,pressure-triplet is set to "NA".
 
   honeywell,transfer-function:
     description: |
-      Transfer function which defines the range of valid values delivered by the
-      sensor.
+      Transfer function which defines the range of valid values delivered by
+      the sensor.
       1 - A, 10% to 90% of 2^24 (1677722 .. 15099494)
       2 - B, 2.5% to 22.5% of 2^24 (419430 .. 3774874)
       3 - C, 20% to 80% of 2^24 (3355443 .. 13421773)
+    enum: [1, 2, 3]
     $ref: /schemas/types.yaml#/definitions/uint32
 
+  honeywell,pressure-triplet:
+    description: |
+      Case-sensitive five character string that defines pressure range, unit
+      and type as part of the device nomenclature. In the unlikely case of a
+      custom chip, set to "NA" and provide pmin-pascal and pmax-pascal.
+    enum: [0001BA, 01.6BA, 02.5BA, 0060MG, 0100MG, 0160MG, 0250MG, 0400MG,
+           0600MG, 0001BG, 01.6BG, 02.5BG, 0100KA, 0160KA, 0250KA, 0006KG,
+           0010KG, 0016KG, 0025KG, 0040KG, 0060KG, 0100KG, 0160KG, 0250KG,
+           0015PA, 0025PA, 0030PA, 0001PG, 0005PG, 0015PG, 0030PG, 0300YG,
+           NA]
+    $ref: /schemas/types.yaml#/definitions/string
+
+  spi-max-frequency:
+    maximum: 800000
+
   vdd-supply:
     description: provide VDD power to the sensor.
 
 required:
   - compatible
   - reg
-  - honeywell,pmin-pascal
-  - honeywell,pmax-pascal
+  - honeywell,pressure-triplet
   - honeywell,transfer-function
-  - vdd-supply
 
 additionalProperties: false
 
+dependentSchemas:
+  honeywell,pmin-pascal:
+    properties:
+      honeywell,pressure-triplet:
+        const: NA
+  honeywell,pmax-pascal:
+    properties:
+      honeywell,pressure-triplet:
+        const: NA
+
 examples:
   - |
     #include <dt-bindings/gpio/gpio.h>
@@ -93,10 +119,28 @@  examples:
             reg = <0x18>;
             reset-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>;
             interrupt-parent = <&gpio3>;
-            interrupts = <21 IRQ_TYPE_EDGE_FALLING>;
-            honeywell,pmin-pascal = <0>;
-            honeywell,pmax-pascal = <172369>;
+            interrupts = <21 IRQ_TYPE_EDGE_RISING>;
+
+            honeywell,pressure-triplet = "0025PA";
             honeywell,transfer-function = <1>;
             vdd-supply = <&vcc_3v3>;
         };
     };
+  - |
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pressure@0 {
+            compatible = "honeywell,mprls0025pa";
+            reg = <0>;
+            spi-max-frequency = <800000>;
+            reset-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+            interrupt-parent = <&gpio0>;
+            interrupts = <30 IRQ_TYPE_EDGE_RISING>;
+
+            honeywell,pressure-triplet = "0015PA";
+            honeywell,transfer-function = <1>;
+        };
+    };
+...