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

Commit c4205fe6 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Nicholas Troast
Browse files

power: qpnp-fg-gen3: add support for skew in capacity learning algorithm



In some cases, a skew needs to be applied on the learnt capacity
to counter the error. Add support for it.

Change-Id: I7f80088e7db4e3414d86983722c92e4fc14323e0
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 183bc63f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1315,11 +1315,20 @@ static bool is_temp_valid_cap_learning(struct fg_chip *chip)
	return true;
}

#define QNOVO_CL_SKEW_DECIPCT	-30
static void fg_cap_learning_post_process(struct fg_chip *chip)
{
	int64_t max_inc_val, min_dec_val, old_cap;
	int rc;

	if (is_qnovo_en(chip)) {
		fg_dbg(chip, FG_CAP_LEARN, "applying skew %d on current learnt capacity %lld\n",
			QNOVO_CL_SKEW_DECIPCT, chip->cl.final_cc_uah);
		chip->cl.final_cc_uah = chip->cl.final_cc_uah *
						(1000 + QNOVO_CL_SKEW_DECIPCT);
		do_div(chip->cl.final_cc_uah, 1000);
	}

	max_inc_val = chip->cl.learned_cc_uah
			* (1000 + chip->dt.cl_max_cap_inc);
	do_div(max_inc_val, 1000);