2023-11-20 14:04:52

by Nikita Travkin

[permalink] [raw]
Subject: [PATCH v4 0/3] pm8916: Add BMS and charger

This series enables VM-BMS and LBC blocks in the pm8916 pmic.

The VM-BMS is a simple voltage monitoring block that allows the software
to estimate the battery capacity left.

The LBC is a linear battery charger for lipo batteries.

Add both devices to the pmic dtsi and enable them for Longcheer L8150
which makes use of them.

Signed-off-by: Nikita Travkin <[email protected]>
---
Changes in v4:
- Un-drop 1/3 (dt-bindings) as it was un-applied.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Drop 1/3 (dt-bindings) as it was applied.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- No changes - resend with minor commit message edits.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Nikita Travkin (3):
dt-bindings: mfd: qcom,spmi-pmic: Add pm8916 vm-bms and lbc
arm64: dts: qcom: pm8916: Add BMS and charger
arm64: dts: qcom: msm8916-longcheer-l8150: Add battery and charger

.../devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 6 +++
.../boot/dts/qcom/msm8916-longcheer-l8150.dts | 43 ++++++++++++++++---
arch/arm64/boot/dts/qcom/pm8916.dtsi | 48 ++++++++++++++++++++++
3 files changed, 91 insertions(+), 6 deletions(-)
---
base-commit: 5a82d69d48c82e89aef44483d2a129f869f3506a
change-id: 20230916-pm8916-dtsi-bms-lbc-2fb1b99d1eb2

Best regards,
--
Nikita Travkin <[email protected]>


2023-11-20 14:05:10

by Nikita Travkin

[permalink] [raw]
Subject: [PATCH v4 3/3] arm64: dts: qcom: msm8916-longcheer-l8150: Add battery and charger

Longcheer L8150 doesn't have any dedicated fuel-gauge or charger,
instead making use of the pmic hardware blocks for those purposes.

Add pm8916 bms and charger, as well as the battery cell description
that those blocks rely on.

Reviewed-by: Konrad Dybcio <[email protected]>
Signed-off-by: Nikita Travkin <[email protected]>
---
.../boot/dts/qcom/msm8916-longcheer-l8150.dts | 43 +++++++++++++++++++---
1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts b/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts
index 37fa55166918..8e4c77003109 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts
@@ -49,6 +49,25 @@ mpss_mem: mpss@8e800000 {
};
};

+ battery: battery {
+ compatible = "simple-battery";
+ voltage-min-design-microvolt = <3400000>;
+ voltage-max-design-microvolt = <4350000>;
+ energy-full-design-microwatt-hours = <9500000>;
+ charge-full-design-microamp-hours = <2500000>;
+
+ ocv-capacity-celsius = <25>;
+ ocv-capacity-table-0 = <4330000 100>, <4265000 95>,
+ <4208000 90>, <4153000 85>, <4100000 80>, <4049000 75>,
+ <4001000 70>, <3962000 65>, <3919000 60>, <3872000 55>,
+ <3839000 50>, <3817000 45>, <3798000 40>, <3783000 35>,
+ <3767000 30>, <3747000 25>, <3729000 20>, <3709000 16>,
+ <3688000 13>, <3681000 11>, <3680000 10>, <3679000 9>,
+ <3677000 8>, <3674000 7>, <3666000 6>, <3641000 5>,
+ <3597000 4>, <3537000 3>, <3457000 2>, <3336000 1>,
+ <3000000 0>;
+ };
+
gpio-keys {
compatible = "gpio-keys";

@@ -236,6 +255,22 @@ &blsp_uart2 {
status = "okay";
};

+&pm8916_bms {
+ status = "okay";
+
+ monitored-battery = <&battery>;
+ power-supplies = <&pm8916_charger>;
+};
+
+&pm8916_charger {
+ status = "okay";
+
+ monitored-battery = <&battery>;
+
+ qcom,fast-charge-safe-current = <900000>;
+ qcom,fast-charge-safe-voltage = <4300000>;
+};
+
&pm8916_codec {
qcom,micbias-lvl = <2800>;
qcom,mbhc-vthreshold-low = <75 150 237 450 500>;
@@ -255,10 +290,6 @@ pm8916_l17: l17 {
};
};

-&pm8916_usbin {
- status = "okay";
-};
-
&pm8916_vib {
status = "okay";
};
@@ -282,11 +313,11 @@ &sound {
&usb {
status = "okay";
dr_mode = "peripheral";
- extcon = <&pm8916_usbin>;
+ extcon = <&pm8916_charger>;
};

&usb_hs_phy {
- extcon = <&pm8916_usbin>;
+ extcon = <&pm8916_charger>;
};

&venus {

--
2.41.0

2023-11-20 14:05:20

by Nikita Travkin

[permalink] [raw]
Subject: [PATCH v4 2/3] arm64: dts: qcom: pm8916: Add BMS and charger

pm8916 contains some hardware blocks for battery powered devices:

- VM-BMS: Battery voltage monitoring block.
- LBC: Linear battery charger.

Add them to the pmic dtsi so the devices that make use of those blocks
can enable them.

Signed-off-by: Nikita Travkin <[email protected]>
---
arch/arm64/boot/dts/qcom/pm8916.dtsi | 48 ++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi
index f4de86787743..4b2e8fb47d2d 100644
--- a/arch/arm64/boot/dts/qcom/pm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8916.dtsi
@@ -41,6 +41,35 @@ watchdog {
};
};

+ pm8916_charger: charger@1000 {
+ compatible = "qcom,pm8916-lbc";
+ reg = <0x1000>, <0x1200>, <0x1300>, <0x1600>;
+ reg-names = "chgr", "bat_if", "usb", "misc";
+
+ interrupts = <0x0 0x10 0 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x10 5 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x10 6 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x10 7 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x12 0 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x12 1 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x13 0 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x13 1 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x13 2 IRQ_TYPE_EDGE_BOTH>,
+ <0x0 0x13 4 IRQ_TYPE_EDGE_BOTH>;
+ interrupt-names = "vbat_det",
+ "fast_chg",
+ "chg_fail",
+ "chg_done",
+ "bat_pres",
+ "temp_ok",
+ "coarse_det",
+ "usb_vbus",
+ "chg_gone",
+ "overtemp";
+
+ status = "disabled";
+ };
+
pm8916_usbin: usb-detect@1300 {
compatible = "qcom,pm8941-misc";
reg = <0x1300>;
@@ -91,6 +120,25 @@ channel@f {
};
};

+ pm8916_bms: battery@4000 {
+ compatible = "qcom,pm8916-bms-vm";
+ reg = <0x4000>;
+ interrupts = <0x0 0x40 0 IRQ_TYPE_EDGE_RISING>,
+ <0x0 0x40 1 IRQ_TYPE_EDGE_RISING>,
+ <0x0 0x40 2 IRQ_TYPE_EDGE_RISING>,
+ <0x0 0x40 3 IRQ_TYPE_EDGE_RISING>,
+ <0x0 0x40 4 IRQ_TYPE_EDGE_RISING>,
+ <0x0 0x40 5 IRQ_TYPE_EDGE_RISING>;
+ interrupt-names = "cv_leave",
+ "cv_enter",
+ "ocv_good",
+ "ocv_thr",
+ "fifo",
+ "state_chg";
+
+ status = "disabled";
+ };
+
rtc@6000 {
compatible = "qcom,pm8941-rtc";
reg = <0x6000>, <0x6100>;

--
2.41.0

2023-11-20 14:06:31

by Nikita Travkin

[permalink] [raw]
Subject: [PATCH v4 1/3] dt-bindings: mfd: qcom,spmi-pmic: Add pm8916 vm-bms and lbc

PM8916 (and probably some other similar pmics) have hardware blocks for
battery monitoring and charging. Add patterns for respecive nodes so the
devicetree for those blocks can be validated properly.

Signed-off-by: Nikita Travkin <[email protected]>
---
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml b/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml
index 9fa568603930..49103e07032a 100644
--- a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml
+++ b/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml
@@ -134,9 +134,15 @@ patternProperties:
type: object
$ref: /schemas/sound/qcom,pm8916-wcd-analog-codec.yaml#

+ "^battery@[0-9a-f]+$":
+ type: object
+ oneOf:
+ - $ref: /schemas/power/supply/qcom,pm8916-bms-vm.yaml#
+
"^charger@[0-9a-f]+$":
type: object
oneOf:
+ - $ref: /schemas/power/supply/qcom,pm8916-lbc.yaml#
- $ref: /schemas/power/supply/qcom,pm8941-charger.yaml#
- $ref: /schemas/power/supply/qcom,pm8941-coincell.yaml#
- $ref: /schemas/power/supply/qcom,pmi8998-charger.yaml#

--
2.41.0

2023-11-21 07:58:58

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] dt-bindings: mfd: qcom,spmi-pmic: Add pm8916 vm-bms and lbc

On 20/11/2023 15:03, Nikita Travkin wrote:
> PM8916 (and probably some other similar pmics) have hardware blocks for
> battery monitoring and charging. Add patterns for respecive nodes so the
> devicetree for those blocks can be validated properly.
>
> Signed-off-by: Nikita Travkin <[email protected]>
> ---
> Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 6 ++++++
> 1 file changed, 6 insertions(+)

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

Best regards,
Krzysztof

2023-11-22 19:31:38

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] arm64: dts: qcom: pm8916: Add BMS and charger



On 11/20/23 15:03, Nikita Travkin wrote:
> pm8916 contains some hardware blocks for battery powered devices:
>
> - VM-BMS: Battery voltage monitoring block.
> - LBC: Linear battery charger.
>
> Add them to the pmic dtsi so the devices that make use of those blocks
> can enable them.
>
> Signed-off-by: Nikita Travkin <[email protected]>
> ---
Acked-by: Konrad Dybcio <[email protected]>

Konrad

2023-11-23 17:19:06

by Lee Jones

[permalink] [raw]
Subject: Re: (subset) [PATCH v4 1/3] dt-bindings: mfd: qcom,spmi-pmic: Add pm8916 vm-bms and lbc

On Mon, 20 Nov 2023 19:03:03 +0500, Nikita Travkin wrote:
> PM8916 (and probably some other similar pmics) have hardware blocks for
> battery monitoring and charging. Add patterns for respecive nodes so the
> devicetree for those blocks can be validated properly.
>
>

Applied, thanks!

[1/3] dt-bindings: mfd: qcom,spmi-pmic: Add pm8916 vm-bms and lbc
commit: 95f44ef666a6504a7c75def89fffacb0ae4bf52c

--
Lee Jones [李琼斯]

2023-12-08 02:49:53

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] arm64: dts: qcom: pm8916: Add BMS and charger

On Mon, Nov 20, 2023 at 07:03:04PM +0500, Nikita Travkin wrote:
> diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi
[..]
>
> + pm8916_bms: battery@4000 {

"battery" is not a valid child of the pmic according to
mfd/qcom,spmi-pmic.yaml, so please update the binding to remove the
warnings that this introduces.

Thanks,
Bjorn

2023-12-08 02:55:23

by Bjorn Andersson

[permalink] [raw]
Subject: Re: (subset) [PATCH v4 0/3] pm8916: Add BMS and charger


On Mon, 20 Nov 2023 19:03:02 +0500, Nikita Travkin wrote:
> This series enables VM-BMS and LBC blocks in the pm8916 pmic.
>
> The VM-BMS is a simple voltage monitoring block that allows the software
> to estimate the battery capacity left.
>
> The LBC is a linear battery charger for lipo batteries.
>
> [...]

Applied, thanks!

[2/3] arm64: dts: qcom: pm8916: Add BMS and charger
commit: 26b87a3dc3337315c9834aa94e01da7030ec2e6c
[3/3] arm64: dts: qcom: msm8916-longcheer-l8150: Add battery and charger
commit: 12fbe58560d6f974339cc30e44c0c5452db331da

Best regards,
--
Bjorn Andersson <[email protected]>

2023-12-08 09:19:29

by Nikita Travkin

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] arm64: dts: qcom: pm8916: Add BMS and charger

Bjorn Andersson писал(а) 08.12.2023 07:48:
> On Mon, Nov 20, 2023 at 07:03:04PM +0500, Nikita Travkin wrote:
>> diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi
> [..]
>>
>> + pm8916_bms: battery@4000 {
>
> "battery" is not a valid child of the pmic according to
> mfd/qcom,spmi-pmic.yaml, so please update the binding to remove the
> warnings that this introduces.
>

This should be done in 1/3 which is already accepted to mfd,
so the warning should be gone when the stuff is pulled together.

Sorry for not making sure it's in earlier
Nikita

> Thanks,
> Bjorn

2023-12-09 02:57:33

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] arm64: dts: qcom: pm8916: Add BMS and charger

On Fri, Dec 08, 2023 at 02:19:11PM +0500, Nikita Travkin wrote:
> Bjorn Andersson писал(а) 08.12.2023 07:48:
> > On Mon, Nov 20, 2023 at 07:03:04PM +0500, Nikita Travkin wrote:
> >> diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi
> > [..]
> >>
> >> + pm8916_bms: battery@4000 {
> >
> > "battery" is not a valid child of the pmic according to
> > mfd/qcom,spmi-pmic.yaml, so please update the binding to remove the
> > warnings that this introduces.
> >
>
> This should be done in 1/3 which is already accepted to mfd,
> so the warning should be gone when the stuff is pulled together.
>

Very good. I just didn't spot that for some reason.

> Sorry for not making sure it's in earlier

No fault on your part, I should have spotted it. Sending binding updates
and DT updates in the same series is preferred way, and as I don't apply
the binding through my tree these warnings show up there.

Thank you,
Bjorn

> Nikita
>
> > Thanks,
> > Bjorn