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

Commit 55246969 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen4: retry ESR fast calibration based on delta ESR count



Currently, ESR fast calibration is attempted whenever the delta
ESR interrupt has not fired even once when the fast calibration
is enabled. In certain cases, delta ESR interrupt won't fire for
over a period of time. Since ESR measurement is essential for
accurate state of charge (SOC) calculations, retry ESR fast
calibration until 3 delta ESR interrupts fire.

Change-Id: I1ecf964f0473e68355bada4a547333c229f26ed4
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 6aa5b0e0
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -2767,13 +2767,14 @@ static irqreturn_t fg_delta_msoc_irq_handler(int irq, void *data)
		pr_err("Error in adjusting ki_coeff_dischg, rc=%d\n", rc);

	/*
	 * If ESR fast calibration is done without a delta ESR interrupt, then
	 * it is possibly a failed attempt. In such cases, retry ESR fast
	 * calibration once again. This will get restored to normal config once
	 * a delta ESR interrupt fires or the timer expires.
	 * If ESR fast calibration is done even before 3 delta ESR interrupts
	 * had fired, then it is possibly a failed attempt. In such cases,
	 * retry ESR fast calibration once again. This will get restored to
	 * normal config once the timer expires or delta ESR interrupt count
	 * reaches the threshold.
	 */
	if (chip->esr_fast_calib && chip->esr_fast_calib_done &&
		!chip->delta_esr_count && !chip->esr_fast_calib_retry) {
		(chip->delta_esr_count < 3) && !chip->esr_fast_calib_retry) {
		rc = fg_gen4_esr_fast_calib_config(chip, true);
		if (rc < 0)
			pr_err("Error in configuring esr_fast_calib, rc=%d\n",