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

Commit 9097bde8 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-smbcharger: fix the FCC misconfiguration in parallel charging



Currently, when running the ESR SW workaround during parallel
charging, we configure the fast charge current (FCC) wrongly
to 100% whereas it should be configured to 50%. Fix it.

While at it, add a debug print when the parallel charger fast
charging current is reduced.

CRs-Fixed: 786898
Change-Id: Ief4d86c2e3b099581c2fbe374b847d0e7537813f
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent cd2c69a8
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ struct smbchg_chip {
	int				usb_tl_current_ma;
	int				dc_target_current_ma;
	int				target_fastchg_current_ma;
	int				cfg_fastchg_current_ma;
	int				fastchg_current_ma;
	int				vfloat_mv;
	int				fastchg_current_comp;
@@ -1559,8 +1560,7 @@ static int smbchg_sw_esr_pulse_en(struct smbchg_chip *chip, bool en)
	int rc;

	chip->sw_esr_pulse_en = en;
	rc = smbchg_set_fastchg_current_raw(chip,
			chip->target_fastchg_current_ma);
	rc = smbchg_set_fastchg_current(chip, chip->target_fastchg_current_ma);
	if (rc)
		return rc;
	rc = smbchg_parallel_usb_charging_en(chip, !en);
@@ -1609,6 +1609,7 @@ static void smbchg_parallel_usb_disable(struct smbchg_chip *chip)
	power_supply_set_current_limit(parallel_psy,
				SUSPEND_CURRENT_MA * 1000);
	power_supply_set_present(parallel_psy, false);
	chip->target_fastchg_current_ma = chip->cfg_fastchg_current_ma;
	smbchg_set_fastchg_current(chip, chip->target_fastchg_current_ma);
	chip->usb_tl_current_ma =
		calc_thermal_limited_current(chip, chip->usb_target_current_ma);
@@ -1648,8 +1649,12 @@ try_again:
		smbchg_parallel_usb_disable(chip);
		goto done;
	}
	pval.intval = 1000 * ((parallel_fcc_ma
	pval.intval = ((parallel_fcc_ma
			* PARALLEL_FCC_PERCENT_REDUCTION) / 100);
	pr_smb(PR_STATUS, "reducing FCC of parallel charger to %d\n",
		pval.intval);
	/* Change it to uA */
	pval.intval *= 1000;
	parallel_psy->set_property(parallel_psy,
			POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, &pval);
	/*
@@ -1788,8 +1793,9 @@ static void smbchg_parallel_usb_enable(struct smbchg_chip *chip)
		goto disable_parallel;
	}
	power_supply_set_present(parallel_psy, true);
	smbchg_set_fastchg_current(chip, chip->target_fastchg_current_ma / 2);
	pval.intval = chip->target_fastchg_current_ma * 1000 / 2;
	chip->target_fastchg_current_ma = chip->cfg_fastchg_current_ma / 2;
	smbchg_set_fastchg_current(chip, chip->target_fastchg_current_ma);
	pval.intval = chip->target_fastchg_current_ma * 1000;
	parallel_psy->set_property(parallel_psy,
			POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, &pval);
	smbchg_set_usb_current_max(chip, chip->parallel.current_max_ma);
@@ -4749,6 +4755,7 @@ static int smb_parse_dt(struct smbchg_chip *chip)
			"parallel-usb-9v-min-current-ma", rc, 1);
	OF_PROP_READ(chip, chip->parallel.allowed_lowering_ma,
			"parallel-allowed-lowering-ma", rc, 1);
	chip->cfg_fastchg_current_ma = chip->target_fastchg_current_ma;
	if (chip->parallel.min_current_thr_ma != -EINVAL
			&& chip->parallel.min_9v_current_thr_ma != -EINVAL)
		chip->parallel.avail = true;