096-10-usb-dwc3-core-fix-PHY-handling-during-suspend.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From 5c4ad318de3b8e8680d654c82a254c4b65243739 Mon Sep 17 00:00:00 2001
  2. From: Felipe Balbi <balbi@kernel.org>
  3. Date: Mon, 11 Apr 2016 17:12:34 +0300
  4. Subject: usb: dwc3: core: fix PHY handling during suspend
  5. we need to power off the PHY during suspend and
  6. power it back on during resume.
  7. Signed-off-by: Felipe Balbi <balbi@kernel.org>
  8. [nsekhar@ti.com: fix call to usb_phy_set_suspend() in dwc3_suspend()]
  9. Signed-off-by: Sekhar Nori <nsekhar@ti.com>
  10. Signed-off-by: Roger Quadros <rogerq@ti.com>
  11. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  12. ---
  13. drivers/usb/dwc3/core.c | 23 ++++++++++++++++++++++-
  14. 1 file changed, 22 insertions(+), 1 deletion(-)
  15. --- a/drivers/usb/dwc3/core.c
  16. +++ b/drivers/usb/dwc3/core.c
  17. @@ -1124,6 +1124,11 @@ static int dwc3_suspend(struct device *d
  18. phy_exit(dwc->usb2_generic_phy);
  19. phy_exit(dwc->usb3_generic_phy);
  20. + usb_phy_set_suspend(dwc->usb2_phy, 1);
  21. + usb_phy_set_suspend(dwc->usb3_phy, 1);
  22. + WARN_ON(phy_power_off(dwc->usb2_generic_phy) < 0);
  23. + WARN_ON(phy_power_off(dwc->usb3_generic_phy) < 0);
  24. +
  25. pinctrl_pm_select_sleep_state(dev);
  26. return 0;
  27. @@ -1137,11 +1142,21 @@ static int dwc3_resume(struct device *de
  28. pinctrl_pm_select_default_state(dev);
  29. + usb_phy_set_suspend(dwc->usb2_phy, 0);
  30. + usb_phy_set_suspend(dwc->usb3_phy, 0);
  31. + ret = phy_power_on(dwc->usb2_generic_phy);
  32. + if (ret < 0)
  33. + return ret;
  34. +
  35. + ret = phy_power_on(dwc->usb3_generic_phy);
  36. + if (ret < 0)
  37. + goto err_usb2phy_power;
  38. +
  39. usb_phy_init(dwc->usb3_phy);
  40. usb_phy_init(dwc->usb2_phy);
  41. ret = phy_init(dwc->usb2_generic_phy);
  42. if (ret < 0)
  43. - return ret;
  44. + goto err_usb3phy_power;
  45. ret = phy_init(dwc->usb3_generic_phy);
  46. if (ret < 0)
  47. @@ -1174,6 +1189,12 @@ static int dwc3_resume(struct device *de
  48. err_usb2phy_init:
  49. phy_exit(dwc->usb2_generic_phy);
  50. +err_usb3phy_power:
  51. + phy_power_off(dwc->usb3_generic_phy);
  52. +
  53. +err_usb2phy_power:
  54. + phy_power_off(dwc->usb2_generic_phy);
  55. +
  56. return ret;
  57. }