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

Commit fbe677e9 authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

power: battery: add support for override votes in FCC stepper



FCC stepper logic runtime calculates the step count based on the
current vote on Main and Parallel's FCC. However, in the case of
a override vote, the value of the overridden voter does not change
across steps and the step-FCC calculations are affected.

Hence update the FCC stepper logic to handle this condition by
tracking the override vote value.

Change-Id: Ie228f5a42ac6b788ac74446726a4f557079e246e
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 0107813a
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ struct pl_data {
	int			parallel_step_fcc_count;
	int			parallel_step_fcc_residual;
	int			step_fcc;
	int			override_main_fcc_ua;
	int			total_fcc_ua;
	u32			wa_flags;
	struct class		qcom_batt_class;
	struct wakeup_source	*pl_ws;
@@ -601,11 +603,34 @@ static void get_main_fcc_config(struct pl_data *chip, int *total_fcc)
static void get_fcc_stepper_params(struct pl_data *chip, int main_fcc_ua,
			int parallel_fcc_ua)
{
	int main_set_fcc_ua, total_fcc_ua;

	if (!chip->fcc_step_size_ua) {
		pr_err("Invalid fcc stepper step size, value 0\n");
		return;
	}

	if (is_override_vote_enabled_locked(chip->fcc_main_votable)) {
		/*
		 * FCC stepper params need re-calculation in override mode
		 * only if there is change in Main or total FCC
		 */

		main_set_fcc_ua = get_effective_result_locked(
							chip->fcc_main_votable);
		total_fcc_ua = main_fcc_ua + parallel_fcc_ua;

		if ((main_set_fcc_ua != chip->override_main_fcc_ua)
				|| (total_fcc_ua != chip->total_fcc_ua)) {
			chip->override_main_fcc_ua = main_set_fcc_ua;
			chip->total_fcc_ua = total_fcc_ua;
			parallel_fcc_ua += (main_fcc_ua
						- chip->override_main_fcc_ua);
		} else {
			goto skip_fcc_step_update;
		}
	}

	/* Read current FCC of main charger */
	chip->main_fcc_ua = get_effective_result(chip->fcc_main_votable);
	chip->main_step_fcc_dir = (main_fcc_ua > chip->main_fcc_ua) ?
@@ -622,6 +647,7 @@ static void get_fcc_stepper_params(struct pl_data *chip, int main_fcc_ua,
	chip->parallel_step_fcc_residual = abs((parallel_fcc_ua -
				chip->slave_fcc_ua) % chip->fcc_step_size_ua);

skip_fcc_step_update:
	if (chip->parallel_step_fcc_count || chip->parallel_step_fcc_residual
		|| chip->main_step_fcc_count || chip->main_step_fcc_residual)
		chip->step_fcc = 1;
+2 −0
Original line number Diff line number Diff line
@@ -1326,6 +1326,8 @@ static int smb5_usb_main_set_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_FORCE_MAIN_FCC:
		vote_override(chg->fcc_main_votable, CC_MODE_VOTER,
				(val->intval < 0) ? false : true, val->intval);
		/* Main FCC updated re-calculate FCC */
		rerun_election(chg->fcc_votable);
		break;
	case POWER_SUPPLY_PROP_FORCE_MAIN_ICL:
		vote_override(chg->usb_icl_votable, CC_MODE_VOTER,