From 9c46ce285a7bc23644e0a68a6056b87193bca038 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Fri, 7 Sep 2007 19:09:01 -0700 Subject: [PATCH] musb_hdrc: Fix HNP for OPT quirks We cannot stop HNP based on SUSPEND, as devctl may still have BDEVICE bit still set. Signed-off-by: Tony Lindgren --- drivers/usb/musb/musb_core.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 53cb110f09a..65f288e4d82 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -321,6 +321,7 @@ void musb_hnp_stop(struct musb *musb) switch (musb->xceiv.state) { case OTG_STATE_A_PERIPHERAL: case OTG_STATE_A_WAIT_VFALL: + case OTG_STATE_A_WAIT_BCON: DBG(1, "HNP: Switching back to A-host\n"); musb_g_disconnect(musb); musb->xceiv.state = OTG_STATE_A_IDLE; @@ -635,9 +636,19 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb, musb_writeb(mbase, MUSB_DEVCTL, 0); } } else if (is_peripheral_capable()) { - DBG(1, "BUS RESET\n"); - - musb_g_reset(musb); + DBG(1, "BUS RESET as %s\n", otg_state_string(musb)); + switch (musb->xceiv.state) { + case OTG_STATE_A_PERIPHERAL: + case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */ + musb_hnp_stop(musb); + break; + case OTG_STATE_B_PERIPHERAL: + musb_g_reset(musb); + break; + default: + DBG(1, "Unhandled BUS RESET as %s\n", + otg_state_string(musb)); + } schedule_work(&musb->irq_work); } @@ -729,6 +740,7 @@ static irqreturn_t musb_stage2_irq(struct musb * musb, u8 int_usb, musb_hnp_stop(musb); break; case OTG_STATE_A_PERIPHERAL: + musb_hnp_stop(musb); musb_root_disconnect(musb); /* FALLTHROUGH */ case OTG_STATE_B_WAIT_ACON: @@ -757,7 +769,10 @@ static irqreturn_t musb_stage2_irq(struct musb * musb, u8 int_usb, switch (musb->xceiv.state) { #ifdef CONFIG_USB_MUSB_OTG case OTG_STATE_A_PERIPHERAL: - musb_hnp_stop(musb); + /* + * We cannot stop HNP here, devctl BDEVICE might be + * still set. + */ break; #endif case OTG_STATE_B_PERIPHERAL: -- 2.41.1