diff options
Diffstat (limited to 'drivers/usb/host')
39 files changed, 3086 insertions, 3019 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index bf8be2a41a4a..0b87480dd713 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -30,8 +30,8 @@ config USB_EHCI_HCD | |||
30 | module will be called ehci-hcd. | 30 | module will be called ehci-hcd. |
31 | 31 | ||
32 | config USB_EHCI_ROOT_HUB_TT | 32 | config USB_EHCI_ROOT_HUB_TT |
33 | bool "Root Hub Transaction Translators (EXPERIMENTAL)" | 33 | bool "Root Hub Transaction Translators" |
34 | depends on USB_EHCI_HCD && EXPERIMENTAL | 34 | depends on USB_EHCI_HCD |
35 | ---help--- | 35 | ---help--- |
36 | Some EHCI chips have vendor-specific extensions to integrate | 36 | Some EHCI chips have vendor-specific extensions to integrate |
37 | transaction translators, so that no OHCI or UHCI companion | 37 | transaction translators, so that no OHCI or UHCI companion |
@@ -260,3 +260,9 @@ config USB_R8A66597_HCD | |||
260 | To compile this driver as a module, choose M here: the | 260 | To compile this driver as a module, choose M here: the |
261 | module will be called r8a66597-hcd. | 261 | module will be called r8a66597-hcd. |
262 | 262 | ||
263 | config SUPERH_ON_CHIP_R8A66597 | ||
264 | boolean "Enable SuperH on-chip USB like the R8A66597" | ||
265 | depends on USB_R8A66597_HCD && CPU_SUBTYPE_SH7366 | ||
266 | help | ||
267 | Renesas SuperH processor has USB like the R8A66597. | ||
268 | This driver supported processor is SH7366. | ||
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index da7532d38bf1..8b5f991e949c 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c | |||
@@ -237,6 +237,7 @@ static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | |||
237 | if (usb_disabled()) | 237 | if (usb_disabled()) |
238 | return -ENODEV; | 238 | return -ENODEV; |
239 | 239 | ||
240 | /* FIXME we only want one one probe() not two */ | ||
240 | ret = usb_ehci_au1xxx_probe(&ehci_au1xxx_hc_driver, &hcd, pdev); | 241 | ret = usb_ehci_au1xxx_probe(&ehci_au1xxx_hc_driver, &hcd, pdev); |
241 | return ret; | 242 | return ret; |
242 | } | 243 | } |
@@ -245,6 +246,7 @@ static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev) | |||
245 | { | 246 | { |
246 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 247 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
247 | 248 | ||
249 | /* FIXME we only want one one remove() not two */ | ||
248 | usb_ehci_au1xxx_remove(hcd, pdev); | 250 | usb_ehci_au1xxx_remove(hcd, pdev); |
249 | return 0; | 251 | return 0; |
250 | } | 252 | } |
@@ -265,7 +267,7 @@ static int ehci_hcd_au1xxx_drv_resume(struct device *dev) | |||
265 | return 0; | 267 | return 0; |
266 | } | 268 | } |
267 | */ | 269 | */ |
268 | MODULE_ALIAS("au1xxx-ehci"); | 270 | MODULE_ALIAS("platform:au1xxx-ehci"); |
269 | static struct platform_driver ehci_hcd_au1xxx_driver = { | 271 | static struct platform_driver ehci_hcd_au1xxx_driver = { |
270 | .probe = ehci_hcd_au1xxx_drv_probe, | 272 | .probe = ehci_hcd_au1xxx_drv_probe, |
271 | .remove = ehci_hcd_au1xxx_drv_remove, | 273 | .remove = ehci_hcd_au1xxx_drv_remove, |
@@ -274,6 +276,5 @@ static struct platform_driver ehci_hcd_au1xxx_driver = { | |||
274 | /*.resume = ehci_hcd_au1xxx_drv_resume, */ | 276 | /*.resume = ehci_hcd_au1xxx_drv_resume, */ |
275 | .driver = { | 277 | .driver = { |
276 | .name = "au1xxx-ehci", | 278 | .name = "au1xxx-ehci", |
277 | .bus = &platform_bus_type | ||
278 | } | 279 | } |
279 | }; | 280 | }; |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index 64ebfc5548a3..4af90df8e7de 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #define ehci_warn(ehci, fmt, args...) \ | 27 | #define ehci_warn(ehci, fmt, args...) \ |
28 | dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) | 28 | dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) |
29 | 29 | ||
30 | #ifdef EHCI_VERBOSE_DEBUG | 30 | #ifdef VERBOSE_DEBUG |
31 | # define vdbg dbg | 31 | # define vdbg dbg |
32 | # define ehci_vdbg ehci_dbg | 32 | # define ehci_vdbg ehci_dbg |
33 | #else | 33 | #else |
@@ -670,7 +670,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
670 | 670 | ||
671 | spin_lock_irqsave (&ehci->lock, flags); | 671 | spin_lock_irqsave (&ehci->lock, flags); |
672 | 672 | ||
673 | if (buf->bus->controller->power.power_state.event) { | 673 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { |
674 | size = scnprintf (next, size, | 674 | size = scnprintf (next, size, |
675 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" | 675 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" |
676 | "%s\n" | 676 | "%s\n" |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index adb0defa1631..6d9bed6c1f48 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * (C) Copyright David Brownell 2000-2002 | ||
3 | * Copyright (c) 2005 MontaVista Software | 2 | * Copyright (c) 2005 MontaVista Software |
4 | * | 3 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
@@ -28,7 +27,6 @@ | |||
28 | /* FIXME: Power Management is un-ported so temporarily disable it */ | 27 | /* FIXME: Power Management is un-ported so temporarily disable it */ |
29 | #undef CONFIG_PM | 28 | #undef CONFIG_PM |
30 | 29 | ||
31 | /* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ | ||
32 | 30 | ||
33 | /* configure so an HC device and id are always provided */ | 31 | /* configure so an HC device and id are always provided */ |
34 | /* always called with process context; sleeping is OK */ | 32 | /* always called with process context; sleeping is OK */ |
@@ -331,6 +329,7 @@ static int ehci_fsl_drv_probe(struct platform_device *pdev) | |||
331 | if (usb_disabled()) | 329 | if (usb_disabled()) |
332 | return -ENODEV; | 330 | return -ENODEV; |
333 | 331 | ||
332 | /* FIXME we only want one one probe() not two */ | ||
334 | return usb_hcd_fsl_probe(&ehci_fsl_hc_driver, pdev); | 333 | return usb_hcd_fsl_probe(&ehci_fsl_hc_driver, pdev); |
335 | } | 334 | } |
336 | 335 | ||
@@ -338,12 +337,12 @@ static int ehci_fsl_drv_remove(struct platform_device *pdev) | |||
338 | { | 337 | { |
339 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 338 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
340 | 339 | ||
340 | /* FIXME we only want one one remove() not two */ | ||
341 | usb_hcd_fsl_remove(hcd, pdev); | 341 | usb_hcd_fsl_remove(hcd, pdev); |
342 | |||
343 | return 0; | 342 | return 0; |
344 | } | 343 | } |
345 | 344 | ||
346 | MODULE_ALIAS("fsl-ehci"); | 345 | MODULE_ALIAS("platform:fsl-ehci"); |
347 | 346 | ||
348 | static struct platform_driver ehci_fsl_driver = { | 347 | static struct platform_driver ehci_fsl_driver = { |
349 | .probe = ehci_fsl_drv_probe, | 348 | .probe = ehci_fsl_drv_probe, |
@@ -351,5 +350,5 @@ static struct platform_driver ehci_fsl_driver = { | |||
351 | .shutdown = usb_hcd_platform_shutdown, | 350 | .shutdown = usb_hcd_platform_shutdown, |
352 | .driver = { | 351 | .driver = { |
353 | .name = "fsl-ehci", | 352 | .name = "fsl-ehci", |
354 | }, | 353 | }, |
355 | }; | 354 | }; |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 85074cb36f38..369a8a5ea7bb 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -57,35 +57,6 @@ | |||
57 | * Special thanks to Intel and VIA for providing host controllers to | 57 | * Special thanks to Intel and VIA for providing host controllers to |
58 | * test this driver on, and Cypress (including In-System Design) for | 58 | * test this driver on, and Cypress (including In-System Design) for |
59 | * providing early devices for those host controllers to talk to! | 59 | * providing early devices for those host controllers to talk to! |
60 | * | ||
61 | * HISTORY: | ||
62 | * | ||
63 | * 2004-05-10 Root hub and PCI suspend/resume support; remote wakeup. (db) | ||
64 | * 2004-02-24 Replace pci_* with generic dma_* API calls (dsaxena@plexity.net) | ||
65 | * 2003-12-29 Rewritten high speed iso transfer support (by Michal Sojka, | ||
66 | * <sojkam@centrum.cz>, updates by DB). | ||
67 | * | ||
68 | * 2002-11-29 Correct handling for hw async_next register. | ||
69 | * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared; | ||
70 | * only scheduling is different, no arbitrary limitations. | ||
71 | * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support, | ||
72 | * clean up HC run state handshaking. | ||
73 | * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts | ||
74 | * 2002-05-11 Clear TT errors for FS/LS ctrl/bulk. Fill in some other | ||
75 | * missing pieces: enabling 64bit dma, handoff from BIOS/SMM. | ||
76 | * 2002-05-07 Some error path cleanups to report better errors; wmb(); | ||
77 | * use non-CVS version id; better iso bandwidth claim. | ||
78 | * 2002-04-19 Control/bulk/interrupt submit no longer uses giveback() on | ||
79 | * errors in submit path. Bugfixes to interrupt scheduling/processing. | ||
80 | * 2002-03-05 Initial high-speed ISO support; reduce ITD memory; shift | ||
81 | * more checking to generic hcd framework (db). Make it work with | ||
82 | * Philips EHCI; reduce PCI traffic; shorten IRQ path (Rory Bolt). | ||
83 | * 2002-01-14 Minor cleanup; version synch. | ||
84 | * 2002-01-08 Fix roothub handoff of FS/LS to companion controllers. | ||
85 | * 2002-01-04 Control/Bulk queuing behaves. | ||
86 | * | ||
87 | * 2001-12-12 Initial patch version for Linux 2.5.1 kernel. | ||
88 | * 2001-June Works with usb-storage and NEC EHCI on 2.4 | ||
89 | */ | 60 | */ |
90 | 61 | ||
91 | #define DRIVER_VERSION "10 Dec 2004" | 62 | #define DRIVER_VERSION "10 Dec 2004" |
@@ -95,7 +66,7 @@ | |||
95 | static const char hcd_name [] = "ehci_hcd"; | 66 | static const char hcd_name [] = "ehci_hcd"; |
96 | 67 | ||
97 | 68 | ||
98 | #undef EHCI_VERBOSE_DEBUG | 69 | #undef VERBOSE_DEBUG |
99 | #undef EHCI_URB_TRACE | 70 | #undef EHCI_URB_TRACE |
100 | 71 | ||
101 | #ifdef DEBUG | 72 | #ifdef DEBUG |
@@ -174,6 +145,16 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr, | |||
174 | return -ETIMEDOUT; | 145 | return -ETIMEDOUT; |
175 | } | 146 | } |
176 | 147 | ||
148 | static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, | ||
149 | u32 mask, u32 done, int usec) | ||
150 | { | ||
151 | int error = handshake(ehci, ptr, mask, done, usec); | ||
152 | if (error) | ||
153 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
154 | |||
155 | return error; | ||
156 | } | ||
157 | |||
177 | /* force HC to halt state from unknown (EHCI spec section 2.3) */ | 158 | /* force HC to halt state from unknown (EHCI spec section 2.3) */ |
178 | static int ehci_halt (struct ehci_hcd *ehci) | 159 | static int ehci_halt (struct ehci_hcd *ehci) |
179 | { | 160 | { |
@@ -246,11 +227,9 @@ static void ehci_quiesce (struct ehci_hcd *ehci) | |||
246 | /* wait for any schedule enables/disables to take effect */ | 227 | /* wait for any schedule enables/disables to take effect */ |
247 | temp = ehci_readl(ehci, &ehci->regs->command) << 10; | 228 | temp = ehci_readl(ehci, &ehci->regs->command) << 10; |
248 | temp &= STS_ASS | STS_PSS; | 229 | temp &= STS_ASS | STS_PSS; |
249 | if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, | 230 | if (handshake_on_error_set_halt(ehci, &ehci->regs->status, |
250 | temp, 16 * 125) != 0) { | 231 | STS_ASS | STS_PSS, temp, 16 * 125)) |
251 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
252 | return; | 232 | return; |
253 | } | ||
254 | 233 | ||
255 | /* then disable anything that's still active */ | 234 | /* then disable anything that's still active */ |
256 | temp = ehci_readl(ehci, &ehci->regs->command); | 235 | temp = ehci_readl(ehci, &ehci->regs->command); |
@@ -258,11 +237,8 @@ static void ehci_quiesce (struct ehci_hcd *ehci) | |||
258 | ehci_writel(ehci, temp, &ehci->regs->command); | 237 | ehci_writel(ehci, temp, &ehci->regs->command); |
259 | 238 | ||
260 | /* hardware can take 16 microframes to turn off ... */ | 239 | /* hardware can take 16 microframes to turn off ... */ |
261 | if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, | 240 | handshake_on_error_set_halt(ehci, &ehci->regs->status, |
262 | 0, 16 * 125) != 0) { | 241 | STS_ASS | STS_PSS, 0, 16 * 125); |
263 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
264 | return; | ||
265 | } | ||
266 | } | 242 | } |
267 | 243 | ||
268 | /*-------------------------------------------------------------------------*/ | 244 | /*-------------------------------------------------------------------------*/ |
@@ -355,17 +331,13 @@ static void ehci_turn_off_all_ports(struct ehci_hcd *ehci) | |||
355 | &ehci->regs->port_status[port]); | 331 | &ehci->regs->port_status[port]); |
356 | } | 332 | } |
357 | 333 | ||
358 | /* ehci_shutdown kick in for silicon on any bus (not just pci, etc). | 334 | /* |
359 | * This forcibly disables dma and IRQs, helping kexec and other cases | 335 | * Halt HC, turn off all ports, and let the BIOS use the companion controllers. |
360 | * where the next system software may expect clean state. | 336 | * Should be called with ehci->lock held. |
361 | */ | 337 | */ |
362 | static void | 338 | static void ehci_silence_controller(struct ehci_hcd *ehci) |
363 | ehci_shutdown (struct usb_hcd *hcd) | ||
364 | { | 339 | { |
365 | struct ehci_hcd *ehci; | 340 | ehci_halt(ehci); |
366 | |||
367 | ehci = hcd_to_ehci (hcd); | ||
368 | (void) ehci_halt (ehci); | ||
369 | ehci_turn_off_all_ports(ehci); | 341 | ehci_turn_off_all_ports(ehci); |
370 | 342 | ||
371 | /* make BIOS/etc use companion controller during reboot */ | 343 | /* make BIOS/etc use companion controller during reboot */ |
@@ -375,6 +347,22 @@ ehci_shutdown (struct usb_hcd *hcd) | |||
375 | ehci_readl(ehci, &ehci->regs->configured_flag); | 347 | ehci_readl(ehci, &ehci->regs->configured_flag); |
376 | } | 348 | } |
377 | 349 | ||
350 | /* ehci_shutdown kick in for silicon on any bus (not just pci, etc). | ||
351 | * This forcibly disables dma and IRQs, helping kexec and other cases | ||
352 | * where the next system software may expect clean state. | ||
353 | */ | ||
354 | static void ehci_shutdown(struct usb_hcd *hcd) | ||
355 | { | ||
356 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
357 | |||
358 | del_timer_sync(&ehci->watchdog); | ||
359 | del_timer_sync(&ehci->iaa_watchdog); | ||
360 | |||
361 | spin_lock_irq(&ehci->lock); | ||
362 | ehci_silence_controller(ehci); | ||
363 | spin_unlock_irq(&ehci->lock); | ||
364 | } | ||
365 | |||
378 | static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | 366 | static void ehci_port_power (struct ehci_hcd *ehci, int is_on) |
379 | { | 367 | { |
380 | unsigned port; | 368 | unsigned port; |
@@ -425,15 +413,15 @@ static void ehci_work (struct ehci_hcd *ehci) | |||
425 | timer_action (ehci, TIMER_IO_WATCHDOG); | 413 | timer_action (ehci, TIMER_IO_WATCHDOG); |
426 | } | 414 | } |
427 | 415 | ||
416 | /* | ||
417 | * Called when the ehci_hcd module is removed. | ||
418 | */ | ||
428 | static void ehci_stop (struct usb_hcd *hcd) | 419 | static void ehci_stop (struct usb_hcd *hcd) |
429 | { | 420 | { |
430 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 421 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
431 | 422 | ||
432 | ehci_dbg (ehci, "stop\n"); | 423 | ehci_dbg (ehci, "stop\n"); |
433 | 424 | ||
434 | /* Turn off port power on all root hub ports. */ | ||
435 | ehci_port_power (ehci, 0); | ||
436 | |||
437 | /* no more interrupts ... */ | 425 | /* no more interrupts ... */ |
438 | del_timer_sync (&ehci->watchdog); | 426 | del_timer_sync (&ehci->watchdog); |
439 | del_timer_sync(&ehci->iaa_watchdog); | 427 | del_timer_sync(&ehci->iaa_watchdog); |
@@ -442,13 +430,10 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
442 | if (HC_IS_RUNNING (hcd->state)) | 430 | if (HC_IS_RUNNING (hcd->state)) |
443 | ehci_quiesce (ehci); | 431 | ehci_quiesce (ehci); |
444 | 432 | ||
433 | ehci_silence_controller(ehci); | ||
445 | ehci_reset (ehci); | 434 | ehci_reset (ehci); |
446 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | ||
447 | spin_unlock_irq(&ehci->lock); | 435 | spin_unlock_irq(&ehci->lock); |
448 | 436 | ||
449 | /* let companion controllers work when we aren't */ | ||
450 | ehci_writel(ehci, 0, &ehci->regs->configured_flag); | ||
451 | |||
452 | remove_companion_file(ehci); | 437 | remove_companion_file(ehci); |
453 | remove_debug_files (ehci); | 438 | remove_debug_files (ehci); |
454 | 439 | ||
@@ -676,7 +661,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
676 | cmd = ehci_readl(ehci, &ehci->regs->command); | 661 | cmd = ehci_readl(ehci, &ehci->regs->command); |
677 | bh = 0; | 662 | bh = 0; |
678 | 663 | ||
679 | #ifdef EHCI_VERBOSE_DEBUG | 664 | #ifdef VERBOSE_DEBUG |
680 | /* unrequested/ignored: Frame List Rollover */ | 665 | /* unrequested/ignored: Frame List Rollover */ |
681 | dbg_status (ehci, "irq", status); | 666 | dbg_status (ehci, "irq", status); |
682 | #endif | 667 | #endif |
@@ -710,6 +695,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
710 | /* remote wakeup [4.3.1] */ | 695 | /* remote wakeup [4.3.1] */ |
711 | if (status & STS_PCD) { | 696 | if (status & STS_PCD) { |
712 | unsigned i = HCS_N_PORTS (ehci->hcs_params); | 697 | unsigned i = HCS_N_PORTS (ehci->hcs_params); |
698 | |||
699 | /* kick root hub later */ | ||
713 | pcd_status = status; | 700 | pcd_status = status; |
714 | 701 | ||
715 | /* resume root hub? */ | 702 | /* resume root hub? */ |
@@ -738,8 +725,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
738 | 725 | ||
739 | /* PCI errors [4.15.2.4] */ | 726 | /* PCI errors [4.15.2.4] */ |
740 | if (unlikely ((status & STS_FATAL) != 0)) { | 727 | if (unlikely ((status & STS_FATAL) != 0)) { |
741 | /* bogus "fatal" IRQs appear on some chips... why? */ | ||
742 | status = ehci_readl(ehci, &ehci->regs->status); | ||
743 | dbg_cmd (ehci, "fatal", ehci_readl(ehci, | 728 | dbg_cmd (ehci, "fatal", ehci_readl(ehci, |
744 | &ehci->regs->command)); | 729 | &ehci->regs->command)); |
745 | dbg_status (ehci, "fatal", status); | 730 | dbg_status (ehci, "fatal", status); |
@@ -758,7 +743,7 @@ dead: | |||
758 | if (bh) | 743 | if (bh) |
759 | ehci_work (ehci); | 744 | ehci_work (ehci); |
760 | spin_unlock (&ehci->lock); | 745 | spin_unlock (&ehci->lock); |
761 | if (pcd_status & STS_PCD) | 746 | if (pcd_status) |
762 | usb_hcd_poll_rh_status(hcd); | 747 | usb_hcd_poll_rh_status(hcd); |
763 | return IRQ_HANDLED; | 748 | return IRQ_HANDLED; |
764 | } | 749 | } |
@@ -788,8 +773,14 @@ static int ehci_urb_enqueue ( | |||
788 | INIT_LIST_HEAD (&qtd_list); | 773 | INIT_LIST_HEAD (&qtd_list); |
789 | 774 | ||
790 | switch (usb_pipetype (urb->pipe)) { | 775 | switch (usb_pipetype (urb->pipe)) { |
791 | // case PIPE_CONTROL: | 776 | case PIPE_CONTROL: |
792 | // case PIPE_BULK: | 777 | /* qh_completions() code doesn't handle all the fault cases |
778 | * in multi-TD control transfers. Even 1KB is rare anyway. | ||
779 | */ | ||
780 | if (urb->transfer_buffer_length > (16 * 1024)) | ||
781 | return -EMSGSIZE; | ||
782 | /* FALLTHROUGH */ | ||
783 | /* case PIPE_BULK: */ | ||
793 | default: | 784 | default: |
794 | if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) | 785 | if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) |
795 | return -ENOMEM; | 786 | return -ENOMEM; |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 4e065e556e4b..efffef64f59d 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -28,7 +28,9 @@ | |||
28 | 28 | ||
29 | /*-------------------------------------------------------------------------*/ | 29 | /*-------------------------------------------------------------------------*/ |
30 | 30 | ||
31 | #ifdef CONFIG_USB_PERSIST | 31 | #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) |
32 | |||
33 | #ifdef CONFIG_PM | ||
32 | 34 | ||
33 | static int ehci_hub_control( | 35 | static int ehci_hub_control( |
34 | struct usb_hcd *hcd, | 36 | struct usb_hcd *hcd, |
@@ -104,15 +106,6 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) | |||
104 | ehci->owned_ports = 0; | 106 | ehci->owned_ports = 0; |
105 | } | 107 | } |
106 | 108 | ||
107 | #else /* CONFIG_USB_PERSIST */ | ||
108 | |||
109 | static inline void ehci_handover_companion_ports(struct ehci_hcd *ehci) | ||
110 | { } | ||
111 | |||
112 | #endif | ||
113 | |||
114 | #ifdef CONFIG_PM | ||
115 | |||
116 | static int ehci_bus_suspend (struct usb_hcd *hcd) | 109 | static int ehci_bus_suspend (struct usb_hcd *hcd) |
117 | { | 110 | { |
118 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 111 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
@@ -158,10 +151,10 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
158 | } | 151 | } |
159 | 152 | ||
160 | /* enable remote wakeup on all ports */ | 153 | /* enable remote wakeup on all ports */ |
161 | if (device_may_wakeup(&hcd->self.root_hub->dev)) | 154 | if (hcd->self.root_hub->do_remote_wakeup) |
162 | t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; | 155 | t2 |= PORT_WAKE_BITS; |
163 | else | 156 | else |
164 | t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E); | 157 | t2 &= ~PORT_WAKE_BITS; |
165 | 158 | ||
166 | if (t1 != t2) { | 159 | if (t1 != t2) { |
167 | ehci_vdbg (ehci, "port %d, %08x -> %08x\n", | 160 | ehci_vdbg (ehci, "port %d, %08x -> %08x\n", |
@@ -183,7 +176,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
183 | 176 | ||
184 | /* allow remote wakeup */ | 177 | /* allow remote wakeup */ |
185 | mask = INTR_MASK; | 178 | mask = INTR_MASK; |
186 | if (!device_may_wakeup(&hcd->self.root_hub->dev)) | 179 | if (!hcd->self.root_hub->do_remote_wakeup) |
187 | mask &= ~STS_PCD; | 180 | mask &= ~STS_PCD; |
188 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); | 181 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); |
189 | ehci_readl(ehci, &ehci->regs->intr_enable); | 182 | ehci_readl(ehci, &ehci->regs->intr_enable); |
@@ -241,8 +234,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
241 | i = HCS_N_PORTS (ehci->hcs_params); | 234 | i = HCS_N_PORTS (ehci->hcs_params); |
242 | while (i--) { | 235 | while (i--) { |
243 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); | 236 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); |
244 | temp &= ~(PORT_RWC_BITS | 237 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); |
245 | | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E); | ||
246 | if (test_bit(i, &ehci->bus_suspended) && | 238 | if (test_bit(i, &ehci->bus_suspended) && |
247 | (temp & PORT_SUSPEND)) { | 239 | (temp & PORT_SUSPEND)) { |
248 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); | 240 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); |
@@ -281,9 +273,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
281 | ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); | 273 | ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); |
282 | 274 | ||
283 | spin_unlock_irq (&ehci->lock); | 275 | spin_unlock_irq (&ehci->lock); |
284 | 276 | ehci_handover_companion_ports(ehci); | |
285 | if (!power_okay) | ||
286 | ehci_handover_companion_ports(ehci); | ||
287 | return 0; | 277 | return 0; |
288 | } | 278 | } |
289 | 279 | ||
@@ -545,8 +535,6 @@ ehci_hub_descriptor ( | |||
545 | 535 | ||
546 | /*-------------------------------------------------------------------------*/ | 536 | /*-------------------------------------------------------------------------*/ |
547 | 537 | ||
548 | #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) | ||
549 | |||
550 | static int ehci_hub_control ( | 538 | static int ehci_hub_control ( |
551 | struct usb_hcd *hcd, | 539 | struct usb_hcd *hcd, |
552 | u16 typeReq, | 540 | u16 typeReq, |
@@ -778,7 +766,7 @@ static int ehci_hub_control ( | |||
778 | if (temp & PORT_POWER) | 766 | if (temp & PORT_POWER) |
779 | status |= 1 << USB_PORT_FEAT_POWER; | 767 | status |= 1 << USB_PORT_FEAT_POWER; |
780 | 768 | ||
781 | #ifndef EHCI_VERBOSE_DEBUG | 769 | #ifndef VERBOSE_DEBUG |
782 | if (status & ~0xffff) /* only if wPortChange is interesting */ | 770 | if (status & ~0xffff) /* only if wPortChange is interesting */ |
783 | #endif | 771 | #endif |
784 | dbg_port (ehci, "GetStatus", wIndex + 1, temp); | 772 | dbg_port (ehci, "GetStatus", wIndex + 1, temp); |
@@ -812,8 +800,6 @@ static int ehci_hub_control ( | |||
812 | if ((temp & PORT_PE) == 0 | 800 | if ((temp & PORT_PE) == 0 |
813 | || (temp & PORT_RESET) != 0) | 801 | || (temp & PORT_RESET) != 0) |
814 | goto error; | 802 | goto error; |
815 | if (device_may_wakeup(&hcd->self.root_hub->dev)) | ||
816 | temp |= PORT_WAKE_BITS; | ||
817 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); | 803 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); |
818 | break; | 804 | break; |
819 | case USB_PORT_FEAT_POWER: | 805 | case USB_PORT_FEAT_POWER: |
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c index 3041d8f055f4..601c8795a854 100644 --- a/drivers/usb/host/ehci-ixp4xx.c +++ b/drivers/usb/host/ehci-ixp4xx.c | |||
@@ -140,13 +140,12 @@ static int ixp4xx_ehci_remove(struct platform_device *pdev) | |||
140 | return 0; | 140 | return 0; |
141 | } | 141 | } |
142 | 142 | ||
143 | MODULE_ALIAS("ixp4xx-ehci"); | 143 | MODULE_ALIAS("platform:ixp4xx-ehci"); |
144 | 144 | ||
145 | static struct platform_driver ixp4xx_ehci_driver = { | 145 | static struct platform_driver ixp4xx_ehci_driver = { |
146 | .probe = ixp4xx_ehci_probe, | 146 | .probe = ixp4xx_ehci_probe, |
147 | .remove = ixp4xx_ehci_remove, | 147 | .remove = ixp4xx_ehci_remove, |
148 | .driver = { | 148 | .driver = { |
149 | .name = "ixp4xx-ehci", | 149 | .name = "ixp4xx-ehci", |
150 | .bus = &platform_bus_type | ||
151 | }, | 150 | }, |
152 | }; | 151 | }; |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 72ccd56e36dd..5bb7f6bb13f3 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -130,6 +130,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
130 | case PCI_VENDOR_ID_TDI: | 130 | case PCI_VENDOR_ID_TDI: |
131 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { | 131 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { |
132 | ehci->is_tdi_rh_tt = 1; | 132 | ehci->is_tdi_rh_tt = 1; |
133 | hcd->has_tt = 1; | ||
133 | tdi_reset(ehci); | 134 | tdi_reset(ehci); |
134 | } | 135 | } |
135 | break; | 136 | break; |
@@ -221,6 +222,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
221 | ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); | 222 | ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); |
222 | #endif | 223 | #endif |
223 | 224 | ||
225 | ehci_port_power(ehci, 1); | ||
224 | retval = ehci_pci_reinit(ehci, pdev); | 226 | retval = ehci_pci_reinit(ehci, pdev); |
225 | done: | 227 | done: |
226 | return retval; | 228 | return retval; |
@@ -299,7 +301,7 @@ static int ehci_pci_resume(struct usb_hcd *hcd) | |||
299 | if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { | 301 | if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { |
300 | int mask = INTR_MASK; | 302 | int mask = INTR_MASK; |
301 | 303 | ||
302 | if (!device_may_wakeup(&hcd->self.root_hub->dev)) | 304 | if (!hcd->self.root_hub->do_remote_wakeup) |
303 | mask &= ~STS_PCD; | 305 | mask &= ~STS_PCD; |
304 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); | 306 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); |
305 | ehci_readl(ehci, &ehci->regs->intr_enable); | 307 | ehci_readl(ehci, &ehci->regs->intr_enable); |
@@ -329,7 +331,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd) | |||
329 | 331 | ||
330 | /* here we "know" root ports should always stay powered */ | 332 | /* here we "know" root ports should always stay powered */ |
331 | ehci_port_power(ehci, 1); | 333 | ehci_port_power(ehci, 1); |
332 | ehci_handover_companion_ports(ehci); | ||
333 | 334 | ||
334 | hcd->state = HC_STATE_SUSPENDED; | 335 | hcd->state = HC_STATE_SUSPENDED; |
335 | return 0; | 336 | return 0; |
@@ -353,8 +354,8 @@ static const struct hc_driver ehci_pci_hc_driver = { | |||
353 | .reset = ehci_pci_setup, | 354 | .reset = ehci_pci_setup, |
354 | .start = ehci_run, | 355 | .start = ehci_run, |
355 | #ifdef CONFIG_PM | 356 | #ifdef CONFIG_PM |
356 | .suspend = ehci_pci_suspend, | 357 | .pci_suspend = ehci_pci_suspend, |
357 | .resume = ehci_pci_resume, | 358 | .pci_resume = ehci_pci_resume, |
358 | #endif | 359 | #endif |
359 | .stop = ehci_stop, | 360 | .stop = ehci_stop, |
360 | .shutdown = ehci_shutdown, | 361 | .shutdown = ehci_shutdown, |
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c index a3249078c808..6c76036783a1 100644 --- a/drivers/usb/host/ehci-ppc-soc.c +++ b/drivers/usb/host/ehci-ppc-soc.c | |||
@@ -175,6 +175,7 @@ static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) | |||
175 | if (usb_disabled()) | 175 | if (usb_disabled()) |
176 | return -ENODEV; | 176 | return -ENODEV; |
177 | 177 | ||
178 | /* FIXME we only want one one probe() not two */ | ||
178 | ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev); | 179 | ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev); |
179 | return ret; | 180 | return ret; |
180 | } | 181 | } |
@@ -183,17 +184,17 @@ static int ehci_hcd_ppc_soc_drv_remove(struct platform_device *pdev) | |||
183 | { | 184 | { |
184 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 185 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
185 | 186 | ||
187 | /* FIXME we only want one one remove() not two */ | ||
186 | usb_ehci_ppc_soc_remove(hcd, pdev); | 188 | usb_ehci_ppc_soc_remove(hcd, pdev); |
187 | return 0; | 189 | return 0; |
188 | } | 190 | } |
189 | 191 | ||
190 | MODULE_ALIAS("ppc-soc-ehci"); | 192 | MODULE_ALIAS("platform:ppc-soc-ehci"); |
191 | static struct platform_driver ehci_ppc_soc_driver = { | 193 | static struct platform_driver ehci_ppc_soc_driver = { |
192 | .probe = ehci_hcd_ppc_soc_drv_probe, | 194 | .probe = ehci_hcd_ppc_soc_drv_probe, |
193 | .remove = ehci_hcd_ppc_soc_drv_remove, | 195 | .remove = ehci_hcd_ppc_soc_drv_remove, |
194 | .shutdown = usb_hcd_platform_shutdown, | 196 | .shutdown = usb_hcd_platform_shutdown, |
195 | .driver = { | 197 | .driver = { |
196 | .name = "ppc-soc-ehci", | 198 | .name = "ppc-soc-ehci", |
197 | .bus = &platform_bus_type | ||
198 | } | 199 | } |
199 | }; | 200 | }; |
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index bbda58eb8813..69782221bcf3 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c | |||
@@ -125,7 +125,6 @@ static int ps3_ehci_probe(struct ps3_system_bus_device *dev) | |||
125 | goto fail_irq; | 125 | goto fail_irq; |
126 | } | 126 | } |
127 | 127 | ||
128 | dev->core.power.power_state = PMSG_ON; | ||
129 | dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ | 128 | dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ |
130 | 129 | ||
131 | hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev->core.bus_id); | 130 | hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev->core.bus_id); |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 2e49de820b14..5ae689139dd0 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -242,7 +242,8 @@ __acquires(ehci->lock) | |||
242 | if (unlikely(urb->unlinked)) { | 242 | if (unlikely(urb->unlinked)) { |
243 | COUNT(ehci->stats.unlink); | 243 | COUNT(ehci->stats.unlink); |
244 | } else { | 244 | } else { |
245 | if (likely(status == -EINPROGRESS)) | 245 | /* report non-error and short read status as zero */ |
246 | if (status == -EINPROGRESS || status == -EREMOTEIO) | ||
246 | status = 0; | 247 | status = 0; |
247 | COUNT(ehci->stats.complete); | 248 | COUNT(ehci->stats.complete); |
248 | } | 249 | } |
@@ -250,7 +251,7 @@ __acquires(ehci->lock) | |||
250 | #ifdef EHCI_URB_TRACE | 251 | #ifdef EHCI_URB_TRACE |
251 | ehci_dbg (ehci, | 252 | ehci_dbg (ehci, |
252 | "%s %s urb %p ep%d%s status %d len %d/%d\n", | 253 | "%s %s urb %p ep%d%s status %d len %d/%d\n", |
253 | __FUNCTION__, urb->dev->devpath, urb, | 254 | __func__, urb->dev->devpath, urb, |
254 | usb_pipeendpoint (urb->pipe), | 255 | usb_pipeendpoint (urb->pipe), |
255 | usb_pipein (urb->pipe) ? "in" : "out", | 256 | usb_pipein (urb->pipe) ? "in" : "out", |
256 | status, | 257 | status, |
@@ -283,7 +284,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
283 | int last_status = -EINPROGRESS; | 284 | int last_status = -EINPROGRESS; |
284 | int stopped; | 285 | int stopped; |
285 | unsigned count = 0; | 286 | unsigned count = 0; |
286 | int do_status = 0; | ||
287 | u8 state; | 287 | u8 state; |
288 | u32 halt = HALT_BIT(ehci); | 288 | u32 halt = HALT_BIT(ehci); |
289 | 289 | ||
@@ -309,7 +309,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
309 | struct ehci_qtd *qtd; | 309 | struct ehci_qtd *qtd; |
310 | struct urb *urb; | 310 | struct urb *urb; |
311 | u32 token = 0; | 311 | u32 token = 0; |
312 | int qtd_status; | ||
313 | 312 | ||
314 | qtd = list_entry (entry, struct ehci_qtd, qtd_list); | 313 | qtd = list_entry (entry, struct ehci_qtd, qtd_list); |
315 | urb = qtd->urb; | 314 | urb = qtd->urb; |
@@ -336,11 +335,20 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
336 | /* always clean up qtds the hc de-activated */ | 335 | /* always clean up qtds the hc de-activated */ |
337 | if ((token & QTD_STS_ACTIVE) == 0) { | 336 | if ((token & QTD_STS_ACTIVE) == 0) { |
338 | 337 | ||
338 | /* on STALL, error, and short reads this urb must | ||
339 | * complete and all its qtds must be recycled. | ||
340 | */ | ||
339 | if ((token & QTD_STS_HALT) != 0) { | 341 | if ((token & QTD_STS_HALT) != 0) { |
340 | stopped = 1; | 342 | stopped = 1; |
341 | 343 | ||
342 | /* magic dummy for some short reads; qh won't advance. | 344 | /* magic dummy for some short reads; qh won't advance. |
343 | * that silicon quirk can kick in with this dummy too. | 345 | * that silicon quirk can kick in with this dummy too. |
346 | * | ||
347 | * other short reads won't stop the queue, including | ||
348 | * control transfers (status stage handles that) or | ||
349 | * most other single-qtd reads ... the queue stops if | ||
350 | * URB_SHORT_NOT_OK was set so the driver submitting | ||
351 | * the urbs could clean it up. | ||
344 | */ | 352 | */ |
345 | } else if (IS_SHORT_READ (token) | 353 | } else if (IS_SHORT_READ (token) |
346 | && !(qtd->hw_alt_next | 354 | && !(qtd->hw_alt_next |
@@ -354,28 +362,21 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
354 | && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) { | 362 | && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) { |
355 | break; | 363 | break; |
356 | 364 | ||
365 | /* scan the whole queue for unlinks whenever it stops */ | ||
357 | } else { | 366 | } else { |
358 | stopped = 1; | 367 | stopped = 1; |
359 | 368 | ||
360 | if (unlikely (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) | 369 | /* cancel everything if we halt, suspend, etc */ |
370 | if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) | ||
361 | last_status = -ESHUTDOWN; | 371 | last_status = -ESHUTDOWN; |
362 | 372 | ||
363 | /* ignore active urbs unless some previous qtd | 373 | /* this qtd is active; skip it unless a previous qtd |
364 | * for the urb faulted (including short read) or | 374 | * for its urb faulted, or its urb was canceled. |
365 | * its urb was canceled. we may patch qh or qtds. | ||
366 | */ | 375 | */ |
367 | if (likely(last_status == -EINPROGRESS && | 376 | else if (last_status == -EINPROGRESS && !urb->unlinked) |
368 | !urb->unlinked)) | ||
369 | continue; | ||
370 | |||
371 | /* issue status after short control reads */ | ||
372 | if (unlikely (do_status != 0) | ||
373 | && QTD_PID (token) == 0 /* OUT */) { | ||
374 | do_status = 0; | ||
375 | continue; | 377 | continue; |
376 | } | ||
377 | 378 | ||
378 | /* token in overlay may be most current */ | 379 | /* qh unlinked; token in overlay may be most current */ |
379 | if (state == QH_STATE_IDLE | 380 | if (state == QH_STATE_IDLE |
380 | && cpu_to_hc32(ehci, qtd->qtd_dma) | 381 | && cpu_to_hc32(ehci, qtd->qtd_dma) |
381 | == qh->hw_current) | 382 | == qh->hw_current) |
@@ -392,21 +393,32 @@ halt: | |||
392 | } | 393 | } |
393 | } | 394 | } |
394 | 395 | ||
395 | /* remove it from the queue */ | 396 | /* unless we already know the urb's status, collect qtd status |
396 | qtd_status = qtd_copy_status(ehci, urb, qtd->length, token); | 397 | * and update count of bytes transferred. in common short read |
397 | if (unlikely(qtd_status == -EREMOTEIO)) { | 398 | * cases with only one data qtd (including control transfers), |
398 | do_status = (!urb->unlinked && | 399 | * queue processing won't halt. but with two or more qtds (for |
399 | usb_pipecontrol(urb->pipe)); | 400 | * example, with a 32 KB transfer), when the first qtd gets a |
400 | qtd_status = 0; | 401 | * short read the second must be removed by hand. |
402 | */ | ||
403 | if (last_status == -EINPROGRESS) { | ||
404 | last_status = qtd_copy_status(ehci, urb, | ||
405 | qtd->length, token); | ||
406 | if (last_status == -EREMOTEIO | ||
407 | && (qtd->hw_alt_next | ||
408 | & EHCI_LIST_END(ehci))) | ||
409 | last_status = -EINPROGRESS; | ||
401 | } | 410 | } |
402 | if (likely(last_status == -EINPROGRESS)) | ||
403 | last_status = qtd_status; | ||
404 | 411 | ||
412 | /* if we're removing something not at the queue head, | ||
413 | * patch the hardware queue pointer. | ||
414 | */ | ||
405 | if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { | 415 | if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { |
406 | last = list_entry (qtd->qtd_list.prev, | 416 | last = list_entry (qtd->qtd_list.prev, |
407 | struct ehci_qtd, qtd_list); | 417 | struct ehci_qtd, qtd_list); |
408 | last->hw_next = qtd->hw_next; | 418 | last->hw_next = qtd->hw_next; |
409 | } | 419 | } |
420 | |||
421 | /* remove qtd; it's recycled after possible urb completion */ | ||
410 | list_del (&qtd->qtd_list); | 422 | list_del (&qtd->qtd_list); |
411 | last = qtd; | 423 | last = qtd; |
412 | } | 424 | } |
@@ -431,7 +443,15 @@ halt: | |||
431 | qh_refresh(ehci, qh); | 443 | qh_refresh(ehci, qh); |
432 | break; | 444 | break; |
433 | case QH_STATE_LINKED: | 445 | case QH_STATE_LINKED: |
434 | /* should be rare for periodic transfers, | 446 | /* We won't refresh a QH that's linked (after the HC |
447 | * stopped the queue). That avoids a race: | ||
448 | * - HC reads first part of QH; | ||
449 | * - CPU updates that first part and the token; | ||
450 | * - HC reads rest of that QH, including token | ||
451 | * Result: HC gets an inconsistent image, and then | ||
452 | * DMAs to/from the wrong memory (corrupting it). | ||
453 | * | ||
454 | * That should be rare for interrupt transfers, | ||
435 | * except maybe high bandwidth ... | 455 | * except maybe high bandwidth ... |
436 | */ | 456 | */ |
437 | if ((cpu_to_hc32(ehci, QH_SMASK) | 457 | if ((cpu_to_hc32(ehci, QH_SMASK) |
@@ -549,6 +569,12 @@ qh_urb_transaction ( | |||
549 | this_qtd_len = qtd_fill(ehci, qtd, buf, len, token, maxpacket); | 569 | this_qtd_len = qtd_fill(ehci, qtd, buf, len, token, maxpacket); |
550 | len -= this_qtd_len; | 570 | len -= this_qtd_len; |
551 | buf += this_qtd_len; | 571 | buf += this_qtd_len; |
572 | |||
573 | /* | ||
574 | * short reads advance to a "magic" dummy instead of the next | ||
575 | * qtd ... that forces the queue to stop, for manual cleanup. | ||
576 | * (this will usually be overridden later.) | ||
577 | */ | ||
552 | if (is_input) | 578 | if (is_input) |
553 | qtd->hw_alt_next = ehci->async->hw_alt_next; | 579 | qtd->hw_alt_next = ehci->async->hw_alt_next; |
554 | 580 | ||
@@ -568,8 +594,10 @@ qh_urb_transaction ( | |||
568 | list_add_tail (&qtd->qtd_list, head); | 594 | list_add_tail (&qtd->qtd_list, head); |
569 | } | 595 | } |
570 | 596 | ||
571 | /* unless the bulk/interrupt caller wants a chance to clean | 597 | /* |
572 | * up after short reads, hc should advance qh past this urb | 598 | * unless the caller requires manual cleanup after short reads, |
599 | * have the alt_next mechanism keep the queue running after the | ||
600 | * last data qtd (the only one, for control and most other cases). | ||
573 | */ | 601 | */ |
574 | if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 | 602 | if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 |
575 | || usb_pipecontrol (urb->pipe))) | 603 | || usb_pipecontrol (urb->pipe))) |
@@ -657,6 +685,14 @@ qh_make ( | |||
657 | type = usb_pipetype (urb->pipe); | 685 | type = usb_pipetype (urb->pipe); |
658 | maxp = usb_maxpacket (urb->dev, urb->pipe, !is_input); | 686 | maxp = usb_maxpacket (urb->dev, urb->pipe, !is_input); |
659 | 687 | ||
688 | /* 1024 byte maxpacket is a hardware ceiling. High bandwidth | ||
689 | * acts like up to 3KB, but is built from smaller packets. | ||
690 | */ | ||
691 | if (max_packet(maxp) > 1024) { | ||
692 | ehci_dbg(ehci, "bogus qh maxpacket %d\n", max_packet(maxp)); | ||
693 | goto done; | ||
694 | } | ||
695 | |||
660 | /* Compute interrupt scheduling parameters just once, and save. | 696 | /* Compute interrupt scheduling parameters just once, and save. |
661 | * - allowing for high bandwidth, how many nsec/uframe are used? | 697 | * - allowing for high bandwidth, how many nsec/uframe are used? |
662 | * - split transactions need a second CSPLIT uframe; same question | 698 | * - split transactions need a second CSPLIT uframe; same question |
@@ -757,7 +793,13 @@ qh_make ( | |||
757 | info2 |= (EHCI_TUNE_MULT_HS << 30); | 793 | info2 |= (EHCI_TUNE_MULT_HS << 30); |
758 | } else if (type == PIPE_BULK) { | 794 | } else if (type == PIPE_BULK) { |
759 | info1 |= (EHCI_TUNE_RL_HS << 28); | 795 | info1 |= (EHCI_TUNE_RL_HS << 28); |
760 | info1 |= 512 << 16; /* usb2 fixed maxpacket */ | 796 | /* The USB spec says that high speed bulk endpoints |
797 | * always use 512 byte maxpacket. But some device | ||
798 | * vendors decided to ignore that, and MSFT is happy | ||
799 | * to help them do so. So now people expect to use | ||
800 | * such nonconformant devices with Linux too; sigh. | ||
801 | */ | ||
802 | info1 |= max_packet(maxp) << 16; | ||
761 | info2 |= (EHCI_TUNE_MULT_HS << 30); | 803 | info2 |= (EHCI_TUNE_MULT_HS << 30); |
762 | } else { /* PIPE_INTERRUPT */ | 804 | } else { /* PIPE_INTERRUPT */ |
763 | info1 |= max_packet (maxp) << 16; | 805 | info1 |= max_packet (maxp) << 16; |
@@ -932,7 +974,7 @@ submit_async ( | |||
932 | #ifdef EHCI_URB_TRACE | 974 | #ifdef EHCI_URB_TRACE |
933 | ehci_dbg (ehci, | 975 | ehci_dbg (ehci, |
934 | "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n", | 976 | "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n", |
935 | __FUNCTION__, urb->dev->devpath, urb, | 977 | __func__, urb->dev->devpath, urb, |
936 | epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", | 978 | epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", |
937 | urb->transfer_buffer_length, | 979 | urb->transfer_buffer_length, |
938 | qtd, urb->ep->hcpriv); | 980 | qtd, urb->ep->hcpriv); |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 8a8e08a51ba3..be575e46eac3 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -440,11 +440,10 @@ static int enable_periodic (struct ehci_hcd *ehci) | |||
440 | /* did clearing PSE did take effect yet? | 440 | /* did clearing PSE did take effect yet? |
441 | * takes effect only at frame boundaries... | 441 | * takes effect only at frame boundaries... |
442 | */ | 442 | */ |
443 | status = handshake(ehci, &ehci->regs->status, STS_PSS, 0, 9 * 125); | 443 | status = handshake_on_error_set_halt(ehci, &ehci->regs->status, |
444 | if (status != 0) { | 444 | STS_PSS, 0, 9 * 125); |
445 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | 445 | if (status) |
446 | return status; | 446 | return status; |
447 | } | ||
448 | 447 | ||
449 | cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE; | 448 | cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE; |
450 | ehci_writel(ehci, cmd, &ehci->regs->command); | 449 | ehci_writel(ehci, cmd, &ehci->regs->command); |
@@ -465,11 +464,10 @@ static int disable_periodic (struct ehci_hcd *ehci) | |||
465 | /* did setting PSE not take effect yet? | 464 | /* did setting PSE not take effect yet? |
466 | * takes effect only at frame boundaries... | 465 | * takes effect only at frame boundaries... |
467 | */ | 466 | */ |
468 | status = handshake(ehci, &ehci->regs->status, STS_PSS, STS_PSS, 9 * 125); | 467 | status = handshake_on_error_set_halt(ehci, &ehci->regs->status, |
469 | if (status != 0) { | 468 | STS_PSS, STS_PSS, 9 * 125); |
470 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | 469 | if (status) |
471 | return status; | 470 | return status; |
472 | } | ||
473 | 471 | ||
474 | cmd = ehci_readl(ehci, &ehci->regs->command) & ~CMD_PSE; | 472 | cmd = ehci_readl(ehci, &ehci->regs->command) & ~CMD_PSE; |
475 | ehci_writel(ehci, cmd, &ehci->regs->command); | 473 | ehci_writel(ehci, cmd, &ehci->regs->command); |
@@ -1183,21 +1181,18 @@ itd_urb_transaction ( | |||
1183 | struct ehci_itd, itd_list); | 1181 | struct ehci_itd, itd_list); |
1184 | list_del (&itd->itd_list); | 1182 | list_del (&itd->itd_list); |
1185 | itd_dma = itd->itd_dma; | 1183 | itd_dma = itd->itd_dma; |
1186 | } else | 1184 | } else { |
1187 | itd = NULL; | ||
1188 | |||
1189 | if (!itd) { | ||
1190 | spin_unlock_irqrestore (&ehci->lock, flags); | 1185 | spin_unlock_irqrestore (&ehci->lock, flags); |
1191 | itd = dma_pool_alloc (ehci->itd_pool, mem_flags, | 1186 | itd = dma_pool_alloc (ehci->itd_pool, mem_flags, |
1192 | &itd_dma); | 1187 | &itd_dma); |
1193 | spin_lock_irqsave (&ehci->lock, flags); | 1188 | spin_lock_irqsave (&ehci->lock, flags); |
1189 | if (!itd) { | ||
1190 | iso_sched_free(stream, sched); | ||
1191 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
1192 | return -ENOMEM; | ||
1193 | } | ||
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | if (unlikely (NULL == itd)) { | ||
1197 | iso_sched_free (stream, sched); | ||
1198 | spin_unlock_irqrestore (&ehci->lock, flags); | ||
1199 | return -ENOMEM; | ||
1200 | } | ||
1201 | memset (itd, 0, sizeof *itd); | 1196 | memset (itd, 0, sizeof *itd); |
1202 | itd->itd_dma = itd_dma; | 1197 | itd->itd_dma = itd_dma; |
1203 | list_add (&itd->itd_list, &sched->td_list); | 1198 | list_add (&itd->itd_list, &sched->td_list); |
@@ -1682,7 +1677,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
1682 | #ifdef EHCI_URB_TRACE | 1677 | #ifdef EHCI_URB_TRACE |
1683 | ehci_dbg (ehci, | 1678 | ehci_dbg (ehci, |
1684 | "%s %s urb %p ep%d%s len %d, %d pkts %d uframes [%p]\n", | 1679 | "%s %s urb %p ep%d%s len %d, %d pkts %d uframes [%p]\n", |
1685 | __FUNCTION__, urb->dev->devpath, urb, | 1680 | __func__, urb->dev->devpath, urb, |
1686 | usb_pipeendpoint (urb->pipe), | 1681 | usb_pipeendpoint (urb->pipe), |
1687 | usb_pipein (urb->pipe) ? "in" : "out", | 1682 | usb_pipein (urb->pipe) ? "in" : "out", |
1688 | urb->transfer_buffer_length, | 1683 | urb->transfer_buffer_length, |
@@ -1816,21 +1811,18 @@ sitd_urb_transaction ( | |||
1816 | struct ehci_sitd, sitd_list); | 1811 | struct ehci_sitd, sitd_list); |
1817 | list_del (&sitd->sitd_list); | 1812 | list_del (&sitd->sitd_list); |
1818 | sitd_dma = sitd->sitd_dma; | 1813 | sitd_dma = sitd->sitd_dma; |
1819 | } else | 1814 | } else { |
1820 | sitd = NULL; | ||
1821 | |||
1822 | if (!sitd) { | ||
1823 | spin_unlock_irqrestore (&ehci->lock, flags); | 1815 | spin_unlock_irqrestore (&ehci->lock, flags); |
1824 | sitd = dma_pool_alloc (ehci->sitd_pool, mem_flags, | 1816 | sitd = dma_pool_alloc (ehci->sitd_pool, mem_flags, |
1825 | &sitd_dma); | 1817 | &sitd_dma); |
1826 | spin_lock_irqsave (&ehci->lock, flags); | 1818 | spin_lock_irqsave (&ehci->lock, flags); |
1819 | if (!sitd) { | ||
1820 | iso_sched_free(stream, iso_sched); | ||
1821 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
1822 | return -ENOMEM; | ||
1823 | } | ||
1827 | } | 1824 | } |
1828 | 1825 | ||
1829 | if (!sitd) { | ||
1830 | iso_sched_free (stream, iso_sched); | ||
1831 | spin_unlock_irqrestore (&ehci->lock, flags); | ||
1832 | return -ENOMEM; | ||
1833 | } | ||
1834 | memset (sitd, 0, sizeof *sitd); | 1826 | memset (sitd, 0, sizeof *sitd); |
1835 | sitd->sitd_dma = sitd_dma; | 1827 | sitd->sitd_dma = sitd_dma; |
1836 | list_add (&sitd->sitd_list, &iso_sched->td_list); | 1828 | list_add (&sitd->sitd_list, &iso_sched->td_list); |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 203a3359a648..20b9a0d07420 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -1400,7 +1400,7 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd) | |||
1400 | spin_unlock_irqrestore(&isp116x->lock, flags); | 1400 | spin_unlock_irqrestore(&isp116x->lock, flags); |
1401 | val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); | 1401 | val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); |
1402 | val |= HCCONTROL_USB_SUSPEND; | 1402 | val |= HCCONTROL_USB_SUSPEND; |
1403 | if (device_may_wakeup(&hcd->self.root_hub->dev)) | 1403 | if (hcd->self.root_hub->do_remote_wakeup) |
1404 | val |= HCCONTROL_RWE; | 1404 | val |= HCCONTROL_RWE; |
1405 | /* Wait for usb transfers to finish */ | 1405 | /* Wait for usb transfers to finish */ |
1406 | msleep(2); | 1406 | msleep(2); |
@@ -1442,11 +1442,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd) | |||
1442 | break; | 1442 | break; |
1443 | case HCCONTROL_USB_OPER: | 1443 | case HCCONTROL_USB_OPER: |
1444 | spin_unlock_irq(&isp116x->lock); | 1444 | spin_unlock_irq(&isp116x->lock); |
1445 | /* Without setting power_state here the | ||
1446 | SUSPENDED state won't be removed from | ||
1447 | sysfs/usbN/power.state as a response to remote | ||
1448 | wakeup. Maybe in the future. */ | ||
1449 | hcd->self.root_hub->dev.power.power_state = PMSG_ON; | ||
1450 | return 0; | 1445 | return 0; |
1451 | default: | 1446 | default: |
1452 | /* HCCONTROL_USB_RESET: this may happen, when during | 1447 | /* HCCONTROL_USB_RESET: this may happen, when during |
@@ -1460,7 +1455,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd) | |||
1460 | if ((isp116x->rhdesca & RH_A_NDP) == 2) | 1455 | if ((isp116x->rhdesca & RH_A_NDP) == 2) |
1461 | isp116x_hub_control(hcd, SetPortFeature, | 1456 | isp116x_hub_control(hcd, SetPortFeature, |
1462 | USB_PORT_FEAT_POWER, 2, NULL, 0); | 1457 | USB_PORT_FEAT_POWER, 2, NULL, 0); |
1463 | hcd->self.root_hub->dev.power.power_state = PMSG_ON; | ||
1464 | return 0; | 1458 | return 0; |
1465 | } | 1459 | } |
1466 | 1460 | ||
@@ -1486,8 +1480,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd) | |||
1486 | isp116x_write_reg32(isp116x, HCCONTROL, | 1480 | isp116x_write_reg32(isp116x, HCCONTROL, |
1487 | (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER); | 1481 | (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER); |
1488 | spin_unlock_irq(&isp116x->lock); | 1482 | spin_unlock_irq(&isp116x->lock); |
1489 | /* see analogous comment above */ | ||
1490 | hcd->self.root_hub->dev.power.power_state = PMSG_ON; | ||
1491 | hcd->state = HC_STATE_RUNNING; | 1483 | hcd->state = HC_STATE_RUNNING; |
1492 | 1484 | ||
1493 | return 0; | 1485 | return 0; |
@@ -1663,7 +1655,6 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
1663 | static int isp116x_suspend(struct platform_device *dev, pm_message_t state) | 1655 | static int isp116x_suspend(struct platform_device *dev, pm_message_t state) |
1664 | { | 1656 | { |
1665 | VDBG("%s: state %x\n", __func__, state.event); | 1657 | VDBG("%s: state %x\n", __func__, state.event); |
1666 | dev->dev.power.power_state = state; | ||
1667 | return 0; | 1658 | return 0; |
1668 | } | 1659 | } |
1669 | 1660 | ||
@@ -1672,8 +1663,7 @@ static int isp116x_suspend(struct platform_device *dev, pm_message_t state) | |||
1672 | */ | 1663 | */ |
1673 | static int isp116x_resume(struct platform_device *dev) | 1664 | static int isp116x_resume(struct platform_device *dev) |
1674 | { | 1665 | { |
1675 | VDBG("%s: state %x\n", __func__, dev->power.power_state.event); | 1666 | VDBG("%s\n", __func__); |
1676 | dev->dev.power.power_state = PMSG_ON; | ||
1677 | return 0; | 1667 | return 0; |
1678 | } | 1668 | } |
1679 | 1669 | ||
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index d72dc07dda01..c96db1153dcf 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -261,7 +261,6 @@ static const struct hc_driver ohci_at91_hc_driver = { | |||
261 | */ | 261 | */ |
262 | .hub_status_data = ohci_hub_status_data, | 262 | .hub_status_data = ohci_hub_status_data, |
263 | .hub_control = ohci_hub_control, | 263 | .hub_control = ohci_hub_control, |
264 | .hub_irq_enable = ohci_rhsc_enable, | ||
265 | #ifdef CONFIG_PM | 264 | #ifdef CONFIG_PM |
266 | .bus_suspend = ohci_bus_suspend, | 265 | .bus_suspend = ohci_bus_suspend, |
267 | .bus_resume = ohci_bus_resume, | 266 | .bus_resume = ohci_bus_resume, |
@@ -348,6 +347,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) | |||
348 | if (!clocked) | 347 | if (!clocked) |
349 | at91_start_clock(); | 348 | at91_start_clock(); |
350 | 349 | ||
350 | ohci_finish_controller_resume(hcd); | ||
351 | return 0; | 351 | return 0; |
352 | } | 352 | } |
353 | #else | 353 | #else |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index f90fe0c7373f..1b9abdba920b 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c | |||
@@ -288,7 +288,6 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { | |||
288 | */ | 288 | */ |
289 | .hub_status_data = ohci_hub_status_data, | 289 | .hub_status_data = ohci_hub_status_data, |
290 | .hub_control = ohci_hub_control, | 290 | .hub_control = ohci_hub_control, |
291 | .hub_irq_enable = ohci_rhsc_enable, | ||
292 | #ifdef CONFIG_PM | 291 | #ifdef CONFIG_PM |
293 | .bus_suspend = ohci_bus_suspend, | 292 | .bus_suspend = ohci_bus_suspend, |
294 | .bus_resume = ohci_bus_resume, | 293 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index a22c30aa745d..e06bfaebec54 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -655,7 +655,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
655 | hcd->product_desc, | 655 | hcd->product_desc, |
656 | hcd_name); | 656 | hcd_name); |
657 | 657 | ||
658 | if (bus->controller->power.power_state.event) { | 658 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { |
659 | size -= scnprintf (next, size, | 659 | size -= scnprintf (next, size, |
660 | "SUSPENDED (no register access)\n"); | 660 | "SUSPENDED (no register access)\n"); |
661 | goto done; | 661 | goto done; |
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index 156e93a9d0df..06aadfb0ec29 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
@@ -135,7 +135,6 @@ static struct hc_driver ohci_ep93xx_hc_driver = { | |||
135 | .get_frame_number = ohci_get_frame, | 135 | .get_frame_number = ohci_get_frame, |
136 | .hub_status_data = ohci_hub_status_data, | 136 | .hub_status_data = ohci_hub_status_data, |
137 | .hub_control = ohci_hub_control, | 137 | .hub_control = ohci_hub_control, |
138 | .hub_irq_enable = ohci_rhsc_enable, | ||
139 | #ifdef CONFIG_PM | 138 | #ifdef CONFIG_PM |
140 | .bus_suspend = ohci_bus_suspend, | 139 | .bus_suspend = ohci_bus_suspend, |
141 | .bus_resume = ohci_bus_resume, | 140 | .bus_resume = ohci_bus_resume, |
@@ -177,7 +176,6 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_ | |||
177 | 176 | ||
178 | ep93xx_stop_hc(&pdev->dev); | 177 | ep93xx_stop_hc(&pdev->dev); |
179 | hcd->state = HC_STATE_SUSPENDED; | 178 | hcd->state = HC_STATE_SUSPENDED; |
180 | pdev->dev.power.power_state = PMSG_SUSPEND; | ||
181 | 179 | ||
182 | return 0; | 180 | return 0; |
183 | } | 181 | } |
@@ -193,9 +191,8 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) | |||
193 | ohci->next_statechange = jiffies; | 191 | ohci->next_statechange = jiffies; |
194 | 192 | ||
195 | ep93xx_start_hc(&pdev->dev); | 193 | ep93xx_start_hc(&pdev->dev); |
196 | pdev->dev.power.power_state = PMSG_ON; | ||
197 | usb_hcd_resume_root_hub(hcd); | ||
198 | 194 | ||
195 | ohci_finish_controller_resume(hcd); | ||
199 | return 0; | 196 | return 0; |
200 | } | 197 | } |
201 | #endif | 198 | #endif |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 48e4b11f4d3e..5be3bb3e6a9d 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -36,18 +36,6 @@ | |||
36 | 36 | ||
37 | /*-------------------------------------------------------------------------*/ | 37 | /*-------------------------------------------------------------------------*/ |
38 | 38 | ||
39 | /* hcd->hub_irq_enable() */ | ||
40 | static void ohci_rhsc_enable (struct usb_hcd *hcd) | ||
41 | { | ||
42 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
43 | |||
44 | spin_lock_irq(&ohci->lock); | ||
45 | if (!ohci->autostop) | ||
46 | del_timer(&hcd->rh_timer); /* Prevent next poll */ | ||
47 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
48 | spin_unlock_irq(&ohci->lock); | ||
49 | } | ||
50 | |||
51 | #define OHCI_SCHED_ENABLES \ | 39 | #define OHCI_SCHED_ENABLES \ |
52 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) | 40 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) |
53 | 41 | ||
@@ -103,11 +91,11 @@ __acquires(ohci->lock) | |||
103 | finish_unlinks (ohci, ohci_frame_no(ohci)); | 91 | finish_unlinks (ohci, ohci_frame_no(ohci)); |
104 | 92 | ||
105 | /* maybe resume can wake root hub */ | 93 | /* maybe resume can wake root hub */ |
106 | if (device_may_wakeup(&ohci_to_hcd(ohci)->self.root_hub->dev) || | 94 | if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) { |
107 | autostop) | ||
108 | ohci->hc_control |= OHCI_CTRL_RWE; | 95 | ohci->hc_control |= OHCI_CTRL_RWE; |
109 | else { | 96 | } else { |
110 | ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrdisable); | 97 | ohci_writel(ohci, OHCI_INTR_RHSC | OHCI_INTR_RD, |
98 | &ohci->regs->intrdisable); | ||
111 | ohci->hc_control &= ~OHCI_CTRL_RWE; | 99 | ohci->hc_control &= ~OHCI_CTRL_RWE; |
112 | } | 100 | } |
113 | 101 | ||
@@ -326,23 +314,76 @@ static int ohci_bus_resume (struct usb_hcd *hcd) | |||
326 | return rc; | 314 | return rc; |
327 | } | 315 | } |
328 | 316 | ||
317 | /* Carry out the final steps of resuming the controller device */ | ||
318 | static void ohci_finish_controller_resume(struct usb_hcd *hcd) | ||
319 | { | ||
320 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
321 | int port; | ||
322 | bool need_reinit = false; | ||
323 | |||
324 | /* See if the controller is already running or has been reset */ | ||
325 | ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); | ||
326 | if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { | ||
327 | need_reinit = true; | ||
328 | } else { | ||
329 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | ||
330 | case OHCI_USB_OPER: | ||
331 | case OHCI_USB_RESET: | ||
332 | need_reinit = true; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | /* If needed, reinitialize and suspend the root hub */ | ||
337 | if (need_reinit) { | ||
338 | spin_lock_irq(&ohci->lock); | ||
339 | hcd->state = HC_STATE_RESUMING; | ||
340 | ohci_rh_resume(ohci); | ||
341 | hcd->state = HC_STATE_QUIESCING; | ||
342 | ohci_rh_suspend(ohci, 0); | ||
343 | hcd->state = HC_STATE_SUSPENDED; | ||
344 | spin_unlock_irq(&ohci->lock); | ||
345 | } | ||
346 | |||
347 | /* Normally just turn on port power and enable interrupts */ | ||
348 | else { | ||
349 | ohci_dbg(ohci, "powerup ports\n"); | ||
350 | for (port = 0; port < ohci->num_ports; port++) | ||
351 | ohci_writel(ohci, RH_PS_PPS, | ||
352 | &ohci->regs->roothub.portstatus[port]); | ||
353 | |||
354 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); | ||
355 | ohci_readl(ohci, &ohci->regs->intrenable); | ||
356 | msleep(20); | ||
357 | } | ||
358 | } | ||
359 | |||
329 | /* Carry out polling-, autostop-, and autoresume-related state changes */ | 360 | /* Carry out polling-, autostop-, and autoresume-related state changes */ |
330 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 361 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
331 | int any_connected) | 362 | int any_connected) |
332 | { | 363 | { |
333 | int poll_rh = 1; | 364 | int poll_rh = 1; |
365 | int rhsc; | ||
334 | 366 | ||
367 | rhsc = ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC; | ||
335 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | 368 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { |
336 | 369 | ||
337 | case OHCI_USB_OPER: | 370 | case OHCI_USB_OPER: |
338 | /* keep on polling until we know a device is connected | 371 | /* If no status changes are pending, enable status-change |
339 | * and RHSC is enabled */ | 372 | * interrupts. |
373 | */ | ||
374 | if (!rhsc && !changed) { | ||
375 | rhsc = OHCI_INTR_RHSC; | ||
376 | ohci_writel(ohci, rhsc, &ohci->regs->intrenable); | ||
377 | } | ||
378 | |||
379 | /* Keep on polling until we know a device is connected | ||
380 | * and RHSC is enabled, or until we autostop. | ||
381 | */ | ||
340 | if (!ohci->autostop) { | 382 | if (!ohci->autostop) { |
341 | if (any_connected || | 383 | if (any_connected || |
342 | !device_may_wakeup(&ohci_to_hcd(ohci) | 384 | !device_may_wakeup(&ohci_to_hcd(ohci) |
343 | ->self.root_hub->dev)) { | 385 | ->self.root_hub->dev)) { |
344 | if (ohci_readl(ohci, &ohci->regs->intrenable) & | 386 | if (rhsc) |
345 | OHCI_INTR_RHSC) | ||
346 | poll_rh = 0; | 387 | poll_rh = 0; |
347 | } else { | 388 | } else { |
348 | ohci->autostop = 1; | 389 | ohci->autostop = 1; |
@@ -355,12 +396,13 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
355 | ohci->autostop = 0; | 396 | ohci->autostop = 0; |
356 | ohci->next_statechange = jiffies + | 397 | ohci->next_statechange = jiffies + |
357 | STATECHANGE_DELAY; | 398 | STATECHANGE_DELAY; |
358 | } else if (time_after_eq(jiffies, | 399 | } else if (rhsc && time_after_eq(jiffies, |
359 | ohci->next_statechange) | 400 | ohci->next_statechange) |
360 | && !ohci->ed_rm_list | 401 | && !ohci->ed_rm_list |
361 | && !(ohci->hc_control & | 402 | && !(ohci->hc_control & |
362 | OHCI_SCHED_ENABLES)) { | 403 | OHCI_SCHED_ENABLES)) { |
363 | ohci_rh_suspend(ohci, 1); | 404 | ohci_rh_suspend(ohci, 1); |
405 | poll_rh = 0; | ||
364 | } | 406 | } |
365 | } | 407 | } |
366 | break; | 408 | break; |
@@ -374,6 +416,12 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
374 | else | 416 | else |
375 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); | 417 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); |
376 | } else { | 418 | } else { |
419 | if (!rhsc && (ohci->autostop || | ||
420 | ohci_to_hcd(ohci)->self.root_hub-> | ||
421 | do_remote_wakeup)) | ||
422 | ohci_writel(ohci, OHCI_INTR_RHSC, | ||
423 | &ohci->regs->intrenable); | ||
424 | |||
377 | /* everything is idle, no need for polling */ | 425 | /* everything is idle, no need for polling */ |
378 | poll_rh = 0; | 426 | poll_rh = 0; |
379 | } | 427 | } |
@@ -395,12 +443,16 @@ static inline int ohci_rh_resume(struct ohci_hcd *ohci) | |||
395 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 443 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
396 | int any_connected) | 444 | int any_connected) |
397 | { | 445 | { |
398 | int poll_rh = 1; | 446 | /* If RHSC is enabled, don't poll */ |
399 | |||
400 | /* keep on polling until RHSC is enabled */ | ||
401 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) | 447 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) |
402 | poll_rh = 0; | 448 | return 0; |
403 | return poll_rh; | 449 | |
450 | /* If no status changes are pending, enable status-change interrupts */ | ||
451 | if (!changed) { | ||
452 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
453 | return 0; | ||
454 | } | ||
455 | return 1; | ||
404 | } | 456 | } |
405 | 457 | ||
406 | #endif /* CONFIG_PM */ | 458 | #endif /* CONFIG_PM */ |
@@ -564,14 +616,18 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) | |||
564 | u32 temp; | 616 | u32 temp; |
565 | u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); | 617 | u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); |
566 | u16 reset_done = now + PORT_RESET_MSEC; | 618 | u16 reset_done = now + PORT_RESET_MSEC; |
619 | int limit_1 = DIV_ROUND_UP(PORT_RESET_MSEC, PORT_RESET_HW_MSEC); | ||
567 | 620 | ||
568 | /* build a "continuous enough" reset signal, with up to | 621 | /* build a "continuous enough" reset signal, with up to |
569 | * 3msec gap between pulses. scheduler HZ==100 must work; | 622 | * 3msec gap between pulses. scheduler HZ==100 must work; |
570 | * this might need to be deadline-scheduled. | 623 | * this might need to be deadline-scheduled. |
571 | */ | 624 | */ |
572 | do { | 625 | do { |
626 | int limit_2; | ||
627 | |||
573 | /* spin until any current reset finishes */ | 628 | /* spin until any current reset finishes */ |
574 | for (;;) { | 629 | limit_2 = PORT_RESET_HW_MSEC * 2; |
630 | while (--limit_2 >= 0) { | ||
575 | temp = ohci_readl (ohci, portstat); | 631 | temp = ohci_readl (ohci, portstat); |
576 | /* handle e.g. CardBus eject */ | 632 | /* handle e.g. CardBus eject */ |
577 | if (temp == ~(u32)0) | 633 | if (temp == ~(u32)0) |
@@ -581,6 +637,17 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) | |||
581 | udelay (500); | 637 | udelay (500); |
582 | } | 638 | } |
583 | 639 | ||
640 | /* timeout (a hardware error) has been observed when | ||
641 | * EHCI sets CF while this driver is resetting a port; | ||
642 | * presumably other disconnect paths might do it too. | ||
643 | */ | ||
644 | if (limit_2 < 0) { | ||
645 | ohci_dbg(ohci, | ||
646 | "port[%d] reset timeout, stat %08x\n", | ||
647 | port, temp); | ||
648 | break; | ||
649 | } | ||
650 | |||
584 | if (!(temp & RH_PS_CCS)) | 651 | if (!(temp & RH_PS_CCS)) |
585 | break; | 652 | break; |
586 | if (temp & RH_PS_PRSC) | 653 | if (temp & RH_PS_PRSC) |
@@ -590,8 +657,11 @@ static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) | |||
590 | ohci_writel (ohci, RH_PS_PRS, portstat); | 657 | ohci_writel (ohci, RH_PS_PRS, portstat); |
591 | msleep(PORT_RESET_HW_MSEC); | 658 | msleep(PORT_RESET_HW_MSEC); |
592 | now = ohci_readl(ohci, &ohci->regs->fmnumber); | 659 | now = ohci_readl(ohci, &ohci->regs->fmnumber); |
593 | } while (tick_before(now, reset_done)); | 660 | } while (tick_before(now, reset_done) && --limit_1 >= 0); |
594 | /* caller synchronizes using PRSC */ | 661 | |
662 | /* caller synchronizes using PRSC ... and handles PRS | ||
663 | * still being set when this returns. | ||
664 | */ | ||
595 | 665 | ||
596 | return 0; | 666 | return 0; |
597 | } | 667 | } |
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c index 13c12ed22252..96d14fa1d833 100644 --- a/drivers/usb/host/ohci-lh7a404.c +++ b/drivers/usb/host/ohci-lh7a404.c | |||
@@ -193,7 +193,6 @@ static const struct hc_driver ohci_lh7a404_hc_driver = { | |||
193 | */ | 193 | */ |
194 | .hub_status_data = ohci_hub_status_data, | 194 | .hub_status_data = ohci_hub_status_data, |
195 | .hub_control = ohci_hub_control, | 195 | .hub_control = ohci_hub_control, |
196 | .hub_irq_enable = ohci_rhsc_enable, | ||
197 | #ifdef CONFIG_PM | 196 | #ifdef CONFIG_PM |
198 | .bus_suspend = ohci_bus_suspend, | 197 | .bus_suspend = ohci_bus_suspend, |
199 | .bus_resume = ohci_bus_resume, | 198 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 7bfca1ed1b58..6859fb5f1d6f 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -466,7 +466,6 @@ static const struct hc_driver ohci_omap_hc_driver = { | |||
466 | */ | 466 | */ |
467 | .hub_status_data = ohci_hub_status_data, | 467 | .hub_status_data = ohci_hub_status_data, |
468 | .hub_control = ohci_hub_control, | 468 | .hub_control = ohci_hub_control, |
469 | .hub_irq_enable = ohci_rhsc_enable, | ||
470 | #ifdef CONFIG_PM | 469 | #ifdef CONFIG_PM |
471 | .bus_suspend = ohci_bus_suspend, | 470 | .bus_suspend = ohci_bus_suspend, |
472 | .bus_resume = ohci_bus_resume, | 471 | .bus_resume = ohci_bus_resume, |
@@ -505,21 +504,20 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message) | |||
505 | 504 | ||
506 | omap_ohci_clock_power(0); | 505 | omap_ohci_clock_power(0); |
507 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | 506 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; |
508 | dev->dev.power.power_state = PMSG_SUSPEND; | ||
509 | return 0; | 507 | return 0; |
510 | } | 508 | } |
511 | 509 | ||
512 | static int ohci_omap_resume(struct platform_device *dev) | 510 | static int ohci_omap_resume(struct platform_device *dev) |
513 | { | 511 | { |
514 | struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev)); | 512 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
513 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
515 | 514 | ||
516 | if (time_before(jiffies, ohci->next_statechange)) | 515 | if (time_before(jiffies, ohci->next_statechange)) |
517 | msleep(5); | 516 | msleep(5); |
518 | ohci->next_statechange = jiffies; | 517 | ohci->next_statechange = jiffies; |
519 | 518 | ||
520 | omap_ohci_clock_power(1); | 519 | omap_ohci_clock_power(1); |
521 | dev->dev.power.power_state = PMSG_ON; | 520 | ohci_finish_controller_resume(hcd); |
522 | usb_hcd_resume_root_hub(platform_get_drvdata(dev)); | ||
523 | return 0; | 521 | return 0; |
524 | } | 522 | } |
525 | 523 | ||
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index d0360f65ebd9..3bf175d95a23 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -238,42 +238,6 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd) | |||
238 | return ret; | 238 | return ret; |
239 | } | 239 | } |
240 | 240 | ||
241 | #if defined(CONFIG_USB_PERSIST) && (defined(CONFIG_USB_EHCI_HCD) || \ | ||
242 | defined(CONFIG_USB_EHCI_HCD_MODULE)) | ||
243 | |||
244 | /* Following a power loss, we must prepare to regain control of the ports | ||
245 | * we used to own. This means turning on the port power before ehci-hcd | ||
246 | * tries to switch ownership. | ||
247 | * | ||
248 | * This isn't a 100% perfect solution. On most systems the OHCI controllers | ||
249 | * lie at lower PCI addresses than the EHCI controller, so they will be | ||
250 | * discovered (and hence resumed) first. But there is no guarantee things | ||
251 | * will always work this way. If the EHCI controller is resumed first and | ||
252 | * the OHCI ports are unpowered, then the handover will fail. | ||
253 | */ | ||
254 | static void prepare_for_handover(struct usb_hcd *hcd) | ||
255 | { | ||
256 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
257 | int port; | ||
258 | |||
259 | /* Here we "know" root ports should always stay powered */ | ||
260 | ohci_dbg(ohci, "powerup ports\n"); | ||
261 | for (port = 0; port < ohci->num_ports; port++) | ||
262 | ohci_writel(ohci, RH_PS_PPS, | ||
263 | &ohci->regs->roothub.portstatus[port]); | ||
264 | |||
265 | /* Flush those writes */ | ||
266 | ohci_readl(ohci, &ohci->regs->control); | ||
267 | msleep(20); | ||
268 | } | ||
269 | |||
270 | #else | ||
271 | |||
272 | static inline void prepare_for_handover(struct usb_hcd *hcd) | ||
273 | { } | ||
274 | |||
275 | #endif /* CONFIG_USB_PERSIST etc. */ | ||
276 | |||
277 | #ifdef CONFIG_PM | 241 | #ifdef CONFIG_PM |
278 | 242 | ||
279 | static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) | 243 | static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) |
@@ -313,10 +277,7 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) | |||
313 | static int ohci_pci_resume (struct usb_hcd *hcd) | 277 | static int ohci_pci_resume (struct usb_hcd *hcd) |
314 | { | 278 | { |
315 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 279 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
316 | 280 | ohci_finish_controller_resume(hcd); | |
317 | /* FIXME: we should try to detect loss of VBUS power here */ | ||
318 | prepare_for_handover(hcd); | ||
319 | |||
320 | return 0; | 281 | return 0; |
321 | } | 282 | } |
322 | 283 | ||
@@ -345,9 +306,8 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
345 | .shutdown = ohci_shutdown, | 306 | .shutdown = ohci_shutdown, |
346 | 307 | ||
347 | #ifdef CONFIG_PM | 308 | #ifdef CONFIG_PM |
348 | /* these suspend/resume entries are for upstream PCI glue ONLY */ | 309 | .pci_suspend = ohci_pci_suspend, |
349 | .suspend = ohci_pci_suspend, | 310 | .pci_resume = ohci_pci_resume, |
350 | .resume = ohci_pci_resume, | ||
351 | #endif | 311 | #endif |
352 | 312 | ||
353 | /* | 313 | /* |
@@ -367,7 +327,6 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
367 | */ | 327 | */ |
368 | .hub_status_data = ohci_hub_status_data, | 328 | .hub_status_data = ohci_hub_status_data, |
369 | .hub_control = ohci_hub_control, | 329 | .hub_control = ohci_hub_control, |
370 | .hub_irq_enable = ohci_rhsc_enable, | ||
371 | #ifdef CONFIG_PM | 330 | #ifdef CONFIG_PM |
372 | .bus_suspend = ohci_bus_suspend, | 331 | .bus_suspend = ohci_bus_suspend, |
373 | .bus_resume = ohci_bus_resume, | 332 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c index 28b458f20cc3..664f07ee8732 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-pnx4008.c | |||
@@ -280,7 +280,6 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { | |||
280 | */ | 280 | */ |
281 | .hub_status_data = ohci_hub_status_data, | 281 | .hub_status_data = ohci_hub_status_data, |
282 | .hub_control = ohci_hub_control, | 282 | .hub_control = ohci_hub_control, |
283 | .hub_irq_enable = ohci_rhsc_enable, | ||
284 | #ifdef CONFIG_PM | 283 | #ifdef CONFIG_PM |
285 | .bus_suspend = ohci_bus_suspend, | 284 | .bus_suspend = ohci_bus_suspend, |
286 | .bus_resume = ohci_bus_resume, | 285 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c index 605d59cba28e..28467e288a93 100644 --- a/drivers/usb/host/ohci-pnx8550.c +++ b/drivers/usb/host/ohci-pnx8550.c | |||
@@ -201,7 +201,6 @@ static const struct hc_driver ohci_pnx8550_hc_driver = { | |||
201 | */ | 201 | */ |
202 | .hub_status_data = ohci_hub_status_data, | 202 | .hub_status_data = ohci_hub_status_data, |
203 | .hub_control = ohci_hub_control, | 203 | .hub_control = ohci_hub_control, |
204 | .hub_irq_enable = ohci_rhsc_enable, | ||
205 | #ifdef CONFIG_PM | 204 | #ifdef CONFIG_PM |
206 | .bus_suspend = ohci_bus_suspend, | 205 | .bus_suspend = ohci_bus_suspend, |
207 | .bus_resume = ohci_bus_resume, | 206 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c index a67252791223..50e55db13636 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c | |||
@@ -72,7 +72,6 @@ static const struct hc_driver ohci_ppc_of_hc_driver = { | |||
72 | */ | 72 | */ |
73 | .hub_status_data = ohci_hub_status_data, | 73 | .hub_status_data = ohci_hub_status_data, |
74 | .hub_control = ohci_hub_control, | 74 | .hub_control = ohci_hub_control, |
75 | .hub_irq_enable = ohci_rhsc_enable, | ||
76 | #ifdef CONFIG_PM | 75 | #ifdef CONFIG_PM |
77 | .bus_suspend = ohci_bus_suspend, | 76 | .bus_suspend = ohci_bus_suspend, |
78 | .bus_resume = ohci_bus_resume, | 77 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 523c30125577..cd3398b675b2 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c | |||
@@ -172,7 +172,6 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = { | |||
172 | */ | 172 | */ |
173 | .hub_status_data = ohci_hub_status_data, | 173 | .hub_status_data = ohci_hub_status_data, |
174 | .hub_control = ohci_hub_control, | 174 | .hub_control = ohci_hub_control, |
175 | .hub_irq_enable = ohci_rhsc_enable, | ||
176 | #ifdef CONFIG_PM | 175 | #ifdef CONFIG_PM |
177 | .bus_suspend = ohci_bus_suspend, | 176 | .bus_suspend = ohci_bus_suspend, |
178 | .bus_resume = ohci_bus_resume, | 177 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c index 01a0caeaa6bc..bfdeb0d22d05 100644 --- a/drivers/usb/host/ohci-ps3.c +++ b/drivers/usb/host/ohci-ps3.c | |||
@@ -68,7 +68,6 @@ static const struct hc_driver ps3_ohci_hc_driver = { | |||
68 | .get_frame_number = ohci_get_frame, | 68 | .get_frame_number = ohci_get_frame, |
69 | .hub_status_data = ohci_hub_status_data, | 69 | .hub_status_data = ohci_hub_status_data, |
70 | .hub_control = ohci_hub_control, | 70 | .hub_control = ohci_hub_control, |
71 | .hub_irq_enable = ohci_rhsc_enable, | ||
72 | .start_port_reset = ohci_start_port_reset, | 71 | .start_port_reset = ohci_start_port_reset, |
73 | #if defined(CONFIG_PM) | 72 | #if defined(CONFIG_PM) |
74 | .bus_suspend = ohci_bus_suspend, | 73 | .bus_suspend = ohci_bus_suspend, |
@@ -127,7 +126,6 @@ static int ps3_ohci_probe(struct ps3_system_bus_device *dev) | |||
127 | goto fail_irq; | 126 | goto fail_irq; |
128 | } | 127 | } |
129 | 128 | ||
130 | dev->core.power.power_state = PMSG_ON; | ||
131 | dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ | 129 | dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ |
132 | 130 | ||
133 | hcd = usb_create_hcd(&ps3_ohci_hc_driver, &dev->core, dev->core.bus_id); | 131 | hcd = usb_create_hcd(&ps3_ohci_hc_driver, &dev->core, dev->core.bus_id); |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 8ad9b3b604b5..70b0d4b459e7 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -298,7 +298,6 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { | |||
298 | */ | 298 | */ |
299 | .hub_status_data = ohci_hub_status_data, | 299 | .hub_status_data = ohci_hub_status_data, |
300 | .hub_control = ohci_hub_control, | 300 | .hub_control = ohci_hub_control, |
301 | .hub_irq_enable = ohci_rhsc_enable, | ||
302 | #ifdef CONFIG_PM | 301 | #ifdef CONFIG_PM |
303 | .bus_suspend = ohci_bus_suspend, | 302 | .bus_suspend = ohci_bus_suspend, |
304 | .bus_resume = ohci_bus_resume, | 303 | .bus_resume = ohci_bus_resume, |
@@ -339,7 +338,6 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_ | |||
339 | 338 | ||
340 | pxa27x_stop_hc(&pdev->dev); | 339 | pxa27x_stop_hc(&pdev->dev); |
341 | hcd->state = HC_STATE_SUSPENDED; | 340 | hcd->state = HC_STATE_SUSPENDED; |
342 | pdev->dev.power.power_state = PMSG_SUSPEND; | ||
343 | 341 | ||
344 | return 0; | 342 | return 0; |
345 | } | 343 | } |
@@ -357,9 +355,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) | |||
357 | if ((status = pxa27x_start_hc(&pdev->dev)) < 0) | 355 | if ((status = pxa27x_start_hc(&pdev->dev)) < 0) |
358 | return status; | 356 | return status; |
359 | 357 | ||
360 | pdev->dev.power.power_state = PMSG_ON; | 358 | ohci_finish_controller_resume(hcd); |
361 | usb_hcd_resume_root_hub(hcd); | ||
362 | |||
363 | return 0; | 359 | return 0; |
364 | } | 360 | } |
365 | #endif | 361 | #endif |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index ead4772f0f27..a73d2ff322e2 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
@@ -466,7 +466,6 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { | |||
466 | */ | 466 | */ |
467 | .hub_status_data = ohci_s3c2410_hub_status_data, | 467 | .hub_status_data = ohci_s3c2410_hub_status_data, |
468 | .hub_control = ohci_s3c2410_hub_control, | 468 | .hub_control = ohci_s3c2410_hub_control, |
469 | .hub_irq_enable = ohci_rhsc_enable, | ||
470 | #ifdef CONFIG_PM | 469 | #ifdef CONFIG_PM |
471 | .bus_suspend = ohci_bus_suspend, | 470 | .bus_suspend = ohci_bus_suspend, |
472 | .bus_resume = ohci_bus_resume, | 471 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index 0f48f2d99226..99438c65981b 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c | |||
@@ -231,7 +231,6 @@ static const struct hc_driver ohci_sa1111_hc_driver = { | |||
231 | */ | 231 | */ |
232 | .hub_status_data = ohci_hub_status_data, | 232 | .hub_status_data = ohci_hub_status_data, |
233 | .hub_control = ohci_hub_control, | 233 | .hub_control = ohci_hub_control, |
234 | .hub_irq_enable = ohci_rhsc_enable, | ||
235 | #ifdef CONFIG_PM | 234 | #ifdef CONFIG_PM |
236 | .bus_suspend = ohci_bus_suspend, | 235 | .bus_suspend = ohci_bus_suspend, |
237 | .bus_resume = ohci_bus_resume, | 236 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c index e7ee607278fe..60f03cc7ec4f 100644 --- a/drivers/usb/host/ohci-sh.c +++ b/drivers/usb/host/ohci-sh.c | |||
@@ -68,7 +68,6 @@ static const struct hc_driver ohci_sh_hc_driver = { | |||
68 | */ | 68 | */ |
69 | .hub_status_data = ohci_hub_status_data, | 69 | .hub_status_data = ohci_hub_status_data, |
70 | .hub_control = ohci_hub_control, | 70 | .hub_control = ohci_hub_control, |
71 | .hub_irq_enable = ohci_rhsc_enable, | ||
72 | #ifdef CONFIG_PM | 71 | #ifdef CONFIG_PM |
73 | .bus_suspend = ohci_bus_suspend, | 72 | .bus_suspend = ohci_bus_suspend, |
74 | .bus_resume = ohci_bus_resume, | 73 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index 4ea92762fb28..77204f001b9a 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c | |||
@@ -75,7 +75,6 @@ static const struct hc_driver ohci_sm501_hc_driver = { | |||
75 | */ | 75 | */ |
76 | .hub_status_data = ohci_hub_status_data, | 76 | .hub_status_data = ohci_hub_status_data, |
77 | .hub_control = ohci_hub_control, | 77 | .hub_control = ohci_hub_control, |
78 | .hub_irq_enable = ohci_rhsc_enable, | ||
79 | #ifdef CONFIG_PM | 78 | #ifdef CONFIG_PM |
80 | .bus_suspend = ohci_bus_suspend, | 79 | .bus_suspend = ohci_bus_suspend, |
81 | .bus_resume = ohci_bus_resume, | 80 | .bus_resume = ohci_bus_resume, |
@@ -199,7 +198,8 @@ static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev) | |||
199 | usb_put_hcd(hcd); | 198 | usb_put_hcd(hcd); |
200 | dma_release_declared_memory(&pdev->dev); | 199 | dma_release_declared_memory(&pdev->dev); |
201 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 200 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
202 | release_mem_region(mem->start, mem->end - mem->start + 1); | 201 | if (mem) |
202 | release_mem_region(mem->start, mem->end - mem->start + 1); | ||
203 | 203 | ||
204 | /* mask interrupts and disable power */ | 204 | /* mask interrupts and disable power */ |
205 | 205 | ||
@@ -224,24 +224,26 @@ static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg) | |||
224 | 224 | ||
225 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); | 225 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); |
226 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | 226 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; |
227 | dev->power.power_state = PMSG_SUSPEND; | ||
228 | return 0; | 227 | return 0; |
229 | } | 228 | } |
230 | 229 | ||
231 | static int ohci_sm501_resume(struct platform_device *pdev) | 230 | static int ohci_sm501_resume(struct platform_device *pdev) |
232 | { | 231 | { |
233 | struct device *dev = &pdev->dev; | 232 | struct device *dev = &pdev->dev; |
234 | struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); | 233 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
234 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
235 | 235 | ||
236 | if (time_before(jiffies, ohci->next_statechange)) | 236 | if (time_before(jiffies, ohci->next_statechange)) |
237 | msleep(5); | 237 | msleep(5); |
238 | ohci->next_statechange = jiffies; | 238 | ohci->next_statechange = jiffies; |
239 | 239 | ||
240 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); | 240 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); |
241 | dev->power.power_state = PMSG_ON; | 241 | ohci_finish_controller_resume(hcd); |
242 | usb_hcd_resume_root_hub(platform_get_drvdata(pdev)); | ||
243 | return 0; | 242 | return 0; |
244 | } | 243 | } |
244 | #else | ||
245 | #define ohci_sm501_suspend NULL | ||
246 | #define ohci_sm501_resume NULL | ||
245 | #endif | 247 | #endif |
246 | 248 | ||
247 | /*-------------------------------------------------------------------------*/ | 249 | /*-------------------------------------------------------------------------*/ |
@@ -253,10 +255,8 @@ static struct platform_driver ohci_hcd_sm501_driver = { | |||
253 | .probe = ohci_hcd_sm501_drv_probe, | 255 | .probe = ohci_hcd_sm501_drv_probe, |
254 | .remove = ohci_hcd_sm501_drv_remove, | 256 | .remove = ohci_hcd_sm501_drv_remove, |
255 | .shutdown = usb_hcd_platform_shutdown, | 257 | .shutdown = usb_hcd_platform_shutdown, |
256 | #ifdef CONFIG_PM | ||
257 | .suspend = ohci_sm501_suspend, | 258 | .suspend = ohci_sm501_suspend, |
258 | .resume = ohci_sm501_resume, | 259 | .resume = ohci_sm501_resume, |
259 | #endif | ||
260 | .driver = { | 260 | .driver = { |
261 | .owner = THIS_MODULE, | 261 | .owner = THIS_MODULE, |
262 | .name = "sm501-usb", | 262 | .name = "sm501-usb", |
diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c index 6e9c2d6db887..c4265caec780 100644 --- a/drivers/usb/host/ohci-ssb.c +++ b/drivers/usb/host/ohci-ssb.c | |||
@@ -60,36 +60,6 @@ static int ssb_ohci_start(struct usb_hcd *hcd) | |||
60 | return err; | 60 | return err; |
61 | } | 61 | } |
62 | 62 | ||
63 | #ifdef CONFIG_PM | ||
64 | static int ssb_ohci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) | ||
65 | { | ||
66 | struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); | ||
67 | struct ohci_hcd *ohci = &ohcidev->ohci; | ||
68 | unsigned long flags; | ||
69 | |||
70 | spin_lock_irqsave(&ohci->lock, flags); | ||
71 | |||
72 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | ||
73 | ohci_readl(ohci, &ohci->regs->intrdisable); /* commit write */ | ||
74 | |||
75 | /* make sure snapshot being resumed re-enumerates everything */ | ||
76 | if (message.event == PM_EVENT_PRETHAW) | ||
77 | ohci_usb_reset(ohci); | ||
78 | |||
79 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
80 | |||
81 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static int ssb_ohci_hcd_resume(struct usb_hcd *hcd) | ||
86 | { | ||
87 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
88 | usb_hcd_resume_root_hub(hcd); | ||
89 | return 0; | ||
90 | } | ||
91 | #endif /* CONFIG_PM */ | ||
92 | |||
93 | static const struct hc_driver ssb_ohci_hc_driver = { | 63 | static const struct hc_driver ssb_ohci_hc_driver = { |
94 | .description = "ssb-usb-ohci", | 64 | .description = "ssb-usb-ohci", |
95 | .product_desc = "SSB OHCI Controller", | 65 | .product_desc = "SSB OHCI Controller", |
@@ -103,11 +73,6 @@ static const struct hc_driver ssb_ohci_hc_driver = { | |||
103 | .stop = ohci_stop, | 73 | .stop = ohci_stop, |
104 | .shutdown = ohci_shutdown, | 74 | .shutdown = ohci_shutdown, |
105 | 75 | ||
106 | #ifdef CONFIG_PM | ||
107 | .suspend = ssb_ohci_hcd_suspend, | ||
108 | .resume = ssb_ohci_hcd_resume, | ||
109 | #endif | ||
110 | |||
111 | .urb_enqueue = ohci_urb_enqueue, | 76 | .urb_enqueue = ohci_urb_enqueue, |
112 | .urb_dequeue = ohci_urb_dequeue, | 77 | .urb_dequeue = ohci_urb_dequeue, |
113 | .endpoint_disable = ohci_endpoint_disable, | 78 | .endpoint_disable = ohci_endpoint_disable, |
@@ -116,7 +81,6 @@ static const struct hc_driver ssb_ohci_hc_driver = { | |||
116 | 81 | ||
117 | .hub_status_data = ohci_hub_status_data, | 82 | .hub_status_data = ohci_hub_status_data, |
118 | .hub_control = ohci_hub_control, | 83 | .hub_control = ohci_hub_control, |
119 | .hub_irq_enable = ohci_rhsc_enable, | ||
120 | #ifdef CONFIG_PM | 84 | #ifdef CONFIG_PM |
121 | .bus_suspend = ohci_bus_suspend, | 85 | .bus_suspend = ohci_bus_suspend, |
122 | .bus_resume = ohci_bus_resume, | 86 | .bus_resume = ohci_bus_resume, |
@@ -224,6 +188,7 @@ static int ssb_ohci_resume(struct ssb_device *dev) | |||
224 | 188 | ||
225 | ssb_device_enable(dev, ohcidev->enable_flags); | 189 | ssb_device_enable(dev, ohcidev->enable_flags); |
226 | 190 | ||
191 | ohci_finish_controller_resume(hcd); | ||
227 | return 0; | 192 | return 0; |
228 | } | 193 | } |
229 | 194 | ||
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 0ee694f043cc..ae6e70edd745 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -106,7 +106,7 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) | |||
106 | pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup); | 106 | pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup); |
107 | if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) { | 107 | if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) { |
108 | dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n", | 108 | dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n", |
109 | __FUNCTION__, legsup); | 109 | __func__, legsup); |
110 | goto reset_needed; | 110 | goto reset_needed; |
111 | } | 111 | } |
112 | 112 | ||
@@ -114,14 +114,14 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) | |||
114 | if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) || | 114 | if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) || |
115 | !(cmd & UHCI_USBCMD_EGSM)) { | 115 | !(cmd & UHCI_USBCMD_EGSM)) { |
116 | dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n", | 116 | dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n", |
117 | __FUNCTION__, cmd); | 117 | __func__, cmd); |
118 | goto reset_needed; | 118 | goto reset_needed; |
119 | } | 119 | } |
120 | 120 | ||
121 | intr = inw(base + UHCI_USBINTR); | 121 | intr = inw(base + UHCI_USBINTR); |
122 | if (intr & (~UHCI_USBINTR_RESUME)) { | 122 | if (intr & (~UHCI_USBINTR_RESUME)) { |
123 | dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n", | 123 | dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n", |
124 | __FUNCTION__, intr); | 124 | __func__, intr); |
125 | goto reset_needed; | 125 | goto reset_needed; |
126 | } | 126 | } |
127 | return 0; | 127 | return 0; |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 9f80e5285575..f4fa93dabdde 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -46,15 +46,17 @@ MODULE_LICENSE("GPL"); | |||
46 | MODULE_AUTHOR("Yoshihiro Shimoda"); | 46 | MODULE_AUTHOR("Yoshihiro Shimoda"); |
47 | MODULE_ALIAS("platform:r8a66597_hcd"); | 47 | MODULE_ALIAS("platform:r8a66597_hcd"); |
48 | 48 | ||
49 | #define DRIVER_VERSION "29 May 2007" | 49 | #define DRIVER_VERSION "10 Apr 2008" |
50 | 50 | ||
51 | static const char hcd_name[] = "r8a66597_hcd"; | 51 | static const char hcd_name[] = "r8a66597_hcd"; |
52 | 52 | ||
53 | /* module parameters */ | 53 | /* module parameters */ |
54 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
54 | static unsigned short clock = XTAL12; | 55 | static unsigned short clock = XTAL12; |
55 | module_param(clock, ushort, 0644); | 56 | module_param(clock, ushort, 0644); |
56 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " | 57 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " |
57 | "(default=0)"); | 58 | "(default=0)"); |
59 | #endif | ||
58 | 60 | ||
59 | static unsigned short vif = LDRV; | 61 | static unsigned short vif = LDRV; |
60 | module_param(vif, ushort, 0644); | 62 | module_param(vif, ushort, 0644); |
@@ -106,11 +108,22 @@ static void set_devadd_reg(struct r8a66597 *r8a66597, u8 r8a66597_address, | |||
106 | r8a66597_write(r8a66597, val, devadd_reg); | 108 | r8a66597_write(r8a66597, val, devadd_reg); |
107 | } | 109 | } |
108 | 110 | ||
109 | static int enable_controller(struct r8a66597 *r8a66597) | 111 | static int r8a66597_clock_enable(struct r8a66597 *r8a66597) |
110 | { | 112 | { |
111 | u16 tmp; | 113 | u16 tmp; |
112 | int i = 0; | 114 | int i = 0; |
113 | 115 | ||
116 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
117 | do { | ||
118 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | ||
119 | tmp = r8a66597_read(r8a66597, SYSCFG0); | ||
120 | if (i++ > 1000) { | ||
121 | err("register access fail."); | ||
122 | return -ENXIO; | ||
123 | } | ||
124 | } while ((tmp & SCKE) != SCKE); | ||
125 | r8a66597_write(r8a66597, 0x04, 0x02); | ||
126 | #else | ||
114 | do { | 127 | do { |
115 | r8a66597_write(r8a66597, USBE, SYSCFG0); | 128 | r8a66597_write(r8a66597, USBE, SYSCFG0); |
116 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 129 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
@@ -132,13 +145,63 @@ static int enable_controller(struct r8a66597 *r8a66597) | |||
132 | return -ENXIO; | 145 | return -ENXIO; |
133 | } | 146 | } |
134 | } while ((tmp & SCKE) != SCKE); | 147 | } while ((tmp & SCKE) != SCKE); |
148 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static void r8a66597_clock_disable(struct r8a66597 *r8a66597) | ||
154 | { | ||
155 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); | ||
156 | udelay(1); | ||
157 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
158 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
159 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
160 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
161 | #endif | ||
162 | } | ||
163 | |||
164 | static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) | ||
165 | { | ||
166 | u16 val; | ||
167 | |||
168 | val = port ? DRPD : DCFM | DRPD; | ||
169 | r8a66597_bset(r8a66597, val, get_syscfg_reg(port)); | ||
170 | r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port)); | ||
171 | |||
172 | r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, get_dmacfg_reg(port)); | ||
173 | r8a66597_bclr(r8a66597, DTCHE, get_intenb_reg(port)); | ||
174 | r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); | ||
175 | } | ||
135 | 176 | ||
136 | r8a66597_bset(r8a66597, DCFM | DRPD, SYSCFG0); | 177 | static void r8a66597_disable_port(struct r8a66597 *r8a66597, int port) |
137 | r8a66597_bset(r8a66597, DRPD, SYSCFG1); | 178 | { |
179 | u16 val, tmp; | ||
180 | |||
181 | r8a66597_write(r8a66597, 0, get_intenb_reg(port)); | ||
182 | r8a66597_write(r8a66597, 0, get_intsts_reg(port)); | ||
183 | |||
184 | r8a66597_port_power(r8a66597, port, 0); | ||
185 | |||
186 | do { | ||
187 | tmp = r8a66597_read(r8a66597, SOFCFG) & EDGESTS; | ||
188 | udelay(640); | ||
189 | } while (tmp == EDGESTS); | ||
190 | |||
191 | val = port ? DRPD : DCFM | DRPD; | ||
192 | r8a66597_bclr(r8a66597, val, get_syscfg_reg(port)); | ||
193 | r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port)); | ||
194 | } | ||
195 | |||
196 | static int enable_controller(struct r8a66597 *r8a66597) | ||
197 | { | ||
198 | int ret, port; | ||
199 | |||
200 | ret = r8a66597_clock_enable(r8a66597); | ||
201 | if (ret < 0) | ||
202 | return ret; | ||
138 | 203 | ||
139 | r8a66597_bset(r8a66597, vif & LDRV, PINCFG); | 204 | r8a66597_bset(r8a66597, vif & LDRV, PINCFG); |
140 | r8a66597_bset(r8a66597, HSE, SYSCFG0); | ||
141 | r8a66597_bset(r8a66597, HSE, SYSCFG1); | ||
142 | r8a66597_bset(r8a66597, USBE, SYSCFG0); | 205 | r8a66597_bset(r8a66597, USBE, SYSCFG0); |
143 | 206 | ||
144 | r8a66597_bset(r8a66597, BEMPE | NRDYE | BRDYE, INTENB0); | 207 | r8a66597_bset(r8a66597, BEMPE | NRDYE | BRDYE, INTENB0); |
@@ -146,53 +209,30 @@ static int enable_controller(struct r8a66597 *r8a66597) | |||
146 | r8a66597_bset(r8a66597, BRDY0, BRDYENB); | 209 | r8a66597_bset(r8a66597, BRDY0, BRDYENB); |
147 | r8a66597_bset(r8a66597, BEMP0, BEMPENB); | 210 | r8a66597_bset(r8a66597, BEMP0, BEMPENB); |
148 | 211 | ||
149 | r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, DMA0CFG); | ||
150 | r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, DMA1CFG); | ||
151 | |||
152 | r8a66597_bset(r8a66597, endian & BIGEND, CFIFOSEL); | 212 | r8a66597_bset(r8a66597, endian & BIGEND, CFIFOSEL); |
153 | r8a66597_bset(r8a66597, endian & BIGEND, D0FIFOSEL); | 213 | r8a66597_bset(r8a66597, endian & BIGEND, D0FIFOSEL); |
154 | r8a66597_bset(r8a66597, endian & BIGEND, D1FIFOSEL); | 214 | r8a66597_bset(r8a66597, endian & BIGEND, D1FIFOSEL); |
155 | |||
156 | r8a66597_bset(r8a66597, TRNENSEL, SOFCFG); | 215 | r8a66597_bset(r8a66597, TRNENSEL, SOFCFG); |
157 | 216 | ||
158 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); | 217 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); |
159 | r8a66597_bclr(r8a66597, DTCHE, INTENB1); | 218 | |
160 | r8a66597_bset(r8a66597, ATTCHE, INTENB1); | 219 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) |
161 | r8a66597_bclr(r8a66597, DTCHE, INTENB2); | 220 | r8a66597_enable_port(r8a66597, port); |
162 | r8a66597_bset(r8a66597, ATTCHE, INTENB2); | ||
163 | 221 | ||
164 | return 0; | 222 | return 0; |
165 | } | 223 | } |
166 | 224 | ||
167 | static void disable_controller(struct r8a66597 *r8a66597) | 225 | static void disable_controller(struct r8a66597 *r8a66597) |
168 | { | 226 | { |
169 | u16 tmp; | 227 | int port; |
170 | 228 | ||
171 | r8a66597_write(r8a66597, 0, INTENB0); | 229 | r8a66597_write(r8a66597, 0, INTENB0); |
172 | r8a66597_write(r8a66597, 0, INTENB1); | ||
173 | r8a66597_write(r8a66597, 0, INTENB2); | ||
174 | r8a66597_write(r8a66597, 0, INTSTS0); | 230 | r8a66597_write(r8a66597, 0, INTSTS0); |
175 | r8a66597_write(r8a66597, 0, INTSTS1); | ||
176 | r8a66597_write(r8a66597, 0, INTSTS2); | ||
177 | |||
178 | r8a66597_port_power(r8a66597, 0, 0); | ||
179 | r8a66597_port_power(r8a66597, 1, 0); | ||
180 | |||
181 | do { | ||
182 | tmp = r8a66597_read(r8a66597, SOFCFG) & EDGESTS; | ||
183 | udelay(640); | ||
184 | } while (tmp == EDGESTS); | ||
185 | 231 | ||
186 | r8a66597_bclr(r8a66597, DCFM | DRPD, SYSCFG0); | 232 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) |
187 | r8a66597_bclr(r8a66597, DRPD, SYSCFG1); | 233 | r8a66597_disable_port(r8a66597, port); |
188 | r8a66597_bclr(r8a66597, HSE, SYSCFG0); | ||
189 | r8a66597_bclr(r8a66597, HSE, SYSCFG1); | ||
190 | 234 | ||
191 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); | 235 | r8a66597_clock_disable(r8a66597); |
192 | udelay(1); | ||
193 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
194 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
195 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
196 | } | 236 | } |
197 | 237 | ||
198 | static int get_parent_r8a66597_address(struct r8a66597 *r8a66597, | 238 | static int get_parent_r8a66597_address(struct r8a66597 *r8a66597, |
@@ -577,13 +617,9 @@ static void pipe_buffer_setting(struct r8a66597 *r8a66597, | |||
577 | PIPEBUF); | 617 | PIPEBUF); |
578 | r8a66597_write(r8a66597, make_devsel(info->address) | info->maxpacket, | 618 | r8a66597_write(r8a66597, make_devsel(info->address) | info->maxpacket, |
579 | PIPEMAXP); | 619 | PIPEMAXP); |
580 | if (info->interval) | ||
581 | info->interval--; | ||
582 | r8a66597_write(r8a66597, info->interval, PIPEPERI); | 620 | r8a66597_write(r8a66597, info->interval, PIPEPERI); |
583 | } | 621 | } |
584 | 622 | ||
585 | |||
586 | |||
587 | /* this function must be called with interrupt disabled */ | 623 | /* this function must be called with interrupt disabled */ |
588 | static void pipe_setting(struct r8a66597 *r8a66597, struct r8a66597_td *td) | 624 | static void pipe_setting(struct r8a66597 *r8a66597, struct r8a66597_td *td) |
589 | { | 625 | { |
@@ -715,6 +751,7 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
715 | struct r8a66597_pipe *pipe, | 751 | struct r8a66597_pipe *pipe, |
716 | struct urb *urb) | 752 | struct urb *urb) |
717 | { | 753 | { |
754 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
718 | int i; | 755 | int i; |
719 | struct r8a66597_pipe_info *info = &pipe->info; | 756 | struct r8a66597_pipe_info *info = &pipe->info; |
720 | 757 | ||
@@ -742,6 +779,7 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
742 | break; | 779 | break; |
743 | } | 780 | } |
744 | } | 781 | } |
782 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | ||
745 | } | 783 | } |
746 | 784 | ||
747 | /* this function must be called with interrupt disabled */ | 785 | /* this function must be called with interrupt disabled */ |
@@ -825,6 +863,25 @@ static void disable_r8a66597_pipe_all(struct r8a66597 *r8a66597, | |||
825 | dev->dma_map = 0; | 863 | dev->dma_map = 0; |
826 | } | 864 | } |
827 | 865 | ||
866 | static unsigned long get_timer_interval(struct urb *urb, __u8 interval) | ||
867 | { | ||
868 | __u8 i; | ||
869 | unsigned long time = 1; | ||
870 | |||
871 | if (usb_pipeisoc(urb->pipe)) | ||
872 | return 0; | ||
873 | |||
874 | if (get_r8a66597_usb_speed(urb->dev->speed) == HSMODE) { | ||
875 | for (i = 0; i < (interval - 1); i++) | ||
876 | time *= 2; | ||
877 | time = time * 125 / 1000; /* uSOF -> msec */ | ||
878 | } else { | ||
879 | time = interval; | ||
880 | } | ||
881 | |||
882 | return time; | ||
883 | } | ||
884 | |||
828 | /* this function must be called with interrupt disabled */ | 885 | /* this function must be called with interrupt disabled */ |
829 | static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb, | 886 | static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb, |
830 | struct usb_host_endpoint *hep, | 887 | struct usb_host_endpoint *hep, |
@@ -840,7 +897,16 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb, | |||
840 | & USB_ENDPOINT_XFERTYPE_MASK); | 897 | & USB_ENDPOINT_XFERTYPE_MASK); |
841 | info.bufnum = get_bufnum(info.pipenum); | 898 | info.bufnum = get_bufnum(info.pipenum); |
842 | info.buf_bsize = get_buf_bsize(info.pipenum); | 899 | info.buf_bsize = get_buf_bsize(info.pipenum); |
843 | info.interval = ep->bInterval; | 900 | if (info.type == R8A66597_BULK) { |
901 | info.interval = 0; | ||
902 | info.timer_interval = 0; | ||
903 | } else { | ||
904 | if (ep->bInterval > IITV) | ||
905 | info.interval = IITV; | ||
906 | else | ||
907 | info.interval = ep->bInterval ? ep->bInterval - 1 : 0; | ||
908 | info.timer_interval = get_timer_interval(urb, ep->bInterval); | ||
909 | } | ||
844 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) | 910 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) |
845 | info.dir_in = 1; | 911 | info.dir_in = 1; |
846 | else | 912 | else |
@@ -876,10 +942,19 @@ static void pipe_irq_disable(struct r8a66597 *r8a66597, u16 pipenum) | |||
876 | } | 942 | } |
877 | 943 | ||
878 | /* this function must be called with interrupt disabled */ | 944 | /* this function must be called with interrupt disabled */ |
879 | static void r8a66597_usb_preconnect(struct r8a66597 *r8a66597, int port) | 945 | static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port, |
946 | u16 syssts) | ||
880 | { | 947 | { |
881 | r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) | 948 | if (syssts == SE0) { |
882 | | (1 << USB_PORT_FEAT_C_CONNECTION); | 949 | r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); |
950 | return; | ||
951 | } | ||
952 | |||
953 | if (syssts == FS_JSTS) | ||
954 | r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port)); | ||
955 | else if (syssts == LS_JSTS) | ||
956 | r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port)); | ||
957 | |||
883 | r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); | 958 | r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); |
884 | r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); | 959 | r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); |
885 | } | 960 | } |
@@ -960,9 +1035,9 @@ static void prepare_packet_read(struct r8a66597 *r8a66597, | |||
960 | r8a66597_write(r8a66597, TRCLR, | 1035 | r8a66597_write(r8a66597, TRCLR, |
961 | td->pipe->pipetre); | 1036 | td->pipe->pipetre); |
962 | r8a66597_write(r8a66597, | 1037 | r8a66597_write(r8a66597, |
963 | (urb->transfer_buffer_length | 1038 | DIV_ROUND_UP |
964 | + td->maxpacket - 1) | 1039 | (urb->transfer_buffer_length, |
965 | / td->maxpacket, | 1040 | td->maxpacket), |
966 | td->pipe->pipetrn); | 1041 | td->pipe->pipetrn); |
967 | r8a66597_bset(r8a66597, TRENB, | 1042 | r8a66597_bset(r8a66597, TRENB, |
968 | td->pipe->pipetre); | 1043 | td->pipe->pipetre); |
@@ -1021,8 +1096,7 @@ static void prepare_status_packet(struct r8a66597 *r8a66597, | |||
1021 | r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL); | 1096 | r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL); |
1022 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); | 1097 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); |
1023 | r8a66597_write(r8a66597, ~BEMP0, BEMPSTS); | 1098 | r8a66597_write(r8a66597, ~BEMP0, BEMPSTS); |
1024 | r8a66597_write(r8a66597, BCLR, CFIFOCTR); | 1099 | r8a66597_write(r8a66597, BCLR | BVAL, CFIFOCTR); |
1025 | r8a66597_write(r8a66597, BVAL, CFIFOCTR); | ||
1026 | enable_irq_empty(r8a66597, 0); | 1100 | enable_irq_empty(r8a66597, 0); |
1027 | } else { | 1101 | } else { |
1028 | r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); | 1102 | r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); |
@@ -1454,13 +1528,21 @@ static void irq_pipe_nrdy(struct r8a66597 *r8a66597) | |||
1454 | } | 1528 | } |
1455 | } | 1529 | } |
1456 | 1530 | ||
1531 | static void r8a66597_root_hub_start_polling(struct r8a66597 *r8a66597) | ||
1532 | { | ||
1533 | mod_timer(&r8a66597->rh_timer, | ||
1534 | jiffies + msecs_to_jiffies(R8A66597_RH_POLL_TIME)); | ||
1535 | } | ||
1536 | |||
1457 | static void start_root_hub_sampling(struct r8a66597 *r8a66597, int port) | 1537 | static void start_root_hub_sampling(struct r8a66597 *r8a66597, int port) |
1458 | { | 1538 | { |
1459 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 1539 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
1460 | 1540 | ||
1461 | rh->old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; | 1541 | rh->old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; |
1462 | rh->scount = R8A66597_MAX_SAMPLING; | 1542 | rh->scount = R8A66597_MAX_SAMPLING; |
1463 | mod_timer(&r8a66597->rh_timer, jiffies + msecs_to_jiffies(50)); | 1543 | r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) |
1544 | | (1 << USB_PORT_FEAT_C_CONNECTION); | ||
1545 | r8a66597_root_hub_start_polling(r8a66597); | ||
1464 | } | 1546 | } |
1465 | 1547 | ||
1466 | static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) | 1548 | static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) |
@@ -1547,41 +1629,55 @@ static void r8a66597_root_hub_control(struct r8a66597 *r8a66597, int port) | |||
1547 | if ((tmp & USBRST) == USBRST) { | 1629 | if ((tmp & USBRST) == USBRST) { |
1548 | r8a66597_mdfy(r8a66597, UACT, USBRST | UACT, | 1630 | r8a66597_mdfy(r8a66597, UACT, USBRST | UACT, |
1549 | dvstctr_reg); | 1631 | dvstctr_reg); |
1550 | mod_timer(&r8a66597->rh_timer, | 1632 | r8a66597_root_hub_start_polling(r8a66597); |
1551 | jiffies + msecs_to_jiffies(50)); | ||
1552 | } else | 1633 | } else |
1553 | r8a66597_usb_connect(r8a66597, port); | 1634 | r8a66597_usb_connect(r8a66597, port); |
1554 | } | 1635 | } |
1555 | 1636 | ||
1637 | if (!(rh->port & (1 << USB_PORT_FEAT_CONNECTION))) { | ||
1638 | r8a66597_write(r8a66597, ~ATTCH, get_intsts_reg(port)); | ||
1639 | r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); | ||
1640 | } | ||
1641 | |||
1556 | if (rh->scount > 0) { | 1642 | if (rh->scount > 0) { |
1557 | tmp = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; | 1643 | tmp = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; |
1558 | if (tmp == rh->old_syssts) { | 1644 | if (tmp == rh->old_syssts) { |
1559 | rh->scount--; | 1645 | rh->scount--; |
1560 | if (rh->scount == 0) { | 1646 | if (rh->scount == 0) |
1561 | if (tmp == FS_JSTS) { | 1647 | r8a66597_check_syssts(r8a66597, port, tmp); |
1562 | r8a66597_bset(r8a66597, HSE, | 1648 | else |
1563 | get_syscfg_reg(port)); | 1649 | r8a66597_root_hub_start_polling(r8a66597); |
1564 | r8a66597_usb_preconnect(r8a66597, port); | ||
1565 | } else if (tmp == LS_JSTS) { | ||
1566 | r8a66597_bclr(r8a66597, HSE, | ||
1567 | get_syscfg_reg(port)); | ||
1568 | r8a66597_usb_preconnect(r8a66597, port); | ||
1569 | } else if (tmp == SE0) | ||
1570 | r8a66597_bset(r8a66597, ATTCHE, | ||
1571 | get_intenb_reg(port)); | ||
1572 | } else { | ||
1573 | mod_timer(&r8a66597->rh_timer, | ||
1574 | jiffies + msecs_to_jiffies(50)); | ||
1575 | } | ||
1576 | } else { | 1650 | } else { |
1577 | rh->scount = R8A66597_MAX_SAMPLING; | 1651 | rh->scount = R8A66597_MAX_SAMPLING; |
1578 | rh->old_syssts = tmp; | 1652 | rh->old_syssts = tmp; |
1579 | mod_timer(&r8a66597->rh_timer, | 1653 | r8a66597_root_hub_start_polling(r8a66597); |
1580 | jiffies + msecs_to_jiffies(50)); | ||
1581 | } | 1654 | } |
1582 | } | 1655 | } |
1583 | } | 1656 | } |
1584 | 1657 | ||
1658 | static void r8a66597_interval_timer(unsigned long _r8a66597) | ||
1659 | { | ||
1660 | struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; | ||
1661 | unsigned long flags; | ||
1662 | u16 pipenum; | ||
1663 | struct r8a66597_td *td; | ||
1664 | |||
1665 | spin_lock_irqsave(&r8a66597->lock, flags); | ||
1666 | |||
1667 | for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { | ||
1668 | if (!(r8a66597->interval_map & (1 << pipenum))) | ||
1669 | continue; | ||
1670 | if (timer_pending(&r8a66597->interval_timer[pipenum])) | ||
1671 | continue; | ||
1672 | |||
1673 | td = r8a66597_get_td(r8a66597, pipenum); | ||
1674 | if (td) | ||
1675 | start_transfer(r8a66597, td); | ||
1676 | } | ||
1677 | |||
1678 | spin_unlock_irqrestore(&r8a66597->lock, flags); | ||
1679 | } | ||
1680 | |||
1585 | static void r8a66597_td_timer(unsigned long _r8a66597) | 1681 | static void r8a66597_td_timer(unsigned long _r8a66597) |
1586 | { | 1682 | { |
1587 | struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; | 1683 | struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; |
@@ -1763,10 +1859,17 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd, | |||
1763 | urb->hcpriv = td; | 1859 | urb->hcpriv = td; |
1764 | 1860 | ||
1765 | if (request) { | 1861 | if (request) { |
1766 | ret = start_transfer(r8a66597, td); | 1862 | if (td->pipe->info.timer_interval) { |
1767 | if (ret < 0) { | 1863 | r8a66597->interval_map |= 1 << td->pipenum; |
1768 | list_del(&td->queue); | 1864 | mod_timer(&r8a66597->interval_timer[td->pipenum], |
1769 | kfree(td); | 1865 | jiffies + msecs_to_jiffies( |
1866 | td->pipe->info.timer_interval)); | ||
1867 | } else { | ||
1868 | ret = start_transfer(r8a66597, td); | ||
1869 | if (ret < 0) { | ||
1870 | list_del(&td->queue); | ||
1871 | kfree(td); | ||
1872 | } | ||
1770 | } | 1873 | } |
1771 | } else | 1874 | } else |
1772 | set_td_timer(r8a66597, td); | 1875 | set_td_timer(r8a66597, td); |
@@ -2107,13 +2210,11 @@ static struct hc_driver r8a66597_hc_driver = { | |||
2107 | #if defined(CONFIG_PM) | 2210 | #if defined(CONFIG_PM) |
2108 | static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) | 2211 | static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) |
2109 | { | 2212 | { |
2110 | pdev->dev.power.power_state = state; | ||
2111 | return 0; | 2213 | return 0; |
2112 | } | 2214 | } |
2113 | 2215 | ||
2114 | static int r8a66597_resume(struct platform_device *pdev) | 2216 | static int r8a66597_resume(struct platform_device *pdev) |
2115 | { | 2217 | { |
2116 | pdev->dev.power.power_state = PMSG_ON; | ||
2117 | return 0; | 2218 | return 0; |
2118 | } | 2219 | } |
2119 | #else /* if defined(CONFIG_PM) */ | 2220 | #else /* if defined(CONFIG_PM) */ |
@@ -2194,6 +2295,9 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2194 | init_timer(&r8a66597->td_timer[i]); | 2295 | init_timer(&r8a66597->td_timer[i]); |
2195 | r8a66597->td_timer[i].function = r8a66597_td_timer; | 2296 | r8a66597->td_timer[i].function = r8a66597_td_timer; |
2196 | r8a66597->td_timer[i].data = (unsigned long)r8a66597; | 2297 | r8a66597->td_timer[i].data = (unsigned long)r8a66597; |
2298 | setup_timer(&r8a66597->interval_timer[i], | ||
2299 | r8a66597_interval_timer, | ||
2300 | (unsigned long)r8a66597); | ||
2197 | } | 2301 | } |
2198 | INIT_LIST_HEAD(&r8a66597->child_device); | 2302 | INIT_LIST_HEAD(&r8a66597->child_device); |
2199 | 2303 | ||
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index 57388252b693..84ee01417315 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -187,7 +187,11 @@ | |||
187 | #define REW 0x4000 /* b14: Buffer rewind */ | 187 | #define REW 0x4000 /* b14: Buffer rewind */ |
188 | #define DCLRM 0x2000 /* b13: DMA buffer clear mode */ | 188 | #define DCLRM 0x2000 /* b13: DMA buffer clear mode */ |
189 | #define DREQE 0x1000 /* b12: DREQ output enable */ | 189 | #define DREQE 0x1000 /* b12: DREQ output enable */ |
190 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
191 | #define MBW 0x0800 | ||
192 | #else | ||
190 | #define MBW 0x0400 /* b10: Maximum bit width for FIFO access */ | 193 | #define MBW 0x0400 /* b10: Maximum bit width for FIFO access */ |
194 | #endif | ||
191 | #define MBW_8 0x0000 /* 8bit */ | 195 | #define MBW_8 0x0000 /* 8bit */ |
192 | #define MBW_16 0x0400 /* 16bit */ | 196 | #define MBW_16 0x0400 /* 16bit */ |
193 | #define BIGEND 0x0100 /* b8: Big endian mode */ | 197 | #define BIGEND 0x0100 /* b8: Big endian mode */ |
@@ -395,8 +399,13 @@ | |||
395 | #define R8A66597_MAX_NUM_PIPE 10 | 399 | #define R8A66597_MAX_NUM_PIPE 10 |
396 | #define R8A66597_BUF_BSIZE 8 | 400 | #define R8A66597_BUF_BSIZE 8 |
397 | #define R8A66597_MAX_DEVICE 10 | 401 | #define R8A66597_MAX_DEVICE 10 |
402 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
403 | #define R8A66597_MAX_ROOT_HUB 1 | ||
404 | #else | ||
398 | #define R8A66597_MAX_ROOT_HUB 2 | 405 | #define R8A66597_MAX_ROOT_HUB 2 |
399 | #define R8A66597_MAX_SAMPLING 10 | 406 | #endif |
407 | #define R8A66597_MAX_SAMPLING 5 | ||
408 | #define R8A66597_RH_POLL_TIME 10 | ||
400 | #define R8A66597_MAX_DMA_CHANNEL 2 | 409 | #define R8A66597_MAX_DMA_CHANNEL 2 |
401 | #define R8A66597_PIPE_NO_DMA R8A66597_MAX_DMA_CHANNEL | 410 | #define R8A66597_PIPE_NO_DMA R8A66597_MAX_DMA_CHANNEL |
402 | #define check_bulk_or_isoc(pipenum) ((pipenum >= 1 && pipenum <= 5)) | 411 | #define check_bulk_or_isoc(pipenum) ((pipenum >= 1 && pipenum <= 5)) |
@@ -404,6 +413,7 @@ | |||
404 | #define make_devsel(addr) (addr << 12) | 413 | #define make_devsel(addr) (addr << 12) |
405 | 414 | ||
406 | struct r8a66597_pipe_info { | 415 | struct r8a66597_pipe_info { |
416 | unsigned long timer_interval; | ||
407 | u16 pipenum; | 417 | u16 pipenum; |
408 | u16 address; /* R8A66597 HCD usb address */ | 418 | u16 address; /* R8A66597 HCD usb address */ |
409 | u16 epnum; | 419 | u16 epnum; |
@@ -478,9 +488,11 @@ struct r8a66597 { | |||
478 | 488 | ||
479 | struct timer_list rh_timer; | 489 | struct timer_list rh_timer; |
480 | struct timer_list td_timer[R8A66597_MAX_NUM_PIPE]; | 490 | struct timer_list td_timer[R8A66597_MAX_NUM_PIPE]; |
491 | struct timer_list interval_timer[R8A66597_MAX_NUM_PIPE]; | ||
481 | 492 | ||
482 | unsigned short address_map; | 493 | unsigned short address_map; |
483 | unsigned short timeout_map; | 494 | unsigned short timeout_map; |
495 | unsigned short interval_map; | ||
484 | unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; | 496 | unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; |
485 | unsigned char dma_map; | 497 | unsigned char dma_map; |
486 | 498 | ||
@@ -526,8 +538,21 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, | |||
526 | unsigned long offset, u16 *buf, | 538 | unsigned long offset, u16 *buf, |
527 | int len) | 539 | int len) |
528 | { | 540 | { |
541 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
542 | unsigned long fifoaddr = r8a66597->reg + offset; | ||
543 | unsigned long count; | ||
544 | |||
545 | count = len / 4; | ||
546 | insl(fifoaddr, buf, count); | ||
547 | |||
548 | if (len & 0x00000003) { | ||
549 | unsigned long tmp = inl(fifoaddr); | ||
550 | memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03); | ||
551 | } | ||
552 | #else | ||
529 | len = (len + 1) / 2; | 553 | len = (len + 1) / 2; |
530 | insw(r8a66597->reg + offset, buf, len); | 554 | insw(r8a66597->reg + offset, buf, len); |
555 | #endif | ||
531 | } | 556 | } |
532 | 557 | ||
533 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, | 558 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, |
@@ -541,6 +566,24 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | |||
541 | int len) | 566 | int len) |
542 | { | 567 | { |
543 | unsigned long fifoaddr = r8a66597->reg + offset; | 568 | unsigned long fifoaddr = r8a66597->reg + offset; |
569 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
570 | unsigned long count; | ||
571 | unsigned char *pb; | ||
572 | int i; | ||
573 | |||
574 | count = len / 4; | ||
575 | outsl(fifoaddr, buf, count); | ||
576 | |||
577 | if (len & 0x00000003) { | ||
578 | pb = (unsigned char *)buf + count * 4; | ||
579 | for (i = 0; i < (len & 0x00000003); i++) { | ||
580 | if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) | ||
581 | outb(pb[i], fifoaddr + i); | ||
582 | else | ||
583 | outb(pb[i], fifoaddr + 3 - i); | ||
584 | } | ||
585 | } | ||
586 | #else | ||
544 | int odd = len & 0x0001; | 587 | int odd = len & 0x0001; |
545 | 588 | ||
546 | len = len / 2; | 589 | len = len / 2; |
@@ -549,6 +592,7 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | |||
549 | buf = &buf[len]; | 592 | buf = &buf[len]; |
550 | outb((unsigned char)*buf, fifoaddr); | 593 | outb((unsigned char)*buf, fifoaddr); |
551 | } | 594 | } |
595 | #endif | ||
552 | } | 596 | } |
553 | 597 | ||
554 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, | 598 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, |
@@ -581,6 +625,11 @@ static inline unsigned long get_dvstctr_reg(int port) | |||
581 | return port == 0 ? DVSTCTR0 : DVSTCTR1; | 625 | return port == 0 ? DVSTCTR0 : DVSTCTR1; |
582 | } | 626 | } |
583 | 627 | ||
628 | static inline unsigned long get_dmacfg_reg(int port) | ||
629 | { | ||
630 | return port == 0 ? DMA0CFG : DMA1CFG; | ||
631 | } | ||
632 | |||
584 | static inline unsigned long get_intenb_reg(int port) | 633 | static inline unsigned long get_intenb_reg(int port) |
585 | { | 634 | { |
586 | return port == 0 ? INTENB1 : INTENB2; | 635 | return port == 0 ? INTENB1 : INTENB2; |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 629bca0ebe8f..274276cf8621 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -94,12 +94,10 @@ static void port_power(struct sl811 *sl811, int is_on) | |||
94 | 94 | ||
95 | sl811->port1 = (1 << USB_PORT_FEAT_POWER); | 95 | sl811->port1 = (1 << USB_PORT_FEAT_POWER); |
96 | sl811->irq_enable = SL11H_INTMASK_INSRMV; | 96 | sl811->irq_enable = SL11H_INTMASK_INSRMV; |
97 | hcd->self.controller->power.power_state = PMSG_ON; | ||
98 | } else { | 97 | } else { |
99 | sl811->port1 = 0; | 98 | sl811->port1 = 0; |
100 | sl811->irq_enable = 0; | 99 | sl811->irq_enable = 0; |
101 | hcd->state = HC_STATE_HALT; | 100 | hcd->state = HC_STATE_HALT; |
102 | hcd->self.controller->power.power_state = PMSG_SUSPEND; | ||
103 | } | 101 | } |
104 | sl811->ctrl1 = 0; | 102 | sl811->ctrl1 = 0; |
105 | sl811_write(sl811, SL11H_IRQ_ENABLE, 0); | 103 | sl811_write(sl811, SL11H_IRQ_ENABLE, 0); |
@@ -1337,7 +1335,7 @@ static int | |||
1337 | sl811h_bus_suspend(struct usb_hcd *hcd) | 1335 | sl811h_bus_suspend(struct usb_hcd *hcd) |
1338 | { | 1336 | { |
1339 | // SOFs off | 1337 | // SOFs off |
1340 | DBG("%s\n", __FUNCTION__); | 1338 | DBG("%s\n", __func__); |
1341 | return 0; | 1339 | return 0; |
1342 | } | 1340 | } |
1343 | 1341 | ||
@@ -1345,7 +1343,7 @@ static int | |||
1345 | sl811h_bus_resume(struct usb_hcd *hcd) | 1343 | sl811h_bus_resume(struct usb_hcd *hcd) |
1346 | { | 1344 | { |
1347 | // SOFs on | 1345 | // SOFs on |
1348 | DBG("%s\n", __FUNCTION__); | 1346 | DBG("%s\n", __func__); |
1349 | return 0; | 1347 | return 0; |
1350 | } | 1348 | } |
1351 | 1349 | ||
@@ -1772,8 +1770,6 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state) | |||
1772 | port_power(sl811, 0); | 1770 | port_power(sl811, 0); |
1773 | break; | 1771 | break; |
1774 | } | 1772 | } |
1775 | if (retval == 0) | ||
1776 | dev->dev.power.power_state = state; | ||
1777 | return retval; | 1773 | return retval; |
1778 | } | 1774 | } |
1779 | 1775 | ||
@@ -1786,15 +1782,13 @@ sl811h_resume(struct platform_device *dev) | |||
1786 | /* with no "check to see if VBUS is still powered" board hook, | 1782 | /* with no "check to see if VBUS is still powered" board hook, |
1787 | * let's assume it'd only be powered to enable remote wakeup. | 1783 | * let's assume it'd only be powered to enable remote wakeup. |
1788 | */ | 1784 | */ |
1789 | if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND | 1785 | if (!sl811->port1 || !device_can_wakeup(&hcd->self.root_hub->dev)) { |
1790 | || !device_can_wakeup(&hcd->self.root_hub->dev)) { | ||
1791 | sl811->port1 = 0; | 1786 | sl811->port1 = 0; |
1792 | port_power(sl811, 1); | 1787 | port_power(sl811, 1); |
1793 | usb_root_hub_lost_power(hcd->self.root_hub); | 1788 | usb_root_hub_lost_power(hcd->self.root_hub); |
1794 | return 0; | 1789 | return 0; |
1795 | } | 1790 | } |
1796 | 1791 | ||
1797 | dev->dev.power.power_state = PMSG_ON; | ||
1798 | return sl811h_bus_resume(hcd); | 1792 | return sl811h_bus_resume(hcd); |
1799 | } | 1793 | } |
1800 | 1794 | ||
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 8e117a795e93..f29307405bb3 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #include "ohci.h" | 67 | #include "ohci.h" |
68 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR | 68 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR |
69 | #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ | 69 | #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ |
70 | OHCI_INTR_WDH) | 70 | OHCI_INTR_WDH) |
71 | MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited"); | 71 | MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited"); |
72 | MODULE_DESCRIPTION("U132 USB Host Controller Driver"); | 72 | MODULE_DESCRIPTION("U132 USB Host Controller Driver"); |
73 | MODULE_LICENSE("GPL"); | 73 | MODULE_LICENSE("GPL"); |
@@ -77,15 +77,15 @@ INT_MODULE_PARM(testing, 0); | |||
77 | static int distrust_firmware = 1; | 77 | static int distrust_firmware = 1; |
78 | module_param(distrust_firmware, bool, 0); | 78 | module_param(distrust_firmware, bool, 0); |
79 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" | 79 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" |
80 | "t setup"); | 80 | "t setup"); |
81 | static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); | 81 | static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); |
82 | /* | 82 | /* |
83 | * u132_module_lock exists to protect access to global variables | 83 | * u132_module_lock exists to protect access to global variables |
84 | * | 84 | * |
85 | */ | 85 | */ |
86 | static struct mutex u132_module_lock; | 86 | static struct mutex u132_module_lock; |
87 | static int u132_exiting = 0; | 87 | static int u132_exiting; |
88 | static int u132_instances = 0; | 88 | static int u132_instances; |
89 | static struct list_head u132_static_list; | 89 | static struct list_head u132_static_list; |
90 | /* | 90 | /* |
91 | * end of the global variables protected by u132_module_lock | 91 | * end of the global variables protected by u132_module_lock |
@@ -97,115 +97,115 @@ static struct workqueue_struct *workqueue; | |||
97 | #define MAX_U132_ENDPS 100 | 97 | #define MAX_U132_ENDPS 100 |
98 | #define MAX_U132_RINGS 4 | 98 | #define MAX_U132_RINGS 4 |
99 | static const char *cc_to_text[16] = { | 99 | static const char *cc_to_text[16] = { |
100 | "No Error ", | 100 | "No Error ", |
101 | "CRC Error ", | 101 | "CRC Error ", |
102 | "Bit Stuff ", | 102 | "Bit Stuff ", |
103 | "Data Togg ", | 103 | "Data Togg ", |
104 | "Stall ", | 104 | "Stall ", |
105 | "DevNotResp ", | 105 | "DevNotResp ", |
106 | "PIDCheck ", | 106 | "PIDCheck ", |
107 | "UnExpPID ", | 107 | "UnExpPID ", |
108 | "DataOver ", | 108 | "DataOver ", |
109 | "DataUnder ", | 109 | "DataUnder ", |
110 | "(for hw) ", | 110 | "(for hw) ", |
111 | "(for hw) ", | 111 | "(for hw) ", |
112 | "BufferOver ", | 112 | "BufferOver ", |
113 | "BuffUnder ", | 113 | "BuffUnder ", |
114 | "(for HCD) ", | 114 | "(for HCD) ", |
115 | "(for HCD) " | 115 | "(for HCD) " |
116 | }; | 116 | }; |
117 | struct u132_port { | 117 | struct u132_port { |
118 | struct u132 *u132; | 118 | struct u132 *u132; |
119 | int reset; | 119 | int reset; |
120 | int enable; | 120 | int enable; |
121 | int power; | 121 | int power; |
122 | int Status; | 122 | int Status; |
123 | }; | 123 | }; |
124 | struct u132_addr { | 124 | struct u132_addr { |
125 | u8 address; | 125 | u8 address; |
126 | }; | 126 | }; |
127 | struct u132_udev { | 127 | struct u132_udev { |
128 | struct kref kref; | 128 | struct kref kref; |
129 | struct usb_device *usb_device; | 129 | struct usb_device *usb_device; |
130 | u8 enumeration; | 130 | u8 enumeration; |
131 | u8 udev_number; | 131 | u8 udev_number; |
132 | u8 usb_addr; | 132 | u8 usb_addr; |
133 | u8 portnumber; | 133 | u8 portnumber; |
134 | u8 endp_number_in[16]; | 134 | u8 endp_number_in[16]; |
135 | u8 endp_number_out[16]; | 135 | u8 endp_number_out[16]; |
136 | }; | 136 | }; |
137 | #define ENDP_QUEUE_SHIFT 3 | 137 | #define ENDP_QUEUE_SHIFT 3 |
138 | #define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT) | 138 | #define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT) |
139 | #define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1) | 139 | #define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1) |
140 | struct u132_urbq { | 140 | struct u132_urbq { |
141 | struct list_head urb_more; | 141 | struct list_head urb_more; |
142 | struct urb *urb; | 142 | struct urb *urb; |
143 | }; | 143 | }; |
144 | struct u132_spin { | 144 | struct u132_spin { |
145 | spinlock_t slock; | 145 | spinlock_t slock; |
146 | }; | 146 | }; |
147 | struct u132_endp { | 147 | struct u132_endp { |
148 | struct kref kref; | 148 | struct kref kref; |
149 | u8 udev_number; | 149 | u8 udev_number; |
150 | u8 endp_number; | 150 | u8 endp_number; |
151 | u8 usb_addr; | 151 | u8 usb_addr; |
152 | u8 usb_endp; | 152 | u8 usb_endp; |
153 | struct u132 *u132; | 153 | struct u132 *u132; |
154 | struct list_head endp_ring; | 154 | struct list_head endp_ring; |
155 | struct u132_ring *ring; | 155 | struct u132_ring *ring; |
156 | unsigned toggle_bits:2; | 156 | unsigned toggle_bits:2; |
157 | unsigned active:1; | 157 | unsigned active:1; |
158 | unsigned delayed:1; | 158 | unsigned delayed:1; |
159 | unsigned input:1; | 159 | unsigned input:1; |
160 | unsigned output:1; | 160 | unsigned output:1; |
161 | unsigned pipetype:2; | 161 | unsigned pipetype:2; |
162 | unsigned dequeueing:1; | 162 | unsigned dequeueing:1; |
163 | unsigned edset_flush:1; | 163 | unsigned edset_flush:1; |
164 | unsigned spare_bits:14; | 164 | unsigned spare_bits:14; |
165 | unsigned long jiffies; | 165 | unsigned long jiffies; |
166 | struct usb_host_endpoint *hep; | 166 | struct usb_host_endpoint *hep; |
167 | struct u132_spin queue_lock; | 167 | struct u132_spin queue_lock; |
168 | u16 queue_size; | 168 | u16 queue_size; |
169 | u16 queue_last; | 169 | u16 queue_last; |
170 | u16 queue_next; | 170 | u16 queue_next; |
171 | struct urb *urb_list[ENDP_QUEUE_SIZE]; | 171 | struct urb *urb_list[ENDP_QUEUE_SIZE]; |
172 | struct list_head urb_more; | 172 | struct list_head urb_more; |
173 | struct delayed_work scheduler; | 173 | struct delayed_work scheduler; |
174 | }; | 174 | }; |
175 | struct u132_ring { | 175 | struct u132_ring { |
176 | unsigned in_use:1; | 176 | unsigned in_use:1; |
177 | unsigned length:7; | 177 | unsigned length:7; |
178 | u8 number; | 178 | u8 number; |
179 | struct u132 *u132; | 179 | struct u132 *u132; |
180 | struct u132_endp *curr_endp; | 180 | struct u132_endp *curr_endp; |
181 | struct delayed_work scheduler; | 181 | struct delayed_work scheduler; |
182 | }; | 182 | }; |
183 | struct u132 { | 183 | struct u132 { |
184 | struct kref kref; | 184 | struct kref kref; |
185 | struct list_head u132_list; | 185 | struct list_head u132_list; |
186 | struct mutex sw_lock; | 186 | struct mutex sw_lock; |
187 | struct semaphore scheduler_lock; | 187 | struct mutex scheduler_lock; |
188 | struct u132_platform_data *board; | 188 | struct u132_platform_data *board; |
189 | struct platform_device *platform_dev; | 189 | struct platform_device *platform_dev; |
190 | struct u132_ring ring[MAX_U132_RINGS]; | 190 | struct u132_ring ring[MAX_U132_RINGS]; |
191 | int sequence_num; | 191 | int sequence_num; |
192 | int going; | 192 | int going; |
193 | int power; | 193 | int power; |
194 | int reset; | 194 | int reset; |
195 | int num_ports; | 195 | int num_ports; |
196 | u32 hc_control; | 196 | u32 hc_control; |
197 | u32 hc_fminterval; | 197 | u32 hc_fminterval; |
198 | u32 hc_roothub_status; | 198 | u32 hc_roothub_status; |
199 | u32 hc_roothub_a; | 199 | u32 hc_roothub_a; |
200 | u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; | 200 | u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; |
201 | int flags; | 201 | int flags; |
202 | unsigned long next_statechange; | 202 | unsigned long next_statechange; |
203 | struct delayed_work monitor; | 203 | struct delayed_work monitor; |
204 | int num_endpoints; | 204 | int num_endpoints; |
205 | struct u132_addr addr[MAX_U132_ADDRS]; | 205 | struct u132_addr addr[MAX_U132_ADDRS]; |
206 | struct u132_udev udev[MAX_U132_UDEVS]; | 206 | struct u132_udev udev[MAX_U132_UDEVS]; |
207 | struct u132_port port[MAX_U132_PORTS]; | 207 | struct u132_port port[MAX_U132_PORTS]; |
208 | struct u132_endp *endp[MAX_U132_ENDPS]; | 208 | struct u132_endp *endp[MAX_U132_ENDPS]; |
209 | }; | 209 | }; |
210 | 210 | ||
211 | /* | 211 | /* |
@@ -213,34 +213,34 @@ struct u132 { | |||
213 | * Does anyone have a better way????? | 213 | * Does anyone have a better way????? |
214 | */ | 214 | */ |
215 | #define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \ | 215 | #define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \ |
216 | offsetof(struct ohci_regs, member), 0, data); | 216 | offsetof(struct ohci_regs, member), 0, data); |
217 | #define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \ | 217 | #define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \ |
218 | offsetof(struct ohci_regs, member), 0, data); | 218 | offsetof(struct ohci_regs, member), 0, data); |
219 | #define u132_read_pcimem(u132, member, data) \ | 219 | #define u132_read_pcimem(u132, member, data) \ |
220 | usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ | 220 | usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ |
221 | ohci_regs, member), 0, data); | 221 | ohci_regs, member), 0, data); |
222 | #define u132_write_pcimem(u132, member, data) \ | 222 | #define u132_write_pcimem(u132, member, data) \ |
223 | usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ | 223 | usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ |
224 | ohci_regs, member), 0, data); | 224 | ohci_regs, member), 0, data); |
225 | static inline struct u132 *udev_to_u132(struct u132_udev *udev) | 225 | static inline struct u132 *udev_to_u132(struct u132_udev *udev) |
226 | { | 226 | { |
227 | u8 udev_number = udev->udev_number; | 227 | u8 udev_number = udev->udev_number; |
228 | return container_of(udev, struct u132, udev[udev_number]); | 228 | return container_of(udev, struct u132, udev[udev_number]); |
229 | } | 229 | } |
230 | 230 | ||
231 | static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd) | 231 | static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd) |
232 | { | 232 | { |
233 | return (struct u132 *)(hcd->hcd_priv); | 233 | return (struct u132 *)(hcd->hcd_priv); |
234 | } | 234 | } |
235 | 235 | ||
236 | static inline struct usb_hcd *u132_to_hcd(struct u132 *u132) | 236 | static inline struct usb_hcd *u132_to_hcd(struct u132 *u132) |
237 | { | 237 | { |
238 | return container_of((void *)u132, struct usb_hcd, hcd_priv); | 238 | return container_of((void *)u132, struct usb_hcd, hcd_priv); |
239 | } | 239 | } |
240 | 240 | ||
241 | static inline void u132_disable(struct u132 *u132) | 241 | static inline void u132_disable(struct u132 *u132) |
242 | { | 242 | { |
243 | u132_to_hcd(u132)->state = HC_STATE_HALT; | 243 | u132_to_hcd(u132)->state = HC_STATE_HALT; |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
@@ -250,147 +250,147 @@ static inline void u132_disable(struct u132 *u132) | |||
250 | #include "../misc/usb_u132.h" | 250 | #include "../misc/usb_u132.h" |
251 | static const char hcd_name[] = "u132_hcd"; | 251 | static const char hcd_name[] = "u132_hcd"; |
252 | #define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \ | 252 | #define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \ |
253 | USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ | 253 | USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ |
254 | USB_PORT_STAT_C_RESET) << 16) | 254 | USB_PORT_STAT_C_RESET) << 16) |
255 | static void u132_hcd_delete(struct kref *kref) | 255 | static void u132_hcd_delete(struct kref *kref) |
256 | { | 256 | { |
257 | struct u132 *u132 = kref_to_u132(kref); | 257 | struct u132 *u132 = kref_to_u132(kref); |
258 | struct platform_device *pdev = u132->platform_dev; | 258 | struct platform_device *pdev = u132->platform_dev; |
259 | struct usb_hcd *hcd = u132_to_hcd(u132); | 259 | struct usb_hcd *hcd = u132_to_hcd(u132); |
260 | u132->going += 1; | 260 | u132->going += 1; |
261 | mutex_lock(&u132_module_lock); | 261 | mutex_lock(&u132_module_lock); |
262 | list_del_init(&u132->u132_list); | 262 | list_del_init(&u132->u132_list); |
263 | u132_instances -= 1; | 263 | u132_instances -= 1; |
264 | mutex_unlock(&u132_module_lock); | 264 | mutex_unlock(&u132_module_lock); |
265 | dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" | 265 | dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" |
266 | "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); | 266 | "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); |
267 | usb_put_hcd(hcd); | 267 | usb_put_hcd(hcd); |
268 | } | 268 | } |
269 | 269 | ||
270 | static inline void u132_u132_put_kref(struct u132 *u132) | 270 | static inline void u132_u132_put_kref(struct u132 *u132) |
271 | { | 271 | { |
272 | kref_put(&u132->kref, u132_hcd_delete); | 272 | kref_put(&u132->kref, u132_hcd_delete); |
273 | } | 273 | } |
274 | 274 | ||
275 | static inline void u132_u132_init_kref(struct u132 *u132) | 275 | static inline void u132_u132_init_kref(struct u132 *u132) |
276 | { | 276 | { |
277 | kref_init(&u132->kref); | 277 | kref_init(&u132->kref); |
278 | } | 278 | } |
279 | 279 | ||
280 | static void u132_udev_delete(struct kref *kref) | 280 | static void u132_udev_delete(struct kref *kref) |
281 | { | 281 | { |
282 | struct u132_udev *udev = kref_to_u132_udev(kref); | 282 | struct u132_udev *udev = kref_to_u132_udev(kref); |
283 | udev->udev_number = 0; | 283 | udev->udev_number = 0; |
284 | udev->usb_device = NULL; | 284 | udev->usb_device = NULL; |
285 | udev->usb_addr = 0; | 285 | udev->usb_addr = 0; |
286 | udev->enumeration = 0; | 286 | udev->enumeration = 0; |
287 | } | 287 | } |
288 | 288 | ||
289 | static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev) | 289 | static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev) |
290 | { | 290 | { |
291 | kref_put(&udev->kref, u132_udev_delete); | 291 | kref_put(&udev->kref, u132_udev_delete); |
292 | } | 292 | } |
293 | 293 | ||
294 | static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev) | 294 | static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev) |
295 | { | 295 | { |
296 | kref_get(&udev->kref); | 296 | kref_get(&udev->kref); |
297 | } | 297 | } |
298 | 298 | ||
299 | static inline void u132_udev_init_kref(struct u132 *u132, | 299 | static inline void u132_udev_init_kref(struct u132 *u132, |
300 | struct u132_udev *udev) | 300 | struct u132_udev *udev) |
301 | { | 301 | { |
302 | kref_init(&udev->kref); | 302 | kref_init(&udev->kref); |
303 | } | 303 | } |
304 | 304 | ||
305 | static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring) | 305 | static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring) |
306 | { | 306 | { |
307 | kref_put(&u132->kref, u132_hcd_delete); | 307 | kref_put(&u132->kref, u132_hcd_delete); |
308 | } | 308 | } |
309 | 309 | ||
310 | static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring, | 310 | static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring, |
311 | unsigned int delta) | 311 | unsigned int delta) |
312 | { | 312 | { |
313 | if (delta > 0) { | 313 | if (delta > 0) { |
314 | if (queue_delayed_work(workqueue, &ring->scheduler, delta)) | 314 | if (queue_delayed_work(workqueue, &ring->scheduler, delta)) |
315 | return; | 315 | return; |
316 | } else if (queue_delayed_work(workqueue, &ring->scheduler, 0)) | 316 | } else if (queue_delayed_work(workqueue, &ring->scheduler, 0)) |
317 | return; | 317 | return; |
318 | kref_put(&u132->kref, u132_hcd_delete); | 318 | kref_put(&u132->kref, u132_hcd_delete); |
319 | return; | 319 | return; |
320 | } | 320 | } |
321 | 321 | ||
322 | static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring, | 322 | static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring, |
323 | unsigned int delta) | 323 | unsigned int delta) |
324 | { | 324 | { |
325 | kref_get(&u132->kref); | 325 | kref_get(&u132->kref); |
326 | u132_ring_requeue_work(u132, ring, delta); | 326 | u132_ring_requeue_work(u132, ring, delta); |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | 329 | ||
330 | static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring) | 330 | static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring) |
331 | { | 331 | { |
332 | if (cancel_delayed_work(&ring->scheduler)) { | 332 | if (cancel_delayed_work(&ring->scheduler)) |
333 | kref_put(&u132->kref, u132_hcd_delete); | 333 | kref_put(&u132->kref, u132_hcd_delete); |
334 | } | ||
335 | } | 334 | } |
336 | 335 | ||
337 | static void u132_endp_delete(struct kref *kref) | 336 | static void u132_endp_delete(struct kref *kref) |
338 | { | 337 | { |
339 | struct u132_endp *endp = kref_to_u132_endp(kref); | 338 | struct u132_endp *endp = kref_to_u132_endp(kref); |
340 | struct u132 *u132 = endp->u132; | 339 | struct u132 *u132 = endp->u132; |
341 | u8 usb_addr = endp->usb_addr; | 340 | u8 usb_addr = endp->usb_addr; |
342 | u8 usb_endp = endp->usb_endp; | 341 | u8 usb_endp = endp->usb_endp; |
343 | u8 address = u132->addr[usb_addr].address; | 342 | u8 address = u132->addr[usb_addr].address; |
344 | struct u132_udev *udev = &u132->udev[address]; | 343 | struct u132_udev *udev = &u132->udev[address]; |
345 | u8 endp_number = endp->endp_number; | 344 | u8 endp_number = endp->endp_number; |
346 | struct usb_host_endpoint *hep = endp->hep; | 345 | struct usb_host_endpoint *hep = endp->hep; |
347 | struct u132_ring *ring = endp->ring; | 346 | struct u132_ring *ring = endp->ring; |
348 | struct list_head *head = &endp->endp_ring; | 347 | struct list_head *head = &endp->endp_ring; |
349 | ring->length -= 1; | 348 | ring->length -= 1; |
350 | if (endp == ring->curr_endp) { | 349 | if (endp == ring->curr_endp) { |
351 | if (list_empty(head)) { | 350 | if (list_empty(head)) { |
352 | ring->curr_endp = NULL; | 351 | ring->curr_endp = NULL; |
353 | list_del(head); | 352 | list_del(head); |
354 | } else { | 353 | } else { |
355 | struct u132_endp *next_endp = list_entry(head->next, | 354 | struct u132_endp *next_endp = list_entry(head->next, |
356 | struct u132_endp, endp_ring); | 355 | struct u132_endp, endp_ring); |
357 | ring->curr_endp = next_endp; | 356 | ring->curr_endp = next_endp; |
358 | list_del(head); | 357 | list_del(head); |
359 | }} else | 358 | } |
360 | list_del(head); | 359 | } else |
361 | if (endp->input) { | 360 | list_del(head); |
362 | udev->endp_number_in[usb_endp] = 0; | 361 | if (endp->input) { |
363 | u132_udev_put_kref(u132, udev); | 362 | udev->endp_number_in[usb_endp] = 0; |
364 | } | 363 | u132_udev_put_kref(u132, udev); |
365 | if (endp->output) { | 364 | } |
366 | udev->endp_number_out[usb_endp] = 0; | 365 | if (endp->output) { |
367 | u132_udev_put_kref(u132, udev); | 366 | udev->endp_number_out[usb_endp] = 0; |
368 | } | 367 | u132_udev_put_kref(u132, udev); |
369 | u132->endp[endp_number - 1] = NULL; | 368 | } |
370 | hep->hcpriv = NULL; | 369 | u132->endp[endp_number - 1] = NULL; |
371 | kfree(endp); | 370 | hep->hcpriv = NULL; |
372 | u132_u132_put_kref(u132); | 371 | kfree(endp); |
372 | u132_u132_put_kref(u132); | ||
373 | } | 373 | } |
374 | 374 | ||
375 | static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp) | 375 | static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp) |
376 | { | 376 | { |
377 | kref_put(&endp->kref, u132_endp_delete); | 377 | kref_put(&endp->kref, u132_endp_delete); |
378 | } | 378 | } |
379 | 379 | ||
380 | static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp) | 380 | static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp) |
381 | { | 381 | { |
382 | kref_get(&endp->kref); | 382 | kref_get(&endp->kref); |
383 | } | 383 | } |
384 | 384 | ||
385 | static inline void u132_endp_init_kref(struct u132 *u132, | 385 | static inline void u132_endp_init_kref(struct u132 *u132, |
386 | struct u132_endp *endp) | 386 | struct u132_endp *endp) |
387 | { | 387 | { |
388 | kref_init(&endp->kref); | 388 | kref_init(&endp->kref); |
389 | kref_get(&u132->kref); | 389 | kref_get(&u132->kref); |
390 | } | 390 | } |
391 | 391 | ||
392 | static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, | 392 | static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, |
393 | unsigned int delta) | 393 | unsigned int delta) |
394 | { | 394 | { |
395 | if (queue_delayed_work(workqueue, &endp->scheduler, delta)) | 395 | if (queue_delayed_work(workqueue, &endp->scheduler, delta)) |
396 | kref_get(&endp->kref); | 396 | kref_get(&endp->kref); |
@@ -398,13 +398,13 @@ static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, | |||
398 | 398 | ||
399 | static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) | 399 | static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) |
400 | { | 400 | { |
401 | if (cancel_delayed_work(&endp->scheduler)) | 401 | if (cancel_delayed_work(&endp->scheduler)) |
402 | kref_put(&endp->kref, u132_endp_delete); | 402 | kref_put(&endp->kref, u132_endp_delete); |
403 | } | 403 | } |
404 | 404 | ||
405 | static inline void u132_monitor_put_kref(struct u132 *u132) | 405 | static inline void u132_monitor_put_kref(struct u132 *u132) |
406 | { | 406 | { |
407 | kref_put(&u132->kref, u132_hcd_delete); | 407 | kref_put(&u132->kref, u132_hcd_delete); |
408 | } | 408 | } |
409 | 409 | ||
410 | static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) | 410 | static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) |
@@ -421,200 +421,201 @@ static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) | |||
421 | 421 | ||
422 | static void u132_monitor_cancel_work(struct u132 *u132) | 422 | static void u132_monitor_cancel_work(struct u132 *u132) |
423 | { | 423 | { |
424 | if (cancel_delayed_work(&u132->monitor)) | 424 | if (cancel_delayed_work(&u132->monitor)) |
425 | kref_put(&u132->kref, u132_hcd_delete); | 425 | kref_put(&u132->kref, u132_hcd_delete); |
426 | } | 426 | } |
427 | 427 | ||
428 | static int read_roothub_info(struct u132 *u132) | 428 | static int read_roothub_info(struct u132 *u132) |
429 | { | 429 | { |
430 | u32 revision; | 430 | u32 revision; |
431 | int retval; | 431 | int retval; |
432 | retval = u132_read_pcimem(u132, revision, &revision); | 432 | retval = u132_read_pcimem(u132, revision, &revision); |
433 | if (retval) { | 433 | if (retval) { |
434 | dev_err(&u132->platform_dev->dev, "error %d accessing device co" | 434 | dev_err(&u132->platform_dev->dev, "error %d accessing device co" |
435 | "ntrol\n", retval); | 435 | "ntrol\n", retval); |
436 | return retval; | 436 | return retval; |
437 | } else if ((revision & 0xFF) == 0x10) { | 437 | } else if ((revision & 0xFF) == 0x10) { |
438 | } else if ((revision & 0xFF) == 0x11) { | 438 | } else if ((revision & 0xFF) == 0x11) { |
439 | } else { | 439 | } else { |
440 | dev_err(&u132->platform_dev->dev, "device revision is not valid" | 440 | dev_err(&u132->platform_dev->dev, "device revision is not valid" |
441 | " %08X\n", revision); | 441 | " %08X\n", revision); |
442 | return -ENODEV; | 442 | return -ENODEV; |
443 | } | 443 | } |
444 | retval = u132_read_pcimem(u132, control, &u132->hc_control); | 444 | retval = u132_read_pcimem(u132, control, &u132->hc_control); |
445 | if (retval) { | 445 | if (retval) { |
446 | dev_err(&u132->platform_dev->dev, "error %d accessing device co" | 446 | dev_err(&u132->platform_dev->dev, "error %d accessing device co" |
447 | "ntrol\n", retval); | 447 | "ntrol\n", retval); |
448 | return retval; | 448 | return retval; |
449 | } | 449 | } |
450 | retval = u132_read_pcimem(u132, roothub.status, | 450 | retval = u132_read_pcimem(u132, roothub.status, |
451 | &u132->hc_roothub_status); | 451 | &u132->hc_roothub_status); |
452 | if (retval) { | 452 | if (retval) { |
453 | dev_err(&u132->platform_dev->dev, "error %d accessing device re" | 453 | dev_err(&u132->platform_dev->dev, "error %d accessing device re" |
454 | "g roothub.status\n", retval); | 454 | "g roothub.status\n", retval); |
455 | return retval; | 455 | return retval; |
456 | } | 456 | } |
457 | retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); | 457 | retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); |
458 | if (retval) { | 458 | if (retval) { |
459 | dev_err(&u132->platform_dev->dev, "error %d accessing device re" | 459 | dev_err(&u132->platform_dev->dev, "error %d accessing device re" |
460 | "g roothub.a\n", retval); | 460 | "g roothub.a\n", retval); |
461 | return retval; | 461 | return retval; |
462 | } | 462 | } |
463 | { | 463 | { |
464 | int I = u132->num_ports; | 464 | int I = u132->num_ports; |
465 | int i = 0; | 465 | int i = 0; |
466 | while (I-- > 0) { | 466 | while (I-- > 0) { |
467 | retval = u132_read_pcimem(u132, roothub.portstatus[i], | 467 | retval = u132_read_pcimem(u132, roothub.portstatus[i], |
468 | &u132->hc_roothub_portstatus[i]); | 468 | &u132->hc_roothub_portstatus[i]); |
469 | if (retval) { | 469 | if (retval) { |
470 | dev_err(&u132->platform_dev->dev, "error %d acc" | 470 | dev_err(&u132->platform_dev->dev, "error %d acc" |
471 | "essing device roothub.portstatus[%d]\n" | 471 | "essing device roothub.portstatus[%d]\n" |
472 | , retval, i); | 472 | , retval, i); |
473 | return retval; | 473 | return retval; |
474 | } else | 474 | } else |
475 | i += 1; | 475 | i += 1; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | return 0; | 478 | return 0; |
479 | } | 479 | } |
480 | 480 | ||
481 | static void u132_hcd_monitor_work(struct work_struct *work) | 481 | static void u132_hcd_monitor_work(struct work_struct *work) |
482 | { | 482 | { |
483 | struct u132 *u132 = container_of(work, struct u132, monitor.work); | 483 | struct u132 *u132 = container_of(work, struct u132, monitor.work); |
484 | if (u132->going > 1) { | 484 | if (u132->going > 1) { |
485 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 485 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
486 | , u132->going); | 486 | , u132->going); |
487 | u132_monitor_put_kref(u132); | 487 | u132_monitor_put_kref(u132); |
488 | return; | 488 | return; |
489 | } else if (u132->going > 0) { | 489 | } else if (u132->going > 0) { |
490 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 490 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
491 | u132_monitor_put_kref(u132); | 491 | u132_monitor_put_kref(u132); |
492 | return; | 492 | return; |
493 | } else { | 493 | } else { |
494 | int retval; | 494 | int retval; |
495 | mutex_lock(&u132->sw_lock); | 495 | mutex_lock(&u132->sw_lock); |
496 | retval = read_roothub_info(u132); | 496 | retval = read_roothub_info(u132); |
497 | if (retval) { | 497 | if (retval) { |
498 | struct usb_hcd *hcd = u132_to_hcd(u132); | 498 | struct usb_hcd *hcd = u132_to_hcd(u132); |
499 | u132_disable(u132); | 499 | u132_disable(u132); |
500 | u132->going = 1; | 500 | u132->going = 1; |
501 | mutex_unlock(&u132->sw_lock); | 501 | mutex_unlock(&u132->sw_lock); |
502 | usb_hc_died(hcd); | 502 | usb_hc_died(hcd); |
503 | ftdi_elan_gone_away(u132->platform_dev); | 503 | ftdi_elan_gone_away(u132->platform_dev); |
504 | u132_monitor_put_kref(u132); | 504 | u132_monitor_put_kref(u132); |
505 | return; | 505 | return; |
506 | } else { | 506 | } else { |
507 | u132_monitor_requeue_work(u132, 500); | 507 | u132_monitor_requeue_work(u132, 500); |
508 | mutex_unlock(&u132->sw_lock); | 508 | mutex_unlock(&u132->sw_lock); |
509 | return; | 509 | return; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, | 514 | static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, |
515 | struct urb *urb, int status) | 515 | struct urb *urb, int status) |
516 | { | 516 | { |
517 | struct u132_ring *ring; | 517 | struct u132_ring *ring; |
518 | unsigned long irqs; | 518 | unsigned long irqs; |
519 | struct usb_hcd *hcd = u132_to_hcd(u132); | 519 | struct usb_hcd *hcd = u132_to_hcd(u132); |
520 | urb->error_count = 0; | 520 | urb->error_count = 0; |
521 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 521 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
522 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 522 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
523 | endp->queue_next += 1; | 523 | endp->queue_next += 1; |
524 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { | 524 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { |
525 | endp->active = 0; | 525 | endp->active = 0; |
526 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 526 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
527 | } else { | 527 | } else { |
528 | struct list_head *next = endp->urb_more.next; | 528 | struct list_head *next = endp->urb_more.next; |
529 | struct u132_urbq *urbq = list_entry(next, struct u132_urbq, | 529 | struct u132_urbq *urbq = list_entry(next, struct u132_urbq, |
530 | urb_more); | 530 | urb_more); |
531 | list_del(next); | 531 | list_del(next); |
532 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = | 532 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = |
533 | urbq->urb; | 533 | urbq->urb; |
534 | endp->active = 0; | 534 | endp->active = 0; |
535 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 535 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
536 | kfree(urbq); | 536 | kfree(urbq); |
537 | } down(&u132->scheduler_lock); | 537 | } |
538 | ring = endp->ring; | 538 | mutex_lock(&u132->scheduler_lock); |
539 | ring->in_use = 0; | 539 | ring = endp->ring; |
540 | u132_ring_cancel_work(u132, ring); | 540 | ring->in_use = 0; |
541 | u132_ring_queue_work(u132, ring, 0); | 541 | u132_ring_cancel_work(u132, ring); |
542 | up(&u132->scheduler_lock); | 542 | u132_ring_queue_work(u132, ring, 0); |
543 | u132_endp_put_kref(u132, endp); | 543 | mutex_unlock(&u132->scheduler_lock); |
544 | u132_endp_put_kref(u132, endp); | ||
544 | usb_hcd_giveback_urb(hcd, urb, status); | 545 | usb_hcd_giveback_urb(hcd, urb, status); |
545 | return; | 546 | return; |
546 | } | 547 | } |
547 | 548 | ||
548 | static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp, | 549 | static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp, |
549 | struct urb *urb, int status) | 550 | struct urb *urb, int status) |
550 | { | 551 | { |
551 | u132_endp_put_kref(u132, endp); | 552 | u132_endp_put_kref(u132, endp); |
552 | } | 553 | } |
553 | 554 | ||
554 | static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, | 555 | static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, |
555 | struct urb *urb, int status) | 556 | struct urb *urb, int status) |
556 | { | 557 | { |
557 | unsigned long irqs; | 558 | unsigned long irqs; |
558 | struct usb_hcd *hcd = u132_to_hcd(u132); | 559 | struct usb_hcd *hcd = u132_to_hcd(u132); |
559 | urb->error_count = 0; | 560 | urb->error_count = 0; |
560 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 561 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
561 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 562 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
562 | endp->queue_next += 1; | 563 | endp->queue_next += 1; |
563 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { | 564 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { |
564 | endp->active = 0; | 565 | endp->active = 0; |
565 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 566 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
566 | } else { | 567 | } else { |
567 | struct list_head *next = endp->urb_more.next; | 568 | struct list_head *next = endp->urb_more.next; |
568 | struct u132_urbq *urbq = list_entry(next, struct u132_urbq, | 569 | struct u132_urbq *urbq = list_entry(next, struct u132_urbq, |
569 | urb_more); | 570 | urb_more); |
570 | list_del(next); | 571 | list_del(next); |
571 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = | 572 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = |
572 | urbq->urb; | 573 | urbq->urb; |
573 | endp->active = 0; | 574 | endp->active = 0; |
574 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 575 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
575 | kfree(urbq); | 576 | kfree(urbq); |
576 | } usb_hcd_giveback_urb(hcd, urb, status); | 577 | } usb_hcd_giveback_urb(hcd, urb, status); |
577 | return; | 578 | return; |
578 | } | 579 | } |
579 | 580 | ||
580 | static inline int edset_input(struct u132 *u132, struct u132_ring *ring, | 581 | static inline int edset_input(struct u132 *u132, struct u132_ring *ring, |
581 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | 582 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, |
582 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | 583 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, |
583 | int toggle_bits, int error_count, int condition_code, int repeat_number, | 584 | int toggle_bits, int error_count, int condition_code, int repeat_number, |
584 | int halted, int skipped, int actual, int non_null)) | 585 | int halted, int skipped, int actual, int non_null)) |
585 | { | 586 | { |
586 | return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, | 587 | return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, |
587 | urb, address, endp->usb_endp, toggle_bits, callback); | 588 | urb, address, endp->usb_endp, toggle_bits, callback); |
588 | } | 589 | } |
589 | 590 | ||
590 | static inline int edset_setup(struct u132 *u132, struct u132_ring *ring, | 591 | static inline int edset_setup(struct u132 *u132, struct u132_ring *ring, |
591 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | 592 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, |
592 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | 593 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, |
593 | int toggle_bits, int error_count, int condition_code, int repeat_number, | 594 | int toggle_bits, int error_count, int condition_code, int repeat_number, |
594 | int halted, int skipped, int actual, int non_null)) | 595 | int halted, int skipped, int actual, int non_null)) |
595 | { | 596 | { |
596 | return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, | 597 | return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, |
597 | urb, address, endp->usb_endp, toggle_bits, callback); | 598 | urb, address, endp->usb_endp, toggle_bits, callback); |
598 | } | 599 | } |
599 | 600 | ||
600 | static inline int edset_single(struct u132 *u132, struct u132_ring *ring, | 601 | static inline int edset_single(struct u132 *u132, struct u132_ring *ring, |
601 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | 602 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, |
602 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | 603 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, |
603 | int toggle_bits, int error_count, int condition_code, int repeat_number, | 604 | int toggle_bits, int error_count, int condition_code, int repeat_number, |
604 | int halted, int skipped, int actual, int non_null)) | 605 | int halted, int skipped, int actual, int non_null)) |
605 | { | 606 | { |
606 | return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, | 607 | return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, |
607 | endp, urb, address, endp->usb_endp, toggle_bits, callback); | 608 | endp, urb, address, endp->usb_endp, toggle_bits, callback); |
608 | } | 609 | } |
609 | 610 | ||
610 | static inline int edset_output(struct u132 *u132, struct u132_ring *ring, | 611 | static inline int edset_output(struct u132 *u132, struct u132_ring *ring, |
611 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | 612 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, |
612 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | 613 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, |
613 | int toggle_bits, int error_count, int condition_code, int repeat_number, | 614 | int toggle_bits, int error_count, int condition_code, int repeat_number, |
614 | int halted, int skipped, int actual, int non_null)) | 615 | int halted, int skipped, int actual, int non_null)) |
615 | { | 616 | { |
616 | return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, | 617 | return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, |
617 | endp, urb, address, endp->usb_endp, toggle_bits, callback); | 618 | endp, urb, address, endp->usb_endp, toggle_bits, callback); |
618 | } | 619 | } |
619 | 620 | ||
620 | 621 | ||
@@ -623,683 +624,678 @@ static inline int edset_output(struct u132 *u132, struct u132_ring *ring, | |||
623 | * | 624 | * |
624 | */ | 625 | */ |
625 | static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, | 626 | static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, |
626 | int len, int toggle_bits, int error_count, int condition_code, | 627 | int len, int toggle_bits, int error_count, int condition_code, |
627 | int repeat_number, int halted, int skipped, int actual, int non_null) | 628 | int repeat_number, int halted, int skipped, int actual, int non_null) |
628 | { | 629 | { |
629 | struct u132_endp *endp = data; | 630 | struct u132_endp *endp = data; |
630 | struct u132 *u132 = endp->u132; | 631 | struct u132 *u132 = endp->u132; |
631 | u8 address = u132->addr[endp->usb_addr].address; | 632 | u8 address = u132->addr[endp->usb_addr].address; |
632 | struct u132_udev *udev = &u132->udev[address]; | 633 | struct u132_udev *udev = &u132->udev[address]; |
633 | down(&u132->scheduler_lock); | 634 | mutex_lock(&u132->scheduler_lock); |
634 | if (u132->going > 1) { | 635 | if (u132->going > 1) { |
635 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 636 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
636 | , u132->going); | 637 | , u132->going); |
637 | up(&u132->scheduler_lock); | 638 | mutex_unlock(&u132->scheduler_lock); |
638 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 639 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
639 | return; | 640 | return; |
640 | } else if (endp->dequeueing) { | 641 | } else if (endp->dequeueing) { |
641 | endp->dequeueing = 0; | 642 | endp->dequeueing = 0; |
642 | up(&u132->scheduler_lock); | 643 | mutex_unlock(&u132->scheduler_lock); |
643 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 644 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
644 | return; | 645 | return; |
645 | } else if (u132->going > 0) { | 646 | } else if (u132->going > 0) { |
646 | dev_err(&u132->platform_dev->dev, "device is being removed " | 647 | dev_err(&u132->platform_dev->dev, "device is being removed " |
647 | "urb=%p\n", urb); | 648 | "urb=%p\n", urb); |
648 | up(&u132->scheduler_lock); | 649 | mutex_unlock(&u132->scheduler_lock); |
649 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 650 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
650 | return; | 651 | return; |
651 | } else if (!urb->unlinked) { | 652 | } else if (!urb->unlinked) { |
652 | struct u132_ring *ring = endp->ring; | 653 | struct u132_ring *ring = endp->ring; |
653 | u8 *u = urb->transfer_buffer + urb->actual_length; | 654 | u8 *u = urb->transfer_buffer + urb->actual_length; |
654 | u8 *b = buf; | 655 | u8 *b = buf; |
655 | int L = len; | 656 | int L = len; |
656 | while (L-- > 0) { | 657 | |
657 | *u++ = *b++; | 658 | while (L-- > 0) |
658 | } | 659 | *u++ = *b++; |
659 | urb->actual_length += len; | 660 | |
660 | if ((condition_code == TD_CC_NOERROR) && | 661 | urb->actual_length += len; |
661 | (urb->transfer_buffer_length > urb->actual_length)) { | 662 | if ((condition_code == TD_CC_NOERROR) && |
662 | endp->toggle_bits = toggle_bits; | 663 | (urb->transfer_buffer_length > urb->actual_length)) { |
663 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | 664 | endp->toggle_bits = toggle_bits; |
664 | 1 & toggle_bits); | 665 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, |
665 | if (urb->actual_length > 0) { | 666 | 1 & toggle_bits); |
666 | int retval; | 667 | if (urb->actual_length > 0) { |
667 | up(&u132->scheduler_lock); | 668 | int retval; |
668 | retval = edset_single(u132, ring, endp, urb, | 669 | mutex_unlock(&u132->scheduler_lock); |
669 | address, endp->toggle_bits, | 670 | retval = edset_single(u132, ring, endp, urb, |
670 | u132_hcd_interrupt_recv); | 671 | address, endp->toggle_bits, |
671 | if (retval == 0) { | 672 | u132_hcd_interrupt_recv); |
672 | } else | 673 | if (retval != 0) |
673 | u132_hcd_giveback_urb(u132, endp, urb, | 674 | u132_hcd_giveback_urb(u132, endp, urb, |
674 | retval); | 675 | retval); |
675 | } else { | 676 | } else { |
676 | ring->in_use = 0; | 677 | ring->in_use = 0; |
677 | endp->active = 0; | 678 | endp->active = 0; |
678 | endp->jiffies = jiffies + | 679 | endp->jiffies = jiffies + |
679 | msecs_to_jiffies(urb->interval); | 680 | msecs_to_jiffies(urb->interval); |
680 | u132_ring_cancel_work(u132, ring); | 681 | u132_ring_cancel_work(u132, ring); |
681 | u132_ring_queue_work(u132, ring, 0); | 682 | u132_ring_queue_work(u132, ring, 0); |
682 | up(&u132->scheduler_lock); | 683 | mutex_unlock(&u132->scheduler_lock); |
683 | u132_endp_put_kref(u132, endp); | 684 | u132_endp_put_kref(u132, endp); |
684 | } | 685 | } |
685 | return; | 686 | return; |
686 | } else if ((condition_code == TD_DATAUNDERRUN) && | 687 | } else if ((condition_code == TD_DATAUNDERRUN) && |
687 | ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { | 688 | ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { |
688 | endp->toggle_bits = toggle_bits; | 689 | endp->toggle_bits = toggle_bits; |
689 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | 690 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, |
690 | 1 & toggle_bits); | 691 | 1 & toggle_bits); |
691 | up(&u132->scheduler_lock); | 692 | mutex_unlock(&u132->scheduler_lock); |
692 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 693 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
693 | return; | 694 | return; |
694 | } else { | 695 | } else { |
695 | if (condition_code == TD_CC_NOERROR) { | 696 | if (condition_code == TD_CC_NOERROR) { |
696 | endp->toggle_bits = toggle_bits; | 697 | endp->toggle_bits = toggle_bits; |
697 | usb_settoggle(udev->usb_device, endp->usb_endp, | 698 | usb_settoggle(udev->usb_device, endp->usb_endp, |
698 | 0, 1 & toggle_bits); | 699 | 0, 1 & toggle_bits); |
699 | } else if (condition_code == TD_CC_STALL) { | 700 | } else if (condition_code == TD_CC_STALL) { |
700 | endp->toggle_bits = 0x2; | 701 | endp->toggle_bits = 0x2; |
701 | usb_settoggle(udev->usb_device, endp->usb_endp, | 702 | usb_settoggle(udev->usb_device, endp->usb_endp, |
702 | 0, 0); | 703 | 0, 0); |
703 | } else { | 704 | } else { |
704 | endp->toggle_bits = 0x2; | 705 | endp->toggle_bits = 0x2; |
705 | usb_settoggle(udev->usb_device, endp->usb_endp, | 706 | usb_settoggle(udev->usb_device, endp->usb_endp, |
706 | 0, 0); | 707 | 0, 0); |
707 | dev_err(&u132->platform_dev->dev, "urb=%p givin" | 708 | dev_err(&u132->platform_dev->dev, "urb=%p givin" |
708 | "g back INTERRUPT %s\n", urb, | 709 | "g back INTERRUPT %s\n", urb, |
709 | cc_to_text[condition_code]); | 710 | cc_to_text[condition_code]); |
710 | } | 711 | } |
711 | up(&u132->scheduler_lock); | 712 | mutex_unlock(&u132->scheduler_lock); |
712 | u132_hcd_giveback_urb(u132, endp, urb, | 713 | u132_hcd_giveback_urb(u132, endp, urb, |
713 | cc_to_error[condition_code]); | 714 | cc_to_error[condition_code]); |
714 | return; | 715 | return; |
715 | } | 716 | } |
716 | } else { | 717 | } else { |
717 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 718 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
718 | "unlinked=%d\n", urb, urb->unlinked); | 719 | "unlinked=%d\n", urb, urb->unlinked); |
719 | up(&u132->scheduler_lock); | 720 | mutex_unlock(&u132->scheduler_lock); |
720 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 721 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
721 | return; | 722 | return; |
722 | } | 723 | } |
723 | } | 724 | } |
724 | 725 | ||
725 | static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, | 726 | static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, |
726 | int len, int toggle_bits, int error_count, int condition_code, | 727 | int len, int toggle_bits, int error_count, int condition_code, |
727 | int repeat_number, int halted, int skipped, int actual, int non_null) | 728 | int repeat_number, int halted, int skipped, int actual, int non_null) |
728 | { | 729 | { |
729 | struct u132_endp *endp = data; | 730 | struct u132_endp *endp = data; |
730 | struct u132 *u132 = endp->u132; | 731 | struct u132 *u132 = endp->u132; |
731 | u8 address = u132->addr[endp->usb_addr].address; | 732 | u8 address = u132->addr[endp->usb_addr].address; |
732 | down(&u132->scheduler_lock); | 733 | mutex_lock(&u132->scheduler_lock); |
733 | if (u132->going > 1) { | 734 | if (u132->going > 1) { |
734 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 735 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
735 | , u132->going); | 736 | , u132->going); |
736 | up(&u132->scheduler_lock); | 737 | mutex_unlock(&u132->scheduler_lock); |
737 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 738 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
738 | return; | 739 | return; |
739 | } else if (endp->dequeueing) { | 740 | } else if (endp->dequeueing) { |
740 | endp->dequeueing = 0; | 741 | endp->dequeueing = 0; |
741 | up(&u132->scheduler_lock); | 742 | mutex_unlock(&u132->scheduler_lock); |
742 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 743 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
743 | return; | 744 | return; |
744 | } else if (u132->going > 0) { | 745 | } else if (u132->going > 0) { |
745 | dev_err(&u132->platform_dev->dev, "device is being removed " | 746 | dev_err(&u132->platform_dev->dev, "device is being removed " |
746 | "urb=%p\n", urb); | 747 | "urb=%p\n", urb); |
747 | up(&u132->scheduler_lock); | 748 | mutex_unlock(&u132->scheduler_lock); |
748 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 749 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
749 | return; | 750 | return; |
750 | } else if (!urb->unlinked) { | 751 | } else if (!urb->unlinked) { |
751 | struct u132_ring *ring = endp->ring; | 752 | struct u132_ring *ring = endp->ring; |
752 | urb->actual_length += len; | 753 | urb->actual_length += len; |
753 | endp->toggle_bits = toggle_bits; | 754 | endp->toggle_bits = toggle_bits; |
754 | if (urb->transfer_buffer_length > urb->actual_length) { | 755 | if (urb->transfer_buffer_length > urb->actual_length) { |
755 | int retval; | 756 | int retval; |
756 | up(&u132->scheduler_lock); | 757 | mutex_unlock(&u132->scheduler_lock); |
757 | retval = edset_output(u132, ring, endp, urb, address, | 758 | retval = edset_output(u132, ring, endp, urb, address, |
758 | endp->toggle_bits, u132_hcd_bulk_output_sent); | 759 | endp->toggle_bits, u132_hcd_bulk_output_sent); |
759 | if (retval == 0) { | 760 | if (retval != 0) |
760 | } else | 761 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
761 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 762 | return; |
762 | return; | 763 | } else { |
763 | } else { | 764 | mutex_unlock(&u132->scheduler_lock); |
764 | up(&u132->scheduler_lock); | 765 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
765 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 766 | return; |
766 | return; | 767 | } |
767 | } | 768 | } else { |
768 | } else { | ||
769 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 769 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
770 | "unlinked=%d\n", urb, urb->unlinked); | 770 | "unlinked=%d\n", urb, urb->unlinked); |
771 | up(&u132->scheduler_lock); | 771 | mutex_unlock(&u132->scheduler_lock); |
772 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 772 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
773 | return; | 773 | return; |
774 | } | 774 | } |
775 | } | 775 | } |
776 | 776 | ||
777 | static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, | 777 | static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, |
778 | int len, int toggle_bits, int error_count, int condition_code, | 778 | int len, int toggle_bits, int error_count, int condition_code, |
779 | int repeat_number, int halted, int skipped, int actual, int non_null) | 779 | int repeat_number, int halted, int skipped, int actual, int non_null) |
780 | { | 780 | { |
781 | struct u132_endp *endp = data; | 781 | struct u132_endp *endp = data; |
782 | struct u132 *u132 = endp->u132; | 782 | struct u132 *u132 = endp->u132; |
783 | u8 address = u132->addr[endp->usb_addr].address; | 783 | u8 address = u132->addr[endp->usb_addr].address; |
784 | struct u132_udev *udev = &u132->udev[address]; | 784 | struct u132_udev *udev = &u132->udev[address]; |
785 | down(&u132->scheduler_lock); | 785 | mutex_lock(&u132->scheduler_lock); |
786 | if (u132->going > 1) { | 786 | if (u132->going > 1) { |
787 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 787 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
788 | , u132->going); | 788 | , u132->going); |
789 | up(&u132->scheduler_lock); | 789 | mutex_unlock(&u132->scheduler_lock); |
790 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 790 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
791 | return; | 791 | return; |
792 | } else if (endp->dequeueing) { | 792 | } else if (endp->dequeueing) { |
793 | endp->dequeueing = 0; | 793 | endp->dequeueing = 0; |
794 | up(&u132->scheduler_lock); | 794 | mutex_unlock(&u132->scheduler_lock); |
795 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 795 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
796 | return; | 796 | return; |
797 | } else if (u132->going > 0) { | 797 | } else if (u132->going > 0) { |
798 | dev_err(&u132->platform_dev->dev, "device is being removed " | 798 | dev_err(&u132->platform_dev->dev, "device is being removed " |
799 | "urb=%p\n", urb); | 799 | "urb=%p\n", urb); |
800 | up(&u132->scheduler_lock); | 800 | mutex_unlock(&u132->scheduler_lock); |
801 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 801 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
802 | return; | 802 | return; |
803 | } else if (!urb->unlinked) { | 803 | } else if (!urb->unlinked) { |
804 | struct u132_ring *ring = endp->ring; | 804 | struct u132_ring *ring = endp->ring; |
805 | u8 *u = urb->transfer_buffer + urb->actual_length; | 805 | u8 *u = urb->transfer_buffer + urb->actual_length; |
806 | u8 *b = buf; | 806 | u8 *b = buf; |
807 | int L = len; | 807 | int L = len; |
808 | while (L-- > 0) { | 808 | |
809 | *u++ = *b++; | 809 | while (L-- > 0) |
810 | } | 810 | *u++ = *b++; |
811 | urb->actual_length += len; | 811 | |
812 | if ((condition_code == TD_CC_NOERROR) && | 812 | urb->actual_length += len; |
813 | (urb->transfer_buffer_length > urb->actual_length)) { | 813 | if ((condition_code == TD_CC_NOERROR) && |
814 | int retval; | 814 | (urb->transfer_buffer_length > urb->actual_length)) { |
815 | endp->toggle_bits = toggle_bits; | 815 | int retval; |
816 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | 816 | endp->toggle_bits = toggle_bits; |
817 | 1 & toggle_bits); | 817 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, |
818 | up(&u132->scheduler_lock); | 818 | 1 & toggle_bits); |
819 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | 819 | mutex_unlock(&u132->scheduler_lock); |
820 | ring->number, endp, urb, address, | 820 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, |
821 | endp->usb_endp, endp->toggle_bits, | 821 | ring->number, endp, urb, address, |
822 | u132_hcd_bulk_input_recv); | 822 | endp->usb_endp, endp->toggle_bits, |
823 | if (retval == 0) { | 823 | u132_hcd_bulk_input_recv); |
824 | } else | 824 | if (retval != 0) |
825 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 825 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
826 | return; | 826 | return; |
827 | } else if (condition_code == TD_CC_NOERROR) { | 827 | } else if (condition_code == TD_CC_NOERROR) { |
828 | endp->toggle_bits = toggle_bits; | 828 | endp->toggle_bits = toggle_bits; |
829 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | 829 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, |
830 | 1 & toggle_bits); | 830 | 1 & toggle_bits); |
831 | up(&u132->scheduler_lock); | 831 | mutex_unlock(&u132->scheduler_lock); |
832 | u132_hcd_giveback_urb(u132, endp, urb, | 832 | u132_hcd_giveback_urb(u132, endp, urb, |
833 | cc_to_error[condition_code]); | 833 | cc_to_error[condition_code]); |
834 | return; | 834 | return; |
835 | } else if ((condition_code == TD_DATAUNDERRUN) && | 835 | } else if ((condition_code == TD_DATAUNDERRUN) && |
836 | ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { | 836 | ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { |
837 | endp->toggle_bits = toggle_bits; | 837 | endp->toggle_bits = toggle_bits; |
838 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | 838 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, |
839 | 1 & toggle_bits); | 839 | 1 & toggle_bits); |
840 | up(&u132->scheduler_lock); | 840 | mutex_unlock(&u132->scheduler_lock); |
841 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 841 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
842 | return; | 842 | return; |
843 | } else if (condition_code == TD_DATAUNDERRUN) { | 843 | } else if (condition_code == TD_DATAUNDERRUN) { |
844 | endp->toggle_bits = toggle_bits; | 844 | endp->toggle_bits = toggle_bits; |
845 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | 845 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, |
846 | 1 & toggle_bits); | 846 | 1 & toggle_bits); |
847 | dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" | 847 | dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" |
848 | ") giving back BULK IN %s\n", urb, | 848 | ") giving back BULK IN %s\n", urb, |
849 | cc_to_text[condition_code]); | 849 | cc_to_text[condition_code]); |
850 | up(&u132->scheduler_lock); | 850 | mutex_unlock(&u132->scheduler_lock); |
851 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 851 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
852 | return; | 852 | return; |
853 | } else if (condition_code == TD_CC_STALL) { | 853 | } else if (condition_code == TD_CC_STALL) { |
854 | endp->toggle_bits = 0x2; | 854 | endp->toggle_bits = 0x2; |
855 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); | 855 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); |
856 | up(&u132->scheduler_lock); | 856 | mutex_unlock(&u132->scheduler_lock); |
857 | u132_hcd_giveback_urb(u132, endp, urb, | 857 | u132_hcd_giveback_urb(u132, endp, urb, |
858 | cc_to_error[condition_code]); | 858 | cc_to_error[condition_code]); |
859 | return; | 859 | return; |
860 | } else { | 860 | } else { |
861 | endp->toggle_bits = 0x2; | 861 | endp->toggle_bits = 0x2; |
862 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); | 862 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); |
863 | dev_err(&u132->platform_dev->dev, "urb=%p giving back B" | 863 | dev_err(&u132->platform_dev->dev, "urb=%p giving back B" |
864 | "ULK IN code=%d %s\n", urb, condition_code, | 864 | "ULK IN code=%d %s\n", urb, condition_code, |
865 | cc_to_text[condition_code]); | 865 | cc_to_text[condition_code]); |
866 | up(&u132->scheduler_lock); | 866 | mutex_unlock(&u132->scheduler_lock); |
867 | u132_hcd_giveback_urb(u132, endp, urb, | 867 | u132_hcd_giveback_urb(u132, endp, urb, |
868 | cc_to_error[condition_code]); | 868 | cc_to_error[condition_code]); |
869 | return; | 869 | return; |
870 | } | 870 | } |
871 | } else { | 871 | } else { |
872 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 872 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
873 | "unlinked=%d\n", urb, urb->unlinked); | 873 | "unlinked=%d\n", urb, urb->unlinked); |
874 | up(&u132->scheduler_lock); | 874 | mutex_unlock(&u132->scheduler_lock); |
875 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 875 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
876 | return; | 876 | return; |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, | 880 | static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, |
881 | int len, int toggle_bits, int error_count, int condition_code, | 881 | int len, int toggle_bits, int error_count, int condition_code, |
882 | int repeat_number, int halted, int skipped, int actual, int non_null) | 882 | int repeat_number, int halted, int skipped, int actual, int non_null) |
883 | { | 883 | { |
884 | struct u132_endp *endp = data; | 884 | struct u132_endp *endp = data; |
885 | struct u132 *u132 = endp->u132; | 885 | struct u132 *u132 = endp->u132; |
886 | down(&u132->scheduler_lock); | 886 | mutex_lock(&u132->scheduler_lock); |
887 | if (u132->going > 1) { | 887 | if (u132->going > 1) { |
888 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 888 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
889 | , u132->going); | 889 | , u132->going); |
890 | up(&u132->scheduler_lock); | 890 | mutex_unlock(&u132->scheduler_lock); |
891 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 891 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
892 | return; | 892 | return; |
893 | } else if (endp->dequeueing) { | 893 | } else if (endp->dequeueing) { |
894 | endp->dequeueing = 0; | 894 | endp->dequeueing = 0; |
895 | up(&u132->scheduler_lock); | 895 | mutex_unlock(&u132->scheduler_lock); |
896 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 896 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
897 | return; | 897 | return; |
898 | } else if (u132->going > 0) { | 898 | } else if (u132->going > 0) { |
899 | dev_err(&u132->platform_dev->dev, "device is being removed " | 899 | dev_err(&u132->platform_dev->dev, "device is being removed " |
900 | "urb=%p\n", urb); | 900 | "urb=%p\n", urb); |
901 | up(&u132->scheduler_lock); | 901 | mutex_unlock(&u132->scheduler_lock); |
902 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 902 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
903 | return; | 903 | return; |
904 | } else if (!urb->unlinked) { | 904 | } else if (!urb->unlinked) { |
905 | up(&u132->scheduler_lock); | 905 | mutex_unlock(&u132->scheduler_lock); |
906 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 906 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
907 | return; | 907 | return; |
908 | } else { | 908 | } else { |
909 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 909 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
910 | "unlinked=%d\n", urb, urb->unlinked); | 910 | "unlinked=%d\n", urb, urb->unlinked); |
911 | up(&u132->scheduler_lock); | 911 | mutex_unlock(&u132->scheduler_lock); |
912 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 912 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
913 | return; | 913 | return; |
914 | } | 914 | } |
915 | } | 915 | } |
916 | 916 | ||
917 | static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, | 917 | static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, |
918 | int len, int toggle_bits, int error_count, int condition_code, | 918 | int len, int toggle_bits, int error_count, int condition_code, |
919 | int repeat_number, int halted, int skipped, int actual, int non_null) | 919 | int repeat_number, int halted, int skipped, int actual, int non_null) |
920 | { | 920 | { |
921 | struct u132_endp *endp = data; | 921 | struct u132_endp *endp = data; |
922 | struct u132 *u132 = endp->u132; | 922 | struct u132 *u132 = endp->u132; |
923 | u8 address = u132->addr[endp->usb_addr].address; | 923 | u8 address = u132->addr[endp->usb_addr].address; |
924 | down(&u132->scheduler_lock); | 924 | mutex_lock(&u132->scheduler_lock); |
925 | if (u132->going > 1) { | 925 | if (u132->going > 1) { |
926 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 926 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
927 | , u132->going); | 927 | , u132->going); |
928 | up(&u132->scheduler_lock); | 928 | mutex_unlock(&u132->scheduler_lock); |
929 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 929 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
930 | return; | 930 | return; |
931 | } else if (endp->dequeueing) { | 931 | } else if (endp->dequeueing) { |
932 | endp->dequeueing = 0; | 932 | endp->dequeueing = 0; |
933 | up(&u132->scheduler_lock); | 933 | mutex_unlock(&u132->scheduler_lock); |
934 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 934 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
935 | return; | 935 | return; |
936 | } else if (u132->going > 0) { | 936 | } else if (u132->going > 0) { |
937 | dev_err(&u132->platform_dev->dev, "device is being removed " | 937 | dev_err(&u132->platform_dev->dev, "device is being removed " |
938 | "urb=%p\n", urb); | 938 | "urb=%p\n", urb); |
939 | up(&u132->scheduler_lock); | 939 | mutex_unlock(&u132->scheduler_lock); |
940 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 940 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
941 | return; | 941 | return; |
942 | } else if (!urb->unlinked) { | 942 | } else if (!urb->unlinked) { |
943 | struct u132_ring *ring = endp->ring; | 943 | struct u132_ring *ring = endp->ring; |
944 | u8 *u = urb->transfer_buffer; | 944 | u8 *u = urb->transfer_buffer; |
945 | u8 *b = buf; | 945 | u8 *b = buf; |
946 | int L = len; | 946 | int L = len; |
947 | while (L-- > 0) { | 947 | |
948 | *u++ = *b++; | 948 | while (L-- > 0) |
949 | } | 949 | *u++ = *b++; |
950 | urb->actual_length = len; | 950 | |
951 | if ((condition_code == TD_CC_NOERROR) || ((condition_code == | 951 | urb->actual_length = len; |
952 | TD_DATAUNDERRUN) && ((urb->transfer_flags & | 952 | if ((condition_code == TD_CC_NOERROR) || ((condition_code == |
953 | URB_SHORT_NOT_OK) == 0))) { | 953 | TD_DATAUNDERRUN) && ((urb->transfer_flags & |
954 | int retval; | 954 | URB_SHORT_NOT_OK) == 0))) { |
955 | up(&u132->scheduler_lock); | 955 | int retval; |
956 | retval = usb_ftdi_elan_edset_empty(u132->platform_dev, | 956 | mutex_unlock(&u132->scheduler_lock); |
957 | ring->number, endp, urb, address, | 957 | retval = usb_ftdi_elan_edset_empty(u132->platform_dev, |
958 | endp->usb_endp, 0x3, | 958 | ring->number, endp, urb, address, |
959 | u132_hcd_configure_empty_sent); | 959 | endp->usb_endp, 0x3, |
960 | if (retval == 0) { | 960 | u132_hcd_configure_empty_sent); |
961 | } else | 961 | if (retval != 0) |
962 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 962 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
963 | return; | 963 | return; |
964 | } else if (condition_code == TD_CC_STALL) { | 964 | } else if (condition_code == TD_CC_STALL) { |
965 | up(&u132->scheduler_lock); | 965 | mutex_unlock(&u132->scheduler_lock); |
966 | dev_warn(&u132->platform_dev->dev, "giving back SETUP I" | 966 | dev_warn(&u132->platform_dev->dev, "giving back SETUP I" |
967 | "NPUT STALL urb %p\n", urb); | 967 | "NPUT STALL urb %p\n", urb); |
968 | u132_hcd_giveback_urb(u132, endp, urb, | 968 | u132_hcd_giveback_urb(u132, endp, urb, |
969 | cc_to_error[condition_code]); | 969 | cc_to_error[condition_code]); |
970 | return; | 970 | return; |
971 | } else { | 971 | } else { |
972 | up(&u132->scheduler_lock); | 972 | mutex_unlock(&u132->scheduler_lock); |
973 | dev_err(&u132->platform_dev->dev, "giving back SETUP IN" | 973 | dev_err(&u132->platform_dev->dev, "giving back SETUP IN" |
974 | "PUT %s urb %p\n", cc_to_text[condition_code], | 974 | "PUT %s urb %p\n", cc_to_text[condition_code], |
975 | urb); | 975 | urb); |
976 | u132_hcd_giveback_urb(u132, endp, urb, | 976 | u132_hcd_giveback_urb(u132, endp, urb, |
977 | cc_to_error[condition_code]); | 977 | cc_to_error[condition_code]); |
978 | return; | 978 | return; |
979 | } | 979 | } |
980 | } else { | 980 | } else { |
981 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 981 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
982 | "unlinked=%d\n", urb, urb->unlinked); | 982 | "unlinked=%d\n", urb, urb->unlinked); |
983 | up(&u132->scheduler_lock); | 983 | mutex_unlock(&u132->scheduler_lock); |
984 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 984 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
985 | return; | 985 | return; |
986 | } | 986 | } |
987 | } | 987 | } |
988 | 988 | ||
989 | static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, | 989 | static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, |
990 | int len, int toggle_bits, int error_count, int condition_code, | 990 | int len, int toggle_bits, int error_count, int condition_code, |
991 | int repeat_number, int halted, int skipped, int actual, int non_null) | 991 | int repeat_number, int halted, int skipped, int actual, int non_null) |
992 | { | 992 | { |
993 | struct u132_endp *endp = data; | 993 | struct u132_endp *endp = data; |
994 | struct u132 *u132 = endp->u132; | 994 | struct u132 *u132 = endp->u132; |
995 | down(&u132->scheduler_lock); | 995 | mutex_lock(&u132->scheduler_lock); |
996 | if (u132->going > 1) { | 996 | if (u132->going > 1) { |
997 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 997 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
998 | , u132->going); | 998 | , u132->going); |
999 | up(&u132->scheduler_lock); | 999 | mutex_unlock(&u132->scheduler_lock); |
1000 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 1000 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
1001 | return; | 1001 | return; |
1002 | } else if (endp->dequeueing) { | 1002 | } else if (endp->dequeueing) { |
1003 | endp->dequeueing = 0; | 1003 | endp->dequeueing = 0; |
1004 | up(&u132->scheduler_lock); | 1004 | mutex_unlock(&u132->scheduler_lock); |
1005 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1005 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1006 | return; | 1006 | return; |
1007 | } else if (u132->going > 0) { | 1007 | } else if (u132->going > 0) { |
1008 | dev_err(&u132->platform_dev->dev, "device is being removed " | 1008 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1009 | "urb=%p\n", urb); | 1009 | "urb=%p\n", urb); |
1010 | up(&u132->scheduler_lock); | 1010 | mutex_unlock(&u132->scheduler_lock); |
1011 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1011 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1012 | return; | 1012 | return; |
1013 | } else if (!urb->unlinked) { | 1013 | } else if (!urb->unlinked) { |
1014 | up(&u132->scheduler_lock); | 1014 | mutex_unlock(&u132->scheduler_lock); |
1015 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1015 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1016 | return; | 1016 | return; |
1017 | } else { | 1017 | } else { |
1018 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 1018 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1019 | "unlinked=%d\n", urb, urb->unlinked); | 1019 | "unlinked=%d\n", urb, urb->unlinked); |
1020 | up(&u132->scheduler_lock); | 1020 | mutex_unlock(&u132->scheduler_lock); |
1021 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1021 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1022 | return; | 1022 | return; |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, | 1026 | static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, |
1027 | int len, int toggle_bits, int error_count, int condition_code, | 1027 | int len, int toggle_bits, int error_count, int condition_code, |
1028 | int repeat_number, int halted, int skipped, int actual, int non_null) | 1028 | int repeat_number, int halted, int skipped, int actual, int non_null) |
1029 | { | 1029 | { |
1030 | struct u132_endp *endp = data; | 1030 | struct u132_endp *endp = data; |
1031 | struct u132 *u132 = endp->u132; | 1031 | struct u132 *u132 = endp->u132; |
1032 | u8 address = u132->addr[endp->usb_addr].address; | 1032 | u8 address = u132->addr[endp->usb_addr].address; |
1033 | down(&u132->scheduler_lock); | 1033 | mutex_lock(&u132->scheduler_lock); |
1034 | if (u132->going > 1) { | 1034 | if (u132->going > 1) { |
1035 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1035 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1036 | , u132->going); | 1036 | , u132->going); |
1037 | up(&u132->scheduler_lock); | 1037 | mutex_unlock(&u132->scheduler_lock); |
1038 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 1038 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
1039 | return; | 1039 | return; |
1040 | } else if (endp->dequeueing) { | 1040 | } else if (endp->dequeueing) { |
1041 | endp->dequeueing = 0; | 1041 | endp->dequeueing = 0; |
1042 | up(&u132->scheduler_lock); | 1042 | mutex_unlock(&u132->scheduler_lock); |
1043 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1043 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1044 | return; | 1044 | return; |
1045 | } else if (u132->going > 0) { | 1045 | } else if (u132->going > 0) { |
1046 | dev_err(&u132->platform_dev->dev, "device is being removed " | 1046 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1047 | "urb=%p\n", urb); | 1047 | "urb=%p\n", urb); |
1048 | up(&u132->scheduler_lock); | 1048 | mutex_unlock(&u132->scheduler_lock); |
1049 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1049 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1050 | return; | 1050 | return; |
1051 | } else if (!urb->unlinked) { | 1051 | } else if (!urb->unlinked) { |
1052 | if (usb_pipein(urb->pipe)) { | 1052 | if (usb_pipein(urb->pipe)) { |
1053 | int retval; | 1053 | int retval; |
1054 | struct u132_ring *ring = endp->ring; | 1054 | struct u132_ring *ring = endp->ring; |
1055 | up(&u132->scheduler_lock); | 1055 | mutex_unlock(&u132->scheduler_lock); |
1056 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | 1056 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, |
1057 | ring->number, endp, urb, address, | 1057 | ring->number, endp, urb, address, |
1058 | endp->usb_endp, 0, | 1058 | endp->usb_endp, 0, |
1059 | u132_hcd_configure_input_recv); | 1059 | u132_hcd_configure_input_recv); |
1060 | if (retval == 0) { | 1060 | if (retval != 0) |
1061 | } else | 1061 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1062 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1062 | return; |
1063 | return; | 1063 | } else { |
1064 | } else { | 1064 | int retval; |
1065 | int retval; | 1065 | struct u132_ring *ring = endp->ring; |
1066 | struct u132_ring *ring = endp->ring; | 1066 | mutex_unlock(&u132->scheduler_lock); |
1067 | up(&u132->scheduler_lock); | 1067 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, |
1068 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | 1068 | ring->number, endp, urb, address, |
1069 | ring->number, endp, urb, address, | 1069 | endp->usb_endp, 0, |
1070 | endp->usb_endp, 0, | 1070 | u132_hcd_configure_empty_recv); |
1071 | u132_hcd_configure_empty_recv); | 1071 | if (retval != 0) |
1072 | if (retval == 0) { | 1072 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1073 | } else | 1073 | return; |
1074 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1074 | } |
1075 | return; | 1075 | } else { |
1076 | } | ||
1077 | } else { | ||
1078 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 1076 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1079 | "unlinked=%d\n", urb, urb->unlinked); | 1077 | "unlinked=%d\n", urb, urb->unlinked); |
1080 | up(&u132->scheduler_lock); | 1078 | mutex_unlock(&u132->scheduler_lock); |
1081 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1079 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1082 | return; | 1080 | return; |
1083 | } | 1081 | } |
1084 | } | 1082 | } |
1085 | 1083 | ||
1086 | static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, | 1084 | static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, |
1087 | u8 *buf, int len, int toggle_bits, int error_count, int condition_code, | 1085 | u8 *buf, int len, int toggle_bits, int error_count, int condition_code, |
1088 | int repeat_number, int halted, int skipped, int actual, int non_null) | 1086 | int repeat_number, int halted, int skipped, int actual, int non_null) |
1089 | { | 1087 | { |
1090 | struct u132_endp *endp = data; | 1088 | struct u132_endp *endp = data; |
1091 | struct u132 *u132 = endp->u132; | 1089 | struct u132 *u132 = endp->u132; |
1092 | u8 address = u132->addr[endp->usb_addr].address; | 1090 | u8 address = u132->addr[endp->usb_addr].address; |
1093 | struct u132_udev *udev = &u132->udev[address]; | 1091 | struct u132_udev *udev = &u132->udev[address]; |
1094 | down(&u132->scheduler_lock); | 1092 | mutex_lock(&u132->scheduler_lock); |
1095 | if (u132->going > 1) { | 1093 | if (u132->going > 1) { |
1096 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1094 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1097 | , u132->going); | 1095 | , u132->going); |
1098 | up(&u132->scheduler_lock); | 1096 | mutex_unlock(&u132->scheduler_lock); |
1099 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 1097 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
1100 | return; | 1098 | return; |
1101 | } else if (endp->dequeueing) { | 1099 | } else if (endp->dequeueing) { |
1102 | endp->dequeueing = 0; | 1100 | endp->dequeueing = 0; |
1103 | up(&u132->scheduler_lock); | 1101 | mutex_unlock(&u132->scheduler_lock); |
1104 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1102 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1105 | return; | 1103 | return; |
1106 | } else if (u132->going > 0) { | 1104 | } else if (u132->going > 0) { |
1107 | dev_err(&u132->platform_dev->dev, "device is being removed " | 1105 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1108 | "urb=%p\n", urb); | 1106 | "urb=%p\n", urb); |
1109 | up(&u132->scheduler_lock); | 1107 | mutex_unlock(&u132->scheduler_lock); |
1110 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1108 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1111 | return; | 1109 | return; |
1112 | } else if (!urb->unlinked) { | 1110 | } else if (!urb->unlinked) { |
1113 | u132->addr[0].address = 0; | 1111 | u132->addr[0].address = 0; |
1114 | endp->usb_addr = udev->usb_addr; | 1112 | endp->usb_addr = udev->usb_addr; |
1115 | up(&u132->scheduler_lock); | 1113 | mutex_unlock(&u132->scheduler_lock); |
1116 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1114 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1117 | return; | 1115 | return; |
1118 | } else { | 1116 | } else { |
1119 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 1117 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1120 | "unlinked=%d\n", urb, urb->unlinked); | 1118 | "unlinked=%d\n", urb, urb->unlinked); |
1121 | up(&u132->scheduler_lock); | 1119 | mutex_unlock(&u132->scheduler_lock); |
1122 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1120 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1123 | return; | 1121 | return; |
1124 | } | 1122 | } |
1125 | } | 1123 | } |
1126 | 1124 | ||
1127 | static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, | 1125 | static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, |
1128 | u8 *buf, int len, int toggle_bits, int error_count, int condition_code, | 1126 | u8 *buf, int len, int toggle_bits, int error_count, int condition_code, |
1129 | int repeat_number, int halted, int skipped, int actual, int non_null) | 1127 | int repeat_number, int halted, int skipped, int actual, int non_null) |
1130 | { | 1128 | { |
1131 | struct u132_endp *endp = data; | 1129 | struct u132_endp *endp = data; |
1132 | struct u132 *u132 = endp->u132; | 1130 | struct u132 *u132 = endp->u132; |
1133 | down(&u132->scheduler_lock); | 1131 | mutex_lock(&u132->scheduler_lock); |
1134 | if (u132->going > 1) { | 1132 | if (u132->going > 1) { |
1135 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1133 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1136 | , u132->going); | 1134 | , u132->going); |
1137 | up(&u132->scheduler_lock); | 1135 | mutex_unlock(&u132->scheduler_lock); |
1138 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 1136 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
1139 | return; | 1137 | return; |
1140 | } else if (endp->dequeueing) { | 1138 | } else if (endp->dequeueing) { |
1141 | endp->dequeueing = 0; | 1139 | endp->dequeueing = 0; |
1142 | up(&u132->scheduler_lock); | 1140 | mutex_unlock(&u132->scheduler_lock); |
1143 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1141 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1144 | return; | 1142 | return; |
1145 | } else if (u132->going > 0) { | 1143 | } else if (u132->going > 0) { |
1146 | dev_err(&u132->platform_dev->dev, "device is being removed " | 1144 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1147 | "urb=%p\n", urb); | 1145 | "urb=%p\n", urb); |
1148 | up(&u132->scheduler_lock); | 1146 | mutex_unlock(&u132->scheduler_lock); |
1149 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1147 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1150 | return; | 1148 | return; |
1151 | } else if (!urb->unlinked) { | 1149 | } else if (!urb->unlinked) { |
1152 | int retval; | 1150 | int retval; |
1153 | struct u132_ring *ring = endp->ring; | 1151 | struct u132_ring *ring = endp->ring; |
1154 | up(&u132->scheduler_lock); | 1152 | mutex_unlock(&u132->scheduler_lock); |
1155 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | 1153 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, |
1156 | ring->number, endp, urb, 0, endp->usb_endp, 0, | 1154 | ring->number, endp, urb, 0, endp->usb_endp, 0, |
1157 | u132_hcd_enumeration_empty_recv); | 1155 | u132_hcd_enumeration_empty_recv); |
1158 | if (retval == 0) { | 1156 | if (retval != 0) |
1159 | } else | 1157 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1160 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1158 | return; |
1161 | return; | 1159 | } else { |
1162 | } else { | ||
1163 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 1160 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1164 | "unlinked=%d\n", urb, urb->unlinked); | 1161 | "unlinked=%d\n", urb, urb->unlinked); |
1165 | up(&u132->scheduler_lock); | 1162 | mutex_unlock(&u132->scheduler_lock); |
1166 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1163 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1167 | return; | 1164 | return; |
1168 | } | 1165 | } |
1169 | } | 1166 | } |
1170 | 1167 | ||
1171 | static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, | 1168 | static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, |
1172 | int len, int toggle_bits, int error_count, int condition_code, | 1169 | int len, int toggle_bits, int error_count, int condition_code, |
1173 | int repeat_number, int halted, int skipped, int actual, int non_null) | 1170 | int repeat_number, int halted, int skipped, int actual, int non_null) |
1174 | { | 1171 | { |
1175 | struct u132_endp *endp = data; | 1172 | struct u132_endp *endp = data; |
1176 | struct u132 *u132 = endp->u132; | 1173 | struct u132 *u132 = endp->u132; |
1177 | down(&u132->scheduler_lock); | 1174 | mutex_lock(&u132->scheduler_lock); |
1178 | if (u132->going > 1) { | 1175 | if (u132->going > 1) { |
1179 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1176 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1180 | , u132->going); | 1177 | , u132->going); |
1181 | up(&u132->scheduler_lock); | 1178 | mutex_unlock(&u132->scheduler_lock); |
1182 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 1179 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
1183 | return; | 1180 | return; |
1184 | } else if (endp->dequeueing) { | 1181 | } else if (endp->dequeueing) { |
1185 | endp->dequeueing = 0; | 1182 | endp->dequeueing = 0; |
1186 | up(&u132->scheduler_lock); | 1183 | mutex_unlock(&u132->scheduler_lock); |
1187 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1184 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1188 | return; | 1185 | return; |
1189 | } else if (u132->going > 0) { | 1186 | } else if (u132->going > 0) { |
1190 | dev_err(&u132->platform_dev->dev, "device is being removed " | 1187 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1191 | "urb=%p\n", urb); | 1188 | "urb=%p\n", urb); |
1192 | up(&u132->scheduler_lock); | 1189 | mutex_unlock(&u132->scheduler_lock); |
1193 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1190 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1194 | return; | 1191 | return; |
1195 | } else if (!urb->unlinked) { | 1192 | } else if (!urb->unlinked) { |
1196 | up(&u132->scheduler_lock); | 1193 | mutex_unlock(&u132->scheduler_lock); |
1197 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1194 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1198 | return; | 1195 | return; |
1199 | } else { | 1196 | } else { |
1200 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 1197 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1201 | "unlinked=%d\n", urb, urb->unlinked); | 1198 | "unlinked=%d\n", urb, urb->unlinked); |
1202 | up(&u132->scheduler_lock); | 1199 | mutex_unlock(&u132->scheduler_lock); |
1203 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1200 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1204 | return; | 1201 | return; |
1205 | } | 1202 | } |
1206 | } | 1203 | } |
1207 | 1204 | ||
1208 | static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, | 1205 | static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, |
1209 | int len, int toggle_bits, int error_count, int condition_code, | 1206 | int len, int toggle_bits, int error_count, int condition_code, |
1210 | int repeat_number, int halted, int skipped, int actual, int non_null) | 1207 | int repeat_number, int halted, int skipped, int actual, int non_null) |
1211 | { | 1208 | { |
1212 | struct u132_endp *endp = data; | 1209 | struct u132_endp *endp = data; |
1213 | struct u132 *u132 = endp->u132; | 1210 | struct u132 *u132 = endp->u132; |
1214 | u8 address = u132->addr[endp->usb_addr].address; | 1211 | u8 address = u132->addr[endp->usb_addr].address; |
1215 | down(&u132->scheduler_lock); | 1212 | mutex_lock(&u132->scheduler_lock); |
1216 | if (u132->going > 1) { | 1213 | if (u132->going > 1) { |
1217 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1214 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1218 | , u132->going); | 1215 | , u132->going); |
1219 | up(&u132->scheduler_lock); | 1216 | mutex_unlock(&u132->scheduler_lock); |
1220 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 1217 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
1221 | return; | 1218 | return; |
1222 | } else if (endp->dequeueing) { | 1219 | } else if (endp->dequeueing) { |
1223 | endp->dequeueing = 0; | 1220 | endp->dequeueing = 0; |
1224 | up(&u132->scheduler_lock); | 1221 | mutex_unlock(&u132->scheduler_lock); |
1225 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1222 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1226 | return; | 1223 | return; |
1227 | } else if (u132->going > 0) { | 1224 | } else if (u132->going > 0) { |
1228 | dev_err(&u132->platform_dev->dev, "device is being removed " | 1225 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1229 | "urb=%p\n", urb); | 1226 | "urb=%p\n", urb); |
1230 | up(&u132->scheduler_lock); | 1227 | mutex_unlock(&u132->scheduler_lock); |
1231 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1228 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1232 | return; | 1229 | return; |
1233 | } else if (!urb->unlinked) { | 1230 | } else if (!urb->unlinked) { |
1234 | int retval; | 1231 | int retval; |
1235 | struct u132_ring *ring = endp->ring; | 1232 | struct u132_ring *ring = endp->ring; |
1236 | u8 *u = urb->transfer_buffer; | 1233 | u8 *u = urb->transfer_buffer; |
1237 | u8 *b = buf; | 1234 | u8 *b = buf; |
1238 | int L = len; | 1235 | int L = len; |
1239 | while (L-- > 0) { | 1236 | |
1240 | *u++ = *b++; | 1237 | while (L-- > 0) |
1241 | } | 1238 | *u++ = *b++; |
1242 | urb->actual_length = len; | 1239 | |
1243 | up(&u132->scheduler_lock); | 1240 | urb->actual_length = len; |
1244 | retval = usb_ftdi_elan_edset_empty(u132->platform_dev, | 1241 | mutex_unlock(&u132->scheduler_lock); |
1245 | ring->number, endp, urb, address, endp->usb_endp, 0x3, | 1242 | retval = usb_ftdi_elan_edset_empty(u132->platform_dev, |
1246 | u132_hcd_initial_empty_sent); | 1243 | ring->number, endp, urb, address, endp->usb_endp, 0x3, |
1247 | if (retval == 0) { | 1244 | u132_hcd_initial_empty_sent); |
1248 | } else | 1245 | if (retval != 0) |
1249 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1246 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1250 | return; | 1247 | return; |
1251 | } else { | 1248 | } else { |
1252 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 1249 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1253 | "unlinked=%d\n", urb, urb->unlinked); | 1250 | "unlinked=%d\n", urb, urb->unlinked); |
1254 | up(&u132->scheduler_lock); | 1251 | mutex_unlock(&u132->scheduler_lock); |
1255 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1252 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1256 | return; | 1253 | return; |
1257 | } | 1254 | } |
1258 | } | 1255 | } |
1259 | 1256 | ||
1260 | static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, | 1257 | static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, |
1261 | int len, int toggle_bits, int error_count, int condition_code, | 1258 | int len, int toggle_bits, int error_count, int condition_code, |
1262 | int repeat_number, int halted, int skipped, int actual, int non_null) | 1259 | int repeat_number, int halted, int skipped, int actual, int non_null) |
1263 | { | 1260 | { |
1264 | struct u132_endp *endp = data; | 1261 | struct u132_endp *endp = data; |
1265 | struct u132 *u132 = endp->u132; | 1262 | struct u132 *u132 = endp->u132; |
1266 | u8 address = u132->addr[endp->usb_addr].address; | 1263 | u8 address = u132->addr[endp->usb_addr].address; |
1267 | down(&u132->scheduler_lock); | 1264 | mutex_lock(&u132->scheduler_lock); |
1268 | if (u132->going > 1) { | 1265 | if (u132->going > 1) { |
1269 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1266 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1270 | , u132->going); | 1267 | , u132->going); |
1271 | up(&u132->scheduler_lock); | 1268 | mutex_unlock(&u132->scheduler_lock); |
1272 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | 1269 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); |
1273 | return; | 1270 | return; |
1274 | } else if (endp->dequeueing) { | 1271 | } else if (endp->dequeueing) { |
1275 | endp->dequeueing = 0; | 1272 | endp->dequeueing = 0; |
1276 | up(&u132->scheduler_lock); | 1273 | mutex_unlock(&u132->scheduler_lock); |
1277 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1274 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1278 | return; | 1275 | return; |
1279 | } else if (u132->going > 0) { | 1276 | } else if (u132->going > 0) { |
1280 | dev_err(&u132->platform_dev->dev, "device is being removed " | 1277 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1281 | "urb=%p\n", urb); | 1278 | "urb=%p\n", urb); |
1282 | up(&u132->scheduler_lock); | 1279 | mutex_unlock(&u132->scheduler_lock); |
1283 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1280 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1284 | return; | 1281 | return; |
1285 | } else if (!urb->unlinked) { | 1282 | } else if (!urb->unlinked) { |
1286 | int retval; | 1283 | int retval; |
1287 | struct u132_ring *ring = endp->ring; | 1284 | struct u132_ring *ring = endp->ring; |
1288 | up(&u132->scheduler_lock); | 1285 | mutex_unlock(&u132->scheduler_lock); |
1289 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | 1286 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, |
1290 | ring->number, endp, urb, address, endp->usb_endp, 0, | 1287 | ring->number, endp, urb, address, endp->usb_endp, 0, |
1291 | u132_hcd_initial_input_recv); | 1288 | u132_hcd_initial_input_recv); |
1292 | if (retval == 0) { | 1289 | if (retval != 0) |
1293 | } else | 1290 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1294 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1291 | return; |
1295 | return; | 1292 | } else { |
1296 | } else { | ||
1297 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " | 1293 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1298 | "unlinked=%d\n", urb, urb->unlinked); | 1294 | "unlinked=%d\n", urb, urb->unlinked); |
1299 | up(&u132->scheduler_lock); | 1295 | mutex_unlock(&u132->scheduler_lock); |
1300 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1296 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1301 | return; | 1297 | return; |
1302 | } | 1298 | } |
1303 | } | 1299 | } |
1304 | 1300 | ||
1305 | /* | 1301 | /* |
@@ -1308,302 +1304,296 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, | |||
1308 | */ | 1304 | */ |
1309 | static void u132_hcd_ring_work_scheduler(struct work_struct *work) | 1305 | static void u132_hcd_ring_work_scheduler(struct work_struct *work) |
1310 | { | 1306 | { |
1311 | struct u132_ring *ring = | 1307 | struct u132_ring *ring = |
1312 | container_of(work, struct u132_ring, scheduler.work); | 1308 | container_of(work, struct u132_ring, scheduler.work); |
1313 | struct u132 *u132 = ring->u132; | 1309 | struct u132 *u132 = ring->u132; |
1314 | down(&u132->scheduler_lock); | 1310 | mutex_lock(&u132->scheduler_lock); |
1315 | if (ring->in_use) { | 1311 | if (ring->in_use) { |
1316 | up(&u132->scheduler_lock); | 1312 | mutex_unlock(&u132->scheduler_lock); |
1317 | u132_ring_put_kref(u132, ring); | 1313 | u132_ring_put_kref(u132, ring); |
1318 | return; | 1314 | return; |
1319 | } else if (ring->curr_endp) { | 1315 | } else if (ring->curr_endp) { |
1320 | struct u132_endp *last_endp = ring->curr_endp; | 1316 | struct u132_endp *last_endp = ring->curr_endp; |
1321 | struct list_head *scan; | 1317 | struct list_head *scan; |
1322 | struct list_head *head = &last_endp->endp_ring; | 1318 | struct list_head *head = &last_endp->endp_ring; |
1323 | unsigned long wakeup = 0; | 1319 | unsigned long wakeup = 0; |
1324 | list_for_each(scan, head) { | 1320 | list_for_each(scan, head) { |
1325 | struct u132_endp *endp = list_entry(scan, | 1321 | struct u132_endp *endp = list_entry(scan, |
1326 | struct u132_endp, endp_ring); | 1322 | struct u132_endp, endp_ring); |
1327 | if (endp->queue_next == endp->queue_last) { | 1323 | if (endp->queue_next == endp->queue_last) { |
1328 | } else if ((endp->delayed == 0) | 1324 | } else if ((endp->delayed == 0) |
1329 | || time_after_eq(jiffies, endp->jiffies)) { | 1325 | || time_after_eq(jiffies, endp->jiffies)) { |
1330 | ring->curr_endp = endp; | 1326 | ring->curr_endp = endp; |
1331 | u132_endp_cancel_work(u132, last_endp); | 1327 | u132_endp_cancel_work(u132, last_endp); |
1332 | u132_endp_queue_work(u132, last_endp, 0); | 1328 | u132_endp_queue_work(u132, last_endp, 0); |
1333 | up(&u132->scheduler_lock); | 1329 | mutex_unlock(&u132->scheduler_lock); |
1334 | u132_ring_put_kref(u132, ring); | 1330 | u132_ring_put_kref(u132, ring); |
1335 | return; | 1331 | return; |
1336 | } else { | 1332 | } else { |
1337 | unsigned long delta = endp->jiffies - jiffies; | 1333 | unsigned long delta = endp->jiffies - jiffies; |
1338 | if (delta > wakeup) | 1334 | if (delta > wakeup) |
1339 | wakeup = delta; | 1335 | wakeup = delta; |
1340 | } | 1336 | } |
1341 | } | 1337 | } |
1342 | if (last_endp->queue_next == last_endp->queue_last) { | 1338 | if (last_endp->queue_next == last_endp->queue_last) { |
1343 | } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, | 1339 | } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, |
1344 | last_endp->jiffies)) { | 1340 | last_endp->jiffies)) { |
1345 | u132_endp_cancel_work(u132, last_endp); | 1341 | u132_endp_cancel_work(u132, last_endp); |
1346 | u132_endp_queue_work(u132, last_endp, 0); | 1342 | u132_endp_queue_work(u132, last_endp, 0); |
1347 | up(&u132->scheduler_lock); | 1343 | mutex_unlock(&u132->scheduler_lock); |
1348 | u132_ring_put_kref(u132, ring); | 1344 | u132_ring_put_kref(u132, ring); |
1349 | return; | 1345 | return; |
1350 | } else { | 1346 | } else { |
1351 | unsigned long delta = last_endp->jiffies - jiffies; | 1347 | unsigned long delta = last_endp->jiffies - jiffies; |
1352 | if (delta > wakeup) | 1348 | if (delta > wakeup) |
1353 | wakeup = delta; | 1349 | wakeup = delta; |
1354 | } | 1350 | } |
1355 | if (wakeup > 0) { | 1351 | if (wakeup > 0) { |
1356 | u132_ring_requeue_work(u132, ring, wakeup); | 1352 | u132_ring_requeue_work(u132, ring, wakeup); |
1357 | up(&u132->scheduler_lock); | 1353 | mutex_unlock(&u132->scheduler_lock); |
1358 | return; | 1354 | return; |
1359 | } else { | 1355 | } else { |
1360 | up(&u132->scheduler_lock); | 1356 | mutex_unlock(&u132->scheduler_lock); |
1361 | u132_ring_put_kref(u132, ring); | 1357 | u132_ring_put_kref(u132, ring); |
1362 | return; | 1358 | return; |
1363 | } | 1359 | } |
1364 | } else { | 1360 | } else { |
1365 | up(&u132->scheduler_lock); | 1361 | mutex_unlock(&u132->scheduler_lock); |
1366 | u132_ring_put_kref(u132, ring); | 1362 | u132_ring_put_kref(u132, ring); |
1367 | return; | 1363 | return; |
1368 | } | 1364 | } |
1369 | } | 1365 | } |
1370 | 1366 | ||
1371 | static void u132_hcd_endp_work_scheduler(struct work_struct *work) | 1367 | static void u132_hcd_endp_work_scheduler(struct work_struct *work) |
1372 | { | 1368 | { |
1373 | struct u132_ring *ring; | 1369 | struct u132_ring *ring; |
1374 | struct u132_endp *endp = | 1370 | struct u132_endp *endp = |
1375 | container_of(work, struct u132_endp, scheduler.work); | 1371 | container_of(work, struct u132_endp, scheduler.work); |
1376 | struct u132 *u132 = endp->u132; | 1372 | struct u132 *u132 = endp->u132; |
1377 | down(&u132->scheduler_lock); | 1373 | mutex_lock(&u132->scheduler_lock); |
1378 | ring = endp->ring; | 1374 | ring = endp->ring; |
1379 | if (endp->edset_flush) { | 1375 | if (endp->edset_flush) { |
1380 | endp->edset_flush = 0; | 1376 | endp->edset_flush = 0; |
1381 | if (endp->dequeueing) | 1377 | if (endp->dequeueing) |
1382 | usb_ftdi_elan_edset_flush(u132->platform_dev, | 1378 | usb_ftdi_elan_edset_flush(u132->platform_dev, |
1383 | ring->number, endp); | 1379 | ring->number, endp); |
1384 | up(&u132->scheduler_lock); | 1380 | mutex_unlock(&u132->scheduler_lock); |
1385 | u132_endp_put_kref(u132, endp); | 1381 | u132_endp_put_kref(u132, endp); |
1386 | return; | 1382 | return; |
1387 | } else if (endp->active) { | 1383 | } else if (endp->active) { |
1388 | up(&u132->scheduler_lock); | 1384 | mutex_unlock(&u132->scheduler_lock); |
1389 | u132_endp_put_kref(u132, endp); | 1385 | u132_endp_put_kref(u132, endp); |
1390 | return; | 1386 | return; |
1391 | } else if (ring->in_use) { | 1387 | } else if (ring->in_use) { |
1392 | up(&u132->scheduler_lock); | 1388 | mutex_unlock(&u132->scheduler_lock); |
1393 | u132_endp_put_kref(u132, endp); | 1389 | u132_endp_put_kref(u132, endp); |
1394 | return; | 1390 | return; |
1395 | } else if (endp->queue_next == endp->queue_last) { | 1391 | } else if (endp->queue_next == endp->queue_last) { |
1396 | up(&u132->scheduler_lock); | 1392 | mutex_unlock(&u132->scheduler_lock); |
1397 | u132_endp_put_kref(u132, endp); | 1393 | u132_endp_put_kref(u132, endp); |
1398 | return; | 1394 | return; |
1399 | } else if (endp->pipetype == PIPE_INTERRUPT) { | 1395 | } else if (endp->pipetype == PIPE_INTERRUPT) { |
1400 | u8 address = u132->addr[endp->usb_addr].address; | 1396 | u8 address = u132->addr[endp->usb_addr].address; |
1401 | if (ring->in_use) { | 1397 | if (ring->in_use) { |
1402 | up(&u132->scheduler_lock); | 1398 | mutex_unlock(&u132->scheduler_lock); |
1403 | u132_endp_put_kref(u132, endp); | 1399 | u132_endp_put_kref(u132, endp); |
1404 | return; | 1400 | return; |
1405 | } else { | 1401 | } else { |
1406 | int retval; | 1402 | int retval; |
1407 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | 1403 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & |
1408 | endp->queue_next]; | 1404 | endp->queue_next]; |
1409 | endp->active = 1; | 1405 | endp->active = 1; |
1410 | ring->curr_endp = endp; | 1406 | ring->curr_endp = endp; |
1411 | ring->in_use = 1; | 1407 | ring->in_use = 1; |
1412 | up(&u132->scheduler_lock); | 1408 | mutex_unlock(&u132->scheduler_lock); |
1413 | retval = edset_single(u132, ring, endp, urb, address, | 1409 | retval = edset_single(u132, ring, endp, urb, address, |
1414 | endp->toggle_bits, u132_hcd_interrupt_recv); | 1410 | endp->toggle_bits, u132_hcd_interrupt_recv); |
1415 | if (retval == 0) { | 1411 | if (retval != 0) |
1416 | } else | 1412 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1417 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1413 | return; |
1418 | return; | 1414 | } |
1419 | } | 1415 | } else if (endp->pipetype == PIPE_CONTROL) { |
1420 | } else if (endp->pipetype == PIPE_CONTROL) { | 1416 | u8 address = u132->addr[endp->usb_addr].address; |
1421 | u8 address = u132->addr[endp->usb_addr].address; | 1417 | if (ring->in_use) { |
1422 | if (ring->in_use) { | 1418 | mutex_unlock(&u132->scheduler_lock); |
1423 | up(&u132->scheduler_lock); | 1419 | u132_endp_put_kref(u132, endp); |
1424 | u132_endp_put_kref(u132, endp); | 1420 | return; |
1425 | return; | 1421 | } else if (address == 0) { |
1426 | } else if (address == 0) { | 1422 | int retval; |
1427 | int retval; | 1423 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & |
1428 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | 1424 | endp->queue_next]; |
1429 | endp->queue_next]; | 1425 | endp->active = 1; |
1430 | endp->active = 1; | 1426 | ring->curr_endp = endp; |
1431 | ring->curr_endp = endp; | 1427 | ring->in_use = 1; |
1432 | ring->in_use = 1; | 1428 | mutex_unlock(&u132->scheduler_lock); |
1433 | up(&u132->scheduler_lock); | 1429 | retval = edset_setup(u132, ring, endp, urb, address, |
1434 | retval = edset_setup(u132, ring, endp, urb, address, | 1430 | 0x2, u132_hcd_initial_setup_sent); |
1435 | 0x2, u132_hcd_initial_setup_sent); | 1431 | if (retval != 0) |
1436 | if (retval == 0) { | 1432 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1437 | } else | 1433 | return; |
1438 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1434 | } else if (endp->usb_addr == 0) { |
1439 | return; | 1435 | int retval; |
1440 | } else if (endp->usb_addr == 0) { | 1436 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & |
1441 | int retval; | 1437 | endp->queue_next]; |
1442 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | 1438 | endp->active = 1; |
1443 | endp->queue_next]; | 1439 | ring->curr_endp = endp; |
1444 | endp->active = 1; | 1440 | ring->in_use = 1; |
1445 | ring->curr_endp = endp; | 1441 | mutex_unlock(&u132->scheduler_lock); |
1446 | ring->in_use = 1; | 1442 | retval = edset_setup(u132, ring, endp, urb, 0, 0x2, |
1447 | up(&u132->scheduler_lock); | 1443 | u132_hcd_enumeration_address_sent); |
1448 | retval = edset_setup(u132, ring, endp, urb, 0, 0x2, | 1444 | if (retval != 0) |
1449 | u132_hcd_enumeration_address_sent); | 1445 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1450 | if (retval == 0) { | 1446 | return; |
1451 | } else | 1447 | } else { |
1452 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1448 | int retval; |
1453 | return; | 1449 | u8 address = u132->addr[endp->usb_addr].address; |
1454 | } else { | 1450 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & |
1455 | int retval; | 1451 | endp->queue_next]; |
1456 | u8 address = u132->addr[endp->usb_addr].address; | 1452 | endp->active = 1; |
1457 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | 1453 | ring->curr_endp = endp; |
1458 | endp->queue_next]; | 1454 | ring->in_use = 1; |
1459 | endp->active = 1; | 1455 | mutex_unlock(&u132->scheduler_lock); |
1460 | ring->curr_endp = endp; | 1456 | retval = edset_setup(u132, ring, endp, urb, address, |
1461 | ring->in_use = 1; | 1457 | 0x2, u132_hcd_configure_setup_sent); |
1462 | up(&u132->scheduler_lock); | 1458 | if (retval != 0) |
1463 | retval = edset_setup(u132, ring, endp, urb, address, | 1459 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1464 | 0x2, u132_hcd_configure_setup_sent); | 1460 | return; |
1465 | if (retval == 0) { | 1461 | } |
1466 | } else | 1462 | } else { |
1467 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1463 | if (endp->input) { |
1468 | return; | 1464 | u8 address = u132->addr[endp->usb_addr].address; |
1469 | } | 1465 | if (ring->in_use) { |
1470 | } else { | 1466 | mutex_unlock(&u132->scheduler_lock); |
1471 | if (endp->input) { | 1467 | u132_endp_put_kref(u132, endp); |
1472 | u8 address = u132->addr[endp->usb_addr].address; | 1468 | return; |
1473 | if (ring->in_use) { | 1469 | } else { |
1474 | up(&u132->scheduler_lock); | 1470 | int retval; |
1475 | u132_endp_put_kref(u132, endp); | 1471 | struct urb *urb = endp->urb_list[ |
1476 | return; | 1472 | ENDP_QUEUE_MASK & endp->queue_next]; |
1477 | } else { | 1473 | endp->active = 1; |
1478 | int retval; | 1474 | ring->curr_endp = endp; |
1479 | struct urb *urb = endp->urb_list[ | 1475 | ring->in_use = 1; |
1480 | ENDP_QUEUE_MASK & endp->queue_next]; | 1476 | mutex_unlock(&u132->scheduler_lock); |
1481 | endp->active = 1; | 1477 | retval = edset_input(u132, ring, endp, urb, |
1482 | ring->curr_endp = endp; | 1478 | address, endp->toggle_bits, |
1483 | ring->in_use = 1; | 1479 | u132_hcd_bulk_input_recv); |
1484 | up(&u132->scheduler_lock); | 1480 | if (retval == 0) { |
1485 | retval = edset_input(u132, ring, endp, urb, | 1481 | } else |
1486 | address, endp->toggle_bits, | 1482 | u132_hcd_giveback_urb(u132, endp, urb, |
1487 | u132_hcd_bulk_input_recv); | 1483 | retval); |
1488 | if (retval == 0) { | 1484 | return; |
1489 | } else | 1485 | } |
1490 | u132_hcd_giveback_urb(u132, endp, urb, | 1486 | } else { /* output pipe */ |
1491 | retval); | 1487 | u8 address = u132->addr[endp->usb_addr].address; |
1492 | return; | 1488 | if (ring->in_use) { |
1493 | } | 1489 | mutex_unlock(&u132->scheduler_lock); |
1494 | } else { /* output pipe */ | 1490 | u132_endp_put_kref(u132, endp); |
1495 | u8 address = u132->addr[endp->usb_addr].address; | 1491 | return; |
1496 | if (ring->in_use) { | 1492 | } else { |
1497 | up(&u132->scheduler_lock); | 1493 | int retval; |
1498 | u132_endp_put_kref(u132, endp); | 1494 | struct urb *urb = endp->urb_list[ |
1499 | return; | 1495 | ENDP_QUEUE_MASK & endp->queue_next]; |
1500 | } else { | 1496 | endp->active = 1; |
1501 | int retval; | 1497 | ring->curr_endp = endp; |
1502 | struct urb *urb = endp->urb_list[ | 1498 | ring->in_use = 1; |
1503 | ENDP_QUEUE_MASK & endp->queue_next]; | 1499 | mutex_unlock(&u132->scheduler_lock); |
1504 | endp->active = 1; | 1500 | retval = edset_output(u132, ring, endp, urb, |
1505 | ring->curr_endp = endp; | 1501 | address, endp->toggle_bits, |
1506 | ring->in_use = 1; | 1502 | u132_hcd_bulk_output_sent); |
1507 | up(&u132->scheduler_lock); | 1503 | if (retval == 0) { |
1508 | retval = edset_output(u132, ring, endp, urb, | 1504 | } else |
1509 | address, endp->toggle_bits, | 1505 | u132_hcd_giveback_urb(u132, endp, urb, |
1510 | u132_hcd_bulk_output_sent); | 1506 | retval); |
1511 | if (retval == 0) { | 1507 | return; |
1512 | } else | 1508 | } |
1513 | u132_hcd_giveback_urb(u132, endp, urb, | 1509 | } |
1514 | retval); | 1510 | } |
1515 | return; | ||
1516 | } | ||
1517 | } | ||
1518 | } | ||
1519 | } | 1511 | } |
1520 | #ifdef CONFIG_PM | 1512 | #ifdef CONFIG_PM |
1521 | 1513 | ||
1522 | static void port_power(struct u132 *u132, int pn, int is_on) | 1514 | static void port_power(struct u132 *u132, int pn, int is_on) |
1523 | { | 1515 | { |
1524 | u132->port[pn].power = is_on; | 1516 | u132->port[pn].power = is_on; |
1525 | } | 1517 | } |
1526 | 1518 | ||
1527 | #endif | 1519 | #endif |
1528 | 1520 | ||
1529 | static void u132_power(struct u132 *u132, int is_on) | 1521 | static void u132_power(struct u132 *u132, int is_on) |
1530 | { | 1522 | { |
1531 | struct usb_hcd *hcd = u132_to_hcd(u132) | 1523 | struct usb_hcd *hcd = u132_to_hcd(u132) |
1532 | ; /* hub is inactive unless the port is powered */ | 1524 | ; /* hub is inactive unless the port is powered */ |
1533 | if (is_on) { | 1525 | if (is_on) { |
1534 | if (u132->power) | 1526 | if (u132->power) |
1535 | return; | 1527 | return; |
1536 | u132->power = 1; | 1528 | u132->power = 1; |
1537 | hcd->self.controller->power.power_state = PMSG_ON; | 1529 | } else { |
1538 | } else { | 1530 | u132->power = 0; |
1539 | u132->power = 0; | 1531 | hcd->state = HC_STATE_HALT; |
1540 | hcd->state = HC_STATE_HALT; | 1532 | } |
1541 | hcd->self.controller->power.power_state = PMSG_SUSPEND; | ||
1542 | } | ||
1543 | } | 1533 | } |
1544 | 1534 | ||
1545 | static int u132_periodic_reinit(struct u132 *u132) | 1535 | static int u132_periodic_reinit(struct u132 *u132) |
1546 | { | 1536 | { |
1547 | int retval; | 1537 | int retval; |
1548 | u32 fi = u132->hc_fminterval & 0x03fff; | 1538 | u32 fi = u132->hc_fminterval & 0x03fff; |
1549 | u32 fit; | 1539 | u32 fit; |
1550 | u32 fminterval; | 1540 | u32 fminterval; |
1551 | retval = u132_read_pcimem(u132, fminterval, &fminterval); | 1541 | retval = u132_read_pcimem(u132, fminterval, &fminterval); |
1552 | if (retval) | 1542 | if (retval) |
1553 | return retval; | 1543 | return retval; |
1554 | fit = fminterval & FIT; | 1544 | fit = fminterval & FIT; |
1555 | retval = u132_write_pcimem(u132, fminterval, | 1545 | retval = u132_write_pcimem(u132, fminterval, |
1556 | (fit ^ FIT) | u132->hc_fminterval); | 1546 | (fit ^ FIT) | u132->hc_fminterval); |
1557 | if (retval) | 1547 | if (retval) |
1558 | return retval; | 1548 | return retval; |
1559 | retval = u132_write_pcimem(u132, periodicstart, | 1549 | retval = u132_write_pcimem(u132, periodicstart, |
1560 | ((9 *fi) / 10) & 0x3fff); | 1550 | ((9 * fi) / 10) & 0x3fff); |
1561 | if (retval) | 1551 | if (retval) |
1562 | return retval; | 1552 | return retval; |
1563 | return 0; | 1553 | return 0; |
1564 | } | 1554 | } |
1565 | 1555 | ||
1566 | static char *hcfs2string(int state) | 1556 | static char *hcfs2string(int state) |
1567 | { | 1557 | { |
1568 | switch (state) { | 1558 | switch (state) { |
1569 | case OHCI_USB_RESET: | 1559 | case OHCI_USB_RESET: |
1570 | return "reset"; | 1560 | return "reset"; |
1571 | case OHCI_USB_RESUME: | 1561 | case OHCI_USB_RESUME: |
1572 | return "resume"; | 1562 | return "resume"; |
1573 | case OHCI_USB_OPER: | 1563 | case OHCI_USB_OPER: |
1574 | return "operational"; | 1564 | return "operational"; |
1575 | case OHCI_USB_SUSPEND: | 1565 | case OHCI_USB_SUSPEND: |
1576 | return "suspend"; | 1566 | return "suspend"; |
1577 | } | 1567 | } |
1578 | return "?"; | 1568 | return "?"; |
1579 | } | 1569 | } |
1580 | 1570 | ||
1581 | static int u132_init(struct u132 *u132) | 1571 | static int u132_init(struct u132 *u132) |
1582 | { | 1572 | { |
1583 | int retval; | 1573 | int retval; |
1584 | u32 control; | 1574 | u32 control; |
1585 | u132_disable(u132); | 1575 | u132_disable(u132); |
1586 | u132->next_statechange = jiffies; | 1576 | u132->next_statechange = jiffies; |
1587 | retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); | 1577 | retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); |
1588 | if (retval) | 1578 | if (retval) |
1589 | return retval; | 1579 | return retval; |
1590 | retval = u132_read_pcimem(u132, control, &control); | 1580 | retval = u132_read_pcimem(u132, control, &control); |
1591 | if (retval) | 1581 | if (retval) |
1592 | return retval; | 1582 | return retval; |
1593 | if (u132->num_ports == 0) { | 1583 | if (u132->num_ports == 0) { |
1594 | u32 rh_a = -1; | 1584 | u32 rh_a = -1; |
1595 | retval = u132_read_pcimem(u132, roothub.a, &rh_a); | 1585 | retval = u132_read_pcimem(u132, roothub.a, &rh_a); |
1596 | if (retval) | 1586 | if (retval) |
1597 | return retval; | 1587 | return retval; |
1598 | u132->num_ports = rh_a & RH_A_NDP; | 1588 | u132->num_ports = rh_a & RH_A_NDP; |
1599 | retval = read_roothub_info(u132); | 1589 | retval = read_roothub_info(u132); |
1600 | if (retval) | 1590 | if (retval) |
1601 | return retval; | 1591 | return retval; |
1602 | } | 1592 | } |
1603 | if (u132->num_ports > MAX_U132_PORTS) { | 1593 | if (u132->num_ports > MAX_U132_PORTS) |
1604 | return -EINVAL; | 1594 | return -EINVAL; |
1605 | } | 1595 | |
1606 | return 0; | 1596 | return 0; |
1607 | } | 1597 | } |
1608 | 1598 | ||
1609 | 1599 | ||
@@ -1613,280 +1603,278 @@ static int u132_init(struct u132 *u132) | |||
1613 | */ | 1603 | */ |
1614 | static int u132_run(struct u132 *u132) | 1604 | static int u132_run(struct u132 *u132) |
1615 | { | 1605 | { |
1616 | int retval; | 1606 | int retval; |
1617 | u32 control; | 1607 | u32 control; |
1618 | u32 status; | 1608 | u32 status; |
1619 | u32 fminterval; | 1609 | u32 fminterval; |
1620 | u32 periodicstart; | 1610 | u32 periodicstart; |
1621 | u32 cmdstatus; | 1611 | u32 cmdstatus; |
1622 | u32 roothub_a; | 1612 | u32 roothub_a; |
1623 | int mask = OHCI_INTR_INIT; | 1613 | int mask = OHCI_INTR_INIT; |
1624 | int first = u132->hc_fminterval == 0; | 1614 | int first = u132->hc_fminterval == 0; |
1625 | int sleep_time = 0; | 1615 | int sleep_time = 0; |
1626 | int reset_timeout = 30; /* ... allow extra time */ | 1616 | int reset_timeout = 30; /* ... allow extra time */ |
1627 | u132_disable(u132); | 1617 | u132_disable(u132); |
1628 | if (first) { | 1618 | if (first) { |
1629 | u32 temp; | 1619 | u32 temp; |
1630 | retval = u132_read_pcimem(u132, fminterval, &temp); | 1620 | retval = u132_read_pcimem(u132, fminterval, &temp); |
1631 | if (retval) | 1621 | if (retval) |
1632 | return retval; | 1622 | return retval; |
1633 | u132->hc_fminterval = temp & 0x3fff; | 1623 | u132->hc_fminterval = temp & 0x3fff; |
1634 | if (u132->hc_fminterval != FI) { | 1624 | u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; |
1635 | } | 1625 | } |
1636 | u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; | 1626 | retval = u132_read_pcimem(u132, control, &u132->hc_control); |
1637 | } | 1627 | if (retval) |
1638 | retval = u132_read_pcimem(u132, control, &u132->hc_control); | 1628 | return retval; |
1639 | if (retval) | 1629 | dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " |
1640 | return retval; | 1630 | "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), |
1641 | dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " | 1631 | u132->hc_control); |
1642 | "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), | 1632 | switch (u132->hc_control & OHCI_CTRL_HCFS) { |
1643 | u132->hc_control); | 1633 | case OHCI_USB_OPER: |
1644 | switch (u132->hc_control & OHCI_CTRL_HCFS) { | 1634 | sleep_time = 0; |
1645 | case OHCI_USB_OPER: | 1635 | break; |
1646 | sleep_time = 0; | 1636 | case OHCI_USB_SUSPEND: |
1647 | break; | 1637 | case OHCI_USB_RESUME: |
1648 | case OHCI_USB_SUSPEND: | 1638 | u132->hc_control &= OHCI_CTRL_RWC; |
1649 | case OHCI_USB_RESUME: | 1639 | u132->hc_control |= OHCI_USB_RESUME; |
1650 | u132->hc_control &= OHCI_CTRL_RWC; | 1640 | sleep_time = 10; |
1651 | u132->hc_control |= OHCI_USB_RESUME; | 1641 | break; |
1652 | sleep_time = 10; | 1642 | default: |
1653 | break; | 1643 | u132->hc_control &= OHCI_CTRL_RWC; |
1654 | default: | 1644 | u132->hc_control |= OHCI_USB_RESET; |
1655 | u132->hc_control &= OHCI_CTRL_RWC; | 1645 | sleep_time = 50; |
1656 | u132->hc_control |= OHCI_USB_RESET; | 1646 | break; |
1657 | sleep_time = 50; | 1647 | } |
1658 | break; | 1648 | retval = u132_write_pcimem(u132, control, u132->hc_control); |
1659 | } | 1649 | if (retval) |
1660 | retval = u132_write_pcimem(u132, control, u132->hc_control); | 1650 | return retval; |
1661 | if (retval) | 1651 | retval = u132_read_pcimem(u132, control, &control); |
1662 | return retval; | 1652 | if (retval) |
1663 | retval = u132_read_pcimem(u132, control, &control); | 1653 | return retval; |
1664 | if (retval) | 1654 | msleep(sleep_time); |
1665 | return retval; | 1655 | retval = u132_read_pcimem(u132, roothub.a, &roothub_a); |
1666 | msleep(sleep_time); | 1656 | if (retval) |
1667 | retval = u132_read_pcimem(u132, roothub.a, &roothub_a); | 1657 | return retval; |
1668 | if (retval) | 1658 | if (!(roothub_a & RH_A_NPS)) { |
1669 | return retval; | 1659 | int temp; /* power down each port */ |
1670 | if (!(roothub_a & RH_A_NPS)) { | 1660 | for (temp = 0; temp < u132->num_ports; temp++) { |
1671 | int temp; /* power down each port */ | 1661 | retval = u132_write_pcimem(u132, |
1672 | for (temp = 0; temp < u132->num_ports; temp++) { | 1662 | roothub.portstatus[temp], RH_PS_LSDA); |
1673 | retval = u132_write_pcimem(u132, | 1663 | if (retval) |
1674 | roothub.portstatus[temp], RH_PS_LSDA); | 1664 | return retval; |
1675 | if (retval) | 1665 | } |
1676 | return retval; | 1666 | } |
1677 | } | 1667 | retval = u132_read_pcimem(u132, control, &control); |
1678 | } | 1668 | if (retval) |
1679 | retval = u132_read_pcimem(u132, control, &control); | 1669 | return retval; |
1680 | if (retval) | 1670 | retry: |
1681 | return retval; | 1671 | retval = u132_read_pcimem(u132, cmdstatus, &status); |
1682 | retry:retval = u132_read_pcimem(u132, cmdstatus, &status); | 1672 | if (retval) |
1683 | if (retval) | 1673 | return retval; |
1684 | return retval; | 1674 | retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR); |
1685 | retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR); | 1675 | if (retval) |
1686 | if (retval) | 1676 | return retval; |
1687 | return retval; | 1677 | extra: { |
1688 | extra:{ | 1678 | retval = u132_read_pcimem(u132, cmdstatus, &status); |
1689 | retval = u132_read_pcimem(u132, cmdstatus, &status); | 1679 | if (retval) |
1690 | if (retval) | 1680 | return retval; |
1691 | return retval; | 1681 | if (0 != (status & OHCI_HCR)) { |
1692 | if (0 != (status & OHCI_HCR)) { | 1682 | if (--reset_timeout == 0) { |
1693 | if (--reset_timeout == 0) { | 1683 | dev_err(&u132->platform_dev->dev, "USB HC reset" |
1694 | dev_err(&u132->platform_dev->dev, "USB HC reset" | 1684 | " timed out!\n"); |
1695 | " timed out!\n"); | 1685 | return -ENODEV; |
1696 | return -ENODEV; | 1686 | } else { |
1697 | } else { | 1687 | msleep(5); |
1698 | msleep(5); | 1688 | goto extra; |
1699 | goto extra; | 1689 | } |
1700 | } | 1690 | } |
1701 | } | 1691 | } |
1702 | } | 1692 | if (u132->flags & OHCI_QUIRK_INITRESET) { |
1703 | if (u132->flags & OHCI_QUIRK_INITRESET) { | 1693 | retval = u132_write_pcimem(u132, control, u132->hc_control); |
1704 | retval = u132_write_pcimem(u132, control, u132->hc_control); | 1694 | if (retval) |
1705 | if (retval) | 1695 | return retval; |
1706 | return retval; | 1696 | retval = u132_read_pcimem(u132, control, &control); |
1707 | retval = u132_read_pcimem(u132, control, &control); | 1697 | if (retval) |
1708 | if (retval) | 1698 | return retval; |
1709 | return retval; | 1699 | } |
1710 | } | 1700 | retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); |
1711 | retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); | 1701 | if (retval) |
1712 | if (retval) | 1702 | return retval; |
1713 | return retval; | 1703 | retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); |
1714 | retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); | 1704 | if (retval) |
1715 | if (retval) | 1705 | return retval; |
1716 | return retval; | 1706 | retval = u132_write_pcimem(u132, hcca, 0x00000000); |
1717 | retval = u132_write_pcimem(u132, hcca, 0x00000000); | 1707 | if (retval) |
1718 | if (retval) | 1708 | return retval; |
1719 | return retval; | 1709 | retval = u132_periodic_reinit(u132); |
1720 | retval = u132_periodic_reinit(u132); | 1710 | if (retval) |
1721 | if (retval) | 1711 | return retval; |
1722 | return retval; | 1712 | retval = u132_read_pcimem(u132, fminterval, &fminterval); |
1723 | retval = u132_read_pcimem(u132, fminterval, &fminterval); | 1713 | if (retval) |
1724 | if (retval) | 1714 | return retval; |
1725 | return retval; | 1715 | retval = u132_read_pcimem(u132, periodicstart, &periodicstart); |
1726 | retval = u132_read_pcimem(u132, periodicstart, &periodicstart); | 1716 | if (retval) |
1727 | if (retval) | 1717 | return retval; |
1728 | return retval; | 1718 | if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { |
1729 | if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { | 1719 | if (!(u132->flags & OHCI_QUIRK_INITRESET)) { |
1730 | if (!(u132->flags & OHCI_QUIRK_INITRESET)) { | 1720 | u132->flags |= OHCI_QUIRK_INITRESET; |
1731 | u132->flags |= OHCI_QUIRK_INITRESET; | 1721 | goto retry; |
1732 | goto retry; | 1722 | } else |
1733 | } else | 1723 | dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" |
1734 | dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" | 1724 | "\n", fminterval, periodicstart); |
1735 | "\n", fminterval, periodicstart); | 1725 | } /* start controller operations */ |
1736 | } /* start controller operations */ | 1726 | u132->hc_control &= OHCI_CTRL_RWC; |
1737 | u132->hc_control &= OHCI_CTRL_RWC; | 1727 | u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; |
1738 | u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; | 1728 | retval = u132_write_pcimem(u132, control, u132->hc_control); |
1739 | retval = u132_write_pcimem(u132, control, u132->hc_control); | 1729 | if (retval) |
1740 | if (retval) | 1730 | return retval; |
1741 | return retval; | 1731 | retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF); |
1742 | retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF); | 1732 | if (retval) |
1743 | if (retval) | 1733 | return retval; |
1744 | return retval; | 1734 | retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); |
1745 | retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); | 1735 | if (retval) |
1746 | if (retval) | 1736 | return retval; |
1747 | return retval; | 1737 | retval = u132_read_pcimem(u132, control, &control); |
1748 | retval = u132_read_pcimem(u132, control, &control); | 1738 | if (retval) |
1749 | if (retval) | 1739 | return retval; |
1750 | return retval; | 1740 | u132_to_hcd(u132)->state = HC_STATE_RUNNING; |
1751 | u132_to_hcd(u132)->state = HC_STATE_RUNNING; | 1741 | retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); |
1752 | retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); | 1742 | if (retval) |
1753 | if (retval) | 1743 | return retval; |
1754 | return retval; | 1744 | retval = u132_write_pcimem(u132, intrstatus, mask); |
1755 | retval = u132_write_pcimem(u132, intrstatus, mask); | 1745 | if (retval) |
1756 | if (retval) | 1746 | return retval; |
1757 | return retval; | 1747 | retval = u132_write_pcimem(u132, intrdisable, |
1758 | retval = u132_write_pcimem(u132, intrdisable, | 1748 | OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | |
1759 | OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | | 1749 | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | |
1760 | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | | 1750 | OHCI_INTR_SO); |
1761 | OHCI_INTR_SO); | 1751 | if (retval) |
1762 | if (retval) | 1752 | return retval; /* handle root hub init quirks ... */ |
1763 | return retval; /* handle root hub init quirks ... */ | 1753 | retval = u132_read_pcimem(u132, roothub.a, &roothub_a); |
1764 | retval = u132_read_pcimem(u132, roothub.a, &roothub_a); | 1754 | if (retval) |
1765 | if (retval) | 1755 | return retval; |
1766 | return retval; | 1756 | roothub_a &= ~(RH_A_PSM | RH_A_OCPM); |
1767 | roothub_a &= ~(RH_A_PSM | RH_A_OCPM); | 1757 | if (u132->flags & OHCI_QUIRK_SUPERIO) { |
1768 | if (u132->flags & OHCI_QUIRK_SUPERIO) { | 1758 | roothub_a |= RH_A_NOCP; |
1769 | roothub_a |= RH_A_NOCP; | 1759 | roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); |
1770 | roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); | 1760 | retval = u132_write_pcimem(u132, roothub.a, roothub_a); |
1771 | retval = u132_write_pcimem(u132, roothub.a, roothub_a); | 1761 | if (retval) |
1772 | if (retval) | 1762 | return retval; |
1773 | return retval; | 1763 | } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { |
1774 | } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { | 1764 | roothub_a |= RH_A_NPS; |
1775 | roothub_a |= RH_A_NPS; | 1765 | retval = u132_write_pcimem(u132, roothub.a, roothub_a); |
1776 | retval = u132_write_pcimem(u132, roothub.a, roothub_a); | 1766 | if (retval) |
1777 | if (retval) | 1767 | return retval; |
1778 | return retval; | 1768 | } |
1779 | } | 1769 | retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); |
1780 | retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); | 1770 | if (retval) |
1781 | if (retval) | 1771 | return retval; |
1782 | return retval; | 1772 | retval = u132_write_pcimem(u132, roothub.b, |
1783 | retval = u132_write_pcimem(u132, roothub.b, | 1773 | (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); |
1784 | (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); | 1774 | if (retval) |
1785 | if (retval) | 1775 | return retval; |
1786 | return retval; | 1776 | retval = u132_read_pcimem(u132, control, &control); |
1787 | retval = u132_read_pcimem(u132, control, &control); | 1777 | if (retval) |
1788 | if (retval) | 1778 | return retval; |
1789 | return retval; | 1779 | mdelay((roothub_a >> 23) & 0x1fe); |
1790 | mdelay((roothub_a >> 23) & 0x1fe); | 1780 | u132_to_hcd(u132)->state = HC_STATE_RUNNING; |
1791 | u132_to_hcd(u132)->state = HC_STATE_RUNNING; | 1781 | return 0; |
1792 | return 0; | ||
1793 | } | 1782 | } |
1794 | 1783 | ||
1795 | static void u132_hcd_stop(struct usb_hcd *hcd) | 1784 | static void u132_hcd_stop(struct usb_hcd *hcd) |
1796 | { | 1785 | { |
1797 | struct u132 *u132 = hcd_to_u132(hcd); | 1786 | struct u132 *u132 = hcd_to_u132(hcd); |
1798 | if (u132->going > 1) { | 1787 | if (u132->going > 1) { |
1799 | dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b" | 1788 | dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b" |
1800 | "een removed %d\n", u132, hcd, u132->going); | 1789 | "een removed %d\n", u132, hcd, u132->going); |
1801 | } else if (u132->going > 0) { | 1790 | } else if (u132->going > 0) { |
1802 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" | 1791 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" |
1803 | "ed\n", hcd); | 1792 | "ed\n", hcd); |
1804 | } else { | 1793 | } else { |
1805 | mutex_lock(&u132->sw_lock); | 1794 | mutex_lock(&u132->sw_lock); |
1806 | msleep(100); | 1795 | msleep(100); |
1807 | u132_power(u132, 0); | 1796 | u132_power(u132, 0); |
1808 | mutex_unlock(&u132->sw_lock); | 1797 | mutex_unlock(&u132->sw_lock); |
1809 | } | 1798 | } |
1810 | } | 1799 | } |
1811 | 1800 | ||
1812 | static int u132_hcd_start(struct usb_hcd *hcd) | 1801 | static int u132_hcd_start(struct usb_hcd *hcd) |
1813 | { | 1802 | { |
1814 | struct u132 *u132 = hcd_to_u132(hcd); | 1803 | struct u132 *u132 = hcd_to_u132(hcd); |
1815 | if (u132->going > 1) { | 1804 | if (u132->going > 1) { |
1816 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1805 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1817 | , u132->going); | 1806 | , u132->going); |
1818 | return -ENODEV; | 1807 | return -ENODEV; |
1819 | } else if (u132->going > 0) { | 1808 | } else if (u132->going > 0) { |
1820 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 1809 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
1821 | return -ESHUTDOWN; | 1810 | return -ESHUTDOWN; |
1822 | } else if (hcd->self.controller) { | 1811 | } else if (hcd->self.controller) { |
1823 | int retval; | 1812 | int retval; |
1824 | struct platform_device *pdev = | 1813 | struct platform_device *pdev = |
1825 | to_platform_device(hcd->self.controller); | 1814 | to_platform_device(hcd->self.controller); |
1826 | u16 vendor = ((struct u132_platform_data *) | 1815 | u16 vendor = ((struct u132_platform_data *) |
1827 | (pdev->dev.platform_data))->vendor; | 1816 | (pdev->dev.platform_data))->vendor; |
1828 | u16 device = ((struct u132_platform_data *) | 1817 | u16 device = ((struct u132_platform_data *) |
1829 | (pdev->dev.platform_data))->device; | 1818 | (pdev->dev.platform_data))->device; |
1830 | mutex_lock(&u132->sw_lock); | 1819 | mutex_lock(&u132->sw_lock); |
1831 | msleep(10); | 1820 | msleep(10); |
1832 | if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { | 1821 | if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { |
1833 | u132->flags = OHCI_QUIRK_AMD756; | 1822 | u132->flags = OHCI_QUIRK_AMD756; |
1834 | } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { | 1823 | } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { |
1835 | dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" | 1824 | dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" |
1836 | "ounds unavailable\n"); | 1825 | "ounds unavailable\n"); |
1837 | } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) | 1826 | } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) |
1838 | u132->flags |= OHCI_QUIRK_ZFMICRO; | 1827 | u132->flags |= OHCI_QUIRK_ZFMICRO; |
1839 | retval = u132_run(u132); | 1828 | retval = u132_run(u132); |
1840 | if (retval) { | 1829 | if (retval) { |
1841 | u132_disable(u132); | 1830 | u132_disable(u132); |
1842 | u132->going = 1; | 1831 | u132->going = 1; |
1843 | } | 1832 | } |
1844 | msleep(100); | 1833 | msleep(100); |
1845 | mutex_unlock(&u132->sw_lock); | 1834 | mutex_unlock(&u132->sw_lock); |
1846 | return retval; | 1835 | return retval; |
1847 | } else { | 1836 | } else { |
1848 | dev_err(&u132->platform_dev->dev, "platform_device missing\n"); | 1837 | dev_err(&u132->platform_dev->dev, "platform_device missing\n"); |
1849 | return -ENODEV; | 1838 | return -ENODEV; |
1850 | } | 1839 | } |
1851 | } | 1840 | } |
1852 | 1841 | ||
1853 | static int u132_hcd_reset(struct usb_hcd *hcd) | 1842 | static int u132_hcd_reset(struct usb_hcd *hcd) |
1854 | { | 1843 | { |
1855 | struct u132 *u132 = hcd_to_u132(hcd); | 1844 | struct u132 *u132 = hcd_to_u132(hcd); |
1856 | if (u132->going > 1) { | 1845 | if (u132->going > 1) { |
1857 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 1846 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
1858 | , u132->going); | 1847 | , u132->going); |
1859 | return -ENODEV; | 1848 | return -ENODEV; |
1860 | } else if (u132->going > 0) { | 1849 | } else if (u132->going > 0) { |
1861 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 1850 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
1862 | return -ESHUTDOWN; | 1851 | return -ESHUTDOWN; |
1863 | } else { | 1852 | } else { |
1864 | int retval; | 1853 | int retval; |
1865 | mutex_lock(&u132->sw_lock); | 1854 | mutex_lock(&u132->sw_lock); |
1866 | retval = u132_init(u132); | 1855 | retval = u132_init(u132); |
1867 | if (retval) { | 1856 | if (retval) { |
1868 | u132_disable(u132); | 1857 | u132_disable(u132); |
1869 | u132->going = 1; | 1858 | u132->going = 1; |
1870 | } | 1859 | } |
1871 | mutex_unlock(&u132->sw_lock); | 1860 | mutex_unlock(&u132->sw_lock); |
1872 | return retval; | 1861 | return retval; |
1873 | } | 1862 | } |
1874 | } | 1863 | } |
1875 | 1864 | ||
1876 | static int create_endpoint_and_queue_int(struct u132 *u132, | 1865 | static int create_endpoint_and_queue_int(struct u132 *u132, |
1877 | struct u132_udev *udev, struct urb *urb, | 1866 | struct u132_udev *udev, struct urb *urb, |
1878 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, | 1867 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, |
1879 | gfp_t mem_flags) | 1868 | gfp_t mem_flags) |
1880 | { | 1869 | { |
1881 | struct u132_ring *ring; | 1870 | struct u132_ring *ring; |
1882 | unsigned long irqs; | 1871 | unsigned long irqs; |
1883 | int rc; | 1872 | int rc; |
1884 | u8 endp_number; | 1873 | u8 endp_number; |
1885 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); | 1874 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); |
1886 | 1875 | ||
1887 | if (!endp) { | 1876 | if (!endp) |
1888 | return -ENOMEM; | 1877 | return -ENOMEM; |
1889 | } | ||
1890 | 1878 | ||
1891 | spin_lock_init(&endp->queue_lock.slock); | 1879 | spin_lock_init(&endp->queue_lock.slock); |
1892 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 1880 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
@@ -1899,94 +1887,93 @@ static int create_endpoint_and_queue_int(struct u132 *u132, | |||
1899 | 1887 | ||
1900 | endp_number = ++u132->num_endpoints; | 1888 | endp_number = ++u132->num_endpoints; |
1901 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; | 1889 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; |
1902 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); | 1890 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); |
1903 | INIT_LIST_HEAD(&endp->urb_more); | 1891 | INIT_LIST_HEAD(&endp->urb_more); |
1904 | ring = endp->ring = &u132->ring[0]; | 1892 | ring = endp->ring = &u132->ring[0]; |
1905 | if (ring->curr_endp) { | 1893 | if (ring->curr_endp) { |
1906 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); | 1894 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); |
1907 | } else { | 1895 | } else { |
1908 | INIT_LIST_HEAD(&endp->endp_ring); | 1896 | INIT_LIST_HEAD(&endp->endp_ring); |
1909 | ring->curr_endp = endp; | 1897 | ring->curr_endp = endp; |
1910 | } | 1898 | } |
1911 | ring->length += 1; | 1899 | ring->length += 1; |
1912 | endp->dequeueing = 0; | 1900 | endp->dequeueing = 0; |
1913 | endp->edset_flush = 0; | 1901 | endp->edset_flush = 0; |
1914 | endp->active = 0; | 1902 | endp->active = 0; |
1915 | endp->delayed = 0; | 1903 | endp->delayed = 0; |
1916 | endp->endp_number = endp_number; | 1904 | endp->endp_number = endp_number; |
1917 | endp->u132 = u132; | 1905 | endp->u132 = u132; |
1918 | endp->hep = urb->ep; | 1906 | endp->hep = urb->ep; |
1919 | endp->pipetype = usb_pipetype(urb->pipe); | 1907 | endp->pipetype = usb_pipetype(urb->pipe); |
1920 | u132_endp_init_kref(u132, endp); | 1908 | u132_endp_init_kref(u132, endp); |
1921 | if (usb_pipein(urb->pipe)) { | 1909 | if (usb_pipein(urb->pipe)) { |
1922 | endp->toggle_bits = 0x2; | 1910 | endp->toggle_bits = 0x2; |
1923 | usb_settoggle(udev->usb_device, usb_endp, 0, 0); | 1911 | usb_settoggle(udev->usb_device, usb_endp, 0, 0); |
1924 | endp->input = 1; | 1912 | endp->input = 1; |
1925 | endp->output = 0; | 1913 | endp->output = 0; |
1926 | udev->endp_number_in[usb_endp] = endp_number; | 1914 | udev->endp_number_in[usb_endp] = endp_number; |
1927 | u132_udev_get_kref(u132, udev); | 1915 | u132_udev_get_kref(u132, udev); |
1928 | } else { | 1916 | } else { |
1929 | endp->toggle_bits = 0x2; | 1917 | endp->toggle_bits = 0x2; |
1930 | usb_settoggle(udev->usb_device, usb_endp, 1, 0); | 1918 | usb_settoggle(udev->usb_device, usb_endp, 1, 0); |
1931 | endp->input = 0; | 1919 | endp->input = 0; |
1932 | endp->output = 1; | 1920 | endp->output = 1; |
1933 | udev->endp_number_out[usb_endp] = endp_number; | 1921 | udev->endp_number_out[usb_endp] = endp_number; |
1934 | u132_udev_get_kref(u132, udev); | 1922 | u132_udev_get_kref(u132, udev); |
1935 | } | 1923 | } |
1936 | urb->hcpriv = u132; | 1924 | urb->hcpriv = u132; |
1937 | endp->delayed = 1; | 1925 | endp->delayed = 1; |
1938 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); | 1926 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); |
1939 | endp->udev_number = address; | 1927 | endp->udev_number = address; |
1940 | endp->usb_addr = usb_addr; | 1928 | endp->usb_addr = usb_addr; |
1941 | endp->usb_endp = usb_endp; | 1929 | endp->usb_endp = usb_endp; |
1942 | endp->queue_size = 1; | 1930 | endp->queue_size = 1; |
1943 | endp->queue_last = 0; | 1931 | endp->queue_last = 0; |
1944 | endp->queue_next = 0; | 1932 | endp->queue_next = 0; |
1945 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | 1933 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; |
1946 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 1934 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
1947 | u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); | 1935 | u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); |
1948 | return 0; | 1936 | return 0; |
1949 | } | 1937 | } |
1950 | 1938 | ||
1951 | static int queue_int_on_old_endpoint(struct u132 *u132, | 1939 | static int queue_int_on_old_endpoint(struct u132 *u132, |
1952 | struct u132_udev *udev, struct urb *urb, | 1940 | struct u132_udev *udev, struct urb *urb, |
1953 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | 1941 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, |
1954 | u8 usb_endp, u8 address) | 1942 | u8 usb_endp, u8 address) |
1955 | { | 1943 | { |
1956 | urb->hcpriv = u132; | 1944 | urb->hcpriv = u132; |
1957 | endp->delayed = 1; | 1945 | endp->delayed = 1; |
1958 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); | 1946 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); |
1959 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | 1947 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { |
1960 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | 1948 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; |
1961 | } else { | 1949 | } else { |
1962 | struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), | 1950 | struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), |
1963 | GFP_ATOMIC); | 1951 | GFP_ATOMIC); |
1964 | if (urbq == NULL) { | 1952 | if (urbq == NULL) { |
1965 | endp->queue_size -= 1; | 1953 | endp->queue_size -= 1; |
1966 | return -ENOMEM; | 1954 | return -ENOMEM; |
1967 | } else { | 1955 | } else { |
1968 | list_add_tail(&urbq->urb_more, &endp->urb_more); | 1956 | list_add_tail(&urbq->urb_more, &endp->urb_more); |
1969 | urbq->urb = urb; | 1957 | urbq->urb = urb; |
1970 | } | 1958 | } |
1971 | } | 1959 | } |
1972 | return 0; | 1960 | return 0; |
1973 | } | 1961 | } |
1974 | 1962 | ||
1975 | static int create_endpoint_and_queue_bulk(struct u132 *u132, | 1963 | static int create_endpoint_and_queue_bulk(struct u132 *u132, |
1976 | struct u132_udev *udev, struct urb *urb, | 1964 | struct u132_udev *udev, struct urb *urb, |
1977 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, | 1965 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, |
1978 | gfp_t mem_flags) | 1966 | gfp_t mem_flags) |
1979 | { | 1967 | { |
1980 | int ring_number; | 1968 | int ring_number; |
1981 | struct u132_ring *ring; | 1969 | struct u132_ring *ring; |
1982 | unsigned long irqs; | 1970 | unsigned long irqs; |
1983 | int rc; | 1971 | int rc; |
1984 | u8 endp_number; | 1972 | u8 endp_number; |
1985 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); | 1973 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); |
1986 | 1974 | ||
1987 | if (!endp) { | 1975 | if (!endp) |
1988 | return -ENOMEM; | 1976 | return -ENOMEM; |
1989 | } | ||
1990 | 1977 | ||
1991 | spin_lock_init(&endp->queue_lock.slock); | 1978 | spin_lock_init(&endp->queue_lock.slock); |
1992 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 1979 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
@@ -1999,91 +1986,90 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132, | |||
1999 | 1986 | ||
2000 | endp_number = ++u132->num_endpoints; | 1987 | endp_number = ++u132->num_endpoints; |
2001 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; | 1988 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; |
2002 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); | 1989 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); |
2003 | INIT_LIST_HEAD(&endp->urb_more); | 1990 | INIT_LIST_HEAD(&endp->urb_more); |
2004 | endp->dequeueing = 0; | 1991 | endp->dequeueing = 0; |
2005 | endp->edset_flush = 0; | 1992 | endp->edset_flush = 0; |
2006 | endp->active = 0; | 1993 | endp->active = 0; |
2007 | endp->delayed = 0; | 1994 | endp->delayed = 0; |
2008 | endp->endp_number = endp_number; | 1995 | endp->endp_number = endp_number; |
2009 | endp->u132 = u132; | 1996 | endp->u132 = u132; |
2010 | endp->hep = urb->ep; | 1997 | endp->hep = urb->ep; |
2011 | endp->pipetype = usb_pipetype(urb->pipe); | 1998 | endp->pipetype = usb_pipetype(urb->pipe); |
2012 | u132_endp_init_kref(u132, endp); | 1999 | u132_endp_init_kref(u132, endp); |
2013 | if (usb_pipein(urb->pipe)) { | 2000 | if (usb_pipein(urb->pipe)) { |
2014 | endp->toggle_bits = 0x2; | 2001 | endp->toggle_bits = 0x2; |
2015 | usb_settoggle(udev->usb_device, usb_endp, 0, 0); | 2002 | usb_settoggle(udev->usb_device, usb_endp, 0, 0); |
2016 | ring_number = 3; | 2003 | ring_number = 3; |
2017 | endp->input = 1; | 2004 | endp->input = 1; |
2018 | endp->output = 0; | 2005 | endp->output = 0; |
2019 | udev->endp_number_in[usb_endp] = endp_number; | 2006 | udev->endp_number_in[usb_endp] = endp_number; |
2020 | u132_udev_get_kref(u132, udev); | 2007 | u132_udev_get_kref(u132, udev); |
2021 | } else { | 2008 | } else { |
2022 | endp->toggle_bits = 0x2; | 2009 | endp->toggle_bits = 0x2; |
2023 | usb_settoggle(udev->usb_device, usb_endp, 1, 0); | 2010 | usb_settoggle(udev->usb_device, usb_endp, 1, 0); |
2024 | ring_number = 2; | 2011 | ring_number = 2; |
2025 | endp->input = 0; | 2012 | endp->input = 0; |
2026 | endp->output = 1; | 2013 | endp->output = 1; |
2027 | udev->endp_number_out[usb_endp] = endp_number; | 2014 | udev->endp_number_out[usb_endp] = endp_number; |
2028 | u132_udev_get_kref(u132, udev); | 2015 | u132_udev_get_kref(u132, udev); |
2029 | } | 2016 | } |
2030 | ring = endp->ring = &u132->ring[ring_number - 1]; | 2017 | ring = endp->ring = &u132->ring[ring_number - 1]; |
2031 | if (ring->curr_endp) { | 2018 | if (ring->curr_endp) { |
2032 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); | 2019 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); |
2033 | } else { | 2020 | } else { |
2034 | INIT_LIST_HEAD(&endp->endp_ring); | 2021 | INIT_LIST_HEAD(&endp->endp_ring); |
2035 | ring->curr_endp = endp; | 2022 | ring->curr_endp = endp; |
2036 | } | 2023 | } |
2037 | ring->length += 1; | 2024 | ring->length += 1; |
2038 | urb->hcpriv = u132; | 2025 | urb->hcpriv = u132; |
2039 | endp->udev_number = address; | 2026 | endp->udev_number = address; |
2040 | endp->usb_addr = usb_addr; | 2027 | endp->usb_addr = usb_addr; |
2041 | endp->usb_endp = usb_endp; | 2028 | endp->usb_endp = usb_endp; |
2042 | endp->queue_size = 1; | 2029 | endp->queue_size = 1; |
2043 | endp->queue_last = 0; | 2030 | endp->queue_last = 0; |
2044 | endp->queue_next = 0; | 2031 | endp->queue_next = 0; |
2045 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | 2032 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; |
2046 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2033 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2047 | u132_endp_queue_work(u132, endp, 0); | 2034 | u132_endp_queue_work(u132, endp, 0); |
2048 | return 0; | 2035 | return 0; |
2049 | } | 2036 | } |
2050 | 2037 | ||
2051 | static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, | 2038 | static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, |
2052 | struct urb *urb, | 2039 | struct urb *urb, |
2053 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | 2040 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, |
2054 | u8 usb_endp, u8 address) | 2041 | u8 usb_endp, u8 address) |
2055 | { | 2042 | { |
2056 | urb->hcpriv = u132; | 2043 | urb->hcpriv = u132; |
2057 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | 2044 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { |
2058 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | 2045 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; |
2059 | } else { | 2046 | } else { |
2060 | struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), | 2047 | struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), |
2061 | GFP_ATOMIC); | 2048 | GFP_ATOMIC); |
2062 | if (urbq == NULL) { | 2049 | if (urbq == NULL) { |
2063 | endp->queue_size -= 1; | 2050 | endp->queue_size -= 1; |
2064 | return -ENOMEM; | 2051 | return -ENOMEM; |
2065 | } else { | 2052 | } else { |
2066 | list_add_tail(&urbq->urb_more, &endp->urb_more); | 2053 | list_add_tail(&urbq->urb_more, &endp->urb_more); |
2067 | urbq->urb = urb; | 2054 | urbq->urb = urb; |
2068 | } | 2055 | } |
2069 | } | 2056 | } |
2070 | return 0; | 2057 | return 0; |
2071 | } | 2058 | } |
2072 | 2059 | ||
2073 | static int create_endpoint_and_queue_control(struct u132 *u132, | 2060 | static int create_endpoint_and_queue_control(struct u132 *u132, |
2074 | struct urb *urb, | 2061 | struct urb *urb, |
2075 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, | 2062 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, |
2076 | gfp_t mem_flags) | 2063 | gfp_t mem_flags) |
2077 | { | 2064 | { |
2078 | struct u132_ring *ring; | 2065 | struct u132_ring *ring; |
2079 | unsigned long irqs; | 2066 | unsigned long irqs; |
2080 | int rc; | 2067 | int rc; |
2081 | u8 endp_number; | 2068 | u8 endp_number; |
2082 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); | 2069 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); |
2083 | 2070 | ||
2084 | if (!endp) { | 2071 | if (!endp) |
2085 | return -ENOMEM; | 2072 | return -ENOMEM; |
2086 | } | ||
2087 | 2073 | ||
2088 | spin_lock_init(&endp->queue_lock.slock); | 2074 | spin_lock_init(&endp->queue_lock.slock); |
2089 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 2075 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
@@ -2096,204 +2082,203 @@ static int create_endpoint_and_queue_control(struct u132 *u132, | |||
2096 | 2082 | ||
2097 | endp_number = ++u132->num_endpoints; | 2083 | endp_number = ++u132->num_endpoints; |
2098 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; | 2084 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; |
2099 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); | 2085 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); |
2100 | INIT_LIST_HEAD(&endp->urb_more); | 2086 | INIT_LIST_HEAD(&endp->urb_more); |
2101 | ring = endp->ring = &u132->ring[0]; | 2087 | ring = endp->ring = &u132->ring[0]; |
2102 | if (ring->curr_endp) { | 2088 | if (ring->curr_endp) { |
2103 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); | 2089 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); |
2104 | } else { | 2090 | } else { |
2105 | INIT_LIST_HEAD(&endp->endp_ring); | 2091 | INIT_LIST_HEAD(&endp->endp_ring); |
2106 | ring->curr_endp = endp; | 2092 | ring->curr_endp = endp; |
2107 | } | 2093 | } |
2108 | ring->length += 1; | 2094 | ring->length += 1; |
2109 | endp->dequeueing = 0; | 2095 | endp->dequeueing = 0; |
2110 | endp->edset_flush = 0; | 2096 | endp->edset_flush = 0; |
2111 | endp->active = 0; | 2097 | endp->active = 0; |
2112 | endp->delayed = 0; | 2098 | endp->delayed = 0; |
2113 | endp->endp_number = endp_number; | 2099 | endp->endp_number = endp_number; |
2114 | endp->u132 = u132; | 2100 | endp->u132 = u132; |
2115 | endp->hep = urb->ep; | 2101 | endp->hep = urb->ep; |
2116 | u132_endp_init_kref(u132, endp); | 2102 | u132_endp_init_kref(u132, endp); |
2117 | u132_endp_get_kref(u132, endp); | 2103 | u132_endp_get_kref(u132, endp); |
2118 | if (usb_addr == 0) { | 2104 | if (usb_addr == 0) { |
2119 | u8 address = u132->addr[usb_addr].address; | 2105 | u8 address = u132->addr[usb_addr].address; |
2120 | struct u132_udev *udev = &u132->udev[address]; | 2106 | struct u132_udev *udev = &u132->udev[address]; |
2121 | endp->udev_number = address; | 2107 | endp->udev_number = address; |
2122 | endp->usb_addr = usb_addr; | 2108 | endp->usb_addr = usb_addr; |
2123 | endp->usb_endp = usb_endp; | 2109 | endp->usb_endp = usb_endp; |
2124 | endp->input = 1; | 2110 | endp->input = 1; |
2125 | endp->output = 1; | 2111 | endp->output = 1; |
2126 | endp->pipetype = usb_pipetype(urb->pipe); | 2112 | endp->pipetype = usb_pipetype(urb->pipe); |
2127 | u132_udev_init_kref(u132, udev); | 2113 | u132_udev_init_kref(u132, udev); |
2128 | u132_udev_get_kref(u132, udev); | 2114 | u132_udev_get_kref(u132, udev); |
2129 | udev->endp_number_in[usb_endp] = endp_number; | 2115 | udev->endp_number_in[usb_endp] = endp_number; |
2130 | udev->endp_number_out[usb_endp] = endp_number; | 2116 | udev->endp_number_out[usb_endp] = endp_number; |
2131 | urb->hcpriv = u132; | 2117 | urb->hcpriv = u132; |
2132 | endp->queue_size = 1; | 2118 | endp->queue_size = 1; |
2133 | endp->queue_last = 0; | 2119 | endp->queue_last = 0; |
2134 | endp->queue_next = 0; | 2120 | endp->queue_next = 0; |
2135 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | 2121 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; |
2136 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2122 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2137 | u132_endp_queue_work(u132, endp, 0); | 2123 | u132_endp_queue_work(u132, endp, 0); |
2138 | return 0; | 2124 | return 0; |
2139 | } else { /*(usb_addr > 0) */ | 2125 | } else { /*(usb_addr > 0) */ |
2140 | u8 address = u132->addr[usb_addr].address; | 2126 | u8 address = u132->addr[usb_addr].address; |
2141 | struct u132_udev *udev = &u132->udev[address]; | 2127 | struct u132_udev *udev = &u132->udev[address]; |
2142 | endp->udev_number = address; | 2128 | endp->udev_number = address; |
2143 | endp->usb_addr = usb_addr; | 2129 | endp->usb_addr = usb_addr; |
2144 | endp->usb_endp = usb_endp; | 2130 | endp->usb_endp = usb_endp; |
2145 | endp->input = 1; | 2131 | endp->input = 1; |
2146 | endp->output = 1; | 2132 | endp->output = 1; |
2147 | endp->pipetype = usb_pipetype(urb->pipe); | 2133 | endp->pipetype = usb_pipetype(urb->pipe); |
2148 | u132_udev_get_kref(u132, udev); | 2134 | u132_udev_get_kref(u132, udev); |
2149 | udev->enumeration = 2; | 2135 | udev->enumeration = 2; |
2150 | udev->endp_number_in[usb_endp] = endp_number; | 2136 | udev->endp_number_in[usb_endp] = endp_number; |
2151 | udev->endp_number_out[usb_endp] = endp_number; | 2137 | udev->endp_number_out[usb_endp] = endp_number; |
2152 | urb->hcpriv = u132; | 2138 | urb->hcpriv = u132; |
2153 | endp->queue_size = 1; | 2139 | endp->queue_size = 1; |
2154 | endp->queue_last = 0; | 2140 | endp->queue_last = 0; |
2155 | endp->queue_next = 0; | 2141 | endp->queue_next = 0; |
2156 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | 2142 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; |
2157 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2143 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2158 | u132_endp_queue_work(u132, endp, 0); | 2144 | u132_endp_queue_work(u132, endp, 0); |
2159 | return 0; | 2145 | return 0; |
2160 | } | 2146 | } |
2161 | } | 2147 | } |
2162 | 2148 | ||
2163 | static int queue_control_on_old_endpoint(struct u132 *u132, | 2149 | static int queue_control_on_old_endpoint(struct u132 *u132, |
2164 | struct urb *urb, | 2150 | struct urb *urb, |
2165 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | 2151 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, |
2166 | u8 usb_endp) | 2152 | u8 usb_endp) |
2167 | { | 2153 | { |
2168 | if (usb_addr == 0) { | 2154 | if (usb_addr == 0) { |
2169 | if (usb_pipein(urb->pipe)) { | 2155 | if (usb_pipein(urb->pipe)) { |
2170 | urb->hcpriv = u132; | 2156 | urb->hcpriv = u132; |
2171 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | 2157 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { |
2172 | endp->urb_list[ENDP_QUEUE_MASK & | 2158 | endp->urb_list[ENDP_QUEUE_MASK & |
2173 | endp->queue_last++] = urb; | 2159 | endp->queue_last++] = urb; |
2174 | } else { | 2160 | } else { |
2175 | struct u132_urbq *urbq = | 2161 | struct u132_urbq *urbq = |
2176 | kmalloc(sizeof(struct u132_urbq), | 2162 | kmalloc(sizeof(struct u132_urbq), |
2177 | GFP_ATOMIC); | 2163 | GFP_ATOMIC); |
2178 | if (urbq == NULL) { | 2164 | if (urbq == NULL) { |
2179 | endp->queue_size -= 1; | 2165 | endp->queue_size -= 1; |
2180 | return -ENOMEM; | 2166 | return -ENOMEM; |
2181 | } else { | 2167 | } else { |
2182 | list_add_tail(&urbq->urb_more, | 2168 | list_add_tail(&urbq->urb_more, |
2183 | &endp->urb_more); | 2169 | &endp->urb_more); |
2184 | urbq->urb = urb; | 2170 | urbq->urb = urb; |
2185 | } | 2171 | } |
2186 | } | 2172 | } |
2187 | return 0; | 2173 | return 0; |
2188 | } else { /* usb_pipeout(urb->pipe) */ | 2174 | } else { /* usb_pipeout(urb->pipe) */ |
2189 | struct u132_addr *addr = &u132->addr[usb_dev->devnum]; | 2175 | struct u132_addr *addr = &u132->addr[usb_dev->devnum]; |
2190 | int I = MAX_U132_UDEVS; | 2176 | int I = MAX_U132_UDEVS; |
2191 | int i = 0; | 2177 | int i = 0; |
2192 | while (--I > 0) { | 2178 | while (--I > 0) { |
2193 | struct u132_udev *udev = &u132->udev[++i]; | 2179 | struct u132_udev *udev = &u132->udev[++i]; |
2194 | if (udev->usb_device) { | 2180 | if (udev->usb_device) { |
2195 | continue; | 2181 | continue; |
2196 | } else { | 2182 | } else { |
2197 | udev->enumeration = 1; | 2183 | udev->enumeration = 1; |
2198 | u132->addr[0].address = i; | 2184 | u132->addr[0].address = i; |
2199 | endp->udev_number = i; | 2185 | endp->udev_number = i; |
2200 | udev->udev_number = i; | 2186 | udev->udev_number = i; |
2201 | udev->usb_addr = usb_dev->devnum; | 2187 | udev->usb_addr = usb_dev->devnum; |
2202 | u132_udev_init_kref(u132, udev); | 2188 | u132_udev_init_kref(u132, udev); |
2203 | udev->endp_number_in[usb_endp] = | 2189 | udev->endp_number_in[usb_endp] = |
2204 | endp->endp_number; | 2190 | endp->endp_number; |
2205 | u132_udev_get_kref(u132, udev); | 2191 | u132_udev_get_kref(u132, udev); |
2206 | udev->endp_number_out[usb_endp] = | 2192 | udev->endp_number_out[usb_endp] = |
2207 | endp->endp_number; | 2193 | endp->endp_number; |
2208 | udev->usb_device = usb_dev; | 2194 | udev->usb_device = usb_dev; |
2209 | ((u8 *) (urb->setup_packet))[2] = | 2195 | ((u8 *) (urb->setup_packet))[2] = |
2210 | addr->address = i; | 2196 | addr->address = i; |
2211 | u132_udev_get_kref(u132, udev); | 2197 | u132_udev_get_kref(u132, udev); |
2212 | break; | 2198 | break; |
2213 | } | 2199 | } |
2214 | } | 2200 | } |
2215 | if (I == 0) { | 2201 | if (I == 0) { |
2216 | dev_err(&u132->platform_dev->dev, "run out of d" | 2202 | dev_err(&u132->platform_dev->dev, "run out of d" |
2217 | "evice space\n"); | 2203 | "evice space\n"); |
2218 | return -EINVAL; | 2204 | return -EINVAL; |
2219 | } | 2205 | } |
2220 | urb->hcpriv = u132; | 2206 | urb->hcpriv = u132; |
2221 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | 2207 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { |
2222 | endp->urb_list[ENDP_QUEUE_MASK & | 2208 | endp->urb_list[ENDP_QUEUE_MASK & |
2223 | endp->queue_last++] = urb; | 2209 | endp->queue_last++] = urb; |
2224 | } else { | 2210 | } else { |
2225 | struct u132_urbq *urbq = | 2211 | struct u132_urbq *urbq = |
2226 | kmalloc(sizeof(struct u132_urbq), | 2212 | kmalloc(sizeof(struct u132_urbq), |
2227 | GFP_ATOMIC); | 2213 | GFP_ATOMIC); |
2228 | if (urbq == NULL) { | 2214 | if (urbq == NULL) { |
2229 | endp->queue_size -= 1; | 2215 | endp->queue_size -= 1; |
2230 | return -ENOMEM; | 2216 | return -ENOMEM; |
2231 | } else { | 2217 | } else { |
2232 | list_add_tail(&urbq->urb_more, | 2218 | list_add_tail(&urbq->urb_more, |
2233 | &endp->urb_more); | 2219 | &endp->urb_more); |
2234 | urbq->urb = urb; | 2220 | urbq->urb = urb; |
2235 | } | 2221 | } |
2236 | } | 2222 | } |
2237 | return 0; | 2223 | return 0; |
2238 | } | 2224 | } |
2239 | } else { /*(usb_addr > 0) */ | 2225 | } else { /*(usb_addr > 0) */ |
2240 | u8 address = u132->addr[usb_addr].address; | 2226 | u8 address = u132->addr[usb_addr].address; |
2241 | struct u132_udev *udev = &u132->udev[address]; | 2227 | struct u132_udev *udev = &u132->udev[address]; |
2242 | urb->hcpriv = u132; | 2228 | urb->hcpriv = u132; |
2243 | if (udev->enumeration == 2) { | 2229 | if (udev->enumeration != 2) |
2244 | } else | 2230 | udev->enumeration = 2; |
2245 | udev->enumeration = 2; | 2231 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { |
2246 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | 2232 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = |
2247 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = | 2233 | urb; |
2248 | urb; | 2234 | } else { |
2249 | } else { | 2235 | struct u132_urbq *urbq = |
2250 | struct u132_urbq *urbq = | 2236 | kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); |
2251 | kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); | 2237 | if (urbq == NULL) { |
2252 | if (urbq == NULL) { | 2238 | endp->queue_size -= 1; |
2253 | endp->queue_size -= 1; | 2239 | return -ENOMEM; |
2254 | return -ENOMEM; | 2240 | } else { |
2255 | } else { | 2241 | list_add_tail(&urbq->urb_more, &endp->urb_more); |
2256 | list_add_tail(&urbq->urb_more, &endp->urb_more); | 2242 | urbq->urb = urb; |
2257 | urbq->urb = urb; | 2243 | } |
2258 | } | 2244 | } |
2259 | } | 2245 | return 0; |
2260 | return 0; | 2246 | } |
2261 | } | ||
2262 | } | 2247 | } |
2263 | 2248 | ||
2264 | static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | 2249 | static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, |
2265 | gfp_t mem_flags) | 2250 | gfp_t mem_flags) |
2266 | { | 2251 | { |
2267 | struct u132 *u132 = hcd_to_u132(hcd); | 2252 | struct u132 *u132 = hcd_to_u132(hcd); |
2268 | if (irqs_disabled()) { | 2253 | if (irqs_disabled()) { |
2269 | if (__GFP_WAIT & mem_flags) { | 2254 | if (__GFP_WAIT & mem_flags) { |
2270 | printk(KERN_ERR "invalid context for function that migh" | 2255 | printk(KERN_ERR "invalid context for function that migh" |
2271 | "t sleep\n"); | 2256 | "t sleep\n"); |
2272 | return -EINVAL; | 2257 | return -EINVAL; |
2273 | } | 2258 | } |
2274 | } | 2259 | } |
2275 | if (u132->going > 1) { | 2260 | if (u132->going > 1) { |
2276 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 2261 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
2277 | , u132->going); | 2262 | , u132->going); |
2278 | return -ENODEV; | 2263 | return -ENODEV; |
2279 | } else if (u132->going > 0) { | 2264 | } else if (u132->going > 0) { |
2280 | dev_err(&u132->platform_dev->dev, "device is being removed " | 2265 | dev_err(&u132->platform_dev->dev, "device is being removed " |
2281 | "urb=%p\n", urb); | 2266 | "urb=%p\n", urb); |
2282 | return -ESHUTDOWN; | 2267 | return -ESHUTDOWN; |
2283 | } else { | 2268 | } else { |
2284 | u8 usb_addr = usb_pipedevice(urb->pipe); | 2269 | u8 usb_addr = usb_pipedevice(urb->pipe); |
2285 | u8 usb_endp = usb_pipeendpoint(urb->pipe); | 2270 | u8 usb_endp = usb_pipeendpoint(urb->pipe); |
2286 | struct usb_device *usb_dev = urb->dev; | 2271 | struct usb_device *usb_dev = urb->dev; |
2287 | if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { | 2272 | if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { |
2288 | u8 address = u132->addr[usb_addr].address; | 2273 | u8 address = u132->addr[usb_addr].address; |
2289 | struct u132_udev *udev = &u132->udev[address]; | 2274 | struct u132_udev *udev = &u132->udev[address]; |
2290 | struct u132_endp *endp = urb->ep->hcpriv; | 2275 | struct u132_endp *endp = urb->ep->hcpriv; |
2291 | urb->actual_length = 0; | 2276 | urb->actual_length = 0; |
2292 | if (endp) { | 2277 | if (endp) { |
2293 | unsigned long irqs; | 2278 | unsigned long irqs; |
2294 | int retval; | 2279 | int retval; |
2295 | spin_lock_irqsave(&endp->queue_lock.slock, | 2280 | spin_lock_irqsave(&endp->queue_lock.slock, |
2296 | irqs); | 2281 | irqs); |
2297 | retval = usb_hcd_link_urb_to_ep(hcd, urb); | 2282 | retval = usb_hcd_link_urb_to_ep(hcd, urb); |
2298 | if (retval == 0) { | 2283 | if (retval == 0) { |
2299 | retval = queue_int_on_old_endpoint( | 2284 | retval = queue_int_on_old_endpoint( |
@@ -2303,39 +2288,39 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
2303 | address); | 2288 | address); |
2304 | if (retval) | 2289 | if (retval) |
2305 | usb_hcd_unlink_urb_from_ep( | 2290 | usb_hcd_unlink_urb_from_ep( |
2306 | hcd, urb); | 2291 | hcd, urb); |
2307 | } | 2292 | } |
2308 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2293 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
2309 | irqs); | 2294 | irqs); |
2310 | if (retval) { | 2295 | if (retval) { |
2311 | return retval; | 2296 | return retval; |
2312 | } else { | 2297 | } else { |
2313 | u132_endp_queue_work(u132, endp, | 2298 | u132_endp_queue_work(u132, endp, |
2314 | msecs_to_jiffies(urb->interval)) | 2299 | msecs_to_jiffies(urb->interval)) |
2315 | ; | 2300 | ; |
2316 | return 0; | 2301 | return 0; |
2317 | } | 2302 | } |
2318 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { | 2303 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { |
2319 | return -EINVAL; | 2304 | return -EINVAL; |
2320 | } else { /*(endp == NULL) */ | 2305 | } else { /*(endp == NULL) */ |
2321 | return create_endpoint_and_queue_int(u132, udev, | 2306 | return create_endpoint_and_queue_int(u132, udev, |
2322 | urb, usb_dev, usb_addr, | 2307 | urb, usb_dev, usb_addr, |
2323 | usb_endp, address, mem_flags); | 2308 | usb_endp, address, mem_flags); |
2324 | } | 2309 | } |
2325 | } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { | 2310 | } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { |
2326 | dev_err(&u132->platform_dev->dev, "the hardware does no" | 2311 | dev_err(&u132->platform_dev->dev, "the hardware does no" |
2327 | "t support PIPE_ISOCHRONOUS\n"); | 2312 | "t support PIPE_ISOCHRONOUS\n"); |
2328 | return -EINVAL; | 2313 | return -EINVAL; |
2329 | } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { | 2314 | } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { |
2330 | u8 address = u132->addr[usb_addr].address; | 2315 | u8 address = u132->addr[usb_addr].address; |
2331 | struct u132_udev *udev = &u132->udev[address]; | 2316 | struct u132_udev *udev = &u132->udev[address]; |
2332 | struct u132_endp *endp = urb->ep->hcpriv; | 2317 | struct u132_endp *endp = urb->ep->hcpriv; |
2333 | urb->actual_length = 0; | 2318 | urb->actual_length = 0; |
2334 | if (endp) { | 2319 | if (endp) { |
2335 | unsigned long irqs; | 2320 | unsigned long irqs; |
2336 | int retval; | 2321 | int retval; |
2337 | spin_lock_irqsave(&endp->queue_lock.slock, | 2322 | spin_lock_irqsave(&endp->queue_lock.slock, |
2338 | irqs); | 2323 | irqs); |
2339 | retval = usb_hcd_link_urb_to_ep(hcd, urb); | 2324 | retval = usb_hcd_link_urb_to_ep(hcd, urb); |
2340 | if (retval == 0) { | 2325 | if (retval == 0) { |
2341 | retval = queue_bulk_on_old_endpoint( | 2326 | retval = queue_bulk_on_old_endpoint( |
@@ -2345,46 +2330,46 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
2345 | address); | 2330 | address); |
2346 | if (retval) | 2331 | if (retval) |
2347 | usb_hcd_unlink_urb_from_ep( | 2332 | usb_hcd_unlink_urb_from_ep( |
2348 | hcd, urb); | 2333 | hcd, urb); |
2334 | } | ||
2335 | spin_unlock_irqrestore(&endp->queue_lock.slock, | ||
2336 | irqs); | ||
2337 | if (retval) { | ||
2338 | return retval; | ||
2339 | } else { | ||
2340 | u132_endp_queue_work(u132, endp, 0); | ||
2341 | return 0; | ||
2349 | } | 2342 | } |
2350 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2343 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { |
2351 | irqs); | 2344 | return -EINVAL; |
2352 | if (retval) { | 2345 | } else |
2353 | return retval; | 2346 | return create_endpoint_and_queue_bulk(u132, |
2354 | } else { | ||
2355 | u132_endp_queue_work(u132, endp, 0); | ||
2356 | return 0; | ||
2357 | } | ||
2358 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { | ||
2359 | return -EINVAL; | ||
2360 | } else | ||
2361 | return create_endpoint_and_queue_bulk(u132, | ||
2362 | udev, urb, usb_dev, usb_addr, | 2347 | udev, urb, usb_dev, usb_addr, |
2363 | usb_endp, address, mem_flags); | 2348 | usb_endp, address, mem_flags); |
2364 | } else { | 2349 | } else { |
2365 | struct u132_endp *endp = urb->ep->hcpriv; | 2350 | struct u132_endp *endp = urb->ep->hcpriv; |
2366 | u16 urb_size = 8; | 2351 | u16 urb_size = 8; |
2367 | u8 *b = urb->setup_packet; | 2352 | u8 *b = urb->setup_packet; |
2368 | int i = 0; | 2353 | int i = 0; |
2369 | char data[30 *3 + 4]; | 2354 | char data[30 * 3 + 4]; |
2370 | char *d = data; | 2355 | char *d = data; |
2371 | int m = (sizeof(data) - 1) / 3; | 2356 | int m = (sizeof(data) - 1) / 3; |
2372 | int l = 0; | 2357 | int l = 0; |
2373 | data[0] = 0; | 2358 | data[0] = 0; |
2374 | while (urb_size-- > 0) { | 2359 | while (urb_size-- > 0) { |
2375 | if (i > m) { | 2360 | if (i > m) { |
2376 | } else if (i++ < m) { | 2361 | } else if (i++ < m) { |
2377 | int w = sprintf(d, " %02X", *b++); | 2362 | int w = sprintf(d, " %02X", *b++); |
2378 | d += w; | 2363 | d += w; |
2379 | l += w; | 2364 | l += w; |
2380 | } else | 2365 | } else |
2381 | d += sprintf(d, " .."); | 2366 | d += sprintf(d, " .."); |
2382 | } | 2367 | } |
2383 | if (endp) { | 2368 | if (endp) { |
2384 | unsigned long irqs; | 2369 | unsigned long irqs; |
2385 | int retval; | 2370 | int retval; |
2386 | spin_lock_irqsave(&endp->queue_lock.slock, | 2371 | spin_lock_irqsave(&endp->queue_lock.slock, |
2387 | irqs); | 2372 | irqs); |
2388 | retval = usb_hcd_link_urb_to_ep(hcd, urb); | 2373 | retval = usb_hcd_link_urb_to_ep(hcd, urb); |
2389 | if (retval == 0) { | 2374 | if (retval == 0) { |
2390 | retval = queue_control_on_old_endpoint( | 2375 | retval = queue_control_on_old_endpoint( |
@@ -2395,267 +2380,267 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
2395 | usb_hcd_unlink_urb_from_ep( | 2380 | usb_hcd_unlink_urb_from_ep( |
2396 | hcd, urb); | 2381 | hcd, urb); |
2397 | } | 2382 | } |
2398 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2383 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
2399 | irqs); | 2384 | irqs); |
2400 | if (retval) { | 2385 | if (retval) { |
2401 | return retval; | 2386 | return retval; |
2402 | } else { | 2387 | } else { |
2403 | u132_endp_queue_work(u132, endp, 0); | 2388 | u132_endp_queue_work(u132, endp, 0); |
2404 | return 0; | 2389 | return 0; |
2405 | } | 2390 | } |
2406 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { | 2391 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { |
2407 | return -EINVAL; | 2392 | return -EINVAL; |
2408 | } else | 2393 | } else |
2409 | return create_endpoint_and_queue_control(u132, | 2394 | return create_endpoint_and_queue_control(u132, |
2410 | urb, usb_dev, usb_addr, usb_endp, | 2395 | urb, usb_dev, usb_addr, usb_endp, |
2411 | mem_flags); | 2396 | mem_flags); |
2412 | } | 2397 | } |
2413 | } | 2398 | } |
2414 | } | 2399 | } |
2415 | 2400 | ||
2416 | static int dequeue_from_overflow_chain(struct u132 *u132, | 2401 | static int dequeue_from_overflow_chain(struct u132 *u132, |
2417 | struct u132_endp *endp, struct urb *urb) | 2402 | struct u132_endp *endp, struct urb *urb) |
2418 | { | 2403 | { |
2419 | struct list_head *scan; | 2404 | struct list_head *scan; |
2420 | struct list_head *head = &endp->urb_more; | 2405 | struct list_head *head = &endp->urb_more; |
2421 | list_for_each(scan, head) { | 2406 | list_for_each(scan, head) { |
2422 | struct u132_urbq *urbq = list_entry(scan, struct u132_urbq, | 2407 | struct u132_urbq *urbq = list_entry(scan, struct u132_urbq, |
2423 | urb_more); | 2408 | urb_more); |
2424 | if (urbq->urb == urb) { | 2409 | if (urbq->urb == urb) { |
2425 | struct usb_hcd *hcd = u132_to_hcd(u132); | 2410 | struct usb_hcd *hcd = u132_to_hcd(u132); |
2426 | list_del(scan); | 2411 | list_del(scan); |
2427 | endp->queue_size -= 1; | 2412 | endp->queue_size -= 1; |
2428 | urb->error_count = 0; | 2413 | urb->error_count = 0; |
2429 | usb_hcd_giveback_urb(hcd, urb, 0); | 2414 | usb_hcd_giveback_urb(hcd, urb, 0); |
2430 | return 0; | 2415 | return 0; |
2431 | } else | 2416 | } else |
2432 | continue; | 2417 | continue; |
2433 | } | 2418 | } |
2434 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" | 2419 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" |
2435 | "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" | 2420 | "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" |
2436 | "\n", urb, endp->endp_number, endp, endp->ring->number, | 2421 | "\n", urb, endp->endp_number, endp, endp->ring->number, |
2437 | endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', | 2422 | endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', |
2438 | endp->usb_endp, endp->usb_addr, endp->queue_size, | 2423 | endp->usb_endp, endp->usb_addr, endp->queue_size, |
2439 | endp->queue_next, endp->queue_last); | 2424 | endp->queue_next, endp->queue_last); |
2440 | return -EINVAL; | 2425 | return -EINVAL; |
2441 | } | 2426 | } |
2442 | 2427 | ||
2443 | static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | 2428 | static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, |
2444 | struct urb *urb, int status) | 2429 | struct urb *urb, int status) |
2445 | { | 2430 | { |
2446 | unsigned long irqs; | 2431 | unsigned long irqs; |
2447 | int rc; | 2432 | int rc; |
2448 | 2433 | ||
2449 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 2434 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
2450 | rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status); | 2435 | rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status); |
2451 | if (rc) { | 2436 | if (rc) { |
2452 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2437 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2453 | return rc; | 2438 | return rc; |
2454 | } | 2439 | } |
2455 | if (endp->queue_size == 0) { | 2440 | if (endp->queue_size == 0) { |
2456 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" | 2441 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" |
2457 | "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, | 2442 | "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, |
2458 | endp->endp_number, endp, endp->ring->number, | 2443 | endp->endp_number, endp, endp->ring->number, |
2459 | endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', | 2444 | endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', |
2460 | endp->usb_endp, endp->usb_addr); | 2445 | endp->usb_endp, endp->usb_addr); |
2461 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2446 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2462 | return -EINVAL; | 2447 | return -EINVAL; |
2463 | } | 2448 | } |
2464 | if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { | 2449 | if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { |
2465 | if (endp->active) { | 2450 | if (endp->active) { |
2466 | endp->dequeueing = 1; | 2451 | endp->dequeueing = 1; |
2467 | endp->edset_flush = 1; | 2452 | endp->edset_flush = 1; |
2468 | u132_endp_queue_work(u132, endp, 0); | 2453 | u132_endp_queue_work(u132, endp, 0); |
2469 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2454 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2470 | return 0; | 2455 | return 0; |
2471 | } else { | 2456 | } else { |
2472 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2457 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2473 | u132_hcd_abandon_urb(u132, endp, urb, status); | 2458 | u132_hcd_abandon_urb(u132, endp, urb, status); |
2474 | return 0; | 2459 | return 0; |
2475 | } | 2460 | } |
2476 | } else { | 2461 | } else { |
2477 | u16 queue_list = 0; | 2462 | u16 queue_list = 0; |
2478 | u16 queue_size = endp->queue_size; | 2463 | u16 queue_size = endp->queue_size; |
2479 | u16 queue_scan = endp->queue_next; | 2464 | u16 queue_scan = endp->queue_next; |
2480 | struct urb **urb_slot = NULL; | 2465 | struct urb **urb_slot = NULL; |
2481 | while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { | 2466 | while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { |
2482 | if (urb == endp->urb_list[ENDP_QUEUE_MASK & | 2467 | if (urb == endp->urb_list[ENDP_QUEUE_MASK & |
2483 | ++queue_scan]) { | 2468 | ++queue_scan]) { |
2484 | urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & | 2469 | urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & |
2485 | queue_scan]; | 2470 | queue_scan]; |
2486 | break; | 2471 | break; |
2487 | } else | 2472 | } else |
2488 | continue; | 2473 | continue; |
2489 | } | 2474 | } |
2490 | while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { | 2475 | while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { |
2491 | *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & | 2476 | *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & |
2492 | ++queue_scan]; | 2477 | ++queue_scan]; |
2493 | urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & | 2478 | urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & |
2494 | queue_scan]; | 2479 | queue_scan]; |
2495 | } | 2480 | } |
2496 | if (urb_slot) { | 2481 | if (urb_slot) { |
2497 | struct usb_hcd *hcd = u132_to_hcd(u132); | 2482 | struct usb_hcd *hcd = u132_to_hcd(u132); |
2498 | 2483 | ||
2499 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 2484 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
2500 | endp->queue_size -= 1; | 2485 | endp->queue_size -= 1; |
2501 | if (list_empty(&endp->urb_more)) { | 2486 | if (list_empty(&endp->urb_more)) { |
2502 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2487 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
2503 | irqs); | 2488 | irqs); |
2504 | } else { | 2489 | } else { |
2505 | struct list_head *next = endp->urb_more.next; | 2490 | struct list_head *next = endp->urb_more.next; |
2506 | struct u132_urbq *urbq = list_entry(next, | 2491 | struct u132_urbq *urbq = list_entry(next, |
2507 | struct u132_urbq, urb_more); | 2492 | struct u132_urbq, urb_more); |
2508 | list_del(next); | 2493 | list_del(next); |
2509 | *urb_slot = urbq->urb; | 2494 | *urb_slot = urbq->urb; |
2510 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2495 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
2511 | irqs); | 2496 | irqs); |
2512 | kfree(urbq); | 2497 | kfree(urbq); |
2513 | } urb->error_count = 0; | 2498 | } urb->error_count = 0; |
2514 | usb_hcd_giveback_urb(hcd, urb, status); | 2499 | usb_hcd_giveback_urb(hcd, urb, status); |
2515 | return 0; | 2500 | return 0; |
2516 | } else if (list_empty(&endp->urb_more)) { | 2501 | } else if (list_empty(&endp->urb_more)) { |
2517 | dev_err(&u132->platform_dev->dev, "urb=%p not found in " | 2502 | dev_err(&u132->platform_dev->dev, "urb=%p not found in " |
2518 | "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" | 2503 | "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" |
2519 | "=%d size=%d next=%04X last=%04X\n", urb, | 2504 | "=%d size=%d next=%04X last=%04X\n", urb, |
2520 | endp->endp_number, endp, endp->ring->number, | 2505 | endp->endp_number, endp, endp->ring->number, |
2521 | endp->input ? 'I' : ' ', | 2506 | endp->input ? 'I' : ' ', |
2522 | endp->output ? 'O' : ' ', endp->usb_endp, | 2507 | endp->output ? 'O' : ' ', endp->usb_endp, |
2523 | endp->usb_addr, endp->queue_size, | 2508 | endp->usb_addr, endp->queue_size, |
2524 | endp->queue_next, endp->queue_last); | 2509 | endp->queue_next, endp->queue_last); |
2525 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2510 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2526 | return -EINVAL; | 2511 | return -EINVAL; |
2527 | } else { | 2512 | } else { |
2528 | int retval; | 2513 | int retval; |
2529 | 2514 | ||
2530 | usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb); | 2515 | usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb); |
2531 | retval = dequeue_from_overflow_chain(u132, endp, | 2516 | retval = dequeue_from_overflow_chain(u132, endp, |
2532 | urb); | 2517 | urb); |
2533 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2518 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2534 | return retval; | 2519 | return retval; |
2535 | } | 2520 | } |
2536 | } | 2521 | } |
2537 | } | 2522 | } |
2538 | 2523 | ||
2539 | static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | 2524 | static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) |
2540 | { | 2525 | { |
2541 | struct u132 *u132 = hcd_to_u132(hcd); | 2526 | struct u132 *u132 = hcd_to_u132(hcd); |
2542 | if (u132->going > 2) { | 2527 | if (u132->going > 2) { |
2543 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 2528 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
2544 | , u132->going); | 2529 | , u132->going); |
2545 | return -ENODEV; | 2530 | return -ENODEV; |
2546 | } else { | 2531 | } else { |
2547 | u8 usb_addr = usb_pipedevice(urb->pipe); | 2532 | u8 usb_addr = usb_pipedevice(urb->pipe); |
2548 | u8 usb_endp = usb_pipeendpoint(urb->pipe); | 2533 | u8 usb_endp = usb_pipeendpoint(urb->pipe); |
2549 | u8 address = u132->addr[usb_addr].address; | 2534 | u8 address = u132->addr[usb_addr].address; |
2550 | struct u132_udev *udev = &u132->udev[address]; | 2535 | struct u132_udev *udev = &u132->udev[address]; |
2551 | if (usb_pipein(urb->pipe)) { | 2536 | if (usb_pipein(urb->pipe)) { |
2552 | u8 endp_number = udev->endp_number_in[usb_endp]; | 2537 | u8 endp_number = udev->endp_number_in[usb_endp]; |
2553 | struct u132_endp *endp = u132->endp[endp_number - 1]; | 2538 | struct u132_endp *endp = u132->endp[endp_number - 1]; |
2554 | return u132_endp_urb_dequeue(u132, endp, urb, status); | 2539 | return u132_endp_urb_dequeue(u132, endp, urb, status); |
2555 | } else { | 2540 | } else { |
2556 | u8 endp_number = udev->endp_number_out[usb_endp]; | 2541 | u8 endp_number = udev->endp_number_out[usb_endp]; |
2557 | struct u132_endp *endp = u132->endp[endp_number - 1]; | 2542 | struct u132_endp *endp = u132->endp[endp_number - 1]; |
2558 | return u132_endp_urb_dequeue(u132, endp, urb, status); | 2543 | return u132_endp_urb_dequeue(u132, endp, urb, status); |
2559 | } | 2544 | } |
2560 | } | 2545 | } |
2561 | } | 2546 | } |
2562 | 2547 | ||
2563 | static void u132_endpoint_disable(struct usb_hcd *hcd, | 2548 | static void u132_endpoint_disable(struct usb_hcd *hcd, |
2564 | struct usb_host_endpoint *hep) | 2549 | struct usb_host_endpoint *hep) |
2565 | { | 2550 | { |
2566 | struct u132 *u132 = hcd_to_u132(hcd); | 2551 | struct u132 *u132 = hcd_to_u132(hcd); |
2567 | if (u132->going > 2) { | 2552 | if (u132->going > 2) { |
2568 | dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p" | 2553 | dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p" |
2569 | ") has been removed %d\n", u132, hcd, hep, | 2554 | ") has been removed %d\n", u132, hcd, hep, |
2570 | u132->going); | 2555 | u132->going); |
2571 | } else { | 2556 | } else { |
2572 | struct u132_endp *endp = hep->hcpriv; | 2557 | struct u132_endp *endp = hep->hcpriv; |
2573 | if (endp) | 2558 | if (endp) |
2574 | u132_endp_put_kref(u132, endp); | 2559 | u132_endp_put_kref(u132, endp); |
2575 | } | 2560 | } |
2576 | } | 2561 | } |
2577 | 2562 | ||
2578 | static int u132_get_frame(struct usb_hcd *hcd) | 2563 | static int u132_get_frame(struct usb_hcd *hcd) |
2579 | { | 2564 | { |
2580 | struct u132 *u132 = hcd_to_u132(hcd); | 2565 | struct u132 *u132 = hcd_to_u132(hcd); |
2581 | if (u132->going > 1) { | 2566 | if (u132->going > 1) { |
2582 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 2567 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
2583 | , u132->going); | 2568 | , u132->going); |
2584 | return -ENODEV; | 2569 | return -ENODEV; |
2585 | } else if (u132->going > 0) { | 2570 | } else if (u132->going > 0) { |
2586 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 2571 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
2587 | return -ESHUTDOWN; | 2572 | return -ESHUTDOWN; |
2588 | } else { | 2573 | } else { |
2589 | int frame = 0; | 2574 | int frame = 0; |
2590 | dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); | 2575 | dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); |
2591 | msleep(100); | 2576 | msleep(100); |
2592 | return frame; | 2577 | return frame; |
2593 | } | 2578 | } |
2594 | } | 2579 | } |
2595 | 2580 | ||
2596 | static int u132_roothub_descriptor(struct u132 *u132, | 2581 | static int u132_roothub_descriptor(struct u132 *u132, |
2597 | struct usb_hub_descriptor *desc) | 2582 | struct usb_hub_descriptor *desc) |
2598 | { | 2583 | { |
2599 | int retval; | 2584 | int retval; |
2600 | u16 temp; | 2585 | u16 temp; |
2601 | u32 rh_a = -1; | 2586 | u32 rh_a = -1; |
2602 | u32 rh_b = -1; | 2587 | u32 rh_b = -1; |
2603 | retval = u132_read_pcimem(u132, roothub.a, &rh_a); | 2588 | retval = u132_read_pcimem(u132, roothub.a, &rh_a); |
2604 | if (retval) | 2589 | if (retval) |
2605 | return retval; | 2590 | return retval; |
2606 | desc->bDescriptorType = 0x29; | 2591 | desc->bDescriptorType = 0x29; |
2607 | desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; | 2592 | desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; |
2608 | desc->bHubContrCurrent = 0; | 2593 | desc->bHubContrCurrent = 0; |
2609 | desc->bNbrPorts = u132->num_ports; | 2594 | desc->bNbrPorts = u132->num_ports; |
2610 | temp = 1 + (u132->num_ports / 8); | 2595 | temp = 1 + (u132->num_ports / 8); |
2611 | desc->bDescLength = 7 + 2 *temp; | 2596 | desc->bDescLength = 7 + 2 * temp; |
2612 | temp = 0; | 2597 | temp = 0; |
2613 | if (rh_a & RH_A_NPS) | 2598 | if (rh_a & RH_A_NPS) |
2614 | temp |= 0x0002; | 2599 | temp |= 0x0002; |
2615 | if (rh_a & RH_A_PSM) | 2600 | if (rh_a & RH_A_PSM) |
2616 | temp |= 0x0001; | 2601 | temp |= 0x0001; |
2617 | if (rh_a & RH_A_NOCP) { | 2602 | if (rh_a & RH_A_NOCP) |
2618 | temp |= 0x0010; | 2603 | temp |= 0x0010; |
2619 | } else if (rh_a & RH_A_OCPM) | 2604 | else if (rh_a & RH_A_OCPM) |
2620 | temp |= 0x0008; | 2605 | temp |= 0x0008; |
2621 | desc->wHubCharacteristics = cpu_to_le16(temp); | 2606 | desc->wHubCharacteristics = cpu_to_le16(temp); |
2622 | retval = u132_read_pcimem(u132, roothub.b, &rh_b); | 2607 | retval = u132_read_pcimem(u132, roothub.b, &rh_b); |
2623 | if (retval) | 2608 | if (retval) |
2624 | return retval; | 2609 | return retval; |
2625 | memset(desc->bitmap, 0xff, sizeof(desc->bitmap)); | 2610 | memset(desc->bitmap, 0xff, sizeof(desc->bitmap)); |
2626 | desc->bitmap[0] = rh_b & RH_B_DR; | 2611 | desc->bitmap[0] = rh_b & RH_B_DR; |
2627 | if (u132->num_ports > 7) { | 2612 | if (u132->num_ports > 7) { |
2628 | desc->bitmap[1] = (rh_b & RH_B_DR) >> 8; | 2613 | desc->bitmap[1] = (rh_b & RH_B_DR) >> 8; |
2629 | desc->bitmap[2] = 0xff; | 2614 | desc->bitmap[2] = 0xff; |
2630 | } else | 2615 | } else |
2631 | desc->bitmap[1] = 0xff; | 2616 | desc->bitmap[1] = 0xff; |
2632 | return 0; | 2617 | return 0; |
2633 | } | 2618 | } |
2634 | 2619 | ||
2635 | static int u132_roothub_status(struct u132 *u132, __le32 *desc) | 2620 | static int u132_roothub_status(struct u132 *u132, __le32 *desc) |
2636 | { | 2621 | { |
2637 | u32 rh_status = -1; | 2622 | u32 rh_status = -1; |
2638 | int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); | 2623 | int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); |
2639 | *desc = cpu_to_le32(rh_status); | 2624 | *desc = cpu_to_le32(rh_status); |
2640 | return ret_status; | 2625 | return ret_status; |
2641 | } | 2626 | } |
2642 | 2627 | ||
2643 | static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) | 2628 | static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) |
2644 | { | 2629 | { |
2645 | if (wIndex == 0 || wIndex > u132->num_ports) { | 2630 | if (wIndex == 0 || wIndex > u132->num_ports) { |
2646 | return -EINVAL; | 2631 | return -EINVAL; |
2647 | } else { | 2632 | } else { |
2648 | int port = wIndex - 1; | 2633 | int port = wIndex - 1; |
2649 | u32 rh_portstatus = -1; | 2634 | u32 rh_portstatus = -1; |
2650 | int ret_portstatus = u132_read_pcimem(u132, | 2635 | int ret_portstatus = u132_read_pcimem(u132, |
2651 | roothub.portstatus[port], &rh_portstatus); | 2636 | roothub.portstatus[port], &rh_portstatus); |
2652 | *desc = cpu_to_le32(rh_portstatus); | 2637 | *desc = cpu_to_le32(rh_portstatus); |
2653 | if (*(u16 *) (desc + 2)) { | 2638 | if (*(u16 *) (desc + 2)) { |
2654 | dev_info(&u132->platform_dev->dev, "Port %d Status Chan" | 2639 | dev_info(&u132->platform_dev->dev, "Port %d Status Chan" |
2655 | "ge = %08X\n", port, *desc); | 2640 | "ge = %08X\n", port, *desc); |
2656 | } | 2641 | } |
2657 | return ret_portstatus; | 2642 | return ret_portstatus; |
2658 | } | 2643 | } |
2659 | } | 2644 | } |
2660 | 2645 | ||
2661 | 2646 | ||
@@ -2666,381 +2651,340 @@ static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) | |||
2666 | #define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) | 2651 | #define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) |
2667 | static int u132_roothub_portreset(struct u132 *u132, int port_index) | 2652 | static int u132_roothub_portreset(struct u132 *u132, int port_index) |
2668 | { | 2653 | { |
2669 | int retval; | 2654 | int retval; |
2670 | u32 fmnumber; | 2655 | u32 fmnumber; |
2671 | u16 now; | 2656 | u16 now; |
2672 | u16 reset_done; | 2657 | u16 reset_done; |
2673 | retval = u132_read_pcimem(u132, fmnumber, &fmnumber); | 2658 | retval = u132_read_pcimem(u132, fmnumber, &fmnumber); |
2674 | if (retval) | 2659 | if (retval) |
2675 | return retval; | 2660 | return retval; |
2676 | now = fmnumber; | 2661 | now = fmnumber; |
2677 | reset_done = now + PORT_RESET_MSEC; | 2662 | reset_done = now + PORT_RESET_MSEC; |
2678 | do { | 2663 | do { |
2679 | u32 portstat; | 2664 | u32 portstat; |
2680 | do { | 2665 | do { |
2681 | retval = u132_read_pcimem(u132, | 2666 | retval = u132_read_pcimem(u132, |
2682 | roothub.portstatus[port_index], &portstat); | 2667 | roothub.portstatus[port_index], &portstat); |
2683 | if (retval) | 2668 | if (retval) |
2684 | return retval; | 2669 | return retval; |
2685 | if (RH_PS_PRS & portstat) { | 2670 | if (RH_PS_PRS & portstat) |
2686 | continue; | 2671 | continue; |
2687 | } else | 2672 | else |
2688 | break; | 2673 | break; |
2689 | } while (tick_before(now, reset_done)); | 2674 | } while (tick_before(now, reset_done)); |
2690 | if (RH_PS_PRS & portstat) | 2675 | if (RH_PS_PRS & portstat) |
2691 | return -ENODEV; | 2676 | return -ENODEV; |
2692 | if (RH_PS_CCS & portstat) { | 2677 | if (RH_PS_CCS & portstat) { |
2693 | if (RH_PS_PRSC & portstat) { | 2678 | if (RH_PS_PRSC & portstat) { |
2694 | retval = u132_write_pcimem(u132, | 2679 | retval = u132_write_pcimem(u132, |
2695 | roothub.portstatus[port_index], | 2680 | roothub.portstatus[port_index], |
2696 | RH_PS_PRSC); | 2681 | RH_PS_PRSC); |
2697 | if (retval) | 2682 | if (retval) |
2698 | return retval; | 2683 | return retval; |
2699 | } | 2684 | } |
2700 | } else | 2685 | } else |
2701 | break; /* start the next reset, | 2686 | break; /* start the next reset, |
2702 | sleep till it's probably done */ | 2687 | sleep till it's probably done */ |
2703 | retval = u132_write_pcimem(u132, roothub.portstatus[port_index], | 2688 | retval = u132_write_pcimem(u132, roothub.portstatus[port_index], |
2704 | RH_PS_PRS); | 2689 | RH_PS_PRS); |
2705 | if (retval) | 2690 | if (retval) |
2706 | return retval; | 2691 | return retval; |
2707 | msleep(PORT_RESET_HW_MSEC); | 2692 | msleep(PORT_RESET_HW_MSEC); |
2708 | retval = u132_read_pcimem(u132, fmnumber, &fmnumber); | 2693 | retval = u132_read_pcimem(u132, fmnumber, &fmnumber); |
2709 | if (retval) | 2694 | if (retval) |
2710 | return retval; | 2695 | return retval; |
2711 | now = fmnumber; | 2696 | now = fmnumber; |
2712 | } while (tick_before(now, reset_done)); | 2697 | } while (tick_before(now, reset_done)); |
2713 | return 0; | 2698 | return 0; |
2714 | } | 2699 | } |
2715 | 2700 | ||
2716 | static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue, | 2701 | static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue, |
2717 | u16 wIndex) | 2702 | u16 wIndex) |
2718 | { | 2703 | { |
2719 | if (wIndex == 0 || wIndex > u132->num_ports) { | 2704 | if (wIndex == 0 || wIndex > u132->num_ports) { |
2720 | return -EINVAL; | 2705 | return -EINVAL; |
2721 | } else { | 2706 | } else { |
2722 | int retval; | 2707 | int retval; |
2723 | int port_index = wIndex - 1; | 2708 | int port_index = wIndex - 1; |
2724 | struct u132_port *port = &u132->port[port_index]; | 2709 | struct u132_port *port = &u132->port[port_index]; |
2725 | port->Status &= ~(1 << wValue); | 2710 | port->Status &= ~(1 << wValue); |
2726 | switch (wValue) { | 2711 | switch (wValue) { |
2727 | case USB_PORT_FEAT_SUSPEND: | 2712 | case USB_PORT_FEAT_SUSPEND: |
2728 | retval = u132_write_pcimem(u132, | 2713 | retval = u132_write_pcimem(u132, |
2729 | roothub.portstatus[port_index], RH_PS_PSS); | 2714 | roothub.portstatus[port_index], RH_PS_PSS); |
2730 | if (retval) | 2715 | if (retval) |
2731 | return retval; | 2716 | return retval; |
2732 | return 0; | 2717 | return 0; |
2733 | case USB_PORT_FEAT_POWER: | 2718 | case USB_PORT_FEAT_POWER: |
2734 | retval = u132_write_pcimem(u132, | 2719 | retval = u132_write_pcimem(u132, |
2735 | roothub.portstatus[port_index], RH_PS_PPS); | 2720 | roothub.portstatus[port_index], RH_PS_PPS); |
2736 | if (retval) | 2721 | if (retval) |
2737 | return retval; | 2722 | return retval; |
2738 | return 0; | 2723 | return 0; |
2739 | case USB_PORT_FEAT_RESET: | 2724 | case USB_PORT_FEAT_RESET: |
2740 | retval = u132_roothub_portreset(u132, port_index); | 2725 | retval = u132_roothub_portreset(u132, port_index); |
2741 | if (retval) | 2726 | if (retval) |
2742 | return retval; | 2727 | return retval; |
2743 | return 0; | 2728 | return 0; |
2744 | default: | 2729 | default: |
2745 | return -EPIPE; | 2730 | return -EPIPE; |
2746 | } | 2731 | } |
2747 | } | 2732 | } |
2748 | } | 2733 | } |
2749 | 2734 | ||
2750 | static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, | 2735 | static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, |
2751 | u16 wIndex) | 2736 | u16 wIndex) |
2752 | { | 2737 | { |
2753 | if (wIndex == 0 || wIndex > u132->num_ports) { | 2738 | if (wIndex == 0 || wIndex > u132->num_ports) { |
2754 | return -EINVAL; | 2739 | return -EINVAL; |
2755 | } else { | 2740 | } else { |
2756 | int port_index = wIndex - 1; | 2741 | int port_index = wIndex - 1; |
2757 | u32 temp; | 2742 | u32 temp; |
2758 | int retval; | 2743 | int retval; |
2759 | struct u132_port *port = &u132->port[port_index]; | 2744 | struct u132_port *port = &u132->port[port_index]; |
2760 | port->Status &= ~(1 << wValue); | 2745 | port->Status &= ~(1 << wValue); |
2761 | switch (wValue) { | 2746 | switch (wValue) { |
2762 | case USB_PORT_FEAT_ENABLE: | 2747 | case USB_PORT_FEAT_ENABLE: |
2763 | temp = RH_PS_CCS; | 2748 | temp = RH_PS_CCS; |
2764 | break; | 2749 | break; |
2765 | case USB_PORT_FEAT_C_ENABLE: | 2750 | case USB_PORT_FEAT_C_ENABLE: |
2766 | temp = RH_PS_PESC; | 2751 | temp = RH_PS_PESC; |
2767 | break; | 2752 | break; |
2768 | case USB_PORT_FEAT_SUSPEND: | 2753 | case USB_PORT_FEAT_SUSPEND: |
2769 | temp = RH_PS_POCI; | 2754 | temp = RH_PS_POCI; |
2770 | if ((u132->hc_control & OHCI_CTRL_HCFS) | 2755 | if ((u132->hc_control & OHCI_CTRL_HCFS) |
2771 | != OHCI_USB_OPER) { | 2756 | != OHCI_USB_OPER) { |
2772 | dev_err(&u132->platform_dev->dev, "TODO resume_" | 2757 | dev_err(&u132->platform_dev->dev, "TODO resume_" |
2773 | "root_hub\n"); | 2758 | "root_hub\n"); |
2774 | } | 2759 | } |
2775 | break; | 2760 | break; |
2776 | case USB_PORT_FEAT_C_SUSPEND: | 2761 | case USB_PORT_FEAT_C_SUSPEND: |
2777 | temp = RH_PS_PSSC; | 2762 | temp = RH_PS_PSSC; |
2778 | break; | 2763 | break; |
2779 | case USB_PORT_FEAT_POWER: | 2764 | case USB_PORT_FEAT_POWER: |
2780 | temp = RH_PS_LSDA; | 2765 | temp = RH_PS_LSDA; |
2781 | break; | 2766 | break; |
2782 | case USB_PORT_FEAT_C_CONNECTION: | 2767 | case USB_PORT_FEAT_C_CONNECTION: |
2783 | temp = RH_PS_CSC; | 2768 | temp = RH_PS_CSC; |
2784 | break; | 2769 | break; |
2785 | case USB_PORT_FEAT_C_OVER_CURRENT: | 2770 | case USB_PORT_FEAT_C_OVER_CURRENT: |
2786 | temp = RH_PS_OCIC; | 2771 | temp = RH_PS_OCIC; |
2787 | break; | 2772 | break; |
2788 | case USB_PORT_FEAT_C_RESET: | 2773 | case USB_PORT_FEAT_C_RESET: |
2789 | temp = RH_PS_PRSC; | 2774 | temp = RH_PS_PRSC; |
2790 | break; | 2775 | break; |
2791 | default: | 2776 | default: |
2792 | return -EPIPE; | 2777 | return -EPIPE; |
2793 | } | 2778 | } |
2794 | retval = u132_write_pcimem(u132, roothub.portstatus[port_index], | 2779 | retval = u132_write_pcimem(u132, roothub.portstatus[port_index], |
2795 | temp); | 2780 | temp); |
2796 | if (retval) | 2781 | if (retval) |
2797 | return retval; | 2782 | return retval; |
2798 | return 0; | 2783 | return 0; |
2799 | } | 2784 | } |
2800 | } | 2785 | } |
2801 | 2786 | ||
2802 | 2787 | ||
2803 | /* the virtual root hub timer IRQ checks for hub status*/ | 2788 | /* the virtual root hub timer IRQ checks for hub status*/ |
2804 | static int u132_hub_status_data(struct usb_hcd *hcd, char *buf) | 2789 | static int u132_hub_status_data(struct usb_hcd *hcd, char *buf) |
2805 | { | 2790 | { |
2806 | struct u132 *u132 = hcd_to_u132(hcd); | 2791 | struct u132 *u132 = hcd_to_u132(hcd); |
2807 | if (u132->going > 1) { | 2792 | if (u132->going > 1) { |
2808 | dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" | 2793 | dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" |
2809 | "ed %d\n", hcd, u132->going); | 2794 | "ed %d\n", hcd, u132->going); |
2810 | return -ENODEV; | 2795 | return -ENODEV; |
2811 | } else if (u132->going > 0) { | 2796 | } else if (u132->going > 0) { |
2812 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" | 2797 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" |
2813 | "ed\n", hcd); | 2798 | "ed\n", hcd); |
2814 | return -ESHUTDOWN; | 2799 | return -ESHUTDOWN; |
2815 | } else { | 2800 | } else { |
2816 | int i, changed = 0, length = 1; | 2801 | int i, changed = 0, length = 1; |
2817 | if (u132->flags & OHCI_QUIRK_AMD756) { | 2802 | if (u132->flags & OHCI_QUIRK_AMD756) { |
2818 | if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { | 2803 | if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { |
2819 | dev_err(&u132->platform_dev->dev, "bogus NDP, r" | 2804 | dev_err(&u132->platform_dev->dev, "bogus NDP, r" |
2820 | "ereads as NDP=%d\n", | 2805 | "ereads as NDP=%d\n", |
2821 | u132->hc_roothub_a & RH_A_NDP); | 2806 | u132->hc_roothub_a & RH_A_NDP); |
2822 | goto done; | 2807 | goto done; |
2823 | } | 2808 | } |
2824 | } | 2809 | } |
2825 | if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) { | 2810 | if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) |
2826 | buf[0] = changed = 1; | 2811 | buf[0] = changed = 1; |
2827 | } else | 2812 | else |
2828 | buf[0] = 0; | 2813 | buf[0] = 0; |
2829 | if (u132->num_ports > 7) { | 2814 | if (u132->num_ports > 7) { |
2830 | buf[1] = 0; | 2815 | buf[1] = 0; |
2831 | length++; | 2816 | length++; |
2832 | } | 2817 | } |
2833 | for (i = 0; i < u132->num_ports; i++) { | 2818 | for (i = 0; i < u132->num_ports; i++) { |
2834 | if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | | 2819 | if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | |
2835 | RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | | 2820 | RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | |
2836 | RH_PS_PRSC)) { | 2821 | RH_PS_PRSC)) { |
2837 | changed = 1; | 2822 | changed = 1; |
2838 | if (i < 7) { | 2823 | if (i < 7) |
2839 | buf[0] |= 1 << (i + 1); | 2824 | buf[0] |= 1 << (i + 1); |
2840 | } else | 2825 | else |
2841 | buf[1] |= 1 << (i - 7); | 2826 | buf[1] |= 1 << (i - 7); |
2842 | continue; | 2827 | continue; |
2843 | } | 2828 | } |
2844 | if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) { | 2829 | if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) |
2845 | continue; | 2830 | continue; |
2846 | } | 2831 | |
2847 | if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) { | 2832 | if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) |
2848 | continue; | 2833 | continue; |
2849 | } | 2834 | } |
2850 | } | 2835 | done: |
2851 | done:return changed ? length : 0; | 2836 | return changed ? length : 0; |
2852 | } | 2837 | } |
2853 | } | 2838 | } |
2854 | 2839 | ||
2855 | static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | 2840 | static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, |
2856 | u16 wIndex, char *buf, u16 wLength) | 2841 | u16 wIndex, char *buf, u16 wLength) |
2857 | { | 2842 | { |
2858 | struct u132 *u132 = hcd_to_u132(hcd); | 2843 | struct u132 *u132 = hcd_to_u132(hcd); |
2859 | if (u132->going > 1) { | 2844 | if (u132->going > 1) { |
2860 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 2845 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
2861 | , u132->going); | 2846 | , u132->going); |
2862 | return -ENODEV; | 2847 | return -ENODEV; |
2863 | } else if (u132->going > 0) { | 2848 | } else if (u132->going > 0) { |
2864 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 2849 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
2865 | return -ESHUTDOWN; | 2850 | return -ESHUTDOWN; |
2866 | } else { | 2851 | } else { |
2867 | int retval = 0; | 2852 | int retval = 0; |
2868 | mutex_lock(&u132->sw_lock); | 2853 | mutex_lock(&u132->sw_lock); |
2869 | switch (typeReq) { | 2854 | switch (typeReq) { |
2870 | case ClearHubFeature: | 2855 | case ClearHubFeature: |
2871 | switch (wValue) { | 2856 | switch (wValue) { |
2872 | case C_HUB_OVER_CURRENT: | 2857 | case C_HUB_OVER_CURRENT: |
2873 | case C_HUB_LOCAL_POWER: | 2858 | case C_HUB_LOCAL_POWER: |
2874 | break; | 2859 | break; |
2875 | default: | 2860 | default: |
2876 | goto stall; | 2861 | goto stall; |
2877 | } | 2862 | } |
2878 | break; | 2863 | break; |
2879 | case SetHubFeature: | 2864 | case SetHubFeature: |
2880 | switch (wValue) { | 2865 | switch (wValue) { |
2881 | case C_HUB_OVER_CURRENT: | 2866 | case C_HUB_OVER_CURRENT: |
2882 | case C_HUB_LOCAL_POWER: | 2867 | case C_HUB_LOCAL_POWER: |
2883 | break; | 2868 | break; |
2884 | default: | 2869 | default: |
2885 | goto stall; | 2870 | goto stall; |
2886 | } | 2871 | } |
2887 | break; | 2872 | break; |
2888 | case ClearPortFeature:{ | 2873 | case ClearPortFeature:{ |
2889 | retval = u132_roothub_clearportfeature(u132, | 2874 | retval = u132_roothub_clearportfeature(u132, |
2890 | wValue, wIndex); | 2875 | wValue, wIndex); |
2891 | if (retval) | 2876 | if (retval) |
2892 | goto error; | 2877 | goto error; |
2893 | break; | 2878 | break; |
2894 | } | 2879 | } |
2895 | case GetHubDescriptor:{ | 2880 | case GetHubDescriptor:{ |
2896 | retval = u132_roothub_descriptor(u132, | 2881 | retval = u132_roothub_descriptor(u132, |
2897 | (struct usb_hub_descriptor *)buf); | 2882 | (struct usb_hub_descriptor *)buf); |
2898 | if (retval) | 2883 | if (retval) |
2899 | goto error; | 2884 | goto error; |
2900 | break; | 2885 | break; |
2901 | } | 2886 | } |
2902 | case GetHubStatus:{ | 2887 | case GetHubStatus:{ |
2903 | retval = u132_roothub_status(u132, | 2888 | retval = u132_roothub_status(u132, |
2904 | (__le32 *) buf); | 2889 | (__le32 *) buf); |
2905 | if (retval) | 2890 | if (retval) |
2906 | goto error; | 2891 | goto error; |
2907 | break; | 2892 | break; |
2908 | } | 2893 | } |
2909 | case GetPortStatus:{ | 2894 | case GetPortStatus:{ |
2910 | retval = u132_roothub_portstatus(u132, | 2895 | retval = u132_roothub_portstatus(u132, |
2911 | (__le32 *) buf, wIndex); | 2896 | (__le32 *) buf, wIndex); |
2912 | if (retval) | 2897 | if (retval) |
2913 | goto error; | 2898 | goto error; |
2914 | break; | 2899 | break; |
2915 | } | 2900 | } |
2916 | case SetPortFeature:{ | 2901 | case SetPortFeature:{ |
2917 | retval = u132_roothub_setportfeature(u132, | 2902 | retval = u132_roothub_setportfeature(u132, |
2918 | wValue, wIndex); | 2903 | wValue, wIndex); |
2919 | if (retval) | 2904 | if (retval) |
2920 | goto error; | 2905 | goto error; |
2921 | break; | 2906 | break; |
2922 | } | 2907 | } |
2923 | default: | 2908 | default: |
2924 | goto stall; | 2909 | goto stall; |
2925 | error:u132_disable(u132); | 2910 | error: |
2926 | u132->going = 1; | 2911 | u132_disable(u132); |
2927 | break; | 2912 | u132->going = 1; |
2928 | stall:retval = -EPIPE; | 2913 | break; |
2929 | break; | 2914 | stall: |
2930 | } | 2915 | retval = -EPIPE; |
2931 | mutex_unlock(&u132->sw_lock); | 2916 | break; |
2932 | return retval; | 2917 | } |
2933 | } | 2918 | mutex_unlock(&u132->sw_lock); |
2919 | return retval; | ||
2920 | } | ||
2934 | } | 2921 | } |
2935 | 2922 | ||
2936 | static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) | 2923 | static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) |
2937 | { | 2924 | { |
2938 | struct u132 *u132 = hcd_to_u132(hcd); | 2925 | struct u132 *u132 = hcd_to_u132(hcd); |
2939 | if (u132->going > 1) { | 2926 | if (u132->going > 1) { |
2940 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 2927 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
2941 | , u132->going); | 2928 | , u132->going); |
2942 | return -ENODEV; | 2929 | return -ENODEV; |
2943 | } else if (u132->going > 0) { | 2930 | } else if (u132->going > 0) { |
2944 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 2931 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
2945 | return -ESHUTDOWN; | 2932 | return -ESHUTDOWN; |
2946 | } else | 2933 | } else |
2947 | return 0; | 2934 | return 0; |
2948 | } | ||
2949 | |||
2950 | static void u132_hub_irq_enable(struct usb_hcd *hcd) | ||
2951 | { | ||
2952 | struct u132 *u132 = hcd_to_u132(hcd); | ||
2953 | if (u132->going > 1) { | ||
2954 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
2955 | , u132->going); | ||
2956 | } else if (u132->going > 0) | ||
2957 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
2958 | } | 2935 | } |
2959 | 2936 | ||
2960 | 2937 | ||
2961 | #ifdef CONFIG_PM | 2938 | #ifdef CONFIG_PM |
2962 | static int u132_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) | ||
2963 | { | ||
2964 | struct u132 *u132 = hcd_to_u132(hcd); | ||
2965 | if (u132->going > 1) { | ||
2966 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
2967 | , u132->going); | ||
2968 | return -ENODEV; | ||
2969 | } else if (u132->going > 0) { | ||
2970 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
2971 | return -ESHUTDOWN; | ||
2972 | } else | ||
2973 | return 0; | ||
2974 | } | ||
2975 | |||
2976 | static int u132_hcd_resume(struct usb_hcd *hcd) | ||
2977 | { | ||
2978 | struct u132 *u132 = hcd_to_u132(hcd); | ||
2979 | if (u132->going > 1) { | ||
2980 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
2981 | , u132->going); | ||
2982 | return -ENODEV; | ||
2983 | } else if (u132->going > 0) { | ||
2984 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
2985 | return -ESHUTDOWN; | ||
2986 | } else | ||
2987 | return 0; | ||
2988 | } | ||
2989 | |||
2990 | static int u132_bus_suspend(struct usb_hcd *hcd) | 2939 | static int u132_bus_suspend(struct usb_hcd *hcd) |
2991 | { | 2940 | { |
2992 | struct u132 *u132 = hcd_to_u132(hcd); | 2941 | struct u132 *u132 = hcd_to_u132(hcd); |
2993 | if (u132->going > 1) { | 2942 | if (u132->going > 1) { |
2994 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 2943 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
2995 | , u132->going); | 2944 | , u132->going); |
2996 | return -ENODEV; | 2945 | return -ENODEV; |
2997 | } else if (u132->going > 0) { | 2946 | } else if (u132->going > 0) { |
2998 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 2947 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
2999 | return -ESHUTDOWN; | 2948 | return -ESHUTDOWN; |
3000 | } else | 2949 | } else |
3001 | return 0; | 2950 | return 0; |
3002 | } | 2951 | } |
3003 | 2952 | ||
3004 | static int u132_bus_resume(struct usb_hcd *hcd) | 2953 | static int u132_bus_resume(struct usb_hcd *hcd) |
3005 | { | 2954 | { |
3006 | struct u132 *u132 = hcd_to_u132(hcd); | 2955 | struct u132 *u132 = hcd_to_u132(hcd); |
3007 | if (u132->going > 1) { | 2956 | if (u132->going > 1) { |
3008 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 2957 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
3009 | , u132->going); | 2958 | , u132->going); |
3010 | return -ENODEV; | 2959 | return -ENODEV; |
3011 | } else if (u132->going > 0) { | 2960 | } else if (u132->going > 0) { |
3012 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 2961 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
3013 | return -ESHUTDOWN; | 2962 | return -ESHUTDOWN; |
3014 | } else | 2963 | } else |
3015 | return 0; | 2964 | return 0; |
3016 | } | 2965 | } |
3017 | 2966 | ||
3018 | #else | 2967 | #else |
3019 | #define u132_hcd_suspend NULL | ||
3020 | #define u132_hcd_resume NULL | ||
3021 | #define u132_bus_suspend NULL | 2968 | #define u132_bus_suspend NULL |
3022 | #define u132_bus_resume NULL | 2969 | #define u132_bus_resume NULL |
3023 | #endif | 2970 | #endif |
3024 | static struct hc_driver u132_hc_driver = { | 2971 | static struct hc_driver u132_hc_driver = { |
3025 | .description = hcd_name, | 2972 | .description = hcd_name, |
3026 | .hcd_priv_size = sizeof(struct u132), | 2973 | .hcd_priv_size = sizeof(struct u132), |
3027 | .irq = NULL, | 2974 | .irq = NULL, |
3028 | .flags = HCD_USB11 | HCD_MEMORY, | 2975 | .flags = HCD_USB11 | HCD_MEMORY, |
3029 | .reset = u132_hcd_reset, | 2976 | .reset = u132_hcd_reset, |
3030 | .start = u132_hcd_start, | 2977 | .start = u132_hcd_start, |
3031 | .suspend = u132_hcd_suspend, | 2978 | .stop = u132_hcd_stop, |
3032 | .resume = u132_hcd_resume, | 2979 | .urb_enqueue = u132_urb_enqueue, |
3033 | .stop = u132_hcd_stop, | 2980 | .urb_dequeue = u132_urb_dequeue, |
3034 | .urb_enqueue = u132_urb_enqueue, | 2981 | .endpoint_disable = u132_endpoint_disable, |
3035 | .urb_dequeue = u132_urb_dequeue, | 2982 | .get_frame_number = u132_get_frame, |
3036 | .endpoint_disable = u132_endpoint_disable, | 2983 | .hub_status_data = u132_hub_status_data, |
3037 | .get_frame_number = u132_get_frame, | 2984 | .hub_control = u132_hub_control, |
3038 | .hub_status_data = u132_hub_status_data, | 2985 | .bus_suspend = u132_bus_suspend, |
3039 | .hub_control = u132_hub_control, | 2986 | .bus_resume = u132_bus_resume, |
3040 | .bus_suspend = u132_bus_suspend, | 2987 | .start_port_reset = u132_start_port_reset, |
3041 | .bus_resume = u132_bus_resume, | ||
3042 | .start_port_reset = u132_start_port_reset, | ||
3043 | .hub_irq_enable = u132_hub_irq_enable, | ||
3044 | }; | 2988 | }; |
3045 | 2989 | ||
3046 | /* | 2990 | /* |
@@ -3051,148 +2995,152 @@ static struct hc_driver u132_hc_driver = { | |||
3051 | */ | 2995 | */ |
3052 | static int __devexit u132_remove(struct platform_device *pdev) | 2996 | static int __devexit u132_remove(struct platform_device *pdev) |
3053 | { | 2997 | { |
3054 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 2998 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
3055 | if (hcd) { | 2999 | if (hcd) { |
3056 | struct u132 *u132 = hcd_to_u132(hcd); | 3000 | struct u132 *u132 = hcd_to_u132(hcd); |
3057 | if (u132->going++ > 1) { | 3001 | if (u132->going++ > 1) { |
3058 | dev_err(&u132->platform_dev->dev, "already being remove" | 3002 | dev_err(&u132->platform_dev->dev, "already being remove" |
3059 | "d\n"); | 3003 | "d\n"); |
3060 | return -ENODEV; | 3004 | return -ENODEV; |
3061 | } else { | 3005 | } else { |
3062 | int rings = MAX_U132_RINGS; | 3006 | int rings = MAX_U132_RINGS; |
3063 | int endps = MAX_U132_ENDPS; | 3007 | int endps = MAX_U132_ENDPS; |
3064 | dev_err(&u132->platform_dev->dev, "removing device u132" | 3008 | dev_err(&u132->platform_dev->dev, "removing device u132" |
3065 | ".%d\n", u132->sequence_num); | 3009 | ".%d\n", u132->sequence_num); |
3066 | msleep(100); | 3010 | msleep(100); |
3067 | mutex_lock(&u132->sw_lock); | 3011 | mutex_lock(&u132->sw_lock); |
3068 | u132_monitor_cancel_work(u132); | 3012 | u132_monitor_cancel_work(u132); |
3069 | while (rings-- > 0) { | 3013 | while (rings-- > 0) { |
3070 | struct u132_ring *ring = &u132->ring[rings]; | 3014 | struct u132_ring *ring = &u132->ring[rings]; |
3071 | u132_ring_cancel_work(u132, ring); | 3015 | u132_ring_cancel_work(u132, ring); |
3072 | } while (endps-- > 0) { | 3016 | } while (endps-- > 0) { |
3073 | struct u132_endp *endp = u132->endp[endps]; | 3017 | struct u132_endp *endp = u132->endp[endps]; |
3074 | if (endp) | 3018 | if (endp) |
3075 | u132_endp_cancel_work(u132, endp); | 3019 | u132_endp_cancel_work(u132, endp); |
3076 | } | 3020 | } |
3077 | u132->going += 1; | 3021 | u132->going += 1; |
3078 | printk(KERN_INFO "removing device u132.%d\n", | 3022 | printk(KERN_INFO "removing device u132.%d\n", |
3079 | u132->sequence_num); | 3023 | u132->sequence_num); |
3080 | mutex_unlock(&u132->sw_lock); | 3024 | mutex_unlock(&u132->sw_lock); |
3081 | usb_remove_hcd(hcd); | 3025 | usb_remove_hcd(hcd); |
3082 | u132_u132_put_kref(u132); | 3026 | u132_u132_put_kref(u132); |
3083 | return 0; | 3027 | return 0; |
3084 | } | 3028 | } |
3085 | } else | 3029 | } else |
3086 | return 0; | 3030 | return 0; |
3087 | } | 3031 | } |
3088 | 3032 | ||
3089 | static void u132_initialise(struct u132 *u132, struct platform_device *pdev) | 3033 | static void u132_initialise(struct u132 *u132, struct platform_device *pdev) |
3090 | { | 3034 | { |
3091 | int rings = MAX_U132_RINGS; | 3035 | int rings = MAX_U132_RINGS; |
3092 | int ports = MAX_U132_PORTS; | 3036 | int ports = MAX_U132_PORTS; |
3093 | int addrs = MAX_U132_ADDRS; | 3037 | int addrs = MAX_U132_ADDRS; |
3094 | int udevs = MAX_U132_UDEVS; | 3038 | int udevs = MAX_U132_UDEVS; |
3095 | int endps = MAX_U132_ENDPS; | 3039 | int endps = MAX_U132_ENDPS; |
3096 | u132->board = pdev->dev.platform_data; | 3040 | u132->board = pdev->dev.platform_data; |
3097 | u132->platform_dev = pdev; | 3041 | u132->platform_dev = pdev; |
3098 | u132->power = 0; | 3042 | u132->power = 0; |
3099 | u132->reset = 0; | 3043 | u132->reset = 0; |
3100 | mutex_init(&u132->sw_lock); | 3044 | mutex_init(&u132->sw_lock); |
3101 | init_MUTEX(&u132->scheduler_lock); | 3045 | mutex_init(&u132->scheduler_lock); |
3102 | while (rings-- > 0) { | 3046 | while (rings-- > 0) { |
3103 | struct u132_ring *ring = &u132->ring[rings]; | 3047 | struct u132_ring *ring = &u132->ring[rings]; |
3104 | ring->u132 = u132; | 3048 | ring->u132 = u132; |
3105 | ring->number = rings + 1; | 3049 | ring->number = rings + 1; |
3106 | ring->length = 0; | 3050 | ring->length = 0; |
3107 | ring->curr_endp = NULL; | 3051 | ring->curr_endp = NULL; |
3108 | INIT_DELAYED_WORK(&ring->scheduler, | 3052 | INIT_DELAYED_WORK(&ring->scheduler, |
3109 | u132_hcd_ring_work_scheduler); | 3053 | u132_hcd_ring_work_scheduler); |
3110 | } mutex_lock(&u132->sw_lock); | 3054 | } |
3111 | INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); | 3055 | mutex_lock(&u132->sw_lock); |
3112 | while (ports-- > 0) { | 3056 | INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); |
3113 | struct u132_port *port = &u132->port[ports]; | 3057 | while (ports-- > 0) { |
3114 | port->u132 = u132; | 3058 | struct u132_port *port = &u132->port[ports]; |
3115 | port->reset = 0; | 3059 | port->u132 = u132; |
3116 | port->enable = 0; | 3060 | port->reset = 0; |
3117 | port->power = 0; | 3061 | port->enable = 0; |
3118 | port->Status = 0; | 3062 | port->power = 0; |
3119 | } while (addrs-- > 0) { | 3063 | port->Status = 0; |
3120 | struct u132_addr *addr = &u132->addr[addrs]; | 3064 | } |
3121 | addr->address = 0; | 3065 | while (addrs-- > 0) { |
3122 | } while (udevs-- > 0) { | 3066 | struct u132_addr *addr = &u132->addr[addrs]; |
3123 | struct u132_udev *udev = &u132->udev[udevs]; | 3067 | addr->address = 0; |
3124 | int i = ARRAY_SIZE(udev->endp_number_in); | 3068 | } |
3125 | int o = ARRAY_SIZE(udev->endp_number_out); | 3069 | while (udevs-- > 0) { |
3126 | udev->usb_device = NULL; | 3070 | struct u132_udev *udev = &u132->udev[udevs]; |
3127 | udev->udev_number = 0; | 3071 | int i = ARRAY_SIZE(udev->endp_number_in); |
3128 | udev->usb_addr = 0; | 3072 | int o = ARRAY_SIZE(udev->endp_number_out); |
3129 | udev->portnumber = 0; | 3073 | udev->usb_device = NULL; |
3130 | while (i-- > 0) { | 3074 | udev->udev_number = 0; |
3131 | udev->endp_number_in[i] = 0; | 3075 | udev->usb_addr = 0; |
3132 | } | 3076 | udev->portnumber = 0; |
3133 | while (o-- > 0) { | 3077 | while (i-- > 0) |
3134 | udev->endp_number_out[o] = 0; | 3078 | udev->endp_number_in[i] = 0; |
3135 | } | 3079 | |
3136 | } | 3080 | while (o-- > 0) |
3137 | while (endps-- > 0) { | 3081 | udev->endp_number_out[o] = 0; |
3138 | u132->endp[endps] = NULL; | 3082 | |
3139 | } | 3083 | } |
3140 | mutex_unlock(&u132->sw_lock); | 3084 | while (endps-- > 0) |
3141 | return; | 3085 | u132->endp[endps] = NULL; |
3086 | |||
3087 | mutex_unlock(&u132->sw_lock); | ||
3088 | return; | ||
3142 | } | 3089 | } |
3143 | 3090 | ||
3144 | static int __devinit u132_probe(struct platform_device *pdev) | 3091 | static int __devinit u132_probe(struct platform_device *pdev) |
3145 | { | 3092 | { |
3146 | struct usb_hcd *hcd; | 3093 | struct usb_hcd *hcd; |
3147 | int retval; | 3094 | int retval; |
3148 | u32 control; | 3095 | u32 control; |
3149 | u32 rh_a = -1; | 3096 | u32 rh_a = -1; |
3150 | u32 num_ports; | 3097 | u32 num_ports; |
3151 | msleep(100); | 3098 | |
3152 | if (u132_exiting > 0) { | 3099 | msleep(100); |
3153 | return -ENODEV; | 3100 | if (u132_exiting > 0) |
3154 | } | 3101 | return -ENODEV; |
3155 | retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE); | 3102 | |
3156 | if (retval) | 3103 | retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE); |
3157 | return retval; | 3104 | if (retval) |
3158 | retval = ftdi_read_pcimem(pdev, control, &control); | 3105 | return retval; |
3159 | if (retval) | 3106 | retval = ftdi_read_pcimem(pdev, control, &control); |
3160 | return retval; | 3107 | if (retval) |
3161 | retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a); | 3108 | return retval; |
3162 | if (retval) | 3109 | retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a); |
3163 | return retval; | 3110 | if (retval) |
3164 | num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */ | 3111 | return retval; |
3165 | if (pdev->dev.dma_mask) { | 3112 | num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */ |
3166 | return -EINVAL; | 3113 | if (pdev->dev.dma_mask) |
3167 | } | 3114 | return -EINVAL; |
3168 | hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id); | 3115 | |
3169 | if (!hcd) { | 3116 | hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id); |
3170 | printk(KERN_ERR "failed to create the usb hcd struct for U132\n" | 3117 | if (!hcd) { |
3171 | ); | 3118 | printk(KERN_ERR "failed to create the usb hcd struct for U132\n" |
3172 | ftdi_elan_gone_away(pdev); | 3119 | ); |
3173 | return -ENOMEM; | 3120 | ftdi_elan_gone_away(pdev); |
3174 | } else { | 3121 | return -ENOMEM; |
3175 | int retval = 0; | 3122 | } else { |
3176 | struct u132 *u132 = hcd_to_u132(hcd); | 3123 | int retval = 0; |
3177 | hcd->rsrc_start = 0; | 3124 | struct u132 *u132 = hcd_to_u132(hcd); |
3178 | mutex_lock(&u132_module_lock); | 3125 | hcd->rsrc_start = 0; |
3179 | list_add_tail(&u132->u132_list, &u132_static_list); | 3126 | mutex_lock(&u132_module_lock); |
3180 | u132->sequence_num = ++u132_instances; | 3127 | list_add_tail(&u132->u132_list, &u132_static_list); |
3181 | mutex_unlock(&u132_module_lock); | 3128 | u132->sequence_num = ++u132_instances; |
3182 | u132_u132_init_kref(u132); | 3129 | mutex_unlock(&u132_module_lock); |
3183 | u132_initialise(u132, pdev); | 3130 | u132_u132_init_kref(u132); |
3184 | hcd->product_desc = "ELAN U132 Host Controller"; | 3131 | u132_initialise(u132, pdev); |
3185 | retval = usb_add_hcd(hcd, 0, 0); | 3132 | hcd->product_desc = "ELAN U132 Host Controller"; |
3186 | if (retval != 0) { | 3133 | retval = usb_add_hcd(hcd, 0, 0); |
3187 | dev_err(&u132->platform_dev->dev, "init error %d\n", | 3134 | if (retval != 0) { |
3188 | retval); | 3135 | dev_err(&u132->platform_dev->dev, "init error %d\n", |
3189 | u132_u132_put_kref(u132); | 3136 | retval); |
3190 | return retval; | 3137 | u132_u132_put_kref(u132); |
3191 | } else { | 3138 | return retval; |
3192 | u132_monitor_queue_work(u132, 100); | 3139 | } else { |
3193 | return 0; | 3140 | u132_monitor_queue_work(u132, 100); |
3194 | } | 3141 | return 0; |
3195 | } | 3142 | } |
3143 | } | ||
3196 | } | 3144 | } |
3197 | 3145 | ||
3198 | 3146 | ||
@@ -3203,61 +3151,58 @@ static int __devinit u132_probe(struct platform_device *pdev) | |||
3203 | */ | 3151 | */ |
3204 | static int u132_suspend(struct platform_device *pdev, pm_message_t state) | 3152 | static int u132_suspend(struct platform_device *pdev, pm_message_t state) |
3205 | { | 3153 | { |
3206 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 3154 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
3207 | struct u132 *u132 = hcd_to_u132(hcd); | 3155 | struct u132 *u132 = hcd_to_u132(hcd); |
3208 | if (u132->going > 1) { | 3156 | if (u132->going > 1) { |
3209 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 3157 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
3210 | , u132->going); | 3158 | , u132->going); |
3211 | return -ENODEV; | 3159 | return -ENODEV; |
3212 | } else if (u132->going > 0) { | 3160 | } else if (u132->going > 0) { |
3213 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 3161 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
3214 | return -ESHUTDOWN; | 3162 | return -ESHUTDOWN; |
3215 | } else { | 3163 | } else { |
3216 | int retval = 0, ports; | 3164 | int retval = 0, ports; |
3217 | 3165 | ||
3218 | switch (state.event) { | 3166 | switch (state.event) { |
3219 | case PM_EVENT_FREEZE: | 3167 | case PM_EVENT_FREEZE: |
3220 | retval = u132_bus_suspend(hcd); | 3168 | retval = u132_bus_suspend(hcd); |
3221 | break; | 3169 | break; |
3222 | case PM_EVENT_SUSPEND: | 3170 | case PM_EVENT_SUSPEND: |
3223 | case PM_EVENT_HIBERNATE: | 3171 | case PM_EVENT_HIBERNATE: |
3224 | ports = MAX_U132_PORTS; | 3172 | ports = MAX_U132_PORTS; |
3225 | while (ports-- > 0) { | 3173 | while (ports-- > 0) { |
3226 | port_power(u132, ports, 0); | 3174 | port_power(u132, ports, 0); |
3227 | } | 3175 | } |
3228 | break; | 3176 | break; |
3229 | } | 3177 | } |
3230 | if (retval == 0) | 3178 | return retval; |
3231 | pdev->dev.power.power_state = state; | 3179 | } |
3232 | return retval; | ||
3233 | } | ||
3234 | } | 3180 | } |
3235 | 3181 | ||
3236 | static int u132_resume(struct platform_device *pdev) | 3182 | static int u132_resume(struct platform_device *pdev) |
3237 | { | 3183 | { |
3238 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 3184 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
3239 | struct u132 *u132 = hcd_to_u132(hcd); | 3185 | struct u132 *u132 = hcd_to_u132(hcd); |
3240 | if (u132->going > 1) { | 3186 | if (u132->going > 1) { |
3241 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | 3187 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" |
3242 | , u132->going); | 3188 | , u132->going); |
3243 | return -ENODEV; | 3189 | return -ENODEV; |
3244 | } else if (u132->going > 0) { | 3190 | } else if (u132->going > 0) { |
3245 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 3191 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
3246 | return -ESHUTDOWN; | 3192 | return -ESHUTDOWN; |
3247 | } else { | 3193 | } else { |
3248 | int retval = 0; | 3194 | int retval = 0; |
3249 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { | 3195 | if (!u132->port[0].power) { |
3250 | int ports = MAX_U132_PORTS; | 3196 | int ports = MAX_U132_PORTS; |
3251 | while (ports-- > 0) { | 3197 | while (ports-- > 0) { |
3252 | port_power(u132, ports, 1); | 3198 | port_power(u132, ports, 1); |
3253 | } | 3199 | } |
3254 | retval = 0; | 3200 | retval = 0; |
3255 | } else { | 3201 | } else { |
3256 | pdev->dev.power.power_state = PMSG_ON; | 3202 | retval = u132_bus_resume(hcd); |
3257 | retval = u132_bus_resume(hcd); | 3203 | } |
3258 | } | 3204 | return retval; |
3259 | return retval; | 3205 | } |
3260 | } | ||
3261 | } | 3206 | } |
3262 | 3207 | ||
3263 | #else | 3208 | #else |
@@ -3270,47 +3215,48 @@ static int u132_resume(struct platform_device *pdev) | |||
3270 | * the platform_driver struct is static because it is per type of module | 3215 | * the platform_driver struct is static because it is per type of module |
3271 | */ | 3216 | */ |
3272 | static struct platform_driver u132_platform_driver = { | 3217 | static struct platform_driver u132_platform_driver = { |
3273 | .probe = u132_probe, | 3218 | .probe = u132_probe, |
3274 | .remove = __devexit_p(u132_remove), | 3219 | .remove = __devexit_p(u132_remove), |
3275 | .suspend = u132_suspend, | 3220 | .suspend = u132_suspend, |
3276 | .resume = u132_resume, | 3221 | .resume = u132_resume, |
3277 | .driver = { | 3222 | .driver = { |
3278 | .name = (char *)hcd_name, | 3223 | .name = (char *)hcd_name, |
3279 | .owner = THIS_MODULE, | 3224 | .owner = THIS_MODULE, |
3280 | }, | 3225 | }, |
3281 | }; | 3226 | }; |
3282 | static int __init u132_hcd_init(void) | 3227 | static int __init u132_hcd_init(void) |
3283 | { | 3228 | { |
3284 | int retval; | 3229 | int retval; |
3285 | INIT_LIST_HEAD(&u132_static_list); | 3230 | INIT_LIST_HEAD(&u132_static_list); |
3286 | u132_instances = 0; | 3231 | u132_instances = 0; |
3287 | u132_exiting = 0; | 3232 | u132_exiting = 0; |
3288 | mutex_init(&u132_module_lock); | 3233 | mutex_init(&u132_module_lock); |
3289 | if (usb_disabled()) | 3234 | if (usb_disabled()) |
3290 | return -ENODEV; | 3235 | return -ENODEV; |
3291 | printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, | 3236 | printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, |
3292 | __DATE__); | 3237 | __DATE__); |
3293 | workqueue = create_singlethread_workqueue("u132"); | 3238 | workqueue = create_singlethread_workqueue("u132"); |
3294 | retval = platform_driver_register(&u132_platform_driver); | 3239 | retval = platform_driver_register(&u132_platform_driver); |
3295 | return retval; | 3240 | return retval; |
3296 | } | 3241 | } |
3297 | 3242 | ||
3298 | 3243 | ||
3299 | module_init(u132_hcd_init); | 3244 | module_init(u132_hcd_init); |
3300 | static void __exit u132_hcd_exit(void) | 3245 | static void __exit u132_hcd_exit(void) |
3301 | { | 3246 | { |
3302 | struct u132 *u132; | 3247 | struct u132 *u132; |
3303 | struct u132 *temp; | 3248 | struct u132 *temp; |
3304 | mutex_lock(&u132_module_lock); | 3249 | mutex_lock(&u132_module_lock); |
3305 | u132_exiting += 1; | 3250 | u132_exiting += 1; |
3306 | mutex_unlock(&u132_module_lock); | 3251 | mutex_unlock(&u132_module_lock); |
3307 | list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { | 3252 | list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { |
3308 | platform_device_unregister(u132->platform_dev); | 3253 | platform_device_unregister(u132->platform_dev); |
3309 | } platform_driver_unregister(&u132_platform_driver); | 3254 | } |
3310 | printk(KERN_INFO "u132-hcd driver deregistered\n"); | 3255 | platform_driver_unregister(&u132_platform_driver); |
3311 | wait_event(u132_hcd_wait, u132_instances == 0); | 3256 | printk(KERN_INFO "u132-hcd driver deregistered\n"); |
3312 | flush_workqueue(workqueue); | 3257 | wait_event(u132_hcd_wait, u132_instances == 0); |
3313 | destroy_workqueue(workqueue); | 3258 | flush_workqueue(workqueue); |
3259 | destroy_workqueue(workqueue); | ||
3314 | } | 3260 | } |
3315 | 3261 | ||
3316 | 3262 | ||
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index ec987897b8ed..d3e0d8aa3980 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -262,20 +262,12 @@ __acquires(uhci->lock) | |||
262 | { | 262 | { |
263 | int auto_stop; | 263 | int auto_stop; |
264 | int int_enable, egsm_enable; | 264 | int int_enable, egsm_enable; |
265 | struct usb_device *rhdev = uhci_to_hcd(uhci)->self.root_hub; | ||
265 | 266 | ||
266 | auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); | 267 | auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); |
267 | dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, | 268 | dev_dbg(&rhdev->dev, "%s%s\n", __func__, |
268 | "%s%s\n", __FUNCTION__, | ||
269 | (auto_stop ? " (auto-stop)" : "")); | 269 | (auto_stop ? " (auto-stop)" : "")); |
270 | 270 | ||
271 | /* If we get a suspend request when we're already auto-stopped | ||
272 | * then there's nothing to do. | ||
273 | */ | ||
274 | if (uhci->rh_state == UHCI_RH_AUTO_STOPPED) { | ||
275 | uhci->rh_state = new_state; | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | /* Enable resume-detect interrupts if they work. | 271 | /* Enable resume-detect interrupts if they work. |
280 | * Then enter Global Suspend mode if _it_ works, still configured. | 272 | * Then enter Global Suspend mode if _it_ works, still configured. |
281 | */ | 273 | */ |
@@ -285,8 +277,10 @@ __acquires(uhci->lock) | |||
285 | if (remote_wakeup_is_broken(uhci)) | 277 | if (remote_wakeup_is_broken(uhci)) |
286 | egsm_enable = 0; | 278 | egsm_enable = 0; |
287 | if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable || | 279 | if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable || |
288 | !device_may_wakeup( | 280 | #ifdef CONFIG_PM |
289 | &uhci_to_hcd(uhci)->self.root_hub->dev)) | 281 | (!auto_stop && !rhdev->do_remote_wakeup) || |
282 | #endif | ||
283 | (auto_stop && !device_may_wakeup(&rhdev->dev))) | ||
290 | uhci->working_RD = int_enable = 0; | 284 | uhci->working_RD = int_enable = 0; |
291 | 285 | ||
292 | outw(int_enable, uhci->io_addr + USBINTR); | 286 | outw(int_enable, uhci->io_addr + USBINTR); |
@@ -308,8 +302,7 @@ __acquires(uhci->lock) | |||
308 | return; | 302 | return; |
309 | } | 303 | } |
310 | if (!(inw(uhci->io_addr + USBSTS) & USBSTS_HCH)) | 304 | if (!(inw(uhci->io_addr + USBSTS) & USBSTS_HCH)) |
311 | dev_warn(&uhci_to_hcd(uhci)->self.root_hub->dev, | 305 | dev_warn(uhci_dev(uhci), "Controller not stopped yet!\n"); |
312 | "Controller not stopped yet!\n"); | ||
313 | 306 | ||
314 | uhci_get_current_frame_number(uhci); | 307 | uhci_get_current_frame_number(uhci); |
315 | 308 | ||
@@ -342,7 +335,7 @@ __releases(uhci->lock) | |||
342 | __acquires(uhci->lock) | 335 | __acquires(uhci->lock) |
343 | { | 336 | { |
344 | dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, | 337 | dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, |
345 | "%s%s\n", __FUNCTION__, | 338 | "%s%s\n", __func__, |
346 | uhci->rh_state == UHCI_RH_AUTO_STOPPED ? | 339 | uhci->rh_state == UHCI_RH_AUTO_STOPPED ? |
347 | " (auto-start)" : ""); | 340 | " (auto-start)" : ""); |
348 | 341 | ||
@@ -737,12 +730,12 @@ static int uhci_rh_resume(struct usb_hcd *hcd) | |||
737 | return rc; | 730 | return rc; |
738 | } | 731 | } |
739 | 732 | ||
740 | static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) | 733 | static int uhci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) |
741 | { | 734 | { |
742 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 735 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
743 | int rc = 0; | 736 | int rc = 0; |
744 | 737 | ||
745 | dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); | 738 | dev_dbg(uhci_dev(uhci), "%s\n", __func__); |
746 | 739 | ||
747 | spin_lock_irq(&uhci->lock); | 740 | spin_lock_irq(&uhci->lock); |
748 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) | 741 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) |
@@ -774,11 +767,11 @@ done: | |||
774 | return rc; | 767 | return rc; |
775 | } | 768 | } |
776 | 769 | ||
777 | static int uhci_resume(struct usb_hcd *hcd) | 770 | static int uhci_pci_resume(struct usb_hcd *hcd) |
778 | { | 771 | { |
779 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 772 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
780 | 773 | ||
781 | dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); | 774 | dev_dbg(uhci_dev(uhci), "%s\n", __func__); |
782 | 775 | ||
783 | /* Since we aren't in D3 any more, it's safe to set this flag | 776 | /* Since we aren't in D3 any more, it's safe to set this flag |
784 | * even if the controller was dead. | 777 | * even if the controller was dead. |
@@ -872,8 +865,8 @@ static const struct hc_driver uhci_driver = { | |||
872 | .reset = uhci_init, | 865 | .reset = uhci_init, |
873 | .start = uhci_start, | 866 | .start = uhci_start, |
874 | #ifdef CONFIG_PM | 867 | #ifdef CONFIG_PM |
875 | .suspend = uhci_suspend, | 868 | .pci_suspend = uhci_pci_suspend, |
876 | .resume = uhci_resume, | 869 | .pci_resume = uhci_pci_resume, |
877 | .bus_suspend = uhci_rh_suspend, | 870 | .bus_suspend = uhci_rh_suspend, |
878 | .bus_resume = uhci_rh_resume, | 871 | .bus_resume = uhci_rh_resume, |
879 | #endif | 872 | #endif |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index 60379b17bbc1..db645936eedd 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -1171,7 +1171,7 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb) | |||
1171 | /* Some debugging code */ | 1171 | /* Some debugging code */ |
1172 | dev_dbg(&urb->dev->dev, | 1172 | dev_dbg(&urb->dev->dev, |
1173 | "%s: failed with status %x\n", | 1173 | "%s: failed with status %x\n", |
1174 | __FUNCTION__, status); | 1174 | __func__, status); |
1175 | 1175 | ||
1176 | if (debug > 1 && errbuf) { | 1176 | if (debug > 1 && errbuf) { |
1177 | /* Print the chain for debugging */ | 1177 | /* Print the chain for debugging */ |