162306a36Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
262306a36Sopenharmony_ci%YAML 1.2
362306a36Sopenharmony_ci---
462306a36Sopenharmony_ci$id: http://devicetree.org/schemas/power/supply/adc-battery.yaml#
562306a36Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
662306a36Sopenharmony_ci
762306a36Sopenharmony_cititle: ADC battery
862306a36Sopenharmony_ci
962306a36Sopenharmony_cimaintainers:
1062306a36Sopenharmony_ci  - Sebastian Reichel <sre@kernel.org>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cidescription:
1362306a36Sopenharmony_ci  Basic battery capacity meter, which only reports basic battery data
1462306a36Sopenharmony_ci  via ADC channels and optionally indicate that the battery is full by
1562306a36Sopenharmony_ci  polling a GPIO line.
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci  The voltage is expected to be measured between the battery terminals
1862306a36Sopenharmony_ci  and mandatory. The optional current/power channel is expected to
1962306a36Sopenharmony_ci  monitor the current/power flowing out of the battery. Last but not
2062306a36Sopenharmony_ci  least the temperature channel is supposed to measure the battery
2162306a36Sopenharmony_ci  temperature.
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciallOf:
2462306a36Sopenharmony_ci  - $ref: power-supply.yaml#
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciproperties:
2762306a36Sopenharmony_ci  compatible:
2862306a36Sopenharmony_ci    const: adc-battery
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci  charged-gpios:
3162306a36Sopenharmony_ci    description:
3262306a36Sopenharmony_ci      GPIO which signals that the battery is fully charged. The GPIO is
3362306a36Sopenharmony_ci      often provided by charger ICs, that are not software controllable.
3462306a36Sopenharmony_ci    maxItems: 1
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci  io-channels:
3762306a36Sopenharmony_ci    minItems: 1
3862306a36Sopenharmony_ci    maxItems: 4
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci  io-channel-names:
4162306a36Sopenharmony_ci    minItems: 1
4262306a36Sopenharmony_ci    items:
4362306a36Sopenharmony_ci      - const: voltage
4462306a36Sopenharmony_ci      - enum: [ current, power, temperature ]
4562306a36Sopenharmony_ci      - enum: [ power, temperature ]
4662306a36Sopenharmony_ci      - const: temperature
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci  monitored-battery: true
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cirequired:
5162306a36Sopenharmony_ci  - compatible
5262306a36Sopenharmony_ci  - io-channels
5362306a36Sopenharmony_ci  - io-channel-names
5462306a36Sopenharmony_ci  - monitored-battery
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciunevaluatedProperties: false
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ciexamples:
5962306a36Sopenharmony_ci  - |
6062306a36Sopenharmony_ci    #include <dt-bindings/gpio/gpio.h>
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci    fuel-gauge {
6362306a36Sopenharmony_ci        compatible = "adc-battery";
6462306a36Sopenharmony_ci        charged-gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
6562306a36Sopenharmony_ci        io-channels = <&adc 13>, <&adc 37>;
6662306a36Sopenharmony_ci        io-channel-names = "voltage", "current";
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci        power-supplies = <&charger>;
6962306a36Sopenharmony_ci        monitored-battery = <&battery>;
7062306a36Sopenharmony_ci    };
71