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

Commit 3af22db0 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
a bug in the code which simply sets the flag indicating 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 c93d9386
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -298,6 +298,7 @@ struct fg_gen4_chip {
	bool			rapid_soc_dec_en;
	bool			vbatt_low;
	bool			soc_scale_mode;
	bool			chg_term_good;
};

struct bias_config {
@@ -2500,8 +2501,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;

@@ -2512,7 +2521,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)
@@ -2531,11 +2540,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)