blob: 8530c6e9b770b3039318923e0e6d41e707d835ec [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 *
8 * Bus Glue for pxa27x
9 *
10 * Written by Christopher Hoover <ch@hpl.hp.com>
11 * Based on fragments of previous driver by Russell King et al.
12 *
13 * Modified for LH7A404 from ohci-sa1111.c
14 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
15 *
16 * Modified for pxa27x from ohci-lh7a404.c
17 * by Nick Bane <nick@cecomputing.co.uk> 26-8-2004
18 *
19 * This file is licenced under the GPL.
20 */
21
22#include <linux/device.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080023#include <linux/signal.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010024#include <linux/platform_device.h>
eric miaoa8bcf412007-12-12 08:53:25 +080025#include <linux/clk.h>
Linus Torvalds4fd5f822005-10-31 07:32:56 -080026
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/hardware.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/pxa2xx-regs.h> /* FIXME: for PSSR */
29#include <mach/ohci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Eric Miao596050b2008-09-27 16:12:32 +080031/*
32 * UHC: USB Host Controller (OHCI-like) register definitions
33 */
34#define UHC_BASE_PHYS (0x4C000000)
35#define UHCREV __REG(0x4C000000) /* UHC HCI Spec Revision */
36#define UHCHCON __REG(0x4C000004) /* UHC Host Control Register */
37#define UHCCOMS __REG(0x4C000008) /* UHC Command Status Register */
38#define UHCINTS __REG(0x4C00000C) /* UHC Interrupt Status Register */
39#define UHCINTE __REG(0x4C000010) /* UHC Interrupt Enable */
40#define UHCINTD __REG(0x4C000014) /* UHC Interrupt Disable */
41#define UHCHCCA __REG(0x4C000018) /* UHC Host Controller Comm. Area */
42#define UHCPCED __REG(0x4C00001C) /* UHC Period Current Endpt Descr */
43#define UHCCHED __REG(0x4C000020) /* UHC Control Head Endpt Descr */
44#define UHCCCED __REG(0x4C000024) /* UHC Control Current Endpt Descr */
45#define UHCBHED __REG(0x4C000028) /* UHC Bulk Head Endpt Descr */
46#define UHCBCED __REG(0x4C00002C) /* UHC Bulk Current Endpt Descr */
47#define UHCDHEAD __REG(0x4C000030) /* UHC Done Head */
48#define UHCFMI __REG(0x4C000034) /* UHC Frame Interval */
49#define UHCFMR __REG(0x4C000038) /* UHC Frame Remaining */
50#define UHCFMN __REG(0x4C00003C) /* UHC Frame Number */
51#define UHCPERS __REG(0x4C000040) /* UHC Periodic Start */
52#define UHCLS __REG(0x4C000044) /* UHC Low Speed Threshold */
53
54#define UHCRHDA __REG(0x4C000048) /* UHC Root Hub Descriptor A */
55#define UHCRHDA_NOCP (1 << 12) /* No over current protection */
56#define UHCRHDA_OCPM (1 << 11) /* Over Current Protection Mode */
57#define UHCRHDA_POTPGT(x) \
58 (((x) & 0xff) << 24) /* Power On To Power Good Time */
59
60#define UHCRHDB __REG(0x4C00004C) /* UHC Root Hub Descriptor B */
61#define UHCRHS __REG(0x4C000050) /* UHC Root Hub Status */
62#define UHCRHPS1 __REG(0x4C000054) /* UHC Root Hub Port 1 Status */
63#define UHCRHPS2 __REG(0x4C000058) /* UHC Root Hub Port 2 Status */
64#define UHCRHPS3 __REG(0x4C00005C) /* UHC Root Hub Port 3 Status */
65
66#define UHCSTAT __REG(0x4C000060) /* UHC Status Register */
67#define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
68#define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
69#define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
70#define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
71#define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
72#define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
73#define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
74#define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
75#define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
76
77#define UHCHR __REG(0x4C000064) /* UHC Reset Register */
78#define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
79#define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
80#define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
81#define UHCHR_PCPL (1 << 7) /* Power control polarity low */
82#define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
83#define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
84#define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
85#define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
86#define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
87#define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
88#define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
89
90#define UHCHIE __REG(0x4C000068) /* UHC Interrupt Enable Register*/
91#define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
92#define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
93#define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
94#define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
95#define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
96 Interrupt Enable*/
97#define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
98#define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
99
100#define UHCHIT __REG(0x4C00006C) /* UHC Interrupt Test register */
101
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#define PXA_UHC_MAX_PORTNUM 3
104
105#define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 )
106
eric miaoa8bcf412007-12-12 08:53:25 +0800107static struct clk *usb_clk;
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109/*
110 PMM_NPS_MODE -- PMM Non-power switching mode
111 Ports are powered continuously.
112
113 PMM_GLOBAL_MODE -- PMM global switching mode
114 All ports are powered at the same time.
115
116 PMM_PERPORT_MODE -- PMM per port switching mode
117 Ports are powered individually.
118 */
119static int pxa27x_ohci_select_pmm( int mode )
120{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 switch ( mode ) {
122 case PMM_NPS_MODE:
123 UHCRHDA |= RH_A_NPS;
David Brownelldd9048a2006-12-05 03:18:31 -0800124 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 case PMM_GLOBAL_MODE:
126 UHCRHDA &= ~(RH_A_NPS & RH_A_PSM);
127 break;
128 case PMM_PERPORT_MODE:
129 UHCRHDA &= ~(RH_A_NPS);
130 UHCRHDA |= RH_A_PSM;
131
132 /* Set port power control mask bits, only 3 ports. */
133 UHCRHDB |= (0x7<<17);
134 break;
135 default:
136 printk( KERN_ERR
David Brownelldd9048a2006-12-05 03:18:31 -0800137 "Invalid mode %d, set to non-power switch mode.\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 mode );
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 UHCRHDA |= RH_A_NPS;
141 }
142
143 return 0;
144}
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146extern int usb_disabled(void);
147
148/*-------------------------------------------------------------------------*/
149
Eric Miao097b5332008-09-27 15:49:57 +0800150static inline void pxa27x_setup_hc(struct pxaohci_platform_data *inf)
151{
152 uint32_t uhchr = UHCHR;
153 uint32_t uhcrhda = UHCRHDA;
154
155 if (inf->flags & ENABLE_PORT1)
156 uhchr &= ~UHCHR_SSEP1;
157
158 if (inf->flags & ENABLE_PORT2)
159 uhchr &= ~UHCHR_SSEP2;
160
161 if (inf->flags & ENABLE_PORT3)
162 uhchr &= ~UHCHR_SSEP3;
163
164 if (inf->flags & POWER_CONTROL_LOW)
165 uhchr |= UHCHR_PCPL;
166
167 if (inf->flags & POWER_SENSE_LOW)
168 uhchr |= UHCHR_PSPL;
169
170 if (inf->flags & NO_OC_PROTECTION)
171 uhcrhda |= UHCRHDA_NOCP;
172
173 if (inf->flags & OC_MODE_PERPORT)
174 uhcrhda |= UHCRHDA_OCPM;
175
176 if (inf->power_on_delay) {
177 uhcrhda &= ~UHCRHDA_POTPGT(0xff);
178 uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2);
179 }
180
181 UHCHR = uhchr;
182 UHCRHDA = uhcrhda;
183}
184
Richard Purdie81f280e2005-11-12 14:22:11 +0000185static int pxa27x_start_hc(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186{
Richard Purdie81f280e2005-11-12 14:22:11 +0000187 int retval = 0;
188 struct pxaohci_platform_data *inf;
189
190 inf = dev->platform_data;
191
eric miaoa8bcf412007-12-12 08:53:25 +0800192 clk_enable(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
194 UHCHR |= UHCHR_FHR;
195 udelay(11);
196 UHCHR &= ~UHCHR_FHR;
197
198 UHCHR |= UHCHR_FSBIR;
199 while (UHCHR & UHCHR_FSBIR)
200 cpu_relax();
201
Eric Miao097b5332008-09-27 15:49:57 +0800202 pxa27x_setup_hc(inf);
203
Richard Purdie81f280e2005-11-12 14:22:11 +0000204 if (inf->init)
205 retval = inf->init(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
Richard Purdie81f280e2005-11-12 14:22:11 +0000207 if (retval < 0)
208 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 UHCHR &= ~UHCHR_SSE;
211
212 UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE);
David Brownell155faf52005-08-31 11:54:09 -0700213
214 /* Clear any OTG Pin Hold */
Philipp Zabeld438ae52008-06-06 18:40:47 +0100215 if (cpu_is_pxa27x() && (PSSR & PSSR_OTGPH))
David Brownell155faf52005-08-31 11:54:09 -0700216 PSSR |= PSSR_OTGPH;
Richard Purdie81f280e2005-11-12 14:22:11 +0000217
218 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219}
220
Richard Purdie81f280e2005-11-12 14:22:11 +0000221static void pxa27x_stop_hc(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222{
Richard Purdie81f280e2005-11-12 14:22:11 +0000223 struct pxaohci_platform_data *inf;
224
225 inf = dev->platform_data;
226
227 if (inf->exit)
228 inf->exit(dev);
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 UHCHR |= UHCHR_FHR;
231 udelay(11);
232 UHCHR &= ~UHCHR_FHR;
233
234 UHCCOMS |= 1;
235 udelay(10);
236
eric miaoa8bcf412007-12-12 08:53:25 +0800237 clk_disable(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238}
239
240
241/*-------------------------------------------------------------------------*/
242
243/* configure so an HC device and id are always provided */
244/* always called with process context; sleeping is OK */
245
246
247/**
248 * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs
249 * Context: !in_interrupt()
250 *
251 * Allocates basic resources for this USB host controller, and
252 * then invokes the start() method for the HCD associated with it
253 * through the hotplug entry's driver_data.
254 *
255 */
Richard Purdie81f280e2005-11-12 14:22:11 +0000256int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257{
Eric Miao84bab732008-10-03 22:37:21 +0800258 int retval, irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 struct usb_hcd *hcd;
Richard Purdie81f280e2005-11-12 14:22:11 +0000260 struct pxaohci_platform_data *inf;
Eric Miao84bab732008-10-03 22:37:21 +0800261 struct resource *r;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
Richard Purdie81f280e2005-11-12 14:22:11 +0000263 inf = pdev->dev.platform_data;
264
265 if (!inf)
266 return -ENODEV;
267
Eric Miao84bab732008-10-03 22:37:21 +0800268 irq = platform_get_irq(pdev, 0);
269 if (irq < 0) {
270 pr_err("no resource of IORESOURCE_IRQ");
271 return -ENXIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 }
273
eric miaoa8bcf412007-12-12 08:53:25 +0800274 usb_clk = clk_get(&pdev->dev, "USBCLK");
275 if (IS_ERR(usb_clk))
276 return PTR_ERR(usb_clk);
277
Richard Purdie81f280e2005-11-12 14:22:11 +0000278 hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 if (!hcd)
280 return -ENOMEM;
Eric Miao84bab732008-10-03 22:37:21 +0800281
282 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
283 if (!r) {
284 pr_err("no resource of IORESOURCE_MEM");
285 retval = -ENXIO;
286 goto err1;
287 }
288
289 hcd->rsrc_start = r->start;
290 hcd->rsrc_len = resource_size(r);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
292 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
293 pr_debug("request_mem_region failed");
294 retval = -EBUSY;
295 goto err1;
296 }
297
298 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
299 if (!hcd->regs) {
300 pr_debug("ioremap failed");
301 retval = -ENOMEM;
302 goto err2;
303 }
304
Richard Purdie81f280e2005-11-12 14:22:11 +0000305 if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) {
306 pr_debug("pxa27x_start_hc failed");
307 goto err3;
308 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /* Select Power Management Mode */
Richard Purdie81f280e2005-11-12 14:22:11 +0000311 pxa27x_ohci_select_pmm(inf->port_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Richard Purdie0c27c5d2006-06-08 22:44:07 +0100313 if (inf->power_budget)
314 hcd->power_budget = inf->power_budget;
315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 ohci_hcd_init(hcd_to_ohci(hcd));
317
Eric Miao84bab732008-10-03 22:37:21 +0800318 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 if (retval == 0)
320 return retval;
321
Richard Purdie81f280e2005-11-12 14:22:11 +0000322 pxa27x_stop_hc(&pdev->dev);
323 err3:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 iounmap(hcd->regs);
325 err2:
326 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
327 err1:
328 usb_put_hcd(hcd);
eric miaoa8bcf412007-12-12 08:53:25 +0800329 clk_put(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 return retval;
331}
332
333
334/* may be called without controller electrically present */
335/* may be called with controller, bus, and devices active */
336
337/**
338 * usb_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs
339 * @dev: USB Host Controller being removed
340 * Context: !in_interrupt()
341 *
342 * Reverses the effect of usb_hcd_pxa27x_probe(), first invoking
343 * the HCD's stop() method. It is always called from a thread
344 * context, normally "rmmod", "apmd", or something similar.
345 *
346 */
Richard Purdie81f280e2005-11-12 14:22:11 +0000347void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348{
349 usb_remove_hcd(hcd);
Richard Purdie81f280e2005-11-12 14:22:11 +0000350 pxa27x_stop_hc(&pdev->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 iounmap(hcd->regs);
352 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
353 usb_put_hcd(hcd);
eric miaoa8bcf412007-12-12 08:53:25 +0800354 clk_put(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355}
356
357/*-------------------------------------------------------------------------*/
358
359static int __devinit
360ohci_pxa27x_start (struct usb_hcd *hcd)
361{
362 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
363 int ret;
364
365 ohci_dbg (ohci, "ohci_pxa27x_start, ohci:%p", ohci);
366
David Brownellfdd13b32005-08-31 11:52:57 -0700367 /* The value of NDP in roothub_a is incorrect on this hardware */
368 ohci->num_ports = 3;
369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 if ((ret = ohci_init(ohci)) < 0)
371 return ret;
372
373 if ((ret = ohci_run (ohci)) < 0) {
374 err ("can't start %s", hcd->self.bus_name);
375 ohci_stop (hcd);
376 return ret;
377 }
378
379 return 0;
380}
381
382/*-------------------------------------------------------------------------*/
383
384static const struct hc_driver ohci_pxa27x_hc_driver = {
385 .description = hcd_name,
386 .product_desc = "PXA27x OHCI",
387 .hcd_priv_size = sizeof(struct ohci_hcd),
388
389 /*
390 * generic hardware linkage
391 */
392 .irq = ohci_irq,
393 .flags = HCD_USB11 | HCD_MEMORY,
394
395 /*
396 * basic lifecycle operations
397 */
398 .start = ohci_pxa27x_start,
399 .stop = ohci_stop,
David Brownelldd9048a2006-12-05 03:18:31 -0800400 .shutdown = ohci_shutdown,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402 /*
403 * managing i/o requests and associated device resources
404 */
405 .urb_enqueue = ohci_urb_enqueue,
406 .urb_dequeue = ohci_urb_dequeue,
407 .endpoint_disable = ohci_endpoint_disable,
408
409 /*
410 * scheduling support
411 */
412 .get_frame_number = ohci_get_frame,
413
414 /*
415 * root hub support
416 */
417 .hub_status_data = ohci_hub_status_data,
418 .hub_control = ohci_hub_control,
David Brownell8ad7fe12005-09-13 19:59:11 -0700419#ifdef CONFIG_PM
Alan Stern0c0382e2005-10-13 17:08:02 -0400420 .bus_suspend = ohci_bus_suspend,
421 .bus_resume = ohci_bus_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422#endif
David Brownell92936772005-09-22 22:32:11 -0700423 .start_port_reset = ohci_start_port_reset,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424};
425
426/*-------------------------------------------------------------------------*/
427
Russell King3ae5eae2005-11-09 22:32:44 +0000428static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 pr_debug ("In ohci_hcd_pxa27x_drv_probe");
431
432 if (usb_disabled())
433 return -ENODEV;
434
Richard Purdie81f280e2005-11-12 14:22:11 +0000435 return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436}
437
Russell King3ae5eae2005-11-09 22:32:44 +0000438static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439{
Russell King3ae5eae2005-11-09 22:32:44 +0000440 struct usb_hcd *hcd = platform_get_drvdata(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442 usb_hcd_pxa27x_remove(hcd, pdev);
Richard Purdiea5e36d22005-11-28 22:15:46 +0000443 platform_set_drvdata(pdev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 return 0;
445}
446
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000447#ifdef CONFIG_PM
448static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449{
Richard Purdiea5e36d22005-11-28 22:15:46 +0000450 struct usb_hcd *hcd = platform_get_drvdata(pdev);
451 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000452
453 if (time_before(jiffies, ohci->next_statechange))
454 msleep(5);
455 ohci->next_statechange = jiffies;
456
457 pxa27x_stop_hc(&pdev->dev);
Richard Purdiea5e36d22005-11-28 22:15:46 +0000458 hcd->state = HC_STATE_SUSPENDED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
460 return 0;
461}
462
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000463static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464{
Richard Purdiea5e36d22005-11-28 22:15:46 +0000465 struct usb_hcd *hcd = platform_get_drvdata(pdev);
466 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000467 int status;
468
469 if (time_before(jiffies, ohci->next_statechange))
470 msleep(5);
471 ohci->next_statechange = jiffies;
472
473 if ((status = pxa27x_start_hc(&pdev->dev)) < 0)
474 return status;
475
Alan Stern43bbb7e2008-04-03 18:03:17 -0400476 ohci_finish_controller_resume(hcd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 return 0;
478}
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000479#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Kay Sieversf4fce612008-04-10 21:29:22 -0700481/* work with hotplug and coldplug */
482MODULE_ALIAS("platform:pxa27x-ohci");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
Russell King3ae5eae2005-11-09 22:32:44 +0000484static struct platform_driver ohci_hcd_pxa27x_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 .probe = ohci_hcd_pxa27x_drv_probe,
486 .remove = ohci_hcd_pxa27x_drv_remove,
David Brownelldd9048a2006-12-05 03:18:31 -0800487 .shutdown = usb_hcd_platform_shutdown,
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000488#ifdef CONFIG_PM
David Brownelldd9048a2006-12-05 03:18:31 -0800489 .suspend = ohci_hcd_pxa27x_drv_suspend,
Russell King3ae5eae2005-11-09 22:32:44 +0000490 .resume = ohci_hcd_pxa27x_drv_resume,
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000491#endif
Russell King3ae5eae2005-11-09 22:32:44 +0000492 .driver = {
493 .name = "pxa27x-ohci",
Kay Sieversf4fce612008-04-10 21:29:22 -0700494 .owner = THIS_MODULE,
Russell King3ae5eae2005-11-09 22:32:44 +0000495 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496};
497