diff mbox series

[v2,1/7] dt-bindings: Add bindings for Azoteq IQS620A/621/622/624/625

Message ID 1575851866-18919-2-git-send-email-jeff@labundy.com (mailing list archive)
State Superseded
Headers show
Series Add support for Azoteq IQS620A/621/622/624/625 | expand

Commit Message

Jeff LaBundy Dec. 9, 2019, 12:38 a.m. UTC
This patch adds device tree bindings for the Azoteq IQS620A, IQS621,
IQS622, IQS624 and IQS625 multi-function sensors.

A total of three bindings are presented (one MFD and two child nodes);
they are submitted as a single patch because the child node bindings
have no meaning in the absence of the MFD binding.

Signed-off-by: Jeff LaBundy <jeff@labundy.com>
---
Changes in v2:
  - Removed "prox" child node and moved "keys" and "pwm" child nodes to their
    own bindings
  - Replaced linux,fw-file property with more common firmware-name property
  - Converted all bindings to YAML

 .../devicetree/bindings/input/iqs62x-keys.yaml     | 126 +++++++++++++++
 Documentation/devicetree/bindings/mfd/iqs62x.yaml  | 177 +++++++++++++++++++++
 .../devicetree/bindings/pwm/iqs620a-pwm.yaml       |  30 ++++
 3 files changed, 333 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/iqs62x-keys.yaml
 create mode 100644 Documentation/devicetree/bindings/mfd/iqs62x.yaml
 create mode 100644 Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml

--
2.7.4

Comments

Rob Herring Dec. 18, 2019, 11:52 p.m. UTC | #1
On Mon, Dec 09, 2019 at 12:38:32AM +0000, Jeff LaBundy wrote:
> This patch adds device tree bindings for the Azoteq IQS620A, IQS621,
> IQS622, IQS624 and IQS625 multi-function sensors.
> 
> A total of three bindings are presented (one MFD and two child nodes);
> they are submitted as a single patch because the child node bindings
> have no meaning in the absence of the MFD binding.
> 
> Signed-off-by: Jeff LaBundy <jeff@labundy.com>
> ---
> Changes in v2:
>   - Removed "prox" child node and moved "keys" and "pwm" child nodes to their
>     own bindings
>   - Replaced linux,fw-file property with more common firmware-name property
>   - Converted all bindings to YAML

Good job for first go.

> 
>  .../devicetree/bindings/input/iqs62x-keys.yaml     | 126 +++++++++++++++
>  Documentation/devicetree/bindings/mfd/iqs62x.yaml  | 177 +++++++++++++++++++++
>  .../devicetree/bindings/pwm/iqs620a-pwm.yaml       |  30 ++++
>  3 files changed, 333 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/iqs62x-keys.yaml
>  create mode 100644 Documentation/devicetree/bindings/mfd/iqs62x.yaml
>  create mode 100644 Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml

A couple of minor things below. With those fixed:

Reviewed-by: Rob Herring <robh@kernel.org>

> 
> diff --git a/Documentation/devicetree/bindings/input/iqs62x-keys.yaml b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> new file mode 100644
> index 0000000..e9b54e0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> @@ -0,0 +1,126 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/input/iqs62x-keys.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Azoteq IQS620A/621/622/624/625 Keys and Switches
> +
> +maintainers:
> +  - Jeff LaBundy <jeff@labundy.com>
> +
> +description: |
> +  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
> +  feature a variety of self-capacitive, mutual-inductive and Hall-effect sens-
> +  ing capabilities that can facilitate a variety of contactless key and switch
> +  applications.
> +
> +  These functions are collectively represented by a "keys" child node from the
> +  parent MFD driver. See Documentation/devicetree/bindings/mfd/iqs62x.yaml for
> +  further details and examples. Sensor hardware configuration (self-capacitive
> +  vs. mutual-inductive, etc.) is selected based on the device's firmware.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - azoteq,iqs620a-keys
> +      - azoteq,iqs621-keys
> +      - azoteq,iqs622-keys
> +      - azoteq,iqs624-keys
> +      - azoteq,iqs625-keys
> +
> +  linux,keycodes:
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32-array
> +      - minItems: 1
> +        maxItems: 16
> +    description: |
> +      Specifies the numeric keycodes associated with each available touch or
> +      proximity event according to the following table. An 'x' indicates the
> +      event is supported for a given device. Specify 0 for unused events.
> +
> +      -------------------------------------------------------------------------
> +      | #  | Event              | IQS620A | IQS621 | IQS622 | IQS624 | IQS625 |
> +      -------------------------------------------------------------------------
> +      | 0  | CH0 Touch          |    x    |    x   |    x   |    x   |    x   |
> +      |    | Antenna 1 Touch*   |    x    |        |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 1  | CH0 Proximity      |    x    |    x   |    x   |    x   |    x   |
> +      |    | Antenna 1 Prox.*   |    x    |        |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 2  | CH1 Touch          |    x    |    x   |    x   |    x   |    x   |
> +      |    | Ant. 1 Deep Touch* |    x    |        |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 3  | CH1 Proximity      |    x    |    x   |    x   |    x   |    x   |
> +      -------------------------------------------------------------------------
> +      | 4  | CH2 Touch          |    x    |        |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 5  | CH2 Proximity      |    x    |        |        |        |        |
> +      |    | Antenna 2 Prox.*   |    x    |        |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 6  | Metal (+) Touch**  |    x    |    x   |        |        |        |
> +      |    | Ant. 2 Deep Touch* |    x    |        |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 7  | Metal (+) Prox.**  |    x    |    x   |        |        |        |
> +      |    | Antenna 2 Touch*   |    x    |        |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 8  | Metal (-) Touch**  |    x    |    x   |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 9  | Metal (-) Prox.**  |    x    |    x   |        |        |        |
> +      -------------------------------------------------------------------------
> +      | 10 | SAR Active***      |    x    |        |    x   |        |        |
> +      -------------------------------------------------------------------------
> +      | 11 | SAR Quick Rel.***  |    x    |        |    x   |        |        |
> +      -------------------------------------------------------------------------
> +      | 12 | SAR Movement***    |    x    |        |    x   |        |        |
> +      -------------------------------------------------------------------------
> +      | 13 | SAR Filter Halt*** |    x    |        |    x   |        |        |
> +      -------------------------------------------------------------------------
> +      | 14 | Wheel Up           |         |        |        |    x   |        |
> +      -------------------------------------------------------------------------
> +      | 15 | Wheel Down         |         |        |        |    x   |        |
> +      -------------------------------------------------------------------------
> +      *   Two-channel SAR. Replaces CH0-2 plus metal touch and proximity events
> +          if enabled via firmware.
> +      **  "+" and "-" refer to the polarity of a channel's delta (LTA - counts),
> +          where "LTA" is defined as the channel's long-term average.
> +      *** One-channel SAR. Replaces CH0-2 touch and proximity events if enabled
> +          via firmware.
> +
> +required:
> +  - compatible
> +  - linux,keycodes

Add: 

additionalProperties: false

> +
> +if:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - azoteq,iqs620a-keys
> +          - azoteq,iqs621-keys
> +          - azoteq,iqs622-keys
> +then:
> +  patternProperties:
> +    "^hall-switch-(north|south)$":
> +      type: object
> +      description:
> +        Represents north/south-field Hall-effect sensor touch or proximity
> +        events. Note that north/south-field orientation is reversed on the
> +        IQS620AXzCSR device due to its flip-chip package.
> +
> +      properties:
> +        linux,code:
> +          $ref: /schemas/types.yaml#/definitions/uint32
> +          description: Numeric switch code associated with the event.
> +
> +        azoteq,use-prox:
> +          $ref: /schemas/types.yaml#/definitions/flag
> +          description:
> +            If present, specifies that Hall-effect sensor reporting should
> +            use the device's wide-range proximity threshold instead of its
> +            close-range touch threshold (default).
> +
> +      required:
> +        - linux,code
> +
> +...
> diff --git a/Documentation/devicetree/bindings/mfd/iqs62x.yaml b/Documentation/devicetree/bindings/mfd/iqs62x.yaml
> new file mode 100644
> index 0000000..24e6004
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/iqs62x.yaml
> @@ -0,0 +1,177 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/iqs62x.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Azoteq IQS620A/621/622/624/625 Multi-Function Sensors
> +
> +maintainers:
> +  - Jeff LaBundy <jeff@labundy.com>
> +
> +description: |
> +  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
> +  integrate multiple sensing technologies in a single package.
> +
> +  Link to data sheets: https://www.azoteq.com/
> +
> +properties:
> +  compatible:
> +    enum:
> +      - azoteq,iqs620a
> +      - azoteq,iqs621
> +      - azoteq,iqs622
> +      - azoteq,iqs624
> +      - azoteq,iqs625
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  firmware-name:
> +    $ref: /schemas/types.yaml#/definitions/string
> +    description:
> +      Specifies the name of the calibration and configuration file selected by
> +      the driver. If this property is omitted, the name is chosen based on the
> +      device name with ".bin" as the extension (e.g. iqs620a.bin for IQS620A).
> +
> +  keys:
> +    $ref: ../input/iqs62x-keys.yaml
> +
> +  pwm:
> +    $ref: ../pwm/iqs620a-pwm.yaml
> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts

Add: 

additionalProperties: false

> +
> +examples:
> +  - |
> +    /*
> +     * Dual capacitive buttons with additional "air button," unipolar lid
> +     * switch and panel-mounted LED.
> +     */
> +    #include <dt-bindings/input/input.h>
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    i2c {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            iqs620a@44 {
> +                    compatible = "azoteq,iqs620a";
> +                    reg = <0x44>;
> +                    interrupt-parent = <&gpio>;
> +                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
> +
> +                    keys {
> +                            compatible = "azoteq,iqs620a-keys";
> +
> +                            linux,keycodes = <KEY_SELECT>,
> +                                             <KEY_MENU>,
> +                                             <KEY_OK>,
> +                                             <KEY_MENU>;
> +
> +                            hall-switch-south {
> +                                    linux,code = <SW_LID>;
> +                                    azoteq,use-prox;
> +                            };
> +                    };
> +
> +                    iqs620a_pwm: pwm {
> +                            compatible = "azoteq,iqs620a-pwm";
> +                            #pwm-cells = <2>;
> +                    };
> +            };
> +    };
> +
> +    pwmleds {
> +            compatible = "pwm-leds";
> +
> +            panel {
> +                    pwms = <&iqs620a_pwm 0 1000000>;
> +                    max-brightness = <255>;
> +            };
> +    };
> +
> +  - |
> +    /* Single inductive button with bipolar dock/tablet-mode switch. */
> +    #include <dt-bindings/input/input.h>
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    i2c {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            iqs620a@44 {
> +                    compatible = "azoteq,iqs620a";
> +                    reg = <0x44>;
> +                    interrupt-parent = <&gpio>;
> +                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
> +
> +                    firmware-name = "iqs620a_coil.bin";
> +
> +                    keys {
> +                            compatible = "azoteq,iqs620a-keys";
> +
> +                            linux,keycodes = <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <KEY_MUTE>;
> +
> +                            hall-switch-north {
> +                                    linux,code = <SW_DOCK>;
> +                            };
> +
> +                            hall-switch-south {
> +                                    linux,code = <SW_TABLET_MODE>;
> +                            };
> +                    };
> +            };
> +    };
> +
> +  - |
> +    /* Dual capacitive buttons with volume knob. */
> +    #include <dt-bindings/input/input.h>
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    i2c {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            iqs624@44 {
> +                    compatible = "azoteq,iqs624";
> +                    reg = <0x44>;
> +                    interrupt-parent = <&gpio>;
> +                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
> +
> +                    keys {
> +                            compatible = "azoteq,iqs624-keys";
> +
> +                            linux,keycodes = <BTN_0>,
> +                                             <0>,
> +                                             <BTN_1>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <0>,
> +                                             <KEY_VOLUMEUP>,
> +                                             <KEY_VOLUMEDOWN>;
> +                    };
> +            };
> +    };
> +
> +...
> diff --git a/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml b/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
> new file mode 100644
> index 0000000..6b7aaef
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
> @@ -0,0 +1,30 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/pwm/iqs620a-pwm.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Azoteq IQS620A PWM Generator
> +
> +maintainers:
> +  - Jeff LaBundy <jeff@labundy.com>
> +
> +description: |
> +  The Azoteq IQS620A multi-function sensor generates a fixed-frequency PWM
> +  output represented by a "pwm" child node from the parent MFD driver. See
> +  Documentation/devicetree/bindings/mfd/iqs62x.yaml for further details as
> +  well as an example.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - azoteq,iqs620a-pwm
> +
> +  "#pwm-cells":
> +    const: 2
> +
> +required:
> +  - compatible
> +  - "#pwm-cells"

Add: 

additionalProperties: false

> +
> +...
> --
> 2.7.4
>
Jeff LaBundy Dec. 20, 2019, 4 a.m. UTC | #2
Hi Rob,

Thank you for your prompt review and your kind words. A couple of questions
and comments for you below.

On Wed, Dec 18, 2019 at 05:52:52PM -0600, Rob Herring wrote:
> On Mon, Dec 09, 2019 at 12:38:32AM +0000, Jeff LaBundy wrote:
> > This patch adds device tree bindings for the Azoteq IQS620A, IQS621,
> > IQS622, IQS624 and IQS625 multi-function sensors.
> > 
> > A total of three bindings are presented (one MFD and two child nodes);
> > they are submitted as a single patch because the child node bindings
> > have no meaning in the absence of the MFD binding.
> > 
> > Signed-off-by: Jeff LaBundy <jeff@labundy.com>
> > ---
> > Changes in v2:
> >   - Removed "prox" child node and moved "keys" and "pwm" child nodes to their
> >     own bindings
> >   - Replaced linux,fw-file property with more common firmware-name property
> >   - Converted all bindings to YAML
> 
> Good job for first go.
> 
> > 
> >  .../devicetree/bindings/input/iqs62x-keys.yaml     | 126 +++++++++++++++
> >  Documentation/devicetree/bindings/mfd/iqs62x.yaml  | 177 +++++++++++++++++++++
> >  .../devicetree/bindings/pwm/iqs620a-pwm.yaml       |  30 ++++
> >  3 files changed, 333 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> >  create mode 100644 Documentation/devicetree/bindings/mfd/iqs62x.yaml
> >  create mode 100644 Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
> 
> A couple of minor things below. With those fixed:
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> 
> > 
> > diff --git a/Documentation/devicetree/bindings/input/iqs62x-keys.yaml b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > new file mode 100644
> > index 0000000..e9b54e0
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > @@ -0,0 +1,126 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/input/iqs62x-keys.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Azoteq IQS620A/621/622/624/625 Keys and Switches
> > +
> > +maintainers:
> > +  - Jeff LaBundy <jeff@labundy.com>
> > +
> > +description: |
> > +  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
> > +  feature a variety of self-capacitive, mutual-inductive and Hall-effect sens-
> > +  ing capabilities that can facilitate a variety of contactless key and switch
> > +  applications.
> > +
> > +  These functions are collectively represented by a "keys" child node from the
> > +  parent MFD driver. See Documentation/devicetree/bindings/mfd/iqs62x.yaml for
> > +  further details and examples. Sensor hardware configuration (self-capacitive
> > +  vs. mutual-inductive, etc.) is selected based on the device's firmware.
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - azoteq,iqs620a-keys
> > +      - azoteq,iqs621-keys
> > +      - azoteq,iqs622-keys
> > +      - azoteq,iqs624-keys
> > +      - azoteq,iqs625-keys
> > +
> > +  linux,keycodes:
> > +    allOf:
> > +      - $ref: /schemas/types.yaml#/definitions/uint32-array
> > +      - minItems: 1
> > +        maxItems: 16
> > +    description: |
> > +      Specifies the numeric keycodes associated with each available touch or
> > +      proximity event according to the following table. An 'x' indicates the
> > +      event is supported for a given device. Specify 0 for unused events.
> > +
> > +      -------------------------------------------------------------------------
> > +      | #  | Event              | IQS620A | IQS621 | IQS622 | IQS624 | IQS625 |
> > +      -------------------------------------------------------------------------
> > +      | 0  | CH0 Touch          |    x    |    x   |    x   |    x   |    x   |
> > +      |    | Antenna 1 Touch*   |    x    |        |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 1  | CH0 Proximity      |    x    |    x   |    x   |    x   |    x   |
> > +      |    | Antenna 1 Prox.*   |    x    |        |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 2  | CH1 Touch          |    x    |    x   |    x   |    x   |    x   |
> > +      |    | Ant. 1 Deep Touch* |    x    |        |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 3  | CH1 Proximity      |    x    |    x   |    x   |    x   |    x   |
> > +      -------------------------------------------------------------------------
> > +      | 4  | CH2 Touch          |    x    |        |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 5  | CH2 Proximity      |    x    |        |        |        |        |
> > +      |    | Antenna 2 Prox.*   |    x    |        |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 6  | Metal (+) Touch**  |    x    |    x   |        |        |        |
> > +      |    | Ant. 2 Deep Touch* |    x    |        |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 7  | Metal (+) Prox.**  |    x    |    x   |        |        |        |
> > +      |    | Antenna 2 Touch*   |    x    |        |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 8  | Metal (-) Touch**  |    x    |    x   |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 9  | Metal (-) Prox.**  |    x    |    x   |        |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 10 | SAR Active***      |    x    |        |    x   |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 11 | SAR Quick Rel.***  |    x    |        |    x   |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 12 | SAR Movement***    |    x    |        |    x   |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 13 | SAR Filter Halt*** |    x    |        |    x   |        |        |
> > +      -------------------------------------------------------------------------
> > +      | 14 | Wheel Up           |         |        |        |    x   |        |
> > +      -------------------------------------------------------------------------
> > +      | 15 | Wheel Down         |         |        |        |    x   |        |
> > +      -------------------------------------------------------------------------
> > +      *   Two-channel SAR. Replaces CH0-2 plus metal touch and proximity events
> > +          if enabled via firmware.
> > +      **  "+" and "-" refer to the polarity of a channel's delta (LTA - counts),
> > +          where "LTA" is defined as the channel's long-term average.
> > +      *** One-channel SAR. Replaces CH0-2 touch and proximity events if enabled
> > +          via firmware.
> > +
> > +required:
> > +  - compatible
> > +  - linux,keycodes
> 
> Add: 
> 
> additionalProperties: false
> 

When I add this, the dt_binding_check step complains that the hall switch child nodes
used in the examples are unrecognized, e.g.:

iqs620a@44: keys: 'hall-switch-south' does not match any of the regexes: 'pinctrl-[0-9]+'

When I originally encountered this, I found that the mdio-mux child node in [0] seems
to be a similar example and omits additionalProperties, which is why I originally did
that here. Do you have any advice on how to proceed?

> > +
> > +if:
> > +  properties:
> > +    compatible:
> > +      contains:
> > +        enum:
> > +          - azoteq,iqs620a-keys
> > +          - azoteq,iqs621-keys
> > +          - azoteq,iqs622-keys
> > +then:
> > +  patternProperties:
> > +    "^hall-switch-(north|south)$":
> > +      type: object
> > +      description:
> > +        Represents north/south-field Hall-effect sensor touch or proximity
> > +        events. Note that north/south-field orientation is reversed on the
> > +        IQS620AXzCSR device due to its flip-chip package.
> > +
> > +      properties:
> > +        linux,code:
> > +          $ref: /schemas/types.yaml#/definitions/uint32
> > +          description: Numeric switch code associated with the event.
> > +
> > +        azoteq,use-prox:
> > +          $ref: /schemas/types.yaml#/definitions/flag
> > +          description:
> > +            If present, specifies that Hall-effect sensor reporting should
> > +            use the device's wide-range proximity threshold instead of its
> > +            close-range touch threshold (default).
> > +
> > +      required:
> > +        - linux,code
> > +

Do you think I should specify additionalProperties: false within these child nodes?

> > +...
> > diff --git a/Documentation/devicetree/bindings/mfd/iqs62x.yaml b/Documentation/devicetree/bindings/mfd/iqs62x.yaml
> > new file mode 100644
> > index 0000000..24e6004
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/iqs62x.yaml
> > @@ -0,0 +1,177 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mfd/iqs62x.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Azoteq IQS620A/621/622/624/625 Multi-Function Sensors
> > +
> > +maintainers:
> > +  - Jeff LaBundy <jeff@labundy.com>
> > +
> > +description: |
> > +  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
> > +  integrate multiple sensing technologies in a single package.
> > +
> > +  Link to data sheets: https://www.azoteq.com/
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - azoteq,iqs620a
> > +      - azoteq,iqs621
> > +      - azoteq,iqs622
> > +      - azoteq,iqs624
> > +      - azoteq,iqs625
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  firmware-name:
> > +    $ref: /schemas/types.yaml#/definitions/string
> > +    description:
> > +      Specifies the name of the calibration and configuration file selected by
> > +      the driver. If this property is omitted, the name is chosen based on the
> > +      device name with ".bin" as the extension (e.g. iqs620a.bin for IQS620A).
> > +
> > +  keys:
> > +    $ref: ../input/iqs62x-keys.yaml
> > +
> > +  pwm:
> > +    $ref: ../pwm/iqs620a-pwm.yaml
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - interrupts
> 
> Add: 
> 
> additionalProperties: false
> 

Sure thing, will do.

> > +
> > +examples:
> > +  - |
> > +    /*
> > +     * Dual capacitive buttons with additional "air button," unipolar lid
> > +     * switch and panel-mounted LED.
> > +     */
> > +    #include <dt-bindings/input/input.h>
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    i2c {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +
> > +            iqs620a@44 {
> > +                    compatible = "azoteq,iqs620a";
> > +                    reg = <0x44>;
> > +                    interrupt-parent = <&gpio>;
> > +                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
> > +
> > +                    keys {
> > +                            compatible = "azoteq,iqs620a-keys";
> > +
> > +                            linux,keycodes = <KEY_SELECT>,
> > +                                             <KEY_MENU>,
> > +                                             <KEY_OK>,
> > +                                             <KEY_MENU>;
> > +
> > +                            hall-switch-south {
> > +                                    linux,code = <SW_LID>;
> > +                                    azoteq,use-prox;
> > +                            };
> > +                    };
> > +
> > +                    iqs620a_pwm: pwm {
> > +                            compatible = "azoteq,iqs620a-pwm";
> > +                            #pwm-cells = <2>;
> > +                    };
> > +            };
> > +    };
> > +
> > +    pwmleds {
> > +            compatible = "pwm-leds";
> > +
> > +            panel {
> > +                    pwms = <&iqs620a_pwm 0 1000000>;
> > +                    max-brightness = <255>;
> > +            };
> > +    };
> > +
> > +  - |
> > +    /* Single inductive button with bipolar dock/tablet-mode switch. */
> > +    #include <dt-bindings/input/input.h>
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    i2c {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +
> > +            iqs620a@44 {
> > +                    compatible = "azoteq,iqs620a";
> > +                    reg = <0x44>;
> > +                    interrupt-parent = <&gpio>;
> > +                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
> > +
> > +                    firmware-name = "iqs620a_coil.bin";
> > +
> > +                    keys {
> > +                            compatible = "azoteq,iqs620a-keys";
> > +
> > +                            linux,keycodes = <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <KEY_MUTE>;
> > +
> > +                            hall-switch-north {
> > +                                    linux,code = <SW_DOCK>;
> > +                            };
> > +
> > +                            hall-switch-south {
> > +                                    linux,code = <SW_TABLET_MODE>;
> > +                            };
> > +                    };
> > +            };
> > +    };
> > +
> > +  - |
> > +    /* Dual capacitive buttons with volume knob. */
> > +    #include <dt-bindings/input/input.h>
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    i2c {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +
> > +            iqs624@44 {
> > +                    compatible = "azoteq,iqs624";
> > +                    reg = <0x44>;
> > +                    interrupt-parent = <&gpio>;
> > +                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
> > +
> > +                    keys {
> > +                            compatible = "azoteq,iqs624-keys";
> > +
> > +                            linux,keycodes = <BTN_0>,
> > +                                             <0>,
> > +                                             <BTN_1>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <0>,
> > +                                             <KEY_VOLUMEUP>,
> > +                                             <KEY_VOLUMEDOWN>;
> > +                    };
> > +            };
> > +    };
> > +
> > +...
> > diff --git a/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml b/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
> > new file mode 100644
> > index 0000000..6b7aaef
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
> > @@ -0,0 +1,30 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/pwm/iqs620a-pwm.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Azoteq IQS620A PWM Generator
> > +
> > +maintainers:
> > +  - Jeff LaBundy <jeff@labundy.com>
> > +
> > +description: |
> > +  The Azoteq IQS620A multi-function sensor generates a fixed-frequency PWM
> > +  output represented by a "pwm" child node from the parent MFD driver. See
> > +  Documentation/devicetree/bindings/mfd/iqs62x.yaml for further details as
> > +  well as an example.
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - azoteq,iqs620a-pwm
> > +
> > +  "#pwm-cells":
> > +    const: 2
> > +
> > +required:
> > +  - compatible
> > +  - "#pwm-cells"
> 
> Add: 
> 
> additionalProperties: false
> 

Sure thing, will do.

> > +
> > +...
> > --
> > 2.7.4
> > 

[0] Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml

Kind regards,
Jeff LaBundy
Rob Herring Dec. 24, 2019, 9:55 p.m. UTC | #3
On Thu, Dec 19, 2019 at 9:00 PM Jeff LaBundy <jeff@labundy.com> wrote:
>
> Hi Rob,
>
> Thank you for your prompt review and your kind words. A couple of questions
> and comments for you below.
>
> On Wed, Dec 18, 2019 at 05:52:52PM -0600, Rob Herring wrote:
> > On Mon, Dec 09, 2019 at 12:38:32AM +0000, Jeff LaBundy wrote:
> > > This patch adds device tree bindings for the Azoteq IQS620A, IQS621,
> > > IQS622, IQS624 and IQS625 multi-function sensors.
> > >
> > > A total of three bindings are presented (one MFD and two child nodes);
> > > they are submitted as a single patch because the child node bindings
> > > have no meaning in the absence of the MFD binding.
> > >
> > > Signed-off-by: Jeff LaBundy <jeff@labundy.com>
> > > ---
> > > Changes in v2:
> > >   - Removed "prox" child node and moved "keys" and "pwm" child nodes to their
> > >     own bindings
> > >   - Replaced linux,fw-file property with more common firmware-name property
> > >   - Converted all bindings to YAML
> >
> > Good job for first go.
> >
> > >
> > >  .../devicetree/bindings/input/iqs62x-keys.yaml     | 126 +++++++++++++++
> > >  Documentation/devicetree/bindings/mfd/iqs62x.yaml  | 177 +++++++++++++++++++++
> > >  .../devicetree/bindings/pwm/iqs620a-pwm.yaml       |  30 ++++
> > >  3 files changed, 333 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > >  create mode 100644 Documentation/devicetree/bindings/mfd/iqs62x.yaml
> > >  create mode 100644 Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
> >
> > A couple of minor things below. With those fixed:
> >
> > Reviewed-by: Rob Herring <robh@kernel.org>
> >
> > >
> > > diff --git a/Documentation/devicetree/bindings/input/iqs62x-keys.yaml b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > > new file mode 100644
> > > index 0000000..e9b54e0
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > > @@ -0,0 +1,126 @@
> > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/input/iqs62x-keys.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Azoteq IQS620A/621/622/624/625 Keys and Switches
> > > +
> > > +maintainers:
> > > +  - Jeff LaBundy <jeff@labundy.com>
> > > +
> > > +description: |
> > > +  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
> > > +  feature a variety of self-capacitive, mutual-inductive and Hall-effect sens-
> > > +  ing capabilities that can facilitate a variety of contactless key and switch
> > > +  applications.
> > > +
> > > +  These functions are collectively represented by a "keys" child node from the
> > > +  parent MFD driver. See Documentation/devicetree/bindings/mfd/iqs62x.yaml for
> > > +  further details and examples. Sensor hardware configuration (self-capacitive
> > > +  vs. mutual-inductive, etc.) is selected based on the device's firmware.
> > > +
> > > +properties:
> > > +  compatible:
> > > +    enum:
> > > +      - azoteq,iqs620a-keys
> > > +      - azoteq,iqs621-keys
> > > +      - azoteq,iqs622-keys
> > > +      - azoteq,iqs624-keys
> > > +      - azoteq,iqs625-keys
> > > +
> > > +  linux,keycodes:
> > > +    allOf:
> > > +      - $ref: /schemas/types.yaml#/definitions/uint32-array
> > > +      - minItems: 1
> > > +        maxItems: 16
> > > +    description: |
> > > +      Specifies the numeric keycodes associated with each available touch or
> > > +      proximity event according to the following table. An 'x' indicates the
> > > +      event is supported for a given device. Specify 0 for unused events.
> > > +
> > > +      -------------------------------------------------------------------------
> > > +      | #  | Event              | IQS620A | IQS621 | IQS622 | IQS624 | IQS625 |
> > > +      -------------------------------------------------------------------------
> > > +      | 0  | CH0 Touch          |    x    |    x   |    x   |    x   |    x   |
> > > +      |    | Antenna 1 Touch*   |    x    |        |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 1  | CH0 Proximity      |    x    |    x   |    x   |    x   |    x   |
> > > +      |    | Antenna 1 Prox.*   |    x    |        |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 2  | CH1 Touch          |    x    |    x   |    x   |    x   |    x   |
> > > +      |    | Ant. 1 Deep Touch* |    x    |        |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 3  | CH1 Proximity      |    x    |    x   |    x   |    x   |    x   |
> > > +      -------------------------------------------------------------------------
> > > +      | 4  | CH2 Touch          |    x    |        |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 5  | CH2 Proximity      |    x    |        |        |        |        |
> > > +      |    | Antenna 2 Prox.*   |    x    |        |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 6  | Metal (+) Touch**  |    x    |    x   |        |        |        |
> > > +      |    | Ant. 2 Deep Touch* |    x    |        |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 7  | Metal (+) Prox.**  |    x    |    x   |        |        |        |
> > > +      |    | Antenna 2 Touch*   |    x    |        |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 8  | Metal (-) Touch**  |    x    |    x   |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 9  | Metal (-) Prox.**  |    x    |    x   |        |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 10 | SAR Active***      |    x    |        |    x   |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 11 | SAR Quick Rel.***  |    x    |        |    x   |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 12 | SAR Movement***    |    x    |        |    x   |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 13 | SAR Filter Halt*** |    x    |        |    x   |        |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 14 | Wheel Up           |         |        |        |    x   |        |
> > > +      -------------------------------------------------------------------------
> > > +      | 15 | Wheel Down         |         |        |        |    x   |        |
> > > +      -------------------------------------------------------------------------
> > > +      *   Two-channel SAR. Replaces CH0-2 plus metal touch and proximity events
> > > +          if enabled via firmware.
> > > +      **  "+" and "-" refer to the polarity of a channel's delta (LTA - counts),
> > > +          where "LTA" is defined as the channel's long-term average.
> > > +      *** One-channel SAR. Replaces CH0-2 touch and proximity events if enabled
> > > +          via firmware.
> > > +
> > > +required:
> > > +  - compatible
> > > +  - linux,keycodes
> >
> > Add:
> >
> > additionalProperties: false
> >
>
> When I add this, the dt_binding_check step complains that the hall switch child nodes
> used in the examples are unrecognized, e.g.:
>
> iqs620a@44: keys: 'hall-switch-south' does not match any of the regexes: 'pinctrl-[0-9]+'
>
> When I originally encountered this, I found that the mdio-mux child node in [0] seems
> to be a similar example and omits additionalProperties, which is why I originally did
> that here. Do you have any advice on how to proceed?

That's because the properties are under an if/then. Your options are
split the schema into 2 files to eliminate the if/then or just define
"^hall-switch-(north|south)$" with just 'true' outside the if/then. A
variation on the 2nd option is invert the if/then and make the schema
false. Then the 'main' schema defines the full superset of properties
and the if/then just filters out ones that don't apply in some cases.

>
> > > +
> > > +if:
> > > +  properties:
> > > +    compatible:
> > > +      contains:
> > > +        enum:
> > > +          - azoteq,iqs620a-keys
> > > +          - azoteq,iqs621-keys
> > > +          - azoteq,iqs622-keys
> > > +then:
> > > +  patternProperties:
> > > +    "^hall-switch-(north|south)$":
> > > +      type: object
> > > +      description:
> > > +        Represents north/south-field Hall-effect sensor touch or proximity
> > > +        events. Note that north/south-field orientation is reversed on the
> > > +        IQS620AXzCSR device due to its flip-chip package.
> > > +
> > > +      properties:
> > > +        linux,code:
> > > +          $ref: /schemas/types.yaml#/definitions/uint32
> > > +          description: Numeric switch code associated with the event.
> > > +
> > > +        azoteq,use-prox:
> > > +          $ref: /schemas/types.yaml#/definitions/flag
> > > +          description:
> > > +            If present, specifies that Hall-effect sensor reporting should
> > > +            use the device's wide-range proximity threshold instead of its
> > > +            close-range touch threshold (default).
> > > +
> > > +      required:
> > > +        - linux,code
> > > +
>
> Do you think I should specify additionalProperties: false within these child nodes?

Yes.
Jeff LaBundy Jan. 1, 2020, 9:32 p.m. UTC | #4
Hi Rob,

On Tue, Dec 24, 2019 at 02:55:41PM -0700, Rob Herring wrote:
> On Thu, Dec 19, 2019 at 9:00 PM Jeff LaBundy <jeff@labundy.com> wrote:
> >
> > Hi Rob,
> >
> > Thank you for your prompt review and your kind words. A couple of questions
> > and comments for you below.
> >
> > On Wed, Dec 18, 2019 at 05:52:52PM -0600, Rob Herring wrote:
> > > On Mon, Dec 09, 2019 at 12:38:32AM +0000, Jeff LaBundy wrote:
> > > > This patch adds device tree bindings for the Azoteq IQS620A, IQS621,
> > > > IQS622, IQS624 and IQS625 multi-function sensors.
> > > >
> > > > A total of three bindings are presented (one MFD and two child nodes);
> > > > they are submitted as a single patch because the child node bindings
> > > > have no meaning in the absence of the MFD binding.
> > > >
> > > > Signed-off-by: Jeff LaBundy <jeff@labundy.com>
> > > > ---
> > > > Changes in v2:
> > > >   - Removed "prox" child node and moved "keys" and "pwm" child nodes to their
> > > >     own bindings
> > > >   - Replaced linux,fw-file property with more common firmware-name property
> > > >   - Converted all bindings to YAML
> > >
> > > Good job for first go.
> > >
> > > >
> > > >  .../devicetree/bindings/input/iqs62x-keys.yaml     | 126 +++++++++++++++
> > > >  Documentation/devicetree/bindings/mfd/iqs62x.yaml  | 177 +++++++++++++++++++++
> > > >  .../devicetree/bindings/pwm/iqs620a-pwm.yaml       |  30 ++++
> > > >  3 files changed, 333 insertions(+)
> > > >  create mode 100644 Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > > >  create mode 100644 Documentation/devicetree/bindings/mfd/iqs62x.yaml
> > > >  create mode 100644 Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
> > >
> > > A couple of minor things below. With those fixed:
> > >
> > > Reviewed-by: Rob Herring <robh@kernel.org>
> > >
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/input/iqs62x-keys.yaml b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > > > new file mode 100644
> > > > index 0000000..e9b54e0
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
> > > > @@ -0,0 +1,126 @@
> > > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > > > +%YAML 1.2
> > > > +---
> > > > +$id: http://devicetree.org/schemas/input/iqs62x-keys.yaml#
> > > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > > +
> > > > +title: Azoteq IQS620A/621/622/624/625 Keys and Switches
> > > > +
> > > > +maintainers:
> > > > +  - Jeff LaBundy <jeff@labundy.com>
> > > > +
> > > > +description: |
> > > > +  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
> > > > +  feature a variety of self-capacitive, mutual-inductive and Hall-effect sens-
> > > > +  ing capabilities that can facilitate a variety of contactless key and switch
> > > > +  applications.
> > > > +
> > > > +  These functions are collectively represented by a "keys" child node from the
> > > > +  parent MFD driver. See Documentation/devicetree/bindings/mfd/iqs62x.yaml for
> > > > +  further details and examples. Sensor hardware configuration (self-capacitive
> > > > +  vs. mutual-inductive, etc.) is selected based on the device's firmware.
> > > > +
> > > > +properties:
> > > > +  compatible:
> > > > +    enum:
> > > > +      - azoteq,iqs620a-keys
> > > > +      - azoteq,iqs621-keys
> > > > +      - azoteq,iqs622-keys
> > > > +      - azoteq,iqs624-keys
> > > > +      - azoteq,iqs625-keys
> > > > +
> > > > +  linux,keycodes:
> > > > +    allOf:
> > > > +      - $ref: /schemas/types.yaml#/definitions/uint32-array
> > > > +      - minItems: 1
> > > > +        maxItems: 16
> > > > +    description: |
> > > > +      Specifies the numeric keycodes associated with each available touch or
> > > > +      proximity event according to the following table. An 'x' indicates the
> > > > +      event is supported for a given device. Specify 0 for unused events.
> > > > +
> > > > +      -------------------------------------------------------------------------
> > > > +      | #  | Event              | IQS620A | IQS621 | IQS622 | IQS624 | IQS625 |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 0  | CH0 Touch          |    x    |    x   |    x   |    x   |    x   |
> > > > +      |    | Antenna 1 Touch*   |    x    |        |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 1  | CH0 Proximity      |    x    |    x   |    x   |    x   |    x   |
> > > > +      |    | Antenna 1 Prox.*   |    x    |        |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 2  | CH1 Touch          |    x    |    x   |    x   |    x   |    x   |
> > > > +      |    | Ant. 1 Deep Touch* |    x    |        |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 3  | CH1 Proximity      |    x    |    x   |    x   |    x   |    x   |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 4  | CH2 Touch          |    x    |        |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 5  | CH2 Proximity      |    x    |        |        |        |        |
> > > > +      |    | Antenna 2 Prox.*   |    x    |        |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 6  | Metal (+) Touch**  |    x    |    x   |        |        |        |
> > > > +      |    | Ant. 2 Deep Touch* |    x    |        |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 7  | Metal (+) Prox.**  |    x    |    x   |        |        |        |
> > > > +      |    | Antenna 2 Touch*   |    x    |        |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 8  | Metal (-) Touch**  |    x    |    x   |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 9  | Metal (-) Prox.**  |    x    |    x   |        |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 10 | SAR Active***      |    x    |        |    x   |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 11 | SAR Quick Rel.***  |    x    |        |    x   |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 12 | SAR Movement***    |    x    |        |    x   |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 13 | SAR Filter Halt*** |    x    |        |    x   |        |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 14 | Wheel Up           |         |        |        |    x   |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      | 15 | Wheel Down         |         |        |        |    x   |        |
> > > > +      -------------------------------------------------------------------------
> > > > +      *   Two-channel SAR. Replaces CH0-2 plus metal touch and proximity events
> > > > +          if enabled via firmware.
> > > > +      **  "+" and "-" refer to the polarity of a channel's delta (LTA - counts),
> > > > +          where "LTA" is defined as the channel's long-term average.
> > > > +      *** One-channel SAR. Replaces CH0-2 touch and proximity events if enabled
> > > > +          via firmware.
> > > > +
> > > > +required:
> > > > +  - compatible
> > > > +  - linux,keycodes
> > >
> > > Add:
> > >
> > > additionalProperties: false
> > >
> >
> > When I add this, the dt_binding_check step complains that the hall switch child nodes
> > used in the examples are unrecognized, e.g.:
> >
> > iqs620a@44: keys: 'hall-switch-south' does not match any of the regexes: 'pinctrl-[0-9]+'
> >
> > When I originally encountered this, I found that the mdio-mux child node in [0] seems
> > to be a similar example and omits additionalProperties, which is why I originally did
> > that here. Do you have any advice on how to proceed?
> 
> That's because the properties are under an if/then. Your options are
> split the schema into 2 files to eliminate the if/then or just define
> "^hall-switch-(north|south)$" with just 'true' outside the if/then. A
> variation on the 2nd option is invert the if/then and make the schema
> false. Then the 'main' schema defines the full superset of properties
> and the if/then just filters out ones that don't apply in some cases.
> 

Thank you for this detailed explanation; it all makes sense now. For v3
I've opted for the variant of option (2) because it allows for a single
binding as I originally intended, and prompts dt_binding_check to throw
an error if a dts author mistakenly defines the hall-switch-north/south
nodes within either of the two devices that don't support that feature.
I also find it simpler and more intuitive.

> >
> > > > +
> > > > +if:
> > > > +  properties:
> > > > +    compatible:
> > > > +      contains:
> > > > +        enum:
> > > > +          - azoteq,iqs620a-keys
> > > > +          - azoteq,iqs621-keys
> > > > +          - azoteq,iqs622-keys
> > > > +then:
> > > > +  patternProperties:
> > > > +    "^hall-switch-(north|south)$":
> > > > +      type: object
> > > > +      description:
> > > > +        Represents north/south-field Hall-effect sensor touch or proximity
> > > > +        events. Note that north/south-field orientation is reversed on the
> > > > +        IQS620AXzCSR device due to its flip-chip package.
> > > > +
> > > > +      properties:
> > > > +        linux,code:
> > > > +          $ref: /schemas/types.yaml#/definitions/uint32
> > > > +          description: Numeric switch code associated with the event.
> > > > +
> > > > +        azoteq,use-prox:
> > > > +          $ref: /schemas/types.yaml#/definitions/flag
> > > > +          description:
> > > > +            If present, specifies that Hall-effect sensor reporting should
> > > > +            use the device's wide-range proximity threshold instead of its
> > > > +            close-range touch threshold (default).
> > > > +
> > > > +      required:
> > > > +        - linux,code
> > > > +
> >
> > Do you think I should specify additionalProperties: false within these child nodes?
> 
> Yes.

Sure thing, will do.

FYI, since these additional changes are quite small and I believe I've
implemented them exactly as you've suggested, I plan on retaining your
Reviewed-by for v3 which I'll be sending out soon. However if you find
that I have misinterpreted anything, please let me know and I will fix
it promptly.

Wishing you a Happy New Year,
Jeff LaBundy
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/input/iqs62x-keys.yaml b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
new file mode 100644
index 0000000..e9b54e0
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/iqs62x-keys.yaml
@@ -0,0 +1,126 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/iqs62x-keys.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Azoteq IQS620A/621/622/624/625 Keys and Switches
+
+maintainers:
+  - Jeff LaBundy <jeff@labundy.com>
+
+description: |
+  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
+  feature a variety of self-capacitive, mutual-inductive and Hall-effect sens-
+  ing capabilities that can facilitate a variety of contactless key and switch
+  applications.
+
+  These functions are collectively represented by a "keys" child node from the
+  parent MFD driver. See Documentation/devicetree/bindings/mfd/iqs62x.yaml for
+  further details and examples. Sensor hardware configuration (self-capacitive
+  vs. mutual-inductive, etc.) is selected based on the device's firmware.
+
+properties:
+  compatible:
+    enum:
+      - azoteq,iqs620a-keys
+      - azoteq,iqs621-keys
+      - azoteq,iqs622-keys
+      - azoteq,iqs624-keys
+      - azoteq,iqs625-keys
+
+  linux,keycodes:
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32-array
+      - minItems: 1
+        maxItems: 16
+    description: |
+      Specifies the numeric keycodes associated with each available touch or
+      proximity event according to the following table. An 'x' indicates the
+      event is supported for a given device. Specify 0 for unused events.
+
+      -------------------------------------------------------------------------
+      | #  | Event              | IQS620A | IQS621 | IQS622 | IQS624 | IQS625 |
+      -------------------------------------------------------------------------
+      | 0  | CH0 Touch          |    x    |    x   |    x   |    x   |    x   |
+      |    | Antenna 1 Touch*   |    x    |        |        |        |        |
+      -------------------------------------------------------------------------
+      | 1  | CH0 Proximity      |    x    |    x   |    x   |    x   |    x   |
+      |    | Antenna 1 Prox.*   |    x    |        |        |        |        |
+      -------------------------------------------------------------------------
+      | 2  | CH1 Touch          |    x    |    x   |    x   |    x   |    x   |
+      |    | Ant. 1 Deep Touch* |    x    |        |        |        |        |
+      -------------------------------------------------------------------------
+      | 3  | CH1 Proximity      |    x    |    x   |    x   |    x   |    x   |
+      -------------------------------------------------------------------------
+      | 4  | CH2 Touch          |    x    |        |        |        |        |
+      -------------------------------------------------------------------------
+      | 5  | CH2 Proximity      |    x    |        |        |        |        |
+      |    | Antenna 2 Prox.*   |    x    |        |        |        |        |
+      -------------------------------------------------------------------------
+      | 6  | Metal (+) Touch**  |    x    |    x   |        |        |        |
+      |    | Ant. 2 Deep Touch* |    x    |        |        |        |        |
+      -------------------------------------------------------------------------
+      | 7  | Metal (+) Prox.**  |    x    |    x   |        |        |        |
+      |    | Antenna 2 Touch*   |    x    |        |        |        |        |
+      -------------------------------------------------------------------------
+      | 8  | Metal (-) Touch**  |    x    |    x   |        |        |        |
+      -------------------------------------------------------------------------
+      | 9  | Metal (-) Prox.**  |    x    |    x   |        |        |        |
+      -------------------------------------------------------------------------
+      | 10 | SAR Active***      |    x    |        |    x   |        |        |
+      -------------------------------------------------------------------------
+      | 11 | SAR Quick Rel.***  |    x    |        |    x   |        |        |
+      -------------------------------------------------------------------------
+      | 12 | SAR Movement***    |    x    |        |    x   |        |        |
+      -------------------------------------------------------------------------
+      | 13 | SAR Filter Halt*** |    x    |        |    x   |        |        |
+      -------------------------------------------------------------------------
+      | 14 | Wheel Up           |         |        |        |    x   |        |
+      -------------------------------------------------------------------------
+      | 15 | Wheel Down         |         |        |        |    x   |        |
+      -------------------------------------------------------------------------
+      *   Two-channel SAR. Replaces CH0-2 plus metal touch and proximity events
+          if enabled via firmware.
+      **  "+" and "-" refer to the polarity of a channel's delta (LTA - counts),
+          where "LTA" is defined as the channel's long-term average.
+      *** One-channel SAR. Replaces CH0-2 touch and proximity events if enabled
+          via firmware.
+
+required:
+  - compatible
+  - linux,keycodes
+
+if:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - azoteq,iqs620a-keys
+          - azoteq,iqs621-keys
+          - azoteq,iqs622-keys
+then:
+  patternProperties:
+    "^hall-switch-(north|south)$":
+      type: object
+      description:
+        Represents north/south-field Hall-effect sensor touch or proximity
+        events. Note that north/south-field orientation is reversed on the
+        IQS620AXzCSR device due to its flip-chip package.
+
+      properties:
+        linux,code:
+          $ref: /schemas/types.yaml#/definitions/uint32
+          description: Numeric switch code associated with the event.
+
+        azoteq,use-prox:
+          $ref: /schemas/types.yaml#/definitions/flag
+          description:
+            If present, specifies that Hall-effect sensor reporting should
+            use the device's wide-range proximity threshold instead of its
+            close-range touch threshold (default).
+
+      required:
+        - linux,code
+
+...
diff --git a/Documentation/devicetree/bindings/mfd/iqs62x.yaml b/Documentation/devicetree/bindings/mfd/iqs62x.yaml
new file mode 100644
index 0000000..24e6004
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/iqs62x.yaml
@@ -0,0 +1,177 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/iqs62x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Azoteq IQS620A/621/622/624/625 Multi-Function Sensors
+
+maintainers:
+  - Jeff LaBundy <jeff@labundy.com>
+
+description: |
+  The Azoteq IQS620A, IQS621, IQS622, IQS624 and IQS625 multi-function sensors
+  integrate multiple sensing technologies in a single package.
+
+  Link to data sheets: https://www.azoteq.com/
+
+properties:
+  compatible:
+    enum:
+      - azoteq,iqs620a
+      - azoteq,iqs621
+      - azoteq,iqs622
+      - azoteq,iqs624
+      - azoteq,iqs625
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  firmware-name:
+    $ref: /schemas/types.yaml#/definitions/string
+    description:
+      Specifies the name of the calibration and configuration file selected by
+      the driver. If this property is omitted, the name is chosen based on the
+      device name with ".bin" as the extension (e.g. iqs620a.bin for IQS620A).
+
+  keys:
+    $ref: ../input/iqs62x-keys.yaml
+
+  pwm:
+    $ref: ../pwm/iqs620a-pwm.yaml
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+examples:
+  - |
+    /*
+     * Dual capacitive buttons with additional "air button," unipolar lid
+     * switch and panel-mounted LED.
+     */
+    #include <dt-bindings/input/input.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            iqs620a@44 {
+                    compatible = "azoteq,iqs620a";
+                    reg = <0x44>;
+                    interrupt-parent = <&gpio>;
+                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
+
+                    keys {
+                            compatible = "azoteq,iqs620a-keys";
+
+                            linux,keycodes = <KEY_SELECT>,
+                                             <KEY_MENU>,
+                                             <KEY_OK>,
+                                             <KEY_MENU>;
+
+                            hall-switch-south {
+                                    linux,code = <SW_LID>;
+                                    azoteq,use-prox;
+                            };
+                    };
+
+                    iqs620a_pwm: pwm {
+                            compatible = "azoteq,iqs620a-pwm";
+                            #pwm-cells = <2>;
+                    };
+            };
+    };
+
+    pwmleds {
+            compatible = "pwm-leds";
+
+            panel {
+                    pwms = <&iqs620a_pwm 0 1000000>;
+                    max-brightness = <255>;
+            };
+    };
+
+  - |
+    /* Single inductive button with bipolar dock/tablet-mode switch. */
+    #include <dt-bindings/input/input.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            iqs620a@44 {
+                    compatible = "azoteq,iqs620a";
+                    reg = <0x44>;
+                    interrupt-parent = <&gpio>;
+                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
+
+                    firmware-name = "iqs620a_coil.bin";
+
+                    keys {
+                            compatible = "azoteq,iqs620a-keys";
+
+                            linux,keycodes = <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <KEY_MUTE>;
+
+                            hall-switch-north {
+                                    linux,code = <SW_DOCK>;
+                            };
+
+                            hall-switch-south {
+                                    linux,code = <SW_TABLET_MODE>;
+                            };
+                    };
+            };
+    };
+
+  - |
+    /* Dual capacitive buttons with volume knob. */
+    #include <dt-bindings/input/input.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            iqs624@44 {
+                    compatible = "azoteq,iqs624";
+                    reg = <0x44>;
+                    interrupt-parent = <&gpio>;
+                    interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
+
+                    keys {
+                            compatible = "azoteq,iqs624-keys";
+
+                            linux,keycodes = <BTN_0>,
+                                             <0>,
+                                             <BTN_1>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <0>,
+                                             <KEY_VOLUMEUP>,
+                                             <KEY_VOLUMEDOWN>;
+                    };
+            };
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml b/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
new file mode 100644
index 0000000..6b7aaef
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/iqs620a-pwm.yaml
@@ -0,0 +1,30 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pwm/iqs620a-pwm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Azoteq IQS620A PWM Generator
+
+maintainers:
+  - Jeff LaBundy <jeff@labundy.com>
+
+description: |
+  The Azoteq IQS620A multi-function sensor generates a fixed-frequency PWM
+  output represented by a "pwm" child node from the parent MFD driver. See
+  Documentation/devicetree/bindings/mfd/iqs62x.yaml for further details as
+  well as an example.
+
+properties:
+  compatible:
+    enum:
+      - azoteq,iqs620a-pwm
+
+  "#pwm-cells":
+    const: 2
+
+required:
+  - compatible
+  - "#pwm-cells"
+
+...