Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1217644

[PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume while we're dual-role

From Roger Quadros <rogerq@ti.com>
Newsgroups linux.kernel
Subject [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume while we're dual-role
Date 2015-09-02 16:30 +0200
Message-ID <q4hd0-7Er-35@gated-at.bofh.it> (permalink)
References <q4hcZ-7Er-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


We can't rely just on dr_mode to decide if we're in host or gadget
mode when we're configured as otg/dual-role. So while dr_mode is
OTG, we find out from  the otg state machine if we're in host
or gadget mode and take the necessary actions during suspend/resume.

Also make sure that we disable OTG irq and events during system suspend
so that we don't lockup the system during system suspend/resume.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/dwc3/core.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 654aebf..25891e3 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1455,18 +1455,15 @@ static int dwc3_suspend(struct device *dev)
 		dwc->octl = dwc3_readl(dwc->regs, DWC3_OCTL);
 		dwc->oevt = dwc3_readl(dwc->regs, DWC3_OEVT);
 		dwc->oevten = dwc3_readl(dwc->regs, DWC3_OEVTEN);
+		dwc3_writel(dwc->regs, DWC3_OEVTEN, 0);
+		disable_irq(dwc->otg_irq);
 	}
 
-	switch (dwc->dr_mode) {
-	case USB_DR_MODE_PERIPHERAL:
-	case USB_DR_MODE_OTG:
+	if (dwc->dr_mode == USB_DR_MODE_PERIPHERAL ||
+	    ((dwc->dr_mode == USB_DR_MODE_OTG) && (dwc->fsm->protocol == PROTO_GADGET)))
 		dwc3_gadget_suspend(dwc);
-		/* FALLTHROUGH */
-	case USB_DR_MODE_HOST:
-	default:
-		dwc3_event_buffers_cleanup(dwc);
-		break;
-	}
+
+	dwc3_event_buffers_cleanup(dwc);
 
 	dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL);
 	spin_unlock_irqrestore(&dwc->lock, flags);
@@ -1506,18 +1503,12 @@ static int dwc3_resume(struct device *dev)
 		dwc3_writel(dwc->regs, DWC3_OCTL, dwc->octl);
 		dwc3_writel(dwc->regs, DWC3_OEVT, dwc->oevt);
 		dwc3_writel(dwc->regs, DWC3_OEVTEN, dwc->oevten);
+		enable_irq(dwc->otg_irq);
 	}
 
-	switch (dwc->dr_mode) {
-	case USB_DR_MODE_PERIPHERAL:
-	case USB_DR_MODE_OTG:
+	if (dwc->dr_mode == USB_DR_MODE_PERIPHERAL ||
+	    ((dwc->dr_mode == USB_DR_MODE_OTG) && (dwc->fsm->protocol == PROTO_GADGET)))
 		dwc3_gadget_resume(dwc);
-		/* FALLTHROUGH */
-	case USB_DR_MODE_HOST:
-	default:
-		/* do nothing */
-		break;
-	}
 
 	spin_unlock_irqrestore(&dwc->lock, flags);
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 0/9] usb: dwc3: add dual-role support Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
  [PATCH v4 1/9] usb: dwc3: add dual-role support Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
    Re: [PATCH v4 1/9] usb: dwc3: add dual-role support Felipe Balbi <balbi@ti.com> - 2015-09-02 16:40 +0200
      Re: [PATCH v4 1/9] usb: dwc3: add dual-role support Roger Quadros <rogerq@ti.com> - 2015-09-03 14:30 +0200
        Re: [PATCH v4 1/9] usb: dwc3: add dual-role support Felipe Balbi <balbi@ti.com> - 2015-09-03 18:10 +0200
          Re: [PATCH v4 1/9] usb: dwc3: add dual-role support Roger Quadros <rogerq@ti.com> - 2015-09-04 11:10 +0200
  [PATCH v4 6/9] usb: dwc3: save/restore OTG registers during suspend/resume Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
    Re: [PATCH v4 6/9] usb: dwc3: save/restore OTG registers during  suspend/resume Felipe Balbi <balbi@ti.com> - 2015-09-02 16:50 +0200
      Re: [PATCH v4 6/9] usb: dwc3: save/restore OTG registers during  suspend/resume Roger Quadros <rogerq@ti.com> - 2015-09-03 16:00 +0200
  [PATCH v4 3/9] usb: dwc3: dwc3-omap: Make the wrapper interrupt shared Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
    Re: [PATCH v4 3/9] usb: dwc3: dwc3-omap: Make the wrapper interrupt  shared Felipe Balbi <balbi@ti.com> - 2015-09-02 16:40 +0200
  [PATCH v4 5/9] usb: dwc3: core: make dual-role work with OTG irq Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
    Re: [PATCH v4 5/9] usb: dwc3: core: make dual-role work with OTG irq Felipe Balbi <balbi@ti.com> - 2015-09-02 16:50 +0200
      Re: [PATCH v4 5/9] usb: dwc3: core: make dual-role work with OTG irq Roger Quadros <rogerq@ti.com> - 2015-09-03 16:00 +0200
        Re: [PATCH v4 5/9] usb: dwc3: core: make dual-role work with OTG irq Felipe Balbi <balbi@ti.com> - 2015-09-03 18:00 +0200
          Re: [PATCH v4 5/9] usb: dwc3: core: make dual-role work with OTG irq Roger Quadros <rogerq@ti.com> - 2015-09-04 11:20 +0200
  [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume while we're dual-role Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
    Re: [PATCH v4 9/9] usb: dwc3: core: don't break during  suspend/resume while we're dual-role Felipe Balbi <balbi@ti.com> - 2015-09-02 16:50 +0200
      Re: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume  while we're dual-role Roger Quadros <rogerq@ti.com> - 2015-09-03 16:10 +0200
    Re: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume  while we're dual-role Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-09-02 19:30 +0200
      Re: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume  while we're dual-role Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-09-03 16:10 +0200
        Re: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume  while we're dual-role Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-09-03 16:20 +0200
        Re: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume  while we're dual-role Roger Quadros <rogerq@ti.com> - 2015-09-03 16:20 +0200
      Re: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume  while we're dual-role Roger Quadros <rogerq@ti.com> - 2015-09-03 16:10 +0200
  [PATCH v4 2/9] usb: dwc3: core.h: add some register definitions Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
  [PATCH v4 4/9] usb: dwc3: core: Adapt to named interrupts Roger Quadros <rogerq@ti.com> - 2015-09-02 16:30 +0200
    Re: [PATCH v4 4/9] usb: dwc3: core: Adapt to named interrupts Felipe Balbi <balbi@ti.com> - 2015-09-02 16:40 +0200
      Re: [PATCH v4 4/9] usb: dwc3: core: Adapt to named interrupts Roger Quadros <rogerq@ti.com> - 2015-09-03 14:50 +0200
        Re: [PATCH v4 4/9] usb: dwc3: core: Adapt to named interrupts Felipe Balbi <balbi@ti.com> - 2015-09-03 18:00 +0200
          Re: [PATCH v4 4/9] usb: dwc3: core: Adapt to named interrupts Roger Quadros <rogerq@ti.com> - 2015-09-04 11:20 +0200

csiph-web