Merge "power: qpnp-fg-gen3: adjust recharge voltage during soft JEITA charge done"

This commit is contained in:
Linux Build Service Account 2017-08-10 21:36:32 -07:00 committed by Gerrit - the friendly Code Review server
commit 75f68f1cdb
3 changed files with 52 additions and 0 deletions

View file

@ -419,6 +419,7 @@ struct fg_chip {
int maint_soc;
int delta_soc;
int last_msoc;
int last_recharge_volt_mv;
int esr_timer_charging_default[NUM_ESR_TIMERS];
enum slope_limit_status slope_limit_sts;
bool profile_available;

View file

@ -1637,6 +1637,9 @@ static int fg_set_recharge_voltage(struct fg_chip *chip, int voltage_mv)
if (chip->wa_flags & PMI8998_V1_REV_WA)
return 0;
if (voltage_mv == chip->last_recharge_volt_mv)
return 0;
fg_dbg(chip, FG_STATUS, "Setting recharge voltage to %dmV\n",
voltage_mv);
fg_encode(chip->sp, FG_SRAM_RECHARGE_VBATT_THR, voltage_mv, &buf);
@ -1651,6 +1654,7 @@ static int fg_set_recharge_voltage(struct fg_chip *chip, int voltage_mv)
return rc;
}
chip->last_recharge_volt_mv = voltage_mv;
return 0;
}
@ -1961,6 +1965,33 @@ static int fg_adjust_recharge_soc(struct fg_chip *chip)
return 0;
}
static int fg_adjust_recharge_voltage(struct fg_chip *chip)
{
int rc, recharge_volt_mv;
if (chip->dt.auto_recharge_soc)
return 0;
fg_dbg(chip, FG_STATUS, "health: %d chg_status: %d chg_done: %d\n",
chip->health, chip->charge_status, chip->charge_done);
recharge_volt_mv = chip->dt.recharge_volt_thr_mv;
/* Lower the recharge voltage in soft JEITA */
if (chip->health == POWER_SUPPLY_HEALTH_WARM ||
chip->health == POWER_SUPPLY_HEALTH_COOL)
recharge_volt_mv -= 200;
rc = fg_set_recharge_voltage(chip, recharge_volt_mv);
if (rc < 0) {
pr_err("Error in setting recharge_voltage, rc=%d\n",
rc);
return rc;
}
return 0;
}
static int fg_slope_limit_config(struct fg_chip *chip, int batt_temp)
{
enum slope_limit_status status;
@ -2424,6 +2455,10 @@ static void status_change_work(struct work_struct *work)
if (rc < 0)
pr_err("Error in adjusting recharge_soc, rc=%d\n", rc);
rc = fg_adjust_recharge_voltage(chip);
if (rc < 0)
pr_err("Error in adjusting recharge_voltage, rc=%d\n", rc);
rc = fg_adjust_ki_coeff_dischg(chip);
if (rc < 0)
pr_err("Error in adjusting ki_coeff_dischg, rc=%d\n", rc);
@ -3979,6 +4014,11 @@ static irqreturn_t fg_delta_batt_temp_irq_handler(int irq, void *data)
if (rc < 0)
pr_err("Error in adjusting timebase, rc=%d\n", rc);
rc = fg_adjust_recharge_voltage(chip);
if (rc < 0)
pr_err("Error in adjusting recharge_voltage, rc=%d\n",
rc);
chip->last_batt_temp = batt_temp;
power_supply_changed(chip->batt_psy);
}

View file

@ -1395,6 +1395,17 @@ static irqreturn_t handle_ptrain_done(int irq, void *data)
struct qnovo *chip = data;
union power_supply_propval pval = {0};
/*
* In some cases (esp shutting down) the userspace would disable by
* setting qnovo_enable=0. Also charger could be removed or there is
* an error (i.e. its not okay to run qnovo)-
* skip taking ESR measurement in such situations
*/
if (get_client_vote(chip->disable_votable, USER_VOTER)
|| get_effective_result(chip->not_ok_to_qnovo_votable) > 0)
return IRQ_HANDLED;
/*
* hw resets pt_en bit once ptrain_done triggers.
* vote on behalf of QNI to disable it such that