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

Commit 80a8f967 authored by Anirudh Ghayal's avatar Anirudh Ghayal
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 2c110e4d
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -7476,6 +7476,7 @@ static void smblib_chg_termination_work(struct work_struct *work)
						chg_termination_work);
						chg_termination_work);
	int rc, input_present, delay = CHG_TERM_WA_ENTRY_DELAY_MS;
	int rc, input_present, delay = CHG_TERM_WA_ENTRY_DELAY_MS;
	int vbat_now_uv, max_fv_uv;
	int vbat_now_uv, max_fv_uv;
	u8 stat = 0;


	/*
	/*
	 * Hold awake votable to prevent pm_relax being called prior to
	 * Hold awake votable to prevent pm_relax being called prior to
@@ -7490,9 +7491,18 @@ static void smblib_chg_termination_work(struct work_struct *work)
	rc = smblib_get_prop_from_bms(chg,
	rc = smblib_get_prop_from_bms(chg,
				POWER_SUPPLY_PROP_REAL_CAPACITY, &pval);
				POWER_SUPPLY_PROP_REAL_CAPACITY, &pval);
	if ((rc < 0) || (pval.intval < 100)) {
	if ((rc < 0) || (pval.intval < 100)) {
		vote(chg->usb_icl_votable, CHG_TERMINATION_VOTER, false, 0);
		rc = smblib_read(chg, BATTERY_CHARGER_STATUS_1_REG, &stat);
		vote(chg->dc_suspend_votable, CHG_TERMINATION_VOTER, false, 0);
		if (rc < 0)
			goto out;
			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 */
	/* Get the battery float voltage */