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

Commit 0934c154 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: qpnp-fg-gen3: Use msoc for recharge-soc comparison



The recharge SOC is based off the monotonic SOC (msoc). Hence, use
the msoc to determine if the hold-soc-while-full logic needs
to be applied.

CRs-Fixed: 2080211
Change-Id: I52b02adc4d97cbed42b0c8034a5a48dba1e343d3
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent c0737029
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1611,7 +1611,7 @@ static int fg_set_recharge_voltage(struct fg_chip *chip, int voltage_mv)
static int fg_charge_full_update(struct fg_chip *chip)
{
	union power_supply_propval prop = {0, };
	int rc, msoc, bsoc, recharge_soc;
	int rc, msoc, bsoc, recharge_soc, msoc_raw;
	u8 full_soc[2] = {0xFF, 0xFF};

	if (!chip->dt.hold_soc_while_full)
@@ -1647,6 +1647,7 @@ static int fg_charge_full_update(struct fg_chip *chip)
		pr_err("Error in getting msoc, rc=%d\n", rc);
		goto out;
	}
	msoc_raw = DIV_ROUND_CLOSEST(msoc * FULL_SOC_RAW, FULL_CAPACITY);

	fg_dbg(chip, FG_STATUS, "msoc: %d bsoc: %x health: %d status: %d full: %d\n",
		msoc, bsoc, chip->health, chip->charge_status,
@@ -1670,7 +1671,7 @@ static int fg_charge_full_update(struct fg_chip *chip)
			fg_dbg(chip, FG_STATUS, "Terminated charging @ SOC%d\n",
				msoc);
		}
	} else if ((bsoc >> 8) <= recharge_soc && chip->charge_full) {
	} else if (msoc_raw < recharge_soc && chip->charge_full) {
		chip->delta_soc = FULL_CAPACITY - msoc;

		/*
@@ -1700,8 +1701,8 @@ static int fg_charge_full_update(struct fg_chip *chip)
				rc);
			goto out;
		}
		fg_dbg(chip, FG_STATUS, "bsoc: %d recharge_soc: %d delta_soc: %d\n",
			bsoc >> 8, recharge_soc, chip->delta_soc);
		fg_dbg(chip, FG_STATUS, "msoc_raw = %d bsoc: %d recharge_soc: %d delta_soc: %d\n",
			msoc_raw, bsoc >> 8, recharge_soc, chip->delta_soc);
	} else {
		goto out;
	}