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

Commit 9b223cfa authored by Sahil Chandna's avatar Sahil Chandna
Browse files

power: smb1390-psy: battery: Fix FCC threshold to disable slave CP



Currently, the FCC threshold to disable the slave CP is configured
based on CC mode status, this makes threshold different for CC and
CV mode. Fix this, by configuring the threshold irrespective of CC
mode status.

Change-Id: I3c7c2fee306a02d7ea076b7e836fa330b9295a21
Signed-off-by: default avatarSahil Chandna <chandna@codeaurora.org>
parent c4f993f9
Loading
Loading
Loading
Loading
+11 −27
Original line number Diff line number Diff line
@@ -905,9 +905,8 @@ static int pl_fcc_vote_callback(struct votable *votable, void *data,
{
	struct pl_data *chip = data;
	int master_fcc_ua = total_fcc_ua, slave_fcc_ua = 0;
	int cp_fcc_ua = 0, fcc_thr_ua = 0, rc;
	int cp_fcc_ua = 0, rc = 0;
	union power_supply_propval pval = {0, };
	bool is_cc_mode = false;

	if (total_fcc_ua < 0)
		return 0;
@@ -929,29 +928,6 @@ static int pl_fcc_vote_callback(struct votable *votable, void *data,
		chip->cp_slave_disable_votable =
			find_votable("CP_SLAVE_DISABLE");

	if (!chip->usb_psy)
		chip->usb_psy = power_supply_get_by_name("usb");

	if (chip->usb_psy) {
		rc = power_supply_get_property(chip->usb_psy,
					POWER_SUPPLY_PROP_ADAPTER_CC_MODE,
					&pval);
		if (rc < 0)
			pr_err("Couldn't get PPS CC mode status rc=%d\n", rc);
		else
			is_cc_mode = pval.intval;
	}

	if (chip->cp_master_psy) {
		rc = power_supply_get_property(chip->cp_master_psy,
					POWER_SUPPLY_PROP_MIN_ICL, &pval);
		if (rc < 0)
			pr_err("Couldn't get MIN ICL threshold rc=%d\n", rc);
		else
			fcc_thr_ua = is_cc_mode ? (3 * pval.intval) :
							(4 * pval.intval);
	}

	/*
	 * CP charger current = Total FCC - Main charger's FCC.
	 * Main charger FCC is userspace's override vote on main.
@@ -961,13 +937,21 @@ static int pl_fcc_vote_callback(struct votable *votable, void *data,
		"cp_fcc_ua=%d total_fcc_ua=%d forced_main_fcc=%d\n",
		cp_fcc_ua, total_fcc_ua, chip->chg_param->forced_main_fcc);
	if (cp_fcc_ua > 0) {
		if (chip->cp_master_psy) {
			rc = power_supply_get_property(chip->cp_master_psy,
					POWER_SUPPLY_PROP_MIN_ICL, &pval);
			if (rc < 0)
				pr_err("Couldn't get MIN ICL threshold rc=%d\n",
									rc);
		}

		if (chip->cp_slave_psy && chip->cp_slave_disable_votable) {
			/*
			 * Disable Slave CP if FCC share
			 * falls below threshold.
			 * falls below 3 * min ICL threshold.
			 */
			vote(chip->cp_slave_disable_votable, FCC_VOTER,
				(cp_fcc_ua < fcc_thr_ua), 0);
				(cp_fcc_ua < (3 * pval.intval)), 0);
		}

		if (chip->cp_disable_votable) {
+1 −2
Original line number Diff line number Diff line
@@ -1553,8 +1553,7 @@ static int smb1390_parse_dt(struct smb1390 *chip)
	of_property_read_u32(chip->dev->of_node, "qcom,parallel-input-mode",
			&chip->pl_input_mode);

	chip->cp_slave_thr_taper_ua = smb1390_is_adapter_cc_mode(chip) ?
			(3 * chip->min_ilim_ua) : (4 * chip->min_ilim_ua);
	chip->cp_slave_thr_taper_ua = 3 * chip->min_ilim_ua;
	of_property_read_u32(chip->dev->of_node, "qcom,cp-slave-thr-taper-ua",
			      &chip->cp_slave_thr_taper_ua);