MLK-10102-9 usb: chipidea: host: add ci_hdrc_host_has_device API
authorLi Jun <jun.li@freescale.com>
Thu, 15 Jan 2015 13:26:05 +0000 (21:26 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:46:59 +0000 (14:46 -0500)
This patch adds a new API ci_hdrc_host_has_device to check if there
is usb device connected on host port.

Signed-off-by: Li Jun <b47624@freescale.com>
(cherry picked from commit fd68eb8ef9cdac1ca861ccbc3d01d874123bf52a)

drivers/usb/chipidea/host.c
drivers/usb/chipidea/host.h

index 2bcbc02..3c8e09c 100644 (file)
@@ -199,6 +199,21 @@ static void host_stop(struct ci_hdrc *ci)
        ci->otg.host = 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;
+}
+
 static void ci_hdrc_host_save_for_power_lost(struct ci_hdrc *ci)
 {
        struct ehci_hcd *ehci;
index 0f12f13..527c960 100644 (file)
@@ -6,6 +6,7 @@
 int ci_hdrc_host_init(struct ci_hdrc *ci);
 void ci_hdrc_host_destroy(struct ci_hdrc *ci);
 void ci_hdrc_host_driver_init(void);
+bool ci_hdrc_host_has_device(struct ci_hdrc *ci);
 
 #else
 
@@ -24,6 +25,11 @@ static void ci_hdrc_host_driver_init(void)
 
 }
 
+static inline bool ci_hdrc_host_has_device(struct ci_hdrc *ci)
+{
+       return false;
+}
+
 #endif
 
 #endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */