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

Commit 5f556655 authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Harry Yang
Browse files

power: qpnp-fg-gen3: Get the raw MSOC directly from FG register



Use the MSOC raw value directly from the register instead of
extrapolating it from MSOC value to avoid any rounding-off
errors.

CRs-Fixed: 2080211
Change-Id: I91d98c6aa8a63344ff79b5414c45d0f5a5b52b81
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 856db920
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -1748,12 +1748,12 @@ static int fg_charge_full_update(struct fg_chip *chip)


	/* We need 2 most significant bytes here */
	/* We need 2 most significant bytes here */
	bsoc = (u32)bsoc >> 16;
	bsoc = (u32)bsoc >> 16;
	rc = fg_get_msoc(chip, &msoc);
	rc = fg_get_msoc_raw(chip, &msoc_raw);
	if (rc < 0) {
	if (rc < 0) {
		pr_err("Error in getting msoc, rc=%d\n", rc);
		pr_err("Error in getting msoc_raw, rc=%d\n", rc);
		goto out;
		goto out;
	}
	}
	msoc_raw = DIV_ROUND_CLOSEST(msoc * FULL_SOC_RAW, FULL_CAPACITY);
	msoc = DIV_ROUND_CLOSEST(msoc_raw * FULL_CAPACITY, FULL_SOC_RAW);


	fg_dbg(chip, FG_STATUS, "msoc: %d bsoc: %x health: %d status: %d full: %d\n",
	fg_dbg(chip, FG_STATUS, "msoc: %d bsoc: %x health: %d status: %d full: %d\n",
		msoc, bsoc, chip->health, chip->charge_status,
		msoc, bsoc, chip->health, chip->charge_status,