mbox series

[00/38] Convert power-supply DT bindings to YAML

Message ID 20210312154357.1561730-1-sebastian.reichel@collabora.com
Headers show
Series Convert power-supply DT bindings to YAML | expand

Message

Sebastian Reichel March 12, 2021, 3:43 p.m. UTC
Hi,

I keep getting patches for existing drivers, that modify DT behaviour
without updating the binding file. Let's move everything to DT schema
files, so that this can easily be cached automatically by dtbs_check.

After this series only three bindings are left unconverted:

1. max8925_battery.txt
   This describes a node below the PMIC, which does not have its own
   compatible value. It needs to be described in the PMIC binding
   file, which has not yet been converted.

2. stericsson,ab8500-battery.txt
   This also describes a node below the PMIC, which does not have
   its own compatible value. The same applies.

3. charger-manager.txt
   This is far more complex to convert than the other files, due
   to the 'cm-regulator-name' / "<>-supply" thing. I skipped it
   for now.

I tested the series using dt-validate 2021.3.dev6+g38efe3f and nothing
is reported when running dtbs_check like this:

make -s -j42 dtbs_check DT_SCHEMA_FILES="Documentation/devicetree/bindings/power/supply/*.yaml"

Also nothing is reported when checking the power-supply binding files
like this:

for file in Documentation/devicetree/bindings/power/supply/*yaml ; do
    make -s -j42 dt_binding_check DT_SCHEMA_FILES=$file ;
done

This is also available as 'psy-yaml-binding' branch from my repository:

https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git

Thanks for reviewing it,

-- Sebastian

Sebastian Reichel (38):
  ARM: dts: motorola-cpcap-mapphone: Prepare for dtbs_check parsing
  dt-bindings: power: supply: cpcap-battery: Convert to DT schema format
  dt-bindings: power: supply: cpcap-charger: Convert to DT schema format
  dt-bindings: power: supply: bq25890: Convert to DT schema format
  dt-bindings: power: supply: bq24257: Convert to DT schema format
  dt-bindings: power: supply: bq24190: Convert to DT schema format
  dt-bindings: power: supply: bq2415x: Convert to DT schema format
  dt-bindings: power: supply: bq24735: Convert to DT schema format
  dt-bindings: power: supply: isp1704: Convert to DT schema format
  dt-bindings: power: supply: sbs-charger: Convert to DT schema format
  dt-bindings: power: supply: sbs-manager: Convert to DT schema format
  dt-bindings: power: supply: ds2760: Convert to DT schema format
  dt-bindings: power: supply: sc27xx-fg: Convert to DT schema format
  dt-bindings: power: supply: sc2731-charger: Convert to DT schema
    format
  dt-bindings: power: supply: tps65090: Convert to DT schema format
  dt-bindings: power: supply: tps65217: Convert to DT schema format
  dt-bindings: power: supply: twl4030: Convert to DT schema format
  dt-bindings: power: supply: n900-battery: Convert to DT schema format
  dt-bindings: power: supply: lego-ev3-battery: Convert to DT schema
    format
  dt-bindings: power: supply: max17040: Convert to DT schema format
  dt-bindings: power: supply: max14656: Convert to DT schema format
  dt-bindings: power: supply: max17042: Convert to DT schema format
  dt-bindings: power: supply: max8903: Convert to DT schema format
  dt-bindings: power: supply: ucs1002: Convert to DT schema format
  dt-bindings: power: supply: pm8941-charger: Convert to DT schema
    format
  dt-bindings: power: supply: pm8941-coincell: Convert to DT schema
    format
  dt-bindings: power: supply: act8945a: Convert to DT schema format
  dt-bindings: power: supply: axp20x: Convert to DT schema format
  dt-bindings: power: supply: da9150: Convert to DT schema format
  dt-bindings: power: supply: lp8727: Convert to DT schema format
  dt-bindings: power: supply: lt3651: Convert to DT schema format
  dt-bindings: power: supply: ltc294x: Convert to DT schema format
  dt-bindings: power: supply: rt9455: Convert to DT schema format
  dt-bindings: power: supply: olpc-battery: Convert to DT schema format
  dt-bindings: power: supply: ab8500: Convert to DT schema format
  dt-bindings: power: supply: sbs-battery: Fix dtbs_check
  dt-bindings: power: supply: Fix remaining battery.txt links
  dt-bindings: power: supply: Drop power_supply.txt

 .../bindings/power/supply/ab8500/btemp.txt    |  16 --
 .../bindings/power/supply/ab8500/chargalg.txt |  16 --
 .../bindings/power/supply/ab8500/charger.txt  |  25 ---
 .../power/supply/act8945a-charger.txt         |  44 -----
 .../supply/active-semi,act8945a-charger.yaml  |  77 ++++++++
 .../bindings/power/supply/axp20x_ac_power.txt |  25 ---
 .../bindings/power/supply/axp20x_battery.txt  |  20 ---
 .../power/supply/axp20x_usb_power.txt         |  41 -----
 .../bindings/power/supply/battery.txt         |   3 -
 .../bindings/power/supply/bq2415x.txt         |  47 -----
 .../bindings/power/supply/bq2415x.yaml        |  98 ++++++++++
 .../bindings/power/supply/bq24190.txt         |  61 -------
 .../bindings/power/supply/bq24190.yaml        |  92 ++++++++++
 .../bindings/power/supply/bq24257.txt         |  62 -------
 .../bindings/power/supply/bq24257.yaml        | 124 +++++++++++++
 .../bindings/power/supply/bq24735.yaml        |  88 +++++++++
 .../bindings/power/supply/bq25890.txt         |  60 -------
 .../bindings/power/supply/bq25890.yaml        | 125 +++++++++++++
 .../bindings/power/supply/bq27xxx.yaml        |   2 +-
 .../bindings/power/supply/cpcap-battery.txt   |  31 ----
 .../bindings/power/supply/cpcap-battery.yaml  |  87 +++++++++
 .../bindings/power/supply/cpcap-charger.txt   |  40 -----
 .../bindings/power/supply/cpcap-charger.yaml  | 106 +++++++++++
 .../bindings/power/supply/da9150-charger.txt  |  26 ---
 .../bindings/power/supply/da9150-fg.txt       |  23 ---
 .../power/supply/dlg,da9150-charger.yaml      |  52 ++++++
 .../power/supply/dlg,da9150-fuel-gauge.yaml   |  51 ++++++
 .../bindings/power/supply/isp1704.txt         |  17 --
 .../bindings/power/supply/isp1704.yaml        |  42 +++++
 .../power/supply/lego,ev3-battery.yaml        |  55 ++++++
 .../power/supply/lego_ev3_battery.txt         |  21 ---
 .../power/supply/lltc,lt3651-charger.yaml     |  44 +++++
 .../bindings/power/supply/lltc,ltc294x.yaml   |  66 +++++++
 .../bindings/power/supply/lp8727_charger.txt  |  43 -----
 .../bindings/power/supply/lt3651-charger.txt  |  29 ---
 .../bindings/power/supply/ltc2941.txt         |  28 ---
 .../power/supply/max17040_battery.txt         |  52 ------
 .../power/supply/max17042_battery.txt         |  35 ----
 .../bindings/power/supply/max8903-charger.txt |  24 ---
 .../bindings/power/supply/maxim,ds2760.txt    |  26 ---
 .../bindings/power/supply/maxim,ds2760.yaml   |  45 +++++
 .../bindings/power/supply/maxim,max14656.txt  |  23 ---
 .../bindings/power/supply/maxim,max14656.yaml |  45 +++++
 .../bindings/power/supply/maxim,max17040.yaml |  95 ++++++++++
 .../bindings/power/supply/maxim,max17042.yaml |  78 ++++++++
 .../bindings/power/supply/maxim,max8903.yaml  |  67 +++++++
 .../power/supply/microchip,ucs1002.txt        |  27 ---
 .../power/supply/microchip,ucs1002.yaml       |  51 ++++++
 .../power/supply/nokia,n900-battery.yaml      |  49 +++++
 .../bindings/power/supply/olpc-battery.yaml   |  27 +++
 .../bindings/power/supply/olpc_battery.txt    |   5 -
 .../bindings/power/supply/power_supply.txt    |   2 -
 .../power/supply/qcom,coincell-charger.txt    |  48 -----
 .../power/supply/qcom,pm8941-charger.yaml     | 169 ++++++++++++++++++
 .../power/supply/qcom,pm8941-coincell.yaml    |  58 ++++++
 .../bindings/power/supply/qcom_smbb.txt       | 150 ----------------
 .../bindings/power/supply/richtek,rt9455.yaml |  90 ++++++++++
 .../bindings/power/supply/rohm,bd99954.yaml   |   2 +-
 .../bindings/power/supply/rt9455_charger.txt  |  46 -----
 .../bindings/power/supply/rx51-battery.txt    |  25 ---
 .../power/supply/sbs,sbs-battery.yaml         |   7 +-
 .../power/supply/sbs,sbs-charger.yaml         |  55 ++++++
 .../bindings/power/supply/sbs,sbs-manager.txt |  66 -------
 .../power/supply/sbs,sbs-manager.yaml         | 111 ++++++++++++
 .../bindings/power/supply/sbs_sbs-charger.txt |  21 ---
 .../bindings/power/supply/sc2731-charger.yaml |  53 ++++++
 .../bindings/power/supply/sc2731_charger.txt  |  40 -----
 .../bindings/power/supply/sc27xx-fg.txt       |  59 ------
 .../bindings/power/supply/sc27xx-fg.yaml      |  98 ++++++++++
 .../fg.txt => stericsson,ab8500-battery.txt}  |  32 +---
 .../power/supply/stericsson,ab8500-btemp.yaml |  73 ++++++++
 .../supply/stericsson,ab8500-chargalg.yaml    |  37 ++++
 .../supply/stericsson,ab8500-charger.yaml     | 123 +++++++++++++
 .../power/supply/stericsson,ab8500-fg.yaml    |  72 ++++++++
 .../bindings/power/supply/ti,bq24735.txt      |  39 ----
 .../bindings/power/supply/ti,lp8727.yaml      | 112 ++++++++++++
 .../power/supply/tps65090-charger.yaml        |  36 ++++
 .../bindings/power/supply/tps65090.txt        |  17 --
 .../power/supply/tps65217-charger.yaml        |  43 +++++
 .../power/supply/tps65217_charger.txt         |  17 --
 .../bindings/power/supply/twl-charger.txt     |  30 ----
 .../power/supply/twl4030-charger.yaml         |  68 +++++++
 .../x-powers,axp20x-ac-power-supply.yaml      |  32 ++++
 .../x-powers,axp20x-battery-power-supply.yaml |  30 ++++
 .../x-powers,axp20x-usb-power-supply.yaml     |  33 ++++
 .../arm/boot/dts/motorola-cpcap-mapphone.dtsi |  59 +++---
 86 files changed, 2896 insertions(+), 1493 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/power/supply/ab8500/btemp.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/ab8500/chargalg.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/ab8500/charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/act8945a-charger.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/active-semi,act8945a-charger.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/axp20x_ac_power.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/axp20x_battery.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/axp20x_usb_power.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/battery.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/bq2415x.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq2415x.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/bq24257.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq24257.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq24735.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/bq25890.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq25890.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/cpcap-battery.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/cpcap-battery.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/cpcap-charger.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/cpcap-charger.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/da9150-charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/da9150-fg.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/dlg,da9150-charger.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/dlg,da9150-fuel-gauge.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/isp1704.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/isp1704.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/lego,ev3-battery.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/lego_ev3_battery.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/lltc,lt3651-charger.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/lltc,ltc294x.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/lp8727_charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/lt3651-charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/ltc2941.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/max17040_battery.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/max17042_battery.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/max8903-charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/maxim,ds2760.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/maxim,ds2760.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/maxim,max14656.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/maxim,max14656.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/maxim,max17040.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/maxim,max8903.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/microchip,ucs1002.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/nokia,n900-battery.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/olpc-battery.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/olpc_battery.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/power_supply.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/qcom,coincell-charger.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/qcom,pm8941-charger.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/qcom,pm8941-coincell.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/qcom_smbb.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9455.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/rt9455_charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/rx51-battery.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/sbs,sbs-charger.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/sbs,sbs-manager.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/sbs,sbs-manager.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/sbs_sbs-charger.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/sc2731-charger.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/sc2731_charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/sc27xx-fg.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/sc27xx-fg.yaml
 rename Documentation/devicetree/bindings/power/supply/{ab8500/fg.txt => stericsson,ab8500-battery.txt} (52%)
 create mode 100644 Documentation/devicetree/bindings/power/supply/stericsson,ab8500-btemp.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/stericsson,ab8500-chargalg.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/stericsson,ab8500-charger.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/stericsson,ab8500-fg.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/ti,bq24735.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/ti,lp8727.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/tps65090-charger.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/tps65090.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
 delete mode 100644 Documentation/devicetree/bindings/power/supply/twl-charger.txt
 create mode 100644 Documentation/devicetree/bindings/power/supply/twl4030-charger.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/x-powers,axp20x-ac-power-supply.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml

Comments

Rob Herring March 15, 2021, 6:21 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>
> ---
>  .../bindings/power/supply/bq25890.txt         |  60 ---------
>  .../bindings/power/supply/bq25890.yaml        | 125 ++++++++++++++++++
>  2 files changed, 125 insertions(+), 60 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/power/supply/bq25890.txt
>  create mode 100644 Documentation/devicetree/bindings/power/supply/bq25890.yaml
>
> diff --git a/Documentation/devicetree/bindings/power/supply/bq25890.txt b/Documentation/devicetree/bindings/power/supply/bq25890.txt
> deleted file mode 100644
> index 805040c6fff9..000000000000
> --- a/Documentation/devicetree/bindings/power/supply/bq25890.txt
> +++ /dev/null
> @@ -1,60 +0,0 @@
> -Binding for TI bq25890 Li-Ion Charger
> -
> -This driver will support the bq25892, the bq25896 and the bq25890. There are
> -other ICs in the same family but those have not been tested.
> -
> -Required properties:
> -- compatible: Should contain one of the following:
> -    * "ti,bq25890"
> -    * "ti,bq25892"
> -    * "ti,bq25895"
> -    * "ti,bq25896"
> -- reg: integer, i2c address of the device.
> -- interrupts: interrupt line;
> -- ti,battery-regulation-voltage: integer, maximum charging voltage (in uV);
> -- ti,charge-current: integer, maximum charging current (in uA);
> -- ti,termination-current: integer, charge will be terminated when current in
> -    constant-voltage phase drops below this value (in uA);
> -- ti,precharge-current: integer, maximum charge current during precharge
> -    phase (in uA);
> -- ti,minimum-sys-voltage: integer, when battery is charging and it is below
> -    minimum system voltage, the system will be regulated above
> -    minimum-sys-voltage setting (in uV);
> -- ti,boost-voltage: integer, VBUS voltage level in boost mode (in uV);
> -- ti,boost-max-current: integer, maximum allowed current draw in boost mode
> -    (in uA).
> -
> -Optional properties:
> -- ti,boost-low-freq: boolean, if present boost mode frequency will be 500kHz,
> -    otherwise 1.5MHz;
> -- ti,use-ilim-pin: boolean, if present the ILIM resistor will be used and the
> -    input current will be the lower between the resistor setting and the IINLIM
> -    register setting;
> -- ti,thermal-regulation-threshold: integer, temperature above which the charge
> -    current is lowered, to avoid overheating (in degrees Celsius). If omitted,
> -    the default setting will be used (120 degrees);
> -- ti,ibatcomp-micro-ohms: integer, value of a resistor in series with
> -    the battery;
> -- ti,ibatcomp-clamp-microvolt: integer, maximum charging voltage adjustment due
> -    to expected voltage drop on in-series resistor;
> -
> -Example:
> -
> -bq25890 {
> -       compatible = "ti,bq25890";
> -       reg = <0x6a>;
> -
> -       interrupt-parent = <&gpio1>;
> -       interrupts = <16 IRQ_TYPE_EDGE_FALLING>;
> -
> -       ti,battery-regulation-voltage = <4200000>;
> -       ti,charge-current = <1000000>;
> -       ti,termination-current = <50000>;
> -       ti,precharge-current = <128000>;
> -       ti,minimum-sys-voltage = <3600000>;
> -       ti,boost-voltage = <5000000>;
> -       ti,boost-max-current = <1000000>;
> -
> -       ti,use-ilim-pin;
> -       ti,thermal-regulation-threshold = <120>;
> -};
> diff --git a/Documentation/devicetree/bindings/power/supply/bq25890.yaml b/Documentation/devicetree/bindings/power/supply/bq25890.yaml
> new file mode 100644
> index 000000000000..de6e03ec120c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/bq25890.yaml
> @@ -0,0 +1,125 @@
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 Sebastian Reichel
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/power/supply/bq25890.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Binding for bq25890, bq25892, bq25895 and bq25896 Li-Ion Charger
> +
> +maintainers:
> +  - Sebastian Reichel <sre@kernel.org>
> +
> +allOf:
> +  - $ref: power-supply.yaml#
> +
> +properties:
> +  compatible:
> +    enum:
> +      - ti,bq25890
> +      - ti,bq25892
> +      - ti,bq25895
> +      - ti,bq25896
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  ti,battery-regulation-voltage:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum charging voltage (in uV)
> +
> +  ti,charge-current:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum charging current (in uA)
> +
> +  ti,termination-current:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      charge will be terminated when current in constant-voltage phase
> +      drops below this value (in uA)
> +
> +  ti,precharge-current:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum charge current during precharge phase (in uA)
> +
> +  ti,minimum-sys-voltage:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      when battery is charging and it is below minimum system voltage,
> +      the system will be regulated above minimum-sys-voltage setting (in uV)
> +
> +  ti,boost-voltage:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: VBUS voltage level in boost mode (in uV)
> +
> +  ti,boost-max-current:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum allowed current draw in boost mode (in uA)
> +
> +  ti,boost-low-freq:
> +    description: boost mode frequency will be 500kHz, otherwise 1.5MHz
> +    type: boolean
> +
> +  ti,use-ilim-pin:
> +    description: |
> +      ILIM resistor will be used and the input current will be the lower
> +      between the resistor setting and the IINLIM register setting
> +    type: boolean
> +
> +  ti,thermal-regulation-threshold:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      temperature above which the charge current is lowered, to avoid overheating
> +      (in degrees Celsius). If omitted, the default setting will be used (120 degrees)
> +
> +  ti,ibatcomp-micro-ohms:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: value of a resistor in series with the battery (in Micro Ohms)
> +
> +  ti,ibatcomp-clamp-microvolt:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: max. charging voltage adjustment due to expected voltage drop on in-series resistor

You don't need a type $ref on properties with a standard unit suffix.
Though it looks like there's some non-standard ones (-microvolts) in
the series.

Rob
Rob Herring March 15, 2021, 6:24 p.m. UTC | #2
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>
> ---
>  .../bindings/power/supply/bq24735.yaml        | 88 +++++++++++++++++++
>  .../bindings/power/supply/ti,bq24735.txt      | 39 --------
>  2 files changed, 88 insertions(+), 39 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/bq24735.yaml
>  delete mode 100644 Documentation/devicetree/bindings/power/supply/ti,bq24735.txt
>
> diff --git a/Documentation/devicetree/bindings/power/supply/bq24735.yaml b/Documentation/devicetree/bindings/power/supply/bq24735.yaml
> new file mode 100644
> index 000000000000..8a3a31ada128
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/bq24735.yaml
> @@ -0,0 +1,88 @@
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 Sebastian Reichel
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/power/supply/bq24735.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Binding for TI BQ24735 Li-Ion Battery Charger
> +
> +maintainers:
> +  - Sebastian Reichel <sre@kernel.org>
> +
> +allOf:
> +  - $ref: power-supply.yaml#
> +
> +properties:
> +  compatible:
> +    const: ti,bq24735
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    description: AC adapter plug event interrupt
> +    maxItems: 1
> +
> +  ti,ac-detect-gpios:
> +    maxItems: 1
> +    description: |
> +      This GPIO is optionally used to read the AC adapter status. This is a Host GPIO
> +      that is configured as an input and connected to the ACOK pin on the bq24735.
> +      Note: for backwards compatibility reasons, the GPIO must be active on AC adapter
> +      absence despite ACOK being active (high) on AC adapter presence.
> +
> +  ti,charge-current:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      Used to control and set the charging current.
> +      This value must be between 128mA and 8.128A with a 64mA step resolution.
> +      The POR value is 0x0000h. This number is in mA (e.g. 8192).
> +      See spec for more information about the ChargeCurrent (0x14h) register.
> +
> +  ti,charge-voltage:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      Used to control and set the charging voltage.
> +      This value must be between 1.024V and 19.2V with a 16mV step resolution.
> +      The POR value is 0x0000h. This number is in mV (e.g. 19200).
> +      See spec for more information about the ChargeVoltage (0x15h) register.
> +
> +  ti,input-current:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      Used to control and set the charger input current.
> +      This value must be between 128mA and 8.064A with a 128mA step resolution.
> +      The POR value is 0x1000h. This number is in mA (e.g. 8064).
> +      See the spec for more information about the InputCurrent (0x3fh) register.
> +
> +  ti,external-control:
> +    type: boolean
> +    description: |
> +      Indicates that the charger is configured externally and that the host should not
> +      attempt to enable/disable charging or set the charge voltage/current.
> +
> +  poll-interval:
> +    description: |
> +      If 'interrupts' is not specified, poll AC adapter presence with this interval (milliseconds).

Needs a type.
Rob Herring March 15, 2021, 6:33 p.m. UTC | #3
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

>
Rob Herring March 15, 2021, 6:37 p.m. UTC | #4
On Fri, Mar 12, 2021 at 8:52 AM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Convert the binding to DT schema format.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  .../bindings/power/supply/lp8727_charger.txt  |  43 -------
>  .../bindings/power/supply/ti,lp8727.yaml      | 112 ++++++++++++++++++
>  2 files changed, 112 insertions(+), 43 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/power/supply/lp8727_charger.txt
>  create mode 100644 Documentation/devicetree/bindings/power/supply/ti,lp8727.yaml
>
> diff --git a/Documentation/devicetree/bindings/power/supply/lp8727_charger.txt b/Documentation/devicetree/bindings/power/supply/lp8727_charger.txt
> deleted file mode 100644
> index 0355a4b68f79..000000000000
> --- a/Documentation/devicetree/bindings/power/supply/lp8727_charger.txt
> +++ /dev/null
> @@ -1,43 +0,0 @@
> -Binding for TI/National Semiconductor LP8727 Charger
> -
> -Required properties:
> -- compatible: "ti,lp8727"
> -- reg: I2C slave address 27h
> -
> -Optional properties:
> -- interrupts: interrupt specifier (see interrupt binding[0])
> -- debounce-ms: interrupt debounce time. (u32)
> -
> -AC and USB charging parameters
> -- charger-type: "ac" or "usb" (string)
> -- eoc-level: value of 'enum lp8727_eoc_level' (u8)
> -- charging-current: value of 'enum lp8727_ichg' (u8)
> -
> -[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
> -
> -Example)
> -
> -lp8727@27 {
> -       compatible = "ti,lp8727";
> -       reg = <0x27>;
> -
> -       /* GPIO 134 is used for LP8728 interrupt pin */
> -       interrupt-parent = <&gpio5>;    /* base = 128 */
> -       interrupts = <6 0x2>;           /* offset = 6, falling edge type */
> -
> -       debounce-ms = <300>;
> -
> -       /* AC charger: 5% EOC and 500mA charging current */
> -       ac {
> -               charger-type = "ac";
> -               eoc-level = /bits/ 8 <0>;
> -               charging-current = /bits/ 8 <4>;
> -       };
> -
> -       /* USB charger: 10% EOC and 400mA charging current */
> -       usb {
> -               charger-type = "usb";
> -               eoc-level = /bits/ 8 <1>;
> -               charging-current = /bits/ 8 <2>;
> -       };
> -};
> diff --git a/Documentation/devicetree/bindings/power/supply/ti,lp8727.yaml b/Documentation/devicetree/bindings/power/supply/ti,lp8727.yaml
> new file mode 100644
> index 000000000000..65894b36a69d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/ti,lp8727.yaml
> @@ -0,0 +1,112 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/power/supply/ti,lp8727.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Binding for TI/National Semiconductor LP8727 Charger
> +
> +maintainers:
> +  - Sebastian Reichel <sre@kernel.org>
> +
> +allOf:
> +  - $ref: power-supply.yaml#
> +
> +properties:
> +  compatible:
> +    const: ti,lp8727
> +
> +  reg:
> +    const: 0x27
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  debounce-ms:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: interrupt debounce time in ms
> +
> +  ac:
> +    type: object
> +    description: AC charging parameters
> +    properties:
> +      charger-type:
> +        const: ac
> +
> +      eoc-level:
> +        $ref: /schemas/types.yaml#/definitions/uint8
> +        minimum: 0
> +        maximum: 6
> +        description: |
> +          End of Charge Percentage with the following mapping:
> +          0 = 5%, 1 = 10%, 2 = 16%, 3 = 20%, 4 = 25%, 5 = 33%, 6 = 50%
> +
> +      charging-current:
> +        $ref: /schemas/types.yaml#/definitions/uint8
> +        minimum: 0
> +        maximum: 9
> +        description: |
> +          Charging current with the following mapping:
> +          0 = 90mA, 1 = 100mA, 2 = 400mA, 3 = 450mA, 4 = 500mA, 5 = 600mA,
> +          6 = 700mA, 7 = 800mA, 8 = 900mA, 9 = 1000mA
> +
> +  usb:
> +    type: object
> +    description: USB charging parameters
> +    properties:
> +      charger-type:
> +        const: usb
> +
> +      eoc-level:
> +        $ref: /schemas/types.yaml#/definitions/uint8
> +        minimum: 0
> +        maximum: 6
> +        description: |
> +          End of Charge Percentage with the following mapping:
> +          0 = 5%, 1 = 10%, 2 = 16%, 3 = 20%, 4 = 25%, 5 = 33%, 6 = 50%
> +
> +      charging-current:
> +        $ref: /schemas/types.yaml#/definitions/uint8
> +        minimum: 0
> +        maximum: 9
> +        description: |
> +          Charging current with the following mapping:
> +          0 = 90mA, 1 = 100mA, 2 = 400mA, 3 = 450mA, 4 = 500mA, 5 = 600mA,
> +          6 = 700mA, 7 = 800mA, 8 = 900mA, 9 = 1000mA

You can avoid the duplication here with:

patternProperties:
  '^(ac|usb)$':
     type: object
     ...

> +
> +required:
> +  - compatible
> +  - reg
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +    i2c0 {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      lp8727: charger@27 {
> +        compatible = "ti,lp8727";
> +        reg = <0x27>;
> +        interrupt-parent = <&gpio5>;
> +        interrupts = <6 IRQ_TYPE_EDGE_FALLING>;
> +        debounce-ms = <300>;
> +
> +        /* AC charger: 5% EOC and 500mA charging current */
> +        ac {
> +          charger-type = "ac";
> +          eoc-level = /bits/ 8 <0>;
> +          charging-current = /bits/ 8 <4>;
> +        };
> +
> +        /* USB charger: 10% EOC and 400mA charging current */
> +        usb {
> +          charger-type = "usb";
> +          eoc-level = /bits/ 8 <1>;
> +          charging-current = /bits/ 8 <2>;
> +        };
> +      };
> +    };
> +
> --
> 2.30.1
>
Rob Herring March 15, 2021, 7:44 p.m. UTC | #5
On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Hi,
>
> I keep getting patches for existing drivers, that modify DT behaviour
> without updating the binding file. Let's move everything to DT schema
> files, so that this can easily be cached automatically by dtbs_check.
>
> After this series only three bindings are left unconverted:
>
> 1. max8925_battery.txt
>    This describes a node below the PMIC, which does not have its own
>    compatible value. It needs to be described in the PMIC binding
>    file, which has not yet been converted.
>
> 2. stericsson,ab8500-battery.txt
>    This also describes a node below the PMIC, which does not have
>    its own compatible value. The same applies.
>
> 3. charger-manager.txt
>    This is far more complex to convert than the other files, due
>    to the 'cm-regulator-name' / "<>-supply" thing. I skipped it
>    for now.
>
> I tested the series using dt-validate 2021.3.dev6+g38efe3f and nothing
> is reported when running dtbs_check like this:
>
> make -s -j42 dtbs_check DT_SCHEMA_FILES="Documentation/devicetree/bindings/power/supply/*.yaml"
>
> Also nothing is reported when checking the power-supply binding files
> like this:
>
> for file in Documentation/devicetree/bindings/power/supply/*yaml ; do
>     make -s -j42 dt_binding_check DT_SCHEMA_FILES=$file ;
> done
>
> This is also available as 'psy-yaml-binding' branch from my repository:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git
>
> Thanks for reviewing it,

Thanks for doing this. Other than the couple of things I pointed out,
looks good overall.

Rob
Sebastian Reichel March 16, 2021, 4:20 p.m. UTC | #6
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
Sebastian Reichel March 16, 2021, 4:22 p.m. UTC | #7
Hi,

On Mon, Mar 15, 2021 at 12:24:09PM -0600, Rob Herring wrote:
> On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel
> > +  poll-interval:
> > +    description: |
> > +      If 'interrupts' is not specified, poll AC adapter presence with this interval (milliseconds).
> 
> Needs a type.

Ack. Just out of curiousity: Do you know why this was not pointed
out by dt_binding_check?

-- Sebastian
Sebastian Reichel March 16, 2021, 4:46 p.m. UTC | #8
Hi,

On Mon, Mar 15, 2021 at 12:21:34PM -0600, Rob Herring wrote:
> On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel
> <sebastian.reichel@collabora.com> wrote:
> > +  ti,ibatcomp-clamp-microvolt:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: max. charging voltage adjustment due to expected voltage drop on in-series resistor
> 
> You don't need a type $ref on properties with a standard unit suffix.
> Though it looks like there's some non-standard ones (-microvolts) in
> the series.

Ok. Unfortunately most properties in this series use non-standard
ones :(. Newer bindings using common properties have already been
written in YAML and/or make use of simple-battery.

Can we have a warning for this in the dt_binding_check? Maybe
something like

superfluous $ref for property with standard suffix

-- Sebastian
Rob Herring March 16, 2021, 5:45 p.m. UTC | #9
On Tue, Mar 16, 2021 at 10:22 AM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Hi,
>
> On Mon, Mar 15, 2021 at 12:24:09PM -0600, Rob Herring wrote:
> > On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel
> > > +  poll-interval:
> > > +    description: |
> > > +      If 'interrupts' is not specified, poll AC adapter presence with this interval (milliseconds).
> >
> > Needs a type.
>
> Ack. Just out of curiousity: Do you know why this was not pointed
> out by dt_binding_check?

There's not really any way we can because there's not a pattern to
match on. So we'd have to do a specific meta-schema for
'poll-interval'. Though maybe we could restructure things to provide a
meta-schema for anything that isn't a common, known property name or a
vendor property.

Rob
Rob Herring March 16, 2021, 5:50 p.m. UTC | #10
On Tue, Mar 16, 2021 at 10:46 AM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>

> Hi,

>

> On Mon, Mar 15, 2021 at 12:21:34PM -0600, Rob Herring wrote:

> > On Fri, Mar 12, 2021 at 8:44 AM Sebastian Reichel

> > <sebastian.reichel@collabora.com> wrote:

> > > +  ti,ibatcomp-clamp-microvolt:

> > > +    $ref: /schemas/types.yaml#/definitions/uint32

> > > +    description: max. charging voltage adjustment due to expected voltage drop on in-series resistor

> >

> > You don't need a type $ref on properties with a standard unit suffix.

> > Though it looks like there's some non-standard ones (-microvolts) in

> > the series.

>

> Ok. Unfortunately most properties in this series use non-standard

> ones :(. Newer bindings using common properties have already been

> written in YAML and/or make use of simple-battery.

>

> Can we have a warning for this in the dt_binding_check? Maybe

> something like


Yeah, I'm working on that.

> superfluous $ref for property with standard suffix


And having more helpful error messages is on my todo, but not much BW
to work on ATM.

Rob
Rob Herring March 16, 2021, 5:52 p.m. UTC | #11
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