On Sat, Oct 13, 2012 at 06:40:23PM +0530, Vikas Sajjan wrote: > Adding the suspend and resume funtionality to DWC3 core. typo -> functionality. Also this is quite lame as a commit log. I'm sure you can do better than this. > 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); > + } this is wrong. You should be calling dwc3_core_init(). Databook is very clear that we _must_ use a softreset to make sure PHY and DWC3 are in sync, otherwise some rather difficult-to-debug bugs might show up. > + > + /* 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, > +}; > +#define DWC3_PM_OPS &(dwc3_pm_ops) > +#else > +#define DWC3_PM_OPS NULL > +#endif /* CONFIG_PM */ > + > static struct platform_driver dwc3_driver = { > .probe = dwc3_probe, > .remove = __devexit_p(dwc3_remove), > .driver = { > .name = "dwc3", > + .pm = DWC3_PM_OPS, > }, > }; > > -- > 1.7.6.5 > -- balbi
Attachment:
signature.asc
Description: Digital signature