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: Nicholas Troast <ntroast@codeaurora.org>
This commit is contained in:
parent
13bdd014a7
commit
fa12cb53c0
2 changed files with 7 additions and 31 deletions
|
@ -161,39 +161,14 @@ 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_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);
|
||||
|
||||
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) {
|
||||
smblib_err(chg, "Couldn't override ICL rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/********************
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue