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