diff options
| author | Subbaraman Narayanamurthy <subbaram@codeaurora.org> | 2017-01-24 18:45:14 -0800 |
|---|---|---|
| committer | Subbaraman Narayanamurthy <subbaram@codeaurora.org> | 2017-02-02 21:02:37 -0800 |
| commit | 7e3256e251bb573b9f324289a00bef5ec5b0ecfd (patch) | |
| tree | 36c19f99a92843847cad31784d26a8ee6b4eb362 /drivers/power | |
| parent | 336e24550387c399c29c3c5a2637c8f29c0a33c7 (diff) | |
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>
Diffstat (limited to 'drivers/power')
| -rw-r--r-- | drivers/power/supply/qcom/qpnp-fg-gen3.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/power/supply/qcom/qpnp-fg-gen3.c b/drivers/power/supply/qcom/qpnp-fg-gen3.c index 7ffa583ca01d..4aba0292b9a5 100644 --- a/drivers/power/supply/qcom/qpnp-fg-gen3.c +++ b/drivers/power/supply/qcom/qpnp-fg-gen3.c @@ -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); |
