[PATCH RFC 1/8] dt-bindings: power: supply: Add schema for Qualcomm pmi8998 fuel gauge

David Heidelberg via B4 Relay posted 8 patches 1 week ago
[PATCH RFC 1/8] dt-bindings: power: supply: Add schema for Qualcomm pmi8998 fuel gauge
Posted by David Heidelberg via B4 Relay 1 week ago
From: Yassine Oudjana <y.oudjana@protonmail.com>

Add a device-tree schema for Qualcomm PMIC 8998 fuel gauge.

Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org>
Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
---
 .../bindings/power/supply/qcom,pmi8998-fg.yaml     | 77 ++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-fg.yaml b/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-fg.yaml
new file mode 100644
index 0000000000000..9acc1a7f04cda
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-fg.yaml
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only or BSD-3-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/qcom,pmi8998-fg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm PMI8998 PMIC Fuel Gauge
+
+maintainers:
+  - Casey Connolly <casey@connolly.tech>
+  - Joel Selvaraj <foss@joelselvaraj.com>
+  - Yassine Oudjana <y.oudjana@protonmail.com>
+
+allOf:
+  - $ref: /schemas/power/supply/power-supply.yaml#
+
+properties:
+  compatible:
+    const: qcom,pmi8998-fg
+
+  reg:
+    maxItems: 1
+
+  monitored-battery:
+    description: |
+       phandle of battery characteristics node.
+       The fuel gauge uses the following battery properties:
+       - charge-full-design-microamp-hours
+       - voltage-min-design-microvolt
+       - voltage-max-design-microvolt
+       See Documentation/devicetree/bindings/power/supply/battery.yaml
+
+  interrupts:
+    items:
+      - description: State of charge change interrupt
+
+  interrupt-names:
+    items:
+      - const: soc-delta
+
+  power-supplies: true
+
+required:
+  - compatible
+  - reg
+  - monitored-battery
+  - interrupts
+  - interrupt-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    battery: battery {
+      compatible = "simple-battery";
+
+      charge-full-design-microamp-hours = <4070000>;
+      voltage-min-design-microvolt = <3400000>;
+      voltage-max-design-microvolt = <4400000>;
+    };
+
+    pmic {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      fuel-gauge@4000 {
+        compatible = "qcom,pmi8998-fg";
+        reg = <0x4000>;
+
+        interrupts = <0x2 0x40 0x4 IRQ_TYPE_EDGE_RISING>;
+        interrupt-names = "soc-delta";
+
+        monitored-battery = <&battery>;
+      };
+    };

-- 
2.51.0


Re: [PATCH RFC 1/8] dt-bindings: power: supply: Add schema for Qualcomm pmi8998 fuel gauge
Posted by Konrad Dybcio 4 days, 13 hours ago
On 11/24/25 10:53 PM, David Heidelberg via B4 Relay wrote:
> From: Yassine Oudjana <y.oudjana@protonmail.com>
> 
> Add a device-tree schema for Qualcomm PMIC 8998 fuel gauge.
> 
> Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org>
> Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
> ---

[...]

> +    pmic {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      fuel-gauge@4000 {
> +        compatible = "qcom,pmi8998-fg";
> +        reg = <0x4000>;
> +
> +        interrupts = <0x2 0x40 0x4 IRQ_TYPE_EDGE_RISING>;
> +        interrupt-names = "soc-delta";

A (much much older but still) similar in functionality, the PM8916
BMS block has 6 interrupts.

pmi8998.dtsi on msm-4.4 defines a total of 16 under the fg-gen3
megadevice. I would assume that at least a majority of them are useful
and/or required for full functionality.

There's 8 under 'fg-batt-soc', 5 under 'fg-batt-info' and 3 under
'fg-memif'

The main node also consumes an IIO channel provided by the RRADC

I'm not asking you to implement all the feature delta in v2, but I
will ask you to assess what the dt-bindings for a complete solution
would look like and to fill in all the resources that will be necessary
down the line, to the best of your knowledge, so that you won't have
to wrestle with bindings updates with every new feature addition

Konrad