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

Commit 1d0e3315 authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Umang Agrawal
Browse files

power: qpnp-qg: Fix reading negative temperature from SDAM



In the SDAM the battery temperature is stored as 2's complement,
use it accordingly.

Change-Id: Id0cb0438e27f80f0e8f8675308466fcf8d729db2
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent a34dc132
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2745,7 +2745,7 @@ static struct ocv_all ocv[] = {
#define S7_ERROR_MARGIN_UV		20000
static int qg_determine_pon_soc(struct qpnp_qg *chip)
{
	int rc = 0, batt_temp = 0, i;
	int rc = 0, batt_temp = 0, i, shutdown_temp = 0;
	bool use_pon_ocv = true;
	unsigned long rtc_sec = 0;
	u32 ocv_uv = 0, soc = 0, pon_soc = 0, full_soc = 0, cutoff_soc = 0;
@@ -2786,6 +2786,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
		pr_err("Failed to read shutdown params rc=%d\n", rc);
		goto use_pon_ocv;
	}
	shutdown_temp = sign_extend32(shutdown[SDAM_TEMP], 15);

	rc = lookup_soc_ocv(&pon_soc, ocv[S7_PON_OCV].ocv_uv, batt_temp, false);
	if (rc < 0) {
@@ -2798,7 +2799,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
			shutdown[SDAM_SOC],
			shutdown[SDAM_OCV_UV],
			shutdown[SDAM_TIME_SEC],
			shutdown[SDAM_TEMP],
			shutdown_temp,
			rtc_sec, batt_temp,
			pon_soc);
	/*
@@ -2815,8 +2816,8 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
		goto use_pon_ocv;

	if (!is_between(0, chip->dt.shutdown_temp_diff,
			abs(shutdown[SDAM_TEMP] -  batt_temp)) &&
			(shutdown[SDAM_TEMP] < 0 || batt_temp < 0))
			abs(shutdown_temp -  batt_temp)) &&
			(shutdown_temp < 0 || batt_temp < 0))
		goto use_pon_ocv;

	if ((chip->dt.shutdown_soc_threshold != -EINVAL) &&