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
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.
12 Signed-off-by: Reinder de Haan <patchesrdh@mveas.com>
13 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
16 -Use the new reset_control_[de]assert_shared reset-controller functions
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(-)
22 diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt b/Documentation/devicetree/bindings/usb/usb-ehci.txt
23 index a12d601..0701812 100644
24 --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt
25 +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt
26 @@ -18,7 +18,7 @@ Optional properties:
27 - clocks : a list of phandle + clock specifier pairs
28 - phys : phandle + phy specifier pair
30 - - resets : phandle + reset specifier pair
31 + - resets : a list of phandle + reset specifier pairs
33 Example (Sequoia 440EPx):
35 diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
36 index bd7082f2..6fbf32a 100644
37 --- a/drivers/usb/host/ehci-platform.c
38 +++ b/drivers/usb/host/ehci-platform.c
41 #define DRIVER_DESC "EHCI generic platform driver"
42 #define EHCI_MAX_CLKS 3
43 +#define EHCI_MAX_RESETS 2
44 #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv)
46 struct ehci_platform_priv {
47 struct clk *clks[EHCI_MAX_CLKS];
48 - struct reset_control *rst;
49 + struct reset_control *resets[EHCI_MAX_RESETS];
53 @@ -149,7 +150,7 @@ static int ehci_platform_probe(struct platform_device *dev)
54 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
55 struct ehci_platform_priv *priv;
56 struct ehci_hcd *ehci;
57 - int err, irq, phy_num, clk = 0;
58 + int err, irq, phy_num, clk = 0, rst = 0;
62 @@ -232,18 +233,24 @@ static int ehci_platform_probe(struct platform_device *dev)
68 - priv->rst = devm_reset_control_get_optional(&dev->dev, NULL);
69 - if (IS_ERR(priv->rst)) {
70 - err = PTR_ERR(priv->rst);
71 - if (err == -EPROBE_DEFER)
75 - err = reset_control_deassert(priv->rst);
78 + for (rst = 0; rst < EHCI_MAX_RESETS; rst++) {
80 + of_reset_control_get_by_index(dev->dev.of_node,
82 + if (IS_ERR(priv->resets[rst])) {
83 + err = PTR_ERR(priv->resets[rst]);
84 + if (err == -EPROBE_DEFER)
86 + priv->resets[rst] = NULL;
89 + err = reset_control_deassert_shared(priv->resets[rst]);
91 + reset_control_put(priv->resets[rst]);
97 if (pdata->big_endian_desc)
98 @@ -300,8 +307,10 @@ static int ehci_platform_probe(struct platform_device *dev)
100 pdata->power_off(dev);
103 - reset_control_assert(priv->rst);
104 + while (--rst >= 0) {
105 + reset_control_assert_shared(priv->resets[rst]);
106 + reset_control_put(priv->resets[rst]);
110 clk_put(priv->clks[clk]);
111 @@ -319,15 +328,17 @@ static int ehci_platform_remove(struct platform_device *dev)
112 struct usb_hcd *hcd = platform_get_drvdata(dev);
113 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
114 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
120 if (pdata->power_off)
121 pdata->power_off(dev);
124 - reset_control_assert(priv->rst);
125 + for (rst = 0; rst < EHCI_MAX_RESETS && priv->resets[rst]; rst++) {
126 + reset_control_assert_shared(priv->resets[rst]);
127 + reset_control_put(priv->resets[rst]);
130 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++)
131 clk_put(priv->clks[clk]);