Linux Power Management development
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Jan-Michael Brummer <jan.brummer@tabos.org>, 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
Subject: Re: [PATCH 2/2] power: supply: qcom_battmgr: expose CHARGE_NOW on SM8350-class firmware
Date: Wed, 2 Sep 2026 17:02:10 +0200	[thread overview]
Message-ID: <a2f3de2b-90f6-427d-9994-a8b1ec8cbed6@oss.qualcomm.com> (raw)
In-Reply-To: <20260829054546.86210-3-jan.brummer@tabos.org>

On 8/29/26 7:45 AM, Jan-Michael Brummer wrote:
> The SM8350-class firmware does not implement a dedicated 'charge now'
> property. It does however report BATT_CHG_COUNTER, and on this class of
> firmware that value is the remaining charge in uAh rather than a
> monotonic counter. Measured on a Fairphone 5 with charge_full at
> 4116000 uAh:
> 
>   BATT_CHG_COUNTER   reported capacity   counter / charge_full
>   2434614            59%                 59.1%
>   3525354            85%                 85.6%
> 
> Map POWER_SUPPLY_PROP_CHARGE_NOW onto the same firmware property and
> store the value in status.capacity, which the CHARGE_NOW/ENERGY_NOW case
> of qcom_battmgr_bat_get_property() already reads.
> 
> Together with the preceding patch this gives userspace both the full
> charge and the current charge. UPower now derives an energy level and
> runtime estimates in both directions:
> 
>     state:               discharging      state:               charging
>     energy:              14.4347 Wh       energy:              15.6003 Wh
>     energy-full:         16.8807 Wh       energy-full:         18.1505 Wh
>     energy-rate:         3.39313 W        energy-rate:         7.3492 W
>     time to empty:       4.3 hours        time to full:        20.8 minutes
> 
> Signed-off-by: Jan-Michael Brummer <jan.brummer@tabos.org>
> ---

Ok this makes more sense now. We should still gate the other property though.

[...]

> @@ -1442,7 +1445,10 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
>  			battmgr->info.technology = le32_to_cpu(resp->intval.value);
>  			break;
>  		case BATT_CHG_COUNTER:
> -			battmgr->info.charge_count = le32_to_cpu(resp->intval.value);
> +			val = le32_to_cpu(resp->intval.value);
> +			battmgr->info.charge_count = val;
> +			/* the firmware reports the remaining charge here */
> +			battmgr->status.capacity = val;

Let me try and find whether we can rely on this - on newer targets
many properties are more or less just front-ends for vendor
plumbing (because there's a ton of different chargers etc.)

Konrad

  reply	other threads:[~2026-09-02 15:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29  5:45 [PATCH 0/2] power: supply: qcom_battmgr: report charge levels on SM8350-class firmware Jan-Michael Brummer
2026-08-29  5:45 ` [PATCH 1/2] power: supply: qcom_battmgr: fix CHARGE_FULL* " Jan-Michael Brummer
2026-09-02 14:35   ` Konrad Dybcio
2026-08-29  5:45 ` [PATCH 2/2] power: supply: qcom_battmgr: expose CHARGE_NOW " Jan-Michael Brummer
2026-09-02 15:02   ` Konrad Dybcio [this message]
2026-09-02 16:21     ` Konrad Dybcio

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=a2f3de2b-90f6-427d-9994-a8b1ec8cbed6@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=jan.brummer@tabos.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