power: supply: core: Add state_of_health power supply property
authorFenglin Wu <fenglin.wu@oss.qualcomm.com>
Wed, 17 Sep 2025 10:15:15 +0000 (18:15 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 17 Sep 2025 23:01:03 +0000 (01:01 +0200)
Add state_of_health power supply property to represent battery
health percentage.

Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Documentation/ABI/testing/sysfs-class-power
drivers/power/supply/power_supply_sysfs.c
include/linux/power_supply.h

index e6cce42..4b21d5d 100644 (file)
@@ -569,6 +569,27 @@ Description:
 
                Valid values: Represented in microohms
 
+What:          /sys/class/power_supply/<supply_name>/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**
 
 What:          /sys/class/power_supply/<supply_name>/input_current_limit
index 8ba08d4..198405f 100644 (file)
@@ -224,6 +224,7 @@ static struct power_supply_attr power_supply_attrs[] __ro_after_init = {
        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),
index f38da7c..360ffdf 100644 (file)
@@ -177,6 +177,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,