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

Commit 4cab28ab authored by Xiaozhe Shi's avatar Xiaozhe Shi Committed by Gerrit - the friendly Code Review server
Browse files

power: qpnp-fg: check for battery empty status before reloading profile



When checking whether the fuel gauge needs to be restarted, also check
if the battery is considered empty. The fuel gauge can get stuck in a
state where it constantly shows empty even with a good voltage. Restart
the fuel gauge when that happens.

Also, add a sram dump before reloading the profile, in order to help
debug battery empty before bootup issues.

CRs-Fixed: 800411
Change-Id: Ib7e56822bb82c5b2d75c46bef382eea0442d1d62
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent c39a75b0
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1063,9 +1063,6 @@ static bool fg_is_batt_empty(struct fg_chip *chip)
		return false;
	}

	if (fg_debug_mask & FG_IRQS)
		pr_info("fg soc sts 0x%x\n", fg_soc_sts);

	return (fg_soc_sts & SOC_EMPTY) != 0;
}

@@ -2673,6 +2670,7 @@ wait:
	if (reg & PROFILE_INTEGRITY_BIT)
		fg_cap_learning_load_data(chip);
	if ((reg & PROFILE_INTEGRITY_BIT) && vbat_in_range
			&& !fg_is_batt_empty(chip)
			&& memcmp(chip->batt_profile, data, len - 4) == 0) {
		if (fg_debug_mask & FG_STATUS)
			pr_info("Battery profiles same, using default\n");
@@ -2680,10 +2678,13 @@ wait:
			schedule_work(&chip->dump_sram);
		goto done;
	}
	dump_sram(&chip->dump_sram);
	if ((fg_debug_mask & FG_STATUS) && !vbat_in_range)
		pr_info("Vbat out of range: v_current_pred: %d, v:%d\n",
				fg_data[FG_DATA_CPRED_VOLTAGE].value,
				fg_data[FG_DATA_VOLTAGE].value);
	if ((fg_debug_mask & FG_STATUS) && fg_is_batt_empty(chip))
		pr_info("battery empty\n");
	if (fg_debug_mask & FG_STATUS) {
		pr_info("Using new profile\n");
		print_hex_dump(KERN_INFO, "FG: loaded profile: ",