From 58e45f3e55e2a5b46ed76c6d153ea62a2db56eb4 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Tue, 7 Aug 2007 05:20:06 -0700 Subject: [PATCH] musb_hdrc: Fixes for OPT HS A tests If RESUME is cleared too soon, OPT HS A 6.8 tests will fail. This patch removes the check for RESUME bit before SUSPEND is set, and makes virthub sleep until RESUME has been held for 20 ms. Additionally virthub waits after clearing RESUME to allow musb to start generating SOFs before RESET. Signed-off-by: Tony Lindgren --- drivers/usb/musb/plat_uds.c | 29 +++++++++++++++-------------- drivers/usb/musb/virthub.c | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/usb/musb/plat_uds.c b/drivers/usb/musb/plat_uds.c index 3aca510af90..36fc5786b55 100644 --- a/drivers/usb/musb/plat_uds.c +++ b/drivers/usb/musb/plat_uds.c @@ -386,26 +386,27 @@ static irqreturn_t musb_stage0_irq(struct musb * pThis, u8 bIntrUSB, /* remote wakeup? later, GetPortStatus * will stop RESUME signaling */ - if (power & MGC_M_POWER_RESUME) { - power &= ~MGC_M_POWER_SUSPENDM; - musb_writeb(pBase, MGC_O_HDRC_POWER, + + if (power & MGC_M_POWER_SUSPENDM) { + /* spurious */ + pThis->int_usb &= ~MGC_M_INTR_SUSPEND; + DBG(2, "Spurious SUSPENDM\n"); + break; + } + + power &= ~MGC_M_POWER_SUSPENDM; + musb_writeb(pBase, MGC_O_HDRC_POWER, power | MGC_M_POWER_RESUME); - pThis->port1_status |= + pThis->port1_status |= (USB_PORT_STAT_C_SUSPEND << 16) | MUSB_PORT_STAT_RESUME; - pThis->rh_timer = jiffies + pThis->rh_timer = jiffies + msecs_to_jiffies(20); - pThis->xceiv.state = OTG_STATE_A_HOST; - pThis->is_active = 1; - usb_hcd_resume_root_hub( - musb_to_hcd(pThis)); - - } else if (power & MGC_M_POWER_SUSPENDM) { - /* spurious */ - pThis->int_usb &= ~MGC_M_INTR_SUSPEND; - } + pThis->xceiv.state = OTG_STATE_A_HOST; + pThis->is_active = 1; + usb_hcd_resume_root_hub(musb_to_hcd(pThis)); break; case OTG_STATE_B_WAIT_ACON: pThis->xceiv.state = OTG_STATE_B_PERIPHERAL; diff --git a/drivers/usb/musb/virthub.c b/drivers/usb/musb/virthub.c index 5b1163b031c..d4fa7153668 100644 --- a/drivers/usb/musb/virthub.c +++ b/drivers/usb/musb/virthub.c @@ -129,6 +129,22 @@ static void musb_port_reset(struct musb *musb, u8 bReset) */ power = musb_readb(pBase, MGC_O_HDRC_POWER); if (bReset) { + + /* + * If RESUME is set, we must make sure it stays minimum 20 ms. + * Then we must clear RESUME and wait a bit to let musb start + * generating SOFs. If we don't do this, OPT HS A 6.8 tests + * fail with "Error! Did not receive an SOF before suspend + * detected". + */ + if (power & MGC_M_POWER_RESUME) { + while (time_before(jiffies, musb->rh_timer)) + msleep(1); + musb_writeb(pBase, MGC_O_HDRC_POWER, + power & ~MGC_M_POWER_RESUME); + msleep(1); + } + musb->bIgnoreDisconnect = TRUE; power &= 0xf0; musb_writeb(pBase, MGC_O_HDRC_POWER, -- 2.41.1