ralink: update patches
[openwrt/svn-archive/archive.git] / target / linux / ramips / patches-3.8 / 0080-MIPS-add-ohci-ehci-support.patch
1 From ec6f3aa022ef6e61f6ca80c6e30610d879654466 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 20 Jun 2013 23:33:05 +0200
4 Subject: [PATCH] MIPS: add ohci/ehci support
5
6 Signed-off-by: John Crsipin <blogic@openwrt.org>
7 ---
8 arch/mips/ralink/Kconfig | 2 ++
9 drivers/usb/Makefile | 3 ++-
10 drivers/usb/host/ehci-platform.c | 43 ++++++++++++++++++++++++++++++++------
11 drivers/usb/host/ohci-platform.c | 37 +++++++++++++++++++++++++++-----
12 4 files changed, 73 insertions(+), 12 deletions(-)
13
14 diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig
15 index c8d5b6c..7cd1188 100644
16 --- a/arch/mips/ralink/Kconfig
17 +++ b/arch/mips/ralink/Kconfig
18 @@ -27,6 +27,8 @@ choice
19 bool "MT7620"
20 select CLKEVT_RT3352
21 select HW_HAS_PCI
22 + select USB_ARCH_HAS_OHCI
23 + select USB_ARCH_HAS_EHCI
24
25 endchoice
26
27 diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
28 index f5ed3d7..41a4741 100644
29 --- a/drivers/usb/Makefile
30 +++ b/drivers/usb/Makefile
31 @@ -12,6 +12,8 @@ obj-$(CONFIG_USB_DWC3) += dwc3/
32
33 obj-$(CONFIG_USB_MON) += mon/
34
35 +obj-$(CONFIG_USB_COMMON) += phy/
36 +
37 obj-$(CONFIG_PCI) += host/
38 obj-$(CONFIG_USB_EHCI_HCD) += host/
39 obj-$(CONFIG_USB_ISP116X_HCD) += host/
40 @@ -46,7 +48,6 @@ obj-$(CONFIG_USB_MICROTEK) += image/
41 obj-$(CONFIG_USB_SERIAL) += serial/
42
43 obj-$(CONFIG_USB) += misc/
44 -obj-$(CONFIG_USB_COMMON) += phy/
45 obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
46
47 obj-$(CONFIG_USB_ATM) += atm/
48 diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
49 index 58fa0c9..0050df7 100644
50 --- a/drivers/usb/host/ehci-platform.c
51 +++ b/drivers/usb/host/ehci-platform.c
52 @@ -23,6 +23,10 @@
53 #include <linux/io.h>
54 #include <linux/module.h>
55 #include <linux/platform_device.h>
56 +#include <linux/dma-mapping.h>
57 +#include <linux/of.h>
58 +#include <linux/usb/otg.h>
59 +#include <linux/usb/phy.h>
60 #include <linux/usb.h>
61 #include <linux/usb/hcd.h>
62 #include <linux/usb/ehci_pdriver.h>
63 @@ -61,22 +65,40 @@ static const struct ehci_driver_overrides platform_overrides __initdata = {
64 .reset = ehci_platform_reset,
65 };
66
67 +static struct usb_ehci_pdata ehci_platform_defaults;
68 +
69 static int ehci_platform_probe(struct platform_device *dev)
70 {
71 struct usb_hcd *hcd;
72 struct resource *res_mem;
73 - struct usb_ehci_pdata *pdata = dev->dev.platform_data;
74 + struct usb_ehci_pdata *pdata;
75 int irq;
76 int err = -ENOMEM;
77
78 - if (!pdata) {
79 - WARN_ON(1);
80 - return -ENODEV;
81 - }
82 -
83 if (usb_disabled())
84 return -ENODEV;
85
86 + /*
87 + * use reasonable defaults so platforms don't have to provide these.
88 + * with DT probing on ARM, none of these are set.
89 + */
90 + if (!dev->dev.platform_data)
91 + dev->dev.platform_data = &ehci_platform_defaults;
92 + if (!dev->dev.dma_mask)
93 + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
94 + if (!dev->dev.coherent_dma_mask)
95 + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
96 +
97 + pdata = dev->dev.platform_data;
98 +
99 +#ifdef CONFIG_USB_COMMON
100 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
101 + if (!IS_ERR_OR_NULL(hcd->phy)) {
102 + otg_set_host(hcd->phy->otg,
103 + &hcd->self);
104 + usb_phy_init(hcd->phy);
105 + }
106 +#endif
107 irq = platform_get_irq(dev, 0);
108 if (irq < 0) {
109 dev_err(&dev->dev, "no irq provided");
110 @@ -138,6 +160,9 @@ static int ehci_platform_remove(struct platform_device *dev)
111 if (pdata->power_off)
112 pdata->power_off(dev);
113
114 + if (pdata == &ehci_platform_defaults)
115 + dev->dev.platform_data = NULL;
116 +
117 return 0;
118 }
119
120 @@ -182,6 +207,11 @@ static int ehci_platform_resume(struct device *dev)
121 #define ehci_platform_resume NULL
122 #endif /* CONFIG_PM */
123
124 +static const struct of_device_id ralink_ehci_ids[] = {
125 + { .compatible = "ralink,rt3xxx-ehci", },
126 + {}
127 +};
128 +
129 static const struct platform_device_id ehci_platform_table[] = {
130 { "ehci-platform", 0 },
131 { }
132 @@ -202,6 +232,7 @@ static struct platform_driver ehci_platform_driver = {
133 .owner = THIS_MODULE,
134 .name = "ehci-platform",
135 .pm = &ehci_platform_pm_ops,
136 + .of_match_table = of_match_ptr(ralink_ehci_ids),
137 }
138 };
139
140 diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
141 index 084503b..3a60f96 100644
142 --- a/drivers/usb/host/ohci-platform.c
143 +++ b/drivers/usb/host/ohci-platform.c
144 @@ -15,6 +15,10 @@
145 */
146 #include <linux/platform_device.h>
147 #include <linux/usb/ohci_pdriver.h>
148 +#include <linux/dma-mapping.h>
149 +#include <linux/of.h>
150 +
151 +static struct usb_ohci_pdata ohci_platform_defaults;
152
153 static int ohci_platform_reset(struct usb_hcd *hcd)
154 {
155 @@ -87,14 +91,22 @@ static int ohci_platform_probe(struct platform_device *dev)
156 {
157 struct usb_hcd *hcd;
158 struct resource *res_mem;
159 - struct usb_ohci_pdata *pdata = dev->dev.platform_data;
160 + struct usb_ohci_pdata *pdata;
161 int irq;
162 int err = -ENOMEM;
163
164 - if (!pdata) {
165 - WARN_ON(1);
166 - return -ENODEV;
167 - }
168 + /*
169 + * use reasonable defaults so platforms don't have to provide these.
170 + * with DT probing on ARM, none of these are set.
171 + */
172 + if (!dev->dev.platform_data)
173 + dev->dev.platform_data = &ohci_platform_defaults;
174 + if (!dev->dev.dma_mask)
175 + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
176 + if (!dev->dev.coherent_dma_mask)
177 + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
178 +
179 + pdata = dev->dev.platform_data;
180
181 if (usb_disabled())
182 return -ENODEV;
183 @@ -124,6 +136,12 @@ static int ohci_platform_probe(struct platform_device *dev)
184 goto err_power;
185 }
186
187 +#ifdef CONFIG_USB_COMMON
188 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
189 + if (!IS_ERR_OR_NULL(hcd->phy))
190 + usb_phy_init(hcd->phy);
191 +#endif
192 +
193 hcd->rsrc_start = res_mem->start;
194 hcd->rsrc_len = resource_size(res_mem);
195
196 @@ -161,6 +179,9 @@ static int ohci_platform_remove(struct platform_device *dev)
197 if (pdata->power_off)
198 pdata->power_off(dev);
199
200 + if (pdata == &ohci_platform_defaults)
201 + dev->dev.platform_data = NULL;
202 +
203 return 0;
204 }
205
206 @@ -200,6 +221,11 @@ static int ohci_platform_resume(struct device *dev)
207 #define ohci_platform_resume NULL
208 #endif /* CONFIG_PM */
209
210 +static const struct of_device_id ralink_ohci_ids[] = {
211 + { .compatible = "ralink,rt3xxx-ohci", },
212 + {}
213 +};
214 +
215 static const struct platform_device_id ohci_platform_table[] = {
216 { "ohci-platform", 0 },
217 { }
218 @@ -220,5 +246,6 @@ static struct platform_driver ohci_platform_driver = {
219 .owner = THIS_MODULE,
220 .name = "ohci-platform",
221 .pm = &ohci_platform_pm_ops,
222 + .of_match_table = of_match_ptr(ralink_ohci_ids),
223 }
224 };
225 --
226 1.7.10.4
227