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

Commit 69e0c368 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb358-charger: Add hysteresis for JEITA control"

parents f10f0a12 8512953a
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -1400,6 +1400,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;
@@ -1426,7 +1427,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 >=
@@ -1438,7 +1439,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 >=
@@ -1450,7 +1451,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 >=
@@ -1461,7 +1462,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;
@@ -1478,7 +1480,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;
		}
@@ -1489,8 +1492,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) {
@@ -1500,7 +1503,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;
@@ -1514,7 +1517,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 =
@@ -1527,7 +1530,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 =
@@ -1544,7 +1547,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;
		}