mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
power: supply: qcom_battmgr: Add state_of_health property
Add state_of_health property to read battery health percentage from battery management firmware. Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
committed by
Sebastian Reichel
parent
45e57e6a21
commit
b8e5030e09
@@ -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_INTERNAL_RESISTANCE] = BATT_RESISTANCE,
|
||||
[POWER_SUPPLY_PROP_STATE_OF_HEALTH] = BATT_SOH,
|
||||
[POWER_SUPPLY_PROP_POWER_NOW] = BATT_POWER_NOW,
|
||||
};
|
||||
|
||||
@@ -590,6 +592,9 @@ static int qcom_battmgr_bat_get_property(struct power_supply *psy,
|
||||
case POWER_SUPPLY_PROP_INTERNAL_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;
|
||||
@@ -675,6 +680,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_INTERNAL_RESISTANCE,
|
||||
POWER_SUPPLY_PROP_STATE_OF_HEALTH,
|
||||
POWER_SUPPLY_PROP_POWER_NOW,
|
||||
};
|
||||
|
||||
@@ -1167,6 +1173,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;
|
||||
|
||||
Reference in New Issue
Block a user