ralink: add 3.14 support
[openwrt.git] / target / linux / ramips / patches-3.14 / 0038-USB-add-OHCI-EHCI-OF-binding.patch
1 From ffb27de4760595c356ef619c97f25722c8db28e7 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 27 Jul 2014 09:49:07 +0100
4 Subject: [PATCH 38/57] USB: add OHCI/EHCI OF binding
5
6 based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 ---
10  drivers/usb/Makefile             |    3 ++-
11  drivers/usb/host/ehci-platform.c |   21 +++++++++++++++++----
12  drivers/usb/host/ohci-platform.c |   37 +++++++++++++++++++++++++++++++------
13  3 files changed, 50 insertions(+), 11 deletions(-)
14
15 diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
16 index 1ae2bf3..aaa15d9 100644
17 --- a/drivers/usb/Makefile
18 +++ b/drivers/usb/Makefile
19 @@ -11,6 +11,8 @@ obj-$(CONFIG_USB_DWC2)                += dwc2/
20  
21  obj-$(CONFIG_USB_MON)          += mon/
22  
23 +obj-$(CONFIG_USB_PHY)          += phy/
24 +
25  obj-$(CONFIG_PCI)              += host/
26  obj-$(CONFIG_USB_EHCI_HCD)     += host/
27  obj-$(CONFIG_USB_ISP116X_HCD)  += host/
28 @@ -41,7 +43,6 @@ obj-$(CONFIG_USB_TMC)         += class/
29  obj-$(CONFIG_USB_STORAGE)      += storage/
30  obj-$(CONFIG_USB)              += storage/
31  
32 -obj-$(CONFIG_USB_MDC800)       += image/
33  obj-$(CONFIG_USB_MICROTEK)     += image/
34  
35  obj-$(CONFIG_USB_SERIAL)       += serial/
36 diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
37 index 01536cf..1b9a8f4 100644
38 --- a/drivers/usb/host/ehci-platform.c
39 +++ b/drivers/usb/host/ehci-platform.c
40 @@ -29,6 +29,8 @@
41  #include <linux/usb.h>
42  #include <linux/usb/hcd.h>
43  #include <linux/usb/ehci_pdriver.h>
44 +#include <linux/usb/phy.h>
45 +#include <linux/usb/otg.h>
46  
47  #include "ehci.h"
48  
49 @@ -123,6 +125,15 @@ static int ehci_platform_probe(struct platform_device *dev)
50         hcd->rsrc_start = res_mem->start;
51         hcd->rsrc_len = resource_size(res_mem);
52  
53 +#ifdef CONFIG_USB_PHY
54 +       hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
55 +       if (!IS_ERR_OR_NULL(hcd->phy)) {
56 +               otg_set_host(hcd->phy->otg,
57 +                               &hcd->self);
58 +               usb_phy_init(hcd->phy);
59 +       }
60 +#endif
61 +
62         hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
63         if (IS_ERR(hcd->regs)) {
64                 err = PTR_ERR(hcd->regs);
65 @@ -160,6 +171,9 @@ static int ehci_platform_remove(struct platform_device *dev)
66         if (pdata == &ehci_platform_defaults)
67                 dev->dev.platform_data = NULL;
68  
69 +       if (pdata == &ehci_platform_defaults)
70 +               dev->dev.platform_data = NULL;
71 +
72         return 0;
73  }
74  
75 @@ -204,9 +218,8 @@ static int ehci_platform_resume(struct device *dev)
76  #define ehci_platform_resume   NULL
77  #endif /* CONFIG_PM */
78  
79 -static const struct of_device_id vt8500_ehci_ids[] = {
80 -       { .compatible = "via,vt8500-ehci", },
81 -       { .compatible = "wm,prizm-ehci", },
82 +static const struct of_device_id ralink_ehci_ids[] = {
83 +       { .compatible = "ralink,rt3xxx-ehci", },
84         {}
85  };
86  
87 @@ -230,7 +243,7 @@ static struct platform_driver ehci_platform_driver = {
88                 .owner  = THIS_MODULE,
89                 .name   = "ehci-platform",
90                 .pm     = &ehci_platform_pm_ops,
91 -               .of_match_table = vt8500_ehci_ids,
92 +               .of_match_table = ralink_ehci_ids,
93         }
94  };
95  
96 diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
97 index 68f674c..2a73fed 100644
98 --- a/drivers/usb/host/ohci-platform.c
99 +++ b/drivers/usb/host/ohci-platform.c
100 @@ -23,17 +23,20 @@
101  #include <linux/usb/ohci_pdriver.h>
102  #include <linux/usb.h>
103  #include <linux/usb/hcd.h>
104 +#include <linux/dma-mapping.h>
105 +#include <linux/of.h>
106  
107  #include "ohci.h"
108  
109  #define DRIVER_DESC "OHCI generic platform driver"
110  
111 +static struct usb_ohci_pdata ohci_platform_defaults;
112  static const char hcd_name[] = "ohci-platform";
113  
114  static int ohci_platform_reset(struct usb_hcd *hcd)
115  {
116         struct platform_device *pdev = to_platform_device(hcd->self.controller);
117 -       struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev);
118 +       struct usb_ohci_pdata *pdata;
119         struct ohci_hcd *ohci = hcd_to_ohci(hcd);
120  
121         if (pdata->big_endian_desc)
122 @@ -63,11 +66,18 @@ static int ohci_platform_probe(struct platform_device *dev)
123         int irq;
124         int err = -ENOMEM;
125  
126 -       if (!pdata) {
127 -               WARN_ON(1);
128 -               return -ENODEV;
129 -       }
130 -
131 +       /*
132 +        * use reasonable defaults so platforms don't have to provide these.
133 +        * with DT probing on ARM, none of these are set.
134 +        */
135 +       if (!dev->dev.platform_data)
136 +               dev->dev.platform_data = &ohci_platform_defaults;
137 +       if (!dev->dev.dma_mask)
138 +               dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
139 +       if (!dev->dev.coherent_dma_mask)
140 +               dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
141 +
142 +       pdata = dev->dev.platform_data;
143         if (usb_disabled())
144                 return -ENODEV;
145  
146 @@ -99,6 +109,12 @@ static int ohci_platform_probe(struct platform_device *dev)
147         hcd->rsrc_start = res_mem->start;
148         hcd->rsrc_len = resource_size(res_mem);
149  
150 +#ifdef CONFIG_USB_PHY
151 +       hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
152 +       if (!IS_ERR_OR_NULL(hcd->phy))
153 +               usb_phy_init(hcd->phy);
154 +#endif
155 +
156         hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
157         if (IS_ERR(hcd->regs)) {
158                 err = PTR_ERR(hcd->regs);
159 @@ -134,6 +150,9 @@ static int ohci_platform_remove(struct platform_device *dev)
160         if (pdata->power_off)
161                 pdata->power_off(dev);
162  
163 +       if (pdata == &ohci_platform_defaults)
164 +               dev->dev.platform_data = NULL;
165 +
166         return 0;
167  }
168  
169 @@ -180,6 +199,11 @@ static int ohci_platform_resume(struct device *dev)
170  #define ohci_platform_resume   NULL
171  #endif /* CONFIG_PM */
172  
173 +static const struct of_device_id ralink_ohci_ids[] = {
174 +       { .compatible = "ralink,rt3xxx-ohci", },
175 +       {}
176 +};
177 +
178  static const struct platform_device_id ohci_platform_table[] = {
179         { "ohci-platform", 0 },
180         { }
181 @@ -200,6 +224,7 @@ static struct platform_driver ohci_platform_driver = {
182                 .owner  = THIS_MODULE,
183                 .name   = "ohci-platform",
184                 .pm     = &ohci_platform_pm_ops,
185 +               .of_match_table = of_match_ptr(ralink_ohci_ids),
186         }
187  };
188  
189 -- 
190 1.7.10.4
191