aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-08-14 16:32:31 +0000
committerAndroid Partner Code Review <android-gerrit-partner@google.com>2018-08-14 16:32:31 +0000
commit7186c3b1a7f8369368405ae81f5f5818dfe9b5f9 (patch)
tree684125b694b49539683e7707e820711a171e2594
parentc585eab81bdfacfd99900c887bba9201a63af232 (diff)
parentfc87b92f3da4c651c718b784821a0ab4a2d86ef4 (diff)
Merge "gauage:add fg restart procedure to fix soc incorrect when battery full" into android-msm-triton-3.18android-wear-8.1.0_r0.1
-rw-r--r--drivers/power/fg-core.h2
-rw-r--r--drivers/power/qpnp-fg-gen3.c29
2 files changed, 31 insertions, 0 deletions
diff --git a/drivers/power/fg-core.h b/drivers/power/fg-core.h
index 97c31a8c204f..f99c9c0bfa80 100644
--- a/drivers/power/fg-core.h
+++ b/drivers/power/fg-core.h
@@ -438,6 +438,7 @@ struct fg_chip {
bool profile_loaded;
bool battery_missing;
bool fg_restarting;
+ bool fg_can_restart_flag;
bool charge_full;
bool recharge_soc_adjusted;
bool ki_coeff_dischg_en;
@@ -455,6 +456,7 @@ struct fg_chip {
struct work_struct esr_sw_work;
struct delayed_work batt_avg_work;
struct delayed_work sram_dump_work;
+ struct delayed_work fg_restart_work;
struct fg_circ_buf ibatt_circ_buf;
struct fg_circ_buf vbatt_circ_buf;
};
diff --git a/drivers/power/qpnp-fg-gen3.c b/drivers/power/qpnp-fg-gen3.c
index d1c7e90deca4..b90da2aa5bdd 100644
--- a/drivers/power/qpnp-fg-gen3.c
+++ b/drivers/power/qpnp-fg-gen3.c
@@ -170,6 +170,7 @@ static void fg_encode_current(struct fg_sram_param *sp,
enum fg_sram_param_id id, int val_ma, u8 *buf);
static void fg_encode_default(struct fg_sram_param *sp,
enum fg_sram_param_id id, int val, u8 *buf);
+static int __fg_restart(struct fg_chip *chip);
static struct fg_irq_info fg_irqs[FG_IRQ_MAX];
@@ -2517,13 +2518,23 @@ static int fg_config_esr_sw(struct fg_chip *chip)
return 0;
}
+static void fg_restart_work(struct work_struct *work)
+{
+ struct fg_chip *chip = container_of(work, struct fg_chip,
+ fg_restart_work.work);
+ chip->fg_can_restart_flag = 1;
+
+}
static void status_change_work(struct work_struct *work)
{
struct fg_chip *chip = container_of(work,
struct fg_chip, status_change_work);
union power_supply_propval prop = {0, };
int rc, batt_temp;
+ int msoc;
+ bool usb_online;
+ static bool fg_restart_once=0;
if (!batt_psy_initialized(chip)) {
fg_dbg(chip, FG_STATUS, "Charger not available?!\n");
@@ -2547,6 +2558,22 @@ static void status_change_work(struct work_struct *work)
}
chip->charge_status = prop.intval;
+ fg_get_prop_capacity(chip, &msoc);
+ fg_get_usb_online(chip, &usb_online);
+ if (!usb_online && fg_restart_once) {
+ fg_restart_once = 0;
+ }
+ if (chip->charge_status == POWER_SUPPLY_STATUS_FULL && msoc < 99 && !fg_restart_once) {
+ if(chip->fg_can_restart_flag)
+ {
+ fg_restart_once = 1;
+ chip->fg_can_restart_flag = 0;
+ schedule_delayed_work(&chip->fg_restart_work,
+ msecs_to_jiffies(3000));
+ __fg_restart(chip);
+ }
+ }
+
rc = power_supply_get_property(chip->batt_psy,
POWER_SUPPLY_PROP_CHARGE_TYPE, &prop);
if (rc < 0) {
@@ -5102,6 +5129,7 @@ static int fg_gen3_probe(struct spmi_device *spmi)
INIT_WORK(&chip->esr_sw_work, fg_esr_sw_work);
INIT_DELAYED_WORK(&chip->batt_avg_work, batt_avg_work);
INIT_DELAYED_WORK(&chip->sram_dump_work, sram_dump_work);
+ INIT_DELAYED_WORK(&chip->fg_restart_work, fg_restart_work);
dev_set_drvdata(&spmi->dev, chip);
rc = fg_memif_init(chip);
@@ -5187,6 +5215,7 @@ static int fg_gen3_probe(struct spmi_device *spmi)
}
chip->twm_soc_value = DEFAULT_TWM_SOC_VALUE;
+ chip->fg_can_restart_flag =1;
rc = fg_get_battery_voltage(chip, &volt_uv);
if (!rc)