ipq806x: switch to upstream usb driver and backport fixes
[openwrt/staging/wigyori.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 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
19 index fa20f5a9..34277ce 100644
20 --- a/drivers/usb/dwc3/core.c
21 +++ b/drivers/usb/dwc3/core.c
22 @@ -1150,6 +1150,11 @@ static int dwc3_suspend(struct device *dev)
23 phy_exit(dwc->usb2_generic_phy);
24 phy_exit(dwc->usb3_generic_phy);
25
26 + usb_phy_set_suspend(dwc->usb2_phy, 1);
27 + usb_phy_set_suspend(dwc->usb3_phy, 1);
28 + WARN_ON(phy_power_off(dwc->usb2_generic_phy) < 0);
29 + WARN_ON(phy_power_off(dwc->usb3_generic_phy) < 0);
30 +
31 pinctrl_pm_select_sleep_state(dev);
32
33 return 0;
34 @@ -1163,11 +1168,21 @@ static int dwc3_resume(struct device *dev)
35
36 pinctrl_pm_select_default_state(dev);
37
38 + usb_phy_set_suspend(dwc->usb2_phy, 0);
39 + usb_phy_set_suspend(dwc->usb3_phy, 0);
40 + ret = phy_power_on(dwc->usb2_generic_phy);
41 + if (ret < 0)
42 + return ret;
43 +
44 + ret = phy_power_on(dwc->usb3_generic_phy);
45 + if (ret < 0)
46 + goto err_usb2phy_power;
47 +
48 usb_phy_init(dwc->usb3_phy);
49 usb_phy_init(dwc->usb2_phy);
50 ret = phy_init(dwc->usb2_generic_phy);
51 if (ret < 0)
52 - return ret;
53 + goto err_usb3phy_power;
54
55 ret = phy_init(dwc->usb3_generic_phy);
56 if (ret < 0)
57 @@ -1200,6 +1215,12 @@ static int dwc3_resume(struct device *dev)
58 err_usb2phy_init:
59 phy_exit(dwc->usb2_generic_phy);
60
61 +err_usb3phy_power:
62 + phy_power_off(dwc->usb3_generic_phy);
63 +
64 +err_usb2phy_power:
65 + phy_power_off(dwc->usb2_generic_phy);
66 +
67 return ret;
68 }
69
70 --
71 cgit v0.12