summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLi Jun <jun.li@nxp.com>2016-02-03 15:54:52 +0800
committerLi Jun <jun.li@nxp.com>2016-02-16 15:48:20 +0800
commitbd54eea0f74c40fd801aa632787f05ec1b7407ea (patch)
tree2df39d8c7e7846d0cfcb2fdfde0f0b2cc1dd2b46 /drivers
parent57b1be6777378c91d983be4eb1de58dfe6028510 (diff)
MLK-12344-1 usb: chipidea: otg: add vbus connect for gadget after sleep
During system sleep, if we switch otg role from host to gadget, because the vbus is on both at system suspend and resume, we will lose vbus connect event after system resume, thus, no chance to setup vbus session for gadget so enumeration will not happen. This patch is to fix it by adding vbus connect handling for this case. Acked-by: Peter Chen <peter.chen@nxp.com> Signed-off-by: Li Jun <jun.li@nxp.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/chipidea/otg.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index c3d003348660..87bb42ed7b66 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -1,7 +1,7 @@
/*
* otg.c - ChipIdea USB IP core OTG driver
*
- * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
*
* Author: Peter Chen
*
@@ -112,6 +112,7 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)
void ci_handle_id_switch(struct ci_hdrc *ci)
{
enum ci_role role = ci_otg_role(ci);
+ int ret = 0;
if (role != ci->role) {
dev_dbg(ci->dev, "switching from %s to %s\n",
@@ -127,10 +128,18 @@ void ci_handle_id_switch(struct ci_hdrc *ci)
if (role == CI_ROLE_GADGET)
/* wait vbus lower than OTGSC_BSV */
- hw_wait_reg(ci, OP_OTGSC, OTGSC_BSV, 0,
+ ret = hw_wait_reg(ci, OP_OTGSC, OTGSC_BSV, 0,
CI_VBUS_STABLE_TIMEOUT_MS);
ci_role_start(ci, role);
+ /*
+ * If the role switch happens(e.g. during system
+ * sleep) and vbus keeps on afterwards, we connect
+ * gadget as vbus connect event lost.
+ */
+ if (ret == -ETIMEDOUT)
+ usb_gadget_vbus_connect(&ci->gadget);
+
}
}