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

Commit 69208a86 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Anirudh Ghayal
Browse files

power: fg-alg: Add function to qualify capacity learning start



Before capacity learning begins, check with FG/QG driver for
qualifying the condition.

Change-Id: Ifbfe2faf1e75578801a9273966c81e44428b8cbc
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 17186baa
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -476,6 +476,11 @@ static int cap_learning_begin(struct cap_learning *cl, u32 batt_soc)
{
	int rc, cc_soc_sw, batt_soc_msb, batt_soc_pct;

	if (cl->ok_to_begin && !cl->ok_to_begin(cl->data)) {
		pr_debug("Not OK to begin\n");
		return -EINVAL;
	}

	batt_soc_msb = batt_soc >> 24;
	batt_soc_pct = DIV_ROUND_CLOSEST(batt_soc_msb * 100, FULL_SOC_RAW);

+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ struct cap_learning {
	bool			active;
	struct mutex		lock;
	struct cl_params	dt;
	bool (*ok_to_begin)(void *data);
	int (*get_learned_capacity)(void *data, int64_t *learned_cap_uah);
	int (*store_learned_capacity)(void *data, int64_t learned_cap_uah);
	int (*get_cc_soc)(void *data, int *cc_soc_sw);