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

Commit 3b313491 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Guru Das Srinagesh
Browse files

power: battery: Fix low vote issue with FCC taper stepper



While in taper mode, the effective result of FCC is obtained and a
reduction of 200mA is made until the taper condition goes away. if
another voter cuts in and votes lower, which results in lower FCC, a
200mA will be deducted from the new low FCC. Note the result cannot
be reversed even after the vote is cancelled or updated.

Occasionally, it may have undesired consequences. A very low vote
voting in and out in the middle can leave a low FCC for the rest
of charging cycle.

Solve the problem by adopting a dedicated FCC voter in taper mode and
doing the reduction with reference to its last vote.

CRs-Fixed: 2357939
Change-Id: I8b0c1e353659c6368ea665471b0345aa24a92eb8
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent 1302c053
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#define DRV_MAJOR_VERSION	1
#define DRV_MINOR_VERSION	0

#define BATT_PROFILE_VOTER		"BATT_PROFILE_VOTER"
#define CHG_STATE_VOTER			"CHG_STATE_VOTER"
#define TAPER_STEPPER_VOTER		"TAPER_STEPPER_VOTER"
#define TAPER_END_VOTER			"TAPER_END_VOTER"
@@ -571,11 +572,12 @@ static void pl_taper_work(struct work_struct *work)
						pl_taper_work);
	union power_supply_propval pval = {0, };
	int rc;
	int eff_fcc_ua;
	int total_fcc_ua, master_fcc_ua, slave_fcc_ua = 0;
	int fcc_ua, total_fcc_ua, master_fcc_ua, slave_fcc_ua = 0;

	chip->taper_entry_fv = get_effective_result(chip->fv_votable);
	chip->taper_work_running = true;
	fcc_ua = get_client_vote(chip->fcc_votable, BATT_PROFILE_VOTER);
	vote(chip->fcc_votable, TAPER_STEPPER_VOTER, true, fcc_ua);
	while (true) {
		if (get_effective_result(chip->pl_disable_votable)) {
			/*
@@ -624,21 +626,22 @@ static void pl_taper_work(struct work_struct *work)

		chip->charge_type = pval.intval;
		if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER) {
			eff_fcc_ua = get_effective_result(chip->fcc_votable);
			if (eff_fcc_ua < 0) {
			fcc_ua = get_client_vote(chip->fcc_votable,
					TAPER_STEPPER_VOTER);
			if (fcc_ua < 0) {
				pr_err("Couldn't get fcc, exiting taper work\n");
				goto done;
			}
			eff_fcc_ua = eff_fcc_ua - TAPER_REDUCTION_UA;
			if (eff_fcc_ua < 0) {
			fcc_ua -= TAPER_REDUCTION_UA;
			if (fcc_ua < 0) {
				pr_err("Can't reduce FCC any more\n");
				goto done;
			}

			pl_dbg(chip, PR_PARALLEL, "master is taper charging; reducing FCC to %dua\n",
					eff_fcc_ua);
					fcc_ua);
			vote(chip->fcc_votable, TAPER_STEPPER_VOTER,
					true, eff_fcc_ua);
					true, fcc_ua);
		} else {
			pl_dbg(chip, PR_PARALLEL, "master is fast charging; waiting for next taper\n");
		}