From: Jan-Michael Brummer <jan.brummer@tabos.org>
To: sre@kernel.org
Cc: andersson@kernel.org, neil.armstrong@linaro.org,
linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Jan-Michael Brummer <jan.brummer@tabos.org>
Subject: [PATCH 1/2] power: supply: qcom_battmgr: fix CHARGE_FULL* on SM8350-class firmware
Date: Sat, 29 Aug 2026 07:45:45 +0200 [thread overview]
Message-ID: <20260829054546.86210-2-jan.brummer@tabos.org> (raw)
In-Reply-To: <20260829054546.86210-1-jan.brummer@tabos.org>
battmgr->unit is only ever assigned in the BATTMGR_BAT_INFO handler of
the SC8280XP callback. The SM8350-class firmware does not implement that
request - every property is fetched individually via
BATTMGR_BAT_PROPERTY_GET - so unit keeps its zero-initialised value,
QCOM_BATTMGR_UNIT_mWh.
POWER_SUPPLY_PROP_CHARGE_FULL and POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN
are guarded by 'if (unit != QCOM_BATTMGR_UNIT_mAh) return -ENODATA;',
hence both properties always fail on these platforms, even though the
values are requested from the firmware and stored in
info.last_full_capacity and info.design_capacity on every access:
$ cat /sys/class/power_supply/qcom-battmgr-bat/charge_full
cat: read error: No data available
Without a full charge value userspace cannot derive an absolute energy
level, so UPower reports a zero energy level and never computes a
time-to-empty/time-to-full estimate:
energy: 0 Wh
energy-full: 0 Wh
energy-rate: 12.4713 W
percentage: 59%
The firmware of this class reports charge domain values, so set the unit
statically when registering the SM8350/SM8550 power supplies. With this
patch the properties read back consistently on a Fairphone 5:
charge_full 4116000
charge_full_design 4260000
capacity 85
Fixes: 29e8142b5623 ("power: supply: Introduce Qualcomm PMIC GLINK power supply")
Signed-off-by: Jan-Michael Brummer <jan.brummer@tabos.org>
---
drivers/power/supply/qcom_battmgr.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 490137a..98a70e1 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -1690,6 +1690,14 @@ static int qcom_battmgr_probe(struct auxiliary_device *adev,
return dev_err_probe(dev, PTR_ERR(battmgr->wls_psy),
"failed to register wireless charing power supply\n");
} else {
+ /*
+ * The SM8350-class firmware has no BATTMGR_BAT_INFO request, so
+ * @unit is never populated from the firmware. It reports charge
+ * domain values, so set it statically here - otherwise the
+ * CHARGE_* properties are rejected with -ENODATA.
+ */
+ battmgr->unit = QCOM_BATTMGR_UNIT_mAh;
+
if (battmgr->variant == QCOM_BATTMGR_SM8550)
psy_desc = &sm8550_bat_psy_desc;
else
next prev parent reply other threads:[~2026-08-29 5:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 5:45 [PATCH 0/2] power: supply: qcom_battmgr: report charge levels " Jan-Michael Brummer
2026-08-29 5:45 ` Jan-Michael Brummer [this message]
2026-08-29 5:45 ` [PATCH 2/2] power: supply: qcom_battmgr: expose CHARGE_NOW " Jan-Michael Brummer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260829054546.86210-2-jan.brummer@tabos.org \
--to=jan.brummer@tabos.org \
--cc=andersson@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®