summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhijeet Dharmapurikar <adharmap@codeaurora.org>2017-08-25 14:23:09 -0700
committerAshay Jaiswal <ashayj@codeaurora.org>2017-11-20 18:12:20 +0530
commit1ef211f2cf6088977c3a46437064b855bc7fb385 (patch)
tree97696c1bcebedfd4d442bdc603f72266be2ffae7
parent74a9c48a91cd57fb125f3479a2c2e37034e560fe (diff)
smb-lib: allow hvdcp if pd is disabled
Currently when pd is disabled, we do not allow hvdcp. To fix that once hvdcp timeout happens and if pd is disabled, force a pd_active = 0. This will cause us to run legacy workaround and rerun apsd if the charger was detected as hvdcp. Importantly, once legacy bit workaround is run, wait 400mS for typeC to debounce. Currently we wait for 100mS only and that causes a removal detection since the CC lines are not settled within 100mS. Also it may take up to 650mS for the vbus to drop once CC lines are floated during the workaround. The current wait is just 500mS, bump it up to a 1 second. Change-Id: I17a7341e96d6efccde6270bc69d79c3f215b83e4 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
-rw-r--r--drivers/power/supply/qcom/smb-lib.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c
index 93512f155c52..7acf5fab573b 100644
--- a/drivers/power/supply/qcom/smb-lib.c
+++ b/drivers/power/supply/qcom/smb-lib.c
@@ -2695,17 +2695,13 @@ int smblib_set_prop_pd_voltage_max(struct smb_charger *chg,
return rc;
}
-int smblib_set_prop_pd_active(struct smb_charger *chg,
- const union power_supply_propval *val)
+static int __smblib_set_prop_pd_active(struct smb_charger *chg, bool pd_active)
{
int rc;
bool orientation, sink_attached, hvdcp;
u8 stat;
- if (!get_effective_result(chg->pd_allowed_votable))
- return -EINVAL;
-
- chg->pd_active = val->intval;
+ chg->pd_active = pd_active;
if (chg->pd_active) {
vote(chg->apsd_disable_votable, PD_VOTER, true, 0);
vote(chg->pd_allowed_votable, PD_VOTER, true, 0);
@@ -2793,6 +2789,15 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
return rc;
}
+int smblib_set_prop_pd_active(struct smb_charger *chg,
+ const union power_supply_propval *val)
+{
+ if (!get_effective_result(chg->pd_allowed_votable))
+ return -EINVAL;
+
+ return __smblib_set_prop_pd_active(chg, val->intval);
+}
+
int smblib_set_prop_ship_mode(struct smb_charger *chg,
const union power_supply_propval *val)
{
@@ -3544,6 +3549,13 @@ static void smblib_handle_hvdcp_check_timeout(struct smb_charger *chg,
/* enforce DCP ICL if specified */
vote(chg->usb_icl_votable, DCP_VOTER,
chg->dcp_icl_ua != -EINVAL, chg->dcp_icl_ua);
+
+ /*
+ * if pd is not allowed, then set pd_active = false right here,
+ * so that it starts the hvdcp engine
+ */
+ if (!get_effective_result(chg->pd_allowed_votable))
+ __smblib_set_prop_pd_active(chg, 0);
}
smblib_dbg(chg, PR_INTERRUPT, "IRQ: smblib_handle_hvdcp_check_timeout %s\n",
@@ -4188,7 +4200,7 @@ irqreturn_t smblib_handle_usb_typec_change(int irq, void *data)
if (chg->cc2_detach_wa_active || chg->typec_en_dis_active ||
chg->try_sink_active) {
- smblib_dbg(chg, PR_INTERRUPT, "Ignoring since %s active\n",
+ smblib_dbg(chg, PR_MISC | PR_INTERRUPT, "Ignoring since %s active\n",
chg->cc2_detach_wa_active ?
"cc2_detach_wa" : "typec_en_dis");
return IRQ_HANDLED;
@@ -4699,7 +4711,9 @@ static void smblib_legacy_detection_work(struct work_struct *work)
smblib_err(chg, "Couldn't disable type-c rc=%d\n", rc);
/* wait for the adapter to turn off VBUS */
- msleep(500);
+ msleep(1000);
+
+ smblib_dbg(chg, PR_MISC, "legacy workaround enabling typec\n");
rc = smblib_masked_write(chg,
TYPE_C_INTRPT_ENB_SOFTWARE_CTRL_REG,
@@ -4708,7 +4722,7 @@ static void smblib_legacy_detection_work(struct work_struct *work)
smblib_err(chg, "Couldn't enable type-c rc=%d\n", rc);
/* wait for type-c detection to complete */
- msleep(100);
+ msleep(400);
rc = smblib_read(chg, TYPE_C_STATUS_5_REG, &stat);
if (rc < 0) {
@@ -4720,6 +4734,8 @@ static void smblib_legacy_detection_work(struct work_struct *work)
vote(chg->usb_icl_votable, LEGACY_UNKNOWN_VOTER, false, 0);
legacy = stat & TYPEC_LEGACY_CABLE_STATUS_BIT;
rp_high = chg->typec_mode == POWER_SUPPLY_TYPEC_SOURCE_HIGH;
+ smblib_dbg(chg, PR_MISC, "legacy workaround done legacy = %d rp_high = %d\n",
+ legacy, rp_high);
if (!legacy || !rp_high)
vote(chg->hvdcp_disable_votable_indirect, VBUS_CC_SHORT_VOTER,
false, 0);