summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Troast <ntroast@codeaurora.org>2017-01-30 14:52:33 -0800
committerNicholas Troast <ntroast@codeaurora.org>2017-01-30 14:52:33 -0800
commit88b334d041876e5cada0339726b310425ff1122a (patch)
tree1f40266d3d79bebfb26df4854ea4db04de13abf0
parent635dca1f6ae9ed278357666b8210fcffc348cf29 (diff)
smb-lib: disable APSD run on CC while APSD is disabled
CC can debounce several times while VBUS is present and if APSD is disabled the APSD result will be unknown. Disable APSD run on CC debounce when APSD is disabled so the APSD result will not be reset in this case. Change-Id: Ia0b18605ea7d51aab0426bc7ad7c873152f42dc7 Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
-rw-r--r--drivers/power/supply/qcom/smb-lib.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c
index d3d79ec0c071..f2579410db12 100644
--- a/drivers/power/supply/qcom/smb-lib.c
+++ b/drivers/power/supply/qcom/smb-lib.c
@@ -1020,13 +1020,41 @@ static int smblib_apsd_disable_vote_callback(struct votable *votable,
struct smb_charger *chg = data;
int rc;
- rc = smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG,
- AUTO_SRC_DETECT_BIT,
- apsd_disable ? 0 : AUTO_SRC_DETECT_BIT);
- if (rc < 0) {
- smblib_err(chg, "Couldn't %s APSD rc=%d\n",
- apsd_disable ? "disable" : "enable", rc);
- return rc;
+ if (apsd_disable) {
+ /* Don't run APSD on CC debounce when APSD is disabled */
+ rc = smblib_masked_write(chg, TYPE_C_CFG_REG,
+ APSD_START_ON_CC_BIT,
+ 0);
+ if (rc < 0) {
+ smblib_err(chg, "Couldn't disable APSD_START_ON_CC rc=%d\n",
+ rc);
+ return rc;
+ }
+
+ rc = smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG,
+ AUTO_SRC_DETECT_BIT,
+ 0);
+ if (rc < 0) {
+ smblib_err(chg, "Couldn't disable APSD rc=%d\n", rc);
+ return rc;
+ }
+ } else {
+ rc = smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG,
+ AUTO_SRC_DETECT_BIT,
+ AUTO_SRC_DETECT_BIT);
+ if (rc < 0) {
+ smblib_err(chg, "Couldn't enable APSD rc=%d\n", rc);
+ return rc;
+ }
+
+ rc = smblib_masked_write(chg, TYPE_C_CFG_REG,
+ APSD_START_ON_CC_BIT,
+ APSD_START_ON_CC_BIT);
+ if (rc < 0) {
+ smblib_err(chg, "Couldn't enable APSD_START_ON_CC rc=%d\n",
+ rc);
+ return rc;
+ }
}
return 0;