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