qcom-charger: smblib: add support for pd current setting

Forcing a certain current limit is not supported in the current
driver, but well needed in when pd is active.

In this change, ICL_OVERRIDE/APSD and USB mode are updated, so
that PD can alter current limit by simply voting the ICL
setting.

Change-Id: I8d3ec938d433fe9bdbb8c091873c07e75c49d632
Signed-off-by: Harry Yang <harryy@codeaurora.org>
This commit is contained in:
Harry Yang 2016-11-07 13:32:52 -08:00
parent 8a9006341d
commit d5c5cd27e0

View file

@ -2014,6 +2014,45 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
"Couldn't enable vconn on CC line rc=%d\n", rc);
return rc;
}
rc = vote(chg->usb_icl_votable, PD_VOTER, true, USBIN_500MA);
if (rc < 0) {
smblib_err(chg, "Couldn't vote for USB ICL rc=%d\n",
rc);
return rc;
}
rc = smblib_masked_write(chg, USBIN_ICL_OPTIONS_REG,
USBIN_MODE_CHG_BIT, USBIN_MODE_CHG_BIT);
if (rc < 0) {
smblib_err(chg,
"Couldn't change USB mode rc=%d\n", rc);
return rc;
}
rc = smblib_masked_write(chg, CMD_APSD_REG,
ICL_OVERRIDE_BIT, ICL_OVERRIDE_BIT);
if (rc < 0) {
smblib_err(chg,
"Couldn't override APSD rc=%d\n", rc);
return rc;
}
} else {
rc = smblib_masked_write(chg, CMD_APSD_REG,
ICL_OVERRIDE_BIT, 0);
if (rc < 0) {
smblib_err(chg,
"Couldn't override APSD rc=%d\n", rc);
return rc;
}
rc = smblib_masked_write(chg, USBIN_ICL_OPTIONS_REG,
USBIN_MODE_CHG_BIT, 0);
if (rc < 0) {
smblib_err(chg,
"Couldn't change USB mode rc=%d\n", rc);
return rc;
}
}
/* CC pin selection s/w override in PD session; h/w otherwise. */