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

Commit b3fca5ba authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-smbcharger: Fix notifying FG while handling TCC interrupt



Commit 227ab376 ("power: qpnp-smbcharger: only set
CHARGE_DONE if terminated") introduced a change to notify FG to
lower the resume_soc only when the TCC bit is set when the
termination interrupt is handled. This may not work well as the
charge termination interrupt is not a level triggered one but a
pulse. So, just notify FG on the charge termination whenever
TCC interrupt is handled. While at it, remove an unwanted call
of chg_term_handler() from determine_initial_status().

CRs-Fixed: 917437
Change-Id: I921f2a6f5ae1c580f7d66987c12645e3d60365c4
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 566d1d5d
Loading
Loading
Loading
Loading
+13 −26
Original line number Diff line number Diff line
@@ -5971,34 +5971,22 @@ static irqreturn_t chg_hot_handler(int irq, void *_chip)
static irqreturn_t chg_term_handler(int irq, void *_chip)
{
	struct smbchg_chip *chip = _chip;
	int rc;
	u8 reg = 0;
	bool terminated = false;

	rc = smbchg_read(chip, &reg, chip->chgr_base + RT_STS, 1);
	if (rc) {
		dev_err(chip->dev, "Error reading RT_STS rc= %d\n", rc);
	} else {
		terminated = !!(reg & BAT_TCC_REACHED_BIT);
		pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
	}
	pr_smb(PR_INTERRUPT, "tcc triggered\n");
	/*
	 * If charging has not actually terminated, then this means that
	 * either this is a manual call to chg_term_handler during
	 * determine_initial_status(), or the charger has instantly restarted
	 * charging.
	 *
	 * In either case, do not do the usual status updates here. If there
	 * is something that needs to be updated, the recharge handler will
	 * handle it.
	 * Charge termination is a pulse and not level triggered. That means,
	 * TCC bit in RT_STS can get cleared by the time this interrupt is
	 * handled. Instead of relying on that to determine whether the
	 * charge termination had happened, we've to simply notify the FG
	 * about this as long as the interrupt is handled.
	 */
	if (terminated) {
	set_property_on_fg(chip, POWER_SUPPLY_PROP_CHARGE_DONE, 1);

	smbchg_parallel_usb_check_ok(chip);
	if (chip->psy_registered)
		power_supply_changed(&chip->batt_psy);
	smbchg_charging_status_change(chip);
		set_property_on_fg(chip, POWER_SUPPLY_PROP_CHARGE_DONE, 1);
	}

	return IRQ_HANDLED;
}

@@ -6397,7 +6385,6 @@ static int determine_initial_status(struct smbchg_chip *chip)
	batt_warm_handler(0, chip);
	batt_cool_handler(0, chip);
	batt_cold_handler(0, chip);
	chg_term_handler(0, chip);
	if (chip->typec_psy) {
		get_property_from_typec(chip, POWER_SUPPLY_PROP_TYPE, &type);
		update_typec_otg_status(chip, type.intval, true);