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

Commit d457c735 authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Ashish Chavan
Browse files

power: smb5-lib: Add additional check to exit charge-termination WA



There is a possibility of the "real capacity" dropping post
termination due to a OCV update causing the charger-termination
WA to exit. Fix this by explicitly checking that we are not
in termination before exiting from the WA.

Change-Id: I5bf91367b633abf79cbc60ef5bdf93cca9559029
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 9835eac1
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -7591,8 +7591,10 @@ static void smblib_chg_termination_work(struct work_struct *work)
	int val;
	struct smb_charger *chg = container_of(work, struct smb_charger,
						chg_termination_work);
	union power_supply_propval pval = {0, };
	int rc, input_present, delay = CHG_TERM_WA_ENTRY_DELAY_MS;
	int vbat_now_uv, max_fv_uv;
	u8 stat = 0;

	/*
	 * Hold awake votable to prevent pm_relax being called prior to
@@ -7612,6 +7614,21 @@ static void smblib_chg_termination_work(struct work_struct *work)
		goto out;
	}

	if ((rc < 0) || (pval.intval < 100)) {
		rc = smblib_read(chg, BATTERY_CHARGER_STATUS_1_REG, &stat);
		if (rc < 0)
			goto out;

		/* check we are not in termination to exit the WA */
		if ((stat & BATTERY_CHARGER_STATUS_MASK) != TERMINATE_CHARGE) {
			vote(chg->usb_icl_votable, CHG_TERMINATION_VOTER,
				false, 0);
			vote(chg->dc_suspend_votable, CHG_TERMINATION_VOTER,
				false, 0);
			goto out;
		}
	}

	/* Get the battery float voltage */
	rc = smblib_get_prop_from_bms(chg, SMB5_QG_VOLTAGE_MAX, &val);
	if (rc < 0) {