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

Commit cff71486 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: smblite: Fix restoring the ICL in the thermal-regulation-loop



Avoid decrementing ICL twice when we are above _UB threshold.
Also, increment back the ICL only when DIE_STATUS is 0 i.e when
we are below the _LB threshold.

Change-Id: I58027cb94500cf93eb42b44dcec9a5e68670b5e1
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 5537f3dc
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -2892,23 +2892,23 @@ static void smblite_lib_thermal_regulation_work(struct work_struct *work)
	}

	if (stat & DIE_TEMP_UB_BIT) {
		icl_ua = get_effective_result(chg->usb_icl_votable)
				- THERM_REGULATION_STEP_UA;

		/* Decrement ICL by one step */
		vote(chg->usb_icl_votable, SW_THERM_REGULATION_VOTER,
				true, icl_ua - THERM_REGULATION_STEP_UA);

		/* Check if we reached minimum ICL limit */
		if (icl_ua < USBIN_500UA + THERM_REGULATION_STEP_UA)
			goto exit;

		/* Decrement ICL by one step */
		icl_ua -= THERM_REGULATION_STEP_UA;
		vote(chg->usb_icl_votable, SW_THERM_REGULATION_VOTER,
				true, icl_ua);

		goto reschedule;
	}

	if (stat & DIE_TEMP_LB_BIT) {
	/* check if DIE_TEMP is below LB */
	if (!(stat & DIE_TEMP_MASK)) {
		icl_ua += THERM_REGULATION_STEP_UA;
		vote(chg->usb_icl_votable, SW_THERM_REGULATION_VOTER,
				true, icl_ua + THERM_REGULATION_STEP_UA);
				true, icl_ua);

		/*
		 * Check if we need further increments:
+1 −0
Original line number Diff line number Diff line
@@ -266,6 +266,7 @@ enum {
#define THERMREG_DISABLED_BIT			BIT(0)

#define DIE_TEMP_STATUS_REG			(MISC_BASE + 0x09)
#define DIE_TEMP_MASK				GENMASK(3, 0)
#define DIE_TEMP_SHDN_BIT			BIT(3)
#define DIE_TEMP_RST_BIT			BIT(2)
#define DIE_TEMP_UB_BIT				BIT(1)