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

Commit f6b73a87 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-bms: allow additional corrections in low voltage"

parents 82775c2e d6875936
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -1817,8 +1817,15 @@ static int report_cc_based_soc(struct qpnp_bms_chip *chip)
					chip->catch_up_time_sec,
					soc, chip->last_soc);

		/* if the battery is close to cutoff allow more change */
		if (wake_lock_active(&chip->low_voltage_wake_lock))
			soc_change = min((int)abs(chip->last_soc - soc),
				time_since_last_change_sec);
		else
			soc_change = min((int)abs(chip->last_soc - soc),
			time_since_last_change_sec / SOC_CHANGE_PER_SEC);
				time_since_last_change_sec
					/ SOC_CHANGE_PER_SEC);

		if (chip->last_soc_unbound) {
			chip->last_soc_unbound = false;
		} else {
@@ -2049,9 +2056,10 @@ static int adjust_soc(struct qpnp_bms_chip *chip, struct soc_params *params,
	 * because we might pull it low
	 * and cause a bad user experience
	 */
	if (soc_est == soc
	if (!wake_lock_active(&chip->low_voltage_wake_lock) &&
			(soc_est == soc
			|| soc_est > chip->adjust_soc_low_threshold
		|| soc >= NO_ADJUST_HIGH_SOC_THRESHOLD)
			|| soc >= NO_ADJUST_HIGH_SOC_THRESHOLD))
		goto out;

	if (chip->last_soc_est == -EINVAL)
@@ -2096,8 +2104,11 @@ static int adjust_soc(struct qpnp_bms_chip *chip, struct soc_params *params,
		pr_debug("new delta ocv = %d\n", delta_ocv_uv);
	}

	if (wake_lock_active(&chip->low_voltage_wake_lock))
	if (wake_lock_active(&chip->low_voltage_wake_lock)) {
		/* when in the cutoff region, do not correct upwards */
		delta_ocv_uv = max(0, delta_ocv_uv);
		goto skip_limits;
	}

	if (chip->last_ocv_uv > chip->flat_ocv_threshold_uv)
		correction_limit_uv = chip->high_ocv_correction_limit_uv;