From: Tony Lindgren Date: Fri, 29 Jun 2007 09:24:12 +0000 (-0700) Subject: musb_hdrc: Make SRP reliable and fix timer value X-Git-Tag: v2.6.22-omap1~11 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=96420a7f31fa8b65bcc14254e4e4e78a3cf3a078;p=linux-2.6-omap-h63xx.git musb_hdrc: Make SRP reliable and fix timer value Make SRP reliable and fix timer value Signed-off-by: Tony Lindgren --- diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index ce389cdbb9f..1b2c8295a5e 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1448,6 +1448,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) unsigned long flags; int status = -EINVAL; u8 power, devctl; + int retries; spin_lock_irqsave(&musb->Lock, flags); @@ -1462,14 +1463,27 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) goto done; case OTG_STATE_B_IDLE: /* Start SRP ... OTG not required. */ - DBG(2, "Sending SRP\n"); devctl = musb_readb(mregs, MGC_O_HDRC_DEVCTL); + DBG(2, "Sending SRP: devctl: %02x\n", devctl); devctl |= MGC_M_DEVCTL_SESSION; musb_writeb(mregs, MGC_O_HDRC_DEVCTL, devctl); + devctl = musb_readb(mregs, MGC_O_HDRC_DEVCTL); + retries = 100; + while (!(devctl & MGC_M_DEVCTL_SESSION)) { + devctl = musb_readb(mregs, MGC_O_HDRC_DEVCTL); + if (retries-- < 1) + break; + } + retries = 10000; + while (devctl & MGC_M_DEVCTL_SESSION) { + devctl = musb_readb(mregs, MGC_O_HDRC_DEVCTL); + if (retries-- < 1) + break; + } /* Block idling for at least 1s */ musb_platform_try_idle(musb, - msecs_to_jiffies(1 * HZ)); + jiffies + msecs_to_jiffies(1 * HZ)); status = 0; goto done;