# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/power/supply/sc27xx-fg.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Spreadtrum SC27XX PMICs Fuel Gauge Unit Power Supply

maintainers:
  - Sebastian Reichel <sre@kernel.org>

allOf:
  - $ref: power-supply.yaml#

properties:
  compatible:
    enum:
      - sprd,sc2720-fgu
      - sprd,sc2721-fgu
      - sprd,sc2723-fgu
      - sprd,sc2730-fgu
      - sprd,sc2731-fgu

  reg:
    maxItems: 1

  battery-detect-gpios:
    maxItems: 1

  io-channels:
    items:
      - description: Battery Temperature ADC
      - description: Battery Charge Voltage ADC

  io-channel-names:
    items:
      - const: bat-temp
      - const: charge-vol

  nvmem-cells:
    maxItems: 1
    description: Calibration cells provided by eFuse device

  nvmem-cell-names:
    const: fgu_calib

  sprd,calib-resistance-micro-ohms:
    description: real resistance of coulomb counter chip in micro Ohms

  monitored-battery: true

required:
  - compatible
  - reg
  - battery-detect-gpios
  - io-channels
  - io-channel-names
  - nvmem-cells
  - nvmem-cell-names
  - sprd,calib-resistance-micro-ohms
  - monitored-battery

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    bat: battery {
      compatible = "simple-battery";
      charge-full-design-microamp-hours = <1900000>;
      constant-charge-voltage-max-microvolt = <4350000>;
      ocv-capacity-celsius = <20>;
      ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>,
                             <4022000 85>, <3983000 80>, <3949000 75>,
                             <3917000 70>, <3889000 65>, <3864000 60>,
                             <3835000 55>, <3805000 50>, <3787000 45>,
                             <3777000 40>, <3773000 35>, <3770000 30>,
                             <3765000 25>, <3752000 20>, <3724000 15>,
                             <3680000 10>, <3605000 5>, <3400000 0>;
                             // ...
    };

    pmic {
      #address-cells = <1>;
      #size-cells = <0>;

      battery@a00 {
        compatible = "sprd,sc2731-fgu";
        reg = <0xa00>;
        battery-detect-gpios = <&pmic_eic 9 GPIO_ACTIVE_HIGH>;
        io-channels = <&pmic_adc 5>, <&pmic_adc 14>;
        io-channel-names = "bat-temp", "charge-vol";
        nvmem-cells = <&fgu_calib>;
        nvmem-cell-names = "fgu_calib";
        monitored-battery = <&bat>;
        sprd,calib-resistance-micro-ohms = <21500>;
      };
    };