power: supply: qcom_battmgr: Add resistance power supply property
Add power supply property to get battery internal resistance from the 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
cd93fbdce5
commit
45e57e6a21
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022, Linaro Ltd
|
||||
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
|
||||
*/
|
||||
#include <linux/auxiliary_bus.h>
|
||||
#include <linux/module.h>
|
||||
@@ -254,6 +255,7 @@ struct qcom_battmgr_status {
|
||||
unsigned int voltage_now;
|
||||
unsigned int voltage_ocv;
|
||||
unsigned int temperature;
|
||||
unsigned int resistance;
|
||||
|
||||
unsigned int discharge_time;
|
||||
unsigned int charge_time;
|
||||
@@ -418,6 +420,7 @@ static const u8 sm8350_bat_prop_map[] = {
|
||||
[POWER_SUPPLY_PROP_MODEL_NAME] = BATT_MODEL_NAME,
|
||||
[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_POWER_NOW] = BATT_POWER_NOW,
|
||||
};
|
||||
|
||||
@@ -584,6 +587,9 @@ static int qcom_battmgr_bat_get_property(struct power_supply *psy,
|
||||
case POWER_SUPPLY_PROP_TEMP:
|
||||
val->intval = battmgr->status.temperature;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_INTERNAL_RESISTANCE:
|
||||
val->intval = battmgr->status.resistance;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
|
||||
val->intval = battmgr->status.discharge_time;
|
||||
break;
|
||||
@@ -668,6 +674,7 @@ static const enum power_supply_property sm8350_bat_props[] = {
|
||||
POWER_SUPPLY_PROP_MODEL_NAME,
|
||||
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
|
||||
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
|
||||
POWER_SUPPLY_PROP_INTERNAL_RESISTANCE,
|
||||
POWER_SUPPLY_PROP_POWER_NOW,
|
||||
};
|
||||
|
||||
@@ -1200,6 +1207,9 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
|
||||
case BATT_TTE_AVG:
|
||||
battmgr->status.discharge_time = le32_to_cpu(resp->intval.value);
|
||||
break;
|
||||
case BATT_RESISTANCE:
|
||||
battmgr->status.resistance = le32_to_cpu(resp->intval.value);
|
||||
break;
|
||||
case BATT_POWER_NOW:
|
||||
battmgr->status.power_now = le32_to_cpu(resp->intval.value);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user