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

Commit 8512953a authored by Zhenhua Huang's avatar Zhenhua Huang
Browse files

power: smb358-charger: Add hysteresis for JEITA control



Add an hysteresis offset to prevent irq storm when battery temperature
around JEITA thresholds.

Change-Id: I3c609b27eb7d1df36a811cbbc5e35316fdfa0f60
CRs-Fixed: 754679
Signed-off-by: default avatarZhenhua Huang <zhenhuah@codeaurora.org>
parent e565ee19
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -1392,6 +1392,7 @@ static void smb358_chg_set_appropriate_vddmax(
			"Couldn't set float voltage rc = %d\n", rc);
}

#define HYSTERESIS_DECIDEGC 20
static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
{
	struct smb358_charger *chip = ctx;
@@ -1418,7 +1419,7 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_present = true;

			chip->adc_param.low_temp =
				chip->hot_bat_decidegc;
				chip->hot_bat_decidegc - HYSTERESIS_DECIDEGC;
			chip->adc_param.state_request =
				ADC_TM_COOL_THR_ENABLE;
		} else if (temp >=
@@ -1430,7 +1431,7 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_present = true;

			chip->adc_param.low_temp =
				chip->warm_bat_decidegc;
				chip->warm_bat_decidegc - HYSTERESIS_DECIDEGC;
			chip->adc_param.high_temp =
				chip->hot_bat_decidegc;
		} else if (temp >=
@@ -1442,7 +1443,7 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_present = true;

			chip->adc_param.low_temp =
				chip->cool_bat_decidegc;
				chip->cool_bat_decidegc - HYSTERESIS_DECIDEGC;
			chip->adc_param.high_temp =
				chip->warm_bat_decidegc;
		} else if (temp >=
@@ -1453,7 +1454,8 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_cool = true;
			bat_present = true;

			chip->adc_param.low_temp = chip->cold_bat_decidegc;
			chip->adc_param.low_temp =
				chip->cold_bat_decidegc - HYSTERESIS_DECIDEGC;
			if (chip->jeita_supported)
				chip->adc_param.high_temp =
						chip->cool_bat_decidegc;
@@ -1470,7 +1472,8 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_present = true;

			chip->adc_param.high_temp = chip->cold_bat_decidegc;
			chip->adc_param.low_temp = chip->bat_present_decidegc;
			chip->adc_param.low_temp = chip->bat_present_decidegc
							- HYSTERESIS_DECIDEGC;
			chip->adc_param.state_request =
					ADC_TM_HIGH_LOW_THR_ENABLE;
		}
@@ -1481,8 +1484,8 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_hot = false;
			bat_warm = false;
			bat_present = false;
			chip->adc_param.high_temp =
				chip->bat_present_decidegc;
			chip->adc_param.high_temp = chip->bat_present_decidegc
							+ HYSTERESIS_DECIDEGC;
			chip->adc_param.state_request =
				ADC_TM_WARM_THR_ENABLE;
		} else if (temp <= chip->cold_bat_decidegc) {
@@ -1492,7 +1495,7 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_cool = false;
			bat_present = true;
			chip->adc_param.high_temp =
				chip->cold_bat_decidegc;
				chip->cold_bat_decidegc + HYSTERESIS_DECIDEGC;
			/* add low_temp to enable batt present check */
			chip->adc_param.low_temp =
				chip->bat_present_decidegc;
@@ -1506,7 +1509,7 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_cool = true;
			bat_present = true;
			chip->adc_param.high_temp =
				chip->cool_bat_decidegc;
				chip->cool_bat_decidegc + HYSTERESIS_DECIDEGC;
			chip->adc_param.low_temp =
				chip->cold_bat_decidegc;
			chip->adc_param.state_request =
@@ -1519,7 +1522,7 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			bat_cool = false;
			bat_present = true;
			chip->adc_param.high_temp =
				chip->warm_bat_decidegc;
				chip->warm_bat_decidegc + HYSTERESIS_DECIDEGC;
			chip->adc_param.low_temp =
				chip->cool_bat_decidegc;
			chip->adc_param.state_request =
@@ -1536,7 +1539,8 @@ static void smb_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
			else
				chip->adc_param.low_temp =
					chip->cold_bat_decidegc;
			chip->adc_param.high_temp = chip->hot_bat_decidegc;
			chip->adc_param.high_temp =
				chip->hot_bat_decidegc + HYSTERESIS_DECIDEGC;
			chip->adc_param.state_request =
					ADC_TM_HIGH_LOW_THR_ENABLE;
		}