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

Commit d0a4e6c7 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb1390: Fix low vote issue with FCC taper stepper"

parents f94410d0 12f57d3a
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -32,6 +32,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"
@@ -576,11 +577,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)) {
			/*
@@ -629,21 +631,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");
		}
+15 −7
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -81,6 +81,7 @@
#define ATEST1_SEL_MASK			GENMASK(6, 0)
#define ISNS_INT_VAL			0x09

#define BATT_PROFILE_VOTER	"BATT_PROFILE_VOTER"
#define CP_VOTER		"CP_VOTER"
#define USER_VOTER		"USER_VOTER"
#define ILIM_VOTER		"ILIM_VOTER"
@@ -544,7 +545,7 @@ static void smb1390_status_change_work(struct work_struct *work)
	struct smb1390 *chip = container_of(work, struct smb1390,
					    status_change_work);
	union power_supply_propval pval = {0, };
	int rc;
	int max_fcc_ma, rc;

	if (!is_psy_voter_available(chip))
		goto out;
@@ -621,7 +622,10 @@ static void smb1390_status_change_work(struct work_struct *work)
		}
	} else {
		vote(chip->disable_votable, SRC_VOTER, true, 0);
		vote(chip->fcc_votable, CP_VOTER, false, 0);
		max_fcc_ma = get_client_vote(chip->fcc_votable,
				BATT_PROFILE_VOTER);
		vote(chip->fcc_votable, CP_VOTER,
				max_fcc_ma > 0 ? true : false, max_fcc_ma);
	}

out:
@@ -639,10 +643,16 @@ static void smb1390_taper_work(struct work_struct *work)
		goto out;

	do {
		fcc_uA = get_effective_result(chip->fcc_votable) - 100000;
		fcc_uA = get_effective_result(chip->fcc_votable);
		if (fcc_uA < 2000000)
			break;

		fcc_uA = get_client_vote(chip->fcc_votable, CP_VOTER) - 100000;
		pr_debug("taper work reducing FCC to %duA\n", fcc_uA);
		vote(chip->fcc_votable, CP_VOTER, true, fcc_uA);

		msleep(500);

		rc = power_supply_get_property(chip->batt_psy,
					POWER_SUPPLY_PROP_CHARGE_TYPE, &pval);
		if (rc < 0) {
@@ -650,9 +660,7 @@ static void smb1390_taper_work(struct work_struct *work)
			goto out;
		}

		msleep(500);
	} while (fcc_uA >= 2000000
		 && pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER);
	} while (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER);

out:
	pr_debug("taper work exit\n");