1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include <linux/err.h>
29#include <linux/signal.h>
30
31#include <linux/of.h>
32#include <linux/of_platform.h>
33#include <linux/of_address.h>
34#include <linux/of_irq.h>
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50static int ehci_xilinx_port_handed_over(struct usb_hcd *hcd, int portnum)
51{
52 dev_warn(hcd->self.controller, "port %d cannot be enabled\n", portnum);
53 if (hcd->has_tt) {
54 dev_warn(hcd->self.controller,
55 "Maybe you have connected a low speed device?\n");
56
57 dev_warn(hcd->self.controller,
58 "We do not support low speed devices\n");
59 } else {
60 dev_warn(hcd->self.controller,
61 "Maybe your device is not a high speed device?\n");
62 dev_warn(hcd->self.controller,
63 "The USB host controller does not support full speed "
64 "nor low speed devices\n");
65 dev_warn(hcd->self.controller,
66 "You can reconfigure the host controller to have "
67 "full speed support\n");
68 }
69
70 return 0;
71}
72
73
74static const struct hc_driver ehci_xilinx_of_hc_driver = {
75 .description = hcd_name,
76 .product_desc = "OF EHCI",
77 .hcd_priv_size = sizeof(struct ehci_hcd),
78
79
80
81
82 .irq = ehci_irq,
83 .flags = HCD_MEMORY | HCD_USB2 | HCD_BH,
84
85
86
87
88 .reset = ehci_setup,
89 .start = ehci_run,
90 .stop = ehci_stop,
91 .shutdown = ehci_shutdown,
92
93
94
95
96 .urb_enqueue = ehci_urb_enqueue,
97 .urb_dequeue = ehci_urb_dequeue,
98 .endpoint_disable = ehci_endpoint_disable,
99 .endpoint_reset = ehci_endpoint_reset,
100
101
102
103
104 .get_frame_number = ehci_get_frame,
105
106
107
108
109 .hub_status_data = ehci_hub_status_data,
110 .hub_control = ehci_hub_control,
111#ifdef CONFIG_PM
112 .bus_suspend = ehci_bus_suspend,
113 .bus_resume = ehci_bus_resume,
114#endif
115 .relinquish_port = NULL,
116 .port_handed_over = ehci_xilinx_port_handed_over,
117
118 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
119};
120
121
122
123
124
125
126
127
128
129
130static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
131{
132 struct device_node *dn = op->dev.of_node;
133 struct usb_hcd *hcd;
134 struct ehci_hcd *ehci;
135 struct resource res;
136 int irq;
137 int rv;
138 int *value;
139
140 if (usb_disabled())
141 return -ENODEV;
142
143 dev_dbg(&op->dev, "initializing XILINX-OF USB Controller\n");
144
145 rv = of_address_to_resource(dn, 0, &res);
146 if (rv)
147 return rv;
148
149 hcd = usb_create_hcd(&ehci_xilinx_of_hc_driver, &op->dev,
150 "XILINX-OF USB");
151 if (!hcd)
152 return -ENOMEM;
153
154 hcd->rsrc_start = res.start;
155 hcd->rsrc_len = resource_size(&res);
156
157 irq = irq_of_parse_and_map(dn, 0);
158 if (!irq) {
159 dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
160 __FILE__);
161 rv = -EBUSY;
162 goto err_irq;
163 }
164
165 hcd->regs = devm_ioremap_resource(&op->dev, &res);
166 if (IS_ERR(hcd->regs)) {
167 rv = PTR_ERR(hcd->regs);
168 goto err_irq;
169 }
170
171 ehci = hcd_to_ehci(hcd);
172
173
174
175
176 ehci->big_endian_mmio = 1;
177 ehci->big_endian_desc = 1;
178
179
180
181 value = (int *)of_get_property(dn, "xlnx,support-usb-fs", NULL);
182 if (value && (*value == 1)) {
183 ehci_dbg(ehci, "USB host controller supports FS devices\n");
184 hcd->has_tt = 1;
185 } else {
186 ehci_dbg(ehci,
187 "USB host controller is HS only\n");
188 hcd->has_tt = 0;
189 }
190
191
192
193 ehci->caps = hcd->regs + 0x100;
194
195 rv = usb_add_hcd(hcd, irq, 0);
196 if (rv == 0) {
197 device_wakeup_enable(hcd->self.controller);
198 return 0;
199 }
200
201err_irq:
202 usb_put_hcd(hcd);
203
204 return rv;
205}
206
207
208
209
210
211
212
213
214static int ehci_hcd_xilinx_of_remove(struct platform_device *op)
215{
216 struct usb_hcd *hcd = platform_get_drvdata(op);
217
218 dev_dbg(&op->dev, "stopping XILINX-OF USB Controller\n");
219
220 usb_remove_hcd(hcd);
221
222 usb_put_hcd(hcd);
223
224 return 0;
225}
226
227static const struct of_device_id ehci_hcd_xilinx_of_match[] = {
228 {.compatible = "xlnx,xps-usb-host-1.00.a",},
229 {},
230};
231MODULE_DEVICE_TABLE(of, ehci_hcd_xilinx_of_match);
232
233static struct platform_driver ehci_hcd_xilinx_of_driver = {
234 .probe = ehci_hcd_xilinx_of_probe,
235 .remove = ehci_hcd_xilinx_of_remove,
236 .shutdown = usb_hcd_platform_shutdown,
237 .driver = {
238 .name = "xilinx-of-ehci",
239 .of_match_table = ehci_hcd_xilinx_of_match,
240 },
241};
242