On Sat, Oct 13, 2012 at 06:40:23PM +0530, Vikas Sajjan wrote: > Adding the suspend and resume funtionality to DWC3 core. > > Signed-off-by: Abhilash Kesavan <a.kesavan@xxxxxxxxxxx> > Signed-off-by: Vikas C Sajjan <vikas.sajjan@xxxxxxxxxx> > CC: Doug Anderson <dianders@xxxxxxxxxxxx> > --- > drivers/usb/dwc3/core.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 54 insertions(+), 0 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index b415c0c..0699061 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -622,11 +622,65 @@ static int __devexit dwc3_remove(struct platform_device *pdev) > return 0; > } > > +#ifdef CONFIG_PM > +static int dwc3_resume(struct device *dev) > +{ > + struct dwc3 *dwc = dev_get_drvdata(dev); > + int ret; > + > + usb_phy_init(dwc->usb2_phy); > + usb_phy_init(dwc->usb3_phy); > + > + ret = dwc3_event_buffers_setup(dwc); > + if (ret < 0) > + return ret; > + > + switch (dwc->mode) { > + case DWC3_MODE_DEVICE: > + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); > + break; > + case DWC3_MODE_HOST: > + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); > + break; > + case DWC3_MODE_DRD: > + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); > + } > + > + /* runtime set active to reflect active state. */ > + pm_runtime_disable(dev); > + pm_runtime_set_active(dev); > + pm_runtime_enable(dev); > + > + return 0; > +} > + > +static int dwc3_suspend(struct device *dev) > +{ > + struct dwc3 *dwc = dev_get_drvdata(dev); > + > + dwc3_event_buffers_cleanup(dwc); > + > + usb_phy_shutdown(dwc->usb2_phy); > + usb_phy_shutdown(dwc->usb3_phy); > + > + return 0; > +} > + > +static const struct dev_pm_ops dwc3_pm_ops = { > + .suspend = dwc3_suspend, > + .resume = dwc3_resume, > +}; one extra comment: SET_SYSTEM_SLEEP_PM_OPS() -- balbi
Attachment:
signature.asc
Description: Digital signature