blob: ba3a46b78b75a7bd16e54e7e9d3690dd5f9df4ef [file] [log] [blame]
Andrew Victor39a269c2006-01-22 10:32:13 -08001/*
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 *
David Brownell0365ee02006-06-19 14:27:20 -07007 * AT91 Bus Glue
Andrew Victor39a269c2006-01-22 10:32:13 -08008 *
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
Russell Kinga09e64f2008-08-05 16:14:15 +010018#include <mach/hardware.h>
David Brownell4bde4a42007-12-27 11:19:49 -080019#include <asm/gpio.h>
20
Russell Kinga09e64f2008-08-05 16:14:15 +010021#include <mach/board.h>
22#include <mach/cpu.h>
Andrew Victor39a269c2006-01-22 10:32:13 -080023
David Brownell0365ee02006-06-19 14:27:20 -070024#ifndef CONFIG_ARCH_AT91
25#error "CONFIG_ARCH_AT91 must be defined."
Andrew Victor39a269c2006-01-22 10:32:13 -080026#endif
27
Andrew Victored077bb2007-02-16 10:18:58 -080028/* interface and function clocks; sometimes also an AHB clock */
29static struct clk *iclk, *fclk, *hclk;
David Brownell0365ee02006-06-19 14:27:20 -070030static int clocked;
Andrew Victor39a269c2006-01-22 10:32:13 -080031
32extern int usb_disabled(void);
33
34/*-------------------------------------------------------------------------*/
35
Andrew Victored077bb2007-02-16 10:18:58 -080036static void at91_start_clock(void)
37{
Jean-Christophe PLAGNIOL-VILLARD0af43162011-08-30 03:29:28 +020038 clk_enable(hclk);
Andrew Victored077bb2007-02-16 10:18:58 -080039 clk_enable(iclk);
40 clk_enable(fclk);
41 clocked = 1;
42}
43
44static void at91_stop_clock(void)
45{
46 clk_disable(fclk);
47 clk_disable(iclk);
Jean-Christophe PLAGNIOL-VILLARD0af43162011-08-30 03:29:28 +020048 clk_disable(hclk);
Andrew Victored077bb2007-02-16 10:18:58 -080049 clocked = 0;
50}
51
Andrew Victor39a269c2006-01-22 10:32:13 -080052static 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
David Brownell0365ee02006-06-19 14:27:20 -070057 dev_dbg(&pdev->dev, "start\n");
Andrew Victor39a269c2006-01-22 10:32:13 -080058
59 /*
60 * Start the USB clocks.
61 */
Andrew Victored077bb2007-02-16 10:18:58 -080062 at91_start_clock();
Andrew Victor39a269c2006-01-22 10:32:13 -080063
64 /*
65 * The USB host controller must remain in reset.
66 */
67 writel(0, &regs->control);
68}
69
70static 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
David Brownell0365ee02006-06-19 14:27:20 -070075 dev_dbg(&pdev->dev, "stop\n");
Andrew Victor39a269c2006-01-22 10:32:13 -080076
77 /*
78 * Put the USB host controller into reset.
79 */
80 writel(0, &regs->control);
81
82 /*
83 * Stop the USB clocks.
84 */
Andrew Victored077bb2007-02-16 10:18:58 -080085 at91_stop_clock();
Andrew Victor39a269c2006-01-22 10:32:13 -080086}
87
88
89/*-------------------------------------------------------------------------*/
90
Pete Zaitcev421b4bf2008-06-01 14:38:43 -070091static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
Andrew Victor39a269c2006-01-22 10:32:13 -080092
93/* configure so an HC device and id are always provided */
94/* always called with process context; sleeping is OK */
95
96
97/**
David Brownell0365ee02006-06-19 14:27:20 -070098 * usb_hcd_at91_probe - initialize AT91-based HCDs
Andrew Victor39a269c2006-01-22 10:32:13 -080099 * 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.
Andrew Victor39a269c2006-01-22 10:32:13 -0800104 */
David Brownell0365ee02006-06-19 14:27:20 -0700105static int usb_hcd_at91_probe(const struct hc_driver *driver,
106 struct platform_device *pdev)
Andrew Victor39a269c2006-01-22 10:32:13 -0800107{
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
David Brownell0365ee02006-06-19 14:27:20 -0700116 if ((pdev->resource[0].flags != IORESOURCE_MEM)
117 || (pdev->resource[1].flags != IORESOURCE_IRQ)) {
Andrew Victor39a269c2006-01-22 10:32:13 -0800118 pr_debug("hcd probe: invalid resource type\n");
119 return -ENODEV;
120 }
121
David Brownell0365ee02006-06-19 14:27:20 -0700122 hcd = usb_create_hcd(driver, &pdev->dev, "at91");
Andrew Victor39a269c2006-01-22 10:32:13 -0800123 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");
Jean-Christophe PLAGNIOL-VILLARD0af43162011-08-30 03:29:28 +0200143 hclk = clk_get(&pdev->dev, "hclk");
Andrew Victor39a269c2006-01-22 10:32:13 -0800144
145 at91_start_hc(pdev);
146 ohci_hcd_init(hcd_to_ohci(hcd));
147
Nicolas Ferre2f2cac32009-07-27 14:59:24 -0700148 retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
Andrew Victor39a269c2006-01-22 10:32:13 -0800149 if (retval == 0)
150 return retval;
151
152 /* Error handling */
153 at91_stop_hc(pdev);
154
Jean-Christophe PLAGNIOL-VILLARD0af43162011-08-30 03:29:28 +0200155 clk_put(hclk);
Andrew Victor39a269c2006-01-22 10:32:13 -0800156 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
Andrew Victor39a269c2006-01-22 10:32:13 -0800170/* may be called with controller, bus, and devices active */
171
172/**
David Brownell0365ee02006-06-19 14:27:20 -0700173 * usb_hcd_at91_remove - shutdown processing for AT91-based HCDs
Andrew Victor39a269c2006-01-22 10:32:13 -0800174 * @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
David Brownell0365ee02006-06-19 14:27:20 -0700179 * context, "rmmod" or something similar.
Andrew Victor39a269c2006-01-22 10:32:13 -0800180 *
181 */
Pete Zaitcev421b4bf2008-06-01 14:38:43 -0700182static void usb_hcd_at91_remove(struct usb_hcd *hcd,
David Brownell0365ee02006-06-19 14:27:20 -0700183 struct platform_device *pdev)
Andrew Victor39a269c2006-01-22 10:32:13 -0800184{
185 usb_remove_hcd(hcd);
186 at91_stop_hc(pdev);
187 iounmap(hcd->regs);
David Brownell68ba61b2006-04-02 20:26:21 -0800188 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
Pete Zaitcev421b4bf2008-06-01 14:38:43 -0700189 usb_put_hcd(hcd);
Andrew Victor39a269c2006-01-22 10:32:13 -0800190
Jean-Christophe PLAGNIOL-VILLARD0af43162011-08-30 03:29:28 +0200191 clk_put(hclk);
David Brownell68ba61b2006-04-02 20:26:21 -0800192 clk_put(fclk);
193 clk_put(iclk);
Andrew Victored077bb2007-02-16 10:18:58 -0800194 fclk = iclk = hclk = NULL;
Andrew Victor39a269c2006-01-22 10:32:13 -0800195
196 dev_set_drvdata(&pdev->dev, NULL);
Andrew Victor39a269c2006-01-22 10:32:13 -0800197}
198
199/*-------------------------------------------------------------------------*/
200
201static int __devinit
202ohci_at91_start (struct usb_hcd *hcd)
203{
David Brownell0365ee02006-06-19 14:27:20 -0700204 struct at91_usbh_data *board = hcd->self.controller->platform_data;
Andrew Victor39a269c2006-01-22 10:32:13 -0800205 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
206 int ret;
207
208 if ((ret = ohci_init(ohci)) < 0)
209 return ret;
210
David Brownellcd22afd2006-09-03 12:21:50 -0700211 ohci->num_ports = board->ports;
David Brownell0365ee02006-06-19 14:27:20 -0700212
Andrew Victor39a269c2006-01-22 10:32:13 -0800213 if ((ret = ohci_run(ohci)) < 0) {
214 err("can't start %s", hcd->self.bus_name);
215 ohci_stop(hcd);
216 return ret;
217 }
Andrew Victor39a269c2006-01-22 10:32:13 -0800218 return 0;
219}
220
Thomas Petazzoniaa6e52a2011-07-13 11:29:17 +0200221static 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
226 gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable);
227}
228
229static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
230{
231 if (port < 0 || port >= 2)
232 return -EINVAL;
233
234 return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted;
235}
236
237/*
238 * Update the status data from the hub with the over-current indicator change.
239 */
240static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf)
241{
242 struct at91_usbh_data *pdata = hcd->self.controller->platform_data;
243 int length = ohci_hub_status_data(hcd, buf);
244 int port;
245
246 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) {
247 if (pdata->overcurrent_changed[port]) {
248 if (! length)
249 length = 1;
250 buf[0] |= 1 << (port + 1);
251 }
252 }
253
254 return length;
255}
256
257/*
258 * Look at the control requests to the root hub and see if we need to override.
259 */
260static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
261 u16 wIndex, char *buf, u16 wLength)
262{
263 struct at91_usbh_data *pdata = hcd->self.controller->platform_data;
264 struct usb_hub_descriptor *desc;
265 int ret = -EINVAL;
266 u32 *data = (u32 *)buf;
267
268 dev_dbg(hcd->self.controller,
269 "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n",
270 hcd, typeReq, wValue, wIndex, buf, wLength);
271
272 switch (typeReq) {
273 case SetPortFeature:
274 if (wValue == USB_PORT_FEAT_POWER) {
275 dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
276 ohci_at91_usb_set_power(pdata, wIndex - 1, 1);
277 goto out;
278 }
279 break;
280
281 case ClearPortFeature:
282 switch (wValue) {
283 case USB_PORT_FEAT_C_OVER_CURRENT:
284 dev_dbg(hcd->self.controller,
285 "ClearPortFeature: C_OVER_CURRENT\n");
286
287 if (wIndex == 1 || wIndex == 2) {
288 pdata->overcurrent_changed[wIndex-1] = 0;
289 pdata->overcurrent_status[wIndex-1] = 0;
290 }
291
292 goto out;
293
294 case USB_PORT_FEAT_OVER_CURRENT:
295 dev_dbg(hcd->self.controller,
296 "ClearPortFeature: OVER_CURRENT\n");
297
298 if (wIndex == 1 || wIndex == 2) {
299 pdata->overcurrent_status[wIndex-1] = 0;
300 }
301
302 goto out;
303
304 case USB_PORT_FEAT_POWER:
305 dev_dbg(hcd->self.controller,
306 "ClearPortFeature: POWER\n");
307
308 if (wIndex == 1 || wIndex == 2) {
309 ohci_at91_usb_set_power(pdata, wIndex - 1, 0);
310 return 0;
311 }
312 }
313 break;
314 }
315
316 ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
317 if (ret)
318 goto out;
319
320 switch (typeReq) {
321 case GetHubDescriptor:
322
323 /* update the hub's descriptor */
324
325 desc = (struct usb_hub_descriptor *)buf;
326
327 dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n",
328 desc->wHubCharacteristics);
329
330 /* remove the old configurations for power-switching, and
331 * over-current protection, and insert our new configuration
332 */
333
334 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
335 desc->wHubCharacteristics |= cpu_to_le16(0x0001);
336
337 if (pdata->overcurrent_supported) {
338 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
339 desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001);
340 }
341
342 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
343 desc->wHubCharacteristics);
344
345 return ret;
346
347 case GetPortStatus:
348 /* check port status */
349
350 dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);
351
352 if (wIndex == 1 || wIndex == 2) {
353 if (! ohci_at91_usb_get_power(pdata, wIndex-1)) {
354 *data &= ~cpu_to_le32(RH_PS_PPS);
355 }
356
357 if (pdata->overcurrent_changed[wIndex-1]) {
358 *data |= cpu_to_le32(RH_PS_OCIC);
359 }
360
361 if (pdata->overcurrent_status[wIndex-1]) {
362 *data |= cpu_to_le32(RH_PS_POCI);
363 }
364 }
365 }
366
367 out:
368 return ret;
369}
370
Andrew Victor39a269c2006-01-22 10:32:13 -0800371/*-------------------------------------------------------------------------*/
372
373static const struct hc_driver ohci_at91_hc_driver = {
374 .description = hcd_name,
David Brownell0365ee02006-06-19 14:27:20 -0700375 .product_desc = "AT91 OHCI",
Andrew Victor39a269c2006-01-22 10:32:13 -0800376 .hcd_priv_size = sizeof(struct ohci_hcd),
377
378 /*
379 * generic hardware linkage
380 */
381 .irq = ohci_irq,
382 .flags = HCD_USB11 | HCD_MEMORY,
383
384 /*
385 * basic lifecycle operations
386 */
387 .start = ohci_at91_start,
388 .stop = ohci_stop,
David Brownelldd9048a2006-12-05 03:18:31 -0800389 .shutdown = ohci_shutdown,
Andrew Victor39a269c2006-01-22 10:32:13 -0800390
391 /*
392 * managing i/o requests and associated device resources
393 */
394 .urb_enqueue = ohci_urb_enqueue,
395 .urb_dequeue = ohci_urb_dequeue,
396 .endpoint_disable = ohci_endpoint_disable,
397
398 /*
399 * scheduling support
400 */
401 .get_frame_number = ohci_get_frame,
402
403 /*
404 * root hub support
405 */
Thomas Petazzoniaa6e52a2011-07-13 11:29:17 +0200406 .hub_status_data = ohci_at91_hub_status_data,
407 .hub_control = ohci_at91_hub_control,
Andrew Victor39a269c2006-01-22 10:32:13 -0800408#ifdef CONFIG_PM
David Brownell68ba61b2006-04-02 20:26:21 -0800409 .bus_suspend = ohci_bus_suspend,
410 .bus_resume = ohci_bus_resume,
Andrew Victor39a269c2006-01-22 10:32:13 -0800411#endif
412 .start_port_reset = ohci_start_port_reset,
413};
414
415/*-------------------------------------------------------------------------*/
416
Thomas Petazzoniaa6e52a2011-07-13 11:29:17 +0200417static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
418{
419 struct platform_device *pdev = data;
420 struct at91_usbh_data *pdata = pdev->dev.platform_data;
421 int val, gpio, port;
422
423 /* From the GPIO notifying the over-current situation, find
424 * out the corresponding port */
425 gpio = irq_to_gpio(irq);
426 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) {
427 if (pdata->overcurrent_pin[port] == gpio)
428 break;
429 }
430
431 if (port == ARRAY_SIZE(pdata->overcurrent_pin)) {
432 dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n");
433 return IRQ_HANDLED;
434 }
435
436 val = gpio_get_value(gpio);
437
438 /* When notified of an over-current situation, disable power
439 on the corresponding port, and mark this port in
440 over-current. */
441 if (! val) {
442 ohci_at91_usb_set_power(pdata, port, 0);
443 pdata->overcurrent_status[port] = 1;
444 pdata->overcurrent_changed[port] = 1;
445 }
446
447 dev_dbg(& pdev->dev, "overcurrent situation %s\n",
448 val ? "exited" : "notified");
449
450 return IRQ_HANDLED;
451}
452
453/*-------------------------------------------------------------------------*/
454
David Brownell0365ee02006-06-19 14:27:20 -0700455static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
Andrew Victor39a269c2006-01-22 10:32:13 -0800456{
David Brownell4bde4a42007-12-27 11:19:49 -0800457 struct at91_usbh_data *pdata = pdev->dev.platform_data;
458 int i;
459
460 if (pdata) {
Justin Waters3d6fdf72009-04-03 21:06:53 +0100461 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
David Brownell4bde4a42007-12-27 11:19:49 -0800462 if (pdata->vbus_pin[i] <= 0)
463 continue;
464 gpio_request(pdata->vbus_pin[i], "ohci_vbus");
Thomas Petazzoniaa6e52a2011-07-13 11:29:17 +0200465 ohci_at91_usb_set_power(pdata, i, 1);
466 }
467
468 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) {
469 int ret;
470
471 if (pdata->overcurrent_pin[i] <= 0)
472 continue;
473 gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent");
474
475 ret = request_irq(gpio_to_irq(pdata->overcurrent_pin[i]),
476 ohci_hcd_at91_overcurrent_irq,
477 IRQF_SHARED, "ohci_overcurrent", pdev);
478 if (ret) {
479 gpio_free(pdata->overcurrent_pin[i]);
480 dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n");
481 }
David Brownell4bde4a42007-12-27 11:19:49 -0800482 }
483 }
484
David Brownell0365ee02006-06-19 14:27:20 -0700485 device_init_wakeup(&pdev->dev, 1);
486 return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
Andrew Victor39a269c2006-01-22 10:32:13 -0800487}
488
David Brownell0365ee02006-06-19 14:27:20 -0700489static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
Andrew Victor39a269c2006-01-22 10:32:13 -0800490{
David Brownell4bde4a42007-12-27 11:19:49 -0800491 struct at91_usbh_data *pdata = pdev->dev.platform_data;
492 int i;
493
494 if (pdata) {
Justin Waters3d6fdf72009-04-03 21:06:53 +0100495 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
David Brownell4bde4a42007-12-27 11:19:49 -0800496 if (pdata->vbus_pin[i] <= 0)
497 continue;
Thomas Petazzoniaa6e52a2011-07-13 11:29:17 +0200498 ohci_at91_usb_set_power(pdata, i, 0);
David Brownell4bde4a42007-12-27 11:19:49 -0800499 gpio_free(pdata->vbus_pin[i]);
500 }
Thomas Petazzoniaa6e52a2011-07-13 11:29:17 +0200501
502 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) {
503 if (pdata->overcurrent_pin[i] <= 0)
504 continue;
505 free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev);
506 gpio_free(pdata->overcurrent_pin[i]);
507 }
David Brownell4bde4a42007-12-27 11:19:49 -0800508 }
509
David Brownell0365ee02006-06-19 14:27:20 -0700510 device_init_wakeup(&pdev->dev, 0);
Pete Zaitcev421b4bf2008-06-01 14:38:43 -0700511 usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev);
512 return 0;
Andrew Victor39a269c2006-01-22 10:32:13 -0800513}
514
515#ifdef CONFIG_PM
Andrew Victor39a269c2006-01-22 10:32:13 -0800516
David Brownell68ba61b2006-04-02 20:26:21 -0800517static int
David Brownell0365ee02006-06-19 14:27:20 -0700518ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
David Brownell68ba61b2006-04-02 20:26:21 -0800519{
David Brownell0365ee02006-06-19 14:27:20 -0700520 struct usb_hcd *hcd = platform_get_drvdata(pdev);
521 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
522
523 if (device_may_wakeup(&pdev->dev))
524 enable_irq_wake(hcd->irq);
David Brownell0365ee02006-06-19 14:27:20 -0700525
526 /*
527 * The integrated transceivers seem unable to notice disconnect,
528 * reconnect, or wakeup without the 48 MHz clock active. so for
529 * correctness, always discard connection state (using reset).
530 *
531 * REVISIT: some boards will be able to turn VBUS off...
532 */
533 if (at91_suspend_entering_slow_clock()) {
534 ohci_usb_reset (ohci);
Patrice Vilchez869aa982010-04-28 13:45:40 +0200535 /* flush the writes */
536 (void) ohci_readl (ohci, &ohci->regs->control);
Andrew Victored077bb2007-02-16 10:18:58 -0800537 at91_stop_clock();
David Brownell0365ee02006-06-19 14:27:20 -0700538 }
Andrew Victor39a269c2006-01-22 10:32:13 -0800539
540 return 0;
541}
542
David Brownell0365ee02006-06-19 14:27:20 -0700543static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
Andrew Victor39a269c2006-01-22 10:32:13 -0800544{
Marc Pignat6dde8962007-01-09 14:00:11 -0800545 struct usb_hcd *hcd = platform_get_drvdata(pdev);
546
547 if (device_may_wakeup(&pdev->dev))
548 disable_irq_wake(hcd->irq);
549
Andrew Victored077bb2007-02-16 10:18:58 -0800550 if (!clocked)
551 at91_start_clock();
Andrew Victor39a269c2006-01-22 10:32:13 -0800552
Alan Stern43bbb7e2008-04-03 18:03:17 -0400553 ohci_finish_controller_resume(hcd);
Andrew Victor39a269c2006-01-22 10:32:13 -0800554 return 0;
555}
556#else
557#define ohci_hcd_at91_drv_suspend NULL
558#define ohci_hcd_at91_drv_resume NULL
559#endif
560
Kay Sieversf4fce612008-04-10 21:29:22 -0700561MODULE_ALIAS("platform:at91_ohci");
David Brownell68ba61b2006-04-02 20:26:21 -0800562
Andrew Victor39a269c2006-01-22 10:32:13 -0800563static struct platform_driver ohci_hcd_at91_driver = {
564 .probe = ohci_hcd_at91_drv_probe,
565 .remove = ohci_hcd_at91_drv_remove,
Aleksey Gorelov64a21d02006-08-08 17:24:08 -0700566 .shutdown = usb_hcd_platform_shutdown,
Andrew Victor39a269c2006-01-22 10:32:13 -0800567 .suspend = ohci_hcd_at91_drv_suspend,
568 .resume = ohci_hcd_at91_drv_resume,
569 .driver = {
David Brownell0365ee02006-06-19 14:27:20 -0700570 .name = "at91_ohci",
Andrew Victor39a269c2006-01-22 10:32:13 -0800571 .owner = THIS_MODULE,
572 },
573};