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

Commit d92b246d authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen3: Restore recharge SOC only when not in JEITA



Currently, recharge SOC is adjusted (lowered) based on the SOC
where charging terminates. It is restored back to the original
threshold when the charge termination condition goes away. This
works fine in most cases. However there are certain conditions
where the charger fluctuates between fast and taper regions along
with the charge termination status.

Handle this by checking if battery is out of JEITA as well before
restoring back the original recharge SOC threshold.

CRs-Fixed: 2213369
Change-Id: Ic64151ddbbff09c26d6ebfcd3e6d4e70e0be8c9d
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 4e0bb670
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2080,12 +2080,21 @@ static int fg_set_recharge_soc(struct fg_chip *chip, int recharge_soc)

static int fg_adjust_recharge_soc(struct fg_chip *chip)
{
	union power_supply_propval prop = {0, };
	int rc, msoc, recharge_soc, new_recharge_soc = 0;
	bool recharge_soc_status;

	if (!chip->dt.auto_recharge_soc)
		return 0;

	rc = power_supply_get_property(chip->batt_psy, POWER_SUPPLY_PROP_HEALTH,
		&prop);
	if (rc < 0) {
		pr_err("Error in getting battery health, rc=%d\n", rc);
		return rc;
	}
	chip->health = prop.intval;

	recharge_soc = chip->dt.recharge_soc_thr;
	recharge_soc_status = chip->recharge_soc_adjusted;
	/*
@@ -2116,6 +2125,9 @@ static int fg_adjust_recharge_soc(struct fg_chip *chip)
			if (!chip->recharge_soc_adjusted)
				return 0;

			if (chip->health != POWER_SUPPLY_HEALTH_GOOD)
				return 0;

			/* Restore the default value */
			new_recharge_soc = recharge_soc;
			chip->recharge_soc_adjusted = false;