mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 22:40:54 -04:00
Ensuring monotonic variation of soc
Ensure that the power monotonically increases during charging and monotonically decreases during discharging. Change-Id: I4ef202daf4b65e0640e4794d7f74a17241051c25 Reviewed-on: https://gerrit.mot.com/2575379 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Wentao Xu <xuwt2@motorola.com> Reviewed-by: Guobin Zhang <zhanggb@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
99381ee852
commit
9eb7fe65ac
1 changed files with 30 additions and 21 deletions
|
|
@ -1813,27 +1813,6 @@ static int mmi_get_battery_health(struct mmi_charger *charger)
|
|||
return batt_health;
|
||||
}
|
||||
|
||||
static int mmi_combine_battery_soc(struct mmi_charger_chip *chip)
|
||||
{
|
||||
int soc = 0;
|
||||
int remain = 0, full = 0;
|
||||
struct mmi_battery_pack *battery = NULL;
|
||||
|
||||
list_for_each_entry(battery, &chip->battery_list, list) {
|
||||
remain += battery->info->batt_soc * battery->info->batt_full_uah;
|
||||
full += battery->info->batt_full_uah;
|
||||
}
|
||||
|
||||
if (full > 0 && remain >= 0) {
|
||||
soc = remain / full;
|
||||
if (soc > 100)
|
||||
soc = 100;
|
||||
} else
|
||||
soc = -1;
|
||||
|
||||
return soc;
|
||||
}
|
||||
|
||||
static int mmi_combine_battery_status(struct mmi_charger_chip *chip)
|
||||
{
|
||||
int status = POWER_SUPPLY_STATUS_UNKNOWN;
|
||||
|
|
@ -1860,6 +1839,36 @@ static int mmi_combine_battery_status(struct mmi_charger_chip *chip)
|
|||
return status;
|
||||
}
|
||||
|
||||
static int mmi_combine_battery_soc(struct mmi_charger_chip *chip)
|
||||
{
|
||||
int status;
|
||||
static int soc = 0;
|
||||
int soc_curr = 0;
|
||||
int remain = 0, full = 0;
|
||||
struct mmi_battery_pack *battery = NULL;
|
||||
|
||||
list_for_each_entry(battery, &chip->battery_list, list) {
|
||||
remain += battery->info->batt_soc * battery->info->batt_full_uah;
|
||||
full += battery->info->batt_full_uah;
|
||||
}
|
||||
|
||||
if (full > 0 && remain >= 0) {
|
||||
soc_curr = remain / full;
|
||||
status = mmi_combine_battery_status(chip);
|
||||
if ((soc <= 0) ||
|
||||
((status == POWER_SUPPLY_STATUS_CHARGING) && (soc_curr > soc)) ||
|
||||
((status != POWER_SUPPLY_STATUS_CHARGING) && (soc_curr < soc))) {
|
||||
soc = soc_curr;
|
||||
}
|
||||
|
||||
if (soc > 100)
|
||||
soc = 100;
|
||||
} else
|
||||
soc = -1;
|
||||
|
||||
return soc;
|
||||
}
|
||||
|
||||
static int mmi_combine_battery_cycles(struct mmi_charger_chip *chip)
|
||||
{
|
||||
int cycles = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue