2022-04-29 09:49:57

by Caleb Connolly

[permalink] [raw]
Subject: [PATCH v2 0/6] power: supply: introduce support for the Qualcomm smb2 charger

Add a driver for the Qualcomm PMI8998/PM660 Switch-Mode Battery Charger.
This is the second generation SMB charger, and replaces the previous
SMBB hardware found in older PMICs.

This driver provides basic support for initialising the hardware,
configuring the USB input current limit and reporting information about
the state of the charger. Features like type-c dual role support and OTG
switching will be added in future patches.

This patch series depends on my previous series adding support for
the Round Robin ADC which is used for reading the USB voltage and
current, it can be found here:
https://lore.kernel.org/linux-arm-msm/[email protected]/

Changes since v1:
* Rename the driver to pmi8998_charger
* Drop unnecessary (and very broken) mutex
* Rework the driver based on feedback to v1
* Fix some minor bugs and improve Automatic Input Current Limit support

---
Caleb Connolly (6):
power: supply: add Qualcomm PMI8998 SMB2 Charger driver
arm64: dts: qcom: pmi8998: add charger node
arm64: dts: sdm845-oneplus: enable pmi8998 charger
arm64: dts: qcom: sdm845-db845c: enable pmi8998 charger
arm64: dts: qcom: sdm845-xiaomi-beryllium enable pmi8998 charger
dt-bindings: power: supply: qcom,pmi8998-charger: add bindings for
smb2 driver

.../power/supply/qcom,pmi8998-charger.yaml | 82 ++
arch/arm64/boot/dts/qcom/pmi8998.dtsi | 17 +
arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 18 +
.../boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 +
.../dts/qcom/sdm845-oneplus-enchilada.dts | 4 +
.../boot/dts/qcom/sdm845-oneplus-fajita.dts | 4 +
.../boot/dts/qcom/sdm845-xiaomi-beryllium.dts | 13 +
drivers/power/supply/Kconfig | 9 +
drivers/power/supply/Makefile | 1 +
drivers/power/supply/qcom_pmi8998_charger.c | 1070 +++++++++++++++++
10 files changed, 1222 insertions(+)
create mode 100644 Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml
create mode 100644 drivers/power/supply/qcom_pmi8998_charger.c

--
2.36.0


2022-04-29 13:53:17

by Caleb Connolly

[permalink] [raw]
Subject: [PATCH v2 5/6] arm64: dts: qcom: sdm845-xiaomi-beryllium enable pmi8998 charger

Enable the smb2 charger driver and add a battery node to report the
battery stats correctly.

Signed-off-by: Caleb Connolly <[email protected]>
---
.../arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts b/arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts
index b3b6aa4e0fa3..1a5e127d7a43 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts
@@ -109,6 +109,14 @@ rmtfs_mem: memory@f6301000 {
};
};

+ battery: battery {
+ compatible = "simple-battery";
+
+ charge-full-design-microamp-hours = <4000000>;
+ voltage-min-design-microvolt = <3400000>;
+ voltage-max-design-microvolt = <4400000>;
+ };
+
vreg_s4a_1p8: vreg-s4a-1p8 {
compatible = "regulator-fixed";
regulator-name = "vreg_s4a_1p8";
@@ -302,6 +310,11 @@ vol_up_pin_a: vol-up-active {
};
};

+&pmi8998_charger {
+ status = "okay";
+ monitored-battery = <&battery>;
+};
+
&pm8998_pon {
resin {
compatible = "qcom,pm8941-resin";
--
2.36.0

2022-05-02 05:36:34

by Caleb Connolly

[permalink] [raw]
Subject: [PATCH v2 6/6] dt-bindings: power: supply: qcom,pmi8998-charger: add bindings for smb2 driver

Add devicetree bindings for the Qualcomm PMI8998/PM660 SMB2 charger
driver.

Signed-off-by: Caleb Connolly <[email protected]>
---
.../power/supply/qcom,pmi8998-charger.yaml | 82 +++++++++++++++++++
1 file changed, 82 insertions(+)
create mode 100644 Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml

diff --git a/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml b/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml
new file mode 100644
index 000000000000..277c47e048b6
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/qcom,pmi8998-charger.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm PMI8998/PM660 Switch-Mode Battery Charger "2"
+
+maintainers:
+ - Caleb Connolly <[email protected]>
+
+properties:
+ compatible:
+ enum:
+ - qcom,pmi8998-charger
+ - qcom,pm660-charger
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 4
+
+ interrupt-names:
+ items:
+ - const: usb-plugin
+ - const: bat-ov
+ - const: wdog-bark
+ - const: usbin-icl-change
+
+ io-channels:
+ items:
+ - description: USB in current in uA
+ - description: USB in voltage in uV
+
+ io-channel-names:
+ items:
+ - const: usbin_i
+ - const: usbin_v
+
+ monitored-battery:
+ description: phandle to the simple-battery node
+ $ref: /schemas/types.yaml#/definitions/phandle
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-names
+ - io-channels
+ - io-channel-names
+ - monitored-battery
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ pmic {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ #interrupt-cells = <4>;
+
+ charger@1000 {
+ compatible = "qcom,pmi8998-charger";
+ reg = <0x1000>;
+
+ interrupts = <0x2 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
+ <0x2 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
+ <0x2 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
+ <0x2 0x16 0x1 IRQ_TYPE_EDGE_RISING>;
+ interrupt-names = "usb-plugin", "bat-ov", "wdog-bark", "usbin-icl-change";
+
+ io-channels = <&pmi8998_rradc 3>,
+ <&pmi8998_rradc 4>;
+ io-channel-names = "usbin_i",
+ "usbin_v";
+
+ monitored-battery = <&battery>;
+ };
+ };
--
2.36.0

2022-05-03 00:25:39

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] dt-bindings: power: supply: qcom,pmi8998-charger: add bindings for smb2 driver

On 28/04/2022 12:42, Caleb Connolly wrote:
> Add devicetree bindings for the Qualcomm PMI8998/PM660 SMB2 charger
> driver.
>
> Signed-off-by: Caleb Connolly <[email protected]>

Reviewed-by: Krzysztof Kozlowski <[email protected]>


Best regards,
Krzysztof