mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fenglin Wu via B4 Relay <devnull+fenglin.wu.oss.qualcomm.com@kernel.org>
To: Sebastian Reichel <sre@kernel.org>,
	 Bjorn Andersson <andersson@kernel.org>
Cc: Subbaraman Narayanamurthy
	<subbaraman.narayanamurthy@oss.qualcomm.com>,
	 David Collins <david.collins@oss.qualcomm.com>,
	linux-pm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,  kernel@oss.qualcomm.com,
	Fenglin Wu <fenglin.wu@oss.qualcomm.com>
Subject: [PATCH 4/5] power: supply: qcom-battmgr: Add state_of_health power supply property
Date: Fri, 23 May 2025 09:39:21 +0800	[thread overview]
Message-ID: <20250523-qcom_battmgr_update-v1-4-2bb6d4e0a56e@oss.qualcomm.com> (raw)
In-Reply-To: <20250523-qcom_battmgr_update-v1-0-2bb6d4e0a56e@oss.qualcomm.com>

From: Fenglin Wu <fenglin.wu@oss.qualcomm.com>

Add state_of_health power supply property to read battery health
percentage from the battery management firmware.

Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
---
 drivers/power/supply/qcom_battmgr.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index bc521f60f67fa427cc03b51c44adaeb46ae746f5..d5d0200b92bdc3d9a22f44159ad45b152efe8be0 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -256,6 +256,7 @@ struct qcom_battmgr_status {
 	unsigned int voltage_ocv;
 	unsigned int temperature;
 	unsigned int resistance;
+	unsigned int soh_percent;
 
 	unsigned int discharge_time;
 	unsigned int charge_time;
@@ -421,6 +422,7 @@ static const u8 sm8350_bat_prop_map[] = {
 	[POWER_SUPPLY_PROP_TIME_TO_FULL_AVG] = BATT_TTF_AVG,
 	[POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG] = BATT_TTE_AVG,
 	[POWER_SUPPLY_PROP_RESISTANCE] = BATT_RESISTANCE,
+	[POWER_SUPPLY_PROP_STATE_OF_HEALTH] = BATT_SOH,
 	[POWER_SUPPLY_PROP_POWER_NOW] = BATT_POWER_NOW,
 };
 
@@ -588,6 +590,9 @@ static int qcom_battmgr_bat_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_RESISTANCE:
 		val->intval = battmgr->status.resistance;
 		break;
+	case POWER_SUPPLY_PROP_STATE_OF_HEALTH:
+		val->intval = battmgr->status.soh_percent;
+		break;
 	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
 		val->intval = battmgr->status.discharge_time;
 		break;
@@ -672,6 +677,7 @@ static const enum power_supply_property sm8350_bat_props[] = {
 	POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
 	POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
 	POWER_SUPPLY_PROP_RESISTANCE,
+	POWER_SUPPLY_PROP_STATE_OF_HEALTH,
 	POWER_SUPPLY_PROP_POWER_NOW,
 };
 
@@ -1141,6 +1147,9 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
 		case BATT_CAPACITY:
 			battmgr->status.percent = le32_to_cpu(resp->intval.value) / 100;
 			break;
+		case BATT_SOH:
+			battmgr->status.soh_percent = le32_to_cpu(resp->intval.value);
+			break;
 		case BATT_VOLT_OCV:
 			battmgr->status.voltage_ocv = le32_to_cpu(resp->intval.value);
 			break;

-- 
2.34.1



  parent reply	other threads:[~2025-05-23  1:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23  1:39 [PATCH 0/5] power: supply: Add several features support in qcom-battmgr driver Fenglin Wu via B4 Relay
2025-05-23  1:39 ` [PATCH 1/5] power: supply: core: add resistance power supply property Fenglin Wu via B4 Relay
2025-05-23  1:39 ` [PATCH 2/5] power: supply: core: Add state_of_health " Fenglin Wu via B4 Relay
2025-05-23  1:39 ` [PATCH 3/5] power: supply: qcom_battmgr: Add resistance " Fenglin Wu via B4 Relay
2025-05-23  1:39 ` Fenglin Wu via B4 Relay [this message]
2025-05-23  1:39 ` [PATCH 5/5] power: supply: qcom-battmgr: Add charge control support Fenglin Wu via B4 Relay
2025-05-23 21:29   ` György Kurucz
2025-05-26  6:19     ` Fenglin Wu
2025-05-26  8:27       ` neil.armstrong
2025-05-26  8:43         ` Fenglin Wu
2025-05-27 16:42       ` me
2025-05-29  7:14         ` Fenglin Wu

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=20250523-qcom_battmgr_update-v1-4-2bb6d4e0a56e@oss.qualcomm.com \
    --to=devnull+fenglin.wu.oss.qualcomm.com@kernel.org \
    --cc=andersson@kernel.org \
    --cc=david.collins@oss.qualcomm.com \
    --cc=fenglin.wu@oss.qualcomm.com \
    --cc=kernel@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=subbaraman.narayanamurthy@oss.qualcomm.com \
    /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®