diff mbox series

[RFC] dt-bindings.yaml: power: supply: add bindings for TI bq24296/7

Message ID 7d7602574b5eda80bd1d40f79854ba3670201c6e.1585510588.git.hns@goldelico.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [RFC] dt-bindings.yaml: power: supply: add bindings for TI bq24296/7 | expand

Commit Message

H. Nikolaus Schaller March 29, 2020, 7:36 p.m. UTC
This is an attempt to define a schema for the bq24296/7
charger and power supply controllers with battery monitoring
and OTG booster.

We model it as a dual regulator because it can generate
a VSYS (with controllable voltage) and optionally an
OTG voltage either from the battery or from external power
supply.

This scheme works well with e.g. the dwc3 setup of the
OMAP5 to turn on OTG regulator on demand.

The DT should provide a reference to a monitored battery
description so that initial and operation parameters
of the battery can be specified to control the charger
parameters.

To support different initial charging current for USB
and AC charger mode, an optional gpio should be provided
that the driver can use to set defaults.

A driver is available and working for several years,
but the bindings should be clarified first.

The example shows what we are successfully using for
the working system.

Since the omap5 Pyra Handheld is not yet in the DTS tree,
there would be no explicit user of this driver. So
the plan is to submit a full patch set for the Pyra
later.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 .../bindings/power/supply/bq2429x.yaml        | 122 ++++++++++++++++++
 1 file changed, 122 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq2429x.yaml

Comments

Rob Herring (Arm) March 30, 2020, 3:43 p.m. UTC | #1
On Sun, 29 Mar 2020 21:36:29 +0200, "H. Nikolaus Schaller" wrote:
> This is an attempt to define a schema for the bq24296/7
> charger and power supply controllers with battery monitoring
> and OTG booster.
> 
> We model it as a dual regulator because it can generate
> a VSYS (with controllable voltage) and optionally an
> OTG voltage either from the battery or from external power
> supply.
> 
> This scheme works well with e.g. the dwc3 setup of the
> OMAP5 to turn on OTG regulator on demand.
> 
> The DT should provide a reference to a monitored battery
> description so that initial and operation parameters
> of the battery can be specified to control the charger
> parameters.
> 
> To support different initial charging current for USB
> and AC charger mode, an optional gpio should be provided
> that the driver can use to set defaults.
> 
> A driver is available and working for several years,
> but the bindings should be clarified first.
> 
> The example shows what we are successfully using for
> the working system.
> 
> Since the omap5 Pyra Handheld is not yet in the DTS tree,
> there would be no explicit user of this driver. So
> the plan is to submit a full patch set for the Pyra
> later.
> 
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
>  .../bindings/power/supply/bq2429x.yaml        | 122 ++++++++++++++++++
>  1 file changed, 122 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/bq2429x.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/bq2429x.yaml: properties:monitored-battery: [{'description': 'phandle to the battery node'}, {'allOf': [{'$ref': '/schemas/types.yaml#/definitions/phandle'}]}, {'enum': [{'voltage-max-design-microvolt': [{'default': 4200000}]}, {'voltage-min-design-microvolt': [{'default': 3200000}]}, {'constant-charge-current-max-microamp': [{'default': 'as defined by boot loader'}]}, {'precharge-current-microamp': [{'default': 128000}]}, {'charge-term-current-microamp': [{'default': 128000}]}]}] is not of type 'object', 'boolean'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/bq2429x.yaml: properties:dc-det-gpios: {'items': [{'description': 'gpio for detecting two different DC sources'}, {'default': 'use usb-input-current-microamp only'}]} is not valid under any of the given schemas (Possible causes of the failure):
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/bq2429x.yaml: properties:dc-det-gpios: 'maxItems' is a required property
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/bq2429x.yaml: properties:dc-det-gpios:items: [{'description': 'gpio for detecting two different DC sources'}, {'default': 'use usb-input-current-microamp only'}] is not valid under any of the given schemas (Possible causes of the failure):
		/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/bq2429x.yaml: properties:dc-det-gpios:items: [{'description': 'gpio for detecting two different DC sources'}, {'default': 'use usb-input-current-microamp only'}] is not of type 'object'
		/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/bq2429x.yaml: properties:dc-det-gpios:items:1:default: 'use usb-input-current-microamp only' is not of type 'integer'


Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/power/supply/bq2429x.example.dts' failed
make[1]: *** [Documentation/devicetree/bindings/power/supply/bq2429x.example.dts] Error 1
make[1]: *** Waiting for unfinished jobs....
warning: no schema found in file: Documentation/devicetree/bindings/power/supply/bq2429x.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/bq2429x.yaml: ignoring, error in schema: properties: monitored-battery
Makefile:1262: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2

See https://patchwork.ozlabs.org/patch/1263547

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/power/supply/bq2429x.yaml b/Documentation/devicetree/bindings/power/supply/bq2429x.yaml
new file mode 100644
index 000000000000..1b31ece4026e
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/bq2429x.yaml
@@ -0,0 +1,122 @@ 
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/bq2429x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI bq24296/24297 and MPS MP2624 Li-Ion Charger with OTG booster
+
+maintainers:
+  - H. Nikolaus Schaller <hns@goldelico.com>
+
+description: |+
+  This binding will support the bq24296 and bq24297.
+  There are other ICs in the same family but those have
+  not been addressed.
+  The MP2624 is very similar to the bq24297 but not exactly
+  identical.
+  This chip is used by the OMAP5 based Pyra-Handheld.
+
+properties:
+  compatible:
+    oneOf:
+      - const: mps,mp2624
+      - const: ti,bq24296
+      - const: ti,bq24297
+
+  reg:
+    const: 0x6b
+
+  interrupts:
+    minItems: 1
+
+  monitored-battery:
+    - description: phandle to the battery node
+    - allOf:
+      - $ref: /schemas/types.yaml#/definitions/phandle
+# QUESTION : how can we correctly describe that we support only the following phandle properties and ignore the others?
+    - enum:
+      - voltage-max-design-microvolt:
+        - default: 4200000
+      - voltage-min-design-microvolt:
+        - default: 3200000
+      - constant-charge-current-max-microamp:
+        - default: as defined by boot loader
+      - precharge-current-microamp:
+        - default: 128000
+      - charge-term-current-microamp:
+        - default: 128000
+
+  regulators:
+    minItems: 2
+    maxItems: 2
+    items:
+# QUESTION: can we specify that these are to be regulator nodes?
+      - description: |
+          two regulator child nodes for
+          [0] vsys (battery or usb input -> system output)
+          [1] otg (battery input -> usb output).
+
+  dc-det-gpios:
+    items:
+# QUESTION: how do we specify that it should be a gpio?
+      - description: gpio for detecting two different DC sources
+      - default: use usb-input-current-microamp only
+
+  ti,usb-input-current-microamp:
+    items:
+      - description: initial current for USB source (if dc-det is 0)
+      - default: value as defined by boot loader
+
+  ti,adp-input-current-microamp:
+    items:
+      - description: initial current for other source (if dc-det is 1)
+      - default: 2048000µA
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    bat: battery {
+      compatible = "simple-battery", "pyra-battery";
+      voltage-min-design-microvolt = <3200000>;
+      voltage-max-design-microvolt = <4200000>;
+      energy-full-design-microwatt-hours = <22200000>;
+      charge-full-design-microamp-hours = <6000000>;
+      charge-term-current-microamp = <128000>;
+      constant-charge-current-max-microamp = <1000000>;
+    };
+
+    bq24297@6b {
+      compatible = "ti,bq24297";
+      reg = <0x6b>;
+      monitored-battery = <&bat>;
+      interrupt-parent = <&gpio99>;
+      interrupts = <(1*8+3) IRQ_TYPE_EDGE_FALLING>;   /* P13 */
+      regulators {
+        vsys_reg: vsys_regulator {
+          regulator-compatible = "bq2429x-vsys";
+          regulator-name = "vsys";
+          regulator-min-microvolt = <3500000>;
+          regulator-max-microvolt = <4200000>;
+          regulator-always-on;
+          regulator-boot-on;
+        };
+        otg_reg: otg_regulator {
+          regulator-compatible = "bq2429x-otg";
+          regulator-name = "otg";
+          regulator-min-microvolt = <4900000>;
+          regulator-max-microvolt = <5100000>;
+        };
+      };
+    };
+
+...