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

Commit 827905a7 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen4: Allow retry ESR fast calibration more than once



Currently, when the ESR fast calibration is enabled and ESR delta
interrupt doesn't fire within a stipulated period, a retry is
attempted to allow ESR fast calibration to run for a single ESR
delta interrupt. Instead, allow it again till the timer expires.
This can help with improving SOC accuracy.

While at it, reset delta_esr_count to 0 when user re-enable ESR
fast calibration.

Change-Id: I2a749c3e08bd45fc27d3edf9224adccb58610448
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 1cef27dd
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2904,9 +2904,8 @@ static void esr_calib_work(struct work_struct *work)
	 * to disable the interrupt OR ESR fast calibration timer is expired
	 * OR after one retry, disable ESR fast calibration.
	 */
	if ((chip->delta_esr_count >= chip->dt.delta_esr_disable_count) ||
		chip->esr_fast_cal_timer_expired ||
		(chip->esr_fast_calib_retry && chip->delta_esr_count > 0)) {
	if (chip->delta_esr_count >= chip->dt.delta_esr_disable_count ||
		chip->esr_fast_cal_timer_expired) {
		rc = fg_gen4_esr_fast_calib_config(chip, false);
		if (rc < 0)
			pr_err("Error in configuring esr_fast_calib, rc=%d\n",
@@ -3236,6 +3235,9 @@ static int fg_esr_fast_cal_sysfs(const char *val, const struct kernel_param *kp)
	if (!chip)
		return -ENODEV;

	if (fg_esr_fast_cal_en)
		chip->delta_esr_count = 0;

	rc = fg_gen4_esr_fast_calib_config(chip, fg_esr_fast_cal_en);
	if (rc < 0)
		return rc;