diff mbox series

[16/38] dt-bindings: power: supply: tps65217: Convert to DT schema format

Message ID 20210312154357.1561730-17-sebastian.reichel@collabora.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Convert power-supply DT bindings to YAML | expand

Commit Message

Sebastian Reichel March 12, 2021, 3:43 p.m. UTC
Convert the binding to DT schema format.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../power/supply/tps65217-charger.yaml        | 43 +++++++++++++++++++
 .../power/supply/tps65217_charger.txt         | 17 --------
 2 files changed, 43 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/tps65217_charger.txt

Comments

Rob Herring March 15, 2021, 6:33 p.m. UTC | #1
On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Convert the binding to DT schema format.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  .../power/supply/tps65217-charger.yaml        | 43 +++++++++++++++++++
>  .../power/supply/tps65217_charger.txt         | 17 --------
>  2 files changed, 43 insertions(+), 17 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
>  delete mode 100644 Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
>
> diff --git a/Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml b/Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
> new file mode 100644
> index 000000000000..a33408c3a407
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
> @@ -0,0 +1,43 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/power/supply/tps65217-charger.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: TPS65217 Charger
> +
> +maintainers:
> +  - Sebastian Reichel <sre@kernel.org>
> +
> +allOf:
> +  - $ref: power-supply.yaml#
> +
> +properties:
> +  compatible:
> +    const: ti,tps65217-charger
> +
> +  interrupts:
> +    minItems: 2
> +    maxItems: 2

We've lost info that was in the original binding. You could do
something like this:

items:
  - description: USB charger
    const: 0
  - description: AC charger
    const: 1

(Usually the interrupt values would be out of scope of the binding,
but I guess here it makes some sense.)

> +
> +  interrupt-names:
> +    items:
> +      - const: USB
> +      - const: AC
> +
> +required:
> +  - compatible
> +  - interrupts
> +  - interrupt-names
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    pmic {
> +      charger {
> +        compatible = "ti,tps65217-charger";
> +        interrupts = <0>, <1>;
> +        interrupt-names = "USB", "AC";
> +      };
> +    };
> diff --git a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
> deleted file mode 100644
> index a11072c5a866..000000000000
> --- a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -TPS65217 Charger
> -
> -Required Properties:
> --compatible: "ti,tps65217-charger"
> --interrupts: TPS65217 interrupt numbers for the AC and USB charger input change.
> -             Should be <0> for the USB charger and <1> for the AC adapter.
> --interrupt-names: Should be "USB" and "AC"
> -
> -This node is a subnode of the tps65217 PMIC.
> -
> -Example:
> -
> -       tps65217-charger {
> -               compatible = "ti,tps65217-charger";
> -               interrupts = <0>, <1>;
> -               interrupt-names = "USB", "AC";
> -       };
> --
> 2.30.1
>
Sebastian Reichel March 16, 2021, 4:20 p.m. UTC | #2
Hi Rob,

On Mon, Mar 15, 2021 at 12:33:23PM -0600, Rob Herring wrote:
> On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel
> <sebastian.reichel@collabora.com> wrote:
> > +  interrupts:
> > +    minItems: 2
> > +    maxItems: 2
> 
> We've lost info that was in the original binding. You could do
> something like this:
> 
> items:
>   - description: USB charger
>     const: 0
>   - description: AC charger
>     const: 1
> 
> (Usually the interrupt values would be out of scope of the binding,
> but I guess here it makes some sense.)

I initially did this, but it did not work. I see the following for
dt_binding_check (dtbs_check triggers the same):

Documentation/devicetree/bindings/power/supply/tps65217-charger.example.dt.yaml: charger: interrupts:0: [0] is too short
	From schema: Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
Documentation/devicetree/bindings/power/supply/tps65217-charger.example.dt.yaml: charger: interrupts: [[0], [1]] is too long
	From schema: Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
Documentation/devicetree/bindings/power/supply/tps65217-charger.example.dt.yaml: charger: interrupts: Additional items are not allowed ([1] was unexpected)
	From schema: Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml

Seemed to be a limitation in the validation tool, so I just dropped
the extra information. If we do not want to loose information I can
add it to the description, or should the validation tool be fixed?
I suppose it's kind of unusual, that the binding can provide the
interrupt line numbers.

-- Sebastian
Rob Herring March 16, 2021, 5:52 p.m. UTC | #3
On Tue, Mar 16, 2021 at 10:20 AM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Hi Rob,
>
> On Mon, Mar 15, 2021 at 12:33:23PM -0600, Rob Herring wrote:
> > On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel
> > <sebastian.reichel@collabora.com> wrote:
> > > +  interrupts:
> > > +    minItems: 2
> > > +    maxItems: 2
> >
> > We've lost info that was in the original binding. You could do
> > something like this:
> >
> > items:
> >   - description: USB charger
> >     const: 0
> >   - description: AC charger
> >     const: 1
> >
> > (Usually the interrupt values would be out of scope of the binding,
> > but I guess here it makes some sense.)
>
> I initially did this, but it did not work. I see the following for
> dt_binding_check (dtbs_check triggers the same):
>
> Documentation/devicetree/bindings/power/supply/tps65217-charger.example.dt.yaml: charger: interrupts:0: [0] is too short
>         From schema: Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
> Documentation/devicetree/bindings/power/supply/tps65217-charger.example.dt.yaml: charger: interrupts: [[0], [1]] is too long
>         From schema: Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
> Documentation/devicetree/bindings/power/supply/tps65217-charger.example.dt.yaml: charger: interrupts: Additional items are not allowed ([1] was unexpected)
>         From schema: Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
>
> Seemed to be a limitation in the validation tool, so I just dropped
> the extra information. If we do not want to loose information I can
> add it to the description, or should the validation tool be fixed?
> I suppose it's kind of unusual, that the binding can provide the
> interrupt line numbers.

It is, so let's just leave it as-is.

Rob
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml b/Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
new file mode 100644
index 000000000000..a33408c3a407
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
@@ -0,0 +1,43 @@ 
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/power/supply/tps65217-charger.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: TPS65217 Charger
+
+maintainers:
+  - Sebastian Reichel <sre@kernel.org>
+
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    const: ti,tps65217-charger
+
+  interrupts:
+    minItems: 2
+    maxItems: 2
+
+  interrupt-names:
+    items:
+      - const: USB
+      - const: AC
+      
+required:
+  - compatible
+  - interrupts
+  - interrupt-names
+
+additionalProperties: false
+
+examples:
+  - |
+    pmic {
+      charger {
+        compatible = "ti,tps65217-charger";
+        interrupts = <0>, <1>;
+        interrupt-names = "USB", "AC";
+      };
+    };
diff --git a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
deleted file mode 100644
index a11072c5a866..000000000000
--- a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
+++ /dev/null
@@ -1,17 +0,0 @@ 
-TPS65217 Charger
-
-Required Properties:
--compatible: "ti,tps65217-charger"
--interrupts: TPS65217 interrupt numbers for the AC and USB charger input change.
-             Should be <0> for the USB charger and <1> for the AC adapter.
--interrupt-names: Should be "USB" and "AC"
-
-This node is a subnode of the tps65217 PMIC.
-
-Example:
-
-	tps65217-charger {
-		compatible = "ti,tps65217-charger";
-		interrupts = <0>, <1>;
-		interrupt-names = "USB", "AC";
-	};