]>
Commit | Line | Data |
---|---|---|
39a269c0 AV |
1 | /* |
2 | * OHCI HCD (Host Controller Driver) for USB. | |
3 | * | |
4 | * Copyright (C) 2004 SAN People (Pty) Ltd. | |
5 | * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> | |
6 | * | |
0365ee0a | 7 | * AT91 Bus Glue |
39a269c0 AV |
8 | * |
9 | * Based on fragments of 2.4 driver by Rick Bronson. | |
10 | * Based on ohci-omap.c | |
11 | * | |
12 | * This file is licenced under the GPL. | |
13 | */ | |
14 | ||
15 | #include <linux/clk.h> | |
16 | #include <linux/platform_device.h> | |
17 | ||
a09e64fb | 18 | #include <mach/hardware.h> |
4bde4a4c DB |
19 | #include <asm/gpio.h> |
20 | ||
a09e64fb RK |
21 | #include <mach/board.h> |
22 | #include <mach/cpu.h> | |
39a269c0 | 23 | |
0365ee0a DB |
24 | #ifndef CONFIG_ARCH_AT91 |
25 | #error "CONFIG_ARCH_AT91 must be defined." | |
39a269c0 AV |
26 | #endif |
27 | ||
ed077bb7 AV |
28 | /* interface and function clocks; sometimes also an AHB clock */ |
29 | static struct clk *iclk, *fclk, *hclk; | |
0365ee0a | 30 | static int clocked; |
39a269c0 AV |
31 | |
32 | extern int usb_disabled(void); | |
33 | ||
34 | /*-------------------------------------------------------------------------*/ | |
35 | ||
ed077bb7 AV |
36 | static void at91_start_clock(void) |
37 | { | |
0af4316b | 38 | clk_enable(hclk); |
ed077bb7 AV |
39 | clk_enable(iclk); |
40 | clk_enable(fclk); | |
41 | clocked = 1; | |
42 | } | |
43 | ||
44 | static void at91_stop_clock(void) | |
45 | { | |
46 | clk_disable(fclk); | |
47 | clk_disable(iclk); | |
0af4316b | 48 | clk_disable(hclk); |
ed077bb7 AV |
49 | clocked = 0; |
50 | } | |
51 | ||
39a269c0 AV |
52 | static void at91_start_hc(struct platform_device *pdev) |
53 | { | |
54 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | |
55 | struct ohci_regs __iomem *regs = hcd->regs; | |
56 | ||
0365ee0a | 57 | dev_dbg(&pdev->dev, "start\n"); |
39a269c0 AV |
58 | |
59 | /* | |
60 | * Start the USB clocks. | |
61 | */ | |
ed077bb7 | 62 | at91_start_clock(); |
39a269c0 AV |
63 | |
64 | /* | |
65 | * The USB host controller must remain in reset. | |
66 | */ | |
67 | writel(0, ®s->control); | |
68 | } | |
69 | ||
70 | static void at91_stop_hc(struct platform_device *pdev) | |
71 | { | |
72 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | |
73 | struct ohci_regs __iomem *regs = hcd->regs; | |
74 | ||
0365ee0a | 75 | dev_dbg(&pdev->dev, "stop\n"); |
39a269c0 AV |
76 | |
77 | /* | |
78 | * Put the USB host controller into reset. | |
79 | */ | |
80 | writel(0, ®s->control); | |
81 | ||
82 | /* | |
83 | * Stop the USB clocks. | |
84 | */ | |
ed077bb7 | 85 | at91_stop_clock(); |
39a269c0 AV |
86 | } |
87 | ||
88 | ||
89 | /*-------------------------------------------------------------------------*/ | |
90 | ||
421b4bf5 | 91 | static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *); |
39a269c0 AV |
92 | |
93 | /* configure so an HC device and id are always provided */ | |
94 | /* always called with process context; sleeping is OK */ | |
95 | ||
96 | ||
97 | /** | |
0365ee0a | 98 | * usb_hcd_at91_probe - initialize AT91-based HCDs |
39a269c0 AV |
99 | * Context: !in_interrupt() |
100 | * | |
101 | * Allocates basic resources for this USB host controller, and | |
102 | * then invokes the start() method for the HCD associated with it | |
103 | * through the hotplug entry's driver_data. | |
39a269c0 | 104 | */ |
0365ee0a DB |
105 | static int usb_hcd_at91_probe(const struct hc_driver *driver, |
106 | struct platform_device *pdev) | |
39a269c0 AV |
107 | { |
108 | int retval; | |
109 | struct usb_hcd *hcd = NULL; | |
110 | ||
111 | if (pdev->num_resources != 2) { | |
112 | pr_debug("hcd probe: invalid num_resources"); | |
113 | return -ENODEV; | |
114 | } | |
115 | ||
0365ee0a DB |
116 | if ((pdev->resource[0].flags != IORESOURCE_MEM) |
117 | || (pdev->resource[1].flags != IORESOURCE_IRQ)) { | |
39a269c0 AV |
118 | pr_debug("hcd probe: invalid resource type\n"); |
119 | return -ENODEV; | |
120 | } | |
121 | ||
0365ee0a | 122 | hcd = usb_create_hcd(driver, &pdev->dev, "at91"); |
39a269c0 AV |
123 | if (!hcd) |
124 | return -ENOMEM; | |
125 | hcd->rsrc_start = pdev->resource[0].start; | |
126 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | |
127 | ||
128 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | |
129 | pr_debug("request_mem_region failed\n"); | |
130 | retval = -EBUSY; | |
131 | goto err1; | |
132 | } | |
133 | ||
134 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | |
135 | if (!hcd->regs) { | |
136 | pr_debug("ioremap failed\n"); | |
137 | retval = -EIO; | |
138 | goto err2; | |
139 | } | |
140 | ||
141 | iclk = clk_get(&pdev->dev, "ohci_clk"); | |
142 | fclk = clk_get(&pdev->dev, "uhpck"); | |
0af4316b | 143 | hclk = clk_get(&pdev->dev, "hclk"); |
39a269c0 AV |
144 | |
145 | at91_start_hc(pdev); | |
146 | ohci_hcd_init(hcd_to_ohci(hcd)); | |
147 | ||
2f2cac3c | 148 | retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED); |
39a269c0 AV |
149 | if (retval == 0) |
150 | return retval; | |
151 | ||
152 | /* Error handling */ | |
153 | at91_stop_hc(pdev); | |
154 | ||
0af4316b | 155 | clk_put(hclk); |
39a269c0 AV |
156 | clk_put(fclk); |
157 | clk_put(iclk); | |
158 | ||
159 | iounmap(hcd->regs); | |
160 | ||
161 | err2: | |
162 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | |
163 | ||
164 | err1: | |
165 | usb_put_hcd(hcd); | |
166 | return retval; | |
167 | } | |
168 | ||
169 | ||
39a269c0 AV |
170 | /* may be called with controller, bus, and devices active */ |
171 | ||
172 | /** | |
0365ee0a | 173 | * usb_hcd_at91_remove - shutdown processing for AT91-based HCDs |
39a269c0 AV |
174 | * @dev: USB Host Controller being removed |
175 | * Context: !in_interrupt() | |
176 | * | |
177 | * Reverses the effect of usb_hcd_at91_probe(), first invoking | |
178 | * the HCD's stop() method. It is always called from a thread | |
0365ee0a | 179 | * context, "rmmod" or something similar. |
39a269c0 AV |
180 | * |
181 | */ | |
421b4bf5 | 182 | static void usb_hcd_at91_remove(struct usb_hcd *hcd, |
0365ee0a | 183 | struct platform_device *pdev) |
39a269c0 AV |
184 | { |
185 | usb_remove_hcd(hcd); | |
186 | at91_stop_hc(pdev); | |
187 | iounmap(hcd->regs); | |
68ba61b8 | 188 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
421b4bf5 | 189 | usb_put_hcd(hcd); |
39a269c0 | 190 | |
0af4316b | 191 | clk_put(hclk); |
68ba61b8 DB |
192 | clk_put(fclk); |
193 | clk_put(iclk); | |
ed077bb7 | 194 | fclk = iclk = hclk = NULL; |
39a269c0 AV |
195 | |
196 | dev_set_drvdata(&pdev->dev, NULL); | |
39a269c0 AV |
197 | } |
198 | ||
199 | /*-------------------------------------------------------------------------*/ | |
200 | ||
201 | static int __devinit | |
202 | ohci_at91_start (struct usb_hcd *hcd) | |
203 | { | |
0365ee0a | 204 | struct at91_usbh_data *board = hcd->self.controller->platform_data; |
39a269c0 AV |
205 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
206 | int ret; | |
207 | ||
208 | if ((ret = ohci_init(ohci)) < 0) | |
209 | return ret; | |
210 | ||
cd22afda | 211 | ohci->num_ports = board->ports; |
0365ee0a | 212 | |
39a269c0 AV |
213 | if ((ret = ohci_run(ohci)) < 0) { |
214 | err("can't start %s", hcd->self.bus_name); | |
215 | ohci_stop(hcd); | |
216 | return ret; | |
217 | } | |
39a269c0 AV |
218 | return 0; |
219 | } | |
220 | ||
aa6e52a3 TP |
221 | static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable) |
222 | { | |
223 | if (port < 0 || port >= 2) | |
224 | return; | |
225 | ||
8a7a49d1 | 226 | if (!gpio_is_valid(pdata->vbus_pin[port])) |
770f0baa JCPV |
227 | return; |
228 | ||
aa6e52a3 TP |
229 | gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); |
230 | } | |
231 | ||
232 | static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | |
233 | { | |
234 | if (port < 0 || port >= 2) | |
235 | return -EINVAL; | |
236 | ||
8a7a49d1 | 237 | if (!gpio_is_valid(pdata->vbus_pin[port])) |
770f0baa JCPV |
238 | return -EINVAL; |
239 | ||
aa6e52a3 TP |
240 | return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; |
241 | } | |
242 | ||
243 | /* | |
244 | * Update the status data from the hub with the over-current indicator change. | |
245 | */ | |
246 | static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf) | |
247 | { | |
248 | struct at91_usbh_data *pdata = hcd->self.controller->platform_data; | |
249 | int length = ohci_hub_status_data(hcd, buf); | |
250 | int port; | |
251 | ||
252 | for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { | |
253 | if (pdata->overcurrent_changed[port]) { | |
254 | if (! length) | |
255 | length = 1; | |
256 | buf[0] |= 1 << (port + 1); | |
257 | } | |
258 | } | |
259 | ||
260 | return length; | |
261 | } | |
262 | ||
263 | /* | |
264 | * Look at the control requests to the root hub and see if we need to override. | |
265 | */ | |
266 | static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |
267 | u16 wIndex, char *buf, u16 wLength) | |
268 | { | |
269 | struct at91_usbh_data *pdata = hcd->self.controller->platform_data; | |
270 | struct usb_hub_descriptor *desc; | |
271 | int ret = -EINVAL; | |
272 | u32 *data = (u32 *)buf; | |
273 | ||
274 | dev_dbg(hcd->self.controller, | |
275 | "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n", | |
276 | hcd, typeReq, wValue, wIndex, buf, wLength); | |
277 | ||
278 | switch (typeReq) { | |
279 | case SetPortFeature: | |
280 | if (wValue == USB_PORT_FEAT_POWER) { | |
281 | dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n"); | |
282 | ohci_at91_usb_set_power(pdata, wIndex - 1, 1); | |
283 | goto out; | |
284 | } | |
285 | break; | |
286 | ||
287 | case ClearPortFeature: | |
288 | switch (wValue) { | |
289 | case USB_PORT_FEAT_C_OVER_CURRENT: | |
290 | dev_dbg(hcd->self.controller, | |
291 | "ClearPortFeature: C_OVER_CURRENT\n"); | |
292 | ||
293 | if (wIndex == 1 || wIndex == 2) { | |
294 | pdata->overcurrent_changed[wIndex-1] = 0; | |
295 | pdata->overcurrent_status[wIndex-1] = 0; | |
296 | } | |
297 | ||
298 | goto out; | |
299 | ||
300 | case USB_PORT_FEAT_OVER_CURRENT: | |
301 | dev_dbg(hcd->self.controller, | |
302 | "ClearPortFeature: OVER_CURRENT\n"); | |
303 | ||
304 | if (wIndex == 1 || wIndex == 2) { | |
305 | pdata->overcurrent_status[wIndex-1] = 0; | |
306 | } | |
307 | ||
308 | goto out; | |
309 | ||
310 | case USB_PORT_FEAT_POWER: | |
311 | dev_dbg(hcd->self.controller, | |
312 | "ClearPortFeature: POWER\n"); | |
313 | ||
314 | if (wIndex == 1 || wIndex == 2) { | |
315 | ohci_at91_usb_set_power(pdata, wIndex - 1, 0); | |
316 | return 0; | |
317 | } | |
318 | } | |
319 | break; | |
320 | } | |
321 | ||
322 | ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); | |
323 | if (ret) | |
324 | goto out; | |
325 | ||
326 | switch (typeReq) { | |
327 | case GetHubDescriptor: | |
328 | ||
329 | /* update the hub's descriptor */ | |
330 | ||
331 | desc = (struct usb_hub_descriptor *)buf; | |
332 | ||
333 | dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n", | |
334 | desc->wHubCharacteristics); | |
335 | ||
336 | /* remove the old configurations for power-switching, and | |
337 | * over-current protection, and insert our new configuration | |
338 | */ | |
339 | ||
340 | desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM); | |
341 | desc->wHubCharacteristics |= cpu_to_le16(0x0001); | |
342 | ||
343 | if (pdata->overcurrent_supported) { | |
344 | desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM); | |
345 | desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001); | |
346 | } | |
347 | ||
348 | dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n", | |
349 | desc->wHubCharacteristics); | |
350 | ||
351 | return ret; | |
352 | ||
353 | case GetPortStatus: | |
354 | /* check port status */ | |
355 | ||
356 | dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex); | |
357 | ||
358 | if (wIndex == 1 || wIndex == 2) { | |
359 | if (! ohci_at91_usb_get_power(pdata, wIndex-1)) { | |
360 | *data &= ~cpu_to_le32(RH_PS_PPS); | |
361 | } | |
362 | ||
363 | if (pdata->overcurrent_changed[wIndex-1]) { | |
364 | *data |= cpu_to_le32(RH_PS_OCIC); | |
365 | } | |
366 | ||
367 | if (pdata->overcurrent_status[wIndex-1]) { | |
368 | *data |= cpu_to_le32(RH_PS_POCI); | |
369 | } | |
370 | } | |
371 | } | |
372 | ||
373 | out: | |
374 | return ret; | |
375 | } | |
376 | ||
39a269c0 AV |
377 | /*-------------------------------------------------------------------------*/ |
378 | ||
379 | static const struct hc_driver ohci_at91_hc_driver = { | |
380 | .description = hcd_name, | |
0365ee0a | 381 | .product_desc = "AT91 OHCI", |
39a269c0 AV |
382 | .hcd_priv_size = sizeof(struct ohci_hcd), |
383 | ||
384 | /* | |
385 | * generic hardware linkage | |
386 | */ | |
387 | .irq = ohci_irq, | |
388 | .flags = HCD_USB11 | HCD_MEMORY, | |
389 | ||
390 | /* | |
391 | * basic lifecycle operations | |
392 | */ | |
393 | .start = ohci_at91_start, | |
394 | .stop = ohci_stop, | |
dd9048af | 395 | .shutdown = ohci_shutdown, |
39a269c0 AV |
396 | |
397 | /* | |
398 | * managing i/o requests and associated device resources | |
399 | */ | |
400 | .urb_enqueue = ohci_urb_enqueue, | |
401 | .urb_dequeue = ohci_urb_dequeue, | |
402 | .endpoint_disable = ohci_endpoint_disable, | |
403 | ||
404 | /* | |
405 | * scheduling support | |
406 | */ | |
407 | .get_frame_number = ohci_get_frame, | |
408 | ||
409 | /* | |
410 | * root hub support | |
411 | */ | |
aa6e52a3 TP |
412 | .hub_status_data = ohci_at91_hub_status_data, |
413 | .hub_control = ohci_at91_hub_control, | |
39a269c0 | 414 | #ifdef CONFIG_PM |
68ba61b8 DB |
415 | .bus_suspend = ohci_bus_suspend, |
416 | .bus_resume = ohci_bus_resume, | |
39a269c0 AV |
417 | #endif |
418 | .start_port_reset = ohci_start_port_reset, | |
419 | }; | |
420 | ||
421 | /*-------------------------------------------------------------------------*/ | |
422 | ||
aa6e52a3 TP |
423 | static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data) |
424 | { | |
425 | struct platform_device *pdev = data; | |
426 | struct at91_usbh_data *pdata = pdev->dev.platform_data; | |
427 | int val, gpio, port; | |
428 | ||
429 | /* From the GPIO notifying the over-current situation, find | |
430 | * out the corresponding port */ | |
431 | gpio = irq_to_gpio(irq); | |
432 | for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { | |
433 | if (pdata->overcurrent_pin[port] == gpio) | |
434 | break; | |
435 | } | |
436 | ||
437 | if (port == ARRAY_SIZE(pdata->overcurrent_pin)) { | |
438 | dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n"); | |
439 | return IRQ_HANDLED; | |
440 | } | |
441 | ||
442 | val = gpio_get_value(gpio); | |
443 | ||
444 | /* When notified of an over-current situation, disable power | |
445 | on the corresponding port, and mark this port in | |
446 | over-current. */ | |
447 | if (! val) { | |
448 | ohci_at91_usb_set_power(pdata, port, 0); | |
449 | pdata->overcurrent_status[port] = 1; | |
450 | pdata->overcurrent_changed[port] = 1; | |
451 | } | |
452 | ||
453 | dev_dbg(& pdev->dev, "overcurrent situation %s\n", | |
454 | val ? "exited" : "notified"); | |
455 | ||
456 | return IRQ_HANDLED; | |
457 | } | |
458 | ||
459 | /*-------------------------------------------------------------------------*/ | |
460 | ||
0365ee0a | 461 | static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) |
39a269c0 | 462 | { |
4bde4a4c DB |
463 | struct at91_usbh_data *pdata = pdev->dev.platform_data; |
464 | int i; | |
465 | ||
466 | if (pdata) { | |
3d6fdf75 | 467 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { |
8a7a49d1 | 468 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
4bde4a4c DB |
469 | continue; |
470 | gpio_request(pdata->vbus_pin[i], "ohci_vbus"); | |
aa6e52a3 TP |
471 | ohci_at91_usb_set_power(pdata, i, 1); |
472 | } | |
473 | ||
474 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | |
475 | int ret; | |
476 | ||
8a7a49d1 | 477 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
aa6e52a3 TP |
478 | continue; |
479 | gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); | |
480 | ||
481 | ret = request_irq(gpio_to_irq(pdata->overcurrent_pin[i]), | |
482 | ohci_hcd_at91_overcurrent_irq, | |
483 | IRQF_SHARED, "ohci_overcurrent", pdev); | |
484 | if (ret) { | |
485 | gpio_free(pdata->overcurrent_pin[i]); | |
486 | dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n"); | |
487 | } | |
4bde4a4c DB |
488 | } |
489 | } | |
490 | ||
0365ee0a DB |
491 | device_init_wakeup(&pdev->dev, 1); |
492 | return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); | |
39a269c0 AV |
493 | } |
494 | ||
0365ee0a | 495 | static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) |
39a269c0 | 496 | { |
4bde4a4c DB |
497 | struct at91_usbh_data *pdata = pdev->dev.platform_data; |
498 | int i; | |
499 | ||
500 | if (pdata) { | |
3d6fdf75 | 501 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { |
8a7a49d1 | 502 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
4bde4a4c | 503 | continue; |
aa6e52a3 | 504 | ohci_at91_usb_set_power(pdata, i, 0); |
4bde4a4c DB |
505 | gpio_free(pdata->vbus_pin[i]); |
506 | } | |
aa6e52a3 TP |
507 | |
508 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | |
8a7a49d1 | 509 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
aa6e52a3 TP |
510 | continue; |
511 | free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); | |
512 | gpio_free(pdata->overcurrent_pin[i]); | |
513 | } | |
4bde4a4c DB |
514 | } |
515 | ||
0365ee0a | 516 | device_init_wakeup(&pdev->dev, 0); |
421b4bf5 PZ |
517 | usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev); |
518 | return 0; | |
39a269c0 AV |
519 | } |
520 | ||
521 | #ifdef CONFIG_PM | |
39a269c0 | 522 | |
68ba61b8 | 523 | static int |
0365ee0a | 524 | ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) |
68ba61b8 | 525 | { |
0365ee0a DB |
526 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
527 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | |
528 | ||
529 | if (device_may_wakeup(&pdev->dev)) | |
530 | enable_irq_wake(hcd->irq); | |
0365ee0a DB |
531 | |
532 | /* | |
533 | * The integrated transceivers seem unable to notice disconnect, | |
534 | * reconnect, or wakeup without the 48 MHz clock active. so for | |
535 | * correctness, always discard connection state (using reset). | |
536 | * | |
537 | * REVISIT: some boards will be able to turn VBUS off... | |
538 | */ | |
539 | if (at91_suspend_entering_slow_clock()) { | |
540 | ohci_usb_reset (ohci); | |
869aa98c PV |
541 | /* flush the writes */ |
542 | (void) ohci_readl (ohci, &ohci->regs->control); | |
ed077bb7 | 543 | at91_stop_clock(); |
0365ee0a | 544 | } |
39a269c0 AV |
545 | |
546 | return 0; | |
547 | } | |
548 | ||
0365ee0a | 549 | static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) |
39a269c0 | 550 | { |
6dde896e MP |
551 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
552 | ||
553 | if (device_may_wakeup(&pdev->dev)) | |
554 | disable_irq_wake(hcd->irq); | |
555 | ||
ed077bb7 AV |
556 | if (!clocked) |
557 | at91_start_clock(); | |
39a269c0 | 558 | |
43bbb7e0 | 559 | ohci_finish_controller_resume(hcd); |
39a269c0 AV |
560 | return 0; |
561 | } | |
562 | #else | |
563 | #define ohci_hcd_at91_drv_suspend NULL | |
564 | #define ohci_hcd_at91_drv_resume NULL | |
565 | #endif | |
566 | ||
f4fce61d | 567 | MODULE_ALIAS("platform:at91_ohci"); |
68ba61b8 | 568 | |
39a269c0 AV |
569 | static struct platform_driver ohci_hcd_at91_driver = { |
570 | .probe = ohci_hcd_at91_drv_probe, | |
571 | .remove = ohci_hcd_at91_drv_remove, | |
64a21d02 | 572 | .shutdown = usb_hcd_platform_shutdown, |
39a269c0 AV |
573 | .suspend = ohci_hcd_at91_drv_suspend, |
574 | .resume = ohci_hcd_at91_drv_resume, | |
575 | .driver = { | |
0365ee0a | 576 | .name = "at91_ohci", |
39a269c0 AV |
577 | .owner = THIS_MODULE, |
578 | }, | |
579 | }; |