提交 c7fdc585 编写于 作者: P Piyush Mehta 提交者: Michal Simek

usb: dwc3: hibernation: Handling hibernation spurious events

Add spurious hibernation events handling for hibernation state:
- Corrected the __dwc3_gadget_ep_enable function action argument for
  endpoint restore or save state.
- When software end active transfer, software must set the DEPCMD_CMDIOC
  bit so that an Endpoint Command Complete event is generated after the
  transfer ends.
- Cleared endpoint flags when endpoint transfer stop or end.
- Modified delay to validate wake-up signal is real or not.
Signed-off-by: NPiyush Mehta <piyush.mehta@xilinx.com>
上级 b63b74c7
......@@ -25,6 +25,9 @@
#include "debug.h"
#include "io.h"
/* delay - wakeup signal is real or not */
#define DWC3_WAKEUP_SIGNAL_DELAY 100
/* array of registers to save on hibernation and restore them on wakeup */
static u32 save_reg_addr[] = {
DWC3_DCTL,
......@@ -32,18 +35,6 @@ static u32 save_reg_addr[] = {
DWC3_DEVTEN
};
/*
* wait_timeout - Waits until timeout
* @wait_time: time to wait in jiffies
*/
static void wait_timeout(unsigned long wait_time)
{
unsigned long timeout = jiffies + wait_time;
while (!time_after_eq(jiffies, timeout))
cpu_relax();
}
/**
* save_regs - Saves registers on hibernation
* @dwc: pointer to our controller context structure
......@@ -149,7 +140,7 @@ static int restore_eps(struct dwc3 *dwc)
if (!(dep->flags & DWC3_EP_ENABLED))
continue;
ret = __dwc3_gadget_ep_enable(dep, true);
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_RESTORE);
if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
return ret;
......@@ -251,7 +242,7 @@ static int restore_ep0(struct dwc3 *dwc)
if (!(dep->flags & DWC3_EP_ENABLED))
continue;
ret = __dwc3_gadget_ep_enable(dep, true);
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_RESTORE);
if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
return ret;
......@@ -342,7 +333,9 @@ void gadget_hibernation_interrupt(struct dwc3 *dwc)
continue;
if (dep->flags & DWC3_EP_TRANSFER_STARTED)
dwc3_stop_active_transfer(dep, false, false);
dwc3_stop_active_transfer(dep, false, true);
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
save_endpoint_state(dep);
}
......@@ -497,7 +490,7 @@ void gadget_wakeup_interrupt(struct dwc3 *dwc)
* As some suprious signals also cause wakeup event, wait for some time
* and check the link state to confirm if the wakeup signal is real
*/
wait_timeout(msecs_to_jiffies(10));
udelay(DWC3_WAKEUP_SIGNAL_DELAY);
link_state = dwc3_gadget_get_link_state(dwc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册