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

Commit f410c920 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

smb-lib: update displaying battery overvoltage in health property



Currently, smb2 charger is configured to not end the charging
cycle when battery overvoltage occurs. However, when the battery
overvoltage status is read, it will be displayed through health
property. Improve this by reading the battery voltage and check
whether it is within 40mV headroom above float voltage. If it is
above that threshold then continue with displaying overvoltage
status.

CRs-Fixed: 1079363
Change-Id: I45847f446c91c80a5110d80b59a0ae4b8e2c40e5
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent b9c370a5
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -1199,6 +1199,7 @@ int smblib_get_prop_batt_charge_type(struct smb_charger *chg,
int smblib_get_prop_batt_health(struct smb_charger *chg,
				union power_supply_propval *val)
{
	union power_supply_propval pval;
	int rc;
	u8 stat;

@@ -1212,10 +1213,20 @@ int smblib_get_prop_batt_health(struct smb_charger *chg,
		   stat);

	if (stat & CHARGER_ERROR_STATUS_BAT_OV_BIT) {
		smblib_err(chg, "battery over-voltage\n");
		rc = smblib_get_prop_batt_voltage_now(chg, &pval);
		if (!rc) {
			/*
			 * If Vbatt is within 40mV above Vfloat, then don't
			 * treat it as overvoltage.
			 */
			if (pval.intval >=
				get_effective_result(chg->fv_votable) + 40000) {
				val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
				smblib_err(chg, "battery over-voltage\n");
				goto done;
			}
		}
	}

	if (stat & BAT_TEMP_STATUS_TOO_COLD_BIT)
		val->intval = POWER_SUPPLY_HEALTH_COLD;