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

Commit 82985a4a authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

power: vm-bms: use die-temp compensation for VADC readings



VM-BMS uses VADC to read the battery voltage.
Incorporate die-temp compensation into VADC reading
for better accuracy in SOC calculation.

Change-Id: I91e3ca936da162964c8ebafa09c4a85128ccd2ce
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 204ea500
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -816,7 +816,8 @@ static int calib_vadc(struct qpnp_bms_chip *chip)
static int convert_vbatt_raw_to_uv(struct qpnp_bms_chip *chip,
				u16 reading, bool is_pon_ocv)
{
	int64_t uv;
	int64_t uv, vbatt;
	int rc;

	uv = vadc_reading_to_uv(reading, true);
	pr_debug("%u raw converted into %lld uv\n", reading, uv);
@@ -824,10 +825,15 @@ static int convert_vbatt_raw_to_uv(struct qpnp_bms_chip *chip,
	uv = adjust_vbatt_reading(chip, uv);
	pr_debug("adjusted into %lld uv\n", uv);

	/*
	 * TODO: add die-temp compensation once the ADC temp.
	 * coeffs are available
	 */
	vbatt = uv;
	rc = qpnp_vbat_sns_comp_result(chip->vadc_dev, &uv, is_pon_ocv);
	if (rc) {
		pr_debug("Vbatt compensation failed rc = %d\n", rc);
		uv = vbatt;
	} else {
		pr_debug("temp-compensated %lld into %lld uv\n", vbatt, uv);
	}

	return uv;
}