From: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
Add power supply property to get battery internal resistance from
the battery management firmware.
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on Thinkpad T14S OLED
Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
---
drivers/power/supply/qcom_battmgr.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index fe27676fbc7cd12292caa6fb3b5b46a18c426e6d..55477ae92fd56ede465b32d6f7ed9da78ebd869c 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2022, Linaro Ltd
+ * Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/auxiliary_bus.h>
#include <linux/module.h>
@@ -254,6 +255,7 @@ struct qcom_battmgr_status {
unsigned int voltage_now;
unsigned int voltage_ocv;
unsigned int temperature;
+ unsigned int resistance;
unsigned int discharge_time;
unsigned int charge_time;
@@ -418,6 +420,7 @@ static const u8 sm8350_bat_prop_map[] = {
[POWER_SUPPLY_PROP_MODEL_NAME] = BATT_MODEL_NAME,
[POWER_SUPPLY_PROP_TIME_TO_FULL_AVG] = BATT_TTF_AVG,
[POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG] = BATT_TTE_AVG,
+ [POWER_SUPPLY_PROP_INTERNAL_RESISTANCE] = BATT_RESISTANCE,
[POWER_SUPPLY_PROP_POWER_NOW] = BATT_POWER_NOW,
};
@@ -582,6 +585,9 @@ static int qcom_battmgr_bat_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_TEMP:
val->intval = battmgr->status.temperature;
break;
+ case POWER_SUPPLY_PROP_INTERNAL_RESISTANCE:
+ val->intval = battmgr->status.resistance;
+ break;
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
val->intval = battmgr->status.discharge_time;
break;
@@ -665,6 +671,7 @@ static const enum power_supply_property sm8350_bat_props[] = {
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
+ POWER_SUPPLY_PROP_INTERNAL_RESISTANCE,
POWER_SUPPLY_PROP_POWER_NOW,
};
@@ -1174,6 +1181,9 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
case BATT_TTE_AVG:
battmgr->status.discharge_time = le32_to_cpu(resp->intval.value);
break;
+ case BATT_RESISTANCE:
+ battmgr->status.resistance = le32_to_cpu(resp->intval.value);
+ break;
case BATT_POWER_NOW:
battmgr->status.power_now = le32_to_cpu(resp->intval.value);
break;
--
2.34.1
On Mon, Sep 15, 2025 at 04:49:55PM +0800, Fenglin Wu via B4 Relay wrote: > From: Fenglin Wu <fenglin.wu@oss.qualcomm.com> > > Add power supply property to get battery internal resistance from > the battery management firmware. > > Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on Thinkpad T14S OLED T14S is X1E80100, which uses SC8280XP-specific sets of properties. This patch changes only SM8350-related data. How was it tested? > Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com> > --- > drivers/power/supply/qcom_battmgr.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c > index fe27676fbc7cd12292caa6fb3b5b46a18c426e6d..55477ae92fd56ede465b32d6f7ed9da78ebd869c 100644 > --- a/drivers/power/supply/qcom_battmgr.c > +++ b/drivers/power/supply/qcom_battmgr.c > @@ -2,6 +2,7 @@ > /* > * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. > * Copyright (c) 2022, Linaro Ltd > + * Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. Please follow marketing guidelines here. > */ > #include <linux/auxiliary_bus.h> > #include <linux/module.h> > @@ -254,6 +255,7 @@ struct qcom_battmgr_status { > unsigned int voltage_now; > unsigned int voltage_ocv; > unsigned int temperature; > + unsigned int resistance; > > unsigned int discharge_time; > unsigned int charge_time; > @@ -418,6 +420,7 @@ static const u8 sm8350_bat_prop_map[] = { > [POWER_SUPPLY_PROP_MODEL_NAME] = BATT_MODEL_NAME, > [POWER_SUPPLY_PROP_TIME_TO_FULL_AVG] = BATT_TTF_AVG, > [POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG] = BATT_TTE_AVG, > + [POWER_SUPPLY_PROP_INTERNAL_RESISTANCE] = BATT_RESISTANCE, > [POWER_SUPPLY_PROP_POWER_NOW] = BATT_POWER_NOW, > }; > > @@ -582,6 +585,9 @@ static int qcom_battmgr_bat_get_property(struct power_supply *psy, > case POWER_SUPPLY_PROP_TEMP: > val->intval = battmgr->status.temperature; > break; > + case POWER_SUPPLY_PROP_INTERNAL_RESISTANCE: > + val->intval = battmgr->status.resistance; > + break; > case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG: > val->intval = battmgr->status.discharge_time; > break; > @@ -665,6 +671,7 @@ static const enum power_supply_property sm8350_bat_props[] = { > POWER_SUPPLY_PROP_MODEL_NAME, > POWER_SUPPLY_PROP_TIME_TO_FULL_AVG, > POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, > + POWER_SUPPLY_PROP_INTERNAL_RESISTANCE, > POWER_SUPPLY_PROP_POWER_NOW, > }; > > @@ -1174,6 +1181,9 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr, > case BATT_TTE_AVG: > battmgr->status.discharge_time = le32_to_cpu(resp->intval.value); > break; > + case BATT_RESISTANCE: > + battmgr->status.resistance = le32_to_cpu(resp->intval.value); > + break; > case BATT_POWER_NOW: > battmgr->status.power_now = le32_to_cpu(resp->intval.value); > break; > > -- > 2.34.1 > > -- With best wishes Dmitry
On 9/15/2025 6:18 PM, Dmitry Baryshkov wrote: > On Mon, Sep 15, 2025 at 04:49:55PM +0800, Fenglin Wu via B4 Relay wrote: >> From: Fenglin Wu <fenglin.wu@oss.qualcomm.com> >> >> Add power supply property to get battery internal resistance from >> the battery management firmware. >> >> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on Thinkpad T14S OLED > T14S is X1E80100, which uses SC8280XP-specific sets of properties. This > patch changes only SM8350-related data. How was it tested? I assumed that Neil has picked the series of the changes and tested the charge control limit functionality on his T14S device. When I run "b4 trailers -u", the tag was added on all patches. I will remove the "Tested-by" trailer for the patches with functionality not applicable for X1E80100 platform.
On 9/16/25 4:31 AM, Fenglin Wu wrote: > > On 9/15/2025 6:18 PM, Dmitry Baryshkov wrote: >> On Mon, Sep 15, 2025 at 04:49:55PM +0800, Fenglin Wu via B4 Relay wrote: >>> From: Fenglin Wu <fenglin.wu@oss.qualcomm.com> >>> >>> Add power supply property to get battery internal resistance from >>> the battery management firmware. >>> >>> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on Thinkpad T14S OLED >> T14S is X1E80100, which uses SC8280XP-specific sets of properties. This >> patch changes only SM8350-related data. How was it tested? > > I assumed that Neil has picked the series of the changes and tested the charge control limit functionality on his T14S device. > > When I run "b4 trailers -u", the tag was added on all patches. I will remove the "Tested-by" trailer for the patches with functionality not applicable for X1E80100 platform. + Konstantin It's quite common to see someone leaving a T-b on the cover letter, trying to say "I gave this series a spin" and then seeing the tag appear on unrelated commits within the series (e.g. bindings or some cosmetic fixes". Maybe some sort of an interactive (opt-in is fine) dialog for "which patches to apply t-b/tags to" could be worth the effort? I was imagining two options: $ b4 trailers -u --lalala > Grabbing tags.. > Found: > [Patch 0/n] Very Nice Changeset > Tested-by: Foo Bar <foo@bar.com> > > Which patches do you want the Tested-by tags to apply to? [all]: 2-5 or: $ b4 trailers -u --lalala2 > Grabbing tagsd.. > Found: > [Patch 0/n] Very Nice Changeset > Apply to Patch 1 ("soc: qcom: Fix all bugs")? [Y/n/a] y > Apply to Patch 2 ("dt-bindings: foobarbaz")? [Y/n/a] n > Apply to Patch 3 ("clk: qcom: Fix ABCD")? [Y/n/a] a > Applying to Patch 4 ("clk: qcom: Fix DEFG") > . . . > Applying to Patch n ("clk: qcom: Fix XYZ") > Tags applied! As I'm writing this, I'm thinking option 2 offers much more fine-grained control, which is always nice to see.. Konrad
On Tue, Sep 16, 2025 at 09:59:04AM +0200, Konrad Dybcio wrote: > + Konstantin > > It's quite common to see someone leaving a T-b on the cover letter, > trying to say "I gave this series a spin" and then seeing the tag > appear on unrelated commits within the series (e.g. bindings or some > cosmetic fixes". Maybe some sort of an interactive (opt-in is fine) > dialog for "which patches to apply t-b/tags to" could be worth the > effort? The plan is to add interactive mode to a few commands, including to the trailers command. This will open an interface similar to interactive rebase, where you can mark trailers as accept, skip, or ignore. That should do what you're asking for, I believe. Best regards, -K
On 9/16/25 3:37 PM, Konstantin Ryabitsev wrote: > On Tue, Sep 16, 2025 at 09:59:04AM +0200, Konrad Dybcio wrote: >> + Konstantin >> >> It's quite common to see someone leaving a T-b on the cover letter, >> trying to say "I gave this series a spin" and then seeing the tag >> appear on unrelated commits within the series (e.g. bindings or some >> cosmetic fixes". Maybe some sort of an interactive (opt-in is fine) >> dialog for "which patches to apply t-b/tags to" could be worth the >> effort? > > The plan is to add interactive mode to a few commands, including to the > trailers command. This will open an interface similar to interactive rebase, > where you can mark trailers as accept, skip, or ignore. That should do what > you're asking for, I believe. That is amazing to hear, thank you Konrad
© 2016 - 2025 Red Hat, Inc.