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

Commit 0b209e37 authored by Kiran Gunda's avatar Kiran Gunda
Browse files

power: qpnp-fg-gen4: Fix the condition for capacity-learning-update



Weighted capacity learning relies on input status to complete the
capacity learning event. The existing logic only relies on
charging_status change to send a cap-learning update, which in a
corner condition may not send an update when input changes status.
Fix this by always sending a capacity learning update irrespective
of the change in input/charge status.

Change-Id: Idfed395e1acad2b3b5c7b19ef137063d186af40f
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent d76cd6ca
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt)	"FG: %s: " fmt, __func__
@@ -4209,13 +4209,11 @@ static void status_change_work(struct work_struct *work)
	cycle_count_update(chip->counter, (u32)batt_soc >> 24,
		fg->charge_status, fg->charge_done, input_present);

	if (fg->charge_status != fg->prev_charge_status) {
	batt_soc_cp = div64_u64((u64)(u32)batt_soc * CENTI_FULL_SOC,
				BATT_SOC_32BIT);
	cap_learning_update(chip->cl, batt_temp, batt_soc_cp,
			fg->charge_status, fg->charge_done, input_present,
			qnovo_en);
	}

	rc = fg_gen4_charge_full_update(fg);
	if (rc < 0)
@@ -4251,7 +4249,6 @@ static void status_change_work(struct work_struct *work)
		pr_err("Failed to validate SOC scale mode, rc=%d\n", rc);

	ttf_update(chip->ttf, input_present);
	fg->prev_charge_status = fg->charge_status;
out:
	fg_dbg(fg, FG_STATUS, "charge_status:%d charge_type:%d charge_done:%d\n",
		fg->charge_status, fg->charge_type, fg->charge_done);
@@ -6209,7 +6206,6 @@ static int fg_gen4_probe(struct platform_device *pdev)
	fg->debug_mask = &fg_gen4_debug_mask;
	fg->irqs = fg_irqs;
	fg->charge_status = -EINVAL;
	fg->prev_charge_status = -EINVAL;
	fg->online_status = -EINVAL;
	fg->batt_id_ohms = -EINVAL;
	chip->ki_coeff_full_soc[0] = -EINVAL;