18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
28c2ecf20Sopenharmony_ci%YAML 1.2
38c2ecf20Sopenharmony_ci---
48c2ecf20Sopenharmony_ci$id: http://devicetree.org/schemas/power/supply/battery.yaml#
58c2ecf20Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cititle: Battery Characteristics
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cimaintainers:
108c2ecf20Sopenharmony_ci  - Sebastian Reichel <sre@kernel.org>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cidescription: |
138c2ecf20Sopenharmony_ci  The devicetree battery node provides static battery characteristics.
148c2ecf20Sopenharmony_ci  In smart batteries, these are typically stored in non-volatile memory
158c2ecf20Sopenharmony_ci  on a fuel gauge chip. The battery node should be used where there is
168c2ecf20Sopenharmony_ci  no appropriate non-volatile memory, or it is unprogrammed/incorrect.
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci  Upstream dts files should not include battery nodes, unless the battery
198c2ecf20Sopenharmony_ci  represented cannot easily be replaced in the system by one of a
208c2ecf20Sopenharmony_ci  different type. This prevents unpredictable, potentially harmful,
218c2ecf20Sopenharmony_ci  behavior should a replacement that changes the battery type occur
228c2ecf20Sopenharmony_ci  without a corresponding update to the dtb.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci  Battery properties are named, where possible, for the corresponding elements
258c2ecf20Sopenharmony_ci  in enum power_supply_property, defined in include/linux/power_supply.h
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci  Batteries must be referenced by chargers and/or fuel-gauges using a phandle.
288c2ecf20Sopenharmony_ci  The phandle's property should be named "monitored-battery".
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciproperties:
318c2ecf20Sopenharmony_ci  compatible:
328c2ecf20Sopenharmony_ci    const: simple-battery
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci  over-voltage-threshold-microvolt:
358c2ecf20Sopenharmony_ci    description: battery over-voltage limit
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci  re-charge-voltage-microvolt:
388c2ecf20Sopenharmony_ci    description: limit to automatically start charging again
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci  voltage-min-design-microvolt:
418c2ecf20Sopenharmony_ci    description: drained battery voltage
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci  voltage-max-design-microvolt:
448c2ecf20Sopenharmony_ci    description: fully charged battery voltage
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci  energy-full-design-microwatt-hours:
478c2ecf20Sopenharmony_ci    description: battery design energy
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci  charge-full-design-microamp-hours:
508c2ecf20Sopenharmony_ci    description: battery design capacity
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci  trickle-charge-current-microamp:
538c2ecf20Sopenharmony_ci    description: current for trickle-charge phase
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci  precharge-current-microamp:
568c2ecf20Sopenharmony_ci    description: current for pre-charge phase
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci  precharge-upper-limit-microvolt:
598c2ecf20Sopenharmony_ci    description: limit when to change to constant charging
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci  charge-term-current-microamp:
628c2ecf20Sopenharmony_ci    description: current for charge termination phase
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci  constant-charge-current-max-microamp:
658c2ecf20Sopenharmony_ci    description: maximum constant input current
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci  constant-charge-voltage-max-microvolt:
688c2ecf20Sopenharmony_ci    description: maximum constant input voltage
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci  factory-internal-resistance-micro-ohms:
718c2ecf20Sopenharmony_ci    description: battery factory internal resistance
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci  resistance-temp-table:
748c2ecf20Sopenharmony_ci    description: |
758c2ecf20Sopenharmony_ci      An array providing the temperature in degree Celsius
768c2ecf20Sopenharmony_ci      and corresponding battery internal resistance percent, which is used to
778c2ecf20Sopenharmony_ci      look up the resistance percent according to current temperature to get an
788c2ecf20Sopenharmony_ci      accurate batterty internal resistance in different temperatures.
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci  ocv-capacity-celsius:
818c2ecf20Sopenharmony_ci    description: |
828c2ecf20Sopenharmony_ci      An array containing the temperature in degree Celsius,
838c2ecf20Sopenharmony_ci      for each of the battery capacity lookup table.
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci  operating-range-celsius:
868c2ecf20Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/uint32-array
878c2ecf20Sopenharmony_ci    description: operating temperature range of a battery
888c2ecf20Sopenharmony_ci    items:
898c2ecf20Sopenharmony_ci      - description: minimum temperature at which battery can operate
908c2ecf20Sopenharmony_ci      - description: maximum temperature at which battery can operate
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci  ambient-celsius:
938c2ecf20Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/uint32-array
948c2ecf20Sopenharmony_ci    description: safe range of ambient temperature
958c2ecf20Sopenharmony_ci    items:
968c2ecf20Sopenharmony_ci      - description: alert when ambient temperature is lower than this value
978c2ecf20Sopenharmony_ci      - description: alert when ambient temperature is higher than this value
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci  alert-celsius:
1008c2ecf20Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/uint32-array
1018c2ecf20Sopenharmony_ci    description: safe range of battery temperature
1028c2ecf20Sopenharmony_ci    items:
1038c2ecf20Sopenharmony_ci      - description: alert when battery temperature is lower than this value
1048c2ecf20Sopenharmony_ci      - description: alert when battery temperature is higher than this value
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cirequired:
1078c2ecf20Sopenharmony_ci  - compatible
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cipatternProperties:
1108c2ecf20Sopenharmony_ci  '^ocv-capacity-table-[0-9]+$':
1118c2ecf20Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/uint32-matrix
1128c2ecf20Sopenharmony_ci    description: |
1138c2ecf20Sopenharmony_ci      An array providing the open circuit voltage (OCV)
1148c2ecf20Sopenharmony_ci      of the battery and corresponding battery capacity percent, which is used
1158c2ecf20Sopenharmony_ci      to look up battery capacity according to current OCV value. And the open
1168c2ecf20Sopenharmony_ci      circuit voltage unit is microvolt.
1178c2ecf20Sopenharmony_ci    maxItems: 100
1188c2ecf20Sopenharmony_ci    items:
1198c2ecf20Sopenharmony_ci      items:
1208c2ecf20Sopenharmony_ci        - description: open circuit voltage (OCV) in microvolts
1218c2ecf20Sopenharmony_ci        - description: battery capacity percent
1228c2ecf20Sopenharmony_ci          maximum: 100
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciadditionalProperties: false
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ciexamples:
1278c2ecf20Sopenharmony_ci  - |
1288c2ecf20Sopenharmony_ci    power {
1298c2ecf20Sopenharmony_ci      #address-cells = <1>;
1308c2ecf20Sopenharmony_ci      #size-cells = <0>;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci      battery: battery {
1338c2ecf20Sopenharmony_ci        compatible = "simple-battery";
1348c2ecf20Sopenharmony_ci        over-voltage-threshold-microvolt = <4500000>;
1358c2ecf20Sopenharmony_ci        re-charge-voltage-microvolt = <250000>;
1368c2ecf20Sopenharmony_ci        voltage-min-design-microvolt = <3200000>;
1378c2ecf20Sopenharmony_ci        voltage-max-design-microvolt = <4200000>;
1388c2ecf20Sopenharmony_ci        energy-full-design-microwatt-hours = <5290000>;
1398c2ecf20Sopenharmony_ci        charge-full-design-microamp-hours = <1430000>;
1408c2ecf20Sopenharmony_ci        precharge-current-microamp = <256000>;
1418c2ecf20Sopenharmony_ci        precharge-upper-limit-microvolt = <2500000>;
1428c2ecf20Sopenharmony_ci        charge-term-current-microamp = <128000>;
1438c2ecf20Sopenharmony_ci        constant-charge-current-max-microamp = <900000>;
1448c2ecf20Sopenharmony_ci        constant-charge-voltage-max-microvolt = <4200000>;
1458c2ecf20Sopenharmony_ci        factory-internal-resistance-micro-ohms = <250000>;
1468c2ecf20Sopenharmony_ci        ocv-capacity-celsius = <(-10) 0 10>;
1478c2ecf20Sopenharmony_ci        /* table for -10 degree Celsius */
1488c2ecf20Sopenharmony_ci        ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>;
1498c2ecf20Sopenharmony_ci        /* table for 0 degree Celsius */
1508c2ecf20Sopenharmony_ci        ocv-capacity-table-1 = <4200000 100>, <4185000 95>, <4113000 90>;
1518c2ecf20Sopenharmony_ci        /* table for 10 degree Celsius */
1528c2ecf20Sopenharmony_ci        ocv-capacity-table-2 = <4250000 100>, <4200000 95>, <4185000 90>;
1538c2ecf20Sopenharmony_ci        resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>;
1548c2ecf20Sopenharmony_ci        operating-range-celsius = <(-30) 50>;
1558c2ecf20Sopenharmony_ci        ambient-celsius = <(-5) 50>;
1568c2ecf20Sopenharmony_ci        alert-celsius = <0 40>;
1578c2ecf20Sopenharmony_ci      };
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci      charger@11 {
1608c2ecf20Sopenharmony_ci        reg = <0x11>;
1618c2ecf20Sopenharmony_ci        monitored-battery = <&battery>;
1628c2ecf20Sopenharmony_ci      };
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci      fuel-gauge@22 {
1658c2ecf20Sopenharmony_ci        reg = <0x22>;
1668c2ecf20Sopenharmony_ci        monitored-battery = <&battery>;
1678c2ecf20Sopenharmony_ci      };
1688c2ecf20Sopenharmony_ci    };
169