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

Commit 600f7d03 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen4: Fix ESR fast calibration calculations



ESR_DELTA is having 17 bit encoding instead of 12 bit encoding
which other ESR parameters have. So, account in that while doing
the calculations. Also, apply the delta without filtering for the
first iteration of ESR fast calibration so that ESR calculation
can converge faster.

Change-Id: I5aae1c53a5eb29c219f31c3faf98c1872f753074
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 130f2f3c
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -3251,9 +3251,15 @@ static void esr_calib_work(struct work_struct *work)
	fg_dbg(fg, FG_STATUS, "esr_raw: 0x%x esr_char_raw: 0x%x esr_meas_diff: 0x%x esr_delta: 0x%x\n",
		esr_raw, esr_char_raw, esr_meas_diff, esr_delta);

	fg_esr_meas_diff = esr_delta - esr_meas_diff;
	fg_esr_meas_diff = esr_meas_diff - (esr_delta / 32);

	/* Don't filter for the first attempt so that ESR can converge faster */
	if (!chip->delta_esr_count)
		esr_filtered = fg_esr_meas_diff;
	else
		esr_filtered = fg_esr_meas_diff >> chip->dt.esr_filter_factor;
	esr_delta = esr_delta - esr_filtered;

	esr_delta = esr_delta + (esr_filtered * 32);

	/* Bound the limits */
	if (esr_delta > SHRT_MAX)