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

Commit 19d1d514 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen4: Fix adjusting recharge SOC after charge termination



Currently, recharge_soc is adjusted based on the monotonic SOC
when the charge termination happens and it is adjusted back to
the original threshold when battery health is good i.e. not in
JEITA. This is needed to help resume charging. However, there is
an issue in the code which simply sets the flag when recharge
SOC is adjusted but not modifying the recharge SOC. Fix it.

Also, allow adjusting recharge SOC only once after a good charge
termination so that recharge SOC won't be modified before
charging resumes or input is removed.

CRs-Fixed: 2390661
Change-Id: Ib79aa25210f96084ddf3f00e6c05a52433381256
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent afa8139d
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -264,6 +264,7 @@ struct fg_gen4_chip {
	bool			rslow_low;
	bool			rapid_soc_dec_en;
	bool			vbatt_low;
	bool			chg_term_good;
};

struct bias_config {
@@ -2348,8 +2349,16 @@ static int fg_gen4_adjust_recharge_soc(struct fg_gen4_chip *chip)
				new_recharge_soc = msoc - (FULL_CAPACITY -
								recharge_soc);
				fg->recharge_soc_adjusted = true;
				if (fg->health == POWER_SUPPLY_HEALTH_GOOD)
					chip->chg_term_good = true;
			} else {
				/* adjusted already, do nothing */
				/*
				 * If charge termination happened properly then
				 * do nothing.
				 */
				if (chip->chg_term_good)
					return 0;

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

@@ -2360,7 +2369,7 @@ static int fg_gen4_adjust_recharge_soc(struct fg_gen4_chip *chip)

				new_recharge_soc = recharge_soc;
				fg->recharge_soc_adjusted = false;
				return 0;
				chip->chg_term_good = false;
			}
		} else {
			if (!fg->recharge_soc_adjusted)
@@ -2379,11 +2388,13 @@ static int fg_gen4_adjust_recharge_soc(struct fg_gen4_chip *chip)
			/* Restore the default value */
			new_recharge_soc = recharge_soc;
			fg->recharge_soc_adjusted = false;
			chip->chg_term_good = false;
		}
	} else {
		/* Restore the default value */
		new_recharge_soc = recharge_soc;
		fg->recharge_soc_adjusted = false;
		chip->chg_term_good = false;
	}

	if (recharge_soc_status == fg->recharge_soc_adjusted)