kernel/3.18: update to version 3.18.25
[openwrt/openwrt.git] / target / linux / sunxi / patches-4.4 / 144-usb-ehci-plat-support-multiple-reset-ctrllines.patch
1 From 957e8f96c67052ca843ea9ffc5223662b973e5de Mon Sep 17 00:00:00 2001
2 From: Reinder de Haan <patchesrdh@mveas.com>
3 Date: Sun, 15 Nov 2015 14:24:46 +0100
4 Subject: [PATCH] ehci-platform: Add support for controllers with multiple
5 reset lines
6
7 At least the EHCI/OHCI found on the Allwinnner H3 SoC needs multiple
8 reset lines, the controller will not initialize while the reset for
9 its companion is still asserted, which means we need to de-assert
10 2 resets for the controller to work.
11
12 Signed-off-by: Reinder de Haan <patchesrdh@mveas.com>
13 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
14 ---
15 Changes in v2:
16 -Use the new reset_control_[de]assert_shared reset-controller functions
17 ---
18 Documentation/devicetree/bindings/usb/usb-ehci.txt | 2 +-
19 drivers/usb/host/ehci-platform.c | 47 +++++++++++++---------
20 2 files changed, 30 insertions(+), 19 deletions(-)
21
22 --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt
23 +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt
24 @@ -18,7 +18,7 @@ Optional properties:
25 - clocks : a list of phandle + clock specifier pairs
26 - phys : phandle + phy specifier pair
27 - phy-names : "usb"
28 - - resets : phandle + reset specifier pair
29 + - resets : a list of phandle + reset specifier pairs
30
31 Example (Sequoia 440EPx):
32 ehci@e0000300 {
33 --- a/drivers/usb/host/ehci-platform.c
34 +++ b/drivers/usb/host/ehci-platform.c
35 @@ -39,11 +39,12 @@
36
37 #define DRIVER_DESC "EHCI generic platform driver"
38 #define EHCI_MAX_CLKS 3
39 +#define EHCI_MAX_RESETS 2
40 #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv)
41
42 struct ehci_platform_priv {
43 struct clk *clks[EHCI_MAX_CLKS];
44 - struct reset_control *rst;
45 + struct reset_control *resets[EHCI_MAX_RESETS];
46 struct phy **phys;
47 int num_phys;
48 bool reset_on_resume;
49 @@ -149,7 +150,7 @@ static int ehci_platform_probe(struct pl
50 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
51 struct ehci_platform_priv *priv;
52 struct ehci_hcd *ehci;
53 - int err, irq, phy_num, clk = 0;
54 + int err, irq, phy_num, clk = 0, rst = 0;
55
56 if (usb_disabled())
57 return -ENODEV;
58 @@ -232,18 +233,24 @@ static int ehci_platform_probe(struct pl
59 break;
60 }
61 }
62 - }
63
64 - priv->rst = devm_reset_control_get_optional(&dev->dev, NULL);
65 - if (IS_ERR(priv->rst)) {
66 - err = PTR_ERR(priv->rst);
67 - if (err == -EPROBE_DEFER)
68 - goto err_put_clks;
69 - priv->rst = NULL;
70 - } else {
71 - err = reset_control_deassert(priv->rst);
72 - if (err)
73 - goto err_put_clks;
74 + for (rst = 0; rst < EHCI_MAX_RESETS; rst++) {
75 + priv->resets[rst] =
76 + of_reset_control_get_by_index(dev->dev.of_node,
77 + rst);
78 + if (IS_ERR(priv->resets[rst])) {
79 + err = PTR_ERR(priv->resets[rst]);
80 + if (err == -EPROBE_DEFER)
81 + goto err_reset;
82 + priv->resets[rst] = NULL;
83 + break;
84 + }
85 + err = reset_control_deassert_shared(priv->resets[rst]);
86 + if (err) {
87 + reset_control_put(priv->resets[rst]);
88 + goto err_reset;
89 + }
90 + }
91 }
92
93 if (pdata->big_endian_desc)
94 @@ -302,8 +309,10 @@ err_power:
95 if (pdata->power_off)
96 pdata->power_off(dev);
97 err_reset:
98 - if (priv->rst)
99 - reset_control_assert(priv->rst);
100 + while (--rst >= 0) {
101 + reset_control_assert_shared(priv->resets[rst]);
102 + reset_control_put(priv->resets[rst]);
103 + }
104 err_put_clks:
105 while (--clk >= 0)
106 clk_put(priv->clks[clk]);
107 @@ -321,15 +330,17 @@ static int ehci_platform_remove(struct p
108 struct usb_hcd *hcd = platform_get_drvdata(dev);
109 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
110 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
111 - int clk;
112 + int clk, rst;
113
114 usb_remove_hcd(hcd);
115
116 if (pdata->power_off)
117 pdata->power_off(dev);
118
119 - if (priv->rst)
120 - reset_control_assert(priv->rst);
121 + for (rst = 0; rst < EHCI_MAX_RESETS && priv->resets[rst]; rst++) {
122 + reset_control_assert_shared(priv->resets[rst]);
123 + reset_control_put(priv->resets[rst]);
124 + }
125
126 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++)
127 clk_put(priv->clks[clk]);