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 --- 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
28 - - resets : phandle + reset specifier pair
29 + - resets : a list of phandle + reset specifier pairs
31 Example (Sequoia 440EPx):
33 --- a/drivers/usb/host/ehci-platform.c
34 +++ b/drivers/usb/host/ehci-platform.c
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)
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];
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;
58 @@ -232,18 +233,24 @@ static int ehci_platform_probe(struct pl
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)
71 - err = reset_control_deassert(priv->rst);
74 + for (rst = 0; rst < EHCI_MAX_RESETS; rst++) {
76 + of_reset_control_get_by_index(dev->dev.of_node,
78 + if (IS_ERR(priv->resets[rst])) {
79 + err = PTR_ERR(priv->resets[rst]);
80 + if (err == -EPROBE_DEFER)
82 + priv->resets[rst] = NULL;
85 + err = reset_control_deassert_shared(priv->resets[rst]);
87 + reset_control_put(priv->resets[rst]);
93 if (pdata->big_endian_desc)
94 @@ -302,8 +309,10 @@ err_power:
96 pdata->power_off(dev);
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]);
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);
116 if (pdata->power_off)
117 pdata->power_off(dev);
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]);
126 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++)
127 clk_put(priv->clks[clk]);