+
+ /* delay, to avoid problems with module reload */
+ if (is_host_enabled(musb)) {
+ int maxdelay = 30;
+ u8 devctl, warn = 0;
+
+ /* if there's no peripheral connected, this can take a
+ * long time to fall, especially on EVM with huge C133.
+ */
+ do {
+ devctl = musb_readb(musb->pRegs, MGC_O_HDRC_DEVCTL);
+ if (!(devctl & MGC_M_DEVCTL_VBUS))
+ break;
+ if ((devctl & MGC_M_DEVCTL_VBUS) != warn) {
+ warn = devctl & MGC_M_DEVCTL_VBUS;
+ DBG(1, "VBUS %d\n", warn >> MGC_S_DEVCTL_VBUS);
+ }
+ msleep(1000);
+ maxdelay--;
+ } while (maxdelay > 0);
+
+ /* in OTG mode, another host might be connected */
+ if (devctl & MGC_M_DEVCTL_VBUS)
+ DBG(1, "VBUS off timeout (devctl %02x)\n", devctl);
+ }
+
+ phy_off();