summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLi Jun <b47624@freescale.com>2014-06-28 22:09:09 +0800
committerLi Jun <B47624@freescale.com>2014-06-30 16:37:04 +0800
commit566e041ef624ed62baf617c17983d44f042693f8 (patch)
treece7296f8814e7d13db1fdb86e56e29e54b1df0a1 /drivers
parent43a2881cd3daa51b1eb49a17bdf872a3771b794d (diff)
ENGR00320439-3 usb: chipidea: host:add API to check if device connected
This patch adds interface to check if the host has usb device connected. Acked-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Li Jun <b47624@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/chipidea/host.c14
-rw-r--r--drivers/usb/chipidea/host.h6
-rw-r--r--drivers/usb/chipidea/otg.c16
3 files changed, 25 insertions, 11 deletions
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 237cd123fc68..e073462c487c 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -324,6 +324,20 @@ static void host_stop(struct ci_hdrc *ci)
ci->hcd = NULL;
}
+bool ci_hdrc_host_has_device(struct ci_hdrc *ci)
+{
+ struct usb_device *roothub;
+ int i;
+
+ if ((ci->role == CI_ROLE_HOST) && ci->hcd) {
+ roothub = ci->hcd->self.root_hub;
+ for (i = 0; i < roothub->maxchild; ++i) {
+ if (usb_hub_find_child(roothub, (i + 1)))
+ return true;
+ }
+ }
+ return false;
+}
void ci_hdrc_host_destroy(struct ci_hdrc *ci)
{
diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h
index 5707bf379bfb..0b01b635e6e4 100644
--- a/drivers/usb/chipidea/host.h
+++ b/drivers/usb/chipidea/host.h
@@ -5,6 +5,7 @@
int ci_hdrc_host_init(struct ci_hdrc *ci);
void ci_hdrc_host_destroy(struct ci_hdrc *ci);
+bool ci_hdrc_host_has_device(struct ci_hdrc *ci);
#else
@@ -18,6 +19,11 @@ static inline void ci_hdrc_host_destroy(struct ci_hdrc *ci)
}
+static inline bool ci_hdrc_host_has_device(struct ci_hdrc *ci)
+{
+ return false;
+}
+
#endif
#endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 15a818ae4bad..453f61080e5b 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -24,6 +24,7 @@
#include "bits.h"
#include "otg.h"
#include "otg_fsm.h"
+#include "host.h"
/**
* hw_read_otgsc returns otgsc register bits value.
@@ -111,22 +112,15 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)
static void ci_handle_id_switch(struct ci_hdrc *ci)
{
enum ci_role role = ci_otg_role(ci);
- struct usb_device *roothub;
- int i;
if (role != ci->role) {
dev_dbg(ci->dev, "switching from %s to %s\n",
ci_role(ci)->name, ci->roles[role]->name);
- if ((ci->role == CI_ROLE_HOST) && ci->hcd) {
- roothub = ci->hcd->self.root_hub;
- for (i = 0; i < roothub->maxchild; ++i) {
- while (usb_hub_find_child(roothub, (i + 1))) {
- enable_irq(ci->irq);
- usleep_range(10000, 15000);
- disable_irq_nosync(ci->irq);
- }
- }
+ while (ci_hdrc_host_has_device(ci)) {
+ enable_irq(ci->irq);
+ usleep_range(10000, 15000);
+ disable_irq_nosync(ci->irq);
}
ci_role_stop(ci);