qpnp-fg-gen3: Show a fake SOC and voltage when battery is missing
During battery hotswap, a strong charger will be supplying enough current to keep the device up and running. Currently, FG driver shows up the monotonic SOC and voltage as-is (which is zero) to the battery power supply and hence to the userspace. Show a fake battery SOC (50%) and fake battery voltage (3.7 V) when the battery is missing. If a strong charger is not present, then the device will be powered down anyways. Change-Id: Ia2c85d1e75bbf0c937a7e36e786362c473c7f7cd Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
parent
336e245503
commit
7e3256e251
1 changed files with 16 additions and 5 deletions
|
@ -773,6 +773,7 @@ static bool is_debug_batt_id(struct fg_chip *chip)
|
|||
#define FULL_CAPACITY 100
|
||||
#define FULL_SOC_RAW 255
|
||||
#define DEBUG_BATT_SOC 67
|
||||
#define BATT_MISS_SOC 50
|
||||
#define EMPTY_SOC 0
|
||||
static int fg_get_prop_capacity(struct fg_chip *chip, int *val)
|
||||
{
|
||||
|
@ -783,6 +784,16 @@ static int fg_get_prop_capacity(struct fg_chip *chip, int *val)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (chip->fg_restarting) {
|
||||
*val = chip->last_soc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (chip->battery_missing) {
|
||||
*val = BATT_MISS_SOC;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_batt_empty(chip)) {
|
||||
*val = EMPTY_SOC;
|
||||
return 0;
|
||||
|
@ -2490,13 +2501,13 @@ static int fg_psy_get_property(struct power_supply *psy,
|
|||
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
if (chip->fg_restarting)
|
||||
pval->intval = chip->last_soc;
|
||||
else
|
||||
rc = fg_get_prop_capacity(chip, &pval->intval);
|
||||
rc = fg_get_prop_capacity(chip, &pval->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
|
||||
rc = fg_get_battery_voltage(chip, &pval->intval);
|
||||
if (chip->battery_missing)
|
||||
pval->intval = 3700000;
|
||||
else
|
||||
rc = fg_get_battery_voltage(chip, &pval->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CURRENT_NOW:
|
||||
rc = fg_get_battery_current(chip, &pval->intval);
|
||||
|
|
Loading…
Add table
Reference in a new issue