blob: 1fd77933a4c60e3ccb66c30468b50589d7bfdffb [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/ohci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Eric Miao596050b2008-09-27 16:12:32 +080030/*
31 * UHC: USB Host Controller (OHCI-like) register definitions
32 */
33#define UHC_BASE_PHYS (0x4C000000)
34#define UHCREV __REG(0x4C000000) /* UHC HCI Spec Revision */
35#define UHCHCON __REG(0x4C000004) /* UHC Host Control Register */
36#define UHCCOMS __REG(0x4C000008) /* UHC Command Status Register */
37#define UHCINTS __REG(0x4C00000C) /* UHC Interrupt Status Register */
38#define UHCINTE __REG(0x4C000010) /* UHC Interrupt Enable */
39#define UHCINTD __REG(0x4C000014) /* UHC Interrupt Disable */
40#define UHCHCCA __REG(0x4C000018) /* UHC Host Controller Comm. Area */
41#define UHCPCED __REG(0x4C00001C) /* UHC Period Current Endpt Descr */
42#define UHCCHED __REG(0x4C000020) /* UHC Control Head Endpt Descr */
43#define UHCCCED __REG(0x4C000024) /* UHC Control Current Endpt Descr */
44#define UHCBHED __REG(0x4C000028) /* UHC Bulk Head Endpt Descr */
45#define UHCBCED __REG(0x4C00002C) /* UHC Bulk Current Endpt Descr */
46#define UHCDHEAD __REG(0x4C000030) /* UHC Done Head */
47#define UHCFMI __REG(0x4C000034) /* UHC Frame Interval */
48#define UHCFMR __REG(0x4C000038) /* UHC Frame Remaining */
49#define UHCFMN __REG(0x4C00003C) /* UHC Frame Number */
50#define UHCPERS __REG(0x4C000040) /* UHC Periodic Start */
51#define UHCLS __REG(0x4C000044) /* UHC Low Speed Threshold */
52
53#define UHCRHDA __REG(0x4C000048) /* UHC Root Hub Descriptor A */
54#define UHCRHDA_NOCP (1 << 12) /* No over current protection */
55#define UHCRHDA_OCPM (1 << 11) /* Over Current Protection Mode */
56#define UHCRHDA_POTPGT(x) \
57 (((x) & 0xff) << 24) /* Power On To Power Good Time */
58
59#define UHCRHDB __REG(0x4C00004C) /* UHC Root Hub Descriptor B */
60#define UHCRHS __REG(0x4C000050) /* UHC Root Hub Status */
61#define UHCRHPS1 __REG(0x4C000054) /* UHC Root Hub Port 1 Status */
62#define UHCRHPS2 __REG(0x4C000058) /* UHC Root Hub Port 2 Status */
63#define UHCRHPS3 __REG(0x4C00005C) /* UHC Root Hub Port 3 Status */
64
65#define UHCSTAT __REG(0x4C000060) /* UHC Status Register */
66#define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
67#define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
68#define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
69#define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
70#define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
71#define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
72#define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
73#define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
74#define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
75
76#define UHCHR __REG(0x4C000064) /* UHC Reset Register */
77#define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
78#define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
79#define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
80#define UHCHR_PCPL (1 << 7) /* Power control polarity low */
81#define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
82#define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
83#define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
84#define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
85#define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
86#define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
87#define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
88
89#define UHCHIE __REG(0x4C000068) /* UHC Interrupt Enable Register*/
90#define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
91#define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
92#define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
93#define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
94#define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
95 Interrupt Enable*/
96#define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
97#define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
98
99#define UHCHIT __REG(0x4C00006C) /* UHC Interrupt Test register */
100
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102#define PXA_UHC_MAX_PORTNUM 3
103
104#define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 )
105
eric miaoa8bcf412007-12-12 08:53:25 +0800106static struct clk *usb_clk;
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108/*
109 PMM_NPS_MODE -- PMM Non-power switching mode
110 Ports are powered continuously.
111
112 PMM_GLOBAL_MODE -- PMM global switching mode
113 All ports are powered at the same time.
114
115 PMM_PERPORT_MODE -- PMM per port switching mode
116 Ports are powered individually.
117 */
118static int pxa27x_ohci_select_pmm( int mode )
119{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 switch ( mode ) {
121 case PMM_NPS_MODE:
122 UHCRHDA |= RH_A_NPS;
David Brownelldd9048a2006-12-05 03:18:31 -0800123 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 case PMM_GLOBAL_MODE:
125 UHCRHDA &= ~(RH_A_NPS & RH_A_PSM);
126 break;
127 case PMM_PERPORT_MODE:
128 UHCRHDA &= ~(RH_A_NPS);
129 UHCRHDA |= RH_A_PSM;
130
131 /* Set port power control mask bits, only 3 ports. */
132 UHCRHDB |= (0x7<<17);
133 break;
134 default:
135 printk( KERN_ERR
David Brownelldd9048a2006-12-05 03:18:31 -0800136 "Invalid mode %d, set to non-power switch mode.\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 mode );
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 UHCRHDA |= RH_A_NPS;
140 }
141
142 return 0;
143}
144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145extern int usb_disabled(void);
146
147/*-------------------------------------------------------------------------*/
148
Eric Miao097b5332008-09-27 15:49:57 +0800149static inline void pxa27x_setup_hc(struct pxaohci_platform_data *inf)
150{
151 uint32_t uhchr = UHCHR;
152 uint32_t uhcrhda = UHCRHDA;
153
154 if (inf->flags & ENABLE_PORT1)
155 uhchr &= ~UHCHR_SSEP1;
156
157 if (inf->flags & ENABLE_PORT2)
158 uhchr &= ~UHCHR_SSEP2;
159
160 if (inf->flags & ENABLE_PORT3)
161 uhchr &= ~UHCHR_SSEP3;
162
163 if (inf->flags & POWER_CONTROL_LOW)
164 uhchr |= UHCHR_PCPL;
165
166 if (inf->flags & POWER_SENSE_LOW)
167 uhchr |= UHCHR_PSPL;
168
169 if (inf->flags & NO_OC_PROTECTION)
170 uhcrhda |= UHCRHDA_NOCP;
171
172 if (inf->flags & OC_MODE_PERPORT)
173 uhcrhda |= UHCRHDA_OCPM;
174
175 if (inf->power_on_delay) {
176 uhcrhda &= ~UHCRHDA_POTPGT(0xff);
177 uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2);
178 }
179
180 UHCHR = uhchr;
181 UHCRHDA = uhcrhda;
182}
183
Eric Miao0cb0b0d2008-10-04 12:45:39 +0800184#ifdef CONFIG_CPU_PXA27x
185extern void pxa27x_clear_otgph(void);
186#else
187#define pxa27x_clear_otgph() do {} while (0)
188#endif
189
Richard Purdie81f280e2005-11-12 14:22:11 +0000190static int pxa27x_start_hc(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191{
Richard Purdie81f280e2005-11-12 14:22:11 +0000192 int retval = 0;
193 struct pxaohci_platform_data *inf;
194
195 inf = dev->platform_data;
196
eric miaoa8bcf412007-12-12 08:53:25 +0800197 clk_enable(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 UHCHR |= UHCHR_FHR;
200 udelay(11);
201 UHCHR &= ~UHCHR_FHR;
202
203 UHCHR |= UHCHR_FSBIR;
204 while (UHCHR & UHCHR_FSBIR)
205 cpu_relax();
206
Eric Miao097b5332008-09-27 15:49:57 +0800207 pxa27x_setup_hc(inf);
208
Richard Purdie81f280e2005-11-12 14:22:11 +0000209 if (inf->init)
210 retval = inf->init(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
Richard Purdie81f280e2005-11-12 14:22:11 +0000212 if (retval < 0)
213 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 UHCHR &= ~UHCHR_SSE;
216
217 UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE);
David Brownell155faf52005-08-31 11:54:09 -0700218
219 /* Clear any OTG Pin Hold */
Eric Miao0cb0b0d2008-10-04 12:45:39 +0800220 pxa27x_clear_otgph();
Richard Purdie81f280e2005-11-12 14:22:11 +0000221 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222}
223
Richard Purdie81f280e2005-11-12 14:22:11 +0000224static void pxa27x_stop_hc(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225{
Richard Purdie81f280e2005-11-12 14:22:11 +0000226 struct pxaohci_platform_data *inf;
227
228 inf = dev->platform_data;
229
230 if (inf->exit)
231 inf->exit(dev);
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 UHCHR |= UHCHR_FHR;
234 udelay(11);
235 UHCHR &= ~UHCHR_FHR;
236
237 UHCCOMS |= 1;
238 udelay(10);
239
eric miaoa8bcf412007-12-12 08:53:25 +0800240 clk_disable(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241}
242
243
244/*-------------------------------------------------------------------------*/
245
246/* configure so an HC device and id are always provided */
247/* always called with process context; sleeping is OK */
248
249
250/**
251 * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs
252 * Context: !in_interrupt()
253 *
254 * Allocates basic resources for this USB host controller, and
255 * then invokes the start() method for the HCD associated with it
256 * through the hotplug entry's driver_data.
257 *
258 */
Richard Purdie81f280e2005-11-12 14:22:11 +0000259int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260{
Eric Miao84bab732008-10-03 22:37:21 +0800261 int retval, irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 struct usb_hcd *hcd;
Richard Purdie81f280e2005-11-12 14:22:11 +0000263 struct pxaohci_platform_data *inf;
Eric Miao84bab732008-10-03 22:37:21 +0800264 struct resource *r;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
Richard Purdie81f280e2005-11-12 14:22:11 +0000266 inf = pdev->dev.platform_data;
267
268 if (!inf)
269 return -ENODEV;
270
Eric Miao84bab732008-10-03 22:37:21 +0800271 irq = platform_get_irq(pdev, 0);
272 if (irq < 0) {
273 pr_err("no resource of IORESOURCE_IRQ");
274 return -ENXIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 }
276
eric miaoa8bcf412007-12-12 08:53:25 +0800277 usb_clk = clk_get(&pdev->dev, "USBCLK");
278 if (IS_ERR(usb_clk))
279 return PTR_ERR(usb_clk);
280
Richard Purdie81f280e2005-11-12 14:22:11 +0000281 hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 if (!hcd)
283 return -ENOMEM;
Eric Miao84bab732008-10-03 22:37:21 +0800284
285 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
286 if (!r) {
287 pr_err("no resource of IORESOURCE_MEM");
288 retval = -ENXIO;
289 goto err1;
290 }
291
292 hcd->rsrc_start = r->start;
293 hcd->rsrc_len = resource_size(r);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
295 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
296 pr_debug("request_mem_region failed");
297 retval = -EBUSY;
298 goto err1;
299 }
300
301 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
302 if (!hcd->regs) {
303 pr_debug("ioremap failed");
304 retval = -ENOMEM;
305 goto err2;
306 }
307
Richard Purdie81f280e2005-11-12 14:22:11 +0000308 if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) {
309 pr_debug("pxa27x_start_hc failed");
310 goto err3;
311 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
313 /* Select Power Management Mode */
Richard Purdie81f280e2005-11-12 14:22:11 +0000314 pxa27x_ohci_select_pmm(inf->port_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
Richard Purdie0c27c5d2006-06-08 22:44:07 +0100316 if (inf->power_budget)
317 hcd->power_budget = inf->power_budget;
318
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 ohci_hcd_init(hcd_to_ohci(hcd));
320
Eric Miao84bab732008-10-03 22:37:21 +0800321 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 if (retval == 0)
323 return retval;
324
Richard Purdie81f280e2005-11-12 14:22:11 +0000325 pxa27x_stop_hc(&pdev->dev);
326 err3:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 iounmap(hcd->regs);
328 err2:
329 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
330 err1:
331 usb_put_hcd(hcd);
eric miaoa8bcf412007-12-12 08:53:25 +0800332 clk_put(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 return retval;
334}
335
336
337/* may be called without controller electrically present */
338/* may be called with controller, bus, and devices active */
339
340/**
341 * usb_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs
342 * @dev: USB Host Controller being removed
343 * Context: !in_interrupt()
344 *
345 * Reverses the effect of usb_hcd_pxa27x_probe(), first invoking
346 * the HCD's stop() method. It is always called from a thread
347 * context, normally "rmmod", "apmd", or something similar.
348 *
349 */
Richard Purdie81f280e2005-11-12 14:22:11 +0000350void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351{
352 usb_remove_hcd(hcd);
Richard Purdie81f280e2005-11-12 14:22:11 +0000353 pxa27x_stop_hc(&pdev->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 iounmap(hcd->regs);
355 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
356 usb_put_hcd(hcd);
eric miaoa8bcf412007-12-12 08:53:25 +0800357 clk_put(usb_clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358}
359
360/*-------------------------------------------------------------------------*/
361
362static int __devinit
363ohci_pxa27x_start (struct usb_hcd *hcd)
364{
365 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
366 int ret;
367
368 ohci_dbg (ohci, "ohci_pxa27x_start, ohci:%p", ohci);
369
David Brownellfdd13b32005-08-31 11:52:57 -0700370 /* The value of NDP in roothub_a is incorrect on this hardware */
371 ohci->num_ports = 3;
372
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 if ((ret = ohci_init(ohci)) < 0)
374 return ret;
375
376 if ((ret = ohci_run (ohci)) < 0) {
377 err ("can't start %s", hcd->self.bus_name);
378 ohci_stop (hcd);
379 return ret;
380 }
381
382 return 0;
383}
384
385/*-------------------------------------------------------------------------*/
386
387static const struct hc_driver ohci_pxa27x_hc_driver = {
388 .description = hcd_name,
389 .product_desc = "PXA27x OHCI",
390 .hcd_priv_size = sizeof(struct ohci_hcd),
391
392 /*
393 * generic hardware linkage
394 */
395 .irq = ohci_irq,
396 .flags = HCD_USB11 | HCD_MEMORY,
397
398 /*
399 * basic lifecycle operations
400 */
401 .start = ohci_pxa27x_start,
402 .stop = ohci_stop,
David Brownelldd9048a2006-12-05 03:18:31 -0800403 .shutdown = ohci_shutdown,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404
405 /*
406 * managing i/o requests and associated device resources
407 */
408 .urb_enqueue = ohci_urb_enqueue,
409 .urb_dequeue = ohci_urb_dequeue,
410 .endpoint_disable = ohci_endpoint_disable,
411
412 /*
413 * scheduling support
414 */
415 .get_frame_number = ohci_get_frame,
416
417 /*
418 * root hub support
419 */
420 .hub_status_data = ohci_hub_status_data,
421 .hub_control = ohci_hub_control,
David Brownell8ad7fe12005-09-13 19:59:11 -0700422#ifdef CONFIG_PM
Alan Stern0c0382e2005-10-13 17:08:02 -0400423 .bus_suspend = ohci_bus_suspend,
424 .bus_resume = ohci_bus_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425#endif
David Brownell92936772005-09-22 22:32:11 -0700426 .start_port_reset = ohci_start_port_reset,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427};
428
429/*-------------------------------------------------------------------------*/
430
Russell King3ae5eae2005-11-09 22:32:44 +0000431static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 pr_debug ("In ohci_hcd_pxa27x_drv_probe");
434
435 if (usb_disabled())
436 return -ENODEV;
437
Richard Purdie81f280e2005-11-12 14:22:11 +0000438 return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439}
440
Russell King3ae5eae2005-11-09 22:32:44 +0000441static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442{
Russell King3ae5eae2005-11-09 22:32:44 +0000443 struct usb_hcd *hcd = platform_get_drvdata(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
445 usb_hcd_pxa27x_remove(hcd, pdev);
Richard Purdiea5e36d22005-11-28 22:15:46 +0000446 platform_set_drvdata(pdev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 return 0;
448}
449
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000450#ifdef CONFIG_PM
451static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452{
Richard Purdiea5e36d22005-11-28 22:15:46 +0000453 struct usb_hcd *hcd = platform_get_drvdata(pdev);
454 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000455
456 if (time_before(jiffies, ohci->next_statechange))
457 msleep(5);
458 ohci->next_statechange = jiffies;
459
460 pxa27x_stop_hc(&pdev->dev);
Richard Purdiea5e36d22005-11-28 22:15:46 +0000461 hcd->state = HC_STATE_SUSPENDED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
463 return 0;
464}
465
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000466static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467{
Richard Purdiea5e36d22005-11-28 22:15:46 +0000468 struct usb_hcd *hcd = platform_get_drvdata(pdev);
469 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000470 int status;
471
472 if (time_before(jiffies, ohci->next_statechange))
473 msleep(5);
474 ohci->next_statechange = jiffies;
475
476 if ((status = pxa27x_start_hc(&pdev->dev)) < 0)
477 return status;
478
Alan Stern43bbb7e2008-04-03 18:03:17 -0400479 ohci_finish_controller_resume(hcd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 return 0;
481}
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000482#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
Kay Sieversf4fce612008-04-10 21:29:22 -0700484/* work with hotplug and coldplug */
485MODULE_ALIAS("platform:pxa27x-ohci");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
Russell King3ae5eae2005-11-09 22:32:44 +0000487static struct platform_driver ohci_hcd_pxa27x_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 .probe = ohci_hcd_pxa27x_drv_probe,
489 .remove = ohci_hcd_pxa27x_drv_remove,
David Brownelldd9048a2006-12-05 03:18:31 -0800490 .shutdown = usb_hcd_platform_shutdown,
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000491#ifdef CONFIG_PM
David Brownelldd9048a2006-12-05 03:18:31 -0800492 .suspend = ohci_hcd_pxa27x_drv_suspend,
Russell King3ae5eae2005-11-09 22:32:44 +0000493 .resume = ohci_hcd_pxa27x_drv_resume,
Richard Purdie2e1dcc12005-11-12 14:22:14 +0000494#endif
Russell King3ae5eae2005-11-09 22:32:44 +0000495 .driver = {
496 .name = "pxa27x-ohci",
Kay Sieversf4fce612008-04-10 21:29:22 -0700497 .owner = THIS_MODULE,
Russell King3ae5eae2005-11-09 22:32:44 +0000498 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499};
500