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

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

power: qpnp-qg: Update the PON SOC flow



The shutdown SOC is rejected if the battery-temperature
changes beyond a threshold value. However, this check
only makes sense at low-temperatures (< 0 degrees C) where
RBAT variation is significant. Add this additional check.

While at it, apply the additional PON_OCV checks only
for PMI632.

Change-Id: I1623d1a83d4ffd175c4ce0169b3433532b882e8e
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent bce946d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -210,6 +210,7 @@ enum qg_wa_flags {
	QG_VBAT_LOW_WA = BIT(0),
	QG_RECHARGE_SOC_WA = BIT(1),
	QG_CLK_ADJUST_WA = BIT(2),
	QG_PON_OCV_WA = BIT(3),
};


+33 −25
Original line number Diff line number Diff line
@@ -2656,7 +2656,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)))
			abs(shutdown[SDAM_TEMP] -  batt_temp)) &&
			(shutdown[SDAM_TEMP] < 0 || batt_temp < 0))
		goto use_pon_ocv;

	if ((chip->dt.shutdown_soc_threshold != -EINVAL) &&
@@ -2672,6 +2673,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)

use_pon_ocv:
	if (use_pon_ocv == true) {
		if (chip->wa_flags & QG_PON_OCV_WA) {
			if (ocv[S3_LAST_OCV].ocv_raw == FIFO_V_RESET_VAL) {
				if (!ocv[SDAM_PON_OCV].ocv_uv) {
					strlcpy(ocv_type, "S7_PON_SOC", 20);
@@ -2691,7 +2693,8 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
					ocv_uv = ocv[SDAM_PON_OCV].ocv_uv;
				}
			} else {
			if (ocv[S3_LAST_OCV].ocv_uv >= ocv[S7_PON_OCV].ocv_uv) {
				if (ocv[S3_LAST_OCV].ocv_uv >=
						ocv[S7_PON_OCV].ocv_uv) {
					strlcpy(ocv_type, "S3_LAST_SOC", 20);
					ocv_uv = ocv[S3_LAST_OCV].ocv_uv;
				} else {
@@ -2699,6 +2702,11 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
					ocv_uv = ocv[S7_PON_OCV].ocv_uv;
				}
			}
		} else {
			/* Use S7 PON OCV */
			strlcpy(ocv_type, "S7_PON_SOC", 20);
			ocv_uv = ocv[S7_PON_OCV].ocv_uv;
		}

		ocv_uv = CAP(QG_MIN_OCV_UV, QG_MAX_OCV_UV, ocv_uv);
		rc = lookup_soc_ocv(&pon_soc, ocv_uv, batt_temp, false);
@@ -2768,7 +2776,7 @@ static int qg_set_wa_flags(struct qpnp_qg *chip)
{
	switch (chip->pmic_rev_id->pmic_subtype) {
	case PMI632_SUBTYPE:
		chip->wa_flags |= QG_RECHARGE_SOC_WA;
		chip->wa_flags |= QG_RECHARGE_SOC_WA | QG_PON_OCV_WA;
		if (chip->pmic_rev_id->rev4 == PMI632_V1P0_REV4)
			chip->wa_flags |= QG_VBAT_LOW_WA;
		break;