From: Baolin Wang Date: Mon, 16 May 2016 08:43:53 +0000 (+0800) Subject: UPSTREAM: dwc3: gadget: Implement the suspend entry event handler X-Git-Tag: firefly_0821_release~1772 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=396fda68c32d1abada4dbdefa370f2c6a70c2548;p=firefly-linux-kernel-4.4.55.git UPSTREAM: dwc3: gadget: Implement the suspend entry event handler It had changed to be suspend event for BIT6 in DEVT register from version 2.30a and above. Thus this patch introduces one suspend event handler to handle the suspend event. Change-Id: I62751ee39a2ff13c1359350a8f6c43c14aa4ea12 Signed-off-by: Baolin Wang Signed-off-by: Felipe Balbi Signed-off-by: Wu Liang feng (cherry picked from commit 72704f876f50b00f08d41d4b13d5a5d11262254f) --- diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 7bd4393dfe8a..906f10793eda 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2692,6 +2692,17 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, dwc->link_state = next; } +static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc, + unsigned int evtinfo) +{ + enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK; + + if (dwc->link_state != next && next == DWC3_LINK_STATE_U3) + dwc3_suspend_gadget(dwc); + + dwc->link_state = next; +} + static void dwc3_gadget_hibernation_interrupt(struct dwc3 *dwc, unsigned int evtinfo) { @@ -2743,7 +2754,20 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc, dwc3_gadget_linksts_change_interrupt(dwc, event->event_info); break; case DWC3_DEVICE_EVENT_EOPF: - dwc3_trace(trace_dwc3_gadget, "End of Periodic Frame"); + /* It changed to be suspend event for version 2.30a and above */ + if (dwc->revision < DWC3_REVISION_230A) { + dwc3_trace(trace_dwc3_gadget, "End of Periodic Frame"); + } else { + dwc3_trace(trace_dwc3_gadget, "U3/L1-L2 Suspend Event"); + + /* + * Ignore suspend event until the gadget enters into + * USB_STATE_CONFIGURED state. + */ + if (dwc->gadget.state >= USB_STATE_CONFIGURED) + dwc3_gadget_suspend_interrupt(dwc, + event->event_info); + } break; case DWC3_DEVICE_EVENT_SOF: dwc3_trace(trace_dwc3_gadget, "Start of Periodic Frame");