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

Commit b407c5fd authored by Xiaozhe Shi's avatar Xiaozhe Shi Committed by Abhijeet Dharmapurikar
Browse files

power: qpnp-smbcharger: fix parallel charging with HVDCP



Booting with an HVDCP will make the very first attempt at doing parallel
charging always fail due to the HVDCP 3.0 APSD rerun algorithm. This is
due to the parallel charging last_disabled timer in the driver
preventing reenabling of parallel charging 30 seconds after it has been
disabled. Historically this had been a problem with bad AICL values
after immediately rerunning AICL when parallel charging was disabled.

However, with the rearchitected parallel charging algorithm, this is no
longer a big issue. Lower the last_disabled time threshold from 30
seconds to 1 second in order to catch more cases where parallel charging
can be enabled.

Additionally, reset the enabled once flag for parallel charging after
HVDCP pulsing is done and normal charging is reenabled, so that parallel
charging can be immediately reenabled afterwards.

Change-Id: I002e7dbbba0cbefd4fe399759a9a504ba803f539
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 5c9cec22
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -1661,7 +1661,7 @@ static int smbchg_set_fastchg_current_raw(struct smbchg_chip *chip,
#define USBIN_SUSPEND_STS_BIT		BIT(3)
#define USBIN_ACTIVE_PWR_SRC_BIT	BIT(1)
#define DCIN_ACTIVE_PWR_SRC_BIT		BIT(0)
#define PARALLEL_REENABLE_TIMER_MS	30000
#define PARALLEL_REENABLE_TIMER_MS	1000
#define PARALLEL_CHG_THRESHOLD_CURRENT	1800

static int smbchg_parallel_usb_charging_en(struct smbchg_chip *chip, bool en)
@@ -4814,6 +4814,13 @@ static int smbchg_unprepare_for_pulsing(struct smbchg_chip *chip)
		goto out;
	}

	/*
	 * reset the enabled once flag for parallel charging so
	 * parallel charging can immediately restart after the HVDCP pulsing
	 * is complete
	 */
	chip->parallel.enabled_once = false;

	/* fake an insertion */
	pr_smb(PR_MISC, "Faking Insertion\n");
	rc = fake_insertion_removal(chip, true);
@@ -5063,6 +5070,12 @@ static int smbchg_hvdcp3_confirmed(struct smbchg_chip *chip)
{
	int rc = 0;

	/*
	 * reset the enabled once flag for parallel charging because this is
	 * effectively a new insertion.
	 */
	chip->parallel.enabled_once = false;

	pr_smb(PR_MISC, "Retracting HVDCP vote for ICL\n");
	rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, false, 0);
	if (rc < 0)