Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65cbdb06 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

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



When there is an early charge termination because of soft JEITA
(warm and cool) conditions, float voltage would have been reduced
by the charger based on the compensation configuration (e.g. by
105 mV). This can be close to the recharge voltage threshold
(e.g. 4.25 V) when the recharge is configured to be based off
Vbatt. Adjust the recharge voltage threshold dynamically by
lowering it by 200 mV during soft JEITA and charge termination.
Reset it back to the original value when the condition clears
i.e. either it is out of soft JEITA or the charger is removed.

Change-Id: If4d293c10e84e414c81204784f2e7062140264b1
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent fbd49499
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+40 −0
Original line number Diff line number Diff line
@@ -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;
}

@@ -1960,6 +1964,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;
@@ -2423,6 +2454,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);
@@ -3978,6 +4013,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);
	}