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

Commit 1b7e5a86 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen4: Enable parallel charging current measurement



Fuel gauge (FG) needs to measure the battery charging current
flowing through both main charger and parallel charger to
calculate the state of charge (SOC) accurately. Enable parallel
charging current measurement to do that.

Change-Id: I6111560f7cc6d831b6292b7322c94e85e73ff8bd
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent be0ba9e9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -268,6 +268,9 @@
#define BATT_INFO_IADC_MSB(chip)		(chip->batt_info_base + 0xAF)
#define IADC_MSB_MASK				GENMASK(6, 0)

#define BATT_INFO_FG_CNV_CHAR_CFG(chip)		(chip->batt_info_base + 0xB7)
#define SMB_MEASURE_EN_BIT			BIT(2)

#define BATT_INFO_TM_MISC(chip)			(chip->batt_info_base + 0xE5)
#define FORCE_SEQ_RESP_TOGGLE_BIT		BIT(6)
#define ALG_DIRECT_VALID_DATA_BIT		BIT(5)
+9 −0
Original line number Diff line number Diff line
@@ -3367,6 +3367,15 @@ static int fg_gen4_hw_init(struct fg_gen4_chip *chip)
	int rc;
	u8 buf[4], val, mask;

	/* Enable measurement of parallel charging current */
	val = mask = SMB_MEASURE_EN_BIT;
	rc = fg_masked_write(fg, BATT_INFO_FG_CNV_CHAR_CFG(fg), mask, val);
	if (rc < 0) {
		pr_err("Error in writing to 0x%04x, rc=%d\n",
			BATT_INFO_FG_CNV_CHAR_CFG(fg), rc);
		return rc;
	}

	fg_encode(fg->sp, FG_SRAM_CUTOFF_VOLT, chip->dt.cutoff_volt_mv, buf);
	rc = fg_sram_write(fg, fg->sp[FG_SRAM_CUTOFF_VOLT].addr_word,
			fg->sp[FG_SRAM_CUTOFF_VOLT].addr_byte, buf,