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

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

power: smb5-lib: Improve the charge-termination WA handling



In rare scenarios when the battery enters/exits JEITA conditions
post termination, the termination workaround restarts thus
resetting the reference values. Improve this handling by
restarting the WA only if the existing WA timer is not running
thus avoiding WA restarts across minor JEITA oscillations.

Change-Id: I5bf91367b633abf79cbc60ef5bdf93cca9559022
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent bb168a0f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/pmic-voter.h>
#include <linux/ktime.h>
#include <linux/usb/typec.h>
#include <linux/alarmtimer.h>
#include "smb5-lib.h"
#include "smb5-reg.h"
#include "schgm-flash.h"
@@ -5194,7 +5195,9 @@ static void smblib_eval_chg_termination(struct smb_charger *chg, u8 batt_status)
	 * battery. Trigger the charge termination WA once charging is completed
	 * to prevent overcharing.
	 */
	if ((batt_status == TERMINATE_CHARGE) && (pval.intval == 100)) {
	if ((batt_status == TERMINATE_CHARGE) && (pval.intval == 100) &&
		(ktime_to_ms(alarm_expires_remaining(/* alarm not pending */
				&chg->chg_termination_alarm)) <= 0)) {
		chg->cc_soc_ref = 0;
		chg->last_cc_soc = 0;
		chg->term_vbat_uv = 0;