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

Commit 6af9020a authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-smbcharger: correctly detect 9V chargers



Currently the charger driver is incorrectly using the INPUT_STS register
to detect 9V charging for parallel charging. This register will show
5V-9V charger for both normal and HVDCP chargers, causing parallel
charging to also not start for HVDCP chargers when input current limit
is under 1.4A.

Fix this by using the USBIN_HVDCP_STS register instead. This will
correctly detect 9V HVDCP operation and allow parallel charging to start
at 700mA when using a 9V charger.

CRs-Fixed: 733213
Change-Id: I21fdfd3b400b5000fa91f794157024b0bea49e57
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent c6297e1e
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -1076,28 +1076,23 @@ out:
	return rc;
}

#define USBIN_INPUT_STS_MASK		SMB_MASK(5, 3)
#define USBIN_INPUT_STS_OFFSET		3
#define USBIN_INPUT_9V			0x4
#define USBIN_INPUT_UNREG		0x2
#define USBIN_INPUT_5V			0x1
#define USBIN_HVDCP_STS			0x0C
#define USBIN_HVDCP_SEL_BIT		BIT(4)
#define USBIN_HVDCP_SEL_9V_BIT		BIT(1)
static int smbchg_get_min_parallel_current_ma(struct smbchg_chip *chip)
{
	int rc;
	u8 vbus_sel, reg;
	u8 reg;

	rc = smbchg_read(chip, &reg, chip->usb_chgpth_base + INPUT_STS, 1);
	rc = smbchg_read(chip, &reg,
			chip->usb_chgpth_base + USBIN_HVDCP_STS, 1);
	if (rc < 0) {
		dev_err(chip->dev, "Couldn't read usb status rc = %d\n", rc);
		return 0;
	}
	vbus_sel = (reg & USBIN_INPUT_STS_MASK) >> USBIN_INPUT_STS_OFFSET;
	if (vbus_sel == USBIN_INPUT_5V || vbus_sel == USBIN_INPUT_UNREG)
		return chip->parallel.min_current_thr_ma;
	else if (vbus_sel == USBIN_INPUT_9V)
	if ((reg & USBIN_HVDCP_SEL_BIT) && (reg & USBIN_HVDCP_SEL_9V_BIT))
		return chip->parallel.min_9v_current_thr_ma;
	else
		return 0;
	return chip->parallel.min_current_thr_ma;
}

#define ICL_STS_1_REG			0x7