aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-04-19 08:23:28 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-04-19 08:23:28 -0400
commitd5aeee8cb28317ef608ecac421abc4d986d585d2 (patch)
tree70ec8ed8891f26e5c58152ffca9924ea1c58fe3a /drivers/usb
parent32898a145404acbebe3256709e012c2830a2043b (diff)
parente816b57a337ea3b755de72bec38c10c864f23015 (diff)
Merge tag 'v3.4-rc3' into staging/for_v3.5
* tag 'v3.4-rc3': (3755 commits) Linux 3.4-rc3 x86-32: fix up strncpy_from_user() sign error ARM: 7386/1: jump_label: fixup for rename to static_key ARM: 7384/1: ThumbEE: Disable userspace TEEHBR access for !CONFIG_ARM_THUMBEE ARM: 7382/1: mm: truncate memory banks to fit in 4GB space for classic MMU ARM: 7359/2: smp_twd: Only wait for reprogramming on active cpus PCI: Fix regression in pci_restore_state(), v3 SCSI: Fix error handling when no ULD is attached ARM: OMAP: clock: cleanup CPUfreq leftovers, fix build errors ARM: dts: remove blank interrupt-parent properties ARM: EXYNOS: Fix Kconfig dependencies for device tree enabled machine files do not export kernel's NULL #define to userspace ARM: EXYNOS: Remove broken config values for touchscren for NURI board ARM: EXYNOS: set fix xusbxti clock for NURI and Universal210 boards ARM: EXYNOS: fix regulator name for NURI board ARM: SAMSUNG: make SAMSUNG_PM_DEBUG select DEBUG_LL cpufreq: OMAP: fix build errors: depends on ARCH_OMAP2PLUS sparc64: Eliminate obsolete __handle_softirq() function sparc64: Fix bootup crash on sun4v. ARM: msm: Fix section mismatches in proc_comm.c ...
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/Kconfig20
-rw-r--r--drivers/usb/core/driver.c9
-rw-r--r--drivers/usb/core/hcd.c12
-rw-r--r--drivers/usb/core/hub.c16
-rw-r--r--drivers/usb/core/inode.c10
-rw-r--r--drivers/usb/core/message.c11
-rw-r--r--drivers/usb/core/urb.c12
-rw-r--r--drivers/usb/gadget/Kconfig8
-rw-r--r--drivers/usb/gadget/amd5536udc.c1
-rw-r--r--drivers/usb/gadget/at91_udc.c50
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c6
-rw-r--r--drivers/usb/gadget/dummy_hcd.c1
-rw-r--r--drivers/usb/gadget/f_phonet.c2
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c1
-rw-r--r--drivers/usb/gadget/goku_udc.c1
-rw-r--r--drivers/usb/gadget/inode.c1
-rw-r--r--drivers/usb/gadget/langwell_udc.c1
-rw-r--r--drivers/usb/gadget/mv_udc_core.c1
-rw-r--r--drivers/usb/gadget/net2272.c1
-rw-r--r--drivers/usb/gadget/net2280.c1
-rw-r--r--drivers/usb/gadget/omap_udc.c1
-rw-r--r--drivers/usb/gadget/printer.c1
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c1
-rw-r--r--drivers/usb/gadget/rndis.c1
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c1
-rw-r--r--drivers/usb/host/ehci-atmel.c25
-rw-r--r--drivers/usb/host/ehci-dbg.c9
-rw-r--r--drivers/usb/host/ehci-hcd.c4
-rw-r--r--drivers/usb/host/ehci-hub.c31
-rw-r--r--drivers/usb/host/ehci-tegra.c2
-rw-r--r--drivers/usb/host/ehci.h2
-rw-r--r--drivers/usb/host/isp116x-hcd.c1
-rw-r--r--drivers/usb/host/isp1362-hcd.c1
-rw-r--r--drivers/usb/host/ohci-at91.c189
-rw-r--r--drivers/usb/host/ohci-hcd.c3
-rw-r--r--drivers/usb/host/ohci-sa1111.c297
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c1
-rw-r--r--drivers/usb/host/pci-quirks.c13
-rw-r--r--drivers/usb/host/sl811-hcd.c1
-rw-r--r--drivers/usb/host/u132-hcd.c1
-rw-r--r--drivers/usb/host/uhci-hcd.c1
-rw-r--r--drivers/usb/host/uhci-hub.c5
-rw-r--r--drivers/usb/host/xhci-dbg.c2
-rw-r--r--drivers/usb/host/xhci-ext-caps.h5
-rw-r--r--drivers/usb/host/xhci-mem.c9
-rw-r--r--drivers/usb/host/xhci-pci.c4
-rw-r--r--drivers/usb/host/xhci-ring.c6
-rw-r--r--drivers/usb/host/xhci.c12
-rw-r--r--drivers/usb/host/xhci.h4
-rw-r--r--drivers/usb/musb/ux500_dma.c4
-rw-r--r--drivers/usb/renesas_usbhs/fifo.c5
-rw-r--r--drivers/usb/serial/bus.c5
-rw-r--r--drivers/usb/serial/ftdi_sio.c39
-rw-r--r--drivers/usb/serial/metro-usb.c6
-rw-r--r--drivers/usb/serial/option.c7
-rw-r--r--drivers/usb/serial/pl2303.c2
-rw-r--r--drivers/usb/serial/sierra.c1
-rw-r--r--drivers/usb/serial/usb-serial.c31
-rw-r--r--drivers/usb/storage/Kconfig2
-rw-r--r--drivers/usb/storage/usb.c30
60 files changed, 568 insertions, 362 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index e4405e08858..76316a33061 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -2,21 +2,13 @@
2# USB device configuration 2# USB device configuration
3# 3#
4 4
5menuconfig USB_SUPPORT
6 bool "USB support"
7 depends on HAS_IOMEM
8 default y
9 ---help---
10 This option adds core support for Universal Serial Bus (USB).
11 You will also need drivers from the following menu to make use of it.
12
13# many non-PCI SOC chips embed OHCI 5# many non-PCI SOC chips embed OHCI
14config USB_ARCH_HAS_OHCI 6config USB_ARCH_HAS_OHCI
15 boolean 7 boolean
16 # ARM: 8 # ARM:
17 default y if SA1111 9 default y if SA1111
18 default y if ARCH_OMAP 10 default y if ARCH_OMAP
19 default y if ARCH_S3C2410 11 default y if ARCH_S3C24XX
20 default y if PXA27x 12 default y if PXA27x
21 default y if PXA3xx 13 default y if PXA3xx
22 default y if ARCH_EP93XX 14 default y if ARCH_EP93XX
@@ -44,7 +36,7 @@ config USB_ARCH_HAS_EHCI
44 default y if PPC_MPC512x 36 default y if PPC_MPC512x
45 default y if ARCH_IXP4XX 37 default y if ARCH_IXP4XX
46 default y if ARCH_W90X900 38 default y if ARCH_W90X900
47 default y if ARCH_AT91SAM9G45 39 default y if ARCH_AT91
48 default y if ARCH_MXC 40 default y if ARCH_MXC
49 default y if ARCH_OMAP3 41 default y if ARCH_OMAP3
50 default y if ARCH_CNS3XXX 42 default y if ARCH_CNS3XXX
@@ -63,6 +55,14 @@ config USB_ARCH_HAS_XHCI
63 boolean 55 boolean
64 default PCI 56 default PCI
65 57
58menuconfig USB_SUPPORT
59 bool "USB support"
60 depends on HAS_IOMEM
61 default y
62 ---help---
63 This option adds core support for Universal Serial Bus (USB).
64 You will also need drivers from the following menu to make use of it.
65
66if USB_SUPPORT 66if USB_SUPPORT
67 67
68config USB_COMMON 68config USB_COMMON
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index f8e2d6d52e5..9a56635dc19 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1189,8 +1189,13 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1189 if (status == 0) { 1189 if (status == 0) {
1190 status = usb_suspend_device(udev, msg); 1190 status = usb_suspend_device(udev, msg);
1191 1191
1192 /* Again, ignore errors during system sleep transitions */ 1192 /*
1193 if (!PMSG_IS_AUTO(msg)) 1193 * Ignore errors from non-root-hub devices during
1194 * system sleep transitions. For the most part,
1195 * these devices should go to low power anyway when
1196 * the entire bus is suspended.
1197 */
1198 if (udev->parent && !PMSG_IS_AUTO(msg))
1194 status = 0; 1199 status = 0;
1195 } 1200 }
1196 1201
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 9d7fc9a3993..140d3e11f21 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1978,6 +1978,18 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
1978 if (status == 0) { 1978 if (status == 0) {
1979 usb_set_device_state(rhdev, USB_STATE_SUSPENDED); 1979 usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
1980 hcd->state = HC_STATE_SUSPENDED; 1980 hcd->state = HC_STATE_SUSPENDED;
1981
1982 /* Did we race with a root-hub wakeup event? */
1983 if (rhdev->do_remote_wakeup) {
1984 char buffer[6];
1985
1986 status = hcd->driver->hub_status_data(hcd, buffer);
1987 if (status != 0) {
1988 dev_dbg(&rhdev->dev, "suspend raced with wakeup event\n");
1989 hcd_bus_resume(rhdev, PMSG_AUTO_RESUME);
1990 status = -EBUSY;
1991 }
1992 }
1981 } else { 1993 } else {
1982 spin_lock_irq(&hcd_root_hub_lock); 1994 spin_lock_irq(&hcd_root_hub_lock);
1983 if (!HCD_DEAD(hcd)) { 1995 if (!HCD_DEAD(hcd)) {
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 28664eb7f55..a2aa9d652c6 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3163,6 +3163,22 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
3163 if (retval) 3163 if (retval)
3164 goto fail; 3164 goto fail;
3165 3165
3166 /*
3167 * Some superspeed devices have finished the link training process
3168 * and attached to a superspeed hub port, but the device descriptor
3169 * got from those devices show they aren't superspeed devices. Warm
3170 * reset the port attached by the devices can fix them.
3171 */
3172 if ((udev->speed == USB_SPEED_SUPER) &&
3173 (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300)) {
3174 dev_err(&udev->dev, "got a wrong device descriptor, "
3175 "warm reset device\n");
3176 hub_port_reset(hub, port1, udev,
3177 HUB_BH_RESET_TIME, true);
3178 retval = -EINVAL;
3179 goto fail;
3180 }
3181
3166 if (udev->descriptor.bMaxPacketSize0 == 0xff || 3182 if (udev->descriptor.bMaxPacketSize0 == 0xff ||
3167 udev->speed == USB_SPEED_SUPER) 3183 udev->speed == USB_SPEED_SUPER)
3168 i = 512; 3184 i = 512;
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index cefa0c8b5b6..d2b9af59cba 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -428,18 +428,10 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
428 return retval; 428 return retval;
429} 429}
430 430
431static int default_open (struct inode *inode, struct file *file)
432{
433 if (inode->i_private)
434 file->private_data = inode->i_private;
435
436 return 0;
437}
438
439static const struct file_operations default_file_operations = { 431static const struct file_operations default_file_operations = {
440 .read = default_read_file, 432 .read = default_read_file,
441 .write = default_write_file, 433 .write = default_write_file,
442 .open = default_open, 434 .open = simple_open,
443 .llseek = default_file_lseek, 435 .llseek = default_file_lseek,
444}; 436};
445 437
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index b3bdfede45e..aed3e07942d 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -308,7 +308,8 @@ static void sg_complete(struct urb *urb)
308 retval = usb_unlink_urb(io->urbs [i]); 308 retval = usb_unlink_urb(io->urbs [i]);
309 if (retval != -EINPROGRESS && 309 if (retval != -EINPROGRESS &&
310 retval != -ENODEV && 310 retval != -ENODEV &&
311 retval != -EBUSY) 311 retval != -EBUSY &&
312 retval != -EIDRM)
312 dev_err(&io->dev->dev, 313 dev_err(&io->dev->dev,
313 "%s, unlink --> %d\n", 314 "%s, unlink --> %d\n",
314 __func__, retval); 315 __func__, retval);
@@ -317,7 +318,6 @@ static void sg_complete(struct urb *urb)
317 } 318 }
318 spin_lock(&io->lock); 319 spin_lock(&io->lock);
319 } 320 }
320 urb->dev = NULL;
321 321
322 /* on the last completion, signal usb_sg_wait() */ 322 /* on the last completion, signal usb_sg_wait() */
323 io->bytes += urb->actual_length; 323 io->bytes += urb->actual_length;
@@ -524,7 +524,6 @@ void usb_sg_wait(struct usb_sg_request *io)
524 case -ENXIO: /* hc didn't queue this one */ 524 case -ENXIO: /* hc didn't queue this one */
525 case -EAGAIN: 525 case -EAGAIN:
526 case -ENOMEM: 526 case -ENOMEM:
527 io->urbs[i]->dev = NULL;
528 retval = 0; 527 retval = 0;
529 yield(); 528 yield();
530 break; 529 break;
@@ -542,7 +541,6 @@ void usb_sg_wait(struct usb_sg_request *io)
542 541
543 /* fail any uncompleted urbs */ 542 /* fail any uncompleted urbs */
544 default: 543 default:
545 io->urbs[i]->dev = NULL;
546 io->urbs[i]->status = retval; 544 io->urbs[i]->status = retval;
547 dev_dbg(&io->dev->dev, "%s, submit --> %d\n", 545 dev_dbg(&io->dev->dev, "%s, submit --> %d\n",
548 __func__, retval); 546 __func__, retval);
@@ -593,7 +591,10 @@ void usb_sg_cancel(struct usb_sg_request *io)
593 if (!io->urbs [i]->dev) 591 if (!io->urbs [i]->dev)
594 continue; 592 continue;
595 retval = usb_unlink_urb(io->urbs [i]); 593 retval = usb_unlink_urb(io->urbs [i]);
596 if (retval != -EINPROGRESS && retval != -EBUSY) 594 if (retval != -EINPROGRESS
595 && retval != -ENODEV
596 && retval != -EBUSY
597 && retval != -EIDRM)
597 dev_warn(&io->dev->dev, "%s, unlink --> %d\n", 598 dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
598 __func__, retval); 599 __func__, retval);
599 } 600 }
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 7239a73c1b8..cd9b3a2cd8a 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -539,6 +539,10 @@ EXPORT_SYMBOL_GPL(usb_submit_urb);
539 * never submitted, or it was unlinked before, or the hardware is already 539 * never submitted, or it was unlinked before, or the hardware is already
540 * finished with it), even if the completion handler has not yet run. 540 * finished with it), even if the completion handler has not yet run.
541 * 541 *
542 * The URB must not be deallocated while this routine is running. In
543 * particular, when a driver calls this routine, it must insure that the
544 * completion handler cannot deallocate the URB.
545 *
542 * Unlinking and Endpoint Queues: 546 * Unlinking and Endpoint Queues:
543 * 547 *
544 * [The behaviors and guarantees described below do not apply to virtual 548 * [The behaviors and guarantees described below do not apply to virtual
@@ -603,6 +607,10 @@ EXPORT_SYMBOL_GPL(usb_unlink_urb);
603 * with error -EPERM. Thus even if the URB's completion handler always 607 * with error -EPERM. Thus even if the URB's completion handler always
604 * tries to resubmit, it will not succeed and the URB will become idle. 608 * tries to resubmit, it will not succeed and the URB will become idle.
605 * 609 *
610 * The URB must not be deallocated while this routine is running. In
611 * particular, when a driver calls this routine, it must insure that the
612 * completion handler cannot deallocate the URB.
613 *
606 * This routine may not be used in an interrupt context (such as a bottom 614 * This routine may not be used in an interrupt context (such as a bottom
607 * half or a completion handler), or when holding a spinlock, or in other 615 * half or a completion handler), or when holding a spinlock, or in other
608 * situations where the caller can't schedule(). 616 * situations where the caller can't schedule().
@@ -640,6 +648,10 @@ EXPORT_SYMBOL_GPL(usb_kill_urb);
640 * with error -EPERM. Thus even if the URB's completion handler always 648 * with error -EPERM. Thus even if the URB's completion handler always
641 * tries to resubmit, it will not succeed and the URB will become idle. 649 * tries to resubmit, it will not succeed and the URB will become idle.
642 * 650 *
651 * The URB must not be deallocated while this routine is running. In
652 * particular, when a driver calls this routine, it must insure that the
653 * completion handler cannot deallocate the URB.
654 *
643 * This routine may not be used in an interrupt context (such as a bottom 655 * This routine may not be used in an interrupt context (such as a bottom
644 * half or a completion handler), or when holding a spinlock, or in other 656 * half or a completion handler), or when holding a spinlock, or in other
645 * situations where the caller can't schedule(). 657 * situations where the caller can't schedule().
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index c14a3972953..2633f759511 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -137,7 +137,7 @@ choice
137 137
138config USB_AT91 138config USB_AT91
139 tristate "Atmel AT91 USB Device Port" 139 tristate "Atmel AT91 USB Device Port"
140 depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 && !ARCH_AT91SAM9G45 140 depends on ARCH_AT91
141 help 141 help
142 Many Atmel AT91 processors (such as the AT91RM2000) have a 142 Many Atmel AT91 processors (such as the AT91RM2000) have a
143 full speed USB Device Port with support for five configurable 143 full speed USB Device Port with support for five configurable
@@ -150,7 +150,7 @@ config USB_AT91
150config USB_ATMEL_USBA 150config USB_ATMEL_USBA
151 tristate "Atmel USBA" 151 tristate "Atmel USBA"
152 select USB_GADGET_DUALSPEED 152 select USB_GADGET_DUALSPEED
153 depends on AVR32 || ARCH_AT91CAP9 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45 153 depends on AVR32 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45
154 help 154 help
155 USBA is the integrated high-speed USB Device controller on 155 USBA is the integrated high-speed USB Device controller on
156 the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel. 156 the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel.
@@ -284,7 +284,7 @@ config USB_IMX
284 284
285config USB_S3C2410 285config USB_S3C2410
286 tristate "S3C2410 USB Device Controller" 286 tristate "S3C2410 USB Device Controller"
287 depends on ARCH_S3C2410 287 depends on ARCH_S3C24XX
288 help 288 help
289 Samsung's S3C2410 is an ARM-4 processor with an integrated 289 Samsung's S3C2410 is an ARM-4 processor with an integrated
290 full speed USB 1.1 device controller. It has 4 configurable 290 full speed USB 1.1 device controller. It has 4 configurable
@@ -299,7 +299,7 @@ config USB_S3C2410_DEBUG
299 299
300config USB_S3C_HSUDC 300config USB_S3C_HSUDC
301 tristate "S3C2416, S3C2443 and S3C2450 USB Device Controller" 301 tristate "S3C2416, S3C2443 and S3C2450 USB Device Controller"
302 depends on ARCH_S3C2410 302 depends on ARCH_S3C24XX
303 select USB_GADGET_DUALSPEED 303 select USB_GADGET_DUALSPEED
304 help 304 help
305 Samsung's S3C2416, S3C2443 and S3C2450 is an ARM9 based SoC 305 Samsung's S3C2416, S3C2443 and S3C2450 is an ARM9 based SoC
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 2204a4c68d8..77779271f48 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -54,7 +54,6 @@
54#include <linux/prefetch.h> 54#include <linux/prefetch.h>
55 55
56#include <asm/byteorder.h> 56#include <asm/byteorder.h>
57#include <asm/system.h>
58#include <asm/unaligned.h> 57#include <asm/unaligned.h>
59 58
60/* gadget stack */ 59/* gadget stack */
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 15a8cdb2ded..0c935d7c65b 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -29,17 +29,19 @@
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/usb/ch9.h> 30#include <linux/usb/ch9.h>
31#include <linux/usb/gadget.h> 31#include <linux/usb/gadget.h>
32#include <linux/of.h>
33#include <linux/of_gpio.h>
32 34
33#include <asm/byteorder.h> 35#include <asm/byteorder.h>
34#include <mach/hardware.h> 36#include <mach/hardware.h>
35#include <asm/io.h> 37#include <asm/io.h>
36#include <asm/irq.h> 38#include <asm/irq.h>
37#include <asm/system.h>
38#include <asm/gpio.h> 39#include <asm/gpio.h>
39 40
40#include <mach/board.h> 41#include <mach/board.h>
41#include <mach/cpu.h> 42#include <mach/cpu.h>
42#include <mach/at91sam9261_matrix.h> 43#include <mach/at91sam9261_matrix.h>
44#include <mach/at91_matrix.h>
43 45
44#include "at91_udc.h" 46#include "at91_udc.h"
45 47
@@ -910,9 +912,9 @@ static void pullup(struct at91_udc *udc, int is_on)
910 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) { 912 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
911 u32 usbpucr; 913 u32 usbpucr;
912 914
913 usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR); 915 usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
914 usbpucr |= AT91_MATRIX_USBPUCR_PUON; 916 usbpucr |= AT91_MATRIX_USBPUCR_PUON;
915 at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr); 917 at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
916 } 918 }
917 } else { 919 } else {
918 stop_activity(udc); 920 stop_activity(udc);
@@ -928,9 +930,9 @@ static void pullup(struct at91_udc *udc, int is_on)
928 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) { 930 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
929 u32 usbpucr; 931 u32 usbpucr;
930 932
931 usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR); 933 usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
932 usbpucr &= ~AT91_MATRIX_USBPUCR_PUON; 934 usbpucr &= ~AT91_MATRIX_USBPUCR_PUON;
933 at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr); 935 at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
934 } 936 }
935 clk_off(udc); 937 clk_off(udc);
936 } 938 }
@@ -1706,7 +1708,27 @@ static void at91udc_shutdown(struct platform_device *dev)
1706 spin_unlock_irqrestore(&udc->lock, flags); 1708 spin_unlock_irqrestore(&udc->lock, flags);
1707} 1709}
1708 1710
1709static int __init at91udc_probe(struct platform_device *pdev) 1711static void __devinit at91udc_of_init(struct at91_udc *udc,
1712 struct device_node *np)
1713{
1714 struct at91_udc_data *board = &udc->board;
1715 u32 val;
1716 enum of_gpio_flags flags;
1717
1718 if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0)
1719 board->vbus_polled = 1;
1720
1721 board->vbus_pin = of_get_named_gpio_flags(np, "atmel,vbus-gpio", 0,
1722 &flags);
1723 board->vbus_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1724
1725 board->pullup_pin = of_get_named_gpio_flags(np, "atmel,pullup-gpio", 0,
1726 &flags);
1727
1728 board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1729}
1730
1731static int __devinit at91udc_probe(struct platform_device *pdev)
1710{ 1732{
1711 struct device *dev = &pdev->dev; 1733 struct device *dev = &pdev->dev;
1712 struct at91_udc *udc; 1734 struct at91_udc *udc;
@@ -1741,7 +1763,11 @@ static int __init at91udc_probe(struct platform_device *pdev)
1741 /* init software state */ 1763 /* init software state */
1742 udc = &controller; 1764 udc = &controller;
1743 udc->gadget.dev.parent = dev; 1765 udc->gadget.dev.parent = dev;
1744 udc->board = *(struct at91_udc_data *) dev->platform_data; 1766 if (pdev->dev.of_node)
1767 at91udc_of_init(udc, pdev->dev.of_node);
1768 else
1769 memcpy(&udc->board, dev->platform_data,
1770 sizeof(struct at91_udc_data));
1745 udc->pdev = pdev; 1771 udc->pdev = pdev;
1746 udc->enabled = 0; 1772 udc->enabled = 0;
1747 spin_lock_init(&udc->lock); 1773 spin_lock_init(&udc->lock);
@@ -1970,6 +1996,15 @@ static int at91udc_resume(struct platform_device *pdev)
1970#define at91udc_resume NULL 1996#define at91udc_resume NULL
1971#endif 1997#endif
1972 1998
1999#if defined(CONFIG_OF)
2000static const struct of_device_id at91_udc_dt_ids[] = {
2001 { .compatible = "atmel,at91rm9200-udc" },
2002 { /* sentinel */ }
2003};
2004
2005MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
2006#endif
2007
1973static struct platform_driver at91_udc_driver = { 2008static struct platform_driver at91_udc_driver = {
1974 .remove = __exit_p(at91udc_remove), 2009 .remove = __exit_p(at91udc_remove),
1975 .shutdown = at91udc_shutdown, 2010 .shutdown = at91udc_shutdown,
@@ -1978,6 +2013,7 @@ static struct platform_driver at91_udc_driver = {
1978 .driver = { 2013 .driver = {
1979 .name = (char *) driver_name, 2014 .name = (char *) driver_name,
1980 .owner = THIS_MODULE, 2015 .owner = THIS_MODULE,
2016 .of_match_table = of_match_ptr(at91_udc_dt_ids),
1981 }, 2017 },
1982}; 2018};
1983 2019
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 5e10f651ad6..9f98508966d 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -332,12 +332,12 @@ static int vbus_is_present(struct usba_udc *udc)
332 332
333static void toggle_bias(int is_on) 333static void toggle_bias(int is_on)
334{ 334{
335 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR); 335 unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
336 336
337 if (is_on) 337 if (is_on)
338 at91_sys_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN); 338 at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
339 else 339 else
340 at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN)); 340 at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
341} 341}
342 342
343#else 343#else
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index e1cd56c5e2a..a6dfd216416 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -44,7 +44,6 @@
44#include <asm/byteorder.h> 44#include <asm/byteorder.h>
45#include <linux/io.h> 45#include <linux/io.h>
46#include <asm/irq.h> 46#include <asm/irq.h>
47#include <asm/system.h>
48#include <asm/unaligned.h> 47#include <asm/unaligned.h>
49 48
50#define DRIVER_DESC "USB Host+Gadget Emulator" 49#define DRIVER_DESC "USB Host+Gadget Emulator"
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 7cdcb63b21f..965a6293206 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -345,7 +345,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct usb_request *req)
345 } 345 }
346 346
347 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 347 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
348 skb->len <= 1, req->actual); 348 skb->len <= 1, req->actual, PAGE_SIZE);
349 page = NULL; 349 page = NULL;
350 350
351 if (req->actual < req->length) { /* Last fragment */ 351 if (req->actual < req->length) { /* Last fragment */
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index b30e21fdbb1..5f94e79cd6b 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -43,7 +43,6 @@
43 43
44#include <asm/byteorder.h> 44#include <asm/byteorder.h>
45#include <asm/io.h> 45#include <asm/io.h>
46#include <asm/system.h>
47#include <asm/unaligned.h> 46#include <asm/unaligned.h>
48#include <asm/dma.h> 47#include <asm/dma.h>
49 48
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index e1dfd32dc80..e151d6b87de 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -43,7 +43,6 @@
43#include <asm/byteorder.h> 43#include <asm/byteorder.h>
44#include <asm/io.h> 44#include <asm/io.h>
45#include <asm/irq.h> 45#include <asm/irq.h>
46#include <asm/system.h>
47#include <asm/unaligned.h> 46#include <asm/unaligned.h>
48 47
49 48
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 8793f32bab1..e58b1644297 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1574,7 +1574,6 @@ static void destroy_ep_files (struct dev_data *dev)
1574 DBG (dev, "%s %d\n", __func__, dev->state); 1574 DBG (dev, "%s %d\n", __func__, dev->state);
1575 1575
1576 /* dev->state must prevent interference */ 1576 /* dev->state must prevent interference */
1577restart:
1578 spin_lock_irq (&dev->lock); 1577 spin_lock_irq (&dev->lock);
1579 while (!list_empty(&dev->epfiles)) { 1578 while (!list_empty(&dev->epfiles)) {
1580 struct ep_data *ep; 1579 struct ep_data *ep;
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c
index edd52d963f1..f9cedd52cf2 100644
--- a/drivers/usb/gadget/langwell_udc.c
+++ b/drivers/usb/gadget/langwell_udc.c
@@ -32,7 +32,6 @@
32#include <linux/pm.h> 32#include <linux/pm.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/irq.h> 34#include <linux/irq.h>
35#include <asm/system.h>
36#include <asm/unaligned.h> 35#include <asm/unaligned.h>
37 36
38#include "langwell_udc.h" 37#include "langwell_udc.h"
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 19bbe80c2f8..a73cf406e2a 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -34,7 +34,6 @@
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/platform_data/mv_usb.h> 36#include <linux/platform_data/mv_usb.h>
37#include <asm/system.h>
38#include <asm/unaligned.h> 37#include <asm/unaligned.h>
39 38
40#include "mv_udc.h" 39#include "mv_udc.h"
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c
index 01ae56f4717..43ac7482fa9 100644
--- a/drivers/usb/gadget/net2272.c
+++ b/drivers/usb/gadget/net2272.c
@@ -42,7 +42,6 @@
42#include <linux/usb/gadget.h> 42#include <linux/usb/gadget.h>
43 43
44#include <asm/byteorder.h> 44#include <asm/byteorder.h>
45#include <asm/system.h>
46#include <asm/unaligned.h> 45#include <asm/unaligned.h>
47 46
48#include "net2272.h" 47#include "net2272.h"
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index a5ccabc37f3..ac335af154b 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -59,7 +59,6 @@
59#include <asm/byteorder.h> 59#include <asm/byteorder.h>
60#include <asm/io.h> 60#include <asm/io.h>
61#include <asm/irq.h> 61#include <asm/irq.h>
62#include <asm/system.h>
63#include <asm/unaligned.h> 62#include <asm/unaligned.h>
64 63
65 64
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index b44830df593..3b4b6dd0f95 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -40,7 +40,6 @@
40#include <asm/byteorder.h> 40#include <asm/byteorder.h>
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/irq.h> 42#include <asm/irq.h>
43#include <asm/system.h>
44#include <asm/unaligned.h> 43#include <asm/unaligned.h>
45#include <asm/mach-types.h> 44#include <asm/mach-types.h>
46 45
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index d83134b0f78..4e4dc1f5f38 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -34,7 +34,6 @@
34#include <asm/byteorder.h> 34#include <asm/byteorder.h>
35#include <linux/io.h> 35#include <linux/io.h>
36#include <linux/irq.h> 36#include <linux/irq.h>
37#include <asm/system.h>
38#include <linux/uaccess.h> 37#include <linux/uaccess.h>
39#include <asm/unaligned.h> 38#include <asm/unaligned.h>
40 39
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 1b33634f273..41ed69c96d8 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -41,7 +41,6 @@
41#include <asm/byteorder.h> 41#include <asm/byteorder.h>
42#include <asm/dma.h> 42#include <asm/dma.h>
43#include <asm/gpio.h> 43#include <asm/gpio.h>
44#include <asm/system.h>
45#include <asm/mach-types.h> 44#include <asm/mach-types.h>
46#include <asm/unaligned.h> 45#include <asm/unaligned.h>
47 46
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index d3cdffea9c8..73a934a170d 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -34,7 +34,6 @@
34 34
35#include <asm/io.h> 35#include <asm/io.h>
36#include <asm/byteorder.h> 36#include <asm/byteorder.h>
37#include <asm/system.h>
38#include <asm/unaligned.h> 37#include <asm/unaligned.h>
39 38
40 39
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index ab9c65e2c1d..195524cde6c 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -37,7 +37,6 @@
37#include <asm/byteorder.h> 37#include <asm/byteorder.h>
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/irq.h> 39#include <asm/irq.h>
40#include <asm/system.h>
41#include <asm/unaligned.h> 40#include <asm/unaligned.h>
42#include <mach/irqs.h> 41#include <mach/irqs.h>
43 42
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index a5a3ef1f009..cf14c95a670 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -13,6 +13,8 @@
13 13
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/of.h>
17#include <linux/of_platform.h>
16 18
17/* interface and function clocks */ 19/* interface and function clocks */
18static struct clk *iclk, *fclk; 20static struct clk *iclk, *fclk;
@@ -115,6 +117,8 @@ static const struct hc_driver ehci_atmel_hc_driver = {
115 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 117 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
116}; 118};
117 119
120static u64 at91_ehci_dma_mask = DMA_BIT_MASK(32);
121
118static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev) 122static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev)
119{ 123{
120 struct usb_hcd *hcd; 124 struct usb_hcd *hcd;
@@ -137,6 +141,13 @@ static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev)
137 goto fail_create_hcd; 141 goto fail_create_hcd;
138 } 142 }
139 143
144 /* Right now device-tree probed devices don't get dma_mask set.
145 * Since shared usb code relies on it, set it here for now.
146 * Once we have dma capability bindings this can go away.
147 */
148 if (!pdev->dev.dma_mask)
149 pdev->dev.dma_mask = &at91_ehci_dma_mask;
150
140 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 151 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
141 if (!hcd) { 152 if (!hcd) {
142 retval = -ENOMEM; 153 retval = -ENOMEM;
@@ -225,9 +236,21 @@ static int __devexit ehci_atmel_drv_remove(struct platform_device *pdev)
225 return 0; 236 return 0;
226} 237}
227 238
239#ifdef CONFIG_OF
240static const struct of_device_id atmel_ehci_dt_ids[] = {
241 { .compatible = "atmel,at91sam9g45-ehci" },
242 { /* sentinel */ }
243};
244
245MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
246#endif
247
228static struct platform_driver ehci_atmel_driver = { 248static struct platform_driver ehci_atmel_driver = {
229 .probe = ehci_atmel_drv_probe, 249 .probe = ehci_atmel_drv_probe,
230 .remove = __devexit_p(ehci_atmel_drv_remove), 250 .remove = __devexit_p(ehci_atmel_drv_remove),
231 .shutdown = usb_hcd_platform_shutdown, 251 .shutdown = usb_hcd_platform_shutdown,
232 .driver.name = "atmel-ehci", 252 .driver = {
253 .name = "atmel-ehci",
254 .of_match_table = of_match_ptr(atmel_ehci_dt_ids),
255 },
233}; 256};
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index fd9109d7eb0..680e1a31fb8 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -352,7 +352,6 @@ static int debug_async_open(struct inode *, struct file *);
352static int debug_periodic_open(struct inode *, struct file *); 352static int debug_periodic_open(struct inode *, struct file *);
353static int debug_registers_open(struct inode *, struct file *); 353static int debug_registers_open(struct inode *, struct file *);
354static int debug_async_open(struct inode *, struct file *); 354static int debug_async_open(struct inode *, struct file *);
355static int debug_lpm_open(struct inode *, struct file *);
356static ssize_t debug_lpm_read(struct file *file, char __user *user_buf, 355static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
357 size_t count, loff_t *ppos); 356 size_t count, loff_t *ppos);
358static ssize_t debug_lpm_write(struct file *file, const char __user *buffer, 357static ssize_t debug_lpm_write(struct file *file, const char __user *buffer,
@@ -385,7 +384,7 @@ static const struct file_operations debug_registers_fops = {
385}; 384};
386static const struct file_operations debug_lpm_fops = { 385static const struct file_operations debug_lpm_fops = {
387 .owner = THIS_MODULE, 386 .owner = THIS_MODULE,
388 .open = debug_lpm_open, 387 .open = simple_open,
389 .read = debug_lpm_read, 388 .read = debug_lpm_read,
390 .write = debug_lpm_write, 389 .write = debug_lpm_write,
391 .release = debug_lpm_close, 390 .release = debug_lpm_close,
@@ -970,12 +969,6 @@ static int debug_registers_open(struct inode *inode, struct file *file)
970 return file->private_data ? 0 : -ENOMEM; 969 return file->private_data ? 0 : -ENOMEM;
971} 970}
972 971
973static int debug_lpm_open(struct inode *inode, struct file *file)
974{
975 file->private_data = inode->i_private;
976 return 0;
977}
978
979static int debug_lpm_close(struct inode *inode, struct file *file) 972static int debug_lpm_close(struct inode *inode, struct file *file)
980{ 973{
981 return 0; 974 return 0;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index aede6374e4b..806cc95317a 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -45,7 +45,6 @@
45#include <asm/byteorder.h> 45#include <asm/byteorder.h>
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/irq.h> 47#include <asm/irq.h>
48#include <asm/system.h>
49#include <asm/unaligned.h> 48#include <asm/unaligned.h>
50 49
51#if defined(CONFIG_PPC_PS3) 50#if defined(CONFIG_PPC_PS3)
@@ -348,6 +347,8 @@ static int ehci_reset (struct ehci_hcd *ehci)
348 if (ehci->debug) 347 if (ehci->debug)
349 dbgp_external_startup(); 348 dbgp_external_startup();
350 349
350 ehci->port_c_suspend = ehci->suspended_ports =
351 ehci->resuming_ports = 0;
351 return retval; 352 return retval;
352} 353}
353 354
@@ -940,6 +941,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
940 * like usb_port_resume() does. 941 * like usb_port_resume() does.
941 */ 942 */
942 ehci->reset_done[i] = jiffies + msecs_to_jiffies(25); 943 ehci->reset_done[i] = jiffies + msecs_to_jiffies(25);
944 set_bit(i, &ehci->resuming_ports);
943 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 945 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
944 mod_timer(&hcd->rh_timer, ehci->reset_done[i]); 946 mod_timer(&hcd->rh_timer, ehci->reset_done[i]);
945 } 947 }
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 256fbd42e48..38fe0762315 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -223,15 +223,10 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
223 * remote wakeup, we must fail the suspend. 223 * remote wakeup, we must fail the suspend.
224 */ 224 */
225 if (hcd->self.root_hub->do_remote_wakeup) { 225 if (hcd->self.root_hub->do_remote_wakeup) {
226 port = HCS_N_PORTS(ehci->hcs_params); 226 if (ehci->resuming_ports) {
227 while (port--) { 227 spin_unlock_irq(&ehci->lock);
228 if (ehci->reset_done[port] != 0) { 228 ehci_dbg(ehci, "suspend failed because a port is resuming\n");
229 spin_unlock_irq(&ehci->lock); 229 return -EBUSY;
230 ehci_dbg(ehci, "suspend failed because "
231 "port %d is resuming\n",
232 port + 1);
233 return -EBUSY;
234 }
235 } 230 }
236 } 231 }
237 232
@@ -554,16 +549,12 @@ static int
554ehci_hub_status_data (struct usb_hcd *hcd, char *buf) 549ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
555{ 550{
556 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 551 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
557 u32 temp, status = 0; 552 u32 temp, status;
558 u32 mask; 553 u32 mask;
559 int ports, i, retval = 1; 554 int ports, i, retval = 1;
560 unsigned long flags; 555 unsigned long flags;
561 u32 ppcd = 0; 556 u32 ppcd = 0;
562 557
563 /* if !USB_SUSPEND, root hub timers won't get shut down ... */
564 if (ehci->rh_state != EHCI_RH_RUNNING)
565 return 0;
566
567 /* init status to no-changes */ 558 /* init status to no-changes */
568 buf [0] = 0; 559 buf [0] = 0;
569 ports = HCS_N_PORTS (ehci->hcs_params); 560 ports = HCS_N_PORTS (ehci->hcs_params);
@@ -572,6 +563,11 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
572 retval++; 563 retval++;
573 } 564 }
574 565
566 /* Inform the core about resumes-in-progress by returning
567 * a non-zero value even if there are no status changes.
568 */
569 status = ehci->resuming_ports;
570
575 /* Some boards (mostly VIA?) report bogus overcurrent indications, 571 /* Some boards (mostly VIA?) report bogus overcurrent indications,
576 * causing massive log spam unless we completely ignore them. It 572 * causing massive log spam unless we completely ignore them. It
577 * may be relevant that VIA VT8235 controllers, where PORT_POWER is 573 * may be relevant that VIA VT8235 controllers, where PORT_POWER is
@@ -846,6 +842,7 @@ static int ehci_hub_control (
846 ehci_writel(ehci, 842 ehci_writel(ehci,
847 temp & ~(PORT_RWC_BITS | PORT_RESUME), 843 temp & ~(PORT_RWC_BITS | PORT_RESUME),
848 status_reg); 844 status_reg);
845 clear_bit(wIndex, &ehci->resuming_ports);
849 retval = handshake(ehci, status_reg, 846 retval = handshake(ehci, status_reg,
850 PORT_RESUME, 0, 2000 /* 2msec */); 847 PORT_RESUME, 0, 2000 /* 2msec */);
851 if (retval != 0) { 848 if (retval != 0) {
@@ -864,6 +861,7 @@ static int ehci_hub_control (
864 ehci->reset_done[wIndex])) { 861 ehci->reset_done[wIndex])) {
865 status |= USB_PORT_STAT_C_RESET << 16; 862 status |= USB_PORT_STAT_C_RESET << 16;
866 ehci->reset_done [wIndex] = 0; 863 ehci->reset_done [wIndex] = 0;
864 clear_bit(wIndex, &ehci->resuming_ports);
867 865
868 /* force reset to complete */ 866 /* force reset to complete */
869 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), 867 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET),
@@ -884,8 +882,10 @@ static int ehci_hub_control (
884 ehci_readl(ehci, status_reg)); 882 ehci_readl(ehci, status_reg));
885 } 883 }
886 884
887 if (!(temp & (PORT_RESUME|PORT_RESET))) 885 if (!(temp & (PORT_RESUME|PORT_RESET))) {
888 ehci->reset_done[wIndex] = 0; 886 ehci->reset_done[wIndex] = 0;
887 clear_bit(wIndex, &ehci->resuming_ports);
888 }
889 889
890 /* transfer dedicated ports to the companion hc */ 890 /* transfer dedicated ports to the companion hc */
891 if ((temp & PORT_CONNECT) && 891 if ((temp & PORT_CONNECT) &&
@@ -920,6 +920,7 @@ static int ehci_hub_control (
920 status |= USB_PORT_STAT_SUSPEND; 920 status |= USB_PORT_STAT_SUSPEND;
921 } else if (test_bit(wIndex, &ehci->suspended_ports)) { 921 } else if (test_bit(wIndex, &ehci->suspended_ports)) {
922 clear_bit(wIndex, &ehci->suspended_ports); 922 clear_bit(wIndex, &ehci->suspended_ports);
923 clear_bit(wIndex, &ehci->resuming_ports);
923 ehci->reset_done[wIndex] = 0; 924 ehci->reset_done[wIndex] = 0;
924 if (temp & PORT_PE) 925 if (temp & PORT_PE)
925 set_bit(wIndex, &ehci->port_c_suspend); 926 set_bit(wIndex, &ehci->port_c_suspend);
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 3de48a2d795..73544bd440b 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -224,6 +224,7 @@ static int tegra_ehci_hub_control(
224 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); 224 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
225 /* start resume signalling */ 225 /* start resume signalling */
226 ehci_writel(ehci, temp | PORT_RESUME, status_reg); 226 ehci_writel(ehci, temp | PORT_RESUME, status_reg);
227 set_bit(wIndex-1, &ehci->resuming_ports);
227 228
228 spin_unlock_irqrestore(&ehci->lock, flags); 229 spin_unlock_irqrestore(&ehci->lock, flags);
229 msleep(20); 230 msleep(20);
@@ -236,6 +237,7 @@ static int tegra_ehci_hub_control(
236 pr_err("%s: timeout waiting for SUSPEND\n", __func__); 237 pr_err("%s: timeout waiting for SUSPEND\n", __func__);
237 238
238 ehci->reset_done[wIndex-1] = 0; 239 ehci->reset_done[wIndex-1] = 0;
240 clear_bit(wIndex-1, &ehci->resuming_ports);
239 241
240 tegra->port_resuming = 1; 242 tegra->port_resuming = 1;
241 goto done; 243 goto done;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 8f9acbc96fd..2694ed6558d 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -117,6 +117,8 @@ struct ehci_hcd { /* one per controller */
117 the change-suspend feature turned on */ 117 the change-suspend feature turned on */
118 unsigned long suspended_ports; /* which ports are 118 unsigned long suspended_ports; /* which ports are
119 suspended */ 119 suspended */
120 unsigned long resuming_ports; /* which ports have
121 started to resume */
120 122
121 /* per-HC memory pools (could be per-bus, but ...) */ 123 /* per-HC memory pools (could be per-bus, but ...) */
122 struct dma_pool *qh_pool; /* qh per active urb */ 124 struct dma_pool *qh_pool; /* qh per active urb */
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 924880087a7..9e65e3091c8 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -70,7 +70,6 @@
70 70
71#include <asm/io.h> 71#include <asm/io.h>
72#include <asm/irq.h> 72#include <asm/irq.h>
73#include <asm/system.h>
74#include <asm/byteorder.h> 73#include <asm/byteorder.h>
75 74
76#include "isp116x.h" 75#include "isp116x.h"
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 9e63cdf1ab7..2ed112d3e15 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -84,7 +84,6 @@
84#include <linux/prefetch.h> 84#include <linux/prefetch.h>
85 85
86#include <asm/irq.h> 86#include <asm/irq.h>
87#include <asm/system.h>
88#include <asm/byteorder.h> 87#include <asm/byteorder.h>
89#include <asm/unaligned.h> 88#include <asm/unaligned.h>
90 89
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 77afabc77f9..09f597ad6e0 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -14,6 +14,8 @@
14 14
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/of_platform.h>
18#include <linux/of_gpio.h>
17 19
18#include <mach/hardware.h> 20#include <mach/hardware.h>
19#include <asm/gpio.h> 21#include <asm/gpio.h>
@@ -25,6 +27,10 @@
25#error "CONFIG_ARCH_AT91 must be defined." 27#error "CONFIG_ARCH_AT91 must be defined."
26#endif 28#endif
27 29
30#define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
31#define at91_for_each_port(index) \
32 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
33
28/* interface and function clocks; sometimes also an AHB clock */ 34/* interface and function clocks; sometimes also an AHB clock */
29static struct clk *iclk, *fclk, *hclk; 35static struct clk *iclk, *fclk, *hclk;
30static int clocked; 36static int clocked;
@@ -238,26 +244,26 @@ ohci_at91_start (struct usb_hcd *hcd)
238 244
239static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable) 245static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable)
240{ 246{
241 if (port < 0 || port >= 2) 247 if (!valid_port(port))
242 return; 248 return;
243 249
244 if (!gpio_is_valid(pdata->vbus_pin[port])) 250 if (!gpio_is_valid(pdata->vbus_pin[port]))
245 return; 251 return;
246 252
247 gpio_set_value(pdata->vbus_pin[port], 253 gpio_set_value(pdata->vbus_pin[port],
248 !pdata->vbus_pin_active_low[port] ^ enable); 254 pdata->vbus_pin_active_low[port] ^ enable);
249} 255}
250 256
251static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) 257static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
252{ 258{
253 if (port < 0 || port >= 2) 259 if (!valid_port(port))
254 return -EINVAL; 260 return -EINVAL;
255 261
256 if (!gpio_is_valid(pdata->vbus_pin[port])) 262 if (!gpio_is_valid(pdata->vbus_pin[port]))
257 return -EINVAL; 263 return -EINVAL;
258 264
259 return gpio_get_value(pdata->vbus_pin[port]) ^ 265 return gpio_get_value(pdata->vbus_pin[port]) ^
260 !pdata->vbus_pin_active_low[port]; 266 pdata->vbus_pin_active_low[port];
261} 267}
262 268
263/* 269/*
@@ -269,9 +275,9 @@ static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf)
269 int length = ohci_hub_status_data(hcd, buf); 275 int length = ohci_hub_status_data(hcd, buf);
270 int port; 276 int port;
271 277
272 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { 278 at91_for_each_port(port) {
273 if (pdata->overcurrent_changed[port]) { 279 if (pdata->overcurrent_changed[port]) {
274 if (! length) 280 if (!length)
275 length = 1; 281 length = 1;
276 buf[0] |= 1 << (port + 1); 282 buf[0] |= 1 << (port + 1);
277 } 283 }
@@ -295,11 +301,17 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
295 "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n", 301 "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n",
296 hcd, typeReq, wValue, wIndex, buf, wLength); 302 hcd, typeReq, wValue, wIndex, buf, wLength);
297 303
304 wIndex--;
305
298 switch (typeReq) { 306 switch (typeReq) {
299 case SetPortFeature: 307 case SetPortFeature:
300 if (wValue == USB_PORT_FEAT_POWER) { 308 if (wValue == USB_PORT_FEAT_POWER) {
301 dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n"); 309 dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
302 ohci_at91_usb_set_power(pdata, wIndex - 1, 1); 310 if (valid_port(wIndex)) {
311 ohci_at91_usb_set_power(pdata, wIndex, 1);
312 ret = 0;
313 }
314
303 goto out; 315 goto out;
304 } 316 }
305 break; 317 break;
@@ -310,9 +322,9 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
310 dev_dbg(hcd->self.controller, 322 dev_dbg(hcd->self.controller,
311 "ClearPortFeature: C_OVER_CURRENT\n"); 323 "ClearPortFeature: C_OVER_CURRENT\n");
312 324
313 if (wIndex == 1 || wIndex == 2) { 325 if (valid_port(wIndex)) {
314 pdata->overcurrent_changed[wIndex-1] = 0; 326 pdata->overcurrent_changed[wIndex] = 0;
315 pdata->overcurrent_status[wIndex-1] = 0; 327 pdata->overcurrent_status[wIndex] = 0;
316 } 328 }
317 329
318 goto out; 330 goto out;
@@ -321,9 +333,8 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
321 dev_dbg(hcd->self.controller, 333 dev_dbg(hcd->self.controller,
322 "ClearPortFeature: OVER_CURRENT\n"); 334 "ClearPortFeature: OVER_CURRENT\n");
323 335
324 if (wIndex == 1 || wIndex == 2) { 336 if (valid_port(wIndex))
325 pdata->overcurrent_status[wIndex-1] = 0; 337 pdata->overcurrent_status[wIndex] = 0;
326 }
327 338
328 goto out; 339 goto out;
329 340
@@ -331,15 +342,15 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
331 dev_dbg(hcd->self.controller, 342 dev_dbg(hcd->self.controller,
332 "ClearPortFeature: POWER\n"); 343 "ClearPortFeature: POWER\n");
333 344
334 if (wIndex == 1 || wIndex == 2) { 345 if (valid_port(wIndex)) {
335 ohci_at91_usb_set_power(pdata, wIndex - 1, 0); 346 ohci_at91_usb_set_power(pdata, wIndex, 0);
336 return 0; 347 return 0;
337 } 348 }
338 } 349 }
339 break; 350 break;
340 } 351 }
341 352
342 ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); 353 ret = ohci_hub_control(hcd, typeReq, wValue, wIndex + 1, buf, wLength);
343 if (ret) 354 if (ret)
344 goto out; 355 goto out;
345 356
@@ -375,18 +386,15 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
375 386
376 dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex); 387 dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);
377 388
378 if (wIndex == 1 || wIndex == 2) { 389 if (valid_port(wIndex)) {
379 if (! ohci_at91_usb_get_power(pdata, wIndex-1)) { 390 if (!ohci_at91_usb_get_power(pdata, wIndex))
380 *data &= ~cpu_to_le32(RH_PS_PPS); 391 *data &= ~cpu_to_le32(RH_PS_PPS);
381 }
382 392
383 if (pdata->overcurrent_changed[wIndex-1]) { 393 if (pdata->overcurrent_changed[wIndex])
384 *data |= cpu_to_le32(RH_PS_OCIC); 394 *data |= cpu_to_le32(RH_PS_OCIC);
385 }
386 395
387 if (pdata->overcurrent_status[wIndex-1]) { 396 if (pdata->overcurrent_status[wIndex])
388 *data |= cpu_to_le32(RH_PS_POCI); 397 *data |= cpu_to_le32(RH_PS_POCI);
389 }
390 } 398 }
391 } 399 }
392 400
@@ -448,13 +456,14 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
448 456
449 /* From the GPIO notifying the over-current situation, find 457 /* From the GPIO notifying the over-current situation, find
450 * out the corresponding port */ 458 * out the corresponding port */
451 gpio = irq_to_gpio(irq); 459 at91_for_each_port(port) {
452 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { 460 if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) {
453 if (pdata->overcurrent_pin[port] == gpio) 461 gpio = pdata->overcurrent_pin[port];
454 break; 462 break;
463 }
455 } 464 }
456 465
457 if (port == ARRAY_SIZE(pdata->overcurrent_pin)) { 466 if (port == AT91_MAX_USBH_PORTS) {
458 dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n"); 467 dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n");
459 return IRQ_HANDLED; 468 return IRQ_HANDLED;
460 } 469 }
@@ -464,7 +473,7 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
464 /* When notified of an over-current situation, disable power 473 /* When notified of an over-current situation, disable power
465 on the corresponding port, and mark this port in 474 on the corresponding port, and mark this port in
466 over-current. */ 475 over-current. */
467 if (! val) { 476 if (!val) {
468 ohci_at91_usb_set_power(pdata, port, 0); 477 ohci_at91_usb_set_power(pdata, port, 0);
469 pdata->overcurrent_status[port] = 1; 478 pdata->overcurrent_status[port] = 1;
470 pdata->overcurrent_changed[port] = 1; 479 pdata->overcurrent_changed[port] = 1;
@@ -476,34 +485,133 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
476 return IRQ_HANDLED; 485 return IRQ_HANDLED;
477} 486}
478 487
488#ifdef CONFIG_OF
489static const struct of_device_id at91_ohci_dt_ids[] = {
490 { .compatible = "atmel,at91rm9200-ohci" },
491 { /* sentinel */ }
492};
493
494MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
495
496static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32);
497
498static int __devinit ohci_at91_of_init(struct platform_device *pdev)
499{
500 struct device_node *np = pdev->dev.of_node;
501 int i, gpio;
502 enum of_gpio_flags flags;
503 struct at91_usbh_data *pdata;
504 u32 ports;
505
506 if (!np)
507 return 0;
508
509 /* Right now device-tree probed devices don't get dma_mask set.
510 * Since shared usb code relies on it, set it here for now.
511 * Once we have dma capability bindings this can go away.
512 */
513 if (!pdev->dev.dma_mask)
514 pdev->dev.dma_mask = &at91_ohci_dma_mask;
515
516 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
517 if (!pdata)
518 return -ENOMEM;
519
520 if (!of_property_read_u32(np, "num-ports", &ports))
521 pdata->ports = ports;
522
523 at91_for_each_port(i) {
524 gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags);
525 pdata->vbus_pin[i] = gpio;
526 if (!gpio_is_valid(gpio))
527 continue;
528 pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW;
529 }
530
531 at91_for_each_port(i)
532 pdata->overcurrent_pin[i] =
533 of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
534
535 pdev->dev.platform_data = pdata;
536
537 return 0;
538}
539#else
540static int __devinit ohci_at91_of_init(struct platform_device *pdev)
541{
542 return 0;
543}
544#endif
545
479/*-------------------------------------------------------------------------*/ 546/*-------------------------------------------------------------------------*/
480 547
481static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) 548static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
482{ 549{
483 struct at91_usbh_data *pdata = pdev->dev.platform_data; 550 struct at91_usbh_data *pdata;
484 int i; 551 int i;
552 int gpio;
553 int ret;
554
555 ret = ohci_at91_of_init(pdev);
556 if (ret)
557 return ret;
558
559 pdata = pdev->dev.platform_data;
485 560
486 if (pdata) { 561 if (pdata) {
487 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { 562 at91_for_each_port(i) {
488 if (!gpio_is_valid(pdata->vbus_pin[i])) 563 if (!gpio_is_valid(pdata->vbus_pin[i]))
489 continue; 564 continue;
490 gpio_request(pdata->vbus_pin[i], "ohci_vbus"); 565 gpio = pdata->vbus_pin[i];
566
567 ret = gpio_request(gpio, "ohci_vbus");
568 if (ret) {
569 dev_err(&pdev->dev,
570 "can't request vbus gpio %d\n", gpio);
571 continue;
572 }
573 ret = gpio_direction_output(gpio,
574 !pdata->vbus_pin_active_low[i]);
575 if (ret) {
576 dev_err(&pdev->dev,
577 "can't put vbus gpio %d as output %d\n",
578 gpio, !pdata->vbus_pin_active_low[i]);
579 gpio_free(gpio);
580 continue;
581 }
582
491 ohci_at91_usb_set_power(pdata, i, 1); 583 ohci_at91_usb_set_power(pdata, i, 1);
492 } 584 }
493 585
494 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { 586 at91_for_each_port(i) {
495 int ret;
496
497 if (!gpio_is_valid(pdata->overcurrent_pin[i])) 587 if (!gpio_is_valid(pdata->overcurrent_pin[i]))
498 continue; 588 continue;
499 gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); 589 gpio = pdata->overcurrent_pin[i];
590
591 ret = gpio_request(gpio, "ohci_overcurrent");
592 if (ret) {
593 dev_err(&pdev->dev,
594 "can't request overcurrent gpio %d\n",
595 gpio);
596 continue;
597 }
598
599 ret = gpio_direction_input(gpio);
600 if (ret) {
601 dev_err(&pdev->dev,
602 "can't configure overcurrent gpio %d as input\n",
603 gpio);
604 gpio_free(gpio);
605 continue;
606 }
500 607
501 ret = request_irq(gpio_to_irq(pdata->overcurrent_pin[i]), 608 ret = request_irq(gpio_to_irq(gpio),
502 ohci_hcd_at91_overcurrent_irq, 609 ohci_hcd_at91_overcurrent_irq,
503 IRQF_SHARED, "ohci_overcurrent", pdev); 610 IRQF_SHARED, "ohci_overcurrent", pdev);
504 if (ret) { 611 if (ret) {
505 gpio_free(pdata->overcurrent_pin[i]); 612 gpio_free(gpio);
506 dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n"); 613 dev_err(&pdev->dev,
614 "can't get gpio IRQ for overcurrent\n");
507 } 615 }
508 } 616 }
509 } 617 }
@@ -518,14 +626,14 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
518 int i; 626 int i;
519 627
520 if (pdata) { 628 if (pdata) {
521 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { 629 at91_for_each_port(i) {
522 if (!gpio_is_valid(pdata->vbus_pin[i])) 630 if (!gpio_is_valid(pdata->vbus_pin[i]))
523 continue; 631 continue;
524 ohci_at91_usb_set_power(pdata, i, 0); 632 ohci_at91_usb_set_power(pdata, i, 0);
525 gpio_free(pdata->vbus_pin[i]); 633 gpio_free(pdata->vbus_pin[i]);
526 } 634 }
527 635
528 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { 636 at91_for_each_port(i) {
529 if (!gpio_is_valid(pdata->overcurrent_pin[i])) 637 if (!gpio_is_valid(pdata->overcurrent_pin[i]))
530 continue; 638 continue;
531 free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); 639 free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev);
@@ -595,5 +703,6 @@ static struct platform_driver ohci_hcd_at91_driver = {
595 .driver = { 703 .driver = {
596 .name = "at91_ohci", 704 .name = "at91_ohci",
597 .owner = THIS_MODULE, 705 .owner = THIS_MODULE,
706 .of_match_table = of_match_ptr(at91_ohci_dt_ids),
598 }, 707 },
599}; 708};
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index cd5e382db89..235171f2946 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -42,7 +42,6 @@
42 42
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/irq.h> 44#include <asm/irq.h>
45#include <asm/system.h>
46#include <asm/unaligned.h> 45#include <asm/unaligned.h>
47#include <asm/byteorder.h> 46#include <asm/byteorder.h>
48 47
@@ -1000,7 +999,7 @@ MODULE_LICENSE ("GPL");
1000#define SA1111_DRIVER ohci_hcd_sa1111_driver 999#define SA1111_DRIVER ohci_hcd_sa1111_driver
1001#endif 1000#endif
1002 1001
1003#if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C64XX) 1002#if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S3C64XX)
1004#include "ohci-s3c2410.c" 1003#include "ohci-s3c2410.c"
1005#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver 1004#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
1006#endif 1005#endif
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index 4bde4f9821b..e1004fb37bd 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -16,29 +16,115 @@
16#include <mach/hardware.h> 16#include <mach/hardware.h>
17#include <asm/mach-types.h> 17#include <asm/mach-types.h>
18#include <mach/assabet.h> 18#include <mach/assabet.h>
19#include <mach/badge4.h>
20#include <asm/hardware/sa1111.h> 19#include <asm/hardware/sa1111.h>
21 20
22#ifndef CONFIG_SA1111 21#ifndef CONFIG_SA1111
23#error "This file is SA-1111 bus glue. CONFIG_SA1111 must be defined." 22#error "This file is SA-1111 bus glue. CONFIG_SA1111 must be defined."
24#endif 23#endif
25 24
26extern int usb_disabled(void); 25#define USB_STATUS 0x0118
26#define USB_RESET 0x011c
27#define USB_IRQTEST 0x0120
28
29#define USB_RESET_FORCEIFRESET (1 << 0)
30#define USB_RESET_FORCEHCRESET (1 << 1)
31#define USB_RESET_CLKGENRESET (1 << 2)
32#define USB_RESET_SIMSCALEDOWN (1 << 3)
33#define USB_RESET_USBINTTEST (1 << 4)
34#define USB_RESET_SLEEPSTBYEN (1 << 5)
35#define USB_RESET_PWRSENSELOW (1 << 6)
36#define USB_RESET_PWRCTRLLOW (1 << 7)
37
38#define USB_STATUS_IRQHCIRMTWKUP (1 << 7)
39#define USB_STATUS_IRQHCIBUFFACC (1 << 8)
40#define USB_STATUS_NIRQHCIM (1 << 9)
41#define USB_STATUS_NHCIMFCLR (1 << 10)
42#define USB_STATUS_USBPWRSENSE (1 << 11)
27 43
28/*-------------------------------------------------------------------------*/ 44#if 0
45static void dump_hci_status(struct usb_hcd *hcd, const char *label)
46{
47 unsigned long status = sa1111_readl(hcd->regs + USB_STATUS);
48
49 dbg("%s USB_STATUS = { %s%s%s%s%s}", label,
50 ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""),
51 ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""),
52 ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "),
53 ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "),
54 ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : ""));
55}
56#endif
29 57
30static void sa1111_start_hc(struct sa1111_dev *dev) 58static int ohci_sa1111_reset(struct usb_hcd *hcd)
31{ 59{
32 unsigned int usb_rst = 0; 60 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
61
62 ohci_hcd_init(ohci);
63 return ohci_init(ohci);
64}
33 65
34 printk(KERN_DEBUG "%s: starting SA-1111 OHCI USB Controller\n", 66static int __devinit ohci_sa1111_start(struct usb_hcd *hcd)
35 __FILE__); 67{
68 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
69 int ret;
36 70
37#ifdef CONFIG_SA1100_BADGE4 71 ret = ohci_run(ohci);
38 if (machine_is_badge4()) { 72 if (ret < 0) {
39 badge4_set_5V(BADGE4_5V_USB, 1); 73 ohci_err(ohci, "can't start\n");
74 ohci_stop(hcd);
40 } 75 }
76 return ret;
77}
78
79static const struct hc_driver ohci_sa1111_hc_driver = {
80 .description = hcd_name,
81 .product_desc = "SA-1111 OHCI",
82 .hcd_priv_size = sizeof(struct ohci_hcd),
83
84 /*
85 * generic hardware linkage
86 */
87 .irq = ohci_irq,
88 .flags = HCD_USB11 | HCD_MEMORY,
89
90 /*
91 * basic lifecycle operations
92 */
93 .reset = ohci_sa1111_reset,
94 .start = ohci_sa1111_start,
95 .stop = ohci_stop,
96 .shutdown = ohci_shutdown,
97
98 /*
99 * managing i/o requests and associated device resources
100 */
101 .urb_enqueue = ohci_urb_enqueue,
102 .urb_dequeue = ohci_urb_dequeue,
103 .endpoint_disable = ohci_endpoint_disable,
104
105 /*
106 * scheduling support
107 */
108 .get_frame_number = ohci_get_frame,
109
110 /*
111 * root hub support
112 */
113 .hub_status_data = ohci_hub_status_data,
114 .hub_control = ohci_hub_control,
115#ifdef CONFIG_PM
116 .bus_suspend = ohci_bus_suspend,
117 .bus_resume = ohci_bus_resume,
41#endif 118#endif
119 .start_port_reset = ohci_start_port_reset,
120};
121
122static int sa1111_start_hc(struct sa1111_dev *dev)
123{
124 unsigned int usb_rst = 0;
125 int ret;
126
127 dev_dbg(&dev->dev, "starting SA-1111 OHCI USB Controller\n");
42 128
43 if (machine_is_xp860() || 129 if (machine_is_xp860() ||
44 machine_has_neponset() || 130 machine_has_neponset() ||
@@ -51,220 +137,121 @@ static void sa1111_start_hc(struct sa1111_dev *dev)
51 * host controller in reset. 137 * host controller in reset.
52 */ 138 */
53 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, 139 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
54 dev->mapbase + SA1111_USB_RESET); 140 dev->mapbase + USB_RESET);
55 141
56 /* 142 /*
57 * Now, carefully enable the USB clock, and take 143 * Now, carefully enable the USB clock, and take
58 * the USB host controller out of reset. 144 * the USB host controller out of reset.
59 */ 145 */
60 sa1111_enable_device(dev); 146 ret = sa1111_enable_device(dev);
61 udelay(11); 147 if (ret == 0) {
62 sa1111_writel(usb_rst, dev->mapbase + SA1111_USB_RESET); 148 udelay(11);
149 sa1111_writel(usb_rst, dev->mapbase + USB_RESET);
150 }
151
152 return ret;
63} 153}
64 154
65static void sa1111_stop_hc(struct sa1111_dev *dev) 155static void sa1111_stop_hc(struct sa1111_dev *dev)
66{ 156{
67 unsigned int usb_rst; 157 unsigned int usb_rst;
68 printk(KERN_DEBUG "%s: stopping SA-1111 OHCI USB Controller\n", 158
69 __FILE__); 159 dev_dbg(&dev->dev, "stopping SA-1111 OHCI USB Controller\n");
70 160
71 /* 161 /*
72 * Put the USB host controller into reset. 162 * Put the USB host controller into reset.
73 */ 163 */
74 usb_rst = sa1111_readl(dev->mapbase + SA1111_USB_RESET); 164 usb_rst = sa1111_readl(dev->mapbase + USB_RESET);
75 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, 165 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
76 dev->mapbase + SA1111_USB_RESET); 166 dev->mapbase + USB_RESET);
77 167
78 /* 168 /*
79 * Stop the USB clock. 169 * Stop the USB clock.
80 */ 170 */
81 sa1111_disable_device(dev); 171 sa1111_disable_device(dev);
82
83#ifdef CONFIG_SA1100_BADGE4
84 if (machine_is_badge4()) {
85 /* Disable power to the USB bus */
86 badge4_set_5V(BADGE4_5V_USB, 0);
87 }
88#endif
89}
90
91
92/*-------------------------------------------------------------------------*/
93
94#if 0
95static void dump_hci_status(struct usb_hcd *hcd, const char *label)
96{
97 unsigned long status = sa1111_readl(hcd->regs + SA1111_USB_STATUS);
98
99 dbg ("%s USB_STATUS = { %s%s%s%s%s}", label,
100 ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""),
101 ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""),
102 ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "),
103 ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "),
104 ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : ""));
105} 172}
106#endif
107
108/*-------------------------------------------------------------------------*/
109
110/* configure so an HC device and id are always provided */
111/* always called with process context; sleeping is OK */
112
113 173
114/** 174/**
115 * usb_hcd_sa1111_probe - initialize SA-1111-based HCDs 175 * ohci_hcd_sa1111_probe - initialize SA-1111-based HCDs
116 * Context: !in_interrupt()
117 * 176 *
118 * Allocates basic resources for this USB host controller, and 177 * Allocates basic resources for this USB host controller, and
119 * then invokes the start() method for the HCD associated with it 178 * then invokes the start() method for the HCD associated with it.
120 * through the hotplug entry's driver_data.
121 *
122 * Store this function in the HCD's struct pci_driver as probe().
123 */ 179 */
124int usb_hcd_sa1111_probe (const struct hc_driver *driver, 180static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)
125 struct sa1111_dev *dev)
126{ 181{
127 struct usb_hcd *hcd; 182 struct usb_hcd *hcd;
128 int retval; 183 int ret;
129 184
130 hcd = usb_create_hcd (driver, &dev->dev, "sa1111"); 185 if (usb_disabled())
186 return -ENODEV;
187
188 hcd = usb_create_hcd(&ohci_sa1111_hc_driver, &dev->dev, "sa1111");
131 if (!hcd) 189 if (!hcd)
132 return -ENOMEM; 190 return -ENOMEM;
191
133 hcd->rsrc_start = dev->res.start; 192 hcd->rsrc_start = dev->res.start;
134 hcd->rsrc_len = resource_size(&dev->res); 193 hcd->rsrc_len = resource_size(&dev->res);
135 194
136 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 195 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
137 dbg("request_mem_region failed"); 196 dbg("request_mem_region failed");
138 retval = -EBUSY; 197 ret = -EBUSY;
139 goto err1; 198 goto err1;
140 } 199 }
200
141 hcd->regs = dev->mapbase; 201 hcd->regs = dev->mapbase;
142 202
143 sa1111_start_hc(dev); 203 ret = sa1111_start_hc(dev);
144 ohci_hcd_init(hcd_to_ohci(hcd)); 204 if (ret)
205 goto err2;
145 206
146 retval = usb_add_hcd(hcd, dev->irq[1], 0); 207 ret = usb_add_hcd(hcd, dev->irq[1], 0);
147 if (retval == 0) 208 if (ret == 0)
148 return retval; 209 return ret;
149 210
150 sa1111_stop_hc(dev); 211 sa1111_stop_hc(dev);
212 err2:
151 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 213 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
152 err1: 214 err1:
153 usb_put_hcd(hcd); 215 usb_put_hcd(hcd);
154 return retval; 216 return ret;
155} 217}
156 218
157
158/* may be called without controller electrically present */
159/* may be called with controller, bus, and devices active */
160
161/** 219/**
162 * usb_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs 220 * ohci_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs
163 * @dev: USB Host Controller being removed 221 * @dev: USB Host Controller being removed
164 * Context: !in_interrupt()
165 *
166 * Reverses the effect of usb_hcd_sa1111_probe(), first invoking
167 * the HCD's stop() method. It is always called from a thread
168 * context, normally "rmmod", "apmd", or something similar.
169 * 222 *
223 * Reverses the effect of ohci_hcd_sa1111_probe(), first invoking
224 * the HCD's stop() method.
170 */ 225 */
171void usb_hcd_sa1111_remove (struct usb_hcd *hcd, struct sa1111_dev *dev) 226static int ohci_hcd_sa1111_remove(struct sa1111_dev *dev)
172{ 227{
228 struct usb_hcd *hcd = sa1111_get_drvdata(dev);
229
173 usb_remove_hcd(hcd); 230 usb_remove_hcd(hcd);
174 sa1111_stop_hc(dev); 231 sa1111_stop_hc(dev);
175 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 232 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
176 usb_put_hcd(hcd); 233 usb_put_hcd(hcd);
177}
178
179/*-------------------------------------------------------------------------*/
180 234
181static int __devinit
182ohci_sa1111_start (struct usb_hcd *hcd)
183{
184 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
185 int ret;
186
187 if ((ret = ohci_init(ohci)) < 0)
188 return ret;
189
190 if ((ret = ohci_run (ohci)) < 0) {
191 err ("can't start %s", hcd->self.bus_name);
192 ohci_stop (hcd);
193 return ret;
194 }
195 return 0; 235 return 0;
196} 236}
197 237
198/*-------------------------------------------------------------------------*/ 238static void ohci_hcd_sa1111_shutdown(struct sa1111_dev *dev)
199
200static const struct hc_driver ohci_sa1111_hc_driver = {
201 .description = hcd_name,
202 .product_desc = "SA-1111 OHCI",
203 .hcd_priv_size = sizeof(struct ohci_hcd),
204
205 /*
206 * generic hardware linkage
207 */
208 .irq = ohci_irq,
209 .flags = HCD_USB11 | HCD_MEMORY,
210
211 /*
212 * basic lifecycle operations
213 */
214 .start = ohci_sa1111_start,
215 .stop = ohci_stop,
216
217 /*
218 * managing i/o requests and associated device resources
219 */
220 .urb_enqueue = ohci_urb_enqueue,
221 .urb_dequeue = ohci_urb_dequeue,
222 .endpoint_disable = ohci_endpoint_disable,
223
224 /*
225 * scheduling support
226 */
227 .get_frame_number = ohci_get_frame,
228
229 /*
230 * root hub support
231 */
232 .hub_status_data = ohci_hub_status_data,
233 .hub_control = ohci_hub_control,
234#ifdef CONFIG_PM
235 .bus_suspend = ohci_bus_suspend,
236 .bus_resume = ohci_bus_resume,
237#endif
238 .start_port_reset = ohci_start_port_reset,
239};
240
241/*-------------------------------------------------------------------------*/
242
243static int ohci_hcd_sa1111_drv_probe(struct sa1111_dev *dev)
244{
245 int ret;
246
247 if (usb_disabled())
248 return -ENODEV;
249
250 ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, dev);
251 return ret;
252}
253
254static int ohci_hcd_sa1111_drv_remove(struct sa1111_dev *dev)
255{ 239{
256 struct usb_hcd *hcd = sa1111_get_drvdata(dev); 240 struct usb_hcd *hcd = sa1111_get_drvdata(dev);
257 241
258 usb_hcd_sa1111_remove(hcd, dev); 242 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
259 return 0; 243 hcd->driver->shutdown(hcd);
244 sa1111_stop_hc(dev);
245 }
260} 246}
261 247
262static struct sa1111_driver ohci_hcd_sa1111_driver = { 248static struct sa1111_driver ohci_hcd_sa1111_driver = {
263 .drv = { 249 .drv = {
264 .name = "sa1111-ohci", 250 .name = "sa1111-ohci",
251 .owner = THIS_MODULE,
265 }, 252 },
266 .devid = SA1111_DEVID_USB, 253 .devid = SA1111_DEVID_USB,
267 .probe = ohci_hcd_sa1111_drv_probe, 254 .probe = ohci_hcd_sa1111_probe,
268 .remove = ohci_hcd_sa1111_drv_remove, 255 .remove = ohci_hcd_sa1111_remove,
256 .shutdown = ohci_hcd_sa1111_shutdown,
269}; 257};
270
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 015c7c62ed4..3b38030b02a 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -40,7 +40,6 @@
40#include <linux/io.h> 40#include <linux/io.h>
41 41
42#include <asm/irq.h> 42#include <asm/irq.h>
43#include <asm/system.h>
44#include <asm/unaligned.h> 43#include <asm/unaligned.h>
45 44
46#include <linux/irq.h> 45#include <linux/irq.h>
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 7732d69e49e..32dada8c8b4 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -825,9 +825,13 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev)
825 } 825 }
826 } 826 }
827 827
828 /* Disable any BIOS SMIs */ 828 val = readl(base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
829 writel(XHCI_LEGACY_DISABLE_SMI, 829 /* Mask off (turn off) any enabled SMIs */
830 base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); 830 val &= XHCI_LEGACY_DISABLE_SMI;
831 /* Mask all SMI events bits, RW1C */
832 val |= XHCI_LEGACY_SMI_EVENTS;
833 /* Disable any BIOS SMIs and clear all SMI events*/
834 writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
831 835
832 if (usb_is_intel_switchable_xhci(pdev)) 836 if (usb_is_intel_switchable_xhci(pdev))
833 usb_enable_xhci_ports(pdev); 837 usb_enable_xhci_ports(pdev);
@@ -893,4 +897,5 @@ static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
893 quirk_usb_handoff_xhci(pdev); 897 quirk_usb_handoff_xhci(pdev);
894 pci_disable_device(pdev); 898 pci_disable_device(pdev);
895} 899}
896DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff); 900DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
901 PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 2a2cce2d2fa..91ce1c02e61 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -51,7 +51,6 @@
51 51
52#include <asm/io.h> 52#include <asm/io.h>
53#include <asm/irq.h> 53#include <asm/irq.h>
54#include <asm/system.h>
55#include <asm/byteorder.h> 54#include <asm/byteorder.h>
56#include <asm/unaligned.h> 55#include <asm/unaligned.h>
57 56
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 16dd6a6abf0..dbbd1ba2522 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -55,7 +55,6 @@
55#include <linux/mutex.h> 55#include <linux/mutex.h>
56#include <asm/io.h> 56#include <asm/io.h>
57#include <asm/irq.h> 57#include <asm/irq.h>
58#include <asm/system.h>
59#include <asm/byteorder.h> 58#include <asm/byteorder.h>
60 59
61 /* FIXME ohci.h is ONLY for internal use by the OHCI driver. 60 /* FIXME ohci.h is ONLY for internal use by the OHCI driver.
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index e37dea87bb5..e4db350602b 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -45,7 +45,6 @@
45#include <asm/uaccess.h> 45#include <asm/uaccess.h>
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/irq.h> 47#include <asm/irq.h>
48#include <asm/system.h>
49 48
50#include "uhci-hcd.h" 49#include "uhci-hcd.h"
51 50
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index 045cde4cbc3..768d54295a2 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -196,11 +196,12 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf)
196 status = get_hub_status_data(uhci, buf); 196 status = get_hub_status_data(uhci, buf);
197 197
198 switch (uhci->rh_state) { 198 switch (uhci->rh_state) {
199 case UHCI_RH_SUSPENDING:
200 case UHCI_RH_SUSPENDED: 199 case UHCI_RH_SUSPENDED:
201 /* if port change, ask to be resumed */ 200 /* if port change, ask to be resumed */
202 if (status || uhci->resuming_ports) 201 if (status || uhci->resuming_ports) {
202 status = 1;
203 usb_hcd_resume_root_hub(hcd); 203 usb_hcd_resume_root_hub(hcd);
204 }
204 break; 205 break;
205 206
206 case UHCI_RH_AUTO_STOPPED: 207 case UHCI_RH_AUTO_STOPPED:
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index e9b0f043455..4b436f5a417 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -119,7 +119,7 @@ static void xhci_print_command_reg(struct xhci_hcd *xhci)
119 xhci_dbg(xhci, " Event Interrupts %s\n", 119 xhci_dbg(xhci, " Event Interrupts %s\n",
120 (temp & CMD_EIE) ? "enabled " : "disabled"); 120 (temp & CMD_EIE) ? "enabled " : "disabled");
121 xhci_dbg(xhci, " Host System Error Interrupts %s\n", 121 xhci_dbg(xhci, " Host System Error Interrupts %s\n",
122 (temp & CMD_EIE) ? "enabled " : "disabled"); 122 (temp & CMD_HSEIE) ? "enabled " : "disabled");
123 xhci_dbg(xhci, " HC has %sfinished light reset\n", 123 xhci_dbg(xhci, " HC has %sfinished light reset\n",
124 (temp & CMD_LRESET) ? "not " : ""); 124 (temp & CMD_LRESET) ? "not " : "");
125} 125}
diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index c7f33123d4c..377f4242dab 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -62,8 +62,9 @@
62/* USB Legacy Support Control and Status Register - section 7.1.2 */ 62/* USB Legacy Support Control and Status Register - section 7.1.2 */
63/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */ 63/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */
64#define XHCI_LEGACY_CONTROL_OFFSET (0x04) 64#define XHCI_LEGACY_CONTROL_OFFSET (0x04)
65/* bits 1:2, 5:12, and 17:19 need to be preserved; bits 21:28 should be zero */ 65/* bits 1:3, 5:12, and 17:19 need to be preserved; bits 21:28 should be zero */
66#define XHCI_LEGACY_DISABLE_SMI ((0x3 << 1) + (0xff << 5) + (0x7 << 17)) 66#define XHCI_LEGACY_DISABLE_SMI ((0x7 << 1) + (0xff << 5) + (0x7 << 17))
67#define XHCI_LEGACY_SMI_EVENTS (0x7 << 29)
67 68
68/* USB 2.0 xHCI 0.96 L1C capability - section 7.2.2.1.3.2 */ 69/* USB 2.0 xHCI 0.96 L1C capability - section 7.2.2.1.3.2 */
69#define XHCI_L1C (1 << 16) 70#define XHCI_L1C (1 << 16)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index cae4c6f2845..68eaa908ac8 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1796,11 +1796,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1796 int i; 1796 int i;
1797 1797
1798 /* Free the Event Ring Segment Table and the actual Event Ring */ 1798 /* Free the Event Ring Segment Table and the actual Event Ring */
1799 if (xhci->ir_set) {
1800 xhci_writel(xhci, 0, &xhci->ir_set->erst_size);
1801 xhci_write_64(xhci, 0, &xhci->ir_set->erst_base);
1802 xhci_write_64(xhci, 0, &xhci->ir_set->erst_dequeue);
1803 }
1804 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 1799 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
1805 if (xhci->erst.entries) 1800 if (xhci->erst.entries)
1806 dma_free_coherent(&pdev->dev, size, 1801 dma_free_coherent(&pdev->dev, size,
@@ -1812,7 +1807,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1812 xhci->event_ring = NULL; 1807 xhci->event_ring = NULL;
1813 xhci_dbg(xhci, "Freed event ring\n"); 1808 xhci_dbg(xhci, "Freed event ring\n");
1814 1809
1815 xhci_write_64(xhci, 0, &xhci->op_regs->cmd_ring);
1816 if (xhci->cmd_ring) 1810 if (xhci->cmd_ring)
1817 xhci_ring_free(xhci, xhci->cmd_ring); 1811 xhci_ring_free(xhci, xhci->cmd_ring);
1818 xhci->cmd_ring = NULL; 1812 xhci->cmd_ring = NULL;
@@ -1841,7 +1835,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1841 xhci->medium_streams_pool = NULL; 1835 xhci->medium_streams_pool = NULL;
1842 xhci_dbg(xhci, "Freed medium stream array pool\n"); 1836 xhci_dbg(xhci, "Freed medium stream array pool\n");
1843 1837
1844 xhci_write_64(xhci, 0, &xhci->op_regs->dcbaa_ptr);
1845 if (xhci->dcbaa) 1838 if (xhci->dcbaa)
1846 dma_free_coherent(&pdev->dev, sizeof(*xhci->dcbaa), 1839 dma_free_coherent(&pdev->dev, sizeof(*xhci->dcbaa),
1847 xhci->dcbaa, xhci->dcbaa->dma); 1840 xhci->dcbaa, xhci->dcbaa->dma);
@@ -2459,6 +2452,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2459 2452
2460fail: 2453fail:
2461 xhci_warn(xhci, "Couldn't initialize memory\n"); 2454 xhci_warn(xhci, "Couldn't initialize memory\n");
2455 xhci_halt(xhci);
2456 xhci_reset(xhci);
2462 xhci_mem_cleanup(xhci); 2457 xhci_mem_cleanup(xhci);
2463 return -ENOMEM; 2458 return -ENOMEM;
2464} 2459}
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index ef98b38626f..7a856a767e7 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -95,6 +95,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
95 xhci->quirks |= XHCI_RESET_ON_RESUME; 95 xhci->quirks |= XHCI_RESET_ON_RESUME;
96 xhci_dbg(xhci, "QUIRK: Resetting on resume\n"); 96 xhci_dbg(xhci, "QUIRK: Resetting on resume\n");
97 } 97 }
98 if (pdev->vendor == PCI_VENDOR_ID_VIA)
99 xhci->quirks |= XHCI_RESET_ON_RESUME;
98} 100}
99 101
100/* called during probe() after chip reset completes */ 102/* called during probe() after chip reset completes */
@@ -326,7 +328,7 @@ int __init xhci_register_pci(void)
326 return pci_register_driver(&xhci_pci_driver); 328 return pci_register_driver(&xhci_pci_driver);
327} 329}
328 330
329void __exit xhci_unregister_pci(void) 331void xhci_unregister_pci(void)
330{ 332{
331 pci_unregister_driver(&xhci_pci_driver); 333 pci_unregister_driver(&xhci_pci_driver);
332} 334}
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 6bd9d53062e..3d9422f16a2 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2417,7 +2417,7 @@ hw_died:
2417 u32 irq_pending; 2417 u32 irq_pending;
2418 /* Acknowledge the PCI interrupt */ 2418 /* Acknowledge the PCI interrupt */
2419 irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); 2419 irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
2420 irq_pending |= 0x3; 2420 irq_pending |= IMAN_IP;
2421 xhci_writel(xhci, irq_pending, &xhci->ir_set->irq_pending); 2421 xhci_writel(xhci, irq_pending, &xhci->ir_set->irq_pending);
2422 } 2422 }
2423 2423
@@ -2734,7 +2734,7 @@ int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2734 urb->dev->speed == USB_SPEED_FULL) 2734 urb->dev->speed == USB_SPEED_FULL)
2735 urb->interval /= 8; 2735 urb->interval /= 8;
2736 } 2736 }
2737 return xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); 2737 return xhci_queue_bulk_tx(xhci, mem_flags, urb, slot_id, ep_index);
2738} 2738}
2739 2739
2740/* 2740/*
@@ -3514,7 +3514,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
3514 } 3514 }
3515 ep_ring->num_trbs_free_temp = ep_ring->num_trbs_free; 3515 ep_ring->num_trbs_free_temp = ep_ring->num_trbs_free;
3516 3516
3517 return xhci_queue_isoc_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); 3517 return xhci_queue_isoc_tx(xhci, mem_flags, urb, slot_id, ep_index);
3518} 3518}
3519 3519
3520/**** Command Ring Operations ****/ 3520/**** Command Ring Operations ****/
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index e1963d4a430..36641a7f237 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -106,6 +106,9 @@ int xhci_halt(struct xhci_hcd *xhci)
106 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); 106 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
107 if (!ret) 107 if (!ret)
108 xhci->xhc_state |= XHCI_STATE_HALTED; 108 xhci->xhc_state |= XHCI_STATE_HALTED;
109 else
110 xhci_warn(xhci, "Host not halted after %u microseconds.\n",
111 XHCI_MAX_HALT_USEC);
109 return ret; 112 return ret;
110} 113}
111 114
@@ -664,11 +667,11 @@ static void xhci_save_registers(struct xhci_hcd *xhci)
664 xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification); 667 xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification);
665 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); 668 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
666 xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg); 669 xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg);
667 xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
668 xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control);
669 xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size); 670 xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size);
670 xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base); 671 xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base);
671 xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 672 xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
673 xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
674 xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control);
672} 675}
673 676
674static void xhci_restore_registers(struct xhci_hcd *xhci) 677static void xhci_restore_registers(struct xhci_hcd *xhci)
@@ -677,10 +680,11 @@ static void xhci_restore_registers(struct xhci_hcd *xhci)
677 xhci_writel(xhci, xhci->s3.dev_nt, &xhci->op_regs->dev_notification); 680 xhci_writel(xhci, xhci->s3.dev_nt, &xhci->op_regs->dev_notification);
678 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr); 681 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr);
679 xhci_writel(xhci, xhci->s3.config_reg, &xhci->op_regs->config_reg); 682 xhci_writel(xhci, xhci->s3.config_reg, &xhci->op_regs->config_reg);
680 xhci_writel(xhci, xhci->s3.irq_pending, &xhci->ir_set->irq_pending);
681 xhci_writel(xhci, xhci->s3.irq_control, &xhci->ir_set->irq_control);
682 xhci_writel(xhci, xhci->s3.erst_size, &xhci->ir_set->erst_size); 683 xhci_writel(xhci, xhci->s3.erst_size, &xhci->ir_set->erst_size);
683 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base); 684 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base);
685 xhci_write_64(xhci, xhci->s3.erst_dequeue, &xhci->ir_set->erst_dequeue);
686 xhci_writel(xhci, xhci->s3.irq_pending, &xhci->ir_set->irq_pending);
687 xhci_writel(xhci, xhci->s3.irq_control, &xhci->ir_set->irq_control);
684} 688}
685 689
686static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci) 690static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 91074fdab3e..3d69c4b2b54 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -205,6 +205,10 @@ struct xhci_op_regs {
205#define CMD_PM_INDEX (1 << 11) 205#define CMD_PM_INDEX (1 << 11)
206/* bits 12:31 are reserved (and should be preserved on writes). */ 206/* bits 12:31 are reserved (and should be preserved on writes). */
207 207
208/* IMAN - Interrupt Management Register */
209#define IMAN_IP (1 << 1)
210#define IMAN_IE (1 << 0)
211
208/* USBSTS - USB status - status bitmasks */ 212/* USBSTS - USB status - status bitmasks */
209/* HC not running - set to 1 when run/stop bit is cleared. */ 213/* HC not running - set to 1 when run/stop bit is cleared. */
210#define STS_HALT XHCI_STS_HALT 214#define STS_HALT XHCI_STS_HALT
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 97cb45916c4..d05c7fbbb70 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -115,12 +115,12 @@ static bool ux500_configure_channel(struct dma_channel *channel,
115 slave_conf.dst_addr = usb_fifo_addr; 115 slave_conf.dst_addr = usb_fifo_addr;
116 slave_conf.dst_addr_width = addr_width; 116 slave_conf.dst_addr_width = addr_width;
117 slave_conf.dst_maxburst = 16; 117 slave_conf.dst_maxburst = 16;
118 slave_conf.device_fc = false;
118 119
119 dma_chan->device->device_control(dma_chan, DMA_SLAVE_CONFIG, 120 dma_chan->device->device_control(dma_chan, DMA_SLAVE_CONFIG,
120 (unsigned long) &slave_conf); 121 (unsigned long) &slave_conf);
121 122
122 dma_desc = dma_chan->device-> 123 dma_desc = dmaengine_prep_slave_sg(dma_chan, &sg, 1, direction,
123 device_prep_slave_sg(dma_chan, &sg, 1, direction,
124 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 124 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
125 if (!dma_desc) 125 if (!dma_desc)
126 return false; 126 return false;
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 3648c82a17f..6ec7f838d7f 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -786,9 +786,8 @@ static void xfer_work(struct work_struct *work)
786 sg_dma_address(&sg) = pkt->dma + pkt->actual; 786 sg_dma_address(&sg) = pkt->dma + pkt->actual;
787 sg_dma_len(&sg) = pkt->trans; 787 sg_dma_len(&sg) = pkt->trans;
788 788
789 desc = chan->device->device_prep_slave_sg(chan, &sg, 1, dir, 789 desc = dmaengine_prep_slave_sg(chan, &sg, 1, dir,
790 DMA_PREP_INTERRUPT | 790 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
791 DMA_CTRL_ACK);
792 if (!desc) 791 if (!desc)
793 return; 792 return;
794 793
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 7f547dc3a59..ed8adb052ca 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -60,8 +60,6 @@ static int usb_serial_device_probe(struct device *dev)
60 retval = -ENODEV; 60 retval = -ENODEV;
61 goto exit; 61 goto exit;
62 } 62 }
63 if (port->dev_state != PORT_REGISTERING)
64 goto exit;
65 63
66 driver = port->serial->type; 64 driver = port->serial->type;
67 if (driver->port_probe) { 65 if (driver->port_probe) {
@@ -98,9 +96,6 @@ static int usb_serial_device_remove(struct device *dev)
98 if (!port) 96 if (!port)
99 return -ENODEV; 97 return -ENODEV;
100 98
101 if (port->dev_state != PORT_UNREGISTERING)
102 return retval;
103
104 device_remove_file(&port->dev, &dev_attr_port_number); 99 device_remove_file(&port->dev, &dev_attr_port_number);
105 100
106 driver = port->serial->type; 101 driver = port->serial->type;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 7c229d30468..02e7f2d32d5 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -75,7 +75,8 @@ struct ftdi_private {
75 unsigned long last_dtr_rts; /* saved modem control outputs */ 75 unsigned long last_dtr_rts; /* saved modem control outputs */
76 struct async_icount icount; 76 struct async_icount icount;
77 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 77 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
78 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 78 char prev_status; /* Used for TIOCMIWAIT */
79 bool dev_gone; /* Used to abort TIOCMIWAIT */
79 char transmit_empty; /* If transmitter is empty or not */ 80 char transmit_empty; /* If transmitter is empty or not */
80 struct usb_serial_port *port; 81 struct usb_serial_port *port;
81 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface 82 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface
@@ -1681,6 +1682,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1681 init_waitqueue_head(&priv->delta_msr_wait); 1682 init_waitqueue_head(&priv->delta_msr_wait);
1682 1683
1683 priv->flags = ASYNC_LOW_LATENCY; 1684 priv->flags = ASYNC_LOW_LATENCY;
1685 priv->dev_gone = false;
1684 1686
1685 if (quirk && quirk->port_probe) 1687 if (quirk && quirk->port_probe)
1686 quirk->port_probe(priv); 1688 quirk->port_probe(priv);
@@ -1724,7 +1726,8 @@ static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
1724 1726
1725/* 1727/*
1726 * Module parameter to control latency timer for NDI FTDI-based USB devices. 1728 * Module parameter to control latency timer for NDI FTDI-based USB devices.
1727 * If this value is not set in modprobe.conf.local its value will be set to 1ms. 1729 * If this value is not set in /etc/modprobe.d/ its value will be set
1730 * to 1ms.
1728 */ 1731 */
1729static int ndi_latency_timer = 1; 1732static int ndi_latency_timer = 1;
1730 1733
@@ -1838,6 +1841,9 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1838 1841
1839 dbg("%s", __func__); 1842 dbg("%s", __func__);
1840 1843
1844 priv->dev_gone = true;
1845 wake_up_interruptible_all(&priv->delta_msr_wait);
1846
1841 remove_sysfs_attrs(port); 1847 remove_sysfs_attrs(port);
1842 1848
1843 kref_put(&priv->kref, ftdi_sio_priv_release); 1849 kref_put(&priv->kref, ftdi_sio_priv_release);
@@ -1981,17 +1987,19 @@ static int ftdi_process_packet(struct tty_struct *tty,
1981 N.B. packet may be processed more than once, but differences 1987 N.B. packet may be processed more than once, but differences
1982 are only processed once. */ 1988 are only processed once. */
1983 status = packet[0] & FTDI_STATUS_B0_MASK; 1989 status = packet[0] & FTDI_STATUS_B0_MASK;
1984 if (status & FTDI_RS0_CTS)
1985 priv->icount.cts++;
1986 if (status & FTDI_RS0_DSR)
1987 priv->icount.dsr++;
1988 if (status & FTDI_RS0_RI)
1989 priv->icount.rng++;
1990 if (status & FTDI_RS0_RLSD)
1991 priv->icount.dcd++;
1992 if (status != priv->prev_status) { 1990 if (status != priv->prev_status) {
1993 priv->diff_status |= status ^ priv->prev_status; 1991 char diff_status = status ^ priv->prev_status;
1994 wake_up_interruptible(&priv->delta_msr_wait); 1992
1993 if (diff_status & FTDI_RS0_CTS)
1994 priv->icount.cts++;
1995 if (diff_status & FTDI_RS0_DSR)
1996 priv->icount.dsr++;
1997 if (diff_status & FTDI_RS0_RI)
1998 priv->icount.rng++;
1999 if (diff_status & FTDI_RS0_RLSD)
2000 priv->icount.dcd++;
2001
2002 wake_up_interruptible_all(&priv->delta_msr_wait);
1995 priv->prev_status = status; 2003 priv->prev_status = status;
1996 } 2004 }
1997 2005
@@ -2394,15 +2402,12 @@ static int ftdi_ioctl(struct tty_struct *tty,
2394 */ 2402 */
2395 case TIOCMIWAIT: 2403 case TIOCMIWAIT:
2396 cprev = priv->icount; 2404 cprev = priv->icount;
2397 while (1) { 2405 while (!priv->dev_gone) {
2398 interruptible_sleep_on(&priv->delta_msr_wait); 2406 interruptible_sleep_on(&priv->delta_msr_wait);
2399 /* see if a signal did it */ 2407 /* see if a signal did it */
2400 if (signal_pending(current)) 2408 if (signal_pending(current))
2401 return -ERESTARTSYS; 2409 return -ERESTARTSYS;
2402 cnow = priv->icount; 2410 cnow = priv->icount;
2403 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
2404 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
2405 return -EIO; /* no change => error */
2406 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || 2411 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
2407 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || 2412 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
2408 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || 2413 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
@@ -2411,7 +2416,7 @@ static int ftdi_ioctl(struct tty_struct *tty,
2411 } 2416 }
2412 cprev = cnow; 2417 cprev = cnow;
2413 } 2418 }
2414 /* not reached */ 2419 return -EIO;
2415 break; 2420 break;
2416 case TIOCSERGETLSR: 2421 case TIOCSERGETLSR:
2417 return get_lsr_info(port, (struct serial_struct __user *)arg); 2422 return get_lsr_info(port, (struct serial_struct __user *)arg);
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 6e1622f2a29..08d16e8c002 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -27,8 +27,8 @@
27 27
28/* Product information. */ 28/* Product information. */
29#define FOCUS_VENDOR_ID 0x0C2E 29#define FOCUS_VENDOR_ID 0x0C2E
30#define FOCUS_PRODUCT_ID 0x0720 30#define FOCUS_PRODUCT_ID_BI 0x0720
31#define FOCUS_PRODUCT_ID_UNI 0x0710 31#define FOCUS_PRODUCT_ID_UNI 0x0700
32 32
33#define METROUSB_SET_REQUEST_TYPE 0x40 33#define METROUSB_SET_REQUEST_TYPE 0x40
34#define METROUSB_SET_MODEM_CTRL_REQUEST 10 34#define METROUSB_SET_MODEM_CTRL_REQUEST 10
@@ -47,7 +47,7 @@ struct metrousb_private {
47 47
48/* Device table list. */ 48/* Device table list. */
49static struct usb_device_id id_table[] = { 49static struct usb_device_id id_table[] = {
50 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID) }, 50 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_BI) },
51 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) }, 51 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) },
52 { }, /* Terminating entry. */ 52 { }, /* Terminating entry. */
53}; 53};
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6815701cf65..f4465ccddc3 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -708,6 +708,7 @@ static const struct usb_device_id option_ids[] = {
708 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, 708 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) },
709 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, 709 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) },
710 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) }, 710 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) },
711 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED) },
711 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3) }, 712 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3) },
712 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4) }, 713 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4) },
713 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5) }, 714 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5) },
@@ -903,8 +904,10 @@ static const struct usb_device_id option_ids[] = {
903 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, 904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), 905 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
905 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 906 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
906 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff) }, 907 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
907 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff) }, 908 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
909 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
910 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
908 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, 911 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) },
909 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, 912 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
910 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, 913 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) },
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ff4a174fa5d..a1a9062954c 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -420,7 +420,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
420 control = priv->line_control; 420 control = priv->line_control;
421 if ((cflag & CBAUD) == B0) 421 if ((cflag & CBAUD) == B0)
422 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); 422 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
423 else 423 else if ((old_termios->c_cflag & CBAUD) == B0)
424 priv->line_control |= (CONTROL_DTR | CONTROL_RTS); 424 priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
425 if (control != priv->line_control) { 425 if (control != priv->line_control) {
426 control = priv->line_control; 426 control = priv->line_control;
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index f14465a83dd..fdd5aa2c8d8 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -289,6 +289,7 @@ static const struct usb_device_id id_table[] = {
289 { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */ 289 { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */
290 { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */ 290 { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */
291 { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */ 291 { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */
292 { USB_DEVICE(0x1199, 0x68A2) }, /* Sierra Wireless MC7710 */
292 /* Sierra Wireless C885 */ 293 /* Sierra Wireless C885 */
293 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)}, 294 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)},
294 /* Sierra Wireless C888, Air Card 501, USB 303, USB 304 */ 295 /* Sierra Wireless C888, Air Card 501, USB 303, USB 304 */
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 69230f01056..97355a15bbe 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1059,6 +1059,12 @@ int usb_serial_probe(struct usb_interface *interface,
1059 serial->attached = 1; 1059 serial->attached = 1;
1060 } 1060 }
1061 1061
1062 /* Avoid race with tty_open and serial_install by setting the
1063 * disconnected flag and not clearing it until all ports have been
1064 * registered.
1065 */
1066 serial->disconnected = 1;
1067
1062 if (get_free_serial(serial, num_ports, &minor) == NULL) { 1068 if (get_free_serial(serial, num_ports, &minor) == NULL) {
1063 dev_err(&interface->dev, "No more free serial devices\n"); 1069 dev_err(&interface->dev, "No more free serial devices\n");
1064 goto probe_error; 1070 goto probe_error;
@@ -1070,19 +1076,16 @@ int usb_serial_probe(struct usb_interface *interface,
1070 port = serial->port[i]; 1076 port = serial->port[i];
1071 dev_set_name(&port->dev, "ttyUSB%d", port->number); 1077 dev_set_name(&port->dev, "ttyUSB%d", port->number);
1072 dbg ("%s - registering %s", __func__, dev_name(&port->dev)); 1078 dbg ("%s - registering %s", __func__, dev_name(&port->dev));
1073 port->dev_state = PORT_REGISTERING;
1074 device_enable_async_suspend(&port->dev); 1079 device_enable_async_suspend(&port->dev);
1075 1080
1076 retval = device_add(&port->dev); 1081 retval = device_add(&port->dev);
1077 if (retval) { 1082 if (retval)
1078 dev_err(&port->dev, "Error registering port device, " 1083 dev_err(&port->dev, "Error registering port device, "
1079 "continuing\n"); 1084 "continuing\n");
1080 port->dev_state = PORT_UNREGISTERED;
1081 } else {
1082 port->dev_state = PORT_REGISTERED;
1083 }
1084 } 1085 }
1085 1086
1087 serial->disconnected = 0;
1088
1086 usb_serial_console_init(debug, minor); 1089 usb_serial_console_init(debug, minor);
1087 1090
1088exit: 1091exit:
@@ -1124,22 +1127,8 @@ void usb_serial_disconnect(struct usb_interface *interface)
1124 } 1127 }
1125 kill_traffic(port); 1128 kill_traffic(port);
1126 cancel_work_sync(&port->work); 1129 cancel_work_sync(&port->work);
1127 if (port->dev_state == PORT_REGISTERED) { 1130 if (device_is_registered(&port->dev))
1128
1129 /* Make sure the port is bound so that the
1130 * driver's port_remove method is called.
1131 */
1132 if (!port->dev.driver) {
1133 int rc;
1134
1135 port->dev.driver =
1136 &serial->type->driver;
1137 rc = device_bind_driver(&port->dev);
1138 }
1139 port->dev_state = PORT_UNREGISTERING;
1140 device_del(&port->dev); 1131 device_del(&port->dev);
1141 port->dev_state = PORT_UNREGISTERED;
1142 }
1143 } 1132 }
1144 } 1133 }
1145 serial->type->disconnect(serial); 1134 serial->type->disconnect(serial);
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index fe2d803a634..7691c866637 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -222,7 +222,7 @@ config USB_LIBUSUAL
222 for usb-storage and ub drivers, and allows to switch binding 222 for usb-storage and ub drivers, and allows to switch binding
223 of these devices without rebuilding modules. 223 of these devices without rebuilding modules.
224 224
225 Typical syntax of /etc/modprobe.conf is: 225 Typical syntax of /etc/modprobe.d/*conf is:
226 226
227 options libusual bias="ub" 227 options libusual bias="ub"
228 228
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index c18538e4a6d..2653e73db62 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -132,6 +132,35 @@ static struct us_unusual_dev for_dynamic_ids =
132#undef COMPLIANT_DEV 132#undef COMPLIANT_DEV
133#undef USUAL_DEV 133#undef USUAL_DEV
134 134
135#ifdef CONFIG_LOCKDEP
136
137static struct lock_class_key us_interface_key[USB_MAXINTERFACES];
138
139static void us_set_lock_class(struct mutex *mutex,
140 struct usb_interface *intf)
141{
142 struct usb_device *udev = interface_to_usbdev(intf);
143 struct usb_host_config *config = udev->actconfig;
144 int i;
145
146 for (i = 0; i < config->desc.bNumInterfaces; i++) {
147 if (config->interface[i] == intf)
148 break;
149 }
150
151 BUG_ON(i == config->desc.bNumInterfaces);
152
153 lockdep_set_class(mutex, &us_interface_key[i]);
154}
155
156#else
157
158static void us_set_lock_class(struct mutex *mutex,
159 struct usb_interface *intf)
160{
161}
162
163#endif
135 164
136#ifdef CONFIG_PM /* Minimal support for suspend and resume */ 165#ifdef CONFIG_PM /* Minimal support for suspend and resume */
137 166
@@ -895,6 +924,7 @@ int usb_stor_probe1(struct us_data **pus,
895 *pus = us = host_to_us(host); 924 *pus = us = host_to_us(host);
896 memset(us, 0, sizeof(struct us_data)); 925 memset(us, 0, sizeof(struct us_data));
897 mutex_init(&(us->dev_mutex)); 926 mutex_init(&(us->dev_mutex));
927 us_set_lock_class(&us->dev_mutex, intf);
898 init_completion(&us->cmnd_ready); 928 init_completion(&us->cmnd_ready);
899 init_completion(&(us->notify)); 929 init_completion(&(us->notify));
900 init_waitqueue_head(&us->delay_wait); 930 init_waitqueue_head(&us->delay_wait);