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/battery.yaml#
562306a36Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
662306a36Sopenharmony_ci
762306a36Sopenharmony_cititle: Battery Characteristics
862306a36Sopenharmony_ci
962306a36Sopenharmony_cimaintainers:
1062306a36Sopenharmony_ci  - Sebastian Reichel <sre@kernel.org>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cidescription: |
1362306a36Sopenharmony_ci  The devicetree battery node provides static battery characteristics.
1462306a36Sopenharmony_ci  In smart batteries, these are typically stored in non-volatile memory
1562306a36Sopenharmony_ci  on a fuel gauge chip. The battery node should be used where there is
1662306a36Sopenharmony_ci  no appropriate non-volatile memory, or it is unprogrammed/incorrect.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci  Upstream dts files should not include battery nodes, unless the battery
1962306a36Sopenharmony_ci  represented cannot easily be replaced in the system by one of a
2062306a36Sopenharmony_ci  different type. This prevents unpredictable, potentially harmful,
2162306a36Sopenharmony_ci  behavior should a replacement that changes the battery type occur
2262306a36Sopenharmony_ci  without a corresponding update to the dtb.
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci  Battery properties are named, where possible, for the corresponding elements
2562306a36Sopenharmony_ci  in enum power_supply_property, defined in include/linux/power_supply.h
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci  Batteries must be referenced by chargers and/or fuel-gauges using a phandle.
2862306a36Sopenharmony_ci  The phandle's property should be named "monitored-battery".
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciproperties:
3162306a36Sopenharmony_ci  compatible:
3262306a36Sopenharmony_ci    const: simple-battery
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci  device-chemistry:
3562306a36Sopenharmony_ci    description: This describes the chemical technology of the battery.
3662306a36Sopenharmony_ci    oneOf:
3762306a36Sopenharmony_ci      - const: nickel-cadmium
3862306a36Sopenharmony_ci      - const: nickel-metal-hydride
3962306a36Sopenharmony_ci      - const: lithium-ion
4062306a36Sopenharmony_ci        description: This is a blanket type for all lithium-ion batteries,
4162306a36Sopenharmony_ci          including those below. If possible, a precise compatible string
4262306a36Sopenharmony_ci          from below should be used, but sometimes it is unknown which specific
4362306a36Sopenharmony_ci          lithium ion battery is employed and this wide compatible can be used.
4462306a36Sopenharmony_ci      - const: lithium-ion-polymer
4562306a36Sopenharmony_ci      - const: lithium-ion-iron-phosphate
4662306a36Sopenharmony_ci      - const: lithium-ion-manganese-oxide
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci  over-voltage-threshold-microvolt:
4962306a36Sopenharmony_ci    description: battery over-voltage limit
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci  re-charge-voltage-microvolt:
5262306a36Sopenharmony_ci    description: limit to automatically start charging again
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci  voltage-min-design-microvolt:
5562306a36Sopenharmony_ci    description: drained battery voltage
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci  voltage-max-design-microvolt:
5862306a36Sopenharmony_ci    description: fully charged battery voltage
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci  energy-full-design-microwatt-hours:
6162306a36Sopenharmony_ci    description: battery design energy
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci  charge-full-design-microamp-hours:
6462306a36Sopenharmony_ci    description: battery design capacity
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci  trickle-charge-current-microamp:
6762306a36Sopenharmony_ci    description: current for trickle-charge phase
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci  precharge-current-microamp:
7062306a36Sopenharmony_ci    description: current for pre-charge phase
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci  precharge-upper-limit-microvolt:
7362306a36Sopenharmony_ci    description: limit when to change to constant charging
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci  charge-term-current-microamp:
7662306a36Sopenharmony_ci    description: current for charge termination phase
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci  constant-charge-current-max-microamp:
7962306a36Sopenharmony_ci    description: maximum constant input current
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci  constant-charge-voltage-max-microvolt:
8262306a36Sopenharmony_ci    description: maximum constant input voltage
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci  factory-internal-resistance-micro-ohms:
8562306a36Sopenharmony_ci    description: battery factory internal resistance
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci  resistance-temp-table:
8862306a36Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/uint32-matrix
8962306a36Sopenharmony_ci    items:
9062306a36Sopenharmony_ci      items:
9162306a36Sopenharmony_ci        - description: the temperature in degree Celsius
9262306a36Sopenharmony_ci        - description: battery internal resistance percent
9362306a36Sopenharmony_ci    description: |
9462306a36Sopenharmony_ci      A table providing the temperature in degree Celsius
9562306a36Sopenharmony_ci      and corresponding battery internal resistance percent, which is used to
9662306a36Sopenharmony_ci      look up the resistance percent according to current temperature to get an
9762306a36Sopenharmony_ci      accurate batterty internal resistance in different temperatures.
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci  ocv-capacity-celsius:
10062306a36Sopenharmony_ci    description: |
10162306a36Sopenharmony_ci      An array containing the temperature in degree Celsius,
10262306a36Sopenharmony_ci      for each of the battery capacity lookup table.
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci  operating-range-celsius:
10562306a36Sopenharmony_ci    description: operating temperature range of a battery
10662306a36Sopenharmony_ci    items:
10762306a36Sopenharmony_ci      - description: minimum temperature at which battery can operate
10862306a36Sopenharmony_ci      - description: maximum temperature at which battery can operate
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci  ambient-celsius:
11162306a36Sopenharmony_ci    description: safe range of ambient temperature
11262306a36Sopenharmony_ci    items:
11362306a36Sopenharmony_ci      - description: alert when ambient temperature is lower than this value
11462306a36Sopenharmony_ci      - description: alert when ambient temperature is higher than this value
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci  alert-celsius:
11762306a36Sopenharmony_ci    description: safe range of battery temperature
11862306a36Sopenharmony_ci    items:
11962306a36Sopenharmony_ci      - description: alert when battery temperature is lower than this value
12062306a36Sopenharmony_ci      - description: alert when battery temperature is higher than this value
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_cirequired:
12362306a36Sopenharmony_ci  - compatible
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_cipatternProperties:
12662306a36Sopenharmony_ci  '^ocv-capacity-table-[0-9]+$':
12762306a36Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/uint32-matrix
12862306a36Sopenharmony_ci    description: |
12962306a36Sopenharmony_ci      An array providing the open circuit voltage (OCV)
13062306a36Sopenharmony_ci      of the battery and corresponding battery capacity percent, which is used
13162306a36Sopenharmony_ci      to look up battery capacity according to current OCV value. And the open
13262306a36Sopenharmony_ci      circuit voltage unit is microvolt.
13362306a36Sopenharmony_ci    maxItems: 100
13462306a36Sopenharmony_ci    items:
13562306a36Sopenharmony_ci      items:
13662306a36Sopenharmony_ci        - description: open circuit voltage (OCV) in microvolts
13762306a36Sopenharmony_ci        - description: battery capacity percent
13862306a36Sopenharmony_ci          maximum: 100
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ciadditionalProperties: false
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ciexamples:
14362306a36Sopenharmony_ci  - |
14462306a36Sopenharmony_ci    power {
14562306a36Sopenharmony_ci      #address-cells = <1>;
14662306a36Sopenharmony_ci      #size-cells = <0>;
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci      battery: battery {
14962306a36Sopenharmony_ci        compatible = "simple-battery";
15062306a36Sopenharmony_ci        over-voltage-threshold-microvolt = <4500000>;
15162306a36Sopenharmony_ci        re-charge-voltage-microvolt = <250000>;
15262306a36Sopenharmony_ci        voltage-min-design-microvolt = <3200000>;
15362306a36Sopenharmony_ci        voltage-max-design-microvolt = <4200000>;
15462306a36Sopenharmony_ci        energy-full-design-microwatt-hours = <5290000>;
15562306a36Sopenharmony_ci        charge-full-design-microamp-hours = <1430000>;
15662306a36Sopenharmony_ci        precharge-current-microamp = <256000>;
15762306a36Sopenharmony_ci        precharge-upper-limit-microvolt = <2500000>;
15862306a36Sopenharmony_ci        charge-term-current-microamp = <128000>;
15962306a36Sopenharmony_ci        constant-charge-current-max-microamp = <900000>;
16062306a36Sopenharmony_ci        constant-charge-voltage-max-microvolt = <4200000>;
16162306a36Sopenharmony_ci        factory-internal-resistance-micro-ohms = <250000>;
16262306a36Sopenharmony_ci        ocv-capacity-celsius = <(-10) 0 10>;
16362306a36Sopenharmony_ci        /* table for -10 degree Celsius */
16462306a36Sopenharmony_ci        ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>;
16562306a36Sopenharmony_ci        /* table for 0 degree Celsius */
16662306a36Sopenharmony_ci        ocv-capacity-table-1 = <4200000 100>, <4185000 95>, <4113000 90>;
16762306a36Sopenharmony_ci        /* table for 10 degree Celsius */
16862306a36Sopenharmony_ci        ocv-capacity-table-2 = <4250000 100>, <4200000 95>, <4185000 90>;
16962306a36Sopenharmony_ci        resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>;
17062306a36Sopenharmony_ci        operating-range-celsius = <(-30) 50>;
17162306a36Sopenharmony_ci        ambient-celsius = <(-5) 50>;
17262306a36Sopenharmony_ci        alert-celsius = <0 40>;
17362306a36Sopenharmony_ci      };
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci      charger@11 {
17662306a36Sopenharmony_ci        reg = <0x11>;
17762306a36Sopenharmony_ci        monitored-battery = <&battery>;
17862306a36Sopenharmony_ci      };
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci      fuel-gauge@22 {
18162306a36Sopenharmony_ci        reg = <0x22>;
18262306a36Sopenharmony_ci        monitored-battery = <&battery>;
18362306a36Sopenharmony_ci      };
18462306a36Sopenharmony_ci    };
185