From nobody Thu Oct 2 13:03:49 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73D0E285077; Wed, 17 Sep 2025 10:15:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758104130; cv=none; b=ehoW1m5tbyp155hrBOgI+D97R9MkA6G2LGKFnBXzqqBOJkbck3x71fRWPS9U4Ee0tlMlJ6zJpIJqTVqJouSLP6WqbiqPm1Kw1U5SVq35TFfIbHPc3ot2lDCg/fCAV6DErkcYyJ0LDOB8BMIpv0QGFZO6y+ZM0VcMWWgt+IELh2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758104130; c=relaxed/simple; bh=Ijlosk76aMbax/0EZX7A1tK9yGUnxGDpDioBTOSifik=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jE8tRe4Cgc2ztWv2/lpAs5YFS+5RC3Fgn8l+kLQl7oNvhWK9MmpoLkYyrj9m43C+5X+X3zHIzRJhfO681D1ltRjbzmQduYWML2jKtwLA3Tt6sUoUNcdROz1NfAM7dnjWryL/wWXVgXoPegtWlUIMuPcepQ34M8hAv9EjL5MYzCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kK7hQsT7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kK7hQsT7" Received: by smtp.kernel.org (Postfix) with ESMTPS id 315CEC4CEFD; Wed, 17 Sep 2025 10:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758104130; bh=Ijlosk76aMbax/0EZX7A1tK9yGUnxGDpDioBTOSifik=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=kK7hQsT758bceHoZEkCox1y8igfc68dCzsuCh64w5mC//8bv2B+a1V4T1CNwC7w1y XGa3olQqJwfbPelGUBA7OSIIYpnIqw0VS9DfFwi5yYknVJcqdSmj45H8FXtThNpOLK wMrhdH/guxRt0GtsznOqo/saES2q+TWjXf7X2Ur/M6ArsdyrQMneeZ4JTYQImRW8bK 2WEykU/B4S9b+YznPyWmdbWJE9igR4t0m0BgFXUJJSpsEN6M0+E5kZDNBMMl9rkY3T w/XBJjBmrHkY1vmK9O70JB6axiEkFrEmHAmPA7/vPFeIwqmXT+Zxt1Tg/eCNFxGAVX MdPOt8Ub/FQIA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CF4ACAC59F; Wed, 17 Sep 2025 10:15:30 +0000 (UTC) From: Fenglin Wu via B4 Relay Date: Wed, 17 Sep 2025 18:15:15 +0800 Subject: [PATCH v5 2/9] power: supply: core: Add state_of_health power supply property Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250917-qcom_battmgr_update-v5-2-270ade9ffe13@oss.qualcomm.com> References: <20250917-qcom_battmgr_update-v5-0-270ade9ffe13@oss.qualcomm.com> In-Reply-To: <20250917-qcom_battmgr_update-v5-0-270ade9ffe13@oss.qualcomm.com> To: Sebastian Reichel , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Greg Kroah-Hartman , Dmitry Baryshkov , Bryan O'Donoghue , Konrad Dybcio Cc: Subbaraman Narayanamurthy , David Collins , =?utf-8?q?Gy=C3=B6rgy_Kurucz?= , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@oss.qualcomm.com, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, Fenglin Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758104128; l=3021; i=fenglin.wu@oss.qualcomm.com; s=20240327; h=from:subject:message-id; bh=X9IUekcuEDwrQoqMr14tBuaW1CVOe9cZSoRRoug9QqU=; b=Akh6bpMVbnZx/CKFVHWtmhT7lnXnEtn9x+I8Wqb4ZILtv6+40r5RLgfhCpVuMb/22B827MkSW kaE6l2AITO6BwB3GAVou9vciqIXt+nOPFb5nE2E47PyIOgkfPuCjC5y X-Developer-Key: i=fenglin.wu@oss.qualcomm.com; a=ed25519; pk=BF8SA4IVDk8/EBCwlBehKtn2hp6kipuuAuDAHh9s+K4= X-Endpoint-Received: by B4 Relay for fenglin.wu@oss.qualcomm.com/20240327 with auth_id=406 X-Original-From: Fenglin Wu Reply-To: fenglin.wu@oss.qualcomm.com From: Fenglin Wu Add state_of_health power supply property to represent battery health percentage. Signed-off-by: Fenglin Wu --- Documentation/ABI/testing/sysfs-class-power | 21 +++++++++++++++++++++ drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 1 + 3 files changed, 23 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/AB= I/testing/sysfs-class-power index cea1a38f5a8fb754d4e6323967ef6cf2e20a68ce..d9e1ad7646f14892bb7ed55ac72= d0de7569f104e 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -568,6 +568,27 @@ Description: =20 Valid values: Represented in microohms =20 +What: /sys/class/power_supply//state_of_health +Date: August 2025 +Contact: linux-arm-msm@vger.kernel.org +Description: + The state_of_health parameter quantifies the overall condition + of a battery as a percentage, reflecting its ability to deliver + rated performance relative to its original specifications. It is + dynamically computed using a combination of learned capacity + and impedance-based degradation indicators, both of which evolve + over the battery's lifecycle. + Note that the exact algorithms are kept secret by most battery + vendors and the value from different battery vendors cannot be + compared with each other as there is no vendor-agnostic definition + of "performance". Also this usually cannot be used for any + calculations (i.e. this is not the factor between charge_full and + charge_full_design). + + Access: Read + + Valid values: 0 - 100 (percent) + **USB Properties** =20 What: /sys/class/power_supply//input_current_limit diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supp= ly/power_supply_sysfs.c index cfa8f90a88ebc8fc1c7447198f138e5d2e699e5a..d96a8578308e3af60cc1a352845= 662aa922c29b3 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -221,6 +221,7 @@ static struct power_supply_attr power_supply_attrs[] __= ro_after_init =3D { POWER_SUPPLY_ATTR(MANUFACTURE_MONTH), POWER_SUPPLY_ATTR(MANUFACTURE_DAY), POWER_SUPPLY_ATTR(INTERNAL_RESISTANCE), + POWER_SUPPLY_ATTR(STATE_OF_HEALTH), /* Properties of type `const char *' */ POWER_SUPPLY_ATTR(MODEL_NAME), POWER_SUPPLY_ATTR(MANUFACTURER), diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 8bc3b7a67eb5693a16db9b7d123e7881711c6bf4..ccb43fe44381965069dc3bd9505= d45050b9b1bd8 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -175,6 +175,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_MANUFACTURE_MONTH, POWER_SUPPLY_PROP_MANUFACTURE_DAY, POWER_SUPPLY_PROP_INTERNAL_RESISTANCE, + POWER_SUPPLY_PROP_STATE_OF_HEALTH, /* Properties of type `const char *' */ POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, --=20 2.34.1