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

Commit 227ab376 authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-smbcharger: only set CHARGE_DONE if terminated



The charger sets the POWER_SUPPLY_PROP_CHARGE_DONE on the bms power
supply during the chg_term interrupt handler function regardless of
whether charging actually terminated. In the cases of an instant
recharge trigger or manually calling the interrupt handler, the
CHARGE_DONE property will be falsely set.

Fix this by checking the real time status bit of the termination
interrupt before setting the charge_done property on the bms power
supply.

CRs-Fixed: 899712
Change-Id: I27e5969e462caba644e58095d6885e3b7e3c4523
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent c8df36dc
Loading
Loading
Loading
Loading
+26 −7
Original line number Diff line number Diff line
@@ -5510,15 +5510,34 @@ 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;

	smbchg_read(chip, &reg, chip->chgr_base + RT_STS, 1);
	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);
	}
	/*
	 * 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.
	 */
	if (terminated) {
		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;
}