Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 23 | #include <linux/signal.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 25 | #include <linux/clk.h> |
Linus Torvalds | 4fd5f82 | 2005-10-31 07:32:56 -0800 | [diff] [blame] | 26 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <mach/hardware.h> |
| 28 | #include <mach/pxa-regs.h> |
| 29 | #include <mach/pxa2xx-regs.h> /* FIXME: for PSSR */ |
| 30 | #include <mach/ohci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | #define PXA_UHC_MAX_PORTNUM 3 |
| 33 | |
| 34 | #define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 ) |
| 35 | |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 36 | static struct clk *usb_clk; |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | /* |
| 39 | PMM_NPS_MODE -- PMM Non-power switching mode |
| 40 | Ports are powered continuously. |
| 41 | |
| 42 | PMM_GLOBAL_MODE -- PMM global switching mode |
| 43 | All ports are powered at the same time. |
| 44 | |
| 45 | PMM_PERPORT_MODE -- PMM per port switching mode |
| 46 | Ports are powered individually. |
| 47 | */ |
| 48 | static int pxa27x_ohci_select_pmm( int mode ) |
| 49 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | switch ( mode ) { |
| 51 | case PMM_NPS_MODE: |
| 52 | UHCRHDA |= RH_A_NPS; |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 53 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | case PMM_GLOBAL_MODE: |
| 55 | UHCRHDA &= ~(RH_A_NPS & RH_A_PSM); |
| 56 | break; |
| 57 | case PMM_PERPORT_MODE: |
| 58 | UHCRHDA &= ~(RH_A_NPS); |
| 59 | UHCRHDA |= RH_A_PSM; |
| 60 | |
| 61 | /* Set port power control mask bits, only 3 ports. */ |
| 62 | UHCRHDB |= (0x7<<17); |
| 63 | break; |
| 64 | default: |
| 65 | printk( KERN_ERR |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 66 | "Invalid mode %d, set to non-power switch mode.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | mode ); |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | UHCRHDA |= RH_A_NPS; |
| 70 | } |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | extern int usb_disabled(void); |
| 76 | |
| 77 | /*-------------------------------------------------------------------------*/ |
| 78 | |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame^] | 79 | static inline void pxa27x_setup_hc(struct pxaohci_platform_data *inf) |
| 80 | { |
| 81 | uint32_t uhchr = UHCHR; |
| 82 | uint32_t uhcrhda = UHCRHDA; |
| 83 | |
| 84 | if (inf->flags & ENABLE_PORT1) |
| 85 | uhchr &= ~UHCHR_SSEP1; |
| 86 | |
| 87 | if (inf->flags & ENABLE_PORT2) |
| 88 | uhchr &= ~UHCHR_SSEP2; |
| 89 | |
| 90 | if (inf->flags & ENABLE_PORT3) |
| 91 | uhchr &= ~UHCHR_SSEP3; |
| 92 | |
| 93 | if (inf->flags & POWER_CONTROL_LOW) |
| 94 | uhchr |= UHCHR_PCPL; |
| 95 | |
| 96 | if (inf->flags & POWER_SENSE_LOW) |
| 97 | uhchr |= UHCHR_PSPL; |
| 98 | |
| 99 | if (inf->flags & NO_OC_PROTECTION) |
| 100 | uhcrhda |= UHCRHDA_NOCP; |
| 101 | |
| 102 | if (inf->flags & OC_MODE_PERPORT) |
| 103 | uhcrhda |= UHCRHDA_OCPM; |
| 104 | |
| 105 | if (inf->power_on_delay) { |
| 106 | uhcrhda &= ~UHCRHDA_POTPGT(0xff); |
| 107 | uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2); |
| 108 | } |
| 109 | |
| 110 | UHCHR = uhchr; |
| 111 | UHCRHDA = uhcrhda; |
| 112 | } |
| 113 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 114 | static int pxa27x_start_hc(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 116 | int retval = 0; |
| 117 | struct pxaohci_platform_data *inf; |
| 118 | |
| 119 | inf = dev->platform_data; |
| 120 | |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 121 | clk_enable(usb_clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
| 123 | UHCHR |= UHCHR_FHR; |
| 124 | udelay(11); |
| 125 | UHCHR &= ~UHCHR_FHR; |
| 126 | |
| 127 | UHCHR |= UHCHR_FSBIR; |
| 128 | while (UHCHR & UHCHR_FSBIR) |
| 129 | cpu_relax(); |
| 130 | |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame^] | 131 | pxa27x_setup_hc(inf); |
| 132 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 133 | if (inf->init) |
| 134 | retval = inf->init(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 136 | if (retval < 0) |
| 137 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | UHCHR &= ~UHCHR_SSE; |
| 140 | |
| 141 | UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE); |
David Brownell | 155faf5 | 2005-08-31 11:54:09 -0700 | [diff] [blame] | 142 | |
| 143 | /* Clear any OTG Pin Hold */ |
Philipp Zabel | d438ae5 | 2008-06-06 18:40:47 +0100 | [diff] [blame] | 144 | if (cpu_is_pxa27x() && (PSSR & PSSR_OTGPH)) |
David Brownell | 155faf5 | 2005-08-31 11:54:09 -0700 | [diff] [blame] | 145 | PSSR |= PSSR_OTGPH; |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 146 | |
| 147 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 150 | static void pxa27x_stop_hc(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | { |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 152 | struct pxaohci_platform_data *inf; |
| 153 | |
| 154 | inf = dev->platform_data; |
| 155 | |
| 156 | if (inf->exit) |
| 157 | inf->exit(dev); |
| 158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | UHCHR |= UHCHR_FHR; |
| 160 | udelay(11); |
| 161 | UHCHR &= ~UHCHR_FHR; |
| 162 | |
| 163 | UHCCOMS |= 1; |
| 164 | udelay(10); |
| 165 | |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 166 | clk_disable(usb_clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | |
| 170 | /*-------------------------------------------------------------------------*/ |
| 171 | |
| 172 | /* configure so an HC device and id are always provided */ |
| 173 | /* always called with process context; sleeping is OK */ |
| 174 | |
| 175 | |
| 176 | /** |
| 177 | * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs |
| 178 | * Context: !in_interrupt() |
| 179 | * |
| 180 | * Allocates basic resources for this USB host controller, and |
| 181 | * then invokes the start() method for the HCD associated with it |
| 182 | * through the hotplug entry's driver_data. |
| 183 | * |
| 184 | */ |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 185 | int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | { |
| 187 | int retval; |
| 188 | struct usb_hcd *hcd; |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 189 | struct pxaohci_platform_data *inf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 191 | inf = pdev->dev.platform_data; |
| 192 | |
| 193 | if (!inf) |
| 194 | return -ENODEV; |
| 195 | |
| 196 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | pr_debug ("resource[1] is not IORESOURCE_IRQ"); |
| 198 | return -ENOMEM; |
| 199 | } |
| 200 | |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 201 | usb_clk = clk_get(&pdev->dev, "USBCLK"); |
| 202 | if (IS_ERR(usb_clk)) |
| 203 | return PTR_ERR(usb_clk); |
| 204 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 205 | hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | if (!hcd) |
| 207 | return -ENOMEM; |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 208 | hcd->rsrc_start = pdev->resource[0].start; |
| 209 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | |
| 211 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { |
| 212 | pr_debug("request_mem_region failed"); |
| 213 | retval = -EBUSY; |
| 214 | goto err1; |
| 215 | } |
| 216 | |
| 217 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); |
| 218 | if (!hcd->regs) { |
| 219 | pr_debug("ioremap failed"); |
| 220 | retval = -ENOMEM; |
| 221 | goto err2; |
| 222 | } |
| 223 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 224 | if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) { |
| 225 | pr_debug("pxa27x_start_hc failed"); |
| 226 | goto err3; |
| 227 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | /* Select Power Management Mode */ |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 230 | pxa27x_ohci_select_pmm(inf->port_mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Richard Purdie | 0c27c5d | 2006-06-08 22:44:07 +0100 | [diff] [blame] | 232 | if (inf->power_budget) |
| 233 | hcd->power_budget = inf->power_budget; |
| 234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | ohci_hcd_init(hcd_to_ohci(hcd)); |
| 236 | |
Thomas Gleixner | d54b5ca | 2006-07-01 19:29:44 -0700 | [diff] [blame] | 237 | retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | if (retval == 0) |
| 239 | return retval; |
| 240 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 241 | pxa27x_stop_hc(&pdev->dev); |
| 242 | err3: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | iounmap(hcd->regs); |
| 244 | err2: |
| 245 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 246 | err1: |
| 247 | usb_put_hcd(hcd); |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 248 | clk_put(usb_clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | return retval; |
| 250 | } |
| 251 | |
| 252 | |
| 253 | /* may be called without controller electrically present */ |
| 254 | /* may be called with controller, bus, and devices active */ |
| 255 | |
| 256 | /** |
| 257 | * usb_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs |
| 258 | * @dev: USB Host Controller being removed |
| 259 | * Context: !in_interrupt() |
| 260 | * |
| 261 | * Reverses the effect of usb_hcd_pxa27x_probe(), first invoking |
| 262 | * the HCD's stop() method. It is always called from a thread |
| 263 | * context, normally "rmmod", "apmd", or something similar. |
| 264 | * |
| 265 | */ |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 266 | void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | { |
| 268 | usb_remove_hcd(hcd); |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 269 | pxa27x_stop_hc(&pdev->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | iounmap(hcd->regs); |
| 271 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 272 | usb_put_hcd(hcd); |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 273 | clk_put(usb_clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | /*-------------------------------------------------------------------------*/ |
| 277 | |
| 278 | static int __devinit |
| 279 | ohci_pxa27x_start (struct usb_hcd *hcd) |
| 280 | { |
| 281 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| 282 | int ret; |
| 283 | |
| 284 | ohci_dbg (ohci, "ohci_pxa27x_start, ohci:%p", ohci); |
| 285 | |
David Brownell | fdd13b3 | 2005-08-31 11:52:57 -0700 | [diff] [blame] | 286 | /* The value of NDP in roothub_a is incorrect on this hardware */ |
| 287 | ohci->num_ports = 3; |
| 288 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | if ((ret = ohci_init(ohci)) < 0) |
| 290 | return ret; |
| 291 | |
| 292 | if ((ret = ohci_run (ohci)) < 0) { |
| 293 | err ("can't start %s", hcd->self.bus_name); |
| 294 | ohci_stop (hcd); |
| 295 | return ret; |
| 296 | } |
| 297 | |
| 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | /*-------------------------------------------------------------------------*/ |
| 302 | |
| 303 | static const struct hc_driver ohci_pxa27x_hc_driver = { |
| 304 | .description = hcd_name, |
| 305 | .product_desc = "PXA27x OHCI", |
| 306 | .hcd_priv_size = sizeof(struct ohci_hcd), |
| 307 | |
| 308 | /* |
| 309 | * generic hardware linkage |
| 310 | */ |
| 311 | .irq = ohci_irq, |
| 312 | .flags = HCD_USB11 | HCD_MEMORY, |
| 313 | |
| 314 | /* |
| 315 | * basic lifecycle operations |
| 316 | */ |
| 317 | .start = ohci_pxa27x_start, |
| 318 | .stop = ohci_stop, |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 319 | .shutdown = ohci_shutdown, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | |
| 321 | /* |
| 322 | * managing i/o requests and associated device resources |
| 323 | */ |
| 324 | .urb_enqueue = ohci_urb_enqueue, |
| 325 | .urb_dequeue = ohci_urb_dequeue, |
| 326 | .endpoint_disable = ohci_endpoint_disable, |
| 327 | |
| 328 | /* |
| 329 | * scheduling support |
| 330 | */ |
| 331 | .get_frame_number = ohci_get_frame, |
| 332 | |
| 333 | /* |
| 334 | * root hub support |
| 335 | */ |
| 336 | .hub_status_data = ohci_hub_status_data, |
| 337 | .hub_control = ohci_hub_control, |
David Brownell | 8ad7fe1 | 2005-09-13 19:59:11 -0700 | [diff] [blame] | 338 | #ifdef CONFIG_PM |
Alan Stern | 0c0382e | 2005-10-13 17:08:02 -0400 | [diff] [blame] | 339 | .bus_suspend = ohci_bus_suspend, |
| 340 | .bus_resume = ohci_bus_resume, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | #endif |
David Brownell | 9293677 | 2005-09-22 22:32:11 -0700 | [diff] [blame] | 342 | .start_port_reset = ohci_start_port_reset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | /*-------------------------------------------------------------------------*/ |
| 346 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 347 | static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | pr_debug ("In ohci_hcd_pxa27x_drv_probe"); |
| 350 | |
| 351 | if (usb_disabled()) |
| 352 | return -ENODEV; |
| 353 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 354 | return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 357 | static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | { |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 359 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
| 361 | usb_hcd_pxa27x_remove(hcd, pdev); |
Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 362 | platform_set_drvdata(pdev, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | return 0; |
| 364 | } |
| 365 | |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 366 | #ifdef CONFIG_PM |
| 367 | static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | { |
Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 369 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 370 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 371 | |
| 372 | if (time_before(jiffies, ohci->next_statechange)) |
| 373 | msleep(5); |
| 374 | ohci->next_statechange = jiffies; |
| 375 | |
| 376 | pxa27x_stop_hc(&pdev->dev); |
Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 377 | hcd->state = HC_STATE_SUSPENDED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
| 379 | return 0; |
| 380 | } |
| 381 | |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 382 | static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | { |
Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 384 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 385 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 386 | int status; |
| 387 | |
| 388 | if (time_before(jiffies, ohci->next_statechange)) |
| 389 | msleep(5); |
| 390 | ohci->next_statechange = jiffies; |
| 391 | |
| 392 | if ((status = pxa27x_start_hc(&pdev->dev)) < 0) |
| 393 | return status; |
| 394 | |
Alan Stern | 43bbb7e | 2008-04-03 18:03:17 -0400 | [diff] [blame] | 395 | ohci_finish_controller_resume(hcd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | return 0; |
| 397 | } |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 398 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
Kay Sievers | f4fce61 | 2008-04-10 21:29:22 -0700 | [diff] [blame] | 400 | /* work with hotplug and coldplug */ |
| 401 | MODULE_ALIAS("platform:pxa27x-ohci"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 403 | static struct platform_driver ohci_hcd_pxa27x_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | .probe = ohci_hcd_pxa27x_drv_probe, |
| 405 | .remove = ohci_hcd_pxa27x_drv_remove, |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 406 | .shutdown = usb_hcd_platform_shutdown, |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 407 | #ifdef CONFIG_PM |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 408 | .suspend = ohci_hcd_pxa27x_drv_suspend, |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 409 | .resume = ohci_hcd_pxa27x_drv_resume, |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 410 | #endif |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 411 | .driver = { |
| 412 | .name = "pxa27x-ohci", |
Kay Sievers | f4fce61 | 2008-04-10 21:29:22 -0700 | [diff] [blame] | 413 | .owner = THIS_MODULE, |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 414 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | }; |
| 416 | |