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

Commit 072b0054 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: use consistent IAVG for raw SOC calculation"

parents cdc76b19 48e145a9
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -904,6 +904,7 @@ static int estimate_ocv(struct qpnp_bms_chip *chip)
	return ocv_est_uv;
}

#define MIN_IAVG_MA 250
static void reset_for_new_battery(struct qpnp_bms_chip *chip, int batt_temp)
{
	chip->last_ocv_uv = chip->insertion_ocv_uv;
@@ -914,7 +915,7 @@ static void reset_for_new_battery(struct qpnp_bms_chip *chip, int batt_temp)
	chip->soc_at_cv = -EINVAL;
	chip->shutdown_soc_invalid = true;
	chip->shutdown_soc = 0;
	chip->shutdown_iavg_ma = 0;
	chip->shutdown_iavg_ma = MIN_IAVG_MA;
	chip->prev_pc_unusable = -EINVAL;
	reset_cc(chip, CLEAR_CC | CLEAR_SHDW_CC);
	chip->software_cc_uah = 0;
@@ -1295,7 +1296,7 @@ static int adjust_uuc(struct qpnp_bms_chip *chip,
	max_percent_change = max(params->delta_time_s
				/ TIME_PER_PERCENT_UUC, 1);

	if (chip->prev_pc_unusable == -EINVAL
	if (chip->first_time_calc_uuc || chip->prev_pc_unusable == -EINVAL
		|| abs(chip->prev_pc_unusable - new_pc_unusable)
			<= max_percent_change) {
		chip->prev_pc_unusable = new_pc_unusable;
@@ -1328,7 +1329,6 @@ static int adjust_uuc(struct qpnp_bms_chip *chip,
	return new_uuc_uah;
}

#define MIN_IAVG_MA 250
static int calculate_unusable_charge_uah(struct qpnp_bms_chip *chip,
					struct soc_params *params,
					int batt_temp)
@@ -3496,6 +3496,7 @@ static void load_shutdown_data(struct qpnp_bms_chip *chip)
	 * Do a quick run of SoC calculation to find whether the shutdown soc
	 * is close enough.
	 */
	chip->shutdown_iavg_ma = MIN_IAVG_MA;
	calculated_soc = recalculate_raw_soc(chip);
	shutdown_soc_out_of_limit = (abs(shutdown_soc - calculated_soc)
			> chip->shutdown_soc_valid_limit);