From df39221f780c3f79bb00fff6a28395a2ca4c02f7 Mon Sep 17 00:00:00 2001
From: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Date: Fri, 15 Jan 2021 11:22:13 +0100
Subject: [PATCH 67/78] dt-bindings: power: Add the bindings for SMB1360
 charger and fuel gauge.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
---
 .../bindings/power/supply/smb1360.yaml        | 262 ++++++++++++++++++
 1 file changed, 262 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/smb1360.yaml

diff --git a/Documentation/devicetree/bindings/power/supply/smb1360.yaml b/Documentation/devicetree/bindings/power/supply/smb1360.yaml
new file mode 100644
index 000000000..b94c98e03
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/smb1360.yaml
@@ -0,0 +1,262 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/power/supply/smb1360.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Qualcomm SMB1360 charger and fuel gauge
+
+maintainers:
+  - Jonathan Albrieux <jonathan.albrieux@gmail.com>
+
+description: |
+  Port for Qualcomm SMB1360 charger and fuel gauge downstream driver.
+
+  A brief overview of the chip can be found at:
+    https://www.qualcomm.com/products/quick-charge-10
+
+  Original code can be found at:
+    https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/master/drivers/power/smb1360-charger-fg.c
+
+properties:
+  compatible:
+    enum:
+      - qcom,smb1360
+
+  reg:
+    description: I2C address of the charger.
+
+  interrupts:
+    description:
+      IRQ number of the GPIO connected to the STAT pin.
+
+  qcom,rsense-10mohm:
+    type: boolean
+    description:
+      Indicates the Rsense resistor configuration.
+      If set, the Rsense is 10mOhm else it's 20mOhm.
+
+  qcom,float-voltage-mv:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The maximum voltage up to which the battery is charged.
+      This value is in mV.
+
+  qcom,iterm-ma:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Specifies the termination current to indicate end-of-charge.
+      Possible values in 25, 50, 75, 100, 125, 150, 175 and 200mA
+
+  qcom,charging-timeout:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Maximum duration in minutes that a single charge cycle may last.
+      Supported values are 0, 192, 384, 768, and 1536. A value of 0 means that
+      no charge cycle timeout is used and charging can continue indefinitely.
+
+  qcom,recharge-thresh-mv:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Specifies the minimum voltage drop in millivolts below the float voltage
+      that is required in order to initiate a new charging cycle.
+      Supported values are 50, 100, 200 and 300mV.
+
+  qcom,chg-inhibit-disabled:
+    type: boolean
+    description:
+      Disables the charger-inhibit function.
+
+  qcom,battery-profile:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Specifies the battery profile to use.
+      0 is for profile A, 1 is for profile B.
+    enum: [0,1]
+
+  qcom,fg-batt-capacity-mah:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The new battery capacity to be supported.
+      This updates the ACTUAL and NOMINAL CAPACITY of the profile.
+
+  qcom,fg-cc-soc-coeff:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The CC_TO_SOC_COEFF of the new battery capacity.
+      This value is calculated from the batt-capacity and then encoded
+      as floating number. cc_soc_coeff = HALF_ENCODING(8192 / batt-capacity)
+
+  qcom,fg-cutoff-voltage-mv:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This is the minimum allowed system voltage. The FG will report
+      SOC = 0 at this voltage. This value is in mV.
+
+  qcom,fg-iterm-ma:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This is termination current at which the Monotonic SOC reports 100.
+      The value passed here is negated in the driver (assuming that the iterm
+      is always -ve). This value is in mA.
+
+  qcom,fg-ibatt-standby-ma:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This is the minimum current value for the SOC to be above 0% at
+      the cutoff voltage. This value is in mA.
+
+  qcom,fg-cc-to-cv-mv:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This is the voltage at which the FG transitions from CC to CV.
+      This value should never be higher than the float voltage. This
+      value is in mV.
+
+  qcom,thermistor-c1-coeff:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      This is the NTC thermistor C1 coeff for the thermistor inside
+      the battery. This value is 16-bit float encoded value determined from the
+      NTC-c1_coeff mapping.
+
+  qcom,fg-auto-recharge-soc:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Defines the auto recharging SOC threshold.
+
+  qcom,otp-hard-jeita-config:
+    type: boolean
+    description:
+      Indicates if cold and hot thresholds need be modified.
+      If it's not defined, default temp thresholds [0, 55] will be used.
+
+  qcom,otp-hot-bat-decidegc:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Hot battery temperature in decidegC.
+
+  qcom,otp-cold-bat-decidegc:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Cold battery temperature in decidegC.
+
+  qcom,soft-jeita-config:
+    type: boolean
+    description:
+      Indicates if soft JEITA compensation should be enabled. When the soft
+      temperature limits are reached, the maximum voltage up to which battery
+      is charged is reduced and charging current is limited.
+
+  qcom,warm-bat-decidegc:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Warm battery temperature in decidegC.
+
+  qcom,cool-bat-decidegc:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Cool battery temperature in decidegC.
+
+  qcom,soft-jeita-comp-voltage-mv:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The battery target voltage that is used when the soft temperature
+      thresholds are reached.
+
+  qcom,soft-jeita-comp-current-ma:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The maximum charging current used when the soft temperature thresholds
+      are reached.
+
+  qcom,shdn-after-pwroff:
+    type: boolean
+    description:
+      Configure smb1360 for shutdown at power-off.
+
+  qcom,fg-reset-at-pon:
+    type: boolean
+    description:
+      Indicates if the FG reset at power-on is enabled.
+
+  qcom,fg-reset-threshold-mv:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Indicates the voltage threshold to reset the FG. It is compared against
+      the difference between in predicted voltage and current voltage.
+      If this value is not specified a default value of 50mV is used.
+      Unit is in milli-volts.
+
+  usb_otg_vbus:
+    description: Regulator controlling USB OTG VBUS.
+    # TODO: Reference regulator-max-microamps here somehow?
+
+dependencies:
+  qcom,otp-hard-jeita-config: [ 'qcom,otp-hot-bat-decidegc', 'qcom,otp-cold-bat-decidegc' ]
+  qcom,otp-hot-bat-decidegc: [ 'qcom,otp-hard-jeita-config' ]
+  qcom,otp-cold-bat-decidegc: [ 'qcom,otp-hard-jeita-config' ]
+  qcom,fg-cc-soc-coeff: [ 'qcom,fg-batt-capacity-mah' ]
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: true
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      charger: battery@14 {
+        compatible = "qcom,smb1360";
+        reg = <0x14>;
+
+        interrupt-parent = <&msmgpio>;
+        interrupts = <62 IRQ_TYPE_LEVEL_LOW>;
+
+        pinctrl-names = "default";
+        pinctrl-0 = <&smb_int_default>;
+
+        qcom,rsense-10mohm;
+
+        qcom,float-voltage-mv = <4400>;
+        qcom,iterm-ma = <100>;
+        qcom,charging-timeout = <192>;
+        qcom,recharge-thresh-mv = <50>;
+        qcom,chg-inhibit-disabled;
+
+        qcom,battery-profile = <0>;
+
+        qcom,fg-batt-capacity-mah = <2810>;
+        qcom,fg-cc-soc-coeff = <0x81D5>;
+        qcom,fg-cutoff-voltage-mv = <3400>;
+        qcom,fg-iterm-ma = <100>;
+        qcom,fg-ibatt-standby-ma = <200>;
+        qcom,fg-cc-to-cv-mv = <4397>;
+        qcom,thermistor-c1-coeff = <0x86C2>;
+        qcom,fg-auto-recharge-soc = <97>;
+
+        qcom,otp-hard-jeita-config;
+        qcom,otp-hot-bat-decidegc = <500>;
+        qcom,otp-cold-bat-decidegc = <(-50)>;
+
+        qcom,soft-jeita-config;
+        qcom,warm-bat-decidegc = <450>;
+        qcom,cool-bat-decidegc = <100>;
+        qcom,soft-jeita-comp-voltage-mv = <4000>;
+        qcom,soft-jeita-comp-current-ma = <600>;
+
+        qcom,shdn-after-pwroff;
+        qcom,fg-reset-at-pon;
+        qcom,fg-reset-threshold-mv = <200>;
+
+        usb_otg_vbus: usb-otg-vbus {
+          regulator-max-microamp = <1500000>;
+        };
+      };
+    };
-- 
2.31.1

