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

Commit 807de827 authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-fg: set patch negative current bit



There’s a bit in the fuel gauge that need to be enabled so that the FG
only reads negative currents when the charger is charging the battery.

This is needed to make sure that in low current situation the fuel gauge
monotonic SoC does not get stuck due to incorrect offsets reading negative
currents.

CRs-Fixed: 768033
Change-Id: I612408ab0b301f07197434aa4c95d470aa345c88
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 5b122b0a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2633,6 +2633,7 @@ static int soc_to_setpoint(int soc)
#define THERMAL_COEFF_ADDR	0x444
#define THERMAL_COEFF_OFFSET	0x2
#define I_TERM_QUAL_BIT		BIT(1)
#define PATCH_NEG_CURRENT_BIT	BIT(3)
static int fg_hw_init(struct fg_chip *chip)
{
	u8 resume_soc;
@@ -2647,6 +2648,15 @@ static int fg_hw_init(struct fg_chip *chip)
		return rc;
	}

	rc = fg_mem_masked_write(chip, EXTERNAL_SENSE_SELECT,
			PATCH_NEG_CURRENT_BIT,
			PATCH_NEG_CURRENT_BIT,
			EXTERNAL_SENSE_OFFSET);
	if (rc) {
		pr_err("failed to write patch current bit rc=%d\n", rc);
		return rc;
	}

	resume_soc = settings[FG_MEM_RESUME_SOC].value;
	if (resume_soc > 0) {
		resume_soc = resume_soc * 255 / 100;