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

Commit 09efd825 authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-fg: force BCL HPM during charge



The BCL device has 3 different power modes: Low Power Mode (LPM), Medium
Power Mode (MPM), and High Power Mode (HPM), in which it can switch
between. These different power modes corresponds to how frequent the BCL
does vbat and ibat conversions. The trigger to switch between these
modes is the battery current.

However, during charging or when an input is present, the battery
currrent can be very low. The BCL can go into MPM or LPM, which can
compromise the resolution of the BCL monitoring.

Force HPM when the device is charging in order to resolve this issue.

CRs-Fixed: 793296
Change-Id: I0b01f1749011bac3ba771a22efde9b6ba59e7ba9
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 353f4f96
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -3751,6 +3751,9 @@ static int bcl_trim_workaround(struct fg_chip *chip)
#define KI_COEFF_PRED_FULL_4_0_MSB	0x88
#define KI_COEFF_PRED_FULL_4_0_LSB	0x00
#define TEMP_FRAC_SHIFT_REG		0x4A4
#define FG_ADC_CONFIG_REG		0x4B8
#define FG_BCL_CONFIG_OFFSET		0x3
#define BCL_FORCED_HPM_IN_CHARGE	BIT(2)
static int fg_hw_init(struct fg_chip *chip)
{
	u8 resume_soc;
@@ -3831,6 +3834,15 @@ static int fg_hw_init(struct fg_chip *chip)
		return rc;
	}

	rc = fg_mem_masked_write(chip, FG_ADC_CONFIG_REG,
			BCL_FORCED_HPM_IN_CHARGE,
			BCL_FORCED_HPM_IN_CHARGE,
			FG_BCL_CONFIG_OFFSET);
	if (rc) {
		pr_err("failed to force hpm in charge rc=%d\n", rc);
		return rc;
	}

	if (chip->use_thermal_coefficients) {
		fg_mem_write(chip, chip->thermal_coefficients,
			THERMAL_COEFF_ADDR, THERMAL_COEFF_N_BYTES,