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

Commit fa12cb53 authored by Nicholas Troast's avatar Nicholas Troast
Browse files

power: smb-lib: use updated ICL override bit



Currently to override the ICL the self-clearing ICL override bit is
used. The problem with this bit is that it is self-clearing and a
separate register needs to be read to get the override status.
Furthermore, the hardware will automatically clear this bit on USB
removal.

A new ICL override bit was added in PMI hardware revision 2.0. This bit
is not self-clearing, and can be set prior to USB insertion. Use this
new bit.

Change-Id: I30a601b6aacba3c404ebdfb82e529504a694a048
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 13bdd014
Loading
Loading
Loading
Loading
+6 −31
Original line number Diff line number Diff line
@@ -161,40 +161,15 @@ static int smblib_get_jeita_cc_delta(struct smb_charger *chg, int *cc_delta_ua)
int smblib_icl_override(struct smb_charger *chg, bool override)
{
	int rc;
	bool override_status;
	u8 stat;
	u16 reg;

	switch (chg->smb_version) {
	case PMI8998_SUBTYPE:
		reg = APSD_RESULT_STATUS_REG;
		break;
	case PM660_SUBTYPE:
		reg = AICL_STATUS_REG;
		break;
	default:
		smblib_dbg(chg, PR_MISC, "Unknown chip version=%x\n",
				chg->smb_version);
		return -EINVAL;
	}

	rc = smblib_read(chg, reg, &stat);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read reg=%x rc=%d\n", reg, rc);
		return rc;
	}
	override_status = (bool)(stat & ICL_OVERRIDE_LATCH_BIT);

	if (override != override_status) {
		rc = smblib_masked_write(chg, CMD_APSD_REG,
				ICL_OVERRIDE_BIT, ICL_OVERRIDE_BIT);
		if (rc < 0) {
	rc = smblib_masked_write(chg, USBIN_LOAD_CFG_REG,
				ICL_OVERRIDE_AFTER_APSD_BIT,
				override ? ICL_OVERRIDE_AFTER_APSD_BIT : 0);
	if (rc < 0)
		smblib_err(chg, "Couldn't override ICL rc=%d\n", rc);

	return rc;
}
	}
	return 0;
}

/********************
 * REGISTER GETTERS *
+1 −0
Original line number Diff line number Diff line
@@ -628,6 +628,7 @@ enum {

#define USBIN_LOAD_CFG_REG			(USBIN_BASE + 0x65)
#define USBIN_OV_CH_LOAD_OPTION_BIT		BIT(7)
#define ICL_OVERRIDE_AFTER_APSD_BIT		BIT(4)

#define USBIN_ICL_OPTIONS_REG			(USBIN_BASE + 0x66)
#define CFG_USB3P0_SEL_BIT			BIT(2)