aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devices.txt5
-rw-r--r--Documentation/powerpc/dts-bindings/fsl/usb.txt22
-rw-r--r--Documentation/usb/proc_usb_info.txt34
-rw-r--r--MAINTAINERS8
-rw-r--r--arch/arm/mach-mx3/mach-cpuimx35.c1
-rw-r--r--arch/arm/mach-omap2/board-am3517evm.c30
-rw-r--r--arch/arm/mach-omap2/usb-musb.c4
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h21
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c163
-rw-r--r--drivers/block/ub.c2
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/scsi/sd.c12
-rw-r--r--drivers/scsi/sr.c8
-rw-r--r--drivers/usb/Kconfig1
-rw-r--r--drivers/usb/atm/Makefile6
-rw-r--r--drivers/usb/c67x00/Makefile6
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--drivers/usb/core/Makefile21
-rw-r--r--drivers/usb/core/devices.c11
-rw-r--r--drivers/usb/core/driver.c2
-rw-r--r--drivers/usb/core/endpoint.c2
-rw-r--r--drivers/usb/core/hcd-pci.c4
-rw-r--r--drivers/usb/core/hcd.c19
-rw-r--r--drivers/usb/core/hub.c41
-rw-r--r--drivers/usb/core/message.c14
-rw-r--r--drivers/usb/core/urb.c5
-rw-r--r--drivers/usb/early/Makefile2
-rw-r--r--drivers/usb/gadget/Kconfig22
-rw-r--r--drivers/usb/gadget/Makefile41
-rw-r--r--drivers/usb/gadget/amd5536udc.c15
-rw-r--r--drivers/usb/gadget/at91_udc.c11
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c10
-rw-r--r--drivers/usb/gadget/audio.c10
-rw-r--r--drivers/usb/gadget/cdc2.c10
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c18
-rw-r--r--drivers/usb/gadget/composite.c139
-rw-r--r--drivers/usb/gadget/dbgp.c19
-rw-r--r--drivers/usb/gadget/dummy_hcd.c18
-rw-r--r--drivers/usb/gadget/ether.c16
-rw-r--r--drivers/usb/gadget/f_acm.c2
-rw-r--r--drivers/usb/gadget/f_loopback.c7
-rw-r--r--drivers/usb/gadget/f_mass_storage.c88
-rw-r--r--drivers/usb/gadget/f_sourcesink.c5
-rw-r--r--drivers/usb/gadget/file_storage.c128
-rw-r--r--drivers/usb/gadget/fsl_mxc_udc.c15
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c12
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c10
-rw-r--r--drivers/usb/gadget/g_ffs.c91
-rw-r--r--drivers/usb/gadget/gmidi.c5
-rw-r--r--drivers/usb/gadget/goku_udc.c35
-rw-r--r--drivers/usb/gadget/hid.c10
-rw-r--r--drivers/usb/gadget/imx_udc.c9
-rw-r--r--drivers/usb/gadget/inode.c6
-rw-r--r--drivers/usb/gadget/langwell_udc.c1058
-rw-r--r--drivers/usb/gadget/langwell_udc.h15
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c10
-rw-r--r--drivers/usb/gadget/m66592-udc.c9
-rw-r--r--drivers/usb/gadget/mass_storage.c82
-rw-r--r--drivers/usb/gadget/multi.c36
-rw-r--r--drivers/usb/gadget/net2280.c10
-rw-r--r--drivers/usb/gadget/nokia.c11
-rw-r--r--drivers/usb/gadget/omap_udc.c10
-rw-r--r--drivers/usb/gadget/printer.c7
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c9
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c12
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c14
-rw-r--r--drivers/usb/gadget/r8a66597-udc.h2
-rw-r--r--drivers/usb/gadget/rndis.c492
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c9
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c17
-rw-r--r--drivers/usb/gadget/serial.c11
-rw-r--r--drivers/usb/gadget/storage_common.c49
-rw-r--r--drivers/usb/gadget/webcam.c11
-rw-r--r--drivers/usb/gadget/zero.c5
-rw-r--r--drivers/usb/host/Kconfig10
-rw-r--r--drivers/usb/host/Makefile24
-rw-r--r--drivers/usb/host/ehci-fsl.c105
-rw-r--r--drivers/usb/host/ehci-fsl.h14
-rw-r--r--drivers/usb/host/ehci-hcd.c15
-rw-r--r--drivers/usb/host/ehci-mem.c2
-rw-r--r--drivers/usb/host/ehci-mxc.c13
-rw-r--r--drivers/usb/host/fsl-mph-dr-of.c308
-rw-r--r--drivers/usb/host/imx21-hcd.c284
-rw-r--r--drivers/usb/host/imx21-hcd.h8
-rw-r--r--drivers/usb/host/isp116x-hcd.c6
-rw-r--r--drivers/usb/host/isp1362-hcd.c25
-rw-r--r--drivers/usb/host/ohci-hcd.c12
-rw-r--r--drivers/usb/host/ohci-pci.c18
-rw-r--r--drivers/usb/host/ohci-sh.c3
-rw-r--r--drivers/usb/host/ohci-sm501.c4
-rw-r--r--drivers/usb/host/ohci.h1
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c2
-rw-r--r--drivers/usb/host/pci-quirks.c18
-rw-r--r--drivers/usb/host/r8a66597.h2
-rw-r--r--drivers/usb/host/uhci-q.c33
-rw-r--r--drivers/usb/host/whci/Kbuild2
-rw-r--r--drivers/usb/host/xhci-hub.c419
-rw-r--r--drivers/usb/host/xhci-mem.c5
-rw-r--r--drivers/usb/host/xhci-pci.c38
-rw-r--r--drivers/usb/host/xhci-ring.c101
-rw-r--r--drivers/usb/host/xhci.c343
-rw-r--r--drivers/usb/host/xhci.h65
-rw-r--r--drivers/usb/misc/Kconfig13
-rw-r--r--drivers/usb/misc/Makefile45
-rw-r--r--drivers/usb/misc/ftdi-elan.c2
-rw-r--r--drivers/usb/misc/iowarrior.c2
-rw-r--r--drivers/usb/misc/sisusbvga/Makefile3
-rw-r--r--drivers/usb/misc/usbtest.c667
-rw-r--r--drivers/usb/misc/yurex.c563
-rw-r--r--drivers/usb/mon/Makefile2
-rw-r--r--drivers/usb/musb/Kconfig16
-rw-r--r--drivers/usb/musb/Makefile71
-rw-r--r--drivers/usb/musb/am35x.c524
-rw-r--r--drivers/usb/musb/blackfin.c7
-rw-r--r--drivers/usb/musb/cppi_dma.c2
-rw-r--r--drivers/usb/musb/da8xx.c469
-rw-r--r--drivers/usb/musb/davinci.c2
-rw-r--r--drivers/usb/musb/musb_core.c57
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/musb/musb_debug.h11
-rw-r--r--drivers/usb/musb/musb_gadget.c132
-rw-r--r--drivers/usb/musb/musb_gadget.h2
-rw-r--r--drivers/usb/musb/musb_host.c11
-rw-r--r--drivers/usb/musb/musbhsdma.c2
-rw-r--r--drivers/usb/musb/omap2430.c1
-rw-r--r--drivers/usb/musb/tusb6010.c4
-rw-r--r--drivers/usb/otg/Kconfig14
-rw-r--r--drivers/usb/otg/Makefile8
-rw-r--r--drivers/usb/otg/langwell_otg.c2408
-rw-r--r--drivers/usb/otg/ulpi.c60
-rw-r--r--drivers/usb/serial/Kconfig9
-rw-r--r--drivers/usb/serial/Makefile10
-rw-r--r--drivers/usb/serial/cp210x.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c42
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h39
-rw-r--r--drivers/usb/serial/mct_u232.c7
-rw-r--r--drivers/usb/serial/opticon.c44
-rw-r--r--drivers/usb/serial/option.c30
-rw-r--r--drivers/usb/serial/qcserial.c33
-rw-r--r--drivers/usb/serial/sam-ba.c206
-rw-r--r--drivers/usb/serial/visor.c11
-rw-r--r--drivers/usb/storage/Kconfig13
-rw-r--r--drivers/usb/storage/Makefile35
-rw-r--r--drivers/usb/storage/scsiglue.c16
-rw-r--r--drivers/usb/storage/sddr09.c2
-rw-r--r--drivers/usb/storage/transport.c10
-rw-r--r--drivers/usb/storage/uas.c751
-rw-r--r--drivers/usb/storage/unusual_alauda.h4
-rw-r--r--drivers/usb/storage/unusual_cypress.h4
-rw-r--r--drivers/usb/storage/unusual_datafab.h20
-rw-r--r--drivers/usb/storage/unusual_devs.h580
-rw-r--r--drivers/usb/storage/unusual_freecom.h2
-rw-r--r--drivers/usb/storage/unusual_isd200.h12
-rw-r--r--drivers/usb/storage/unusual_jumpshot.h2
-rw-r--r--drivers/usb/storage/unusual_karma.h2
-rw-r--r--drivers/usb/storage/unusual_onetouch.h4
-rw-r--r--drivers/usb/storage/unusual_sddr09.h12
-rw-r--r--drivers/usb/storage/unusual_sddr55.h8
-rw-r--r--drivers/usb/storage/unusual_usbat.h8
-rw-r--r--drivers/usb/storage/usb.c30
-rw-r--r--drivers/usb/wusbcore/Makefile19
-rw-r--r--drivers/uwb/address.c5
-rw-r--r--drivers/uwb/wlp/wss-lc.c7
-rw-r--r--include/linux/fsl_devices.h18
-rw-r--r--include/linux/init.h13
-rw-r--r--include/linux/usb/cdc.h79
-rw-r--r--include/linux/usb/ch9.h68
-rw-r--r--include/linux/usb/composite.h40
-rw-r--r--include/linux/usb/gadget.h20
-rw-r--r--include/linux/usb/hcd.h2
-rw-r--r--include/linux/usb/intel_mid_otg.h180
-rw-r--r--include/linux/usb/langwell_otg.h139
-rw-r--r--include/linux/usb/ncm.h114
-rw-r--r--include/linux/usb/otg.h11
-rw-r--r--include/linux/usb/storage.h48
-rw-r--r--include/linux/usb_usual.h43
-rw-r--r--include/scsi/scsi.h2
-rw-r--r--include/scsi/scsi_device.h2
179 files changed, 9945 insertions, 2874 deletions
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 6a08fd731d28..c58abf1ccc71 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -2554,7 +2554,10 @@ Your cooperation is appreciated.
2554 175 = /dev/usb/legousbtower15 16th USB Legotower device 2554 175 = /dev/usb/legousbtower15 16th USB Legotower device
2555 176 = /dev/usb/usbtmc1 First USB TMC device 2555 176 = /dev/usb/usbtmc1 First USB TMC device
2556 ... 2556 ...
2557 192 = /dev/usb/usbtmc16 16th USB TMC device 2557 191 = /dev/usb/usbtmc16 16th USB TMC device
2558 192 = /dev/usb/yurex1 First USB Yurex device
2559 ...
2560 209 = /dev/usb/yurex16 16th USB Yurex device
2558 240 = /dev/usb/dabusb0 First daubusb device 2561 240 = /dev/usb/dabusb0 First daubusb device
2559 ... 2562 ...
2560 243 = /dev/usb/dabusb3 Fourth dabusb device 2563 243 = /dev/usb/dabusb3 Fourth dabusb device
diff --git a/Documentation/powerpc/dts-bindings/fsl/usb.txt b/Documentation/powerpc/dts-bindings/fsl/usb.txt
index b00152402694..bd5723f0b67e 100644
--- a/Documentation/powerpc/dts-bindings/fsl/usb.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/usb.txt
@@ -8,6 +8,7 @@ and additions :
8Required properties : 8Required properties :
9 - compatible : Should be "fsl-usb2-mph" for multi port host USB 9 - compatible : Should be "fsl-usb2-mph" for multi port host USB
10 controllers, or "fsl-usb2-dr" for dual role USB controllers 10 controllers, or "fsl-usb2-dr" for dual role USB controllers
11 or "fsl,mpc5121-usb2-dr" for dual role USB controllers of MPC5121
11 - phy_type : For multi port host USB controllers, should be one of 12 - phy_type : For multi port host USB controllers, should be one of
12 "ulpi", or "serial". For dual role USB controllers, should be 13 "ulpi", or "serial". For dual role USB controllers, should be
13 one of "ulpi", "utmi", "utmi_wide", or "serial". 14 one of "ulpi", "utmi", "utmi_wide", or "serial".
@@ -33,6 +34,12 @@ Recommended properties :
33 - interrupt-parent : the phandle for the interrupt controller that 34 - interrupt-parent : the phandle for the interrupt controller that
34 services interrupts for this device. 35 services interrupts for this device.
35 36
37Optional properties :
38 - fsl,invert-drvvbus : boolean; for MPC5121 USB0 only. Indicates the
39 port power polarity of internal PHY signal DRVVBUS is inverted.
40 - fsl,invert-pwr-fault : boolean; for MPC5121 USB0 only. Indicates
41 the PWR_FAULT signal polarity is inverted.
42
36Example multi port host USB controller device node : 43Example multi port host USB controller device node :
37 usb@22000 { 44 usb@22000 {
38 compatible = "fsl-usb2-mph"; 45 compatible = "fsl-usb2-mph";
@@ -57,3 +64,18 @@ Example dual role USB controller device node :
57 dr_mode = "otg"; 64 dr_mode = "otg";
58 phy = "ulpi"; 65 phy = "ulpi";
59 }; 66 };
67
68Example dual role USB controller device node for MPC5121ADS:
69
70 usb@4000 {
71 compatible = "fsl,mpc5121-usb2-dr";
72 reg = <0x4000 0x1000>;
73 #address-cells = <1>;
74 #size-cells = <0>;
75 interrupt-parent = < &ipic >;
76 interrupts = <44 0x8>;
77 dr_mode = "otg";
78 phy_type = "utmi_wide";
79 fsl,invert-drvvbus;
80 fsl,invert-pwr-fault;
81 };
diff --git a/Documentation/usb/proc_usb_info.txt b/Documentation/usb/proc_usb_info.txt
index fafcd4723260..afe596d5f201 100644
--- a/Documentation/usb/proc_usb_info.txt
+++ b/Documentation/usb/proc_usb_info.txt
@@ -1,12 +1,17 @@
1/proc/bus/usb filesystem output 1/proc/bus/usb filesystem output
2=============================== 2===============================
3(version 2003.05.30) 3(version 2010.09.13)
4 4
5 5
6The usbfs filesystem for USB devices is traditionally mounted at 6The usbfs filesystem for USB devices is traditionally mounted at
7/proc/bus/usb. It provides the /proc/bus/usb/devices file, as well as 7/proc/bus/usb. It provides the /proc/bus/usb/devices file, as well as
8the /proc/bus/usb/BBB/DDD files. 8the /proc/bus/usb/BBB/DDD files.
9 9
10In many modern systems the usbfs filsystem isn't used at all. Instead
11USB device nodes are created under /dev/usb/ or someplace similar. The
12"devices" file is available in debugfs, typically as
13/sys/kernel/debug/usb/devices.
14
10 15
11**NOTE**: If /proc/bus/usb appears empty, and a host controller 16**NOTE**: If /proc/bus/usb appears empty, and a host controller
12 driver has been linked, then you need to mount the 17 driver has been linked, then you need to mount the
@@ -106,8 +111,8 @@ Legend:
106 111
107Topology info: 112Topology info:
108 113
109T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd 114T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=dddd MxCh=dd
110| | | | | | | | |__MaxChildren 115| | | | | | | | |__MaxChildren
111| | | | | | | |__Device Speed in Mbps 116| | | | | | | |__Device Speed in Mbps
112| | | | | | |__DeviceNumber 117| | | | | | |__DeviceNumber
113| | | | | |__Count of devices at this level 118| | | | | |__Count of devices at this level
@@ -120,8 +125,13 @@ T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd
120 Speed may be: 125 Speed may be:
121 1.5 Mbit/s for low speed USB 126 1.5 Mbit/s for low speed USB
122 12 Mbit/s for full speed USB 127 12 Mbit/s for full speed USB
123 480 Mbit/s for high speed USB (added for USB 2.0) 128 480 Mbit/s for high speed USB (added for USB 2.0);
129 also used for Wireless USB, which has no fixed speed
130 5000 Mbit/s for SuperSpeed USB (added for USB 3.0)
124 131
132 For reasons lost in the mists of time, the Port number is always
133 too low by 1. For example, a device plugged into port 4 will
134 show up with "Port=03".
125 135
126Bandwidth info: 136Bandwidth info:
127B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd 137B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd
@@ -291,7 +301,7 @@ Here's an example, from a system which has a UHCI root hub,
291an external hub connected to the root hub, and a mouse and 301an external hub connected to the root hub, and a mouse and
292a serial converter connected to the external hub. 302a serial converter connected to the external hub.
293 303
294T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2 304T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
295B: Alloc= 28/900 us ( 3%), #Int= 2, #Iso= 0 305B: Alloc= 28/900 us ( 3%), #Int= 2, #Iso= 0
296D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 306D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
297P: Vendor=0000 ProdID=0000 Rev= 0.00 307P: Vendor=0000 ProdID=0000 Rev= 0.00
@@ -301,21 +311,21 @@ C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr= 0mA
301I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub 311I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
302E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=255ms 312E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=255ms
303 313
304T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4 314T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4
305D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 315D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
306P: Vendor=0451 ProdID=1446 Rev= 1.00 316P: Vendor=0451 ProdID=1446 Rev= 1.00
307C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA 317C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
308I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub 318I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
309E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms 319E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms
310 320
311T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0 321T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
312D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 322D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
313P: Vendor=04b4 ProdID=0001 Rev= 0.00 323P: Vendor=04b4 ProdID=0001 Rev= 0.00
314C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA 324C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
315I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse 325I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse
316E: Ad=81(I) Atr=03(Int.) MxPS= 3 Ivl= 10ms 326E: Ad=81(I) Atr=03(Int.) MxPS= 3 Ivl= 10ms
317 327
318T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0 328T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
319D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 329D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
320P: Vendor=0565 ProdID=0001 Rev= 1.08 330P: Vendor=0565 ProdID=0001 Rev= 1.08
321S: Manufacturer=Peracom Networks, Inc. 331S: Manufacturer=Peracom Networks, Inc.
@@ -330,12 +340,12 @@ E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl= 8ms
330Selecting only the "T:" and "I:" lines from this (for example, by using 340Selecting only the "T:" and "I:" lines from this (for example, by using
331"procusb ti"), we have: 341"procusb ti"), we have:
332 342
333T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2 343T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
334T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4 344T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4
335I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub 345I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
336T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0 346T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
337I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse 347I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse
338T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0 348T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
339I: If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial 349I: If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial
340 350
341 351
diff --git a/MAINTAINERS b/MAINTAINERS
index 060e32ab35fb..9a0432de9141 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5973,6 +5973,14 @@ S: Maintained
5973F: Documentation/usb/acm.txt 5973F: Documentation/usb/acm.txt
5974F: drivers/usb/class/cdc-acm.* 5974F: drivers/usb/class/cdc-acm.*
5975 5975
5976USB ATTACHED SCSI
5977M: Matthew Wilcox <willy@linux.intel.com>
5978M: Sarah Sharp <sarah.a.sharp@linux.intel.com>
5979L: linux-usb@vger.kernel.org
5980L: linux-scsi@vger.kernel.org
5981S: Supported
5982F: drivers/usb/storage/uas.c
5983
5976USB BLOCK DRIVER (UB ub) 5984USB BLOCK DRIVER (UB ub)
5977M: Pete Zaitcev <zaitcev@redhat.com> 5985M: Pete Zaitcev <zaitcev@redhat.com>
5978L: linux-usb@vger.kernel.org 5986L: linux-usb@vger.kernel.org
diff --git a/arch/arm/mach-mx3/mach-cpuimx35.c b/arch/arm/mach-mx3/mach-cpuimx35.c
index 8533bf04284a..9fde873f5889 100644
--- a/arch/arm/mach-mx3/mach-cpuimx35.c
+++ b/arch/arm/mach-mx3/mach-cpuimx35.c
@@ -131,6 +131,7 @@ static struct mxc_usbh_platform_data __maybe_unused usbh1_pdata = {
131static struct fsl_usb2_platform_data otg_device_pdata = { 131static struct fsl_usb2_platform_data otg_device_pdata = {
132 .operating_mode = FSL_USB2_DR_DEVICE, 132 .operating_mode = FSL_USB2_DR_DEVICE,
133 .phy_mode = FSL_USB2_PHY_UTMI, 133 .phy_mode = FSL_USB2_PHY_UTMI,
134 .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
134}; 135};
135 136
136static int otg_mode_host; 137static int otg_mode_host;
diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index f85c8da17e8b..d547036aff3f 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -375,6 +375,31 @@ static void __init am3517_evm_init_irq(void)
375 omap_gpio_init(); 375 omap_gpio_init();
376} 376}
377 377
378static struct omap_musb_board_data musb_board_data = {
379 .interface_type = MUSB_INTERFACE_ULPI,
380 .mode = MUSB_OTG,
381 .power = 500,
382};
383
384static __init void am3517_evm_musb_init(void)
385{
386 u32 devconf2;
387
388 /*
389 * Set up USB clock/mode in the DEVCONF2 register.
390 */
391 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
392
393 /* USB2.0 PHY reference clock is 13 MHz */
394 devconf2 &= ~(CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE);
395 devconf2 |= CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_VBDTCTEN
396 | CONF2_DATPOL;
397
398 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
399
400 usb_musb_init(&musb_board_data);
401}
402
378static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { 403static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
379 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, 404 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
380#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \ 405#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
@@ -393,6 +418,8 @@ static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
393 418
394#ifdef CONFIG_OMAP_MUX 419#ifdef CONFIG_OMAP_MUX
395static struct omap_board_mux board_mux[] __initdata = { 420static struct omap_board_mux board_mux[] __initdata = {
421 /* USB OTG DRVVBUS offset = 0x212 */
422 OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
396 { .reg_offset = OMAP_MUX_TERMINATOR }, 423 { .reg_offset = OMAP_MUX_TERMINATOR },
397}; 424};
398#else 425#else
@@ -459,6 +486,9 @@ static void __init am3517_evm_init(void)
459 ARRAY_SIZE(am3517evm_i2c1_boardinfo)); 486 ARRAY_SIZE(am3517evm_i2c1_boardinfo));
460 /*Ethernet*/ 487 /*Ethernet*/
461 am3517_evm_ethernet_init(&am3517_evm_emac_pdata); 488 am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
489
490 /* MUSB */
491 am3517_evm_musb_init();
462} 492}
463 493
464MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") 494MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 33a5cde1c227..72605584bfff 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -28,6 +28,7 @@
28 28
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30#include <mach/irqs.h> 30#include <mach/irqs.h>
31#include <mach/am35xx.h>
31#include <plat/usb.h> 32#include <plat/usb.h>
32 33
33#ifdef CONFIG_USB_MUSB_SOC 34#ifdef CONFIG_USB_MUSB_SOC
@@ -89,6 +90,9 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data)
89{ 90{
90 if (cpu_is_omap243x()) { 91 if (cpu_is_omap243x()) {
91 musb_resources[0].start = OMAP243X_HS_BASE; 92 musb_resources[0].start = OMAP243X_HS_BASE;
93 } else if (cpu_is_omap3517() || cpu_is_omap3505()) {
94 musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
95 musb_resources[1].start = INT_35XX_USBOTG_IRQ;
92 } else if (cpu_is_omap34xx()) { 96 } else if (cpu_is_omap34xx()) {
93 musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE; 97 musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
94 } else if (cpu_is_omap44xx()) { 98 } else if (cpu_is_omap44xx()) {
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 2a9427c8cc48..9feddacfe850 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -218,6 +218,27 @@ static inline omap2_usbfs_init(struct omap_usb_config *pdata)
218# define USBT2TLL5PI (1 << 17) 218# define USBT2TLL5PI (1 << 17)
219# define USB0PUENACTLOI (1 << 16) 219# define USB0PUENACTLOI (1 << 16)
220# define USBSTANDBYCTRL (1 << 15) 220# define USBSTANDBYCTRL (1 << 15)
221/* AM35x */
222/* USB 2.0 PHY Control */
223#define CONF2_PHY_GPIOMODE (1 << 23)
224#define CONF2_OTGMODE (3 << 14)
225#define CONF2_NO_OVERRIDE (0 << 14)
226#define CONF2_FORCE_HOST (1 << 14)
227#define CONF2_FORCE_DEVICE (2 << 14)
228#define CONF2_FORCE_HOST_VBUS_LOW (3 << 14)
229#define CONF2_SESENDEN (1 << 13)
230#define CONF2_VBDTCTEN (1 << 12)
231#define CONF2_REFFREQ_24MHZ (2 << 8)
232#define CONF2_REFFREQ_26MHZ (7 << 8)
233#define CONF2_REFFREQ_13MHZ (6 << 8)
234#define CONF2_REFFREQ (0xf << 8)
235#define CONF2_PHYCLKGD (1 << 7)
236#define CONF2_VBUSSENSE (1 << 6)
237#define CONF2_PHY_PLLON (1 << 5)
238#define CONF2_RESET (1 << 4)
239#define CONF2_PHYPWRDN (1 << 3)
240#define CONF2_OTGPWRDN (1 << 2)
241#define CONF2_DATPOL (1 << 1)
221 242
222#if defined(CONFIG_ARCH_OMAP1) && defined(CONFIG_USB) 243#if defined(CONFIG_ARCH_OMAP1) && defined(CONFIG_USB)
223u32 omap1_usb0_init(unsigned nwires, unsigned is_device); 244u32 omap1_usb0_init(unsigned nwires, unsigned is_device);
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 6c67d9ebf166..19e5015e039b 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -209,169 +209,6 @@ static int __init of_add_fixed_phys(void)
209arch_initcall(of_add_fixed_phys); 209arch_initcall(of_add_fixed_phys);
210#endif /* CONFIG_FIXED_PHY */ 210#endif /* CONFIG_FIXED_PHY */
211 211
212static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type)
213{
214 if (!phy_type)
215 return FSL_USB2_PHY_NONE;
216 if (!strcasecmp(phy_type, "ulpi"))
217 return FSL_USB2_PHY_ULPI;
218 if (!strcasecmp(phy_type, "utmi"))
219 return FSL_USB2_PHY_UTMI;
220 if (!strcasecmp(phy_type, "utmi_wide"))
221 return FSL_USB2_PHY_UTMI_WIDE;
222 if (!strcasecmp(phy_type, "serial"))
223 return FSL_USB2_PHY_SERIAL;
224
225 return FSL_USB2_PHY_NONE;
226}
227
228static int __init fsl_usb_of_init(void)
229{
230 struct device_node *np;
231 unsigned int i = 0;
232 struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL,
233 *usb_dev_dr_client = NULL;
234 int ret;
235
236 for_each_compatible_node(np, NULL, "fsl-usb2-mph") {
237 struct resource r[2];
238 struct fsl_usb2_platform_data usb_data;
239 const unsigned char *prop = NULL;
240
241 memset(&r, 0, sizeof(r));
242 memset(&usb_data, 0, sizeof(usb_data));
243
244 ret = of_address_to_resource(np, 0, &r[0]);
245 if (ret)
246 goto err;
247
248 of_irq_to_resource(np, 0, &r[1]);
249
250 usb_dev_mph =
251 platform_device_register_simple("fsl-ehci", i, r, 2);
252 if (IS_ERR(usb_dev_mph)) {
253 ret = PTR_ERR(usb_dev_mph);
254 goto err;
255 }
256
257 usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
258 usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
259
260 usb_data.operating_mode = FSL_USB2_MPH_HOST;
261
262 prop = of_get_property(np, "port0", NULL);
263 if (prop)
264 usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
265
266 prop = of_get_property(np, "port1", NULL);
267 if (prop)
268 usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
269
270 prop = of_get_property(np, "phy_type", NULL);
271 usb_data.phy_mode = determine_usb_phy(prop);
272
273 ret =
274 platform_device_add_data(usb_dev_mph, &usb_data,
275 sizeof(struct
276 fsl_usb2_platform_data));
277 if (ret)
278 goto unreg_mph;
279 i++;
280 }
281
282 for_each_compatible_node(np, NULL, "fsl-usb2-dr") {
283 struct resource r[2];
284 struct fsl_usb2_platform_data usb_data;
285 const unsigned char *prop = NULL;
286
287 if (!of_device_is_available(np))
288 continue;
289
290 memset(&r, 0, sizeof(r));
291 memset(&usb_data, 0, sizeof(usb_data));
292
293 ret = of_address_to_resource(np, 0, &r[0]);
294 if (ret)
295 goto unreg_mph;
296
297 of_irq_to_resource(np, 0, &r[1]);
298
299 prop = of_get_property(np, "dr_mode", NULL);
300
301 if (!prop || !strcmp(prop, "host")) {
302 usb_data.operating_mode = FSL_USB2_DR_HOST;
303 usb_dev_dr_host = platform_device_register_simple(
304 "fsl-ehci", i, r, 2);
305 if (IS_ERR(usb_dev_dr_host)) {
306 ret = PTR_ERR(usb_dev_dr_host);
307 goto err;
308 }
309 } else if (prop && !strcmp(prop, "peripheral")) {
310 usb_data.operating_mode = FSL_USB2_DR_DEVICE;
311 usb_dev_dr_client = platform_device_register_simple(
312 "fsl-usb2-udc", i, r, 2);
313 if (IS_ERR(usb_dev_dr_client)) {
314 ret = PTR_ERR(usb_dev_dr_client);
315 goto err;
316 }
317 } else if (prop && !strcmp(prop, "otg")) {
318 usb_data.operating_mode = FSL_USB2_DR_OTG;
319 usb_dev_dr_host = platform_device_register_simple(
320 "fsl-ehci", i, r, 2);
321 if (IS_ERR(usb_dev_dr_host)) {
322 ret = PTR_ERR(usb_dev_dr_host);
323 goto err;
324 }
325 usb_dev_dr_client = platform_device_register_simple(
326 "fsl-usb2-udc", i, r, 2);
327 if (IS_ERR(usb_dev_dr_client)) {
328 ret = PTR_ERR(usb_dev_dr_client);
329 goto err;
330 }
331 } else {
332 ret = -EINVAL;
333 goto err;
334 }
335
336 prop = of_get_property(np, "phy_type", NULL);
337 usb_data.phy_mode = determine_usb_phy(prop);
338
339 if (usb_dev_dr_host) {
340 usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL;
341 usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host->
342 dev.coherent_dma_mask;
343 if ((ret = platform_device_add_data(usb_dev_dr_host,
344 &usb_data, sizeof(struct
345 fsl_usb2_platform_data))))
346 goto unreg_dr;
347 }
348 if (usb_dev_dr_client) {
349 usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL;
350 usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client->
351 dev.coherent_dma_mask;
352 if ((ret = platform_device_add_data(usb_dev_dr_client,
353 &usb_data, sizeof(struct
354 fsl_usb2_platform_data))))
355 goto unreg_dr;
356 }
357 i++;
358 }
359 return 0;
360
361unreg_dr:
362 if (usb_dev_dr_host)
363 platform_device_unregister(usb_dev_dr_host);
364 if (usb_dev_dr_client)
365 platform_device_unregister(usb_dev_dr_client);
366unreg_mph:
367 if (usb_dev_mph)
368 platform_device_unregister(usb_dev_mph);
369err:
370 return ret;
371}
372
373arch_initcall(fsl_usb_of_init);
374
375#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx) 212#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
376static __be32 __iomem *rstcr; 213static __be32 __iomem *rstcr;
377 214
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index b5690a045a01..9ae3bb713286 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -397,7 +397,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum);
397#else 397#else
398 398
399static const struct usb_device_id ub_usb_ids[] = { 399static const struct usb_device_id ub_usb_ids[] = {
400 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) }, 400 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_BULK) },
401 { } 401 { }
402}; 402};
403 403
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index a0dea3d1296e..3cb6632d4518 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1662,6 +1662,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1662 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 1662 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
1663 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1663 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
1664 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 1664 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
1665 { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_YUREX) },
1665 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1666 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
1666 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 1667 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
1667 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1668 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index c5ae5f1545bd..855aa8e355f4 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -304,6 +304,9 @@
304#define USB_VENDOR_ID_IMATION 0x0718 304#define USB_VENDOR_ID_IMATION 0x0718
305#define USB_DEVICE_ID_DISC_STAKKA 0xd000 305#define USB_DEVICE_ID_DISC_STAKKA 0xd000
306 306
307#define USB_VENDOR_ID_JESS 0x0c45
308#define USB_DEVICE_ID_JESS_YUREX 0x1010
309
307#define USB_VENDOR_ID_KBGEAR 0x084e 310#define USB_VENDOR_ID_KBGEAR 0x084e
308#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 311#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
309 312
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 20295774bf70..57d1e3e1bd44 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1498,6 +1498,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
1498 unsigned long long lba; 1498 unsigned long long lba;
1499 unsigned sector_size; 1499 unsigned sector_size;
1500 1500
1501 if (sdp->no_read_capacity_16)
1502 return -EINVAL;
1503
1501 do { 1504 do {
1502 memset(cmd, 0, 16); 1505 memset(cmd, 0, 16);
1503 cmd[0] = SERVICE_ACTION_IN; 1506 cmd[0] = SERVICE_ACTION_IN;
@@ -1626,6 +1629,15 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
1626 sector_size = get_unaligned_be32(&buffer[4]); 1629 sector_size = get_unaligned_be32(&buffer[4]);
1627 lba = get_unaligned_be32(&buffer[0]); 1630 lba = get_unaligned_be32(&buffer[0]);
1628 1631
1632 if (sdp->no_read_capacity_16 && (lba == 0xffffffff)) {
1633 /* Some buggy (usb cardreader) devices return an lba of
1634 0xffffffff when the want to report a size of 0 (with
1635 which they really mean no media is present) */
1636 sdkp->capacity = 0;
1637 sdkp->physical_block_size = sector_size;
1638 return sector_size;
1639 }
1640
1629 if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) { 1641 if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) {
1630 sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " 1642 sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a "
1631 "kernel compiled with support for large block " 1643 "kernel compiled with support for large block "
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index e148341079b5..d7b383c96d5d 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -862,10 +862,16 @@ static void get_capabilities(struct scsi_cd *cd)
862static int sr_packet(struct cdrom_device_info *cdi, 862static int sr_packet(struct cdrom_device_info *cdi,
863 struct packet_command *cgc) 863 struct packet_command *cgc)
864{ 864{
865 struct scsi_cd *cd = cdi->handle;
866 struct scsi_device *sdev = cd->device;
867
868 if (cgc->cmd[0] == GPCMD_READ_DISC_INFO && sdev->no_read_disc_info)
869 return -EDRIVE_CANT_DO_THIS;
870
865 if (cgc->timeout <= 0) 871 if (cgc->timeout <= 0)
866 cgc->timeout = IOCTL_TIMEOUT; 872 cgc->timeout = IOCTL_TIMEOUT;
867 873
868 sr_do_ioctl(cdi->handle, cgc); 874 sr_do_ioctl(cd, cgc);
869 875
870 return cgc->stat; 876 return cgc->stat;
871} 877}
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 4aa00e6e57ad..67eb3770868f 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -59,6 +59,7 @@ config USB_ARCH_HAS_OHCI
59config USB_ARCH_HAS_EHCI 59config USB_ARCH_HAS_EHCI
60 boolean 60 boolean
61 default y if PPC_83xx 61 default y if PPC_83xx
62 default y if PPC_MPC512x
62 default y if SOC_AU1200 63 default y if SOC_AU1200
63 default y if ARCH_IXP4XX 64 default y if ARCH_IXP4XX
64 default y if ARCH_W90X900 65 default y if ARCH_W90X900
diff --git a/drivers/usb/atm/Makefile b/drivers/usb/atm/Makefile
index 4c4a776ab1cd..a5d792ec3ad5 100644
--- a/drivers/usb/atm/Makefile
+++ b/drivers/usb/atm/Makefile
@@ -2,12 +2,10 @@
2# Makefile for USB ATM/xDSL drivers 2# Makefile for USB ATM/xDSL drivers
3# 3#
4 4
5ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
6
5obj-$(CONFIG_USB_CXACRU) += cxacru.o 7obj-$(CONFIG_USB_CXACRU) += cxacru.o
6obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o 8obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o
7obj-$(CONFIG_USB_UEAGLEATM) += ueagle-atm.o 9obj-$(CONFIG_USB_UEAGLEATM) += ueagle-atm.o
8obj-$(CONFIG_USB_ATM) += usbatm.o 10obj-$(CONFIG_USB_ATM) += usbatm.o
9obj-$(CONFIG_USB_XUSBATM) += xusbatm.o 11obj-$(CONFIG_USB_XUSBATM) += xusbatm.o
10
11ifeq ($(CONFIG_USB_DEBUG),y)
12EXTRA_CFLAGS += -DDEBUG
13endif
diff --git a/drivers/usb/c67x00/Makefile b/drivers/usb/c67x00/Makefile
index 868bc41b5980..b1218683c8ec 100644
--- a/drivers/usb/c67x00/Makefile
+++ b/drivers/usb/c67x00/Makefile
@@ -2,8 +2,8 @@
2# Makefile for Cypress C67X00 USB Controller 2# Makefile for Cypress C67X00 USB Controller
3# 3#
4 4
5ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG 5ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
6 6
7obj-$(CONFIG_USB_C67X00_HCD) += c67x00.o 7obj-$(CONFIG_USB_C67X00_HCD) += c67x00.o
8 8
9c67x00-objs := c67x00-drv.o c67x00-ll-hpi.o c67x00-hcd.o c67x00-sched.o 9c67x00-y := c67x00-drv.o c67x00-ll-hpi.o c67x00-hcd.o c67x00-sched.o
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index bc62fae0680f..d6ede989ff22 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1614,7 +1614,7 @@ static const struct usb_device_id acm_ids[] = {
1614 /* Support Lego NXT using pbLua firmware */ 1614 /* Support Lego NXT using pbLua firmware */
1615 { USB_DEVICE(0x0694, 0xff00), 1615 { USB_DEVICE(0x0694, 0xff00),
1616 .driver_info = NOT_A_MODEM, 1616 .driver_info = NOT_A_MODEM,
1617 }, 1617 },
1618 1618
1619 /* control interfaces without any protocol set */ 1619 /* control interfaces without any protocol set */
1620 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1620 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index ec16e6029905..507a4e1b6360 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -2,20 +2,13 @@
2# Makefile for USB Core files and filesystem 2# Makefile for USB Core files and filesystem
3# 3#
4 4
5usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \ 5ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
6 config.o file.o buffer.o sysfs.o endpoint.o \
7 devio.o notify.o generic.o quirks.o devices.o
8 6
9ifeq ($(CONFIG_PCI),y) 7usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o
10 usbcore-objs += hcd-pci.o 8usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o
11endif 9usbcore-y += devio.o notify.o generic.o quirks.o devices.o
12 10
13ifeq ($(CONFIG_USB_DEVICEFS),y) 11usbcore-$(CONFIG_PCI) += hcd-pci.o
14 usbcore-objs += inode.o 12usbcore-$(CONFIG_USB_DEVICEFS) += inode.o
15endif
16 13
17obj-$(CONFIG_USB) += usbcore.o 14obj-$(CONFIG_USB) += usbcore.o
18
19ifeq ($(CONFIG_USB_DEBUG),y)
20EXTRA_CFLAGS += -DDEBUG
21endif
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 3449742c00e1..ddb4dc980923 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -66,8 +66,8 @@
66#define ALLOW_SERIAL_NUMBER 66#define ALLOW_SERIAL_NUMBER
67 67
68static const char *format_topo = 68static const char *format_topo =
69/* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd */ 69/* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=dddd MxCh=dd */
70"\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%3s MxCh=%2d\n"; 70"\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%-4s MxCh=%2d\n";
71 71
72static const char *format_string_manufacturer = 72static const char *format_string_manufacturer =
73/* S: Manufacturer=xxxx */ 73/* S: Manufacturer=xxxx */
@@ -520,11 +520,14 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
520 speed = "1.5"; break; 520 speed = "1.5"; break;
521 case USB_SPEED_UNKNOWN: /* usb 1.1 root hub code */ 521 case USB_SPEED_UNKNOWN: /* usb 1.1 root hub code */
522 case USB_SPEED_FULL: 522 case USB_SPEED_FULL:
523 speed = "12 "; break; 523 speed = "12"; break;
524 case USB_SPEED_WIRELESS: /* Wireless has no real fixed speed */
524 case USB_SPEED_HIGH: 525 case USB_SPEED_HIGH:
525 speed = "480"; break; 526 speed = "480"; break;
527 case USB_SPEED_SUPER:
528 speed = "5000"; break;
526 default: 529 default:
527 speed = "?? "; 530 speed = "??";
528 } 531 }
529 data_end = pages_start + sprintf(pages_start, format_topo, 532 data_end = pages_start + sprintf(pages_start, format_topo,
530 bus->busnum, level, parent_devnum, 533 bus->busnum, level, parent_devnum,
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d7a4401ef019..c0e60fbcb048 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1337,7 +1337,7 @@ int usb_resume(struct device *dev, pm_message_t msg)
1337 /* Avoid PM error messages for devices disconnected while suspended 1337 /* Avoid PM error messages for devices disconnected while suspended
1338 * as we'll display regular disconnect messages just a bit later. 1338 * as we'll display regular disconnect messages just a bit later.
1339 */ 1339 */
1340 if (status == -ENODEV) 1340 if (status == -ENODEV || status == -ESHUTDOWN)
1341 status = 0; 1341 status = 0;
1342 return status; 1342 return status;
1343} 1343}
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3788e738e265..9da250563027 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -202,7 +202,7 @@ int usb_create_ep_devs(struct device *parent,
202 return retval; 202 return retval;
203 203
204error_register: 204error_register:
205 kfree(ep_dev); 205 put_device(&ep_dev->dev);
206exit: 206exit:
207 return retval; 207 return retval;
208} 208}
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index c3f98543caaf..3799573bd385 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -329,8 +329,10 @@ void usb_hcd_pci_shutdown(struct pci_dev *dev)
329 return; 329 return;
330 330
331 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && 331 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) &&
332 hcd->driver->shutdown) 332 hcd->driver->shutdown) {
333 hcd->driver->shutdown(hcd); 333 hcd->driver->shutdown(hcd);
334 pci_disable_device(dev);
335 }
334} 336}
335EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown); 337EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
336 338
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 5cca00a6d09d..61800f77dac8 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1263,10 +1263,8 @@ static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle,
1263 *dma_handle = 0; 1263 *dma_handle = 0;
1264} 1264}
1265 1265
1266static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) 1266void unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb)
1267{ 1267{
1268 enum dma_data_direction dir;
1269
1270 if (urb->transfer_flags & URB_SETUP_MAP_SINGLE) 1268 if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
1271 dma_unmap_single(hcd->self.controller, 1269 dma_unmap_single(hcd->self.controller,
1272 urb->setup_dma, 1270 urb->setup_dma,
@@ -1279,6 +1277,17 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
1279 sizeof(struct usb_ctrlrequest), 1277 sizeof(struct usb_ctrlrequest),
1280 DMA_TO_DEVICE); 1278 DMA_TO_DEVICE);
1281 1279
1280 /* Make it safe to call this routine more than once */
1281 urb->transfer_flags &= ~(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL);
1282}
1283EXPORT_SYMBOL_GPL(unmap_urb_setup_for_dma);
1284
1285void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
1286{
1287 enum dma_data_direction dir;
1288
1289 unmap_urb_setup_for_dma(hcd, urb);
1290
1282 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 1291 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
1283 if (urb->transfer_flags & URB_DMA_MAP_SG) 1292 if (urb->transfer_flags & URB_DMA_MAP_SG)
1284 dma_unmap_sg(hcd->self.controller, 1293 dma_unmap_sg(hcd->self.controller,
@@ -1303,10 +1312,10 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
1303 dir); 1312 dir);
1304 1313
1305 /* Make it safe to call this routine more than once */ 1314 /* Make it safe to call this routine more than once */
1306 urb->transfer_flags &= ~(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL | 1315 urb->transfer_flags &= ~(URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
1307 URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
1308 URB_DMA_MAP_SINGLE | URB_MAP_LOCAL); 1316 URB_DMA_MAP_SINGLE | URB_MAP_LOCAL);
1309} 1317}
1318EXPORT_SYMBOL_GPL(unmap_urb_for_dma);
1310 1319
1311static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, 1320static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
1312 gfp_t mem_flags) 1321 gfp_t mem_flags)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 84c1897188d2..27115b45edc5 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -758,6 +758,9 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
758 clear_port_feature(hdev, port1, 758 clear_port_feature(hdev, port1,
759 USB_PORT_FEAT_ENABLE); 759 USB_PORT_FEAT_ENABLE);
760 portstatus &= ~USB_PORT_STAT_ENABLE; 760 portstatus &= ~USB_PORT_STAT_ENABLE;
761 } else {
762 /* Pretend that power was lost for USB3 devs */
763 portstatus &= ~USB_PORT_STAT_ENABLE;
761 } 764 }
762 } 765 }
763 766
@@ -2594,16 +2597,14 @@ static int hub_set_address(struct usb_device *udev, int devnum)
2594 return 0; 2597 return 0;
2595 if (udev->state != USB_STATE_DEFAULT) 2598 if (udev->state != USB_STATE_DEFAULT)
2596 return -EINVAL; 2599 return -EINVAL;
2597 if (hcd->driver->address_device) { 2600 if (hcd->driver->address_device)
2598 retval = hcd->driver->address_device(hcd, udev); 2601 retval = hcd->driver->address_device(hcd, udev);
2599 } else { 2602 else
2600 retval = usb_control_msg(udev, usb_sndaddr0pipe(), 2603 retval = usb_control_msg(udev, usb_sndaddr0pipe(),
2601 USB_REQ_SET_ADDRESS, 0, devnum, 0, 2604 USB_REQ_SET_ADDRESS, 0, devnum, 0,
2602 NULL, 0, USB_CTRL_SET_TIMEOUT); 2605 NULL, 0, USB_CTRL_SET_TIMEOUT);
2603 if (retval == 0)
2604 update_address(udev, devnum);
2605 }
2606 if (retval == 0) { 2606 if (retval == 0) {
2607 update_address(udev, devnum);
2607 /* Device now using proper address. */ 2608 /* Device now using proper address. */
2608 usb_set_device_state(udev, USB_STATE_ADDRESS); 2609 usb_set_device_state(udev, USB_STATE_ADDRESS);
2609 usb_ep0_reinit(udev); 2610 usb_ep0_reinit(udev);
@@ -2860,13 +2861,16 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2860 else 2861 else
2861 i = udev->descriptor.bMaxPacketSize0; 2862 i = udev->descriptor.bMaxPacketSize0;
2862 if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) { 2863 if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
2863 if (udev->speed != USB_SPEED_FULL || 2864 if (udev->speed == USB_SPEED_LOW ||
2864 !(i == 8 || i == 16 || i == 32 || i == 64)) { 2865 !(i == 8 || i == 16 || i == 32 || i == 64)) {
2865 dev_err(&udev->dev, "ep0 maxpacket = %d\n", i); 2866 dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i);
2866 retval = -EMSGSIZE; 2867 retval = -EMSGSIZE;
2867 goto fail; 2868 goto fail;
2868 } 2869 }
2869 dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); 2870 if (udev->speed == USB_SPEED_FULL)
2871 dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
2872 else
2873 dev_warn(&udev->dev, "Using ep0 maxpacket: %d\n", i);
2870 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i); 2874 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i);
2871 usb_ep0_reinit(udev); 2875 usb_ep0_reinit(udev);
2872 } 2876 }
@@ -3097,16 +3101,17 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
3097 udev->speed = USB_SPEED_UNKNOWN; 3101 udev->speed = USB_SPEED_UNKNOWN;
3098 3102
3099 /* 3103 /*
3100 * xHCI needs to issue an address device command later 3104 * Set the address.
3101 * in the hub_port_init sequence for SS/HS/FS/LS devices. 3105 * Note xHCI needs to issue an address device command later
3106 * in the hub_port_init sequence for SS/HS/FS/LS devices,
3107 * and xHC will assign an address to the device. But use
3108 * kernel assigned address here, to avoid any address conflict
3109 * issue.
3102 */ 3110 */
3103 if (!(hcd->driver->flags & HCD_USB3)) { 3111 choose_address(udev);
3104 /* set the address */ 3112 if (udev->devnum <= 0) {
3105 choose_address(udev); 3113 status = -ENOTCONN; /* Don't retry */
3106 if (udev->devnum <= 0) { 3114 goto loop;
3107 status = -ENOTCONN; /* Don't retry */
3108 goto loop;
3109 }
3110 } 3115 }
3111 3116
3112 /* reset (non-USB 3.0 devices) and get descriptor */ 3117 /* reset (non-USB 3.0 devices) and get descriptor */
@@ -3629,7 +3634,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
3629 } 3634 }
3630 3635
3631 if (!parent_hdev) { 3636 if (!parent_hdev) {
3632 /* this requires hcd-specific logic; see OHCI hc_restart() */ 3637 /* this requires hcd-specific logic; see ohci_restart() */
3633 dev_dbg(&udev->dev, "%s for root hub!\n", __func__); 3638 dev_dbg(&udev->dev, "%s for root hub!\n", __func__);
3634 return -EISDIR; 3639 return -EISDIR;
3635 } 3640 }
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 9f0ce7de0e36..d6e3e410477e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1140,13 +1140,6 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1140{ 1140{
1141 int i; 1141 int i;
1142 1142
1143 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
1144 skip_ep0 ? "non-ep0" : "all");
1145 for (i = skip_ep0; i < 16; ++i) {
1146 usb_disable_endpoint(dev, i, true);
1147 usb_disable_endpoint(dev, i + USB_DIR_IN, true);
1148 }
1149
1150 /* getting rid of interfaces will disconnect 1143 /* getting rid of interfaces will disconnect
1151 * any drivers bound to them (a key side effect) 1144 * any drivers bound to them (a key side effect)
1152 */ 1145 */
@@ -1176,6 +1169,13 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1176 if (dev->state == USB_STATE_CONFIGURED) 1169 if (dev->state == USB_STATE_CONFIGURED)
1177 usb_set_device_state(dev, USB_STATE_ADDRESS); 1170 usb_set_device_state(dev, USB_STATE_ADDRESS);
1178 } 1171 }
1172
1173 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
1174 skip_ep0 ? "non-ep0" : "all");
1175 for (i = skip_ep0; i < 16; ++i) {
1176 usb_disable_endpoint(dev, i, true);
1177 usb_disable_endpoint(dev, i + USB_DIR_IN, true);
1178 }
1179} 1179}
1180 1180
1181/** 1181/**
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 419e6b34e2fe..c14fc082864f 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -401,8 +401,11 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
401 }; 401 };
402 402
403 /* Check that the pipe's type matches the endpoint's type */ 403 /* Check that the pipe's type matches the endpoint's type */
404 if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) 404 if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) {
405 dev_err(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n",
406 usb_pipetype(urb->pipe), pipetypes[xfertype]);
405 return -EPIPE; /* The most suitable error code :-) */ 407 return -EPIPE; /* The most suitable error code :-) */
408 }
406 409
407 /* enforce simple/standard policy */ 410 /* enforce simple/standard policy */
408 allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | 411 allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK |
diff --git a/drivers/usb/early/Makefile b/drivers/usb/early/Makefile
index dfedee8c45b6..24bbe519c737 100644
--- a/drivers/usb/early/Makefile
+++ b/drivers/usb/early/Makefile
@@ -2,4 +2,4 @@
2# Makefile for early USB devices 2# Makefile for early USB devices
3# 3#
4 4
5obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o 5obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index cd27f9bde2c8..b739ca814651 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -158,6 +158,7 @@ config USB_GADGET_FSL_USB2
158 boolean "Freescale Highspeed USB DR Peripheral Controller" 158 boolean "Freescale Highspeed USB DR Peripheral Controller"
159 depends on FSL_SOC || ARCH_MXC 159 depends on FSL_SOC || ARCH_MXC
160 select USB_GADGET_DUALSPEED 160 select USB_GADGET_DUALSPEED
161 select USB_FSL_MPH_DR_OF
161 help 162 help
162 Some of Freescale PowerPC processors have a High Speed 163 Some of Freescale PowerPC processors have a High Speed
163 Dual-Role(DR) USB controller, which supports device mode. 164 Dual-Role(DR) USB controller, which supports device mode.
@@ -209,17 +210,6 @@ config USB_OMAP
209 default USB_GADGET 210 default USB_GADGET
210 select USB_GADGET_SELECTED 211 select USB_GADGET_SELECTED
211 212
212config USB_OTG
213 boolean "OTG Support"
214 depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD
215 help
216 The most notable feature of USB OTG is support for a
217 "Dual-Role" device, which can act as either a device
218 or a host. The initial role choice can be changed
219 later, when two dual-role devices talk to each other.
220
221 Select this only if your OMAP board has a Mini-AB connector.
222
223config USB_GADGET_PXA25X 213config USB_GADGET_PXA25X
224 boolean "PXA 25x or IXP 4xx" 214 boolean "PXA 25x or IXP 4xx"
225 depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX 215 depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX
@@ -716,8 +706,8 @@ config USB_FUNCTIONFS
716 depends on EXPERIMENTAL 706 depends on EXPERIMENTAL
717 select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS) 707 select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS)
718 help 708 help
719 The Function Filesystem (FunctioFS) lets one create USB 709 The Function Filesystem (FunctionFS) lets one create USB
720 composite functions in user space in the same way as GadgetFS 710 composite functions in user space in the same way GadgetFS
721 lets one create USB gadgets in user space. This allows creation 711 lets one create USB gadgets in user space. This allows creation
722 of composite gadgets such that some of the functions are 712 of composite gadgets such that some of the functions are
723 implemented in kernel space (for instance Ethernet, serial or 713 implemented in kernel space (for instance Ethernet, serial or
@@ -733,14 +723,14 @@ config USB_FUNCTIONFS_ETH
733 bool "Include configuration with CDC ECM (Ethernet)" 723 bool "Include configuration with CDC ECM (Ethernet)"
734 depends on USB_FUNCTIONFS && NET 724 depends on USB_FUNCTIONFS && NET
735 help 725 help
736 Include a configuration with CDC ECM funcion (Ethernet) and the 726 Include a configuration with CDC ECM function (Ethernet) and the
737 Funcion Filesystem. 727 Function Filesystem.
738 728
739config USB_FUNCTIONFS_RNDIS 729config USB_FUNCTIONFS_RNDIS
740 bool "Include configuration with RNDIS (Ethernet)" 730 bool "Include configuration with RNDIS (Ethernet)"
741 depends on USB_FUNCTIONFS && NET 731 depends on USB_FUNCTIONFS && NET
742 help 732 help
743 Include a configuration with RNDIS funcion (Ethernet) and the Filesystem. 733 Include a configuration with RNDIS function (Ethernet) and the Filesystem.
744 734
745config USB_FUNCTIONFS_GENERIC 735config USB_FUNCTIONFS_GENERIC
746 bool "Include 'pure' configuration" 736 bool "Include 'pure' configuration"
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 27283df37d09..5780db42417b 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -1,9 +1,7 @@
1# 1#
2# USB peripheral controller drivers 2# USB peripheral controller drivers
3# 3#
4ifeq ($(CONFIG_USB_GADGET_DEBUG),y) 4ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
5 EXTRA_CFLAGS += -DDEBUG
6endif
7 5
8obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o 6obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o
9obj-$(CONFIG_USB_NET2280) += net2280.o 7obj-$(CONFIG_USB_NET2280) += net2280.o
@@ -18,10 +16,8 @@ obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o
18obj-$(CONFIG_USB_AT91) += at91_udc.o 16obj-$(CONFIG_USB_AT91) += at91_udc.o
19obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o 17obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o
20obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o 18obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o
21fsl_usb2_udc-objs := fsl_udc_core.o 19fsl_usb2_udc-y := fsl_udc_core.o
22ifeq ($(CONFIG_ARCH_MXC),y) 20fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o
23fsl_usb2_udc-objs += fsl_mxc_udc.o
24endif
25obj-$(CONFIG_USB_M66592) += m66592-udc.o 21obj-$(CONFIG_USB_M66592) += m66592-udc.o
26obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o 22obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o
27obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o 23obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o
@@ -32,21 +28,21 @@ obj-$(CONFIG_USB_LANGWELL) += langwell_udc.o
32# 28#
33# USB gadget drivers 29# USB gadget drivers
34# 30#
35g_zero-objs := zero.o 31g_zero-y := zero.o
36g_audio-objs := audio.o 32g_audio-y := audio.o
37g_ether-objs := ether.o 33g_ether-y := ether.o
38g_serial-objs := serial.o 34g_serial-y := serial.o
39g_midi-objs := gmidi.o 35g_midi-y := gmidi.o
40gadgetfs-objs := inode.o 36gadgetfs-y := inode.o
41g_file_storage-objs := file_storage.o 37g_file_storage-y := file_storage.o
42g_mass_storage-objs := mass_storage.o 38g_mass_storage-y := mass_storage.o
43g_printer-objs := printer.o 39g_printer-y := printer.o
44g_cdc-objs := cdc2.o 40g_cdc-y := cdc2.o
45g_multi-objs := multi.o 41g_multi-y := multi.o
46g_hid-objs := hid.o 42g_hid-y := hid.o
47g_dbgp-objs := dbgp.o 43g_dbgp-y := dbgp.o
48g_nokia-objs := nokia.o 44g_nokia-y := nokia.o
49g_webcam-objs := webcam.o 45g_webcam-y := webcam.o
50 46
51obj-$(CONFIG_USB_ZERO) += g_zero.o 47obj-$(CONFIG_USB_ZERO) += g_zero.o
52obj-$(CONFIG_USB_AUDIO) += g_audio.o 48obj-$(CONFIG_USB_AUDIO) += g_audio.o
@@ -64,4 +60,3 @@ obj-$(CONFIG_USB_G_DBGP) += g_dbgp.o
64obj-$(CONFIG_USB_G_MULTI) += g_multi.o 60obj-$(CONFIG_USB_G_MULTI) += g_multi.o
65obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o 61obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o
66obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o 62obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o
67
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 731150d4b1d9..9034e0344723 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -203,7 +203,7 @@ static void print_regs(struct udc *dev)
203 DBG(dev, "DMA mode = PPBNDU (packet per buffer " 203 DBG(dev, "DMA mode = PPBNDU (packet per buffer "
204 "WITHOUT desc. update)\n"); 204 "WITHOUT desc. update)\n");
205 dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBNDU"); 205 dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBNDU");
206 } else if (use_dma && use_dma_ppb_du && use_dma_ppb_du) { 206 } else if (use_dma && use_dma_ppb && use_dma_ppb_du) {
207 DBG(dev, "DMA mode = PPBDU (packet per buffer " 207 DBG(dev, "DMA mode = PPBDU (packet per buffer "
208 "WITH desc. update)\n"); 208 "WITH desc. update)\n");
209 dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBDU"); 209 dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBDU");
@@ -1954,13 +1954,14 @@ static int setup_ep0(struct udc *dev)
1954} 1954}
1955 1955
1956/* Called by gadget driver to register itself */ 1956/* Called by gadget driver to register itself */
1957int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1957int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1958 int (*bind)(struct usb_gadget *))
1958{ 1959{
1959 struct udc *dev = udc; 1960 struct udc *dev = udc;
1960 int retval; 1961 int retval;
1961 u32 tmp; 1962 u32 tmp;
1962 1963
1963 if (!driver || !driver->bind || !driver->setup 1964 if (!driver || !bind || !driver->setup
1964 || driver->speed != USB_SPEED_HIGH) 1965 || driver->speed != USB_SPEED_HIGH)
1965 return -EINVAL; 1966 return -EINVAL;
1966 if (!dev) 1967 if (!dev)
@@ -1972,7 +1973,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1972 dev->driver = driver; 1973 dev->driver = driver;
1973 dev->gadget.dev.driver = &driver->driver; 1974 dev->gadget.dev.driver = &driver->driver;
1974 1975
1975 retval = driver->bind(&dev->gadget); 1976 retval = bind(&dev->gadget);
1976 1977
1977 /* Some gadget drivers use both ep0 directions. 1978 /* Some gadget drivers use both ep0 directions.
1978 * NOTE: to gadget driver, ep0 is just one endpoint... 1979 * NOTE: to gadget driver, ep0 is just one endpoint...
@@ -2000,7 +2001,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2000 2001
2001 return 0; 2002 return 0;
2002} 2003}
2003EXPORT_SYMBOL(usb_gadget_register_driver); 2004EXPORT_SYMBOL(usb_gadget_probe_driver);
2004 2005
2005/* shutdown requests and disconnect from gadget */ 2006/* shutdown requests and disconnect from gadget */
2006static void 2007static void
@@ -3382,8 +3383,10 @@ static int udc_probe(struct udc *dev)
3382 udc = dev; 3383 udc = dev;
3383 3384
3384 retval = device_register(&dev->gadget.dev); 3385 retval = device_register(&dev->gadget.dev);
3385 if (retval) 3386 if (retval) {
3387 put_device(&dev->gadget.dev);
3386 goto finished; 3388 goto finished;
3389 }
3387 3390
3388 /* timer init */ 3391 /* timer init */
3389 init_timer(&udc_timer); 3392 init_timer(&udc_timer);
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 93ead19507b6..387e503b9d14 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1628,7 +1628,8 @@ static void at91_vbus_timer(unsigned long data)
1628 schedule_work(&udc->vbus_timer_work); 1628 schedule_work(&udc->vbus_timer_work);
1629} 1629}
1630 1630
1631int usb_gadget_register_driver (struct usb_gadget_driver *driver) 1631int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1632 int (*bind)(struct usb_gadget *))
1632{ 1633{
1633 struct at91_udc *udc = &controller; 1634 struct at91_udc *udc = &controller;
1634 int retval; 1635 int retval;
@@ -1636,7 +1637,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1636 1637
1637 if (!driver 1638 if (!driver
1638 || driver->speed < USB_SPEED_FULL 1639 || driver->speed < USB_SPEED_FULL
1639 || !driver->bind 1640 || !bind
1640 || !driver->setup) { 1641 || !driver->setup) {
1641 DBG("bad parameter.\n"); 1642 DBG("bad parameter.\n");
1642 return -EINVAL; 1643 return -EINVAL;
@@ -1653,9 +1654,9 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1653 udc->enabled = 1; 1654 udc->enabled = 1;
1654 udc->selfpowered = 1; 1655 udc->selfpowered = 1;
1655 1656
1656 retval = driver->bind(&udc->gadget); 1657 retval = bind(&udc->gadget);
1657 if (retval) { 1658 if (retval) {
1658 DBG("driver->bind() returned %d\n", retval); 1659 DBG("bind() returned %d\n", retval);
1659 udc->driver = NULL; 1660 udc->driver = NULL;
1660 udc->gadget.dev.driver = NULL; 1661 udc->gadget.dev.driver = NULL;
1661 dev_set_drvdata(&udc->gadget.dev, NULL); 1662 dev_set_drvdata(&udc->gadget.dev, NULL);
@@ -1671,7 +1672,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1671 DBG("bound to %s\n", driver->driver.name); 1672 DBG("bound to %s\n", driver->driver.name);
1672 return 0; 1673 return 0;
1673} 1674}
1674EXPORT_SYMBOL (usb_gadget_register_driver); 1675EXPORT_SYMBOL(usb_gadget_probe_driver);
1675 1676
1676int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) 1677int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
1677{ 1678{
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index d623c7bda1f6..b5e20e873cba 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1789,7 +1789,8 @@ out:
1789 return IRQ_HANDLED; 1789 return IRQ_HANDLED;
1790} 1790}
1791 1791
1792int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1792int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1793 int (*bind)(struct usb_gadget *))
1793{ 1794{
1794 struct usba_udc *udc = &the_udc; 1795 struct usba_udc *udc = &the_udc;
1795 unsigned long flags; 1796 unsigned long flags;
@@ -1812,7 +1813,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1812 clk_enable(udc->pclk); 1813 clk_enable(udc->pclk);
1813 clk_enable(udc->hclk); 1814 clk_enable(udc->hclk);
1814 1815
1815 ret = driver->bind(&udc->gadget); 1816 ret = bind(&udc->gadget);
1816 if (ret) { 1817 if (ret) {
1817 DBG(DBG_ERR, "Could not bind to driver %s: error %d\n", 1818 DBG(DBG_ERR, "Could not bind to driver %s: error %d\n",
1818 driver->driver.name, ret); 1819 driver->driver.name, ret);
@@ -1841,7 +1842,7 @@ err_driver_bind:
1841 udc->gadget.dev.driver = NULL; 1842 udc->gadget.dev.driver = NULL;
1842 return ret; 1843 return ret;
1843} 1844}
1844EXPORT_SYMBOL(usb_gadget_register_driver); 1845EXPORT_SYMBOL(usb_gadget_probe_driver);
1845 1846
1846int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 1847int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1847{ 1848{
@@ -2014,6 +2015,9 @@ static int __init usba_udc_probe(struct platform_device *pdev)
2014 } else { 2015 } else {
2015 disable_irq(gpio_to_irq(udc->vbus_pin)); 2016 disable_irq(gpio_to_irq(udc->vbus_pin));
2016 } 2017 }
2018 } else {
2019 /* gpio_request fail so use -EINVAL for gpio_is_valid */
2020 ubc->vbus_pin = -EINVAL;
2017 } 2021 }
2018 } 2022 }
2019 2023
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index b744ccd0f34d..93b999e49ef3 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -89,7 +89,7 @@ static const struct usb_descriptor_header *otg_desc[] = {
89 89
90/*-------------------------------------------------------------------------*/ 90/*-------------------------------------------------------------------------*/
91 91
92static int __ref audio_do_config(struct usb_configuration *c) 92static int __init audio_do_config(struct usb_configuration *c)
93{ 93{
94 /* FIXME alloc iConfiguration string, set it in c->strings */ 94 /* FIXME alloc iConfiguration string, set it in c->strings */
95 95
@@ -105,7 +105,6 @@ static int __ref audio_do_config(struct usb_configuration *c)
105 105
106static struct usb_configuration audio_config_driver = { 106static struct usb_configuration audio_config_driver = {
107 .label = DRIVER_DESC, 107 .label = DRIVER_DESC,
108 .bind = audio_do_config,
109 .bConfigurationValue = 1, 108 .bConfigurationValue = 1,
110 /* .iConfiguration = DYNAMIC */ 109 /* .iConfiguration = DYNAMIC */
111 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 110 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -113,7 +112,7 @@ static struct usb_configuration audio_config_driver = {
113 112
114/*-------------------------------------------------------------------------*/ 113/*-------------------------------------------------------------------------*/
115 114
116static int __ref audio_bind(struct usb_composite_dev *cdev) 115static int __init audio_bind(struct usb_composite_dev *cdev)
117{ 116{
118 int gcnum; 117 int gcnum;
119 int status; 118 int status;
@@ -145,7 +144,7 @@ static int __ref audio_bind(struct usb_composite_dev *cdev)
145 strings_dev[STRING_PRODUCT_IDX].id = status; 144 strings_dev[STRING_PRODUCT_IDX].id = status;
146 device_desc.iProduct = status; 145 device_desc.iProduct = status;
147 146
148 status = usb_add_config(cdev, &audio_config_driver); 147 status = usb_add_config(cdev, &audio_config_driver, audio_do_config);
149 if (status < 0) 148 if (status < 0)
150 goto fail; 149 goto fail;
151 150
@@ -166,13 +165,12 @@ static struct usb_composite_driver audio_driver = {
166 .name = "g_audio", 165 .name = "g_audio",
167 .dev = &device_desc, 166 .dev = &device_desc,
168 .strings = audio_strings, 167 .strings = audio_strings,
169 .bind = audio_bind,
170 .unbind = __exit_p(audio_unbind), 168 .unbind = __exit_p(audio_unbind),
171}; 169};
172 170
173static int __init init(void) 171static int __init init(void)
174{ 172{
175 return usb_composite_register(&audio_driver); 173 return usb_composite_probe(&audio_driver, audio_bind);
176} 174}
177module_init(init); 175module_init(init);
178 176
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 1f5ba2fd4c1f..2720ab07ef1a 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -129,7 +129,7 @@ static u8 hostaddr[ETH_ALEN];
129/* 129/*
130 * We _always_ have both CDC ECM and CDC ACM functions. 130 * We _always_ have both CDC ECM and CDC ACM functions.
131 */ 131 */
132static int __ref cdc_do_config(struct usb_configuration *c) 132static int __init cdc_do_config(struct usb_configuration *c)
133{ 133{
134 int status; 134 int status;
135 135
@@ -151,7 +151,6 @@ static int __ref cdc_do_config(struct usb_configuration *c)
151 151
152static struct usb_configuration cdc_config_driver = { 152static struct usb_configuration cdc_config_driver = {
153 .label = "CDC Composite (ECM + ACM)", 153 .label = "CDC Composite (ECM + ACM)",
154 .bind = cdc_do_config,
155 .bConfigurationValue = 1, 154 .bConfigurationValue = 1,
156 /* .iConfiguration = DYNAMIC */ 155 /* .iConfiguration = DYNAMIC */
157 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 156 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -159,7 +158,7 @@ static struct usb_configuration cdc_config_driver = {
159 158
160/*-------------------------------------------------------------------------*/ 159/*-------------------------------------------------------------------------*/
161 160
162static int __ref cdc_bind(struct usb_composite_dev *cdev) 161static int __init cdc_bind(struct usb_composite_dev *cdev)
163{ 162{
164 int gcnum; 163 int gcnum;
165 struct usb_gadget *gadget = cdev->gadget; 164 struct usb_gadget *gadget = cdev->gadget;
@@ -218,7 +217,7 @@ static int __ref cdc_bind(struct usb_composite_dev *cdev)
218 device_desc.iProduct = status; 217 device_desc.iProduct = status;
219 218
220 /* register our configuration */ 219 /* register our configuration */
221 status = usb_add_config(cdev, &cdc_config_driver); 220 status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config);
222 if (status < 0) 221 if (status < 0)
223 goto fail1; 222 goto fail1;
224 223
@@ -245,7 +244,6 @@ static struct usb_composite_driver cdc_driver = {
245 .name = "g_cdc", 244 .name = "g_cdc",
246 .dev = &device_desc, 245 .dev = &device_desc,
247 .strings = dev_strings, 246 .strings = dev_strings,
248 .bind = cdc_bind,
249 .unbind = __exit_p(cdc_unbind), 247 .unbind = __exit_p(cdc_unbind),
250}; 248};
251 249
@@ -255,7 +253,7 @@ MODULE_LICENSE("GPL");
255 253
256static int __init init(void) 254static int __init init(void)
257{ 255{
258 return usb_composite_register(&cdc_driver); 256 return usb_composite_probe(&cdc_driver, cdc_bind);
259} 257}
260module_init(init); 258module_init(init);
261 259
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 699695128e33..98b36fc88c77 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -2340,12 +2340,15 @@ static const struct usb_ep_ops usb_ep_ops = {
2340static const struct usb_gadget_ops usb_gadget_ops; 2340static const struct usb_gadget_ops usb_gadget_ops;
2341 2341
2342/** 2342/**
2343 * usb_gadget_register_driver: register a gadget driver 2343 * usb_gadget_probe_driver: register a gadget driver
2344 * @driver: the driver being registered
2345 * @bind: the driver's bind callback
2344 * 2346 *
2345 * Check usb_gadget_register_driver() at "usb_gadget.h" for details 2347 * Check usb_gadget_probe_driver() at <linux/usb/gadget.h> for details.
2346 * Interrupts are enabled here 2348 * Interrupts are enabled here.
2347 */ 2349 */
2348int usb_gadget_register_driver(struct usb_gadget_driver *driver) 2350int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2351 int (*bind)(struct usb_gadget *))
2349{ 2352{
2350 struct ci13xxx *udc = _udc; 2353 struct ci13xxx *udc = _udc;
2351 unsigned long i, k, flags; 2354 unsigned long i, k, flags;
@@ -2354,7 +2357,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2354 trace("%p", driver); 2357 trace("%p", driver);
2355 2358
2356 if (driver == NULL || 2359 if (driver == NULL ||
2357 driver->bind == NULL || 2360 bind == NULL ||
2358 driver->unbind == NULL || 2361 driver->unbind == NULL ||
2359 driver->setup == NULL || 2362 driver->setup == NULL ||
2360 driver->disconnect == NULL || 2363 driver->disconnect == NULL ||
@@ -2430,7 +2433,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2430 udc->gadget.dev.driver = &driver->driver; 2433 udc->gadget.dev.driver = &driver->driver;
2431 2434
2432 spin_unlock_irqrestore(udc->lock, flags); 2435 spin_unlock_irqrestore(udc->lock, flags);
2433 retval = driver->bind(&udc->gadget); /* MAY SLEEP */ 2436 retval = bind(&udc->gadget); /* MAY SLEEP */
2434 spin_lock_irqsave(udc->lock, flags); 2437 spin_lock_irqsave(udc->lock, flags);
2435 2438
2436 if (retval) { 2439 if (retval) {
@@ -2447,7 +2450,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2447 usb_gadget_unregister_driver(driver); 2450 usb_gadget_unregister_driver(driver);
2448 return retval; 2451 return retval;
2449} 2452}
2450EXPORT_SYMBOL(usb_gadget_register_driver); 2453EXPORT_SYMBOL(usb_gadget_probe_driver);
2451 2454
2452/** 2455/**
2453 * usb_gadget_unregister_driver: unregister a gadget driver 2456 * usb_gadget_unregister_driver: unregister a gadget driver
@@ -2462,7 +2465,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2462 trace("%p", driver); 2465 trace("%p", driver);
2463 2466
2464 if (driver == NULL || 2467 if (driver == NULL ||
2465 driver->bind == NULL ||
2466 driver->unbind == NULL || 2468 driver->unbind == NULL ||
2467 driver->setup == NULL || 2469 driver->setup == NULL ||
2468 driver->disconnect == NULL || 2470 driver->disconnect == NULL ||
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 1160c55de7f2..7b5cc16e4a0b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/utsname.h>
27 28
28#include <linux/usb/composite.h> 29#include <linux/usb/composite.h>
29 30
@@ -39,6 +40,7 @@
39#define USB_BUFSIZ 1024 40#define USB_BUFSIZ 1024
40 41
41static struct usb_composite_driver *composite; 42static struct usb_composite_driver *composite;
43static int (*composite_gadget_bind)(struct usb_composite_dev *cdev);
42 44
43/* Some systems will need runtime overrides for the product identifers 45/* Some systems will need runtime overrides for the product identifers
44 * published in the device descriptor, either numbers or strings or both. 46 * published in the device descriptor, either numbers or strings or both.
@@ -69,6 +71,8 @@ static char *iSerialNumber;
69module_param(iSerialNumber, charp, 0); 71module_param(iSerialNumber, charp, 0);
70MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); 72MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");
71 73
74static char composite_manufacturer[50];
75
72/*-------------------------------------------------------------------------*/ 76/*-------------------------------------------------------------------------*/
73 77
74/** 78/**
@@ -470,18 +474,20 @@ done:
470 * usb_add_config() - add a configuration to a device. 474 * usb_add_config() - add a configuration to a device.
471 * @cdev: wraps the USB gadget 475 * @cdev: wraps the USB gadget
472 * @config: the configuration, with bConfigurationValue assigned 476 * @config: the configuration, with bConfigurationValue assigned
477 * @bind: the configuration's bind function
473 * Context: single threaded during gadget setup 478 * Context: single threaded during gadget setup
474 * 479 *
475 * One of the main tasks of a composite driver's bind() routine is to 480 * One of the main tasks of a composite @bind() routine is to
476 * add each of the configurations it supports, using this routine. 481 * add each of the configurations it supports, using this routine.
477 * 482 *
478 * This function returns the value of the configuration's bind(), which 483 * This function returns the value of the configuration's @bind(), which
479 * is zero for success else a negative errno value. Binding configurations 484 * is zero for success else a negative errno value. Binding configurations
480 * assigns global resources including string IDs, and per-configuration 485 * assigns global resources including string IDs, and per-configuration
481 * resources such as interface IDs and endpoints. 486 * resources such as interface IDs and endpoints.
482 */ 487 */
483int usb_add_config(struct usb_composite_dev *cdev, 488int usb_add_config(struct usb_composite_dev *cdev,
484 struct usb_configuration *config) 489 struct usb_configuration *config,
490 int (*bind)(struct usb_configuration *))
485{ 491{
486 int status = -EINVAL; 492 int status = -EINVAL;
487 struct usb_configuration *c; 493 struct usb_configuration *c;
@@ -490,7 +496,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
490 config->bConfigurationValue, 496 config->bConfigurationValue,
491 config->label, config); 497 config->label, config);
492 498
493 if (!config->bConfigurationValue || !config->bind) 499 if (!config->bConfigurationValue || !bind)
494 goto done; 500 goto done;
495 501
496 /* Prevent duplicate configuration identifiers */ 502 /* Prevent duplicate configuration identifiers */
@@ -507,7 +513,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
507 INIT_LIST_HEAD(&config->functions); 513 INIT_LIST_HEAD(&config->functions);
508 config->next_interface_id = 0; 514 config->next_interface_id = 0;
509 515
510 status = config->bind(config); 516 status = bind(config);
511 if (status < 0) { 517 if (status < 0) {
512 list_del(&config->list); 518 list_del(&config->list);
513 config->cdev = NULL; 519 config->cdev = NULL;
@@ -533,7 +539,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
533 } 539 }
534 } 540 }
535 541
536 /* set_alt(), or next config->bind(), sets up 542 /* set_alt(), or next bind(), sets up
537 * ep->driver_data as needed. 543 * ep->driver_data as needed.
538 */ 544 */
539 usb_ep_autoconfig_reset(cdev->gadget); 545 usb_ep_autoconfig_reset(cdev->gadget);
@@ -599,6 +605,7 @@ static int get_string(struct usb_composite_dev *cdev,
599 struct usb_configuration *c; 605 struct usb_configuration *c;
600 struct usb_function *f; 606 struct usb_function *f;
601 int len; 607 int len;
608 const char *str;
602 609
603 /* Yes, not only is USB's I18N support probably more than most 610 /* Yes, not only is USB's I18N support probably more than most
604 * folk will ever care about ... also, it's all supported here. 611 * folk will ever care about ... also, it's all supported here.
@@ -638,9 +645,29 @@ static int get_string(struct usb_composite_dev *cdev,
638 return s->bLength; 645 return s->bLength;
639 } 646 }
640 647
641 /* Otherwise, look up and return a specified string. String IDs 648 /* Otherwise, look up and return a specified string. First
642 * are device-scoped, so we look up each string table we're told 649 * check if the string has not been overridden.
643 * about. These lookups are infrequent; simpler-is-better here. 650 */
651 if (cdev->manufacturer_override == id)
652 str = iManufacturer ?: composite->iManufacturer ?:
653 composite_manufacturer;
654 else if (cdev->product_override == id)
655 str = iProduct ?: composite->iProduct;
656 else if (cdev->serial_override == id)
657 str = iSerialNumber;
658 else
659 str = NULL;
660 if (str) {
661 struct usb_gadget_strings strings = {
662 .language = language,
663 .strings = &(struct usb_string) { 0xff, str }
664 };
665 return usb_gadget_get_string(&strings, 0xff, buf);
666 }
667
668 /* String IDs are device-scoped, so we look up each string
669 * table we're told about. These lookups are infrequent;
670 * simpler-is-better here.
644 */ 671 */
645 if (composite->strings) { 672 if (composite->strings) {
646 len = lookup_string(composite->strings, buf, language, id); 673 len = lookup_string(composite->strings, buf, language, id);
@@ -901,7 +928,8 @@ unknown:
901 */ 928 */
902 switch (ctrl->bRequestType & USB_RECIP_MASK) { 929 switch (ctrl->bRequestType & USB_RECIP_MASK) {
903 case USB_RECIP_INTERFACE: 930 case USB_RECIP_INTERFACE:
904 f = cdev->config->interface[intf]; 931 if (cdev->config)
932 f = cdev->config->interface[intf];
905 break; 933 break;
906 934
907 case USB_RECIP_ENDPOINT: 935 case USB_RECIP_ENDPOINT:
@@ -1025,26 +1053,17 @@ composite_unbind(struct usb_gadget *gadget)
1025 composite = NULL; 1053 composite = NULL;
1026} 1054}
1027 1055
1028static void 1056static u8 override_id(struct usb_composite_dev *cdev, u8 *desc)
1029string_override_one(struct usb_gadget_strings *tab, u8 id, const char *s)
1030{ 1057{
1031 struct usb_string *str = tab->strings; 1058 if (!*desc) {
1032 1059 int ret = usb_string_id(cdev);
1033 for (str = tab->strings; str->s; str++) { 1060 if (unlikely(ret < 0))
1034 if (str->id == id) { 1061 WARNING(cdev, "failed to override string ID\n");
1035 str->s = s; 1062 else
1036 return; 1063 *desc = ret;
1037 }
1038 } 1064 }
1039}
1040 1065
1041static void 1066 return *desc;
1042string_override(struct usb_gadget_strings **tab, u8 id, const char *s)
1043{
1044 while (*tab) {
1045 string_override_one(*tab, id, s);
1046 tab++;
1047 }
1048} 1067}
1049 1068
1050static int composite_bind(struct usb_gadget *gadget) 1069static int composite_bind(struct usb_gadget *gadget)
@@ -1074,7 +1093,13 @@ static int composite_bind(struct usb_gadget *gadget)
1074 cdev->bufsiz = USB_BUFSIZ; 1093 cdev->bufsiz = USB_BUFSIZ;
1075 cdev->driver = composite; 1094 cdev->driver = composite;
1076 1095
1077 usb_gadget_set_selfpowered(gadget); 1096 /*
1097 * As per USB compliance update, a device that is actively drawing
1098 * more than 100mA from USB must report itself as bus-powered in
1099 * the GetStatus(DEVICE) call.
1100 */
1101 if (CONFIG_USB_GADGET_VBUS_DRAW <= USB_SELF_POWER_VBUS_MAX_DRAW)
1102 usb_gadget_set_selfpowered(gadget);
1078 1103
1079 /* interface and string IDs start at zero via kzalloc. 1104 /* interface and string IDs start at zero via kzalloc.
1080 * we force endpoints to start unassigned; few controller 1105 * we force endpoints to start unassigned; few controller
@@ -1094,26 +1119,41 @@ static int composite_bind(struct usb_gadget *gadget)
1094 * serial number), register function drivers, potentially update 1119 * serial number), register function drivers, potentially update
1095 * power state and consumption, etc 1120 * power state and consumption, etc
1096 */ 1121 */
1097 status = composite->bind(cdev); 1122 status = composite_gadget_bind(cdev);
1098 if (status < 0) 1123 if (status < 0)
1099 goto fail; 1124 goto fail;
1100 1125
1101 cdev->desc = *composite->dev; 1126 cdev->desc = *composite->dev;
1102 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket; 1127 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1103 1128
1104 /* strings can't be assigned before bind() allocates the 1129 /* stirng overrides */
1105 * releavnt identifiers 1130 if (iManufacturer || !cdev->desc.iManufacturer) {
1106 */ 1131 if (!iManufacturer && !composite->iManufacturer &&
1107 if (cdev->desc.iManufacturer && iManufacturer) 1132 !*composite_manufacturer)
1108 string_override(composite->strings, 1133 snprintf(composite_manufacturer,
1109 cdev->desc.iManufacturer, iManufacturer); 1134 sizeof composite_manufacturer,
1110 if (cdev->desc.iProduct && iProduct) 1135 "%s %s with %s",
1111 string_override(composite->strings, 1136 init_utsname()->sysname,
1112 cdev->desc.iProduct, iProduct); 1137 init_utsname()->release,
1113 if (cdev->desc.iSerialNumber && iSerialNumber) 1138 gadget->name);
1114 string_override(composite->strings, 1139
1115 cdev->desc.iSerialNumber, iSerialNumber); 1140 cdev->manufacturer_override =
1141 override_id(cdev, &cdev->desc.iManufacturer);
1142 }
1143
1144 if (iProduct || (!cdev->desc.iProduct && composite->iProduct))
1145 cdev->product_override =
1146 override_id(cdev, &cdev->desc.iProduct);
1147
1148 if (iSerialNumber)
1149 cdev->serial_override =
1150 override_id(cdev, &cdev->desc.iSerialNumber);
1151
1152 /* has userspace failed to provide a serial number? */
1153 if (composite->needs_serial && !cdev->desc.iSerialNumber)
1154 WARNING(cdev, "userspace failed to provide iSerialNumber\n");
1116 1155
1156 /* finish up */
1117 status = device_create_file(&gadget->dev, &dev_attr_suspended); 1157 status = device_create_file(&gadget->dev, &dev_attr_suspended);
1118 if (status) 1158 if (status)
1119 goto fail; 1159 goto fail;
@@ -1177,7 +1217,6 @@ composite_resume(struct usb_gadget *gadget)
1177static struct usb_gadget_driver composite_driver = { 1217static struct usb_gadget_driver composite_driver = {
1178 .speed = USB_SPEED_HIGH, 1218 .speed = USB_SPEED_HIGH,
1179 1219
1180 .bind = composite_bind,
1181 .unbind = composite_unbind, 1220 .unbind = composite_unbind,
1182 1221
1183 .setup = composite_setup, 1222 .setup = composite_setup,
@@ -1192,8 +1231,12 @@ static struct usb_gadget_driver composite_driver = {
1192}; 1231};
1193 1232
1194/** 1233/**
1195 * usb_composite_register() - register a composite driver 1234 * usb_composite_probe() - register a composite driver
1196 * @driver: the driver to register 1235 * @driver: the driver to register
1236 * @bind: the callback used to allocate resources that are shared across the
1237 * whole device, such as string IDs, and add its configurations using
1238 * @usb_add_config(). This may fail by returning a negative errno
1239 * value; it should return zero on successful initialization.
1197 * Context: single threaded during gadget setup 1240 * Context: single threaded during gadget setup
1198 * 1241 *
1199 * This function is used to register drivers using the composite driver 1242 * This function is used to register drivers using the composite driver
@@ -1206,18 +1249,22 @@ static struct usb_gadget_driver composite_driver = {
1206 * while it was binding. That would usually be done in order to wait for 1249 * while it was binding. That would usually be done in order to wait for
1207 * some userspace participation. 1250 * some userspace participation.
1208 */ 1251 */
1209int usb_composite_register(struct usb_composite_driver *driver) 1252extern int usb_composite_probe(struct usb_composite_driver *driver,
1253 int (*bind)(struct usb_composite_dev *cdev))
1210{ 1254{
1211 if (!driver || !driver->dev || !driver->bind || composite) 1255 if (!driver || !driver->dev || !bind || composite)
1212 return -EINVAL; 1256 return -EINVAL;
1213 1257
1258 if (!driver->iProduct)
1259 driver->iProduct = driver->name;
1214 if (!driver->name) 1260 if (!driver->name)
1215 driver->name = "composite"; 1261 driver->name = "composite";
1216 composite_driver.function = (char *) driver->name; 1262 composite_driver.function = (char *) driver->name;
1217 composite_driver.driver.name = driver->name; 1263 composite_driver.driver.name = driver->name;
1218 composite = driver; 1264 composite = driver;
1265 composite_gadget_bind = bind;
1219 1266
1220 return usb_gadget_register_driver(&composite_driver); 1267 return usb_gadget_probe_driver(&composite_driver, composite_bind);
1221} 1268}
1222 1269
1223/** 1270/**
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c
index 0ed50a2c0a36..e5ac8a316fec 100644
--- a/drivers/usb/gadget/dbgp.c
+++ b/drivers/usb/gadget/dbgp.c
@@ -386,15 +386,13 @@ static int dbgp_setup(struct usb_gadget *gadget,
386 } else 386 } else
387 goto fail; 387 goto fail;
388 388
389 if (len >= 0) { 389 req->length = min(length, len);
390 req->length = min(length, len); 390 req->zero = len < req->length;
391 req->zero = len < req->length; 391 if (data && req->length)
392 if (data && req->length) 392 memcpy(req->buf, data, req->length);
393 memcpy(req->buf, data, req->length); 393
394 394 req->complete = dbgp_setup_complete;
395 req->complete = dbgp_setup_complete; 395 return usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
396 return usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
397 }
398 396
399fail: 397fail:
400 dev_dbg(&dbgp.gadget->dev, 398 dev_dbg(&dbgp.gadget->dev,
@@ -405,7 +403,6 @@ fail:
405static struct usb_gadget_driver dbgp_driver = { 403static struct usb_gadget_driver dbgp_driver = {
406 .function = "dbgp", 404 .function = "dbgp",
407 .speed = USB_SPEED_HIGH, 405 .speed = USB_SPEED_HIGH,
408 .bind = dbgp_bind,
409 .unbind = dbgp_unbind, 406 .unbind = dbgp_unbind,
410 .setup = dbgp_setup, 407 .setup = dbgp_setup,
411 .disconnect = dbgp_disconnect, 408 .disconnect = dbgp_disconnect,
@@ -417,7 +414,7 @@ static struct usb_gadget_driver dbgp_driver = {
417 414
418static int __init dbgp_init(void) 415static int __init dbgp_init(void)
419{ 416{
420 return usb_gadget_register_driver(&dbgp_driver); 417 return usb_gadget_probe_driver(&dbgp_driver, dbgp_bind);
421} 418}
422 419
423static void __exit dbgp_exit(void) 420static void __exit dbgp_exit(void)
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index dc6546248ed9..1d2a2abbfa80 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -748,7 +748,8 @@ static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
748 */ 748 */
749 749
750int 750int
751usb_gadget_register_driver (struct usb_gadget_driver *driver) 751usb_gadget_probe_driver(struct usb_gadget_driver *driver,
752 int (*bind)(struct usb_gadget *))
752{ 753{
753 struct dummy *dum = the_controller; 754 struct dummy *dum = the_controller;
754 int retval, i; 755 int retval, i;
@@ -757,8 +758,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
757 return -EINVAL; 758 return -EINVAL;
758 if (dum->driver) 759 if (dum->driver)
759 return -EBUSY; 760 return -EBUSY;
760 if (!driver->bind || !driver->setup 761 if (!bind || !driver->setup || driver->speed == USB_SPEED_UNKNOWN)
761 || driver->speed == USB_SPEED_UNKNOWN)
762 return -EINVAL; 762 return -EINVAL;
763 763
764 /* 764 /*
@@ -796,7 +796,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
796 dum->gadget.dev.driver = &driver->driver; 796 dum->gadget.dev.driver = &driver->driver;
797 dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", 797 dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n",
798 driver->driver.name); 798 driver->driver.name);
799 retval = driver->bind(&dum->gadget); 799 retval = bind(&dum->gadget);
800 if (retval) { 800 if (retval) {
801 dum->driver = NULL; 801 dum->driver = NULL;
802 dum->gadget.dev.driver = NULL; 802 dum->gadget.dev.driver = NULL;
@@ -812,7 +812,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
812 usb_hcd_poll_rh_status (dummy_to_hcd (dum)); 812 usb_hcd_poll_rh_status (dummy_to_hcd (dum));
813 return 0; 813 return 0;
814} 814}
815EXPORT_SYMBOL (usb_gadget_register_driver); 815EXPORT_SYMBOL(usb_gadget_probe_driver);
816 816
817int 817int
818usb_gadget_unregister_driver (struct usb_gadget_driver *driver) 818usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
@@ -874,6 +874,8 @@ static int dummy_udc_probe (struct platform_device *pdev)
874 struct dummy *dum = the_controller; 874 struct dummy *dum = the_controller;
875 int rc; 875 int rc;
876 876
877 usb_get_hcd(dummy_to_hcd(dum));
878
877 dum->gadget.name = gadget_name; 879 dum->gadget.name = gadget_name;
878 dum->gadget.ops = &dummy_ops; 880 dum->gadget.ops = &dummy_ops;
879 dum->gadget.is_dualspeed = 1; 881 dum->gadget.is_dualspeed = 1;
@@ -885,10 +887,10 @@ static int dummy_udc_probe (struct platform_device *pdev)
885 dum->gadget.dev.parent = &pdev->dev; 887 dum->gadget.dev.parent = &pdev->dev;
886 dum->gadget.dev.release = dummy_gadget_release; 888 dum->gadget.dev.release = dummy_gadget_release;
887 rc = device_register (&dum->gadget.dev); 889 rc = device_register (&dum->gadget.dev);
888 if (rc < 0) 890 if (rc < 0) {
891 put_device(&dum->gadget.dev);
889 return rc; 892 return rc;
890 893 }
891 usb_get_hcd (dummy_to_hcd (dum));
892 894
893 platform_set_drvdata (pdev, dum); 895 platform_set_drvdata (pdev, dum);
894 rc = device_create_file (&dum->gadget.dev, &dev_attr_function); 896 rc = device_create_file (&dum->gadget.dev, &dev_attr_function);
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 114fa024c22c..1690c9d68256 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -237,7 +237,7 @@ static u8 hostaddr[ETH_ALEN];
237 * the first one present. That's to make Microsoft's drivers happy, 237 * the first one present. That's to make Microsoft's drivers happy,
238 * and to follow DOCSIS 1.0 (cable modem standard). 238 * and to follow DOCSIS 1.0 (cable modem standard).
239 */ 239 */
240static int __ref rndis_do_config(struct usb_configuration *c) 240static int __init rndis_do_config(struct usb_configuration *c)
241{ 241{
242 /* FIXME alloc iConfiguration string, set it in c->strings */ 242 /* FIXME alloc iConfiguration string, set it in c->strings */
243 243
@@ -251,7 +251,6 @@ static int __ref rndis_do_config(struct usb_configuration *c)
251 251
252static struct usb_configuration rndis_config_driver = { 252static struct usb_configuration rndis_config_driver = {
253 .label = "RNDIS", 253 .label = "RNDIS",
254 .bind = rndis_do_config,
255 .bConfigurationValue = 2, 254 .bConfigurationValue = 2,
256 /* .iConfiguration = DYNAMIC */ 255 /* .iConfiguration = DYNAMIC */
257 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 256 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -270,7 +269,7 @@ MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
270/* 269/*
271 * We _always_ have an ECM, CDC Subset, or EEM configuration. 270 * We _always_ have an ECM, CDC Subset, or EEM configuration.
272 */ 271 */
273static int __ref eth_do_config(struct usb_configuration *c) 272static int __init eth_do_config(struct usb_configuration *c)
274{ 273{
275 /* FIXME alloc iConfiguration string, set it in c->strings */ 274 /* FIXME alloc iConfiguration string, set it in c->strings */
276 275
@@ -289,7 +288,6 @@ static int __ref eth_do_config(struct usb_configuration *c)
289 288
290static struct usb_configuration eth_config_driver = { 289static struct usb_configuration eth_config_driver = {
291 /* .label = f(hardware) */ 290 /* .label = f(hardware) */
292 .bind = eth_do_config,
293 .bConfigurationValue = 1, 291 .bConfigurationValue = 1,
294 /* .iConfiguration = DYNAMIC */ 292 /* .iConfiguration = DYNAMIC */
295 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 293 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -297,7 +295,7 @@ static struct usb_configuration eth_config_driver = {
297 295
298/*-------------------------------------------------------------------------*/ 296/*-------------------------------------------------------------------------*/
299 297
300static int __ref eth_bind(struct usb_composite_dev *cdev) 298static int __init eth_bind(struct usb_composite_dev *cdev)
301{ 299{
302 int gcnum; 300 int gcnum;
303 struct usb_gadget *gadget = cdev->gadget; 301 struct usb_gadget *gadget = cdev->gadget;
@@ -373,12 +371,13 @@ static int __ref eth_bind(struct usb_composite_dev *cdev)
373 371
374 /* register our configuration(s); RNDIS first, if it's used */ 372 /* register our configuration(s); RNDIS first, if it's used */
375 if (has_rndis()) { 373 if (has_rndis()) {
376 status = usb_add_config(cdev, &rndis_config_driver); 374 status = usb_add_config(cdev, &rndis_config_driver,
375 rndis_do_config);
377 if (status < 0) 376 if (status < 0)
378 goto fail; 377 goto fail;
379 } 378 }
380 379
381 status = usb_add_config(cdev, &eth_config_driver); 380 status = usb_add_config(cdev, &eth_config_driver, eth_do_config);
382 if (status < 0) 381 if (status < 0)
383 goto fail; 382 goto fail;
384 383
@@ -402,7 +401,6 @@ static struct usb_composite_driver eth_driver = {
402 .name = "g_ether", 401 .name = "g_ether",
403 .dev = &device_desc, 402 .dev = &device_desc,
404 .strings = dev_strings, 403 .strings = dev_strings,
405 .bind = eth_bind,
406 .unbind = __exit_p(eth_unbind), 404 .unbind = __exit_p(eth_unbind),
407}; 405};
408 406
@@ -412,7 +410,7 @@ MODULE_LICENSE("GPL");
412 410
413static int __init init(void) 411static int __init init(void)
414{ 412{
415 return usb_composite_register(&eth_driver); 413 return usb_composite_probe(&eth_driver, eth_bind);
416} 414}
417module_init(init); 415module_init(init);
418 416
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index d47a123f15ab..bd6226cbae86 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -111,7 +111,7 @@ acm_iad_descriptor = {
111 .bInterfaceCount = 2, // control + data 111 .bInterfaceCount = 2, // control + data
112 .bFunctionClass = USB_CLASS_COMM, 112 .bFunctionClass = USB_CLASS_COMM,
113 .bFunctionSubClass = USB_CDC_SUBCLASS_ACM, 113 .bFunctionSubClass = USB_CDC_SUBCLASS_ACM,
114 .bFunctionProtocol = USB_CDC_PROTO_NONE, 114 .bFunctionProtocol = USB_CDC_ACM_PROTO_AT_V25TER,
115 /* .iFunction = DYNAMIC */ 115 /* .iFunction = DYNAMIC */
116}; 116};
117 117
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index 43225879c3cd..b37960f9e753 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -324,7 +324,7 @@ static void loopback_disable(struct usb_function *f)
324 324
325/*-------------------------------------------------------------------------*/ 325/*-------------------------------------------------------------------------*/
326 326
327static int __ref loopback_bind_config(struct usb_configuration *c) 327static int __init loopback_bind_config(struct usb_configuration *c)
328{ 328{
329 struct f_loopback *loop; 329 struct f_loopback *loop;
330 int status; 330 int status;
@@ -346,10 +346,9 @@ static int __ref loopback_bind_config(struct usb_configuration *c)
346 return status; 346 return status;
347} 347}
348 348
349static struct usb_configuration loopback_driver = { 349static struct usb_configuration loopback_driver = {
350 .label = "loopback", 350 .label = "loopback",
351 .strings = loopback_strings, 351 .strings = loopback_strings,
352 .bind = loopback_bind_config,
353 .bConfigurationValue = 2, 352 .bConfigurationValue = 2,
354 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 353 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
355 /* .iConfiguration = DYNAMIC */ 354 /* .iConfiguration = DYNAMIC */
@@ -382,5 +381,5 @@ int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume)
382 loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 381 loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
383 } 382 }
384 383
385 return usb_add_config(cdev, &loopback_driver); 384 return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
386} 385}
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 32cce029f65c..838286b1cd14 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -73,6 +73,8 @@
73 * being removable. 73 * being removable.
74 * ->cdrom Flag specifying that LUN shall be reported as 74 * ->cdrom Flag specifying that LUN shall be reported as
75 * being a CD-ROM. 75 * being a CD-ROM.
76 * ->nofua Flag specifying that FUA flag in SCSI WRITE(10,12)
77 * commands for this LUN shall be ignored.
76 * 78 *
77 * lun_name_format A printf-like format for names of the LUN 79 * lun_name_format A printf-like format for names of the LUN
78 * devices. This determines how the 80 * devices. This determines how the
@@ -127,6 +129,8 @@
127 * Default true, boolean for removable media. 129 * Default true, boolean for removable media.
128 * cdrom=b[,b...] Default false, boolean for whether to emulate 130 * cdrom=b[,b...] Default false, boolean for whether to emulate
129 * a CD-ROM drive. 131 * a CD-ROM drive.
132 * nofua=b[,b...] Default false, booleans for ignore FUA flag
133 * in SCSI WRITE(10,12) commands
130 * luns=N Default N = number of filenames, number of 134 * luns=N Default N = number of filenames, number of
131 * LUNs to support. 135 * LUNs to support.
132 * stall Default determined according to the type of 136 * stall Default determined according to the type of
@@ -409,6 +413,7 @@ struct fsg_config {
409 char ro; 413 char ro;
410 char removable; 414 char removable;
411 char cdrom; 415 char cdrom;
416 char nofua;
412 } luns[FSG_MAX_LUNS]; 417 } luns[FSG_MAX_LUNS];
413 418
414 const char *lun_name_format; 419 const char *lun_name_format;
@@ -736,7 +741,7 @@ static int do_read(struct fsg_common *common)
736 741
737 /* Get the starting Logical Block Address and check that it's 742 /* Get the starting Logical Block Address and check that it's
738 * not too big */ 743 * not too big */
739 if (common->cmnd[0] == SC_READ_6) 744 if (common->cmnd[0] == READ_6)
740 lba = get_unaligned_be24(&common->cmnd[1]); 745 lba = get_unaligned_be24(&common->cmnd[1]);
741 else { 746 else {
742 lba = get_unaligned_be32(&common->cmnd[2]); 747 lba = get_unaligned_be32(&common->cmnd[2]);
@@ -874,7 +879,7 @@ static int do_write(struct fsg_common *common)
874 879
875 /* Get the starting Logical Block Address and check that it's 880 /* Get the starting Logical Block Address and check that it's
876 * not too big */ 881 * not too big */
877 if (common->cmnd[0] == SC_WRITE_6) 882 if (common->cmnd[0] == WRITE_6)
878 lba = get_unaligned_be24(&common->cmnd[1]); 883 lba = get_unaligned_be24(&common->cmnd[1]);
879 else { 884 else {
880 lba = get_unaligned_be32(&common->cmnd[2]); 885 lba = get_unaligned_be32(&common->cmnd[2]);
@@ -887,7 +892,7 @@ static int do_write(struct fsg_common *common)
887 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; 892 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
888 return -EINVAL; 893 return -EINVAL;
889 } 894 }
890 if (common->cmnd[1] & 0x08) { /* FUA */ 895 if (!curlun->nofua && (common->cmnd[1] & 0x08)) { /* FUA */
891 spin_lock(&curlun->filp->f_lock); 896 spin_lock(&curlun->filp->f_lock);
892 curlun->filp->f_flags |= O_SYNC; 897 curlun->filp->f_flags |= O_SYNC;
893 spin_unlock(&curlun->filp->f_lock); 898 spin_unlock(&curlun->filp->f_lock);
@@ -1181,7 +1186,7 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh)
1181 return 36; 1186 return 36;
1182 } 1187 }
1183 1188
1184 buf[0] = curlun->cdrom ? TYPE_CDROM : TYPE_DISK; 1189 buf[0] = curlun->cdrom ? TYPE_ROM : TYPE_DISK;
1185 buf[1] = curlun->removable ? 0x80 : 0; 1190 buf[1] = curlun->removable ? 0x80 : 0;
1186 buf[2] = 2; /* ANSI SCSI level 2 */ 1191 buf[2] = 2; /* ANSI SCSI level 2 */
1187 buf[3] = 2; /* SCSI-2 INQUIRY data format */ 1192 buf[3] = 2; /* SCSI-2 INQUIRY data format */
@@ -1348,11 +1353,11 @@ static int do_mode_sense(struct fsg_common *common, struct fsg_buffhd *bh)
1348 * The only variable value is the WriteProtect bit. We will fill in 1353 * The only variable value is the WriteProtect bit. We will fill in
1349 * the mode data length later. */ 1354 * the mode data length later. */
1350 memset(buf, 0, 8); 1355 memset(buf, 0, 8);
1351 if (mscmnd == SC_MODE_SENSE_6) { 1356 if (mscmnd == MODE_SENSE) {
1352 buf[2] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */ 1357 buf[2] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */
1353 buf += 4; 1358 buf += 4;
1354 limit = 255; 1359 limit = 255;
1355 } else { /* SC_MODE_SENSE_10 */ 1360 } else { /* MODE_SENSE_10 */
1356 buf[3] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */ 1361 buf[3] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */
1357 buf += 8; 1362 buf += 8;
1358 limit = 65535; /* Should really be FSG_BUFLEN */ 1363 limit = 65535; /* Should really be FSG_BUFLEN */
@@ -1392,7 +1397,7 @@ static int do_mode_sense(struct fsg_common *common, struct fsg_buffhd *bh)
1392 } 1397 }
1393 1398
1394 /* Store the mode data length */ 1399 /* Store the mode data length */
1395 if (mscmnd == SC_MODE_SENSE_6) 1400 if (mscmnd == MODE_SENSE)
1396 buf0[0] = len - 1; 1401 buf0[0] = len - 1;
1397 else 1402 else
1398 put_unaligned_be16(len - 2, buf0); 1403 put_unaligned_be16(len - 2, buf0);
@@ -1881,7 +1886,7 @@ static int check_command(struct fsg_common *common, int cmnd_size,
1881 if (common->lun >= 0 && common->lun < common->nluns) { 1886 if (common->lun >= 0 && common->lun < common->nluns) {
1882 curlun = &common->luns[common->lun]; 1887 curlun = &common->luns[common->lun];
1883 common->curlun = curlun; 1888 common->curlun = curlun;
1884 if (common->cmnd[0] != SC_REQUEST_SENSE) { 1889 if (common->cmnd[0] != REQUEST_SENSE) {
1885 curlun->sense_data = SS_NO_SENSE; 1890 curlun->sense_data = SS_NO_SENSE;
1886 curlun->sense_data_info = 0; 1891 curlun->sense_data_info = 0;
1887 curlun->info_valid = 0; 1892 curlun->info_valid = 0;
@@ -1893,8 +1898,8 @@ static int check_command(struct fsg_common *common, int cmnd_size,
1893 1898
1894 /* INQUIRY and REQUEST SENSE commands are explicitly allowed 1899 /* INQUIRY and REQUEST SENSE commands are explicitly allowed
1895 * to use unsupported LUNs; all others may not. */ 1900 * to use unsupported LUNs; all others may not. */
1896 if (common->cmnd[0] != SC_INQUIRY && 1901 if (common->cmnd[0] != INQUIRY &&
1897 common->cmnd[0] != SC_REQUEST_SENSE) { 1902 common->cmnd[0] != REQUEST_SENSE) {
1898 DBG(common, "unsupported LUN %d\n", common->lun); 1903 DBG(common, "unsupported LUN %d\n", common->lun);
1899 return -EINVAL; 1904 return -EINVAL;
1900 } 1905 }
@@ -1903,8 +1908,8 @@ static int check_command(struct fsg_common *common, int cmnd_size,
1903 /* If a unit attention condition exists, only INQUIRY and 1908 /* If a unit attention condition exists, only INQUIRY and
1904 * REQUEST SENSE commands are allowed; anything else must fail. */ 1909 * REQUEST SENSE commands are allowed; anything else must fail. */
1905 if (curlun && curlun->unit_attention_data != SS_NO_SENSE && 1910 if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
1906 common->cmnd[0] != SC_INQUIRY && 1911 common->cmnd[0] != INQUIRY &&
1907 common->cmnd[0] != SC_REQUEST_SENSE) { 1912 common->cmnd[0] != REQUEST_SENSE) {
1908 curlun->sense_data = curlun->unit_attention_data; 1913 curlun->sense_data = curlun->unit_attention_data;
1909 curlun->unit_attention_data = SS_NO_SENSE; 1914 curlun->unit_attention_data = SS_NO_SENSE;
1910 return -EINVAL; 1915 return -EINVAL;
@@ -1955,7 +1960,7 @@ static int do_scsi_command(struct fsg_common *common)
1955 down_read(&common->filesem); /* We're using the backing file */ 1960 down_read(&common->filesem); /* We're using the backing file */
1956 switch (common->cmnd[0]) { 1961 switch (common->cmnd[0]) {
1957 1962
1958 case SC_INQUIRY: 1963 case INQUIRY:
1959 common->data_size_from_cmnd = common->cmnd[4]; 1964 common->data_size_from_cmnd = common->cmnd[4];
1960 reply = check_command(common, 6, DATA_DIR_TO_HOST, 1965 reply = check_command(common, 6, DATA_DIR_TO_HOST,
1961 (1<<4), 0, 1966 (1<<4), 0,
@@ -1964,7 +1969,7 @@ static int do_scsi_command(struct fsg_common *common)
1964 reply = do_inquiry(common, bh); 1969 reply = do_inquiry(common, bh);
1965 break; 1970 break;
1966 1971
1967 case SC_MODE_SELECT_6: 1972 case MODE_SELECT:
1968 common->data_size_from_cmnd = common->cmnd[4]; 1973 common->data_size_from_cmnd = common->cmnd[4];
1969 reply = check_command(common, 6, DATA_DIR_FROM_HOST, 1974 reply = check_command(common, 6, DATA_DIR_FROM_HOST,
1970 (1<<1) | (1<<4), 0, 1975 (1<<1) | (1<<4), 0,
@@ -1973,7 +1978,7 @@ static int do_scsi_command(struct fsg_common *common)
1973 reply = do_mode_select(common, bh); 1978 reply = do_mode_select(common, bh);
1974 break; 1979 break;
1975 1980
1976 case SC_MODE_SELECT_10: 1981 case MODE_SELECT_10:
1977 common->data_size_from_cmnd = 1982 common->data_size_from_cmnd =
1978 get_unaligned_be16(&common->cmnd[7]); 1983 get_unaligned_be16(&common->cmnd[7]);
1979 reply = check_command(common, 10, DATA_DIR_FROM_HOST, 1984 reply = check_command(common, 10, DATA_DIR_FROM_HOST,
@@ -1983,7 +1988,7 @@ static int do_scsi_command(struct fsg_common *common)
1983 reply = do_mode_select(common, bh); 1988 reply = do_mode_select(common, bh);
1984 break; 1989 break;
1985 1990
1986 case SC_MODE_SENSE_6: 1991 case MODE_SENSE:
1987 common->data_size_from_cmnd = common->cmnd[4]; 1992 common->data_size_from_cmnd = common->cmnd[4];
1988 reply = check_command(common, 6, DATA_DIR_TO_HOST, 1993 reply = check_command(common, 6, DATA_DIR_TO_HOST,
1989 (1<<1) | (1<<2) | (1<<4), 0, 1994 (1<<1) | (1<<2) | (1<<4), 0,
@@ -1992,7 +1997,7 @@ static int do_scsi_command(struct fsg_common *common)
1992 reply = do_mode_sense(common, bh); 1997 reply = do_mode_sense(common, bh);
1993 break; 1998 break;
1994 1999
1995 case SC_MODE_SENSE_10: 2000 case MODE_SENSE_10:
1996 common->data_size_from_cmnd = 2001 common->data_size_from_cmnd =
1997 get_unaligned_be16(&common->cmnd[7]); 2002 get_unaligned_be16(&common->cmnd[7]);
1998 reply = check_command(common, 10, DATA_DIR_TO_HOST, 2003 reply = check_command(common, 10, DATA_DIR_TO_HOST,
@@ -2002,7 +2007,7 @@ static int do_scsi_command(struct fsg_common *common)
2002 reply = do_mode_sense(common, bh); 2007 reply = do_mode_sense(common, bh);
2003 break; 2008 break;
2004 2009
2005 case SC_PREVENT_ALLOW_MEDIUM_REMOVAL: 2010 case ALLOW_MEDIUM_REMOVAL:
2006 common->data_size_from_cmnd = 0; 2011 common->data_size_from_cmnd = 0;
2007 reply = check_command(common, 6, DATA_DIR_NONE, 2012 reply = check_command(common, 6, DATA_DIR_NONE,
2008 (1<<4), 0, 2013 (1<<4), 0,
@@ -2011,7 +2016,7 @@ static int do_scsi_command(struct fsg_common *common)
2011 reply = do_prevent_allow(common); 2016 reply = do_prevent_allow(common);
2012 break; 2017 break;
2013 2018
2014 case SC_READ_6: 2019 case READ_6:
2015 i = common->cmnd[4]; 2020 i = common->cmnd[4];
2016 common->data_size_from_cmnd = (i == 0 ? 256 : i) << 9; 2021 common->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
2017 reply = check_command(common, 6, DATA_DIR_TO_HOST, 2022 reply = check_command(common, 6, DATA_DIR_TO_HOST,
@@ -2021,7 +2026,7 @@ static int do_scsi_command(struct fsg_common *common)
2021 reply = do_read(common); 2026 reply = do_read(common);
2022 break; 2027 break;
2023 2028
2024 case SC_READ_10: 2029 case READ_10:
2025 common->data_size_from_cmnd = 2030 common->data_size_from_cmnd =
2026 get_unaligned_be16(&common->cmnd[7]) << 9; 2031 get_unaligned_be16(&common->cmnd[7]) << 9;
2027 reply = check_command(common, 10, DATA_DIR_TO_HOST, 2032 reply = check_command(common, 10, DATA_DIR_TO_HOST,
@@ -2031,7 +2036,7 @@ static int do_scsi_command(struct fsg_common *common)
2031 reply = do_read(common); 2036 reply = do_read(common);
2032 break; 2037 break;
2033 2038
2034 case SC_READ_12: 2039 case READ_12:
2035 common->data_size_from_cmnd = 2040 common->data_size_from_cmnd =
2036 get_unaligned_be32(&common->cmnd[6]) << 9; 2041 get_unaligned_be32(&common->cmnd[6]) << 9;
2037 reply = check_command(common, 12, DATA_DIR_TO_HOST, 2042 reply = check_command(common, 12, DATA_DIR_TO_HOST,
@@ -2041,7 +2046,7 @@ static int do_scsi_command(struct fsg_common *common)
2041 reply = do_read(common); 2046 reply = do_read(common);
2042 break; 2047 break;
2043 2048
2044 case SC_READ_CAPACITY: 2049 case READ_CAPACITY:
2045 common->data_size_from_cmnd = 8; 2050 common->data_size_from_cmnd = 8;
2046 reply = check_command(common, 10, DATA_DIR_TO_HOST, 2051 reply = check_command(common, 10, DATA_DIR_TO_HOST,
2047 (0xf<<2) | (1<<8), 1, 2052 (0xf<<2) | (1<<8), 1,
@@ -2050,7 +2055,7 @@ static int do_scsi_command(struct fsg_common *common)
2050 reply = do_read_capacity(common, bh); 2055 reply = do_read_capacity(common, bh);
2051 break; 2056 break;
2052 2057
2053 case SC_READ_HEADER: 2058 case READ_HEADER:
2054 if (!common->curlun || !common->curlun->cdrom) 2059 if (!common->curlun || !common->curlun->cdrom)
2055 goto unknown_cmnd; 2060 goto unknown_cmnd;
2056 common->data_size_from_cmnd = 2061 common->data_size_from_cmnd =
@@ -2062,7 +2067,7 @@ static int do_scsi_command(struct fsg_common *common)
2062 reply = do_read_header(common, bh); 2067 reply = do_read_header(common, bh);
2063 break; 2068 break;
2064 2069
2065 case SC_READ_TOC: 2070 case READ_TOC:
2066 if (!common->curlun || !common->curlun->cdrom) 2071 if (!common->curlun || !common->curlun->cdrom)
2067 goto unknown_cmnd; 2072 goto unknown_cmnd;
2068 common->data_size_from_cmnd = 2073 common->data_size_from_cmnd =
@@ -2074,7 +2079,7 @@ static int do_scsi_command(struct fsg_common *common)
2074 reply = do_read_toc(common, bh); 2079 reply = do_read_toc(common, bh);
2075 break; 2080 break;
2076 2081
2077 case SC_READ_FORMAT_CAPACITIES: 2082 case READ_FORMAT_CAPACITIES:
2078 common->data_size_from_cmnd = 2083 common->data_size_from_cmnd =
2079 get_unaligned_be16(&common->cmnd[7]); 2084 get_unaligned_be16(&common->cmnd[7]);
2080 reply = check_command(common, 10, DATA_DIR_TO_HOST, 2085 reply = check_command(common, 10, DATA_DIR_TO_HOST,
@@ -2084,7 +2089,7 @@ static int do_scsi_command(struct fsg_common *common)
2084 reply = do_read_format_capacities(common, bh); 2089 reply = do_read_format_capacities(common, bh);
2085 break; 2090 break;
2086 2091
2087 case SC_REQUEST_SENSE: 2092 case REQUEST_SENSE:
2088 common->data_size_from_cmnd = common->cmnd[4]; 2093 common->data_size_from_cmnd = common->cmnd[4];
2089 reply = check_command(common, 6, DATA_DIR_TO_HOST, 2094 reply = check_command(common, 6, DATA_DIR_TO_HOST,
2090 (1<<4), 0, 2095 (1<<4), 0,
@@ -2093,7 +2098,7 @@ static int do_scsi_command(struct fsg_common *common)
2093 reply = do_request_sense(common, bh); 2098 reply = do_request_sense(common, bh);
2094 break; 2099 break;
2095 2100
2096 case SC_START_STOP_UNIT: 2101 case START_STOP:
2097 common->data_size_from_cmnd = 0; 2102 common->data_size_from_cmnd = 0;
2098 reply = check_command(common, 6, DATA_DIR_NONE, 2103 reply = check_command(common, 6, DATA_DIR_NONE,
2099 (1<<1) | (1<<4), 0, 2104 (1<<1) | (1<<4), 0,
@@ -2102,7 +2107,7 @@ static int do_scsi_command(struct fsg_common *common)
2102 reply = do_start_stop(common); 2107 reply = do_start_stop(common);
2103 break; 2108 break;
2104 2109
2105 case SC_SYNCHRONIZE_CACHE: 2110 case SYNCHRONIZE_CACHE:
2106 common->data_size_from_cmnd = 0; 2111 common->data_size_from_cmnd = 0;
2107 reply = check_command(common, 10, DATA_DIR_NONE, 2112 reply = check_command(common, 10, DATA_DIR_NONE,
2108 (0xf<<2) | (3<<7), 1, 2113 (0xf<<2) | (3<<7), 1,
@@ -2111,7 +2116,7 @@ static int do_scsi_command(struct fsg_common *common)
2111 reply = do_synchronize_cache(common); 2116 reply = do_synchronize_cache(common);
2112 break; 2117 break;
2113 2118
2114 case SC_TEST_UNIT_READY: 2119 case TEST_UNIT_READY:
2115 common->data_size_from_cmnd = 0; 2120 common->data_size_from_cmnd = 0;
2116 reply = check_command(common, 6, DATA_DIR_NONE, 2121 reply = check_command(common, 6, DATA_DIR_NONE,
2117 0, 1, 2122 0, 1,
@@ -2120,7 +2125,7 @@ static int do_scsi_command(struct fsg_common *common)
2120 2125
2121 /* Although optional, this command is used by MS-Windows. We 2126 /* Although optional, this command is used by MS-Windows. We
2122 * support a minimal version: BytChk must be 0. */ 2127 * support a minimal version: BytChk must be 0. */
2123 case SC_VERIFY: 2128 case VERIFY:
2124 common->data_size_from_cmnd = 0; 2129 common->data_size_from_cmnd = 0;
2125 reply = check_command(common, 10, DATA_DIR_NONE, 2130 reply = check_command(common, 10, DATA_DIR_NONE,
2126 (1<<1) | (0xf<<2) | (3<<7), 1, 2131 (1<<1) | (0xf<<2) | (3<<7), 1,
@@ -2129,7 +2134,7 @@ static int do_scsi_command(struct fsg_common *common)
2129 reply = do_verify(common); 2134 reply = do_verify(common);
2130 break; 2135 break;
2131 2136
2132 case SC_WRITE_6: 2137 case WRITE_6:
2133 i = common->cmnd[4]; 2138 i = common->cmnd[4];
2134 common->data_size_from_cmnd = (i == 0 ? 256 : i) << 9; 2139 common->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
2135 reply = check_command(common, 6, DATA_DIR_FROM_HOST, 2140 reply = check_command(common, 6, DATA_DIR_FROM_HOST,
@@ -2139,7 +2144,7 @@ static int do_scsi_command(struct fsg_common *common)
2139 reply = do_write(common); 2144 reply = do_write(common);
2140 break; 2145 break;
2141 2146
2142 case SC_WRITE_10: 2147 case WRITE_10:
2143 common->data_size_from_cmnd = 2148 common->data_size_from_cmnd =
2144 get_unaligned_be16(&common->cmnd[7]) << 9; 2149 get_unaligned_be16(&common->cmnd[7]) << 9;
2145 reply = check_command(common, 10, DATA_DIR_FROM_HOST, 2150 reply = check_command(common, 10, DATA_DIR_FROM_HOST,
@@ -2149,7 +2154,7 @@ static int do_scsi_command(struct fsg_common *common)
2149 reply = do_write(common); 2154 reply = do_write(common);
2150 break; 2155 break;
2151 2156
2152 case SC_WRITE_12: 2157 case WRITE_12:
2153 common->data_size_from_cmnd = 2158 common->data_size_from_cmnd =
2154 get_unaligned_be32(&common->cmnd[6]) << 9; 2159 get_unaligned_be32(&common->cmnd[6]) << 9;
2155 reply = check_command(common, 12, DATA_DIR_FROM_HOST, 2160 reply = check_command(common, 12, DATA_DIR_FROM_HOST,
@@ -2163,10 +2168,10 @@ static int do_scsi_command(struct fsg_common *common)
2163 * They don't mean much in this setting. It's left as an exercise 2168 * They don't mean much in this setting. It's left as an exercise
2164 * for anyone interested to implement RESERVE and RELEASE in terms 2169 * for anyone interested to implement RESERVE and RELEASE in terms
2165 * of Posix locks. */ 2170 * of Posix locks. */
2166 case SC_FORMAT_UNIT: 2171 case FORMAT_UNIT:
2167 case SC_RELEASE: 2172 case RELEASE:
2168 case SC_RESERVE: 2173 case RESERVE:
2169 case SC_SEND_DIAGNOSTIC: 2174 case SEND_DIAGNOSTIC:
2170 /* Fall through */ 2175 /* Fall through */
2171 2176
2172 default: 2177 default:
@@ -2662,6 +2667,7 @@ static int fsg_main_thread(void *common_)
2662 2667
2663/* Write permission is checked per LUN in store_*() functions. */ 2668/* Write permission is checked per LUN in store_*() functions. */
2664static DEVICE_ATTR(ro, 0644, fsg_show_ro, fsg_store_ro); 2669static DEVICE_ATTR(ro, 0644, fsg_show_ro, fsg_store_ro);
2670static DEVICE_ATTR(nofua, 0644, fsg_show_nofua, fsg_store_nofua);
2665static DEVICE_ATTR(file, 0644, fsg_show_file, fsg_store_file); 2671static DEVICE_ATTR(file, 0644, fsg_show_file, fsg_store_file);
2666 2672
2667 2673
@@ -2768,6 +2774,9 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
2768 rc = device_create_file(&curlun->dev, &dev_attr_file); 2774 rc = device_create_file(&curlun->dev, &dev_attr_file);
2769 if (rc) 2775 if (rc)
2770 goto error_luns; 2776 goto error_luns;
2777 rc = device_create_file(&curlun->dev, &dev_attr_nofua);
2778 if (rc)
2779 goto error_luns;
2771 2780
2772 if (lcfg->filename) { 2781 if (lcfg->filename) {
2773 rc = fsg_lun_open(curlun, lcfg->filename); 2782 rc = fsg_lun_open(curlun, lcfg->filename);
@@ -2911,6 +2920,7 @@ static void fsg_common_release(struct kref *ref)
2911 2920
2912 /* In error recovery common->nluns may be zero. */ 2921 /* In error recovery common->nluns may be zero. */
2913 for (; i; --i, ++lun) { 2922 for (; i; --i, ++lun) {
2923 device_remove_file(&lun->dev, &dev_attr_nofua);
2914 device_remove_file(&lun->dev, &dev_attr_ro); 2924 device_remove_file(&lun->dev, &dev_attr_ro);
2915 device_remove_file(&lun->dev, &dev_attr_file); 2925 device_remove_file(&lun->dev, &dev_attr_file);
2916 fsg_lun_close(lun); 2926 fsg_lun_close(lun);
@@ -3069,8 +3079,10 @@ struct fsg_module_parameters {
3069 int ro[FSG_MAX_LUNS]; 3079 int ro[FSG_MAX_LUNS];
3070 int removable[FSG_MAX_LUNS]; 3080 int removable[FSG_MAX_LUNS];
3071 int cdrom[FSG_MAX_LUNS]; 3081 int cdrom[FSG_MAX_LUNS];
3082 int nofua[FSG_MAX_LUNS];
3072 3083
3073 unsigned int file_count, ro_count, removable_count, cdrom_count; 3084 unsigned int file_count, ro_count, removable_count, cdrom_count;
3085 unsigned int nofua_count;
3074 unsigned int luns; /* nluns */ 3086 unsigned int luns; /* nluns */
3075 int stall; /* can_stall */ 3087 int stall; /* can_stall */
3076}; 3088};
@@ -3096,6 +3108,8 @@ struct fsg_module_parameters {
3096 "true to simulate removable media"); \ 3108 "true to simulate removable media"); \
3097 _FSG_MODULE_PARAM_ARRAY(prefix, params, cdrom, bool, \ 3109 _FSG_MODULE_PARAM_ARRAY(prefix, params, cdrom, bool, \
3098 "true to simulate CD-ROM instead of disk"); \ 3110 "true to simulate CD-ROM instead of disk"); \
3111 _FSG_MODULE_PARAM_ARRAY(prefix, params, nofua, bool, \
3112 "true to ignore SCSI WRITE(10,12) FUA bit"); \
3099 _FSG_MODULE_PARAM(prefix, params, luns, uint, \ 3113 _FSG_MODULE_PARAM(prefix, params, luns, uint, \
3100 "number of LUNs"); \ 3114 "number of LUNs"); \
3101 _FSG_MODULE_PARAM(prefix, params, stall, bool, \ 3115 _FSG_MODULE_PARAM(prefix, params, stall, bool, \
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index 685d768f336e..e403a534dd55 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -404,7 +404,7 @@ static void sourcesink_disable(struct usb_function *f)
404 404
405/*-------------------------------------------------------------------------*/ 405/*-------------------------------------------------------------------------*/
406 406
407static int __ref sourcesink_bind_config(struct usb_configuration *c) 407static int __init sourcesink_bind_config(struct usb_configuration *c)
408{ 408{
409 struct f_sourcesink *ss; 409 struct f_sourcesink *ss;
410 int status; 410 int status;
@@ -498,7 +498,6 @@ unknown:
498static struct usb_configuration sourcesink_driver = { 498static struct usb_configuration sourcesink_driver = {
499 .label = "source/sink", 499 .label = "source/sink",
500 .strings = sourcesink_strings, 500 .strings = sourcesink_strings,
501 .bind = sourcesink_bind_config,
502 .setup = sourcesink_setup, 501 .setup = sourcesink_setup,
503 .bConfigurationValue = 3, 502 .bConfigurationValue = 3,
504 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 503 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -532,5 +531,5 @@ int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume)
532 sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 531 sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
533 } 532 }
534 533
535 return usb_add_config(cdev, &sourcesink_driver); 534 return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
536} 535}
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index a857b7ac238c..d4fdf65fb925 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -89,6 +89,7 @@
89 * Required if "removable" is not set, names of 89 * Required if "removable" is not set, names of
90 * the files or block devices used for 90 * the files or block devices used for
91 * backing storage 91 * backing storage
92 * serial=HHHH... Required serial number (string of hex chars)
92 * ro=b[,b...] Default false, booleans for read-only access 93 * ro=b[,b...] Default false, booleans for read-only access
93 * removable Default false, boolean for removable media 94 * removable Default false, boolean for removable media
94 * luns=N Default N = number of filenames, number of 95 * luns=N Default N = number of filenames, number of
@@ -108,12 +109,11 @@
108 * vendor=0xVVVV Default 0x0525 (NetChip), USB Vendor ID 109 * vendor=0xVVVV Default 0x0525 (NetChip), USB Vendor ID
109 * product=0xPPPP Default 0xa4a5 (FSG), USB Product ID 110 * product=0xPPPP Default 0xa4a5 (FSG), USB Product ID
110 * release=0xRRRR Override the USB release number (bcdDevice) 111 * release=0xRRRR Override the USB release number (bcdDevice)
111 * serial=HHHH... Override serial number (string of hex chars)
112 * buflen=N Default N=16384, buffer size used (will be 112 * buflen=N Default N=16384, buffer size used (will be
113 * rounded down to a multiple of 113 * rounded down to a multiple of
114 * PAGE_CACHE_SIZE) 114 * PAGE_CACHE_SIZE)
115 * 115 *
116 * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "ro", 116 * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "serial", "ro",
117 * "removable", "luns", "nofua", "stall", and "cdrom" options are available; 117 * "removable", "luns", "nofua", "stall", and "cdrom" options are available;
118 * default values are used for everything else. 118 * default values are used for everything else.
119 * 119 *
@@ -273,13 +273,10 @@
273 273
274#define DRIVER_DESC "File-backed Storage Gadget" 274#define DRIVER_DESC "File-backed Storage Gadget"
275#define DRIVER_NAME "g_file_storage" 275#define DRIVER_NAME "g_file_storage"
276/* DRIVER_VERSION must be at least 6 characters long, as it is used 276#define DRIVER_VERSION "1 September 2010"
277 * to generate a fallback serial number. */
278#define DRIVER_VERSION "20 November 2008"
279 277
280static char fsg_string_manufacturer[64]; 278static char fsg_string_manufacturer[64];
281static const char fsg_string_product[] = DRIVER_DESC; 279static const char fsg_string_product[] = DRIVER_DESC;
282static char fsg_string_serial[13];
283static const char fsg_string_config[] = "Self-powered"; 280static const char fsg_string_config[] = "Self-powered";
284static const char fsg_string_interface[] = "Mass Storage"; 281static const char fsg_string_interface[] = "Mass Storage";
285 282
@@ -305,6 +302,7 @@ MODULE_LICENSE("Dual BSD/GPL");
305 302
306static struct { 303static struct {
307 char *file[FSG_MAX_LUNS]; 304 char *file[FSG_MAX_LUNS];
305 char *serial;
308 int ro[FSG_MAX_LUNS]; 306 int ro[FSG_MAX_LUNS];
309 int nofua[FSG_MAX_LUNS]; 307 int nofua[FSG_MAX_LUNS];
310 unsigned int num_filenames; 308 unsigned int num_filenames;
@@ -321,7 +319,6 @@ static struct {
321 unsigned short vendor; 319 unsigned short vendor;
322 unsigned short product; 320 unsigned short product;
323 unsigned short release; 321 unsigned short release;
324 char *serial;
325 unsigned int buflen; 322 unsigned int buflen;
326 323
327 int transport_type; 324 int transport_type;
@@ -346,6 +343,9 @@ module_param_array_named(file, mod_data.file, charp, &mod_data.num_filenames,
346 S_IRUGO); 343 S_IRUGO);
347MODULE_PARM_DESC(file, "names of backing files or devices"); 344MODULE_PARM_DESC(file, "names of backing files or devices");
348 345
346module_param_named(serial, mod_data.serial, charp, S_IRUGO);
347MODULE_PARM_DESC(serial, "USB serial number");
348
349module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO); 349module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO);
350MODULE_PARM_DESC(ro, "true to force read-only"); 350MODULE_PARM_DESC(ro, "true to force read-only");
351 351
@@ -365,9 +365,6 @@ MODULE_PARM_DESC(stall, "false to prevent bulk stalls");
365module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO); 365module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
366MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk"); 366MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");
367 367
368module_param_named(serial, mod_data.serial, charp, S_IRUGO);
369MODULE_PARM_DESC(serial, "USB serial number");
370
371/* In the non-TEST version, only the module parameters listed above 368/* In the non-TEST version, only the module parameters listed above
372 * are available. */ 369 * are available. */
373#ifdef CONFIG_USB_FILE_STORAGE_TEST 370#ifdef CONFIG_USB_FILE_STORAGE_TEST
@@ -786,7 +783,7 @@ static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
786{ 783{
787 struct usb_request *req = fsg->ep0req; 784 struct usb_request *req = fsg->ep0req;
788 static u8 cbi_reset_cmnd[6] = { 785 static u8 cbi_reset_cmnd[6] = {
789 SC_SEND_DIAGNOSTIC, 4, 0xff, 0xff, 0xff, 0xff}; 786 SEND_DIAGNOSTIC, 4, 0xff, 0xff, 0xff, 0xff};
790 787
791 /* Error in command transfer? */ 788 /* Error in command transfer? */
792 if (req->status || req->length != req->actual || 789 if (req->status || req->length != req->actual ||
@@ -1138,7 +1135,7 @@ static int do_read(struct fsg_dev *fsg)
1138 1135
1139 /* Get the starting Logical Block Address and check that it's 1136 /* Get the starting Logical Block Address and check that it's
1140 * not too big */ 1137 * not too big */
1141 if (fsg->cmnd[0] == SC_READ_6) 1138 if (fsg->cmnd[0] == READ_6)
1142 lba = get_unaligned_be24(&fsg->cmnd[1]); 1139 lba = get_unaligned_be24(&fsg->cmnd[1]);
1143 else { 1140 else {
1144 lba = get_unaligned_be32(&fsg->cmnd[2]); 1141 lba = get_unaligned_be32(&fsg->cmnd[2]);
@@ -1273,7 +1270,7 @@ static int do_write(struct fsg_dev *fsg)
1273 1270
1274 /* Get the starting Logical Block Address and check that it's 1271 /* Get the starting Logical Block Address and check that it's
1275 * not too big */ 1272 * not too big */
1276 if (fsg->cmnd[0] == SC_WRITE_6) 1273 if (fsg->cmnd[0] == WRITE_6)
1277 lba = get_unaligned_be24(&fsg->cmnd[1]); 1274 lba = get_unaligned_be24(&fsg->cmnd[1]);
1278 else { 1275 else {
1279 lba = get_unaligned_be32(&fsg->cmnd[2]); 1276 lba = get_unaligned_be32(&fsg->cmnd[2]);
@@ -1581,7 +1578,7 @@ static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1581 } 1578 }
1582 1579
1583 memset(buf, 0, 8); 1580 memset(buf, 0, 8);
1584 buf[0] = (mod_data.cdrom ? TYPE_CDROM : TYPE_DISK); 1581 buf[0] = (mod_data.cdrom ? TYPE_ROM : TYPE_DISK);
1585 if (mod_data.removable) 1582 if (mod_data.removable)
1586 buf[1] = 0x80; 1583 buf[1] = 0x80;
1587 buf[2] = 2; // ANSI SCSI level 2 1584 buf[2] = 2; // ANSI SCSI level 2
@@ -1750,11 +1747,11 @@ static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1750 * The only variable value is the WriteProtect bit. We will fill in 1747 * The only variable value is the WriteProtect bit. We will fill in
1751 * the mode data length later. */ 1748 * the mode data length later. */
1752 memset(buf, 0, 8); 1749 memset(buf, 0, 8);
1753 if (mscmnd == SC_MODE_SENSE_6) { 1750 if (mscmnd == MODE_SENSE) {
1754 buf[2] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA 1751 buf[2] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
1755 buf += 4; 1752 buf += 4;
1756 limit = 255; 1753 limit = 255;
1757 } else { // SC_MODE_SENSE_10 1754 } else { // MODE_SENSE_10
1758 buf[3] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA 1755 buf[3] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
1759 buf += 8; 1756 buf += 8;
1760 limit = 65535; // Should really be mod_data.buflen 1757 limit = 65535; // Should really be mod_data.buflen
@@ -1794,7 +1791,7 @@ static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1794 } 1791 }
1795 1792
1796 /* Store the mode data length */ 1793 /* Store the mode data length */
1797 if (mscmnd == SC_MODE_SENSE_6) 1794 if (mscmnd == MODE_SENSE)
1798 buf0[0] = len - 1; 1795 buf0[0] = len - 1;
1799 else 1796 else
1800 put_unaligned_be16(len - 2, buf0); 1797 put_unaligned_be16(len - 2, buf0);
@@ -2319,7 +2316,7 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
2319 /* Check the LUN */ 2316 /* Check the LUN */
2320 if (fsg->lun >= 0 && fsg->lun < fsg->nluns) { 2317 if (fsg->lun >= 0 && fsg->lun < fsg->nluns) {
2321 fsg->curlun = curlun = &fsg->luns[fsg->lun]; 2318 fsg->curlun = curlun = &fsg->luns[fsg->lun];
2322 if (fsg->cmnd[0] != SC_REQUEST_SENSE) { 2319 if (fsg->cmnd[0] != REQUEST_SENSE) {
2323 curlun->sense_data = SS_NO_SENSE; 2320 curlun->sense_data = SS_NO_SENSE;
2324 curlun->sense_data_info = 0; 2321 curlun->sense_data_info = 0;
2325 curlun->info_valid = 0; 2322 curlun->info_valid = 0;
@@ -2330,8 +2327,8 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
2330 2327
2331 /* INQUIRY and REQUEST SENSE commands are explicitly allowed 2328 /* INQUIRY and REQUEST SENSE commands are explicitly allowed
2332 * to use unsupported LUNs; all others may not. */ 2329 * to use unsupported LUNs; all others may not. */
2333 if (fsg->cmnd[0] != SC_INQUIRY && 2330 if (fsg->cmnd[0] != INQUIRY &&
2334 fsg->cmnd[0] != SC_REQUEST_SENSE) { 2331 fsg->cmnd[0] != REQUEST_SENSE) {
2335 DBG(fsg, "unsupported LUN %d\n", fsg->lun); 2332 DBG(fsg, "unsupported LUN %d\n", fsg->lun);
2336 return -EINVAL; 2333 return -EINVAL;
2337 } 2334 }
@@ -2340,8 +2337,8 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
2340 /* If a unit attention condition exists, only INQUIRY and 2337 /* If a unit attention condition exists, only INQUIRY and
2341 * REQUEST SENSE commands are allowed; anything else must fail. */ 2338 * REQUEST SENSE commands are allowed; anything else must fail. */
2342 if (curlun && curlun->unit_attention_data != SS_NO_SENSE && 2339 if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
2343 fsg->cmnd[0] != SC_INQUIRY && 2340 fsg->cmnd[0] != INQUIRY &&
2344 fsg->cmnd[0] != SC_REQUEST_SENSE) { 2341 fsg->cmnd[0] != REQUEST_SENSE) {
2345 curlun->sense_data = curlun->unit_attention_data; 2342 curlun->sense_data = curlun->unit_attention_data;
2346 curlun->unit_attention_data = SS_NO_SENSE; 2343 curlun->unit_attention_data = SS_NO_SENSE;
2347 return -EINVAL; 2344 return -EINVAL;
@@ -2391,7 +2388,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2391 down_read(&fsg->filesem); // We're using the backing file 2388 down_read(&fsg->filesem); // We're using the backing file
2392 switch (fsg->cmnd[0]) { 2389 switch (fsg->cmnd[0]) {
2393 2390
2394 case SC_INQUIRY: 2391 case INQUIRY:
2395 fsg->data_size_from_cmnd = fsg->cmnd[4]; 2392 fsg->data_size_from_cmnd = fsg->cmnd[4];
2396 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, 2393 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
2397 (1<<4), 0, 2394 (1<<4), 0,
@@ -2399,7 +2396,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2399 reply = do_inquiry(fsg, bh); 2396 reply = do_inquiry(fsg, bh);
2400 break; 2397 break;
2401 2398
2402 case SC_MODE_SELECT_6: 2399 case MODE_SELECT:
2403 fsg->data_size_from_cmnd = fsg->cmnd[4]; 2400 fsg->data_size_from_cmnd = fsg->cmnd[4];
2404 if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST, 2401 if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST,
2405 (1<<1) | (1<<4), 0, 2402 (1<<1) | (1<<4), 0,
@@ -2407,7 +2404,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2407 reply = do_mode_select(fsg, bh); 2404 reply = do_mode_select(fsg, bh);
2408 break; 2405 break;
2409 2406
2410 case SC_MODE_SELECT_10: 2407 case MODE_SELECT_10:
2411 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); 2408 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2412 if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST, 2409 if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
2413 (1<<1) | (3<<7), 0, 2410 (1<<1) | (3<<7), 0,
@@ -2415,7 +2412,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2415 reply = do_mode_select(fsg, bh); 2412 reply = do_mode_select(fsg, bh);
2416 break; 2413 break;
2417 2414
2418 case SC_MODE_SENSE_6: 2415 case MODE_SENSE:
2419 fsg->data_size_from_cmnd = fsg->cmnd[4]; 2416 fsg->data_size_from_cmnd = fsg->cmnd[4];
2420 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, 2417 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
2421 (1<<1) | (1<<2) | (1<<4), 0, 2418 (1<<1) | (1<<2) | (1<<4), 0,
@@ -2423,7 +2420,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2423 reply = do_mode_sense(fsg, bh); 2420 reply = do_mode_sense(fsg, bh);
2424 break; 2421 break;
2425 2422
2426 case SC_MODE_SENSE_10: 2423 case MODE_SENSE_10:
2427 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); 2424 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2428 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, 2425 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2429 (1<<1) | (1<<2) | (3<<7), 0, 2426 (1<<1) | (1<<2) | (3<<7), 0,
@@ -2431,7 +2428,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2431 reply = do_mode_sense(fsg, bh); 2428 reply = do_mode_sense(fsg, bh);
2432 break; 2429 break;
2433 2430
2434 case SC_PREVENT_ALLOW_MEDIUM_REMOVAL: 2431 case ALLOW_MEDIUM_REMOVAL:
2435 fsg->data_size_from_cmnd = 0; 2432 fsg->data_size_from_cmnd = 0;
2436 if ((reply = check_command(fsg, 6, DATA_DIR_NONE, 2433 if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
2437 (1<<4), 0, 2434 (1<<4), 0,
@@ -2439,7 +2436,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2439 reply = do_prevent_allow(fsg); 2436 reply = do_prevent_allow(fsg);
2440 break; 2437 break;
2441 2438
2442 case SC_READ_6: 2439 case READ_6:
2443 i = fsg->cmnd[4]; 2440 i = fsg->cmnd[4];
2444 fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9; 2441 fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
2445 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, 2442 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
@@ -2448,7 +2445,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2448 reply = do_read(fsg); 2445 reply = do_read(fsg);
2449 break; 2446 break;
2450 2447
2451 case SC_READ_10: 2448 case READ_10:
2452 fsg->data_size_from_cmnd = 2449 fsg->data_size_from_cmnd =
2453 get_unaligned_be16(&fsg->cmnd[7]) << 9; 2450 get_unaligned_be16(&fsg->cmnd[7]) << 9;
2454 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, 2451 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
@@ -2457,7 +2454,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2457 reply = do_read(fsg); 2454 reply = do_read(fsg);
2458 break; 2455 break;
2459 2456
2460 case SC_READ_12: 2457 case READ_12:
2461 fsg->data_size_from_cmnd = 2458 fsg->data_size_from_cmnd =
2462 get_unaligned_be32(&fsg->cmnd[6]) << 9; 2459 get_unaligned_be32(&fsg->cmnd[6]) << 9;
2463 if ((reply = check_command(fsg, 12, DATA_DIR_TO_HOST, 2460 if ((reply = check_command(fsg, 12, DATA_DIR_TO_HOST,
@@ -2466,7 +2463,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2466 reply = do_read(fsg); 2463 reply = do_read(fsg);
2467 break; 2464 break;
2468 2465
2469 case SC_READ_CAPACITY: 2466 case READ_CAPACITY:
2470 fsg->data_size_from_cmnd = 8; 2467 fsg->data_size_from_cmnd = 8;
2471 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, 2468 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2472 (0xf<<2) | (1<<8), 1, 2469 (0xf<<2) | (1<<8), 1,
@@ -2474,7 +2471,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2474 reply = do_read_capacity(fsg, bh); 2471 reply = do_read_capacity(fsg, bh);
2475 break; 2472 break;
2476 2473
2477 case SC_READ_HEADER: 2474 case READ_HEADER:
2478 if (!mod_data.cdrom) 2475 if (!mod_data.cdrom)
2479 goto unknown_cmnd; 2476 goto unknown_cmnd;
2480 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); 2477 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
@@ -2484,7 +2481,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2484 reply = do_read_header(fsg, bh); 2481 reply = do_read_header(fsg, bh);
2485 break; 2482 break;
2486 2483
2487 case SC_READ_TOC: 2484 case READ_TOC:
2488 if (!mod_data.cdrom) 2485 if (!mod_data.cdrom)
2489 goto unknown_cmnd; 2486 goto unknown_cmnd;
2490 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); 2487 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
@@ -2494,7 +2491,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2494 reply = do_read_toc(fsg, bh); 2491 reply = do_read_toc(fsg, bh);
2495 break; 2492 break;
2496 2493
2497 case SC_READ_FORMAT_CAPACITIES: 2494 case READ_FORMAT_CAPACITIES:
2498 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); 2495 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2499 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, 2496 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2500 (3<<7), 1, 2497 (3<<7), 1,
@@ -2502,7 +2499,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2502 reply = do_read_format_capacities(fsg, bh); 2499 reply = do_read_format_capacities(fsg, bh);
2503 break; 2500 break;
2504 2501
2505 case SC_REQUEST_SENSE: 2502 case REQUEST_SENSE:
2506 fsg->data_size_from_cmnd = fsg->cmnd[4]; 2503 fsg->data_size_from_cmnd = fsg->cmnd[4];
2507 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, 2504 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
2508 (1<<4), 0, 2505 (1<<4), 0,
@@ -2510,7 +2507,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2510 reply = do_request_sense(fsg, bh); 2507 reply = do_request_sense(fsg, bh);
2511 break; 2508 break;
2512 2509
2513 case SC_START_STOP_UNIT: 2510 case START_STOP:
2514 fsg->data_size_from_cmnd = 0; 2511 fsg->data_size_from_cmnd = 0;
2515 if ((reply = check_command(fsg, 6, DATA_DIR_NONE, 2512 if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
2516 (1<<1) | (1<<4), 0, 2513 (1<<1) | (1<<4), 0,
@@ -2518,7 +2515,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2518 reply = do_start_stop(fsg); 2515 reply = do_start_stop(fsg);
2519 break; 2516 break;
2520 2517
2521 case SC_SYNCHRONIZE_CACHE: 2518 case SYNCHRONIZE_CACHE:
2522 fsg->data_size_from_cmnd = 0; 2519 fsg->data_size_from_cmnd = 0;
2523 if ((reply = check_command(fsg, 10, DATA_DIR_NONE, 2520 if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
2524 (0xf<<2) | (3<<7), 1, 2521 (0xf<<2) | (3<<7), 1,
@@ -2526,7 +2523,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2526 reply = do_synchronize_cache(fsg); 2523 reply = do_synchronize_cache(fsg);
2527 break; 2524 break;
2528 2525
2529 case SC_TEST_UNIT_READY: 2526 case TEST_UNIT_READY:
2530 fsg->data_size_from_cmnd = 0; 2527 fsg->data_size_from_cmnd = 0;
2531 reply = check_command(fsg, 6, DATA_DIR_NONE, 2528 reply = check_command(fsg, 6, DATA_DIR_NONE,
2532 0, 1, 2529 0, 1,
@@ -2535,7 +2532,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2535 2532
2536 /* Although optional, this command is used by MS-Windows. We 2533 /* Although optional, this command is used by MS-Windows. We
2537 * support a minimal version: BytChk must be 0. */ 2534 * support a minimal version: BytChk must be 0. */
2538 case SC_VERIFY: 2535 case VERIFY:
2539 fsg->data_size_from_cmnd = 0; 2536 fsg->data_size_from_cmnd = 0;
2540 if ((reply = check_command(fsg, 10, DATA_DIR_NONE, 2537 if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
2541 (1<<1) | (0xf<<2) | (3<<7), 1, 2538 (1<<1) | (0xf<<2) | (3<<7), 1,
@@ -2543,7 +2540,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2543 reply = do_verify(fsg); 2540 reply = do_verify(fsg);
2544 break; 2541 break;
2545 2542
2546 case SC_WRITE_6: 2543 case WRITE_6:
2547 i = fsg->cmnd[4]; 2544 i = fsg->cmnd[4];
2548 fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9; 2545 fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
2549 if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST, 2546 if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST,
@@ -2552,7 +2549,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2552 reply = do_write(fsg); 2549 reply = do_write(fsg);
2553 break; 2550 break;
2554 2551
2555 case SC_WRITE_10: 2552 case WRITE_10:
2556 fsg->data_size_from_cmnd = 2553 fsg->data_size_from_cmnd =
2557 get_unaligned_be16(&fsg->cmnd[7]) << 9; 2554 get_unaligned_be16(&fsg->cmnd[7]) << 9;
2558 if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST, 2555 if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
@@ -2561,7 +2558,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2561 reply = do_write(fsg); 2558 reply = do_write(fsg);
2562 break; 2559 break;
2563 2560
2564 case SC_WRITE_12: 2561 case WRITE_12:
2565 fsg->data_size_from_cmnd = 2562 fsg->data_size_from_cmnd =
2566 get_unaligned_be32(&fsg->cmnd[6]) << 9; 2563 get_unaligned_be32(&fsg->cmnd[6]) << 9;
2567 if ((reply = check_command(fsg, 12, DATA_DIR_FROM_HOST, 2564 if ((reply = check_command(fsg, 12, DATA_DIR_FROM_HOST,
@@ -2574,10 +2571,10 @@ static int do_scsi_command(struct fsg_dev *fsg)
2574 * They don't mean much in this setting. It's left as an exercise 2571 * They don't mean much in this setting. It's left as an exercise
2575 * for anyone interested to implement RESERVE and RELEASE in terms 2572 * for anyone interested to implement RESERVE and RELEASE in terms
2576 * of Posix locks. */ 2573 * of Posix locks. */
2577 case SC_FORMAT_UNIT: 2574 case FORMAT_UNIT:
2578 case SC_RELEASE: 2575 case RELEASE:
2579 case SC_RESERVE: 2576 case RESERVE:
2580 case SC_SEND_DIAGNOSTIC: 2577 case SEND_DIAGNOSTIC:
2581 // Fall through 2578 // Fall through
2582 2579
2583 default: 2580 default:
@@ -3178,6 +3175,7 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
3178 for (i = 0; i < fsg->nluns; ++i) { 3175 for (i = 0; i < fsg->nluns; ++i) {
3179 curlun = &fsg->luns[i]; 3176 curlun = &fsg->luns[i];
3180 if (curlun->registered) { 3177 if (curlun->registered) {
3178 device_remove_file(&curlun->dev, &dev_attr_nofua);
3181 device_remove_file(&curlun->dev, &dev_attr_ro); 3179 device_remove_file(&curlun->dev, &dev_attr_ro);
3182 device_remove_file(&curlun->dev, &dev_attr_file); 3180 device_remove_file(&curlun->dev, &dev_attr_file);
3183 fsg_lun_close(curlun); 3181 fsg_lun_close(curlun);
@@ -3213,7 +3211,6 @@ static int __init check_parameters(struct fsg_dev *fsg)
3213{ 3211{
3214 int prot; 3212 int prot;
3215 int gcnum; 3213 int gcnum;
3216 int i;
3217 3214
3218 /* Store the default values */ 3215 /* Store the default values */
3219 mod_data.transport_type = USB_PR_BULK; 3216 mod_data.transport_type = USB_PR_BULK;
@@ -3309,45 +3306,29 @@ static int __init check_parameters(struct fsg_dev *fsg)
3309 if ((*ch < '0' || *ch > '9') && 3306 if ((*ch < '0' || *ch > '9') &&
3310 (*ch < 'A' || *ch > 'F')) { /* not uppercase hex */ 3307 (*ch < 'A' || *ch > 'F')) { /* not uppercase hex */
3311 WARNING(fsg, 3308 WARNING(fsg,
3312 "Invalid serial string character: %c; " 3309 "Invalid serial string character: %c\n",
3313 "Failing back to default\n",
3314 *ch); 3310 *ch);
3315 goto fill_serial; 3311 goto no_serial;
3316 } 3312 }
3317 } 3313 }
3318 if (len > 126 || 3314 if (len > 126 ||
3319 (mod_data.transport_type == USB_PR_BULK && len < 12) || 3315 (mod_data.transport_type == USB_PR_BULK && len < 12) ||
3320 (mod_data.transport_type != USB_PR_BULK && len > 12)) { 3316 (mod_data.transport_type != USB_PR_BULK && len > 12)) {
3321 WARNING(fsg, 3317 WARNING(fsg, "Invalid serial string length!\n");
3322 "Invalid serial string length; " 3318 goto no_serial;
3323 "Failing back to default\n");
3324 goto fill_serial;
3325 } 3319 }
3326 fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial; 3320 fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial;
3327 } else { 3321 } else {
3328 WARNING(fsg, 3322 WARNING(fsg, "No serial-number string provided!\n");
3329 "Userspace failed to provide serial number; " 3323 no_serial:
3330 "Failing back to default\n"); 3324 device_desc.iSerialNumber = 0;
3331fill_serial:
3332 /* Serial number not specified or invalid, make our own.
3333 * We just encode it from the driver version string,
3334 * 12 characters to comply with both CB[I] and BBB spec.
3335 * Warning : Two devices running the same kernel will have
3336 * the same fallback serial number. */
3337 for (i = 0; i < 12; i += 2) {
3338 unsigned char c = DRIVER_VERSION[i / 2];
3339
3340 if (!c)
3341 break;
3342 sprintf(&fsg_string_serial[i], "%02X", c);
3343 }
3344 } 3325 }
3345 3326
3346 return 0; 3327 return 0;
3347} 3328}
3348 3329
3349 3330
3350static int __ref fsg_bind(struct usb_gadget *gadget) 3331static int __init fsg_bind(struct usb_gadget *gadget)
3351{ 3332{
3352 struct fsg_dev *fsg = the_fsg; 3333 struct fsg_dev *fsg = the_fsg;
3353 int rc; 3334 int rc;
@@ -3607,7 +3588,6 @@ static struct usb_gadget_driver fsg_driver = {
3607 .speed = USB_SPEED_FULL, 3588 .speed = USB_SPEED_FULL,
3608#endif 3589#endif
3609 .function = (char *) fsg_string_product, 3590 .function = (char *) fsg_string_product,
3610 .bind = fsg_bind,
3611 .unbind = fsg_unbind, 3591 .unbind = fsg_unbind,
3612 .disconnect = fsg_disconnect, 3592 .disconnect = fsg_disconnect,
3613 .setup = fsg_setup, 3593 .setup = fsg_setup,
@@ -3649,7 +3629,7 @@ static int __init fsg_init(void)
3649 if ((rc = fsg_alloc()) != 0) 3629 if ((rc = fsg_alloc()) != 0)
3650 return rc; 3630 return rc;
3651 fsg = the_fsg; 3631 fsg = the_fsg;
3652 if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0) 3632 if ((rc = usb_gadget_probe_driver(&fsg_driver, fsg_bind)) != 0)
3653 kref_put(&fsg->ref, fsg_release); 3633 kref_put(&fsg->ref, fsg_release);
3654 return rc; 3634 return rc;
3655} 3635}
diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
index eafa6d2c5ed7..5bdbfe619853 100644
--- a/drivers/usb/gadget/fsl_mxc_udc.c
+++ b/drivers/usb/gadget/fsl_mxc_udc.c
@@ -22,6 +22,10 @@
22static struct clk *mxc_ahb_clk; 22static struct clk *mxc_ahb_clk;
23static struct clk *mxc_usb_clk; 23static struct clk *mxc_usb_clk;
24 24
25/* workaround ENGcm09152 for i.MX35 */
26#define USBPHYCTRL_OTGBASE_OFFSET 0x608
27#define USBPHYCTRL_EVDO (1 << 23)
28
25int fsl_udc_clk_init(struct platform_device *pdev) 29int fsl_udc_clk_init(struct platform_device *pdev)
26{ 30{
27 struct fsl_usb2_platform_data *pdata; 31 struct fsl_usb2_platform_data *pdata;
@@ -84,6 +88,17 @@ eenahb:
84void fsl_udc_clk_finalize(struct platform_device *pdev) 88void fsl_udc_clk_finalize(struct platform_device *pdev)
85{ 89{
86 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; 90 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
91#if defined(CONFIG_ARCH_MX35)
92 unsigned int v;
93
94 /* workaround ENGcm09152 for i.MX35 */
95 if (pdata->workaround & FLS_USB2_WORKAROUND_ENGCM09152) {
96 v = readl(MX35_IO_ADDRESS(MX35_OTG_BASE_ADDR +
97 USBPHYCTRL_OTGBASE_OFFSET));
98 writel(v | USBPHYCTRL_EVDO, MX35_IO_ADDRESS(MX35_OTG_BASE_ADDR +
99 USBPHYCTRL_OTGBASE_OFFSET));
100 }
101#endif
87 102
88 /* ULPI transceivers don't need usbpll */ 103 /* ULPI transceivers don't need usbpll */
89 if (pdata->phy_mode == FSL_USB2_PHY_ULPI) { 104 if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index a5ea2c1d8c93..792d5ef40137 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2302,9 +2302,10 @@ static irqreturn_t qe_udc_irq(int irq, void *_udc)
2302} 2302}
2303 2303
2304/*------------------------------------------------------------------------- 2304/*-------------------------------------------------------------------------
2305 Gadget driver register and unregister. 2305 Gadget driver probe and unregister.
2306 --------------------------------------------------------------------------*/ 2306 --------------------------------------------------------------------------*/
2307int usb_gadget_register_driver(struct usb_gadget_driver *driver) 2307int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2308 int (*bind)(struct usb_gadget *))
2308{ 2309{
2309 int retval; 2310 int retval;
2310 unsigned long flags = 0; 2311 unsigned long flags = 0;
@@ -2315,8 +2316,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2315 2316
2316 if (!driver || (driver->speed != USB_SPEED_FULL 2317 if (!driver || (driver->speed != USB_SPEED_FULL
2317 && driver->speed != USB_SPEED_HIGH) 2318 && driver->speed != USB_SPEED_HIGH)
2318 || !driver->bind || !driver->disconnect 2319 || !bind || !driver->disconnect || !driver->setup)
2319 || !driver->setup)
2320 return -EINVAL; 2320 return -EINVAL;
2321 2321
2322 if (udc_controller->driver) 2322 if (udc_controller->driver)
@@ -2332,7 +2332,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2332 udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed); 2332 udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed);
2333 spin_unlock_irqrestore(&udc_controller->lock, flags); 2333 spin_unlock_irqrestore(&udc_controller->lock, flags);
2334 2334
2335 retval = driver->bind(&udc_controller->gadget); 2335 retval = bind(&udc_controller->gadget);
2336 if (retval) { 2336 if (retval) {
2337 dev_err(udc_controller->dev, "bind to %s --> %d", 2337 dev_err(udc_controller->dev, "bind to %s --> %d",
2338 driver->driver.name, retval); 2338 driver->driver.name, retval);
@@ -2353,7 +2353,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2353 udc_controller->gadget.name, driver->driver.name); 2353 udc_controller->gadget.name, driver->driver.name);
2354 return 0; 2354 return 0;
2355} 2355}
2356EXPORT_SYMBOL(usb_gadget_register_driver); 2356EXPORT_SYMBOL(usb_gadget_probe_driver);
2357 2357
2358int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 2358int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2359{ 2359{
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 08a9a62a39e3..c16b402a876b 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -1765,7 +1765,8 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc)
1765 * Hook to gadget drivers 1765 * Hook to gadget drivers
1766 * Called by initialization code of gadget drivers 1766 * Called by initialization code of gadget drivers
1767*----------------------------------------------------------------*/ 1767*----------------------------------------------------------------*/
1768int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1768int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1769 int (*bind)(struct usb_gadget *))
1769{ 1770{
1770 int retval = -ENODEV; 1771 int retval = -ENODEV;
1771 unsigned long flags = 0; 1772 unsigned long flags = 0;
@@ -1775,8 +1776,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1775 1776
1776 if (!driver || (driver->speed != USB_SPEED_FULL 1777 if (!driver || (driver->speed != USB_SPEED_FULL
1777 && driver->speed != USB_SPEED_HIGH) 1778 && driver->speed != USB_SPEED_HIGH)
1778 || !driver->bind || !driver->disconnect 1779 || !bind || !driver->disconnect || !driver->setup)
1779 || !driver->setup)
1780 return -EINVAL; 1780 return -EINVAL;
1781 1781
1782 if (udc_controller->driver) 1782 if (udc_controller->driver)
@@ -1792,7 +1792,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1792 spin_unlock_irqrestore(&udc_controller->lock, flags); 1792 spin_unlock_irqrestore(&udc_controller->lock, flags);
1793 1793
1794 /* bind udc driver to gadget driver */ 1794 /* bind udc driver to gadget driver */
1795 retval = driver->bind(&udc_controller->gadget); 1795 retval = bind(&udc_controller->gadget);
1796 if (retval) { 1796 if (retval) {
1797 VDBG("bind to %s --> %d", driver->driver.name, retval); 1797 VDBG("bind to %s --> %d", driver->driver.name, retval);
1798 udc_controller->gadget.dev.driver = NULL; 1798 udc_controller->gadget.dev.driver = NULL;
@@ -1814,7 +1814,7 @@ out:
1814 retval); 1814 retval);
1815 return retval; 1815 return retval;
1816} 1816}
1817EXPORT_SYMBOL(usb_gadget_register_driver); 1817EXPORT_SYMBOL(usb_gadget_probe_driver);
1818 1818
1819/* Disconnect from gadget driver */ 1819/* Disconnect from gadget driver */
1820int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 1820int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index a9474f8d5325..af75e3620849 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -52,9 +52,8 @@ MODULE_DESCRIPTION(DRIVER_DESC);
52MODULE_AUTHOR("Michal Nazarewicz"); 52MODULE_AUTHOR("Michal Nazarewicz");
53MODULE_LICENSE("GPL"); 53MODULE_LICENSE("GPL");
54 54
55 55#define GFS_VENDOR_ID 0x1d6b /* Linux Foundation */
56static unsigned short gfs_vendor_id = 0x0525; /* XXX NetChip */ 56#define GFS_PRODUCT_ID 0x0105 /* FunctionFS Gadget */
57static unsigned short gfs_product_id = 0xa4ac; /* XXX */
58 57
59static struct usb_device_descriptor gfs_dev_desc = { 58static struct usb_device_descriptor gfs_dev_desc = {
60 .bLength = sizeof gfs_dev_desc, 59 .bLength = sizeof gfs_dev_desc,
@@ -63,29 +62,16 @@ static struct usb_device_descriptor gfs_dev_desc = {
63 .bcdUSB = cpu_to_le16(0x0200), 62 .bcdUSB = cpu_to_le16(0x0200),
64 .bDeviceClass = USB_CLASS_PER_INTERFACE, 63 .bDeviceClass = USB_CLASS_PER_INTERFACE,
65 64
66 /* Vendor and product id can be overridden by module parameters. */ 65 .idVendor = cpu_to_le16(GFS_VENDOR_ID),
67 /* .idVendor = cpu_to_le16(gfs_vendor_id), */ 66 .idProduct = cpu_to_le16(GFS_PRODUCT_ID),
68 /* .idProduct = cpu_to_le16(gfs_product_id), */
69 /* .bcdDevice = f(hardware) */
70 /* .iManufacturer = DYNAMIC */
71 /* .iProduct = DYNAMIC */
72 /* NO SERIAL NUMBER */
73 .bNumConfigurations = 1,
74}; 67};
75 68
76#define GFS_MODULE_PARAM_DESC(name, field) \ 69module_param_named(bDeviceClass, gfs_dev_desc.bDeviceClass, byte, 0644);
77 MODULE_PARM_DESC(name, "Value of the " #field " field of the device descriptor sent to the host. Takes effect only prior to the user-space driver registering to the FunctionFS.") 70MODULE_PARM_DESC(bDeviceClass, "USB Device class");
78 71module_param_named(bDeviceSubClass, gfs_dev_desc.bDeviceSubClass, byte, 0644);
79module_param_named(usb_class, gfs_dev_desc.bDeviceClass, byte, 0644); 72MODULE_PARM_DESC(bDeviceSubClass, "USB Device subclass");
80GFS_MODULE_PARAM_DESC(usb_class, bDeviceClass); 73module_param_named(bDeviceProtocol, gfs_dev_desc.bDeviceProtocol, byte, 0644);
81module_param_named(usb_subclass, gfs_dev_desc.bDeviceSubClass, byte, 0644); 74MODULE_PARM_DESC(bDeviceProtocol, "USB Device protocol");
82GFS_MODULE_PARAM_DESC(usb_subclass, bDeviceSubClass);
83module_param_named(usb_protocol, gfs_dev_desc.bDeviceProtocol, byte, 0644);
84GFS_MODULE_PARAM_DESC(usb_protocol, bDeviceProtocol);
85module_param_named(usb_vendor, gfs_vendor_id, ushort, 0644);
86GFS_MODULE_PARAM_DESC(usb_vendor, idVendor);
87module_param_named(usb_product, gfs_product_id, ushort, 0644);
88GFS_MODULE_PARAM_DESC(usb_product, idProduct);
89 75
90 76
91 77
@@ -95,8 +81,10 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = {
95 .bLength = sizeof(struct usb_otg_descriptor), 81 .bLength = sizeof(struct usb_otg_descriptor),
96 .bDescriptorType = USB_DT_OTG, 82 .bDescriptorType = USB_DT_OTG,
97 83
98 /* REVISIT SRP-only hardware is possible, although 84 /*
99 * it would not be called "OTG" ... */ 85 * REVISIT SRP-only hardware is possible, although
86 * it would not be called "OTG" ...
87 */
100 .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, 88 .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
101 }, 89 },
102 90
@@ -105,19 +93,7 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = {
105 93
106/* string IDs are assigned dynamically */ 94/* string IDs are assigned dynamically */
107 95
108enum {
109 GFS_STRING_MANUFACTURER_IDX,
110 GFS_STRING_PRODUCT_IDX,
111 GFS_STRING_FIRST_CONFIG_IDX,
112};
113
114static char gfs_manufacturer[50];
115static const char gfs_driver_desc[] = DRIVER_DESC;
116static const char gfs_short_name[] = DRIVER_NAME;
117
118static struct usb_string gfs_strings[] = { 96static struct usb_string gfs_strings[] = {
119 [GFS_STRING_MANUFACTURER_IDX].s = gfs_manufacturer,
120 [GFS_STRING_PRODUCT_IDX].s = gfs_driver_desc,
121#ifdef CONFIG_USB_FUNCTIONFS_RNDIS 97#ifdef CONFIG_USB_FUNCTIONFS_RNDIS
122 { .s = "FunctionFS + RNDIS" }, 98 { .s = "FunctionFS + RNDIS" },
123#endif 99#endif
@@ -168,11 +144,11 @@ static int gfs_unbind(struct usb_composite_dev *cdev);
168static int gfs_do_config(struct usb_configuration *c); 144static int gfs_do_config(struct usb_configuration *c);
169 145
170static struct usb_composite_driver gfs_driver = { 146static struct usb_composite_driver gfs_driver = {
171 .name = gfs_short_name, 147 .name = DRIVER_NAME,
172 .dev = &gfs_dev_desc, 148 .dev = &gfs_dev_desc,
173 .strings = gfs_dev_strings, 149 .strings = gfs_dev_strings,
174 .bind = gfs_bind,
175 .unbind = gfs_unbind, 150 .unbind = gfs_unbind,
151 .iProduct = DRIVER_DESC,
176}; 152};
177 153
178 154
@@ -210,7 +186,7 @@ static int functionfs_ready_callback(struct ffs_data *ffs)
210 return -EBUSY; 186 return -EBUSY;
211 187
212 gfs_ffs_data = ffs; 188 gfs_ffs_data = ffs;
213 ret = usb_composite_register(&gfs_driver); 189 ret = usb_composite_probe(&gfs_driver, gfs_bind);
214 if (unlikely(ret < 0)) 190 if (unlikely(ret < 0))
215 clear_bit(0, &gfs_registered); 191 clear_bit(0, &gfs_registered);
216 return ret; 192 return ret;
@@ -245,20 +221,10 @@ static int gfs_bind(struct usb_composite_dev *cdev)
245 if (unlikely(ret < 0)) 221 if (unlikely(ret < 0))
246 goto error_quick; 222 goto error_quick;
247 223
248 gfs_dev_desc.idVendor = cpu_to_le16(gfs_vendor_id);
249 gfs_dev_desc.idProduct = cpu_to_le16(gfs_product_id);
250
251 snprintf(gfs_manufacturer, sizeof gfs_manufacturer, "%s %s with %s",
252 init_utsname()->sysname, init_utsname()->release,
253 cdev->gadget->name);
254
255 ret = usb_string_ids_tab(cdev, gfs_strings); 224 ret = usb_string_ids_tab(cdev, gfs_strings);
256 if (unlikely(ret < 0)) 225 if (unlikely(ret < 0))
257 goto error; 226 goto error;
258 227
259 gfs_dev_desc.iManufacturer = gfs_strings[GFS_STRING_MANUFACTURER_IDX].id;
260 gfs_dev_desc.iProduct = gfs_strings[GFS_STRING_PRODUCT_IDX].id;
261
262 ret = functionfs_bind(gfs_ffs_data, cdev); 228 ret = functionfs_bind(gfs_ffs_data, cdev);
263 if (unlikely(ret < 0)) 229 if (unlikely(ret < 0))
264 goto error; 230 goto error;
@@ -266,14 +232,12 @@ static int gfs_bind(struct usb_composite_dev *cdev)
266 for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { 232 for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) {
267 struct gfs_configuration *c = gfs_configurations + i; 233 struct gfs_configuration *c = gfs_configurations + i;
268 234
269 ret = GFS_STRING_FIRST_CONFIG_IDX + i; 235 c->c.label = gfs_strings[i].s;
270 c->c.label = gfs_strings[ret].s; 236 c->c.iConfiguration = gfs_strings[i].id;
271 c->c.iConfiguration = gfs_strings[ret].id;
272 c->c.bind = gfs_do_config;
273 c->c.bConfigurationValue = 1 + i; 237 c->c.bConfigurationValue = 1 + i;
274 c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; 238 c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER;
275 239
276 ret = usb_add_config(cdev, &c->c); 240 ret = usb_add_config(cdev, &c->c, gfs_do_config);
277 if (unlikely(ret < 0)) 241 if (unlikely(ret < 0))
278 goto error_unbind; 242 goto error_unbind;
279 } 243 }
@@ -293,13 +257,14 @@ static int gfs_unbind(struct usb_composite_dev *cdev)
293{ 257{
294 ENTER(); 258 ENTER();
295 259
296 /* We may have been called in an error recovery frem 260 /*
261 * We may have been called in an error recovery from
297 * composite_bind() after gfs_unbind() failure so we need to 262 * composite_bind() after gfs_unbind() failure so we need to
298 * check if gfs_ffs_data is not NULL since gfs_bind() handles 263 * check if gfs_ffs_data is not NULL since gfs_bind() handles
299 * all error recovery itself. I'd rather we werent called 264 * all error recovery itself. I'd rather we werent called
300 * from composite on orror recovery, but what you're gonna 265 * from composite on orror recovery, but what you're gonna
301 * do...? */ 266 * do...?
302 267 */
303 if (gfs_ffs_data) { 268 if (gfs_ffs_data) {
304 gether_cleanup(); 269 gether_cleanup();
305 functionfs_unbind(gfs_ffs_data); 270 functionfs_unbind(gfs_ffs_data);
@@ -334,14 +299,16 @@ static int gfs_do_config(struct usb_configuration *c)
334 if (unlikely(ret < 0)) 299 if (unlikely(ret < 0))
335 return ret; 300 return ret;
336 301
337 /* After previous do_configs there may be some invalid 302 /*
303 * After previous do_configs there may be some invalid
338 * pointers in c->interface array. This happens every time 304 * pointers in c->interface array. This happens every time
339 * a user space function with fewer interfaces than a user 305 * a user space function with fewer interfaces than a user
340 * space function that was run before the new one is run. The 306 * space function that was run before the new one is run. The
341 * compasit's set_config() assumes that if there is no more 307 * compasit's set_config() assumes that if there is no more
342 * then MAX_CONFIG_INTERFACES interfaces in a configuration 308 * then MAX_CONFIG_INTERFACES interfaces in a configuration
343 * then there is a NULL pointer after the last interface in 309 * then there is a NULL pointer after the last interface in
344 * c->interface array. We need to make sure this is true. */ 310 * c->interface array. We need to make sure this is true.
311 */
345 if (c->next_interface_id < ARRAY_SIZE(c->interface)) 312 if (c->next_interface_id < ARRAY_SIZE(c->interface))
346 c->interface[c->next_interface_id] = NULL; 313 c->interface[c->next_interface_id] = NULL;
347 314
@@ -350,10 +317,12 @@ static int gfs_do_config(struct usb_configuration *c)
350 317
351 318
352#ifdef CONFIG_USB_FUNCTIONFS_ETH 319#ifdef CONFIG_USB_FUNCTIONFS_ETH
320
353static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) 321static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
354{ 322{
355 return can_support_ecm(c->cdev->gadget) 323 return can_support_ecm(c->cdev->gadget)
356 ? ecm_bind_config(c, ethaddr) 324 ? ecm_bind_config(c, ethaddr)
357 : geth_bind_config(c, ethaddr); 325 : geth_bind_config(c, ethaddr);
358} 326}
327
359#endif 328#endif
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 1b413a5cc3f6..0ab7e141d494 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -1157,7 +1157,7 @@ fail:
1157/* 1157/*
1158 * Creates an output endpoint, and initializes output ports. 1158 * Creates an output endpoint, and initializes output ports.
1159 */ 1159 */
1160static int __ref gmidi_bind(struct usb_gadget *gadget) 1160static int __init gmidi_bind(struct usb_gadget *gadget)
1161{ 1161{
1162 struct gmidi_device *dev; 1162 struct gmidi_device *dev;
1163 struct usb_ep *in_ep, *out_ep; 1163 struct usb_ep *in_ep, *out_ep;
@@ -1292,7 +1292,6 @@ static void gmidi_resume(struct usb_gadget *gadget)
1292static struct usb_gadget_driver gmidi_driver = { 1292static struct usb_gadget_driver gmidi_driver = {
1293 .speed = USB_SPEED_FULL, 1293 .speed = USB_SPEED_FULL,
1294 .function = (char *)longname, 1294 .function = (char *)longname,
1295 .bind = gmidi_bind,
1296 .unbind = gmidi_unbind, 1295 .unbind = gmidi_unbind,
1297 1296
1298 .setup = gmidi_setup, 1297 .setup = gmidi_setup,
@@ -1309,7 +1308,7 @@ static struct usb_gadget_driver gmidi_driver = {
1309 1308
1310static int __init gmidi_init(void) 1309static int __init gmidi_init(void)
1311{ 1310{
1312 return usb_gadget_register_driver(&gmidi_driver); 1311 return usb_gadget_probe_driver(&gmidi_driver, gmidi_bind);
1313} 1312}
1314module_init(gmidi_init); 1313module_init(gmidi_init);
1315 1314
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 1088d08c7ed8..48a760220baf 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1343,14 +1343,15 @@ static struct goku_udc *the_controller;
1343 * disconnect is reported. then a host may connect again, or 1343 * disconnect is reported. then a host may connect again, or
1344 * the driver might get unbound. 1344 * the driver might get unbound.
1345 */ 1345 */
1346int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1346int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1347 int (*bind)(struct usb_gadget *))
1347{ 1348{
1348 struct goku_udc *dev = the_controller; 1349 struct goku_udc *dev = the_controller;
1349 int retval; 1350 int retval;
1350 1351
1351 if (!driver 1352 if (!driver
1352 || driver->speed < USB_SPEED_FULL 1353 || driver->speed < USB_SPEED_FULL
1353 || !driver->bind 1354 || !bind
1354 || !driver->disconnect 1355 || !driver->disconnect
1355 || !driver->setup) 1356 || !driver->setup)
1356 return -EINVAL; 1357 return -EINVAL;
@@ -1363,7 +1364,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1363 driver->driver.bus = NULL; 1364 driver->driver.bus = NULL;
1364 dev->driver = driver; 1365 dev->driver = driver;
1365 dev->gadget.dev.driver = &driver->driver; 1366 dev->gadget.dev.driver = &driver->driver;
1366 retval = driver->bind(&dev->gadget); 1367 retval = bind(&dev->gadget);
1367 if (retval) { 1368 if (retval) {
1368 DBG(dev, "bind to driver %s --> error %d\n", 1369 DBG(dev, "bind to driver %s --> error %d\n",
1369 driver->driver.name, retval); 1370 driver->driver.name, retval);
@@ -1380,7 +1381,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1380 DBG(dev, "registered gadget driver '%s'\n", driver->driver.name); 1381 DBG(dev, "registered gadget driver '%s'\n", driver->driver.name);
1381 return 0; 1382 return 0;
1382} 1383}
1383EXPORT_SYMBOL(usb_gadget_register_driver); 1384EXPORT_SYMBOL(usb_gadget_probe_driver);
1384 1385
1385static void 1386static void
1386stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver) 1387stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver)
@@ -1744,7 +1745,8 @@ static void goku_remove(struct pci_dev *pdev)
1744 pci_resource_len (pdev, 0)); 1745 pci_resource_len (pdev, 0));
1745 if (dev->enabled) 1746 if (dev->enabled)
1746 pci_disable_device(pdev); 1747 pci_disable_device(pdev);
1747 device_unregister(&dev->gadget.dev); 1748 if (dev->registered)
1749 device_unregister(&dev->gadget.dev);
1748 1750
1749 pci_set_drvdata(pdev, NULL); 1751 pci_set_drvdata(pdev, NULL);
1750 dev->regs = NULL; 1752 dev->regs = NULL;
@@ -1774,7 +1776,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1774 if (!pdev->irq) { 1776 if (!pdev->irq) {
1775 printk(KERN_ERR "Check PCI %s IRQ setup!\n", pci_name(pdev)); 1777 printk(KERN_ERR "Check PCI %s IRQ setup!\n", pci_name(pdev));
1776 retval = -ENODEV; 1778 retval = -ENODEV;
1777 goto done; 1779 goto err;
1778 } 1780 }
1779 1781
1780 /* alloc, and start init */ 1782 /* alloc, and start init */
@@ -1782,7 +1784,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1782 if (dev == NULL){ 1784 if (dev == NULL){
1783 pr_debug("enomem %s\n", pci_name(pdev)); 1785 pr_debug("enomem %s\n", pci_name(pdev));
1784 retval = -ENOMEM; 1786 retval = -ENOMEM;
1785 goto done; 1787 goto err;
1786 } 1788 }
1787 1789
1788 spin_lock_init(&dev->lock); 1790 spin_lock_init(&dev->lock);
@@ -1800,7 +1802,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1800 retval = pci_enable_device(pdev); 1802 retval = pci_enable_device(pdev);
1801 if (retval < 0) { 1803 if (retval < 0) {
1802 DBG(dev, "can't enable, %d\n", retval); 1804 DBG(dev, "can't enable, %d\n", retval);
1803 goto done; 1805 goto err;
1804 } 1806 }
1805 dev->enabled = 1; 1807 dev->enabled = 1;
1806 1808
@@ -1809,7 +1811,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1809 if (!request_mem_region(resource, len, driver_name)) { 1811 if (!request_mem_region(resource, len, driver_name)) {
1810 DBG(dev, "controller already in use\n"); 1812 DBG(dev, "controller already in use\n");
1811 retval = -EBUSY; 1813 retval = -EBUSY;
1812 goto done; 1814 goto err;
1813 } 1815 }
1814 dev->got_region = 1; 1816 dev->got_region = 1;
1815 1817
@@ -1817,7 +1819,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1817 if (base == NULL) { 1819 if (base == NULL) {
1818 DBG(dev, "can't map memory\n"); 1820 DBG(dev, "can't map memory\n");
1819 retval = -EFAULT; 1821 retval = -EFAULT;
1820 goto done; 1822 goto err;
1821 } 1823 }
1822 dev->regs = (struct goku_udc_regs __iomem *) base; 1824 dev->regs = (struct goku_udc_regs __iomem *) base;
1823 1825
@@ -1833,7 +1835,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1833 driver_name, dev) != 0) { 1835 driver_name, dev) != 0) {
1834 DBG(dev, "request interrupt %d failed\n", pdev->irq); 1836 DBG(dev, "request interrupt %d failed\n", pdev->irq);
1835 retval = -EBUSY; 1837 retval = -EBUSY;
1836 goto done; 1838 goto err;
1837 } 1839 }
1838 dev->got_irq = 1; 1840 dev->got_irq = 1;
1839 if (use_dma) 1841 if (use_dma)
@@ -1844,13 +1846,16 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1844 create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); 1846 create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev);
1845#endif 1847#endif
1846 1848
1847 /* done */
1848 the_controller = dev; 1849 the_controller = dev;
1849 retval = device_register(&dev->gadget.dev); 1850 retval = device_register(&dev->gadget.dev);
1850 if (retval == 0) 1851 if (retval) {
1851 return 0; 1852 put_device(&dev->gadget.dev);
1853 goto err;
1854 }
1855 dev->registered = 1;
1856 return 0;
1852 1857
1853done: 1858err:
1854 if (dev) 1859 if (dev)
1855 goku_remove (pdev); 1860 goku_remove (pdev);
1856 return retval; 1861 return retval;
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c
index 735495bf8411..2523e54097bd 100644
--- a/drivers/usb/gadget/hid.c
+++ b/drivers/usb/gadget/hid.c
@@ -127,7 +127,7 @@ static struct usb_gadget_strings *dev_strings[] = {
127 127
128/****************************** Configurations ******************************/ 128/****************************** Configurations ******************************/
129 129
130static int __ref do_config(struct usb_configuration *c) 130static int __init do_config(struct usb_configuration *c)
131{ 131{
132 struct hidg_func_node *e; 132 struct hidg_func_node *e;
133 int func = 0, status = 0; 133 int func = 0, status = 0;
@@ -148,7 +148,6 @@ static int __ref do_config(struct usb_configuration *c)
148 148
149static struct usb_configuration config_driver = { 149static struct usb_configuration config_driver = {
150 .label = "HID Gadget", 150 .label = "HID Gadget",
151 .bind = do_config,
152 .bConfigurationValue = 1, 151 .bConfigurationValue = 1,
153 /* .iConfiguration = DYNAMIC */ 152 /* .iConfiguration = DYNAMIC */
154 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 153 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -156,7 +155,7 @@ static struct usb_configuration config_driver = {
156 155
157/****************************** Gadget Bind ******************************/ 156/****************************** Gadget Bind ******************************/
158 157
159static int __ref hid_bind(struct usb_composite_dev *cdev) 158static int __init hid_bind(struct usb_composite_dev *cdev)
160{ 159{
161 struct usb_gadget *gadget = cdev->gadget; 160 struct usb_gadget *gadget = cdev->gadget;
162 struct list_head *tmp; 161 struct list_head *tmp;
@@ -201,7 +200,7 @@ static int __ref hid_bind(struct usb_composite_dev *cdev)
201 device_desc.iProduct = status; 200 device_desc.iProduct = status;
202 201
203 /* register our configuration */ 202 /* register our configuration */
204 status = usb_add_config(cdev, &config_driver); 203 status = usb_add_config(cdev, &config_driver, do_config);
205 if (status < 0) 204 if (status < 0)
206 return status; 205 return status;
207 206
@@ -256,7 +255,6 @@ static struct usb_composite_driver hidg_driver = {
256 .name = "g_hid", 255 .name = "g_hid",
257 .dev = &device_desc, 256 .dev = &device_desc,
258 .strings = dev_strings, 257 .strings = dev_strings,
259 .bind = hid_bind,
260 .unbind = __exit_p(hid_unbind), 258 .unbind = __exit_p(hid_unbind),
261}; 259};
262 260
@@ -282,7 +280,7 @@ static int __init hidg_init(void)
282 if (status < 0) 280 if (status < 0)
283 return status; 281 return status;
284 282
285 status = usb_composite_register(&hidg_driver); 283 status = usb_composite_probe(&hidg_driver, hid_bind);
286 if (status < 0) 284 if (status < 0)
287 platform_driver_unregister(&hidg_plat_driver); 285 platform_driver_unregister(&hidg_plat_driver);
288 286
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
index e743122fcd93..ed0266462c57 100644
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -1319,14 +1319,15 @@ static struct imx_udc_struct controller = {
1319 * USB gadged driver functions 1319 * USB gadged driver functions
1320 ******************************************************************************* 1320 *******************************************************************************
1321 */ 1321 */
1322int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1322int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1323 int (*bind)(struct usb_gadget *))
1323{ 1324{
1324 struct imx_udc_struct *imx_usb = &controller; 1325 struct imx_udc_struct *imx_usb = &controller;
1325 int retval; 1326 int retval;
1326 1327
1327 if (!driver 1328 if (!driver
1328 || driver->speed < USB_SPEED_FULL 1329 || driver->speed < USB_SPEED_FULL
1329 || !driver->bind 1330 || !bind
1330 || !driver->disconnect 1331 || !driver->disconnect
1331 || !driver->setup) 1332 || !driver->setup)
1332 return -EINVAL; 1333 return -EINVAL;
@@ -1342,7 +1343,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1342 retval = device_add(&imx_usb->gadget.dev); 1343 retval = device_add(&imx_usb->gadget.dev);
1343 if (retval) 1344 if (retval)
1344 goto fail; 1345 goto fail;
1345 retval = driver->bind(&imx_usb->gadget); 1346 retval = bind(&imx_usb->gadget);
1346 if (retval) { 1347 if (retval) {
1347 D_ERR(imx_usb->dev, "<%s> bind to driver %s --> error %d\n", 1348 D_ERR(imx_usb->dev, "<%s> bind to driver %s --> error %d\n",
1348 __func__, driver->driver.name, retval); 1349 __func__, driver->driver.name, retval);
@@ -1362,7 +1363,7 @@ fail:
1362 imx_usb->gadget.dev.driver = NULL; 1363 imx_usb->gadget.dev.driver = NULL;
1363 return retval; 1364 return retval;
1364} 1365}
1365EXPORT_SYMBOL(usb_gadget_register_driver); 1366EXPORT_SYMBOL(usb_gadget_probe_driver);
1366 1367
1367int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 1368int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1368{ 1369{
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 3f1d771c8be5..d1d72d946b04 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1774,7 +1774,6 @@ static struct usb_gadget_driver gadgetfs_driver = {
1774 .speed = USB_SPEED_FULL, 1774 .speed = USB_SPEED_FULL,
1775#endif 1775#endif
1776 .function = (char *) driver_desc, 1776 .function = (char *) driver_desc,
1777 .bind = gadgetfs_bind,
1778 .unbind = gadgetfs_unbind, 1777 .unbind = gadgetfs_unbind,
1779 .setup = gadgetfs_setup, 1778 .setup = gadgetfs_setup,
1780 .disconnect = gadgetfs_disconnect, 1779 .disconnect = gadgetfs_disconnect,
@@ -1797,7 +1796,6 @@ static int gadgetfs_probe (struct usb_gadget *gadget)
1797 1796
1798static struct usb_gadget_driver probe_driver = { 1797static struct usb_gadget_driver probe_driver = {
1799 .speed = USB_SPEED_HIGH, 1798 .speed = USB_SPEED_HIGH,
1800 .bind = gadgetfs_probe,
1801 .unbind = gadgetfs_nop, 1799 .unbind = gadgetfs_nop,
1802 .setup = (void *)gadgetfs_nop, 1800 .setup = (void *)gadgetfs_nop,
1803 .disconnect = gadgetfs_nop, 1801 .disconnect = gadgetfs_nop,
@@ -1907,7 +1905,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1907 1905
1908 /* triggers gadgetfs_bind(); then we can enumerate. */ 1906 /* triggers gadgetfs_bind(); then we can enumerate. */
1909 spin_unlock_irq (&dev->lock); 1907 spin_unlock_irq (&dev->lock);
1910 value = usb_gadget_register_driver (&gadgetfs_driver); 1908 value = usb_gadget_probe_driver(&gadgetfs_driver, gadgetfs_bind);
1911 if (value != 0) { 1909 if (value != 0) {
1912 kfree (dev->buf); 1910 kfree (dev->buf);
1913 dev->buf = NULL; 1911 dev->buf = NULL;
@@ -2046,7 +2044,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
2046 return -ESRCH; 2044 return -ESRCH;
2047 2045
2048 /* fake probe to determine $CHIP */ 2046 /* fake probe to determine $CHIP */
2049 (void) usb_gadget_register_driver (&probe_driver); 2047 (void) usb_gadget_probe_driver(&probe_driver, gadgetfs_probe);
2050 if (!CHIP) 2048 if (!CHIP)
2051 return -ENODEV; 2049 return -ENODEV;
2052 2050
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c
index c2d2a201f84b..b8ec954c0692 100644
--- a/drivers/usb/gadget/langwell_udc.c
+++ b/drivers/usb/gadget/langwell_udc.c
@@ -19,7 +19,7 @@
19 19
20 20
21/* #undef DEBUG */ 21/* #undef DEBUG */
22/* #undef VERBOSE */ 22/* #undef VERBOSE_DEBUG */
23 23
24#if defined(CONFIG_USB_LANGWELL_OTG) 24#if defined(CONFIG_USB_LANGWELL_OTG)
25#define OTG_TRANSCEIVER 25#define OTG_TRANSCEIVER
@@ -77,141 +77,110 @@ langwell_ep0_desc = {
77/*-------------------------------------------------------------------------*/ 77/*-------------------------------------------------------------------------*/
78/* debugging */ 78/* debugging */
79 79
80#ifdef DEBUG 80#ifdef VERBOSE_DEBUG
81#define DBG(dev, fmt, args...) \
82 pr_debug("%s %s: " fmt , driver_name, \
83 pci_name(dev->pdev), ## args)
84#else
85#define DBG(dev, fmt, args...) \
86 do { } while (0)
87#endif /* DEBUG */
88
89
90#ifdef VERBOSE
91#define VDBG DBG
92#else
93#define VDBG(dev, fmt, args...) \
94 do { } while (0)
95#endif /* VERBOSE */
96
97
98#define ERROR(dev, fmt, args...) \
99 pr_err("%s %s: " fmt , driver_name, \
100 pci_name(dev->pdev), ## args)
101
102#define WARNING(dev, fmt, args...) \
103 pr_warning("%s %s: " fmt , driver_name, \
104 pci_name(dev->pdev), ## args)
105
106#define INFO(dev, fmt, args...) \
107 pr_info("%s %s: " fmt , driver_name, \
108 pci_name(dev->pdev), ## args)
109
110
111#ifdef VERBOSE
112static inline void print_all_registers(struct langwell_udc *dev) 81static inline void print_all_registers(struct langwell_udc *dev)
113{ 82{
114 int i; 83 int i;
115 84
116 /* Capability Registers */ 85 /* Capability Registers */
117 printk(KERN_DEBUG "Capability Registers (offset: " 86 dev_dbg(&dev->pdev->dev,
118 "0x%04x, length: 0x%08x)\n", 87 "Capability Registers (offset: 0x%04x, length: 0x%08x)\n",
119 CAP_REG_OFFSET, 88 CAP_REG_OFFSET, (u32)sizeof(struct langwell_cap_regs));
120 (u32)sizeof(struct langwell_cap_regs)); 89 dev_dbg(&dev->pdev->dev, "caplength=0x%02x\n",
121 printk(KERN_DEBUG "caplength=0x%02x\n",
122 readb(&dev->cap_regs->caplength)); 90 readb(&dev->cap_regs->caplength));
123 printk(KERN_DEBUG "hciversion=0x%04x\n", 91 dev_dbg(&dev->pdev->dev, "hciversion=0x%04x\n",
124 readw(&dev->cap_regs->hciversion)); 92 readw(&dev->cap_regs->hciversion));
125 printk(KERN_DEBUG "hcsparams=0x%08x\n", 93 dev_dbg(&dev->pdev->dev, "hcsparams=0x%08x\n",
126 readl(&dev->cap_regs->hcsparams)); 94 readl(&dev->cap_regs->hcsparams));
127 printk(KERN_DEBUG "hccparams=0x%08x\n", 95 dev_dbg(&dev->pdev->dev, "hccparams=0x%08x\n",
128 readl(&dev->cap_regs->hccparams)); 96 readl(&dev->cap_regs->hccparams));
129 printk(KERN_DEBUG "dciversion=0x%04x\n", 97 dev_dbg(&dev->pdev->dev, "dciversion=0x%04x\n",
130 readw(&dev->cap_regs->dciversion)); 98 readw(&dev->cap_regs->dciversion));
131 printk(KERN_DEBUG "dccparams=0x%08x\n", 99 dev_dbg(&dev->pdev->dev, "dccparams=0x%08x\n",
132 readl(&dev->cap_regs->dccparams)); 100 readl(&dev->cap_regs->dccparams));
133 101
134 /* Operational Registers */ 102 /* Operational Registers */
135 printk(KERN_DEBUG "Operational Registers (offset: " 103 dev_dbg(&dev->pdev->dev,
136 "0x%04x, length: 0x%08x)\n", 104 "Operational Registers (offset: 0x%04x, length: 0x%08x)\n",
137 OP_REG_OFFSET, 105 OP_REG_OFFSET, (u32)sizeof(struct langwell_op_regs));
138 (u32)sizeof(struct langwell_op_regs)); 106 dev_dbg(&dev->pdev->dev, "extsts=0x%08x\n",
139 printk(KERN_DEBUG "extsts=0x%08x\n",
140 readl(&dev->op_regs->extsts)); 107 readl(&dev->op_regs->extsts));
141 printk(KERN_DEBUG "extintr=0x%08x\n", 108 dev_dbg(&dev->pdev->dev, "extintr=0x%08x\n",
142 readl(&dev->op_regs->extintr)); 109 readl(&dev->op_regs->extintr));
143 printk(KERN_DEBUG "usbcmd=0x%08x\n", 110 dev_dbg(&dev->pdev->dev, "usbcmd=0x%08x\n",
144 readl(&dev->op_regs->usbcmd)); 111 readl(&dev->op_regs->usbcmd));
145 printk(KERN_DEBUG "usbsts=0x%08x\n", 112 dev_dbg(&dev->pdev->dev, "usbsts=0x%08x\n",
146 readl(&dev->op_regs->usbsts)); 113 readl(&dev->op_regs->usbsts));
147 printk(KERN_DEBUG "usbintr=0x%08x\n", 114 dev_dbg(&dev->pdev->dev, "usbintr=0x%08x\n",
148 readl(&dev->op_regs->usbintr)); 115 readl(&dev->op_regs->usbintr));
149 printk(KERN_DEBUG "frindex=0x%08x\n", 116 dev_dbg(&dev->pdev->dev, "frindex=0x%08x\n",
150 readl(&dev->op_regs->frindex)); 117 readl(&dev->op_regs->frindex));
151 printk(KERN_DEBUG "ctrldssegment=0x%08x\n", 118 dev_dbg(&dev->pdev->dev, "ctrldssegment=0x%08x\n",
152 readl(&dev->op_regs->ctrldssegment)); 119 readl(&dev->op_regs->ctrldssegment));
153 printk(KERN_DEBUG "deviceaddr=0x%08x\n", 120 dev_dbg(&dev->pdev->dev, "deviceaddr=0x%08x\n",
154 readl(&dev->op_regs->deviceaddr)); 121 readl(&dev->op_regs->deviceaddr));
155 printk(KERN_DEBUG "endpointlistaddr=0x%08x\n", 122 dev_dbg(&dev->pdev->dev, "endpointlistaddr=0x%08x\n",
156 readl(&dev->op_regs->endpointlistaddr)); 123 readl(&dev->op_regs->endpointlistaddr));
157 printk(KERN_DEBUG "ttctrl=0x%08x\n", 124 dev_dbg(&dev->pdev->dev, "ttctrl=0x%08x\n",
158 readl(&dev->op_regs->ttctrl)); 125 readl(&dev->op_regs->ttctrl));
159 printk(KERN_DEBUG "burstsize=0x%08x\n", 126 dev_dbg(&dev->pdev->dev, "burstsize=0x%08x\n",
160 readl(&dev->op_regs->burstsize)); 127 readl(&dev->op_regs->burstsize));
161 printk(KERN_DEBUG "txfilltuning=0x%08x\n", 128 dev_dbg(&dev->pdev->dev, "txfilltuning=0x%08x\n",
162 readl(&dev->op_regs->txfilltuning)); 129 readl(&dev->op_regs->txfilltuning));
163 printk(KERN_DEBUG "txttfilltuning=0x%08x\n", 130 dev_dbg(&dev->pdev->dev, "txttfilltuning=0x%08x\n",
164 readl(&dev->op_regs->txttfilltuning)); 131 readl(&dev->op_regs->txttfilltuning));
165 printk(KERN_DEBUG "ic_usb=0x%08x\n", 132 dev_dbg(&dev->pdev->dev, "ic_usb=0x%08x\n",
166 readl(&dev->op_regs->ic_usb)); 133 readl(&dev->op_regs->ic_usb));
167 printk(KERN_DEBUG "ulpi_viewport=0x%08x\n", 134 dev_dbg(&dev->pdev->dev, "ulpi_viewport=0x%08x\n",
168 readl(&dev->op_regs->ulpi_viewport)); 135 readl(&dev->op_regs->ulpi_viewport));
169 printk(KERN_DEBUG "configflag=0x%08x\n", 136 dev_dbg(&dev->pdev->dev, "configflag=0x%08x\n",
170 readl(&dev->op_regs->configflag)); 137 readl(&dev->op_regs->configflag));
171 printk(KERN_DEBUG "portsc1=0x%08x\n", 138 dev_dbg(&dev->pdev->dev, "portsc1=0x%08x\n",
172 readl(&dev->op_regs->portsc1)); 139 readl(&dev->op_regs->portsc1));
173 printk(KERN_DEBUG "devlc=0x%08x\n", 140 dev_dbg(&dev->pdev->dev, "devlc=0x%08x\n",
174 readl(&dev->op_regs->devlc)); 141 readl(&dev->op_regs->devlc));
175 printk(KERN_DEBUG "otgsc=0x%08x\n", 142 dev_dbg(&dev->pdev->dev, "otgsc=0x%08x\n",
176 readl(&dev->op_regs->otgsc)); 143 readl(&dev->op_regs->otgsc));
177 printk(KERN_DEBUG "usbmode=0x%08x\n", 144 dev_dbg(&dev->pdev->dev, "usbmode=0x%08x\n",
178 readl(&dev->op_regs->usbmode)); 145 readl(&dev->op_regs->usbmode));
179 printk(KERN_DEBUG "endptnak=0x%08x\n", 146 dev_dbg(&dev->pdev->dev, "endptnak=0x%08x\n",
180 readl(&dev->op_regs->endptnak)); 147 readl(&dev->op_regs->endptnak));
181 printk(KERN_DEBUG "endptnaken=0x%08x\n", 148 dev_dbg(&dev->pdev->dev, "endptnaken=0x%08x\n",
182 readl(&dev->op_regs->endptnaken)); 149 readl(&dev->op_regs->endptnaken));
183 printk(KERN_DEBUG "endptsetupstat=0x%08x\n", 150 dev_dbg(&dev->pdev->dev, "endptsetupstat=0x%08x\n",
184 readl(&dev->op_regs->endptsetupstat)); 151 readl(&dev->op_regs->endptsetupstat));
185 printk(KERN_DEBUG "endptprime=0x%08x\n", 152 dev_dbg(&dev->pdev->dev, "endptprime=0x%08x\n",
186 readl(&dev->op_regs->endptprime)); 153 readl(&dev->op_regs->endptprime));
187 printk(KERN_DEBUG "endptflush=0x%08x\n", 154 dev_dbg(&dev->pdev->dev, "endptflush=0x%08x\n",
188 readl(&dev->op_regs->endptflush)); 155 readl(&dev->op_regs->endptflush));
189 printk(KERN_DEBUG "endptstat=0x%08x\n", 156 dev_dbg(&dev->pdev->dev, "endptstat=0x%08x\n",
190 readl(&dev->op_regs->endptstat)); 157 readl(&dev->op_regs->endptstat));
191 printk(KERN_DEBUG "endptcomplete=0x%08x\n", 158 dev_dbg(&dev->pdev->dev, "endptcomplete=0x%08x\n",
192 readl(&dev->op_regs->endptcomplete)); 159 readl(&dev->op_regs->endptcomplete));
193 160
194 for (i = 0; i < dev->ep_max / 2; i++) { 161 for (i = 0; i < dev->ep_max / 2; i++) {
195 printk(KERN_DEBUG "endptctrl[%d]=0x%08x\n", 162 dev_dbg(&dev->pdev->dev, "endptctrl[%d]=0x%08x\n",
196 i, readl(&dev->op_regs->endptctrl[i])); 163 i, readl(&dev->op_regs->endptctrl[i]));
197 } 164 }
198} 165}
199#endif /* VERBOSE */ 166#else
167
168#define print_all_registers(dev) do { } while (0)
169
170#endif /* VERBOSE_DEBUG */
200 171
201 172
202/*-------------------------------------------------------------------------*/ 173/*-------------------------------------------------------------------------*/
203 174
204#define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out") 175#define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \
176 USB_DIR_IN) : (usb_endpoint_dir_in((ep)->desc)))
205 177
206#define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \ 178#define DIR_STRING(ep) (is_in(ep) ? "in" : "out")
207 USB_DIR_IN) : ((ep)->desc->bEndpointAddress \
208 & USB_DIR_IN) == USB_DIR_IN)
209 179
210 180
211#ifdef DEBUG 181static char *type_string(const struct usb_endpoint_descriptor *desc)
212static char *type_string(u8 bmAttributes)
213{ 182{
214 switch ((bmAttributes) & USB_ENDPOINT_XFERTYPE_MASK) { 183 switch (usb_endpoint_type(desc)) {
215 case USB_ENDPOINT_XFER_BULK: 184 case USB_ENDPOINT_XFER_BULK:
216 return "bulk"; 185 return "bulk";
217 case USB_ENDPOINT_XFER_ISOC: 186 case USB_ENDPOINT_XFER_ISOC:
@@ -222,7 +191,6 @@ static char *type_string(u8 bmAttributes)
222 191
223 return "control"; 192 return "control";
224} 193}
225#endif
226 194
227 195
228/* configure endpoint control registers */ 196/* configure endpoint control registers */
@@ -233,7 +201,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num,
233 u32 endptctrl; 201 u32 endptctrl;
234 202
235 dev = ep->dev; 203 dev = ep->dev;
236 VDBG(dev, "---> %s()\n", __func__); 204 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
237 205
238 endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); 206 endptctrl = readl(&dev->op_regs->endptctrl[ep_num]);
239 if (is_in) { /* TX */ 207 if (is_in) { /* TX */
@@ -250,7 +218,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num,
250 218
251 writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); 219 writel(endptctrl, &dev->op_regs->endptctrl[ep_num]);
252 220
253 VDBG(dev, "<--- %s()\n", __func__); 221 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
254} 222}
255 223
256 224
@@ -260,7 +228,7 @@ static void ep0_reset(struct langwell_udc *dev)
260 struct langwell_ep *ep; 228 struct langwell_ep *ep;
261 int i; 229 int i;
262 230
263 VDBG(dev, "---> %s()\n", __func__); 231 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
264 232
265 /* ep0 in and out */ 233 /* ep0 in and out */
266 for (i = 0; i < 2; i++) { 234 for (i = 0; i < 2; i++) {
@@ -274,17 +242,18 @@ static void ep0_reset(struct langwell_udc *dev)
274 ep->dqh->dqh_ios = 1; 242 ep->dqh->dqh_ios = 1;
275 ep->dqh->dqh_mpl = EP0_MAX_PKT_SIZE; 243 ep->dqh->dqh_mpl = EP0_MAX_PKT_SIZE;
276 244
277 /* FIXME: enable ep0-in HW zero length termination select */ 245 /* enable ep0-in HW zero length termination select */
278 if (is_in(ep)) 246 if (is_in(ep))
279 ep->dqh->dqh_zlt = 0; 247 ep->dqh->dqh_zlt = 0;
280 ep->dqh->dqh_mult = 0; 248 ep->dqh->dqh_mult = 0;
281 249
250 ep->dqh->dtd_next = DTD_TERM;
251
282 /* configure ep0 control registers */ 252 /* configure ep0 control registers */
283 ep_reset(&dev->ep[0], 0, i, USB_ENDPOINT_XFER_CONTROL); 253 ep_reset(&dev->ep[0], 0, i, USB_ENDPOINT_XFER_CONTROL);
284 } 254 }
285 255
286 VDBG(dev, "<--- %s()\n", __func__); 256 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
287 return;
288} 257}
289 258
290 259
@@ -300,12 +269,12 @@ static int langwell_ep_enable(struct usb_ep *_ep,
300 struct langwell_ep *ep; 269 struct langwell_ep *ep;
301 u16 max = 0; 270 u16 max = 0;
302 unsigned long flags; 271 unsigned long flags;
303 int retval = 0; 272 int i, retval = 0;
304 unsigned char zlt, ios = 0, mult = 0; 273 unsigned char zlt, ios = 0, mult = 0;
305 274
306 ep = container_of(_ep, struct langwell_ep, ep); 275 ep = container_of(_ep, struct langwell_ep, ep);
307 dev = ep->dev; 276 dev = ep->dev;
308 VDBG(dev, "---> %s()\n", __func__); 277 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
309 278
310 if (!_ep || !desc || ep->desc 279 if (!_ep || !desc || ep->desc
311 || desc->bDescriptorType != USB_DT_ENDPOINT) 280 || desc->bDescriptorType != USB_DT_ENDPOINT)
@@ -326,7 +295,7 @@ static int langwell_ep_enable(struct usb_ep *_ep,
326 * sanity check type, direction, address, and then 295 * sanity check type, direction, address, and then
327 * initialize the endpoint capabilities fields in dQH 296 * initialize the endpoint capabilities fields in dQH
328 */ 297 */
329 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 298 switch (usb_endpoint_type(desc)) {
330 case USB_ENDPOINT_XFER_CONTROL: 299 case USB_ENDPOINT_XFER_CONTROL:
331 ios = 1; 300 ios = 1;
332 break; 301 break;
@@ -386,33 +355,36 @@ static int langwell_ep_enable(struct usb_ep *_ep,
386 355
387 spin_lock_irqsave(&dev->lock, flags); 356 spin_lock_irqsave(&dev->lock, flags);
388 357
389 /* configure endpoint capabilities in dQH */
390 ep->dqh->dqh_ios = ios;
391 ep->dqh->dqh_mpl = cpu_to_le16(max);
392 ep->dqh->dqh_zlt = zlt;
393 ep->dqh->dqh_mult = mult;
394
395 ep->ep.maxpacket = max; 358 ep->ep.maxpacket = max;
396 ep->desc = desc; 359 ep->desc = desc;
397 ep->stopped = 0; 360 ep->stopped = 0;
398 ep->ep_num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 361 ep->ep_num = usb_endpoint_num(desc);
399 362
400 /* ep_type */ 363 /* ep_type */
401 ep->ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 364 ep->ep_type = usb_endpoint_type(desc);
402 365
403 /* configure endpoint control registers */ 366 /* configure endpoint control registers */
404 ep_reset(ep, ep->ep_num, is_in(ep), ep->ep_type); 367 ep_reset(ep, ep->ep_num, is_in(ep), ep->ep_type);
405 368
406 DBG(dev, "enabled %s (ep%d%s-%s), max %04x\n", 369 /* configure endpoint capabilities in dQH */
370 i = ep->ep_num * 2 + is_in(ep);
371 ep->dqh = &dev->ep_dqh[i];
372 ep->dqh->dqh_ios = ios;
373 ep->dqh->dqh_mpl = cpu_to_le16(max);
374 ep->dqh->dqh_zlt = zlt;
375 ep->dqh->dqh_mult = mult;
376 ep->dqh->dtd_next = DTD_TERM;
377
378 dev_dbg(&dev->pdev->dev, "enabled %s (ep%d%s-%s), max %04x\n",
407 _ep->name, 379 _ep->name,
408 ep->ep_num, 380 ep->ep_num,
409 DIR_STRING(desc->bEndpointAddress), 381 DIR_STRING(ep),
410 type_string(desc->bmAttributes), 382 type_string(desc),
411 max); 383 max);
412 384
413 spin_unlock_irqrestore(&dev->lock, flags); 385 spin_unlock_irqrestore(&dev->lock, flags);
414done: 386done:
415 VDBG(dev, "<--- %s()\n", __func__); 387 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
416 return retval; 388 return retval;
417} 389}
418 390
@@ -428,7 +400,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
428 struct langwell_dtd *curr_dtd, *next_dtd; 400 struct langwell_dtd *curr_dtd, *next_dtd;
429 int i; 401 int i;
430 402
431 VDBG(dev, "---> %s()\n", __func__); 403 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
432 404
433 /* remove the req from ep->queue */ 405 /* remove the req from ep->queue */
434 list_del_init(&req->queue); 406 list_del_init(&req->queue);
@@ -448,7 +420,8 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
448 } 420 }
449 421
450 if (req->mapped) { 422 if (req->mapped) {
451 dma_unmap_single(&dev->pdev->dev, req->req.dma, req->req.length, 423 dma_unmap_single(&dev->pdev->dev,
424 req->req.dma, req->req.length,
452 is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); 425 is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
453 req->req.dma = DMA_ADDR_INVALID; 426 req->req.dma = DMA_ADDR_INVALID;
454 req->mapped = 0; 427 req->mapped = 0;
@@ -458,9 +431,10 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
458 is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 431 is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
459 432
460 if (status != -ESHUTDOWN) 433 if (status != -ESHUTDOWN)
461 DBG(dev, "complete %s, req %p, stat %d, len %u/%u\n", 434 dev_dbg(&dev->pdev->dev,
462 ep->ep.name, &req->req, status, 435 "complete %s, req %p, stat %d, len %u/%u\n",
463 req->req.actual, req->req.length); 436 ep->ep.name, &req->req, status,
437 req->req.actual, req->req.length);
464 438
465 /* don't modify queue heads during completion callback */ 439 /* don't modify queue heads during completion callback */
466 ep->stopped = 1; 440 ep->stopped = 1;
@@ -473,7 +447,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
473 spin_lock(&dev->lock); 447 spin_lock(&dev->lock);
474 ep->stopped = stopped; 448 ep->stopped = stopped;
475 449
476 VDBG(dev, "<--- %s()\n", __func__); 450 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
477} 451}
478 452
479 453
@@ -511,7 +485,7 @@ static int langwell_ep_disable(struct usb_ep *_ep)
511 485
512 ep = container_of(_ep, struct langwell_ep, ep); 486 ep = container_of(_ep, struct langwell_ep, ep);
513 dev = ep->dev; 487 dev = ep->dev;
514 VDBG(dev, "---> %s()\n", __func__); 488 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
515 489
516 if (!_ep || !ep->desc) 490 if (!_ep || !ep->desc)
517 return -EINVAL; 491 return -EINVAL;
@@ -535,8 +509,8 @@ static int langwell_ep_disable(struct usb_ep *_ep)
535 509
536 spin_unlock_irqrestore(&dev->lock, flags); 510 spin_unlock_irqrestore(&dev->lock, flags);
537 511
538 DBG(dev, "disabled %s\n", _ep->name); 512 dev_dbg(&dev->pdev->dev, "disabled %s\n", _ep->name);
539 VDBG(dev, "<--- %s()\n", __func__); 513 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
540 514
541 return 0; 515 return 0;
542} 516}
@@ -555,7 +529,7 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep,
555 529
556 ep = container_of(_ep, struct langwell_ep, ep); 530 ep = container_of(_ep, struct langwell_ep, ep);
557 dev = ep->dev; 531 dev = ep->dev;
558 VDBG(dev, "---> %s()\n", __func__); 532 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
559 533
560 req = kzalloc(sizeof(*req), gfp_flags); 534 req = kzalloc(sizeof(*req), gfp_flags);
561 if (!req) 535 if (!req)
@@ -564,8 +538,8 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep,
564 req->req.dma = DMA_ADDR_INVALID; 538 req->req.dma = DMA_ADDR_INVALID;
565 INIT_LIST_HEAD(&req->queue); 539 INIT_LIST_HEAD(&req->queue);
566 540
567 VDBG(dev, "alloc request for %s\n", _ep->name); 541 dev_vdbg(&dev->pdev->dev, "alloc request for %s\n", _ep->name);
568 VDBG(dev, "<--- %s()\n", __func__); 542 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
569 return &req->req; 543 return &req->req;
570} 544}
571 545
@@ -580,7 +554,7 @@ static void langwell_free_request(struct usb_ep *_ep,
580 554
581 ep = container_of(_ep, struct langwell_ep, ep); 555 ep = container_of(_ep, struct langwell_ep, ep);
582 dev = ep->dev; 556 dev = ep->dev;
583 VDBG(dev, "---> %s()\n", __func__); 557 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
584 558
585 if (!_ep || !_req) 559 if (!_ep || !_req)
586 return; 560 return;
@@ -591,8 +565,8 @@ static void langwell_free_request(struct usb_ep *_ep,
591 if (_req) 565 if (_req)
592 kfree(req); 566 kfree(req);
593 567
594 VDBG(dev, "free request for %s\n", _ep->name); 568 dev_vdbg(&dev->pdev->dev, "free request for %s\n", _ep->name);
595 VDBG(dev, "<--- %s()\n", __func__); 569 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
596} 570}
597 571
598 572
@@ -608,23 +582,24 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req)
608 struct langwell_udc *dev; 582 struct langwell_udc *dev;
609 583
610 dev = ep->dev; 584 dev = ep->dev;
611 VDBG(dev, "---> %s()\n", __func__); 585 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
612 586
613 i = ep->ep_num * 2 + is_in(ep); 587 i = ep->ep_num * 2 + is_in(ep);
614 dqh = &dev->ep_dqh[i]; 588 dqh = &dev->ep_dqh[i];
615 589
616 if (ep->ep_num) 590 if (ep->ep_num)
617 VDBG(dev, "%s\n", ep->name); 591 dev_vdbg(&dev->pdev->dev, "%s\n", ep->name);
618 else 592 else
619 /* ep0 */ 593 /* ep0 */
620 VDBG(dev, "%s-%s\n", ep->name, is_in(ep) ? "in" : "out"); 594 dev_vdbg(&dev->pdev->dev, "%s-%s\n", ep->name, DIR_STRING(ep));
621 595
622 VDBG(dev, "ep_dqh[%d] addr: 0x%08x\n", i, (u32)&(dev->ep_dqh[i])); 596 dev_vdbg(&dev->pdev->dev, "ep_dqh[%d] addr: 0x%08x\n",
597 i, (u32)&(dev->ep_dqh[i]));
623 598
624 bit_mask = is_in(ep) ? 599 bit_mask = is_in(ep) ?
625 (1 << (ep->ep_num + 16)) : (1 << (ep->ep_num)); 600 (1 << (ep->ep_num + 16)) : (1 << (ep->ep_num));
626 601
627 VDBG(dev, "bit_mask = 0x%08x\n", bit_mask); 602 dev_vdbg(&dev->pdev->dev, "bit_mask = 0x%08x\n", bit_mask);
628 603
629 /* check if the pipe is empty */ 604 /* check if the pipe is empty */
630 if (!(list_empty(&ep->queue))) { 605 if (!(list_empty(&ep->queue))) {
@@ -665,14 +640,17 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req)
665 /* clear active and halt bit */ 640 /* clear active and halt bit */
666 dtd_status = (u8) ~(DTD_STS_ACTIVE | DTD_STS_HALTED); 641 dtd_status = (u8) ~(DTD_STS_ACTIVE | DTD_STS_HALTED);
667 dqh->dtd_status &= dtd_status; 642 dqh->dtd_status &= dtd_status;
668 VDBG(dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status); 643 dev_vdbg(&dev->pdev->dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status);
644
645 /* ensure that updates to the dQH will occure before priming */
646 wmb();
669 647
670 /* write 1 to endptprime register to PRIME endpoint */ 648 /* write 1 to endptprime register to PRIME endpoint */
671 bit_mask = is_in(ep) ? (1 << (ep->ep_num + 16)) : (1 << ep->ep_num); 649 bit_mask = is_in(ep) ? (1 << (ep->ep_num + 16)) : (1 << ep->ep_num);
672 VDBG(dev, "endprime bit_mask = 0x%08x\n", bit_mask); 650 dev_vdbg(&dev->pdev->dev, "endprime bit_mask = 0x%08x\n", bit_mask);
673 writel(bit_mask, &dev->op_regs->endptprime); 651 writel(bit_mask, &dev->op_regs->endptprime);
674out: 652out:
675 VDBG(dev, "<--- %s()\n", __func__); 653 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
676 return 0; 654 return 0;
677} 655}
678 656
@@ -687,7 +665,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
687 int i; 665 int i;
688 666
689 dev = req->ep->dev; 667 dev = req->ep->dev;
690 VDBG(dev, "---> %s()\n", __func__); 668 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
691 669
692 /* the maximum transfer length, up to 16k bytes */ 670 /* the maximum transfer length, up to 16k bytes */
693 *length = min(req->req.length - req->req.actual, 671 *length = min(req->req.length - req->req.actual,
@@ -708,7 +686,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
708 686
709 /* fill in total bytes with transfer size */ 687 /* fill in total bytes with transfer size */
710 dtd->dtd_total = cpu_to_le16(*length); 688 dtd->dtd_total = cpu_to_le16(*length);
711 VDBG(dev, "dtd->dtd_total = %d\n", dtd->dtd_total); 689 dev_vdbg(&dev->pdev->dev, "dtd->dtd_total = %d\n", dtd->dtd_total);
712 690
713 /* set is_last flag if req->req.zero is set or not */ 691 /* set is_last flag if req->req.zero is set or not */
714 if (req->req.zero) { 692 if (req->req.zero) {
@@ -722,7 +700,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
722 *is_last = 0; 700 *is_last = 0;
723 701
724 if (*is_last == 0) 702 if (*is_last == 0)
725 VDBG(dev, "multi-dtd request!\n"); 703 dev_vdbg(&dev->pdev->dev, "multi-dtd request!\n");
726 704
727 /* set interrupt on complete bit for the last dTD */ 705 /* set interrupt on complete bit for the last dTD */
728 if (*is_last && !req->req.no_interrupt) 706 if (*is_last && !req->req.no_interrupt)
@@ -733,10 +711,12 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
733 711
734 /* set the active bit of status field to 1 */ 712 /* set the active bit of status field to 1 */
735 dtd->dtd_status = DTD_STS_ACTIVE; 713 dtd->dtd_status = DTD_STS_ACTIVE;
736 VDBG(dev, "dtd->dtd_status = 0x%02x\n", dtd->dtd_status); 714 dev_vdbg(&dev->pdev->dev, "dtd->dtd_status = 0x%02x\n",
715 dtd->dtd_status);
737 716
738 VDBG(dev, "length = %d, dma addr= 0x%08x\n", *length, (int)*dma); 717 dev_vdbg(&dev->pdev->dev, "length = %d, dma addr= 0x%08x\n",
739 VDBG(dev, "<--- %s()\n", __func__); 718 *length, (int)*dma);
719 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
740 return dtd; 720 return dtd;
741} 721}
742 722
@@ -751,7 +731,7 @@ static int req_to_dtd(struct langwell_request *req)
751 dma_addr_t dma; 731 dma_addr_t dma;
752 732
753 dev = req->ep->dev; 733 dev = req->ep->dev;
754 VDBG(dev, "---> %s()\n", __func__); 734 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
755 do { 735 do {
756 dtd = build_dtd(req, &count, &dma, &is_last); 736 dtd = build_dtd(req, &count, &dma, &is_last);
757 if (dtd == NULL) 737 if (dtd == NULL)
@@ -773,7 +753,7 @@ static int req_to_dtd(struct langwell_request *req)
773 753
774 req->tail = dtd; 754 req->tail = dtd;
775 755
776 VDBG(dev, "<--- %s()\n", __func__); 756 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
777 return 0; 757 return 0;
778} 758}
779 759
@@ -803,9 +783,9 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
803 783
804 dev = ep->dev; 784 dev = ep->dev;
805 req->ep = ep; 785 req->ep = ep;
806 VDBG(dev, "---> %s()\n", __func__); 786 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
807 787
808 if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { 788 if (usb_endpoint_xfer_isoc(ep->desc)) {
809 if (req->req.length > ep->ep.maxpacket) 789 if (req->req.length > ep->ep.maxpacket)
810 return -EMSGSIZE; 790 return -EMSGSIZE;
811 is_iso = 1; 791 is_iso = 1;
@@ -818,7 +798,7 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
818 if (_req->dma == DMA_ADDR_INVALID) { 798 if (_req->dma == DMA_ADDR_INVALID) {
819 /* WORKAROUND: WARN_ON(size == 0) */ 799 /* WORKAROUND: WARN_ON(size == 0) */
820 if (_req->length == 0) { 800 if (_req->length == 0) {
821 VDBG(dev, "req->length: 0->1\n"); 801 dev_vdbg(&dev->pdev->dev, "req->length: 0->1\n");
822 zlflag = 1; 802 zlflag = 1;
823 _req->length++; 803 _req->length++;
824 } 804 }
@@ -827,24 +807,25 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
827 _req->buf, _req->length, 807 _req->buf, _req->length,
828 is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 808 is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
829 if (zlflag && (_req->length == 1)) { 809 if (zlflag && (_req->length == 1)) {
830 VDBG(dev, "req->length: 1->0\n"); 810 dev_vdbg(&dev->pdev->dev, "req->length: 1->0\n");
831 zlflag = 0; 811 zlflag = 0;
832 _req->length = 0; 812 _req->length = 0;
833 } 813 }
834 814
835 req->mapped = 1; 815 req->mapped = 1;
836 VDBG(dev, "req->mapped = 1\n"); 816 dev_vdbg(&dev->pdev->dev, "req->mapped = 1\n");
837 } else { 817 } else {
838 dma_sync_single_for_device(&dev->pdev->dev, 818 dma_sync_single_for_device(&dev->pdev->dev,
839 _req->dma, _req->length, 819 _req->dma, _req->length,
840 is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 820 is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
841 req->mapped = 0; 821 req->mapped = 0;
842 VDBG(dev, "req->mapped = 0\n"); 822 dev_vdbg(&dev->pdev->dev, "req->mapped = 0\n");
843 } 823 }
844 824
845 DBG(dev, "%s queue req %p, len %u, buf %p, dma 0x%08llx\n", 825 dev_dbg(&dev->pdev->dev,
846 _ep->name, 826 "%s queue req %p, len %u, buf %p, dma 0x%08x\n",
847 _req, _req->length, _req->buf, (unsigned long long)_req->dma); 827 _ep->name,
828 _req, _req->length, _req->buf, (int)_req->dma);
848 829
849 _req->status = -EINPROGRESS; 830 _req->status = -EINPROGRESS;
850 _req->actual = 0; 831 _req->actual = 0;
@@ -866,12 +847,12 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
866 847
867 if (likely(req != NULL)) { 848 if (likely(req != NULL)) {
868 list_add_tail(&req->queue, &ep->queue); 849 list_add_tail(&req->queue, &ep->queue);
869 VDBG(dev, "list_add_tail() \n"); 850 dev_vdbg(&dev->pdev->dev, "list_add_tail()\n");
870 } 851 }
871 852
872 spin_unlock_irqrestore(&dev->lock, flags); 853 spin_unlock_irqrestore(&dev->lock, flags);
873 854
874 VDBG(dev, "<--- %s()\n", __func__); 855 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
875 return 0; 856 return 0;
876} 857}
877 858
@@ -888,7 +869,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
888 869
889 ep = container_of(_ep, struct langwell_ep, ep); 870 ep = container_of(_ep, struct langwell_ep, ep);
890 dev = ep->dev; 871 dev = ep->dev;
891 VDBG(dev, "---> %s()\n", __func__); 872 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
892 873
893 if (!_ep || !ep->desc || !_req) 874 if (!_ep || !ep->desc || !_req)
894 return -EINVAL; 875 return -EINVAL;
@@ -924,7 +905,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
924 905
925 /* queue head may be partially complete. */ 906 /* queue head may be partially complete. */
926 if (ep->queue.next == &req->queue) { 907 if (ep->queue.next == &req->queue) {
927 DBG(dev, "unlink (%s) dma\n", _ep->name); 908 dev_dbg(&dev->pdev->dev, "unlink (%s) dma\n", _ep->name);
928 _req->status = -ECONNRESET; 909 _req->status = -ECONNRESET;
929 langwell_ep_fifo_flush(&ep->ep); 910 langwell_ep_fifo_flush(&ep->ep);
930 911
@@ -963,7 +944,7 @@ done:
963 ep->stopped = stopped; 944 ep->stopped = stopped;
964 spin_unlock_irqrestore(&dev->lock, flags); 945 spin_unlock_irqrestore(&dev->lock, flags);
965 946
966 VDBG(dev, "<--- %s()\n", __func__); 947 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
967 return retval; 948 return retval;
968} 949}
969 950
@@ -976,7 +957,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value)
976 u32 endptctrl = 0; 957 u32 endptctrl = 0;
977 int ep_num; 958 int ep_num;
978 struct langwell_udc *dev = ep->dev; 959 struct langwell_udc *dev = ep->dev;
979 VDBG(dev, "---> %s()\n", __func__); 960 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
980 961
981 ep_num = ep->ep_num; 962 ep_num = ep->ep_num;
982 endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); 963 endptctrl = readl(&dev->op_regs->endptctrl[ep_num]);
@@ -1001,7 +982,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value)
1001 982
1002 writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); 983 writel(endptctrl, &dev->op_regs->endptctrl[ep_num]);
1003 984
1004 VDBG(dev, "<--- %s()\n", __func__); 985 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1005} 986}
1006 987
1007 988
@@ -1016,7 +997,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
1016 ep = container_of(_ep, struct langwell_ep, ep); 997 ep = container_of(_ep, struct langwell_ep, ep);
1017 dev = ep->dev; 998 dev = ep->dev;
1018 999
1019 VDBG(dev, "---> %s()\n", __func__); 1000 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1020 1001
1021 if (!_ep || !ep->desc) 1002 if (!_ep || !ep->desc)
1022 return -EINVAL; 1003 return -EINVAL;
@@ -1024,8 +1005,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
1024 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) 1005 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
1025 return -ESHUTDOWN; 1006 return -ESHUTDOWN;
1026 1007
1027 if (ep->desc && (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 1008 if (usb_endpoint_xfer_isoc(ep->desc))
1028 == USB_ENDPOINT_XFER_ISOC)
1029 return -EOPNOTSUPP; 1009 return -EOPNOTSUPP;
1030 1010
1031 spin_lock_irqsave(&dev->lock, flags); 1011 spin_lock_irqsave(&dev->lock, flags);
@@ -1036,7 +1016,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
1036 */ 1016 */
1037 if (!list_empty(&ep->queue) && is_in(ep) && value) { 1017 if (!list_empty(&ep->queue) && is_in(ep) && value) {
1038 /* IN endpoint FIFO holds bytes */ 1018 /* IN endpoint FIFO holds bytes */
1039 DBG(dev, "%s FIFO holds bytes\n", _ep->name); 1019 dev_dbg(&dev->pdev->dev, "%s FIFO holds bytes\n", _ep->name);
1040 retval = -EAGAIN; 1020 retval = -EAGAIN;
1041 goto done; 1021 goto done;
1042 } 1022 }
@@ -1050,8 +1030,9 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
1050 } 1030 }
1051done: 1031done:
1052 spin_unlock_irqrestore(&dev->lock, flags); 1032 spin_unlock_irqrestore(&dev->lock, flags);
1053 DBG(dev, "%s %s halt\n", _ep->name, value ? "set" : "clear"); 1033 dev_dbg(&dev->pdev->dev, "%s %s halt\n",
1054 VDBG(dev, "<--- %s()\n", __func__); 1034 _ep->name, value ? "set" : "clear");
1035 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1055 return retval; 1036 return retval;
1056} 1037}
1057 1038
@@ -1065,12 +1046,12 @@ static int langwell_ep_set_wedge(struct usb_ep *_ep)
1065 ep = container_of(_ep, struct langwell_ep, ep); 1046 ep = container_of(_ep, struct langwell_ep, ep);
1066 dev = ep->dev; 1047 dev = ep->dev;
1067 1048
1068 VDBG(dev, "---> %s()\n", __func__); 1049 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1069 1050
1070 if (!_ep || !ep->desc) 1051 if (!_ep || !ep->desc)
1071 return -EINVAL; 1052 return -EINVAL;
1072 1053
1073 VDBG(dev, "<--- %s()\n", __func__); 1054 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1074 return usb_ep_set_halt(_ep); 1055 return usb_ep_set_halt(_ep);
1075} 1056}
1076 1057
@@ -1086,15 +1067,16 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep)
1086 ep = container_of(_ep, struct langwell_ep, ep); 1067 ep = container_of(_ep, struct langwell_ep, ep);
1087 dev = ep->dev; 1068 dev = ep->dev;
1088 1069
1089 VDBG(dev, "---> %s()\n", __func__); 1070 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1090 1071
1091 if (!_ep || !ep->desc) { 1072 if (!_ep || !ep->desc) {
1092 VDBG(dev, "ep or ep->desc is NULL\n"); 1073 dev_vdbg(&dev->pdev->dev, "ep or ep->desc is NULL\n");
1093 VDBG(dev, "<--- %s()\n", __func__); 1074 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1094 return; 1075 return;
1095 } 1076 }
1096 1077
1097 VDBG(dev, "%s-%s fifo flush\n", _ep->name, is_in(ep) ? "in" : "out"); 1078 dev_vdbg(&dev->pdev->dev, "%s-%s fifo flush\n",
1079 _ep->name, DIR_STRING(ep));
1098 1080
1099 /* flush endpoint buffer */ 1081 /* flush endpoint buffer */
1100 if (ep->ep_num == 0) 1082 if (ep->ep_num == 0)
@@ -1110,14 +1092,14 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep)
1110 writel(flush_bit, &dev->op_regs->endptflush); 1092 writel(flush_bit, &dev->op_regs->endptflush);
1111 while (readl(&dev->op_regs->endptflush)) { 1093 while (readl(&dev->op_regs->endptflush)) {
1112 if (time_after(jiffies, timeout)) { 1094 if (time_after(jiffies, timeout)) {
1113 ERROR(dev, "ep flush timeout\n"); 1095 dev_err(&dev->pdev->dev, "ep flush timeout\n");
1114 goto done; 1096 goto done;
1115 } 1097 }
1116 cpu_relax(); 1098 cpu_relax();
1117 } 1099 }
1118 } while (readl(&dev->op_regs->endptstat) & flush_bit); 1100 } while (readl(&dev->op_regs->endptstat) & flush_bit);
1119done: 1101done:
1120 VDBG(dev, "<--- %s()\n", __func__); 1102 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1121} 1103}
1122 1104
1123 1105
@@ -1167,31 +1149,59 @@ static int langwell_get_frame(struct usb_gadget *_gadget)
1167 return -ENODEV; 1149 return -ENODEV;
1168 1150
1169 dev = container_of(_gadget, struct langwell_udc, gadget); 1151 dev = container_of(_gadget, struct langwell_udc, gadget);
1170 VDBG(dev, "---> %s()\n", __func__); 1152 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1171 1153
1172 retval = readl(&dev->op_regs->frindex) & FRINDEX_MASK; 1154 retval = readl(&dev->op_regs->frindex) & FRINDEX_MASK;
1173 1155
1174 VDBG(dev, "<--- %s()\n", __func__); 1156 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1175 return retval; 1157 return retval;
1176} 1158}
1177 1159
1178 1160
1161/* enter or exit PHY low power state */
1162static void langwell_phy_low_power(struct langwell_udc *dev, bool flag)
1163{
1164 u32 devlc;
1165 u8 devlc_byte2;
1166 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
1167
1168 devlc = readl(&dev->op_regs->devlc);
1169 dev_vdbg(&dev->pdev->dev, "devlc = 0x%08x\n", devlc);
1170
1171 if (flag)
1172 devlc |= LPM_PHCD;
1173 else
1174 devlc &= ~LPM_PHCD;
1175
1176 /* FIXME: workaround for Langwell A1/A2/A3 sighting */
1177 devlc_byte2 = (devlc >> 16) & 0xff;
1178 writeb(devlc_byte2, (u8 *)&dev->op_regs->devlc + 2);
1179
1180 devlc = readl(&dev->op_regs->devlc);
1181 dev_vdbg(&dev->pdev->dev,
1182 "%s PHY low power suspend, devlc = 0x%08x\n",
1183 flag ? "enter" : "exit", devlc);
1184}
1185
1186
1179/* tries to wake up the host connected to this gadget */ 1187/* tries to wake up the host connected to this gadget */
1180static int langwell_wakeup(struct usb_gadget *_gadget) 1188static int langwell_wakeup(struct usb_gadget *_gadget)
1181{ 1189{
1182 struct langwell_udc *dev; 1190 struct langwell_udc *dev;
1183 u32 portsc1, devlc; 1191 u32 portsc1;
1184 unsigned long flags; 1192 unsigned long flags;
1185 1193
1186 if (!_gadget) 1194 if (!_gadget)
1187 return 0; 1195 return 0;
1188 1196
1189 dev = container_of(_gadget, struct langwell_udc, gadget); 1197 dev = container_of(_gadget, struct langwell_udc, gadget);
1190 VDBG(dev, "---> %s()\n", __func__); 1198 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1191 1199
1192 /* Remote Wakeup feature not enabled by host */ 1200 /* remote wakeup feature not enabled by host */
1193 if (!dev->remote_wakeup) 1201 if (!dev->remote_wakeup) {
1202 dev_info(&dev->pdev->dev, "remote wakeup is disabled\n");
1194 return -ENOTSUPP; 1203 return -ENOTSUPP;
1204 }
1195 1205
1196 spin_lock_irqsave(&dev->lock, flags); 1206 spin_lock_irqsave(&dev->lock, flags);
1197 1207
@@ -1201,27 +1211,23 @@ static int langwell_wakeup(struct usb_gadget *_gadget)
1201 return 0; 1211 return 0;
1202 } 1212 }
1203 1213
1204 /* LPM L1 to L0, remote wakeup */ 1214 /* LPM L1 to L0 or legacy remote wakeup */
1205 if (dev->lpm && dev->lpm_state == LPM_L1) { 1215 if (dev->lpm && dev->lpm_state == LPM_L1)
1206 portsc1 |= PORTS_SLP; 1216 dev_info(&dev->pdev->dev, "LPM L1 to L0 remote wakeup\n");
1207 writel(portsc1, &dev->op_regs->portsc1); 1217 else
1208 } 1218 dev_info(&dev->pdev->dev, "device remote wakeup\n");
1209
1210 /* force port resume */
1211 if (dev->usb_state == USB_STATE_SUSPENDED) {
1212 portsc1 |= PORTS_FPR;
1213 writel(portsc1, &dev->op_regs->portsc1);
1214 }
1215 1219
1216 /* exit PHY low power suspend */ 1220 /* exit PHY low power suspend */
1217 devlc = readl(&dev->op_regs->devlc); 1221 if (dev->pdev->device != 0x0829)
1218 VDBG(dev, "devlc = 0x%08x\n", devlc); 1222 langwell_phy_low_power(dev, 0);
1219 devlc &= ~LPM_PHCD; 1223
1220 writel(devlc, &dev->op_regs->devlc); 1224 /* force port resume */
1225 portsc1 |= PORTS_FPR;
1226 writel(portsc1, &dev->op_regs->portsc1);
1221 1227
1222 spin_unlock_irqrestore(&dev->lock, flags); 1228 spin_unlock_irqrestore(&dev->lock, flags);
1223 1229
1224 VDBG(dev, "<--- %s()\n", __func__); 1230 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1225 return 0; 1231 return 0;
1226} 1232}
1227 1233
@@ -1231,16 +1237,17 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active)
1231{ 1237{
1232 struct langwell_udc *dev; 1238 struct langwell_udc *dev;
1233 unsigned long flags; 1239 unsigned long flags;
1234 u32 usbcmd; 1240 u32 usbcmd;
1235 1241
1236 if (!_gadget) 1242 if (!_gadget)
1237 return -ENODEV; 1243 return -ENODEV;
1238 1244
1239 dev = container_of(_gadget, struct langwell_udc, gadget); 1245 dev = container_of(_gadget, struct langwell_udc, gadget);
1240 VDBG(dev, "---> %s()\n", __func__); 1246 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1241 1247
1242 spin_lock_irqsave(&dev->lock, flags); 1248 spin_lock_irqsave(&dev->lock, flags);
1243 VDBG(dev, "VBUS status: %s\n", is_active ? "on" : "off"); 1249 dev_vdbg(&dev->pdev->dev, "VBUS status: %s\n",
1250 is_active ? "on" : "off");
1244 1251
1245 dev->vbus_active = (is_active != 0); 1252 dev->vbus_active = (is_active != 0);
1246 if (dev->driver && dev->softconnected && dev->vbus_active) { 1253 if (dev->driver && dev->softconnected && dev->vbus_active) {
@@ -1255,7 +1262,7 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active)
1255 1262
1256 spin_unlock_irqrestore(&dev->lock, flags); 1263 spin_unlock_irqrestore(&dev->lock, flags);
1257 1264
1258 VDBG(dev, "<--- %s()\n", __func__); 1265 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1259 return 0; 1266 return 0;
1260} 1267}
1261 1268
@@ -1269,15 +1276,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
1269 return -ENODEV; 1276 return -ENODEV;
1270 1277
1271 dev = container_of(_gadget, struct langwell_udc, gadget); 1278 dev = container_of(_gadget, struct langwell_udc, gadget);
1272 VDBG(dev, "---> %s()\n", __func__); 1279 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1273 1280
1274 if (dev->transceiver) { 1281 if (dev->transceiver) {
1275 VDBG(dev, "otg_set_power\n"); 1282 dev_vdbg(&dev->pdev->dev, "otg_set_power\n");
1276 VDBG(dev, "<--- %s()\n", __func__); 1283 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1277 return otg_set_power(dev->transceiver, mA); 1284 return otg_set_power(dev->transceiver, mA);
1278 } 1285 }
1279 1286
1280 VDBG(dev, "<--- %s()\n", __func__); 1287 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1281 return -ENOTSUPP; 1288 return -ENOTSUPP;
1282} 1289}
1283 1290
@@ -1286,15 +1293,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
1286static int langwell_pullup(struct usb_gadget *_gadget, int is_on) 1293static int langwell_pullup(struct usb_gadget *_gadget, int is_on)
1287{ 1294{
1288 struct langwell_udc *dev; 1295 struct langwell_udc *dev;
1289 u32 usbcmd; 1296 u32 usbcmd;
1290 unsigned long flags; 1297 unsigned long flags;
1291 1298
1292 if (!_gadget) 1299 if (!_gadget)
1293 return -ENODEV; 1300 return -ENODEV;
1294 1301
1295 dev = container_of(_gadget, struct langwell_udc, gadget); 1302 dev = container_of(_gadget, struct langwell_udc, gadget);
1296 1303
1297 VDBG(dev, "---> %s()\n", __func__); 1304 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1298 1305
1299 spin_lock_irqsave(&dev->lock, flags); 1306 spin_lock_irqsave(&dev->lock, flags);
1300 dev->softconnected = (is_on != 0); 1307 dev->softconnected = (is_on != 0);
@@ -1310,7 +1317,7 @@ static int langwell_pullup(struct usb_gadget *_gadget, int is_on)
1310 } 1317 }
1311 spin_unlock_irqrestore(&dev->lock, flags); 1318 spin_unlock_irqrestore(&dev->lock, flags);
1312 1319
1313 VDBG(dev, "<--- %s()\n", __func__); 1320 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1314 return 0; 1321 return 0;
1315} 1322}
1316 1323
@@ -1346,12 +1353,13 @@ static const struct usb_gadget_ops langwell_ops = {
1346static int langwell_udc_reset(struct langwell_udc *dev) 1353static int langwell_udc_reset(struct langwell_udc *dev)
1347{ 1354{
1348 u32 usbcmd, usbmode, devlc, endpointlistaddr; 1355 u32 usbcmd, usbmode, devlc, endpointlistaddr;
1356 u8 devlc_byte0, devlc_byte2;
1349 unsigned long timeout; 1357 unsigned long timeout;
1350 1358
1351 if (!dev) 1359 if (!dev)
1352 return -EINVAL; 1360 return -EINVAL;
1353 1361
1354 DBG(dev, "---> %s()\n", __func__); 1362 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
1355 1363
1356 /* set controller to stop state */ 1364 /* set controller to stop state */
1357 usbcmd = readl(&dev->op_regs->usbcmd); 1365 usbcmd = readl(&dev->op_regs->usbcmd);
@@ -1367,7 +1375,7 @@ static int langwell_udc_reset(struct langwell_udc *dev)
1367 timeout = jiffies + RESET_TIMEOUT; 1375 timeout = jiffies + RESET_TIMEOUT;
1368 while (readl(&dev->op_regs->usbcmd) & CMD_RST) { 1376 while (readl(&dev->op_regs->usbcmd) & CMD_RST) {
1369 if (time_after(jiffies, timeout)) { 1377 if (time_after(jiffies, timeout)) {
1370 ERROR(dev, "device reset timeout\n"); 1378 dev_err(&dev->pdev->dev, "device reset timeout\n");
1371 return -ETIMEDOUT; 1379 return -ETIMEDOUT;
1372 } 1380 }
1373 cpu_relax(); 1381 cpu_relax();
@@ -1382,7 +1390,7 @@ static int langwell_udc_reset(struct langwell_udc *dev)
1382 1390
1383 writel(usbmode, &dev->op_regs->usbmode); 1391 writel(usbmode, &dev->op_regs->usbmode);
1384 usbmode = readl(&dev->op_regs->usbmode); 1392 usbmode = readl(&dev->op_regs->usbmode);
1385 VDBG(dev, "usbmode=0x%08x\n", usbmode); 1393 dev_vdbg(&dev->pdev->dev, "usbmode=0x%08x\n", usbmode);
1386 1394
1387 /* Write-Clear setup status */ 1395 /* Write-Clear setup status */
1388 writel(0, &dev->op_regs->usbsts); 1396 writel(0, &dev->op_regs->usbsts);
@@ -1390,9 +1398,17 @@ static int langwell_udc_reset(struct langwell_udc *dev)
1390 /* if support USB LPM, ACK all LPM token */ 1398 /* if support USB LPM, ACK all LPM token */
1391 if (dev->lpm) { 1399 if (dev->lpm) {
1392 devlc = readl(&dev->op_regs->devlc); 1400 devlc = readl(&dev->op_regs->devlc);
1401 dev_vdbg(&dev->pdev->dev, "devlc = 0x%08x\n", devlc);
1402 /* FIXME: workaround for Langwell A1/A2/A3 sighting */
1393 devlc &= ~LPM_STL; /* don't STALL LPM token */ 1403 devlc &= ~LPM_STL; /* don't STALL LPM token */
1394 devlc &= ~LPM_NYT_ACK; /* ACK LPM token */ 1404 devlc &= ~LPM_NYT_ACK; /* ACK LPM token */
1395 writel(devlc, &dev->op_regs->devlc); 1405 devlc_byte0 = devlc & 0xff;
1406 devlc_byte2 = (devlc >> 16) & 0xff;
1407 writeb(devlc_byte0, (u8 *)&dev->op_regs->devlc);
1408 writeb(devlc_byte2, (u8 *)&dev->op_regs->devlc + 2);
1409 devlc = readl(&dev->op_regs->devlc);
1410 dev_vdbg(&dev->pdev->dev,
1411 "ACK LPM token, devlc = 0x%08x\n", devlc);
1396 } 1412 }
1397 1413
1398 /* fill endpointlistaddr register */ 1414 /* fill endpointlistaddr register */
@@ -1400,10 +1416,11 @@ static int langwell_udc_reset(struct langwell_udc *dev)
1400 endpointlistaddr &= ENDPOINTLISTADDR_MASK; 1416 endpointlistaddr &= ENDPOINTLISTADDR_MASK;
1401 writel(endpointlistaddr, &dev->op_regs->endpointlistaddr); 1417 writel(endpointlistaddr, &dev->op_regs->endpointlistaddr);
1402 1418
1403 VDBG(dev, "dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n", 1419 dev_vdbg(&dev->pdev->dev,
1404 dev->ep_dqh, endpointlistaddr, 1420 "dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n",
1405 readl(&dev->op_regs->endpointlistaddr)); 1421 dev->ep_dqh, endpointlistaddr,
1406 DBG(dev, "<--- %s()\n", __func__); 1422 readl(&dev->op_regs->endpointlistaddr));
1423 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1407 return 0; 1424 return 0;
1408} 1425}
1409 1426
@@ -1415,7 +1432,7 @@ static int eps_reinit(struct langwell_udc *dev)
1415 char name[14]; 1432 char name[14];
1416 int i; 1433 int i;
1417 1434
1418 VDBG(dev, "---> %s()\n", __func__); 1435 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1419 1436
1420 /* initialize ep0 */ 1437 /* initialize ep0 */
1421 ep = &dev->ep[0]; 1438 ep = &dev->ep[0];
@@ -1449,11 +1466,9 @@ static int eps_reinit(struct langwell_udc *dev)
1449 1466
1450 INIT_LIST_HEAD(&ep->queue); 1467 INIT_LIST_HEAD(&ep->queue);
1451 list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); 1468 list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list);
1452
1453 ep->dqh = &dev->ep_dqh[i];
1454 } 1469 }
1455 1470
1456 VDBG(dev, "<--- %s()\n", __func__); 1471 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1457 return 0; 1472 return 0;
1458} 1473}
1459 1474
@@ -1462,7 +1477,7 @@ static int eps_reinit(struct langwell_udc *dev)
1462static void langwell_udc_start(struct langwell_udc *dev) 1477static void langwell_udc_start(struct langwell_udc *dev)
1463{ 1478{
1464 u32 usbintr, usbcmd; 1479 u32 usbintr, usbcmd;
1465 DBG(dev, "---> %s()\n", __func__); 1480 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
1466 1481
1467 /* enable interrupts */ 1482 /* enable interrupts */
1468 usbintr = INTR_ULPIE /* ULPI */ 1483 usbintr = INTR_ULPIE /* ULPI */
@@ -1485,8 +1500,7 @@ static void langwell_udc_start(struct langwell_udc *dev)
1485 usbcmd |= CMD_RUNSTOP; 1500 usbcmd |= CMD_RUNSTOP;
1486 writel(usbcmd, &dev->op_regs->usbcmd); 1501 writel(usbcmd, &dev->op_regs->usbcmd);
1487 1502
1488 DBG(dev, "<--- %s()\n", __func__); 1503 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1489 return;
1490} 1504}
1491 1505
1492 1506
@@ -1495,7 +1509,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
1495{ 1509{
1496 u32 usbcmd; 1510 u32 usbcmd;
1497 1511
1498 DBG(dev, "---> %s()\n", __func__); 1512 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
1499 1513
1500 /* disable all interrupts */ 1514 /* disable all interrupts */
1501 writel(0, &dev->op_regs->usbintr); 1515 writel(0, &dev->op_regs->usbintr);
@@ -1508,8 +1522,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
1508 usbcmd &= ~CMD_RUNSTOP; 1522 usbcmd &= ~CMD_RUNSTOP;
1509 writel(usbcmd, &dev->op_regs->usbcmd); 1523 writel(usbcmd, &dev->op_regs->usbcmd);
1510 1524
1511 DBG(dev, "<--- %s()\n", __func__); 1525 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1512 return;
1513} 1526}
1514 1527
1515 1528
@@ -1518,7 +1531,7 @@ static void stop_activity(struct langwell_udc *dev,
1518 struct usb_gadget_driver *driver) 1531 struct usb_gadget_driver *driver)
1519{ 1532{
1520 struct langwell_ep *ep; 1533 struct langwell_ep *ep;
1521 DBG(dev, "---> %s()\n", __func__); 1534 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
1522 1535
1523 nuke(&dev->ep[0], -ESHUTDOWN); 1536 nuke(&dev->ep[0], -ESHUTDOWN);
1524 1537
@@ -1533,7 +1546,7 @@ static void stop_activity(struct langwell_udc *dev,
1533 spin_lock(&dev->lock); 1546 spin_lock(&dev->lock);
1534 } 1547 }
1535 1548
1536 DBG(dev, "<--- %s()\n", __func__); 1549 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1537} 1550}
1538 1551
1539 1552
@@ -1659,13 +1672,15 @@ static ssize_t show_langwell_udc(struct device *_dev,
1659 "Over-current Change: %s\n" 1672 "Over-current Change: %s\n"
1660 "Port Enable/Disable Change: %s\n" 1673 "Port Enable/Disable Change: %s\n"
1661 "Port Enabled/Disabled: %s\n" 1674 "Port Enabled/Disabled: %s\n"
1662 "Current Connect Status: %s\n\n", 1675 "Current Connect Status: %s\n"
1676 "LPM Suspend Status: %s\n\n",
1663 (tmp_reg & PORTS_PR) ? "Reset" : "Not Reset", 1677 (tmp_reg & PORTS_PR) ? "Reset" : "Not Reset",
1664 (tmp_reg & PORTS_SUSP) ? "Suspend " : "Not Suspend", 1678 (tmp_reg & PORTS_SUSP) ? "Suspend " : "Not Suspend",
1665 (tmp_reg & PORTS_OCC) ? "Detected" : "No", 1679 (tmp_reg & PORTS_OCC) ? "Detected" : "No",
1666 (tmp_reg & PORTS_PEC) ? "Changed" : "Not Changed", 1680 (tmp_reg & PORTS_PEC) ? "Changed" : "Not Changed",
1667 (tmp_reg & PORTS_PE) ? "Enable" : "Not Correct", 1681 (tmp_reg & PORTS_PE) ? "Enable" : "Not Correct",
1668 (tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached"); 1682 (tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached",
1683 (tmp_reg & PORTS_SLP) ? "LPM L1" : "LPM L0");
1669 size -= t; 1684 size -= t;
1670 next += t; 1685 next += t;
1671 1686
@@ -1676,7 +1691,7 @@ static ssize_t show_langwell_udc(struct device *_dev,
1676 "Serial Transceiver : %d\n" 1691 "Serial Transceiver : %d\n"
1677 "Port Speed: %s\n" 1692 "Port Speed: %s\n"
1678 "Port Force Full Speed Connenct: %s\n" 1693 "Port Force Full Speed Connenct: %s\n"
1679 "PHY Low Power Suspend Clock Disable: %s\n" 1694 "PHY Low Power Suspend Clock: %s\n"
1680 "BmAttributes: %d\n\n", 1695 "BmAttributes: %d\n\n",
1681 LPM_PTS(tmp_reg), 1696 LPM_PTS(tmp_reg),
1682 (tmp_reg & LPM_STS) ? 1 : 0, 1697 (tmp_reg & LPM_STS) ? 1 : 0,
@@ -1797,6 +1812,36 @@ static ssize_t show_langwell_udc(struct device *_dev,
1797static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL); 1812static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL);
1798 1813
1799 1814
1815/* device "remote_wakeup" sysfs attribute file */
1816static ssize_t store_remote_wakeup(struct device *_dev,
1817 struct device_attribute *attr, const char *buf, size_t count)
1818{
1819 struct langwell_udc *dev = the_controller;
1820 unsigned long flags;
1821 ssize_t rc = count;
1822
1823 if (count > 2)
1824 return -EINVAL;
1825
1826 if (count > 0 && buf[count-1] == '\n')
1827 ((char *) buf)[count-1] = 0;
1828
1829 if (buf[0] != '1')
1830 return -EINVAL;
1831
1832 /* force remote wakeup enabled in case gadget driver doesn't support */
1833 spin_lock_irqsave(&dev->lock, flags);
1834 dev->remote_wakeup = 1;
1835 dev->dev_status |= (1 << USB_DEVICE_REMOTE_WAKEUP);
1836 spin_unlock_irqrestore(&dev->lock, flags);
1837
1838 langwell_wakeup(&dev->gadget);
1839
1840 return rc;
1841}
1842static DEVICE_ATTR(remote_wakeup, S_IWUSR, NULL, store_remote_wakeup);
1843
1844
1800/*-------------------------------------------------------------------------*/ 1845/*-------------------------------------------------------------------------*/
1801 1846
1802/* 1847/*
@@ -1807,7 +1852,8 @@ static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL);
1807 * the driver might get unbound. 1852 * the driver might get unbound.
1808 */ 1853 */
1809 1854
1810int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1855int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1856 int (*bind)(struct usb_gadget *))
1811{ 1857{
1812 struct langwell_udc *dev = the_controller; 1858 struct langwell_udc *dev = the_controller;
1813 unsigned long flags; 1859 unsigned long flags;
@@ -1816,7 +1862,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1816 if (!dev) 1862 if (!dev)
1817 return -ENODEV; 1863 return -ENODEV;
1818 1864
1819 DBG(dev, "---> %s()\n", __func__); 1865 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
1820 1866
1821 if (dev->driver) 1867 if (dev->driver)
1822 return -EBUSY; 1868 return -EBUSY;
@@ -1830,9 +1876,9 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1830 1876
1831 spin_unlock_irqrestore(&dev->lock, flags); 1877 spin_unlock_irqrestore(&dev->lock, flags);
1832 1878
1833 retval = driver->bind(&dev->gadget); 1879 retval = bind(&dev->gadget);
1834 if (retval) { 1880 if (retval) {
1835 DBG(dev, "bind to driver %s --> %d\n", 1881 dev_dbg(&dev->pdev->dev, "bind to driver %s --> %d\n",
1836 driver->driver.name, retval); 1882 driver->driver.name, retval);
1837 dev->driver = NULL; 1883 dev->driver = NULL;
1838 dev->gadget.dev.driver = NULL; 1884 dev->gadget.dev.driver = NULL;
@@ -1851,13 +1897,13 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1851 if (dev->got_irq) 1897 if (dev->got_irq)
1852 langwell_udc_start(dev); 1898 langwell_udc_start(dev);
1853 1899
1854 VDBG(dev, "After langwell_udc_start(), print all registers:\n"); 1900 dev_vdbg(&dev->pdev->dev,
1855#ifdef VERBOSE 1901 "After langwell_udc_start(), print all registers:\n");
1856 print_all_registers(dev); 1902 print_all_registers(dev);
1857#endif
1858 1903
1859 INFO(dev, "register driver: %s\n", driver->driver.name); 1904 dev_info(&dev->pdev->dev, "register driver: %s\n",
1860 VDBG(dev, "<--- %s()\n", __func__); 1905 driver->driver.name);
1906 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1861 return 0; 1907 return 0;
1862 1908
1863err_unbind: 1909err_unbind:
@@ -1865,10 +1911,10 @@ err_unbind:
1865 dev->gadget.dev.driver = NULL; 1911 dev->gadget.dev.driver = NULL;
1866 dev->driver = NULL; 1912 dev->driver = NULL;
1867 1913
1868 DBG(dev, "<--- %s()\n", __func__); 1914 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1869 return retval; 1915 return retval;
1870} 1916}
1871EXPORT_SYMBOL(usb_gadget_register_driver); 1917EXPORT_SYMBOL(usb_gadget_probe_driver);
1872 1918
1873 1919
1874/* unregister gadget driver */ 1920/* unregister gadget driver */
@@ -1880,11 +1926,15 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1880 if (!dev) 1926 if (!dev)
1881 return -ENODEV; 1927 return -ENODEV;
1882 1928
1883 DBG(dev, "---> %s()\n", __func__); 1929 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
1884 1930
1885 if (unlikely(!driver || !driver->bind || !driver->unbind)) 1931 if (unlikely(!driver || !driver->unbind))
1886 return -EINVAL; 1932 return -EINVAL;
1887 1933
1934 /* exit PHY low power suspend */
1935 if (dev->pdev->device != 0x0829)
1936 langwell_phy_low_power(dev, 0);
1937
1888 /* unbind OTG transceiver */ 1938 /* unbind OTG transceiver */
1889 if (dev->transceiver) 1939 if (dev->transceiver)
1890 (void)otg_set_peripheral(dev->transceiver, 0); 1940 (void)otg_set_peripheral(dev->transceiver, 0);
@@ -1910,8 +1960,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1910 1960
1911 device_remove_file(&dev->pdev->dev, &dev_attr_function); 1961 device_remove_file(&dev->pdev->dev, &dev_attr_function);
1912 1962
1913 INFO(dev, "unregistered driver '%s'\n", driver->driver.name); 1963 dev_info(&dev->pdev->dev, "unregistered driver '%s'\n",
1914 DBG(dev, "<--- %s()\n", __func__); 1964 driver->driver.name);
1965 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1915 return 0; 1966 return 0;
1916} 1967}
1917EXPORT_SYMBOL(usb_gadget_unregister_driver); 1968EXPORT_SYMBOL(usb_gadget_unregister_driver);
@@ -1930,7 +1981,7 @@ static void setup_tripwire(struct langwell_udc *dev)
1930 unsigned long timeout; 1981 unsigned long timeout;
1931 struct langwell_dqh *dqh; 1982 struct langwell_dqh *dqh;
1932 1983
1933 VDBG(dev, "---> %s()\n", __func__); 1984 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1934 1985
1935 /* ep0 OUT dQH */ 1986 /* ep0 OUT dQH */
1936 dqh = &dev->ep_dqh[EP_DIR_OUT]; 1987 dqh = &dev->ep_dqh[EP_DIR_OUT];
@@ -1943,7 +1994,7 @@ static void setup_tripwire(struct langwell_udc *dev)
1943 timeout = jiffies + SETUPSTAT_TIMEOUT; 1994 timeout = jiffies + SETUPSTAT_TIMEOUT;
1944 while (readl(&dev->op_regs->endptsetupstat)) { 1995 while (readl(&dev->op_regs->endptsetupstat)) {
1945 if (time_after(jiffies, timeout)) { 1996 if (time_after(jiffies, timeout)) {
1946 ERROR(dev, "setup_tripwire timeout\n"); 1997 dev_err(&dev->pdev->dev, "setup_tripwire timeout\n");
1947 break; 1998 break;
1948 } 1999 }
1949 cpu_relax(); 2000 cpu_relax();
@@ -1963,7 +2014,7 @@ static void setup_tripwire(struct langwell_udc *dev)
1963 usbcmd = readl(&dev->op_regs->usbcmd); 2014 usbcmd = readl(&dev->op_regs->usbcmd);
1964 writel(usbcmd & ~CMD_SUTW, &dev->op_regs->usbcmd); 2015 writel(usbcmd & ~CMD_SUTW, &dev->op_regs->usbcmd);
1965 2016
1966 VDBG(dev, "<--- %s()\n", __func__); 2017 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1967} 2018}
1968 2019
1969 2020
@@ -1972,7 +2023,7 @@ static void ep0_stall(struct langwell_udc *dev)
1972{ 2023{
1973 u32 endptctrl; 2024 u32 endptctrl;
1974 2025
1975 VDBG(dev, "---> %s()\n", __func__); 2026 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1976 2027
1977 /* set TX and RX to stall */ 2028 /* set TX and RX to stall */
1978 endptctrl = readl(&dev->op_regs->endptctrl[0]); 2029 endptctrl = readl(&dev->op_regs->endptctrl[0]);
@@ -1983,7 +2034,7 @@ static void ep0_stall(struct langwell_udc *dev)
1983 dev->ep0_state = WAIT_FOR_SETUP; 2034 dev->ep0_state = WAIT_FOR_SETUP;
1984 dev->ep0_dir = USB_DIR_OUT; 2035 dev->ep0_dir = USB_DIR_OUT;
1985 2036
1986 VDBG(dev, "<--- %s()\n", __func__); 2037 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
1987} 2038}
1988 2039
1989 2040
@@ -1994,7 +2045,7 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
1994 struct langwell_ep *ep; 2045 struct langwell_ep *ep;
1995 int status = 0; 2046 int status = 0;
1996 2047
1997 VDBG(dev, "---> %s()\n", __func__); 2048 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
1998 2049
1999 if (dir == EP_DIR_IN) 2050 if (dir == EP_DIR_IN)
2000 dev->ep0_dir = USB_DIR_IN; 2051 dev->ep0_dir = USB_DIR_IN;
@@ -2019,11 +2070,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
2019 return -ENOMEM; 2070 return -ENOMEM;
2020 2071
2021 if (status) 2072 if (status)
2022 ERROR(dev, "can't queue ep0 status request\n"); 2073 dev_err(&dev->pdev->dev, "can't queue ep0 status request\n");
2023 2074
2024 list_add_tail(&req->queue, &ep->queue); 2075 list_add_tail(&req->queue, &ep->queue);
2025 2076
2026 VDBG(dev, "<--- %s()\n", __func__); 2077 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2027 return status; 2078 return status;
2028} 2079}
2029 2080
@@ -2032,11 +2083,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
2032static void set_address(struct langwell_udc *dev, u16 value, 2083static void set_address(struct langwell_udc *dev, u16 value,
2033 u16 index, u16 length) 2084 u16 index, u16 length)
2034{ 2085{
2035 VDBG(dev, "---> %s()\n", __func__); 2086 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2036 2087
2037 /* save the new address to device struct */ 2088 /* save the new address to device struct */
2038 dev->dev_addr = (u8) value; 2089 dev->dev_addr = (u8) value;
2039 VDBG(dev, "dev->dev_addr = %d\n", dev->dev_addr); 2090 dev_vdbg(&dev->pdev->dev, "dev->dev_addr = %d\n", dev->dev_addr);
2040 2091
2041 /* update usb state */ 2092 /* update usb state */
2042 dev->usb_state = USB_STATE_ADDRESS; 2093 dev->usb_state = USB_STATE_ADDRESS;
@@ -2045,7 +2096,7 @@ static void set_address(struct langwell_udc *dev, u16 value,
2045 if (prime_status_phase(dev, EP_DIR_IN)) 2096 if (prime_status_phase(dev, EP_DIR_IN))
2046 ep0_stall(dev); 2097 ep0_stall(dev);
2047 2098
2048 VDBG(dev, "<--- %s()\n", __func__); 2099 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2049} 2100}
2050 2101
2051 2102
@@ -2054,7 +2105,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev,
2054 u16 wIndex) 2105 u16 wIndex)
2055{ 2106{
2056 struct langwell_ep *ep; 2107 struct langwell_ep *ep;
2057 VDBG(dev, "---> %s()\n", __func__); 2108 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2058 2109
2059 if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0) 2110 if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0)
2060 return &dev->ep[0]; 2111 return &dev->ep[0];
@@ -2073,7 +2124,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev,
2073 return ep; 2124 return ep;
2074 } 2125 }
2075 2126
2076 VDBG(dev, "<--- %s()\n", __func__); 2127 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2077 return NULL; 2128 return NULL;
2078} 2129}
2079 2130
@@ -2085,7 +2136,7 @@ static int ep_is_stall(struct langwell_ep *ep)
2085 u32 endptctrl; 2136 u32 endptctrl;
2086 int retval; 2137 int retval;
2087 2138
2088 VDBG(dev, "---> %s()\n", __func__); 2139 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2089 2140
2090 endptctrl = readl(&dev->op_regs->endptctrl[ep->ep_num]); 2141 endptctrl = readl(&dev->op_regs->endptctrl[ep->ep_num]);
2091 if (is_in(ep)) 2142 if (is_in(ep))
@@ -2093,7 +2144,7 @@ static int ep_is_stall(struct langwell_ep *ep)
2093 else 2144 else
2094 retval = endptctrl & EPCTRL_RXS ? 1 : 0; 2145 retval = endptctrl & EPCTRL_RXS ? 1 : 0;
2095 2146
2096 VDBG(dev, "<--- %s()\n", __func__); 2147 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2097 return retval; 2148 return retval;
2098} 2149}
2099 2150
@@ -2107,14 +2158,13 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
2107 u16 status_data = 0; /* 16 bits cpu view status data */ 2158 u16 status_data = 0; /* 16 bits cpu view status data */
2108 int status = 0; 2159 int status = 0;
2109 2160
2110 VDBG(dev, "---> %s()\n", __func__); 2161 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2111 2162
2112 ep = &dev->ep[0]; 2163 ep = &dev->ep[0];
2113 2164
2114 if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) { 2165 if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) {
2115 /* get device status */ 2166 /* get device status */
2116 status_data = 1 << USB_DEVICE_SELF_POWERED; 2167 status_data = dev->dev_status;
2117 status_data |= dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP;
2118 } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) { 2168 } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) {
2119 /* get interface status */ 2169 /* get interface status */
2120 status_data = 0; 2170 status_data = 0;
@@ -2129,6 +2179,8 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
2129 status_data = ep_is_stall(epn) << USB_ENDPOINT_HALT; 2179 status_data = ep_is_stall(epn) << USB_ENDPOINT_HALT;
2130 } 2180 }
2131 2181
2182 dev_dbg(&dev->pdev->dev, "get status data: 0x%04x\n", status_data);
2183
2132 dev->ep0_dir = USB_DIR_IN; 2184 dev->ep0_dir = USB_DIR_IN;
2133 2185
2134 /* borrow the per device status_req */ 2186 /* borrow the per device status_req */
@@ -2150,18 +2202,19 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
2150 goto stall; 2202 goto stall;
2151 2203
2152 if (status) { 2204 if (status) {
2153 ERROR(dev, "response error on GET_STATUS request\n"); 2205 dev_err(&dev->pdev->dev,
2206 "response error on GET_STATUS request\n");
2154 goto stall; 2207 goto stall;
2155 } 2208 }
2156 2209
2157 list_add_tail(&req->queue, &ep->queue); 2210 list_add_tail(&req->queue, &ep->queue);
2158 dev->ep0_state = DATA_STATE_XMIT; 2211 dev->ep0_state = DATA_STATE_XMIT;
2159 2212
2160 VDBG(dev, "<--- %s()\n", __func__); 2213 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2161 return; 2214 return;
2162stall: 2215stall:
2163 ep0_stall(dev); 2216 ep0_stall(dev);
2164 VDBG(dev, "<--- %s()\n", __func__); 2217 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2165} 2218}
2166 2219
2167 2220
@@ -2173,12 +2226,12 @@ static void handle_setup_packet(struct langwell_udc *dev,
2173 u16 wIndex = le16_to_cpu(setup->wIndex); 2226 u16 wIndex = le16_to_cpu(setup->wIndex);
2174 u16 wLength = le16_to_cpu(setup->wLength); 2227 u16 wLength = le16_to_cpu(setup->wLength);
2175 2228
2176 VDBG(dev, "---> %s()\n", __func__); 2229 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2177 2230
2178 /* ep0 fifo flush */ 2231 /* ep0 fifo flush */
2179 nuke(&dev->ep[0], -ESHUTDOWN); 2232 nuke(&dev->ep[0], -ESHUTDOWN);
2180 2233
2181 DBG(dev, "SETUP %02x.%02x v%04x i%04x l%04x\n", 2234 dev_dbg(&dev->pdev->dev, "SETUP %02x.%02x v%04x i%04x l%04x\n",
2182 setup->bRequestType, setup->bRequest, 2235 setup->bRequestType, setup->bRequest,
2183 wValue, wIndex, wLength); 2236 wValue, wIndex, wLength);
2184 2237
@@ -2197,7 +2250,7 @@ static void handle_setup_packet(struct langwell_udc *dev,
2197 /* We process some stardard setup requests here */ 2250 /* We process some stardard setup requests here */
2198 switch (setup->bRequest) { 2251 switch (setup->bRequest) {
2199 case USB_REQ_GET_STATUS: 2252 case USB_REQ_GET_STATUS:
2200 DBG(dev, "SETUP: USB_REQ_GET_STATUS\n"); 2253 dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_GET_STATUS\n");
2201 /* get status, DATA and STATUS phase */ 2254 /* get status, DATA and STATUS phase */
2202 if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK)) 2255 if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK))
2203 != (USB_DIR_IN | USB_TYPE_STANDARD)) 2256 != (USB_DIR_IN | USB_TYPE_STANDARD))
@@ -2206,7 +2259,7 @@ static void handle_setup_packet(struct langwell_udc *dev,
2206 goto end; 2259 goto end;
2207 2260
2208 case USB_REQ_SET_ADDRESS: 2261 case USB_REQ_SET_ADDRESS:
2209 DBG(dev, "SETUP: USB_REQ_SET_ADDRESS\n"); 2262 dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_SET_ADDRESS\n");
2210 /* STATUS phase */ 2263 /* STATUS phase */
2211 if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD 2264 if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD
2212 | USB_RECIP_DEVICE)) 2265 | USB_RECIP_DEVICE))
@@ -2220,9 +2273,11 @@ static void handle_setup_packet(struct langwell_udc *dev,
2220 { 2273 {
2221 int rc = -EOPNOTSUPP; 2274 int rc = -EOPNOTSUPP;
2222 if (setup->bRequest == USB_REQ_SET_FEATURE) 2275 if (setup->bRequest == USB_REQ_SET_FEATURE)
2223 DBG(dev, "SETUP: USB_REQ_SET_FEATURE\n"); 2276 dev_dbg(&dev->pdev->dev,
2277 "SETUP: USB_REQ_SET_FEATURE\n");
2224 else if (setup->bRequest == USB_REQ_CLEAR_FEATURE) 2278 else if (setup->bRequest == USB_REQ_CLEAR_FEATURE)
2225 DBG(dev, "SETUP: USB_REQ_CLEAR_FEATURE\n"); 2279 dev_dbg(&dev->pdev->dev,
2280 "SETUP: USB_REQ_CLEAR_FEATURE\n");
2226 2281
2227 if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK)) 2282 if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK))
2228 == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) { 2283 == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) {
@@ -2240,13 +2295,29 @@ static void handle_setup_packet(struct langwell_udc *dev,
2240 2295
2241 spin_unlock(&dev->lock); 2296 spin_unlock(&dev->lock);
2242 rc = langwell_ep_set_halt(&epn->ep, 2297 rc = langwell_ep_set_halt(&epn->ep,
2243 (setup->bRequest == USB_REQ_SET_FEATURE) 2298 (setup->bRequest == USB_REQ_SET_FEATURE)
2244 ? 1 : 0); 2299 ? 1 : 0);
2245 spin_lock(&dev->lock); 2300 spin_lock(&dev->lock);
2246 2301
2247 } else if ((setup->bRequestType & (USB_RECIP_MASK 2302 } else if ((setup->bRequestType & (USB_RECIP_MASK
2248 | USB_TYPE_MASK)) == (USB_RECIP_DEVICE 2303 | USB_TYPE_MASK)) == (USB_RECIP_DEVICE
2249 | USB_TYPE_STANDARD)) { 2304 | USB_TYPE_STANDARD)) {
2305 rc = 0;
2306 switch (wValue) {
2307 case USB_DEVICE_REMOTE_WAKEUP:
2308 if (setup->bRequest == USB_REQ_SET_FEATURE) {
2309 dev->remote_wakeup = 1;
2310 dev->dev_status |= (1 << wValue);
2311 } else {
2312 dev->remote_wakeup = 0;
2313 dev->dev_status &= ~(1 << wValue);
2314 }
2315 break;
2316 default:
2317 rc = -EOPNOTSUPP;
2318 break;
2319 }
2320
2250 if (!gadget_is_otg(&dev->gadget)) 2321 if (!gadget_is_otg(&dev->gadget))
2251 break; 2322 break;
2252 else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) { 2323 else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) {
@@ -2262,7 +2333,6 @@ static void handle_setup_packet(struct langwell_udc *dev,
2262 dev->gadget.a_alt_hnp_support = 1; 2333 dev->gadget.a_alt_hnp_support = 1;
2263 else 2334 else
2264 break; 2335 break;
2265 rc = 0;
2266 } else 2336 } else
2267 break; 2337 break;
2268 2338
@@ -2274,31 +2344,38 @@ static void handle_setup_packet(struct langwell_udc *dev,
2274 } 2344 }
2275 2345
2276 case USB_REQ_GET_DESCRIPTOR: 2346 case USB_REQ_GET_DESCRIPTOR:
2277 DBG(dev, "SETUP: USB_REQ_GET_DESCRIPTOR\n"); 2347 dev_dbg(&dev->pdev->dev,
2348 "SETUP: USB_REQ_GET_DESCRIPTOR\n");
2278 goto delegate; 2349 goto delegate;
2279 2350
2280 case USB_REQ_SET_DESCRIPTOR: 2351 case USB_REQ_SET_DESCRIPTOR:
2281 DBG(dev, "SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n"); 2352 dev_dbg(&dev->pdev->dev,
2353 "SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n");
2282 goto delegate; 2354 goto delegate;
2283 2355
2284 case USB_REQ_GET_CONFIGURATION: 2356 case USB_REQ_GET_CONFIGURATION:
2285 DBG(dev, "SETUP: USB_REQ_GET_CONFIGURATION\n"); 2357 dev_dbg(&dev->pdev->dev,
2358 "SETUP: USB_REQ_GET_CONFIGURATION\n");
2286 goto delegate; 2359 goto delegate;
2287 2360
2288 case USB_REQ_SET_CONFIGURATION: 2361 case USB_REQ_SET_CONFIGURATION:
2289 DBG(dev, "SETUP: USB_REQ_SET_CONFIGURATION\n"); 2362 dev_dbg(&dev->pdev->dev,
2363 "SETUP: USB_REQ_SET_CONFIGURATION\n");
2290 goto delegate; 2364 goto delegate;
2291 2365
2292 case USB_REQ_GET_INTERFACE: 2366 case USB_REQ_GET_INTERFACE:
2293 DBG(dev, "SETUP: USB_REQ_GET_INTERFACE\n"); 2367 dev_dbg(&dev->pdev->dev,
2368 "SETUP: USB_REQ_GET_INTERFACE\n");
2294 goto delegate; 2369 goto delegate;
2295 2370
2296 case USB_REQ_SET_INTERFACE: 2371 case USB_REQ_SET_INTERFACE:
2297 DBG(dev, "SETUP: USB_REQ_SET_INTERFACE\n"); 2372 dev_dbg(&dev->pdev->dev,
2373 "SETUP: USB_REQ_SET_INTERFACE\n");
2298 goto delegate; 2374 goto delegate;
2299 2375
2300 case USB_REQ_SYNCH_FRAME: 2376 case USB_REQ_SYNCH_FRAME:
2301 DBG(dev, "SETUP: USB_REQ_SYNCH_FRAME unsupported\n"); 2377 dev_dbg(&dev->pdev->dev,
2378 "SETUP: USB_REQ_SYNCH_FRAME unsupported\n");
2302 goto delegate; 2379 goto delegate;
2303 2380
2304 default: 2381 default:
@@ -2310,7 +2387,8 @@ delegate:
2310 /* DATA phase from gadget, STATUS phase from udc */ 2387 /* DATA phase from gadget, STATUS phase from udc */
2311 dev->ep0_dir = (setup->bRequestType & USB_DIR_IN) 2388 dev->ep0_dir = (setup->bRequestType & USB_DIR_IN)
2312 ? USB_DIR_IN : USB_DIR_OUT; 2389 ? USB_DIR_IN : USB_DIR_OUT;
2313 VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n", 2390 dev_vdbg(&dev->pdev->dev,
2391 "dev->ep0_dir = 0x%x, wLength = %d\n",
2314 dev->ep0_dir, wLength); 2392 dev->ep0_dir, wLength);
2315 spin_unlock(&dev->lock); 2393 spin_unlock(&dev->lock);
2316 if (dev->driver->setup(&dev->gadget, 2394 if (dev->driver->setup(&dev->gadget,
@@ -2322,7 +2400,8 @@ delegate:
2322 } else { 2400 } else {
2323 /* no DATA phase, IN STATUS phase from gadget */ 2401 /* no DATA phase, IN STATUS phase from gadget */
2324 dev->ep0_dir = USB_DIR_IN; 2402 dev->ep0_dir = USB_DIR_IN;
2325 VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n", 2403 dev_vdbg(&dev->pdev->dev,
2404 "dev->ep0_dir = 0x%x, wLength = %d\n",
2326 dev->ep0_dir, wLength); 2405 dev->ep0_dir, wLength);
2327 spin_unlock(&dev->lock); 2406 spin_unlock(&dev->lock);
2328 if (dev->driver->setup(&dev->gadget, 2407 if (dev->driver->setup(&dev->gadget,
@@ -2334,8 +2413,7 @@ delegate:
2334 break; 2413 break;
2335 } 2414 }
2336end: 2415end:
2337 VDBG(dev, "<--- %s()\n", __func__); 2416 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2338 return;
2339} 2417}
2340 2418
2341 2419
@@ -2359,23 +2437,27 @@ static int process_ep_req(struct langwell_udc *dev, int index,
2359 td_complete = 0; 2437 td_complete = 0;
2360 actual = curr_req->req.length; 2438 actual = curr_req->req.length;
2361 2439
2362 VDBG(dev, "---> %s()\n", __func__); 2440 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2363 2441
2364 for (i = 0; i < curr_req->dtd_count; i++) { 2442 for (i = 0; i < curr_req->dtd_count; i++) {
2365 remaining_length = le16_to_cpu(curr_dtd->dtd_total);
2366 actual -= remaining_length;
2367 2443
2368 /* command execution states by dTD */ 2444 /* command execution states by dTD */
2369 dtd_status = curr_dtd->dtd_status; 2445 dtd_status = curr_dtd->dtd_status;
2370 2446
2447 barrier();
2448 remaining_length = le16_to_cpu(curr_dtd->dtd_total);
2449 actual -= remaining_length;
2450
2371 if (!dtd_status) { 2451 if (!dtd_status) {
2372 /* transfers completed successfully */ 2452 /* transfers completed successfully */
2373 if (!remaining_length) { 2453 if (!remaining_length) {
2374 td_complete++; 2454 td_complete++;
2375 VDBG(dev, "dTD transmitted successfully\n"); 2455 dev_vdbg(&dev->pdev->dev,
2456 "dTD transmitted successfully\n");
2376 } else { 2457 } else {
2377 if (dir) { 2458 if (dir) {
2378 VDBG(dev, "TX dTD remains data\n"); 2459 dev_vdbg(&dev->pdev->dev,
2460 "TX dTD remains data\n");
2379 retval = -EPROTO; 2461 retval = -EPROTO;
2380 break; 2462 break;
2381 2463
@@ -2387,27 +2469,32 @@ static int process_ep_req(struct langwell_udc *dev, int index,
2387 } else { 2469 } else {
2388 /* transfers completed with errors */ 2470 /* transfers completed with errors */
2389 if (dtd_status & DTD_STS_ACTIVE) { 2471 if (dtd_status & DTD_STS_ACTIVE) {
2390 DBG(dev, "request not completed\n"); 2472 dev_dbg(&dev->pdev->dev,
2473 "dTD status ACTIVE dQH[%d]\n", index);
2391 retval = 1; 2474 retval = 1;
2392 return retval; 2475 return retval;
2393 } else if (dtd_status & DTD_STS_HALTED) { 2476 } else if (dtd_status & DTD_STS_HALTED) {
2394 ERROR(dev, "dTD error %08x dQH[%d]\n", 2477 dev_err(&dev->pdev->dev,
2395 dtd_status, index); 2478 "dTD error %08x dQH[%d]\n",
2479 dtd_status, index);
2396 /* clear the errors and halt condition */ 2480 /* clear the errors and halt condition */
2397 curr_dqh->dtd_status = 0; 2481 curr_dqh->dtd_status = 0;
2398 retval = -EPIPE; 2482 retval = -EPIPE;
2399 break; 2483 break;
2400 } else if (dtd_status & DTD_STS_DBE) { 2484 } else if (dtd_status & DTD_STS_DBE) {
2401 DBG(dev, "data buffer (overflow) error\n"); 2485 dev_dbg(&dev->pdev->dev,
2486 "data buffer (overflow) error\n");
2402 retval = -EPROTO; 2487 retval = -EPROTO;
2403 break; 2488 break;
2404 } else if (dtd_status & DTD_STS_TRE) { 2489 } else if (dtd_status & DTD_STS_TRE) {
2405 DBG(dev, "transaction(ISO) error\n"); 2490 dev_dbg(&dev->pdev->dev,
2491 "transaction(ISO) error\n");
2406 retval = -EILSEQ; 2492 retval = -EILSEQ;
2407 break; 2493 break;
2408 } else 2494 } else
2409 ERROR(dev, "unknown error (0x%x)!\n", 2495 dev_err(&dev->pdev->dev,
2410 dtd_status); 2496 "unknown error (0x%x)!\n",
2497 dtd_status);
2411 } 2498 }
2412 2499
2413 if (i != curr_req->dtd_count - 1) 2500 if (i != curr_req->dtd_count - 1)
@@ -2420,7 +2507,7 @@ static int process_ep_req(struct langwell_udc *dev, int index,
2420 2507
2421 curr_req->req.actual = actual; 2508 curr_req->req.actual = actual;
2422 2509
2423 VDBG(dev, "<--- %s()\n", __func__); 2510 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2424 return 0; 2511 return 0;
2425} 2512}
2426 2513
@@ -2430,7 +2517,7 @@ static void ep0_req_complete(struct langwell_udc *dev,
2430 struct langwell_ep *ep0, struct langwell_request *req) 2517 struct langwell_ep *ep0, struct langwell_request *req)
2431{ 2518{
2432 u32 new_addr; 2519 u32 new_addr;
2433 VDBG(dev, "---> %s()\n", __func__); 2520 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2434 2521
2435 if (dev->usb_state == USB_STATE_ADDRESS) { 2522 if (dev->usb_state == USB_STATE_ADDRESS) {
2436 /* set the new address */ 2523 /* set the new address */
@@ -2438,7 +2525,7 @@ static void ep0_req_complete(struct langwell_udc *dev,
2438 writel(new_addr << USBADR_SHIFT, &dev->op_regs->deviceaddr); 2525 writel(new_addr << USBADR_SHIFT, &dev->op_regs->deviceaddr);
2439 2526
2440 new_addr = USBADR(readl(&dev->op_regs->deviceaddr)); 2527 new_addr = USBADR(readl(&dev->op_regs->deviceaddr));
2441 VDBG(dev, "new_addr = %d\n", new_addr); 2528 dev_vdbg(&dev->pdev->dev, "new_addr = %d\n", new_addr);
2442 } 2529 }
2443 2530
2444 done(ep0, req, 0); 2531 done(ep0, req, 0);
@@ -2458,14 +2545,14 @@ static void ep0_req_complete(struct langwell_udc *dev,
2458 dev->ep0_state = WAIT_FOR_SETUP; 2545 dev->ep0_state = WAIT_FOR_SETUP;
2459 break; 2546 break;
2460 case WAIT_FOR_SETUP: 2547 case WAIT_FOR_SETUP:
2461 ERROR(dev, "unexpect ep0 packets\n"); 2548 dev_err(&dev->pdev->dev, "unexpect ep0 packets\n");
2462 break; 2549 break;
2463 default: 2550 default:
2464 ep0_stall(dev); 2551 ep0_stall(dev);
2465 break; 2552 break;
2466 } 2553 }
2467 2554
2468 VDBG(dev, "<--- %s()\n", __func__); 2555 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2469} 2556}
2470 2557
2471 2558
@@ -2477,16 +2564,17 @@ static void handle_trans_complete(struct langwell_udc *dev)
2477 struct langwell_ep *epn; 2564 struct langwell_ep *epn;
2478 struct langwell_request *curr_req, *temp_req; 2565 struct langwell_request *curr_req, *temp_req;
2479 2566
2480 VDBG(dev, "---> %s()\n", __func__); 2567 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2481 2568
2482 complete_bits = readl(&dev->op_regs->endptcomplete); 2569 complete_bits = readl(&dev->op_regs->endptcomplete);
2483 VDBG(dev, "endptcomplete register: 0x%08x\n", complete_bits); 2570 dev_vdbg(&dev->pdev->dev, "endptcomplete register: 0x%08x\n",
2571 complete_bits);
2484 2572
2485 /* Write-Clear the bits in endptcomplete register */ 2573 /* Write-Clear the bits in endptcomplete register */
2486 writel(complete_bits, &dev->op_regs->endptcomplete); 2574 writel(complete_bits, &dev->op_regs->endptcomplete);
2487 2575
2488 if (!complete_bits) { 2576 if (!complete_bits) {
2489 DBG(dev, "complete_bits = 0\n"); 2577 dev_dbg(&dev->pdev->dev, "complete_bits = 0\n");
2490 goto done; 2578 goto done;
2491 } 2579 }
2492 2580
@@ -2506,23 +2594,25 @@ static void handle_trans_complete(struct langwell_udc *dev)
2506 epn = &dev->ep[i]; 2594 epn = &dev->ep[i];
2507 2595
2508 if (epn->name == NULL) { 2596 if (epn->name == NULL) {
2509 WARNING(dev, "invalid endpoint\n"); 2597 dev_warn(&dev->pdev->dev, "invalid endpoint\n");
2510 continue; 2598 continue;
2511 } 2599 }
2512 2600
2513 if (i < 2) 2601 if (i < 2)
2514 /* ep0 in and out */ 2602 /* ep0 in and out */
2515 DBG(dev, "%s-%s transfer completed\n", 2603 dev_dbg(&dev->pdev->dev, "%s-%s transfer completed\n",
2516 epn->name, 2604 epn->name,
2517 is_in(epn) ? "in" : "out"); 2605 is_in(epn) ? "in" : "out");
2518 else 2606 else
2519 DBG(dev, "%s transfer completed\n", epn->name); 2607 dev_dbg(&dev->pdev->dev, "%s transfer completed\n",
2608 epn->name);
2520 2609
2521 /* process the req queue until an uncomplete request */ 2610 /* process the req queue until an uncomplete request */
2522 list_for_each_entry_safe(curr_req, temp_req, 2611 list_for_each_entry_safe(curr_req, temp_req,
2523 &epn->queue, queue) { 2612 &epn->queue, queue) {
2524 status = process_ep_req(dev, i, curr_req); 2613 status = process_ep_req(dev, i, curr_req);
2525 VDBG(dev, "%s req status: %d\n", epn->name, status); 2614 dev_vdbg(&dev->pdev->dev, "%s req status: %d\n",
2615 epn->name, status);
2526 2616
2527 if (status) 2617 if (status)
2528 break; 2618 break;
@@ -2540,8 +2630,7 @@ static void handle_trans_complete(struct langwell_udc *dev)
2540 } 2630 }
2541 } 2631 }
2542done: 2632done:
2543 VDBG(dev, "<--- %s()\n", __func__); 2633 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2544 return;
2545} 2634}
2546 2635
2547 2636
@@ -2551,14 +2640,14 @@ static void handle_port_change(struct langwell_udc *dev)
2551 u32 portsc1, devlc; 2640 u32 portsc1, devlc;
2552 u32 speed; 2641 u32 speed;
2553 2642
2554 VDBG(dev, "---> %s()\n", __func__); 2643 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2555 2644
2556 if (dev->bus_reset) 2645 if (dev->bus_reset)
2557 dev->bus_reset = 0; 2646 dev->bus_reset = 0;
2558 2647
2559 portsc1 = readl(&dev->op_regs->portsc1); 2648 portsc1 = readl(&dev->op_regs->portsc1);
2560 devlc = readl(&dev->op_regs->devlc); 2649 devlc = readl(&dev->op_regs->devlc);
2561 VDBG(dev, "portsc1 = 0x%08x, devlc = 0x%08x\n", 2650 dev_vdbg(&dev->pdev->dev, "portsc1 = 0x%08x, devlc = 0x%08x\n",
2562 portsc1, devlc); 2651 portsc1, devlc);
2563 2652
2564 /* bus reset is finished */ 2653 /* bus reset is finished */
@@ -2579,25 +2668,22 @@ static void handle_port_change(struct langwell_udc *dev)
2579 dev->gadget.speed = USB_SPEED_UNKNOWN; 2668 dev->gadget.speed = USB_SPEED_UNKNOWN;
2580 break; 2669 break;
2581 } 2670 }
2582 VDBG(dev, "speed = %d, dev->gadget.speed = %d\n", 2671 dev_vdbg(&dev->pdev->dev,
2672 "speed = %d, dev->gadget.speed = %d\n",
2583 speed, dev->gadget.speed); 2673 speed, dev->gadget.speed);
2584 } 2674 }
2585 2675
2586 /* LPM L0 to L1 */ 2676 /* LPM L0 to L1 */
2587 if (dev->lpm && dev->lpm_state == LPM_L0) 2677 if (dev->lpm && dev->lpm_state == LPM_L0)
2588 if (portsc1 & PORTS_SUSP && portsc1 & PORTS_SLP) { 2678 if (portsc1 & PORTS_SUSP && portsc1 & PORTS_SLP) {
2589 INFO(dev, "LPM L0 to L1\n"); 2679 dev_info(&dev->pdev->dev, "LPM L0 to L1\n");
2590 dev->lpm_state = LPM_L1; 2680 dev->lpm_state = LPM_L1;
2591 } 2681 }
2592 2682
2593 /* LPM L1 to L0, force resume or remote wakeup finished */ 2683 /* LPM L1 to L0, force resume or remote wakeup finished */
2594 if (dev->lpm && dev->lpm_state == LPM_L1) 2684 if (dev->lpm && dev->lpm_state == LPM_L1)
2595 if (!(portsc1 & PORTS_SUSP)) { 2685 if (!(portsc1 & PORTS_SUSP)) {
2596 if (portsc1 & PORTS_SLP) 2686 dev_info(&dev->pdev->dev, "LPM L1 to L0\n");
2597 INFO(dev, "LPM L1 to L0, force resume\n");
2598 else
2599 INFO(dev, "LPM L1 to L0, remote wakeup\n");
2600
2601 dev->lpm_state = LPM_L0; 2687 dev->lpm_state = LPM_L0;
2602 } 2688 }
2603 2689
@@ -2605,7 +2691,7 @@ static void handle_port_change(struct langwell_udc *dev)
2605 if (!dev->resume_state) 2691 if (!dev->resume_state)
2606 dev->usb_state = USB_STATE_DEFAULT; 2692 dev->usb_state = USB_STATE_DEFAULT;
2607 2693
2608 VDBG(dev, "<--- %s()\n", __func__); 2694 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2609} 2695}
2610 2696
2611 2697
@@ -2617,7 +2703,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2617 endptcomplete; 2703 endptcomplete;
2618 unsigned long timeout; 2704 unsigned long timeout;
2619 2705
2620 VDBG(dev, "---> %s()\n", __func__); 2706 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2621 2707
2622 /* Write-Clear the device address */ 2708 /* Write-Clear the device address */
2623 deviceaddr = readl(&dev->op_regs->deviceaddr); 2709 deviceaddr = readl(&dev->op_regs->deviceaddr);
@@ -2634,7 +2720,10 @@ static void handle_usb_reset(struct langwell_udc *dev)
2634 2720
2635 dev->ep0_dir = USB_DIR_OUT; 2721 dev->ep0_dir = USB_DIR_OUT;
2636 dev->ep0_state = WAIT_FOR_SETUP; 2722 dev->ep0_state = WAIT_FOR_SETUP;
2637 dev->remote_wakeup = 0; /* default to 0 on reset */ 2723
2724 /* remote wakeup reset to 0 when the device is reset */
2725 dev->remote_wakeup = 0;
2726 dev->dev_status = 1 << USB_DEVICE_SELF_POWERED;
2638 dev->gadget.b_hnp_enable = 0; 2727 dev->gadget.b_hnp_enable = 0;
2639 dev->gadget.a_hnp_support = 0; 2728 dev->gadget.a_hnp_support = 0;
2640 dev->gadget.a_alt_hnp_support = 0; 2729 dev->gadget.a_alt_hnp_support = 0;
@@ -2651,7 +2740,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2651 timeout = jiffies + PRIME_TIMEOUT; 2740 timeout = jiffies + PRIME_TIMEOUT;
2652 while (readl(&dev->op_regs->endptprime)) { 2741 while (readl(&dev->op_regs->endptprime)) {
2653 if (time_after(jiffies, timeout)) { 2742 if (time_after(jiffies, timeout)) {
2654 ERROR(dev, "USB reset timeout\n"); 2743 dev_err(&dev->pdev->dev, "USB reset timeout\n");
2655 break; 2744 break;
2656 } 2745 }
2657 cpu_relax(); 2746 cpu_relax();
@@ -2661,7 +2750,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2661 writel((u32) ~0, &dev->op_regs->endptflush); 2750 writel((u32) ~0, &dev->op_regs->endptflush);
2662 2751
2663 if (readl(&dev->op_regs->portsc1) & PORTS_PR) { 2752 if (readl(&dev->op_regs->portsc1) & PORTS_PR) {
2664 VDBG(dev, "USB bus reset\n"); 2753 dev_vdbg(&dev->pdev->dev, "USB bus reset\n");
2665 /* bus is reseting */ 2754 /* bus is reseting */
2666 dev->bus_reset = 1; 2755 dev->bus_reset = 1;
2667 2756
@@ -2669,7 +2758,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
2669 stop_activity(dev, dev->driver); 2758 stop_activity(dev, dev->driver);
2670 dev->usb_state = USB_STATE_DEFAULT; 2759 dev->usb_state = USB_STATE_DEFAULT;
2671 } else { 2760 } else {
2672 VDBG(dev, "device controller reset\n"); 2761 dev_vdbg(&dev->pdev->dev, "device controller reset\n");
2673 /* controller reset */ 2762 /* controller reset */
2674 langwell_udc_reset(dev); 2763 langwell_udc_reset(dev);
2675 2764
@@ -2691,15 +2780,14 @@ static void handle_usb_reset(struct langwell_udc *dev)
2691 dev->lotg->hsm.b_hnp_enable = 0; 2780 dev->lotg->hsm.b_hnp_enable = 0;
2692#endif 2781#endif
2693 2782
2694 VDBG(dev, "<--- %s()\n", __func__); 2783 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2695} 2784}
2696 2785
2697 2786
2698/* USB bus suspend/resume interrupt */ 2787/* USB bus suspend/resume interrupt */
2699static void handle_bus_suspend(struct langwell_udc *dev) 2788static void handle_bus_suspend(struct langwell_udc *dev)
2700{ 2789{
2701 u32 devlc; 2790 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
2702 DBG(dev, "---> %s()\n", __func__);
2703 2791
2704 dev->resume_state = dev->usb_state; 2792 dev->resume_state = dev->usb_state;
2705 dev->usb_state = USB_STATE_SUSPENDED; 2793 dev->usb_state = USB_STATE_SUSPENDED;
@@ -2733,33 +2821,29 @@ static void handle_bus_suspend(struct langwell_udc *dev)
2733 spin_unlock(&dev->lock); 2821 spin_unlock(&dev->lock);
2734 dev->driver->suspend(&dev->gadget); 2822 dev->driver->suspend(&dev->gadget);
2735 spin_lock(&dev->lock); 2823 spin_lock(&dev->lock);
2736 DBG(dev, "suspend %s\n", dev->driver->driver.name); 2824 dev_dbg(&dev->pdev->dev, "suspend %s\n",
2825 dev->driver->driver.name);
2737 } 2826 }
2738 } 2827 }
2739 2828
2740 /* enter PHY low power suspend */ 2829 /* enter PHY low power suspend */
2741 devlc = readl(&dev->op_regs->devlc); 2830 if (dev->pdev->device != 0x0829)
2742 VDBG(dev, "devlc = 0x%08x\n", devlc); 2831 langwell_phy_low_power(dev, 0);
2743 devlc |= LPM_PHCD;
2744 writel(devlc, &dev->op_regs->devlc);
2745 2832
2746 DBG(dev, "<--- %s()\n", __func__); 2833 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2747} 2834}
2748 2835
2749 2836
2750static void handle_bus_resume(struct langwell_udc *dev) 2837static void handle_bus_resume(struct langwell_udc *dev)
2751{ 2838{
2752 u32 devlc; 2839 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
2753 DBG(dev, "---> %s()\n", __func__);
2754 2840
2755 dev->usb_state = dev->resume_state; 2841 dev->usb_state = dev->resume_state;
2756 dev->resume_state = 0; 2842 dev->resume_state = 0;
2757 2843
2758 /* exit PHY low power suspend */ 2844 /* exit PHY low power suspend */
2759 devlc = readl(&dev->op_regs->devlc); 2845 if (dev->pdev->device != 0x0829)
2760 VDBG(dev, "devlc = 0x%08x\n", devlc); 2846 langwell_phy_low_power(dev, 0);
2761 devlc &= ~LPM_PHCD;
2762 writel(devlc, &dev->op_regs->devlc);
2763 2847
2764#ifdef OTG_TRANSCEIVER 2848#ifdef OTG_TRANSCEIVER
2765 if (dev->lotg->otg.default_a == 0) 2849 if (dev->lotg->otg.default_a == 0)
@@ -2772,11 +2856,12 @@ static void handle_bus_resume(struct langwell_udc *dev)
2772 spin_unlock(&dev->lock); 2856 spin_unlock(&dev->lock);
2773 dev->driver->resume(&dev->gadget); 2857 dev->driver->resume(&dev->gadget);
2774 spin_lock(&dev->lock); 2858 spin_lock(&dev->lock);
2775 DBG(dev, "resume %s\n", dev->driver->driver.name); 2859 dev_dbg(&dev->pdev->dev, "resume %s\n",
2860 dev->driver->driver.name);
2776 } 2861 }
2777 } 2862 }
2778 2863
2779 DBG(dev, "<--- %s()\n", __func__); 2864 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2780} 2865}
2781 2866
2782 2867
@@ -2789,11 +2874,11 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
2789 irq_sts, 2874 irq_sts,
2790 portsc1; 2875 portsc1;
2791 2876
2792 VDBG(dev, "---> %s()\n", __func__); 2877 dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
2793 2878
2794 if (dev->stopped) { 2879 if (dev->stopped) {
2795 VDBG(dev, "handle IRQ_NONE\n"); 2880 dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n");
2796 VDBG(dev, "<--- %s()\n", __func__); 2881 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2797 return IRQ_NONE; 2882 return IRQ_NONE;
2798 } 2883 }
2799 2884
@@ -2806,12 +2891,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
2806 usbintr = readl(&dev->op_regs->usbintr); 2891 usbintr = readl(&dev->op_regs->usbintr);
2807 2892
2808 irq_sts = usbsts & usbintr; 2893 irq_sts = usbsts & usbintr;
2809 VDBG(dev, "usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n", 2894 dev_vdbg(&dev->pdev->dev,
2895 "usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n",
2810 usbsts, usbintr, irq_sts); 2896 usbsts, usbintr, irq_sts);
2811 2897
2812 if (!irq_sts) { 2898 if (!irq_sts) {
2813 VDBG(dev, "handle IRQ_NONE\n"); 2899 dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n");
2814 VDBG(dev, "<--- %s()\n", __func__); 2900 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2815 spin_unlock(&dev->lock); 2901 spin_unlock(&dev->lock);
2816 return IRQ_NONE; 2902 return IRQ_NONE;
2817 } 2903 }
@@ -2827,12 +2913,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
2827 2913
2828 /* USB interrupt */ 2914 /* USB interrupt */
2829 if (irq_sts & STS_UI) { 2915 if (irq_sts & STS_UI) {
2830 VDBG(dev, "USB interrupt\n"); 2916 dev_vdbg(&dev->pdev->dev, "USB interrupt\n");
2831 2917
2832 /* setup packet received from ep0 */ 2918 /* setup packet received from ep0 */
2833 if (readl(&dev->op_regs->endptsetupstat) 2919 if (readl(&dev->op_regs->endptsetupstat)
2834 & EP0SETUPSTAT_MASK) { 2920 & EP0SETUPSTAT_MASK) {
2835 VDBG(dev, "USB SETUP packet received interrupt\n"); 2921 dev_vdbg(&dev->pdev->dev,
2922 "USB SETUP packet received interrupt\n");
2836 /* setup tripwire semaphone */ 2923 /* setup tripwire semaphone */
2837 setup_tripwire(dev); 2924 setup_tripwire(dev);
2838 handle_setup_packet(dev, &dev->local_setup_buff); 2925 handle_setup_packet(dev, &dev->local_setup_buff);
@@ -2840,7 +2927,8 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
2840 2927
2841 /* USB transfer completion */ 2928 /* USB transfer completion */
2842 if (readl(&dev->op_regs->endptcomplete)) { 2929 if (readl(&dev->op_regs->endptcomplete)) {
2843 VDBG(dev, "USB transfer completion interrupt\n"); 2930 dev_vdbg(&dev->pdev->dev,
2931 "USB transfer completion interrupt\n");
2844 handle_trans_complete(dev); 2932 handle_trans_complete(dev);
2845 } 2933 }
2846 } 2934 }
@@ -2848,36 +2936,36 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
2848 /* SOF received interrupt (for ISO transfer) */ 2936 /* SOF received interrupt (for ISO transfer) */
2849 if (irq_sts & STS_SRI) { 2937 if (irq_sts & STS_SRI) {
2850 /* FIXME */ 2938 /* FIXME */
2851 /* VDBG(dev, "SOF received interrupt\n"); */ 2939 /* dev_vdbg(&dev->pdev->dev, "SOF received interrupt\n"); */
2852 } 2940 }
2853 2941
2854 /* port change detect interrupt */ 2942 /* port change detect interrupt */
2855 if (irq_sts & STS_PCI) { 2943 if (irq_sts & STS_PCI) {
2856 VDBG(dev, "port change detect interrupt\n"); 2944 dev_vdbg(&dev->pdev->dev, "port change detect interrupt\n");
2857 handle_port_change(dev); 2945 handle_port_change(dev);
2858 } 2946 }
2859 2947
2860 /* suspend interrrupt */ 2948 /* suspend interrrupt */
2861 if (irq_sts & STS_SLI) { 2949 if (irq_sts & STS_SLI) {
2862 VDBG(dev, "suspend interrupt\n"); 2950 dev_vdbg(&dev->pdev->dev, "suspend interrupt\n");
2863 handle_bus_suspend(dev); 2951 handle_bus_suspend(dev);
2864 } 2952 }
2865 2953
2866 /* USB reset interrupt */ 2954 /* USB reset interrupt */
2867 if (irq_sts & STS_URI) { 2955 if (irq_sts & STS_URI) {
2868 VDBG(dev, "USB reset interrupt\n"); 2956 dev_vdbg(&dev->pdev->dev, "USB reset interrupt\n");
2869 handle_usb_reset(dev); 2957 handle_usb_reset(dev);
2870 } 2958 }
2871 2959
2872 /* USB error or system error interrupt */ 2960 /* USB error or system error interrupt */
2873 if (irq_sts & (STS_UEI | STS_SEI)) { 2961 if (irq_sts & (STS_UEI | STS_SEI)) {
2874 /* FIXME */ 2962 /* FIXME */
2875 WARNING(dev, "error IRQ, irq_sts: %x\n", irq_sts); 2963 dev_warn(&dev->pdev->dev, "error IRQ, irq_sts: %x\n", irq_sts);
2876 } 2964 }
2877 2965
2878 spin_unlock(&dev->lock); 2966 spin_unlock(&dev->lock);
2879 2967
2880 VDBG(dev, "<--- %s()\n", __func__); 2968 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2881 return IRQ_HANDLED; 2969 return IRQ_HANDLED;
2882} 2970}
2883 2971
@@ -2889,15 +2977,59 @@ static void gadget_release(struct device *_dev)
2889{ 2977{
2890 struct langwell_udc *dev = the_controller; 2978 struct langwell_udc *dev = the_controller;
2891 2979
2892 DBG(dev, "---> %s()\n", __func__); 2980 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
2893 2981
2894 complete(dev->done); 2982 complete(dev->done);
2895 2983
2896 DBG(dev, "<--- %s()\n", __func__); 2984 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2897 kfree(dev); 2985 kfree(dev);
2898} 2986}
2899 2987
2900 2988
2989/* enable SRAM caching if SRAM detected */
2990static void sram_init(struct langwell_udc *dev)
2991{
2992 struct pci_dev *pdev = dev->pdev;
2993
2994 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
2995
2996 dev->sram_addr = pci_resource_start(pdev, 1);
2997 dev->sram_size = pci_resource_len(pdev, 1);
2998 dev_info(&dev->pdev->dev, "Found private SRAM at %x size:%x\n",
2999 dev->sram_addr, dev->sram_size);
3000 dev->got_sram = 1;
3001
3002 if (pci_request_region(pdev, 1, kobject_name(&pdev->dev.kobj))) {
3003 dev_warn(&dev->pdev->dev, "SRAM request failed\n");
3004 dev->got_sram = 0;
3005 } else if (!dma_declare_coherent_memory(&pdev->dev, dev->sram_addr,
3006 dev->sram_addr, dev->sram_size, DMA_MEMORY_MAP)) {
3007 dev_warn(&dev->pdev->dev, "SRAM DMA declare failed\n");
3008 pci_release_region(pdev, 1);
3009 dev->got_sram = 0;
3010 }
3011
3012 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
3013}
3014
3015
3016/* release SRAM caching */
3017static void sram_deinit(struct langwell_udc *dev)
3018{
3019 struct pci_dev *pdev = dev->pdev;
3020
3021 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
3022
3023 dma_release_declared_memory(&pdev->dev);
3024 pci_release_region(pdev, 1);
3025
3026 dev->got_sram = 0;
3027
3028 dev_info(&dev->pdev->dev, "release SRAM caching\n");
3029 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
3030}
3031
3032
2901/* tear down the binding between this driver and the pci device */ 3033/* tear down the binding between this driver and the pci device */
2902static void langwell_udc_remove(struct pci_dev *pdev) 3034static void langwell_udc_remove(struct pci_dev *pdev)
2903{ 3035{
@@ -2906,23 +3038,29 @@ static void langwell_udc_remove(struct pci_dev *pdev)
2906 DECLARE_COMPLETION(done); 3038 DECLARE_COMPLETION(done);
2907 3039
2908 BUG_ON(dev->driver); 3040 BUG_ON(dev->driver);
2909 DBG(dev, "---> %s()\n", __func__); 3041 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
2910 3042
2911 dev->done = &done; 3043 dev->done = &done;
2912 3044
2913 /* free memory allocated in probe */ 3045#ifndef OTG_TRANSCEIVER
3046 /* free dTD dma_pool and dQH */
2914 if (dev->dtd_pool) 3047 if (dev->dtd_pool)
2915 dma_pool_destroy(dev->dtd_pool); 3048 dma_pool_destroy(dev->dtd_pool);
2916 3049
3050 if (dev->ep_dqh)
3051 dma_free_coherent(&pdev->dev, dev->ep_dqh_size,
3052 dev->ep_dqh, dev->ep_dqh_dma);
3053
3054 /* release SRAM caching */
3055 if (dev->has_sram && dev->got_sram)
3056 sram_deinit(dev);
3057#endif
3058
2917 if (dev->status_req) { 3059 if (dev->status_req) {
2918 kfree(dev->status_req->req.buf); 3060 kfree(dev->status_req->req.buf);
2919 kfree(dev->status_req); 3061 kfree(dev->status_req);
2920 } 3062 }
2921 3063
2922 if (dev->ep_dqh)
2923 dma_free_coherent(&pdev->dev, dev->ep_dqh_size,
2924 dev->ep_dqh, dev->ep_dqh_dma);
2925
2926 kfree(dev->ep); 3064 kfree(dev->ep);
2927 3065
2928 /* diable IRQ handler */ 3066 /* diable IRQ handler */
@@ -2949,11 +3087,12 @@ static void langwell_udc_remove(struct pci_dev *pdev)
2949 3087
2950 dev->cap_regs = NULL; 3088 dev->cap_regs = NULL;
2951 3089
2952 INFO(dev, "unbind\n"); 3090 dev_info(&dev->pdev->dev, "unbind\n");
2953 DBG(dev, "<--- %s()\n", __func__); 3091 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
2954 3092
2955 device_unregister(&dev->gadget.dev); 3093 device_unregister(&dev->gadget.dev);
2956 device_remove_file(&pdev->dev, &dev_attr_langwell_udc); 3094 device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
3095 device_remove_file(&pdev->dev, &dev_attr_remote_wakeup);
2957 3096
2958#ifndef OTG_TRANSCEIVER 3097#ifndef OTG_TRANSCEIVER
2959 pci_set_drvdata(pdev, NULL); 3098 pci_set_drvdata(pdev, NULL);
@@ -2997,7 +3136,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
2997 spin_lock_init(&dev->lock); 3136 spin_lock_init(&dev->lock);
2998 3137
2999 dev->pdev = pdev; 3138 dev->pdev = pdev;
3000 DBG(dev, "---> %s()\n", __func__); 3139 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
3001 3140
3002#ifdef OTG_TRANSCEIVER 3141#ifdef OTG_TRANSCEIVER
3003 /* PCI device is already enabled by otg_transceiver driver */ 3142 /* PCI device is already enabled by otg_transceiver driver */
@@ -3022,7 +3161,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3022 resource = pci_resource_start(pdev, 0); 3161 resource = pci_resource_start(pdev, 0);
3023 len = pci_resource_len(pdev, 0); 3162 len = pci_resource_len(pdev, 0);
3024 if (!request_mem_region(resource, len, driver_name)) { 3163 if (!request_mem_region(resource, len, driver_name)) {
3025 ERROR(dev, "controller already in use\n"); 3164 dev_err(&dev->pdev->dev, "controller already in use\n");
3026 retval = -EBUSY; 3165 retval = -EBUSY;
3027 goto error; 3166 goto error;
3028 } 3167 }
@@ -3031,33 +3170,43 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3031 base = ioremap_nocache(resource, len); 3170 base = ioremap_nocache(resource, len);
3032#endif 3171#endif
3033 if (base == NULL) { 3172 if (base == NULL) {
3034 ERROR(dev, "can't map memory\n"); 3173 dev_err(&dev->pdev->dev, "can't map memory\n");
3035 retval = -EFAULT; 3174 retval = -EFAULT;
3036 goto error; 3175 goto error;
3037 } 3176 }
3038 3177
3039 dev->cap_regs = (struct langwell_cap_regs __iomem *) base; 3178 dev->cap_regs = (struct langwell_cap_regs __iomem *) base;
3040 VDBG(dev, "dev->cap_regs: %p\n", dev->cap_regs); 3179 dev_vdbg(&dev->pdev->dev, "dev->cap_regs: %p\n", dev->cap_regs);
3041 dev->op_regs = (struct langwell_op_regs __iomem *) 3180 dev->op_regs = (struct langwell_op_regs __iomem *)
3042 (base + OP_REG_OFFSET); 3181 (base + OP_REG_OFFSET);
3043 VDBG(dev, "dev->op_regs: %p\n", dev->op_regs); 3182 dev_vdbg(&dev->pdev->dev, "dev->op_regs: %p\n", dev->op_regs);
3044 3183
3045 /* irq setup after old hardware is cleaned up */ 3184 /* irq setup after old hardware is cleaned up */
3046 if (!pdev->irq) { 3185 if (!pdev->irq) {
3047 ERROR(dev, "No IRQ. Check PCI setup!\n"); 3186 dev_err(&dev->pdev->dev, "No IRQ. Check PCI setup!\n");
3048 retval = -ENODEV; 3187 retval = -ENODEV;
3049 goto error; 3188 goto error;
3050 } 3189 }
3051 3190
3191 dev->has_sram = 1;
3192 dev->got_sram = 0;
3193 dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram);
3194
3052#ifndef OTG_TRANSCEIVER 3195#ifndef OTG_TRANSCEIVER
3053 INFO(dev, "irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n", 3196 /* enable SRAM caching if detected */
3197 if (dev->has_sram && !dev->got_sram)
3198 sram_init(dev);
3199
3200 dev_info(&dev->pdev->dev,
3201 "irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n",
3054 pdev->irq, resource, len, base); 3202 pdev->irq, resource, len, base);
3055 /* enables bus-mastering for device dev */ 3203 /* enables bus-mastering for device dev */
3056 pci_set_master(pdev); 3204 pci_set_master(pdev);
3057 3205
3058 if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, 3206 if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED,
3059 driver_name, dev) != 0) { 3207 driver_name, dev) != 0) {
3060 ERROR(dev, "request interrupt %d failed\n", pdev->irq); 3208 dev_err(&dev->pdev->dev,
3209 "request interrupt %d failed\n", pdev->irq);
3061 retval = -EBUSY; 3210 retval = -EBUSY;
3062 goto error; 3211 goto error;
3063 } 3212 }
@@ -3071,32 +3220,34 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3071 dev->lpm = (readl(&dev->cap_regs->hccparams) & HCC_LEN) ? 1 : 0; 3220 dev->lpm = (readl(&dev->cap_regs->hccparams) & HCC_LEN) ? 1 : 0;
3072 dev->dciversion = readw(&dev->cap_regs->dciversion); 3221 dev->dciversion = readw(&dev->cap_regs->dciversion);
3073 dev->devcap = (readl(&dev->cap_regs->dccparams) & DEVCAP) ? 1 : 0; 3222 dev->devcap = (readl(&dev->cap_regs->dccparams) & DEVCAP) ? 1 : 0;
3074 VDBG(dev, "dev->lpm: %d\n", dev->lpm); 3223 dev_vdbg(&dev->pdev->dev, "dev->lpm: %d\n", dev->lpm);
3075 VDBG(dev, "dev->dciversion: 0x%04x\n", dev->dciversion); 3224 dev_vdbg(&dev->pdev->dev, "dev->dciversion: 0x%04x\n",
3076 VDBG(dev, "dccparams: 0x%08x\n", readl(&dev->cap_regs->dccparams)); 3225 dev->dciversion);
3077 VDBG(dev, "dev->devcap: %d\n", dev->devcap); 3226 dev_vdbg(&dev->pdev->dev, "dccparams: 0x%08x\n",
3227 readl(&dev->cap_regs->dccparams));
3228 dev_vdbg(&dev->pdev->dev, "dev->devcap: %d\n", dev->devcap);
3078 if (!dev->devcap) { 3229 if (!dev->devcap) {
3079 ERROR(dev, "can't support device mode\n"); 3230 dev_err(&dev->pdev->dev, "can't support device mode\n");
3080 retval = -ENODEV; 3231 retval = -ENODEV;
3081 goto error; 3232 goto error;
3082 } 3233 }
3083 3234
3084 /* a pair of endpoints (out/in) for each address */ 3235 /* a pair of endpoints (out/in) for each address */
3085 dev->ep_max = DEN(readl(&dev->cap_regs->dccparams)) * 2; 3236 dev->ep_max = DEN(readl(&dev->cap_regs->dccparams)) * 2;
3086 VDBG(dev, "dev->ep_max: %d\n", dev->ep_max); 3237 dev_vdbg(&dev->pdev->dev, "dev->ep_max: %d\n", dev->ep_max);
3087 3238
3088 /* allocate endpoints memory */ 3239 /* allocate endpoints memory */
3089 dev->ep = kzalloc(sizeof(struct langwell_ep) * dev->ep_max, 3240 dev->ep = kzalloc(sizeof(struct langwell_ep) * dev->ep_max,
3090 GFP_KERNEL); 3241 GFP_KERNEL);
3091 if (!dev->ep) { 3242 if (!dev->ep) {
3092 ERROR(dev, "allocate endpoints memory failed\n"); 3243 dev_err(&dev->pdev->dev, "allocate endpoints memory failed\n");
3093 retval = -ENOMEM; 3244 retval = -ENOMEM;
3094 goto error; 3245 goto error;
3095 } 3246 }
3096 3247
3097 /* allocate device dQH memory */ 3248 /* allocate device dQH memory */
3098 size = dev->ep_max * sizeof(struct langwell_dqh); 3249 size = dev->ep_max * sizeof(struct langwell_dqh);
3099 VDBG(dev, "orig size = %d\n", size); 3250 dev_vdbg(&dev->pdev->dev, "orig size = %d\n", size);
3100 if (size < DQH_ALIGNMENT) 3251 if (size < DQH_ALIGNMENT)
3101 size = DQH_ALIGNMENT; 3252 size = DQH_ALIGNMENT;
3102 else if ((size % DQH_ALIGNMENT) != 0) { 3253 else if ((size % DQH_ALIGNMENT) != 0) {
@@ -3106,17 +3257,18 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3106 dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size, 3257 dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size,
3107 &dev->ep_dqh_dma, GFP_KERNEL); 3258 &dev->ep_dqh_dma, GFP_KERNEL);
3108 if (!dev->ep_dqh) { 3259 if (!dev->ep_dqh) {
3109 ERROR(dev, "allocate dQH memory failed\n"); 3260 dev_err(&dev->pdev->dev, "allocate dQH memory failed\n");
3110 retval = -ENOMEM; 3261 retval = -ENOMEM;
3111 goto error; 3262 goto error;
3112 } 3263 }
3113 dev->ep_dqh_size = size; 3264 dev->ep_dqh_size = size;
3114 VDBG(dev, "ep_dqh_size = %d\n", dev->ep_dqh_size); 3265 dev_vdbg(&dev->pdev->dev, "ep_dqh_size = %d\n", dev->ep_dqh_size);
3115 3266
3116 /* initialize ep0 status request structure */ 3267 /* initialize ep0 status request structure */
3117 dev->status_req = kzalloc(sizeof(struct langwell_request), GFP_KERNEL); 3268 dev->status_req = kzalloc(sizeof(struct langwell_request), GFP_KERNEL);
3118 if (!dev->status_req) { 3269 if (!dev->status_req) {
3119 ERROR(dev, "allocate status_req memory failed\n"); 3270 dev_err(&dev->pdev->dev,
3271 "allocate status_req memory failed\n");
3120 retval = -ENOMEM; 3272 retval = -ENOMEM;
3121 goto error; 3273 goto error;
3122 } 3274 }
@@ -3129,7 +3281,10 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3129 dev->resume_state = USB_STATE_NOTATTACHED; 3281 dev->resume_state = USB_STATE_NOTATTACHED;
3130 dev->usb_state = USB_STATE_POWERED; 3282 dev->usb_state = USB_STATE_POWERED;
3131 dev->ep0_dir = USB_DIR_OUT; 3283 dev->ep0_dir = USB_DIR_OUT;
3132 dev->remote_wakeup = 0; /* default to 0 on reset */ 3284
3285 /* remote wakeup reset to 0 when the device is reset */
3286 dev->remote_wakeup = 0;
3287 dev->dev_status = 1 << USB_DEVICE_SELF_POWERED;
3133 3288
3134#ifndef OTG_TRANSCEIVER 3289#ifndef OTG_TRANSCEIVER
3135 /* reset device controller */ 3290 /* reset device controller */
@@ -3174,18 +3329,20 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3174 } 3329 }
3175 3330
3176 /* done */ 3331 /* done */
3177 INFO(dev, "%s\n", driver_desc); 3332 dev_info(&dev->pdev->dev, "%s\n", driver_desc);
3178 INFO(dev, "irq %d, pci mem %p\n", pdev->irq, base); 3333 dev_info(&dev->pdev->dev, "irq %d, pci mem %p\n", pdev->irq, base);
3179 INFO(dev, "Driver version: " DRIVER_VERSION "\n"); 3334 dev_info(&dev->pdev->dev, "Driver version: " DRIVER_VERSION "\n");
3180 INFO(dev, "Support (max) %d endpoints\n", dev->ep_max); 3335 dev_info(&dev->pdev->dev, "Support (max) %d endpoints\n", dev->ep_max);
3181 INFO(dev, "Device interface version: 0x%04x\n", dev->dciversion); 3336 dev_info(&dev->pdev->dev, "Device interface version: 0x%04x\n",
3182 INFO(dev, "Controller mode: %s\n", dev->devcap ? "Device" : "Host"); 3337 dev->dciversion);
3183 INFO(dev, "Support USB LPM: %s\n", dev->lpm ? "Yes" : "No"); 3338 dev_info(&dev->pdev->dev, "Controller mode: %s\n",
3184 3339 dev->devcap ? "Device" : "Host");
3185 VDBG(dev, "After langwell_udc_probe(), print all registers:\n"); 3340 dev_info(&dev->pdev->dev, "Support USB LPM: %s\n",
3186#ifdef VERBOSE 3341 dev->lpm ? "Yes" : "No");
3342
3343 dev_vdbg(&dev->pdev->dev,
3344 "After langwell_udc_probe(), print all registers:\n");
3187 print_all_registers(dev); 3345 print_all_registers(dev);
3188#endif
3189 3346
3190 the_controller = dev; 3347 the_controller = dev;
3191 3348
@@ -3197,12 +3354,18 @@ static int langwell_udc_probe(struct pci_dev *pdev,
3197 if (retval) 3354 if (retval)
3198 goto error; 3355 goto error;
3199 3356
3200 VDBG(dev, "<--- %s()\n", __func__); 3357 retval = device_create_file(&pdev->dev, &dev_attr_remote_wakeup);
3358 if (retval)
3359 goto error_attr1;
3360
3361 dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
3201 return 0; 3362 return 0;
3202 3363
3364error_attr1:
3365 device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
3203error: 3366error:
3204 if (dev) { 3367 if (dev) {
3205 DBG(dev, "<--- %s()\n", __func__); 3368 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
3206 langwell_udc_remove(pdev); 3369 langwell_udc_remove(pdev);
3207 } 3370 }
3208 3371
@@ -3214,9 +3377,8 @@ error:
3214static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) 3377static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
3215{ 3378{
3216 struct langwell_udc *dev = the_controller; 3379 struct langwell_udc *dev = the_controller;
3217 u32 devlc;
3218 3380
3219 DBG(dev, "---> %s()\n", __func__); 3381 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
3220 3382
3221 /* disable interrupt and set controller to stop state */ 3383 /* disable interrupt and set controller to stop state */
3222 langwell_udc_stop(dev); 3384 langwell_udc_stop(dev);
@@ -3226,20 +3388,34 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
3226 free_irq(pdev->irq, dev); 3388 free_irq(pdev->irq, dev);
3227 dev->got_irq = 0; 3389 dev->got_irq = 0;
3228 3390
3229
3230 /* save PCI state */ 3391 /* save PCI state */
3231 pci_save_state(pdev); 3392 pci_save_state(pdev);
3232 3393
3394 spin_lock_irq(&dev->lock);
3395 /* stop all usb activities */
3396 stop_activity(dev, dev->driver);
3397 spin_unlock_irq(&dev->lock);
3398
3399 /* free dTD dma_pool and dQH */
3400 if (dev->dtd_pool)
3401 dma_pool_destroy(dev->dtd_pool);
3402
3403 if (dev->ep_dqh)
3404 dma_free_coherent(&pdev->dev, dev->ep_dqh_size,
3405 dev->ep_dqh, dev->ep_dqh_dma);
3406
3407 /* release SRAM caching */
3408 if (dev->has_sram && dev->got_sram)
3409 sram_deinit(dev);
3410
3233 /* set device power state */ 3411 /* set device power state */
3234 pci_set_power_state(pdev, PCI_D3hot); 3412 pci_set_power_state(pdev, PCI_D3hot);
3235 3413
3236 /* enter PHY low power suspend */ 3414 /* enter PHY low power suspend */
3237 devlc = readl(&dev->op_regs->devlc); 3415 if (dev->pdev->device != 0x0829)
3238 VDBG(dev, "devlc = 0x%08x\n", devlc); 3416 langwell_phy_low_power(dev, 1);
3239 devlc |= LPM_PHCD;
3240 writel(devlc, &dev->op_regs->devlc);
3241 3417
3242 DBG(dev, "<--- %s()\n", __func__); 3418 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
3243 return 0; 3419 return 0;
3244} 3420}
3245 3421
@@ -3248,27 +3424,58 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
3248static int langwell_udc_resume(struct pci_dev *pdev) 3424static int langwell_udc_resume(struct pci_dev *pdev)
3249{ 3425{
3250 struct langwell_udc *dev = the_controller; 3426 struct langwell_udc *dev = the_controller;
3251 u32 devlc; 3427 size_t size;
3252 3428
3253 DBG(dev, "---> %s()\n", __func__); 3429 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
3254 3430
3255 /* exit PHY low power suspend */ 3431 /* exit PHY low power suspend */
3256 devlc = readl(&dev->op_regs->devlc); 3432 if (dev->pdev->device != 0x0829)
3257 VDBG(dev, "devlc = 0x%08x\n", devlc); 3433 langwell_phy_low_power(dev, 0);
3258 devlc &= ~LPM_PHCD;
3259 writel(devlc, &dev->op_regs->devlc);
3260 3434
3261 /* set device D0 power state */ 3435 /* set device D0 power state */
3262 pci_set_power_state(pdev, PCI_D0); 3436 pci_set_power_state(pdev, PCI_D0);
3263 3437
3438 /* enable SRAM caching if detected */
3439 if (dev->has_sram && !dev->got_sram)
3440 sram_init(dev);
3441
3442 /* allocate device dQH memory */
3443 size = dev->ep_max * sizeof(struct langwell_dqh);
3444 dev_vdbg(&dev->pdev->dev, "orig size = %d\n", size);
3445 if (size < DQH_ALIGNMENT)
3446 size = DQH_ALIGNMENT;
3447 else if ((size % DQH_ALIGNMENT) != 0) {
3448 size += DQH_ALIGNMENT + 1;
3449 size &= ~(DQH_ALIGNMENT - 1);
3450 }
3451 dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size,
3452 &dev->ep_dqh_dma, GFP_KERNEL);
3453 if (!dev->ep_dqh) {
3454 dev_err(&dev->pdev->dev, "allocate dQH memory failed\n");
3455 return -ENOMEM;
3456 }
3457 dev->ep_dqh_size = size;
3458 dev_vdbg(&dev->pdev->dev, "ep_dqh_size = %d\n", dev->ep_dqh_size);
3459
3460 /* create dTD dma_pool resource */
3461 dev->dtd_pool = dma_pool_create("langwell_dtd",
3462 &dev->pdev->dev,
3463 sizeof(struct langwell_dtd),
3464 DTD_ALIGNMENT,
3465 DMA_BOUNDARY);
3466
3467 if (!dev->dtd_pool)
3468 return -ENOMEM;
3469
3264 /* restore PCI state */ 3470 /* restore PCI state */
3265 pci_restore_state(pdev); 3471 pci_restore_state(pdev);
3266 3472
3267 /* enable IRQ handler */ 3473 /* enable IRQ handler */
3268 if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, driver_name, dev) 3474 if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED,
3269 != 0) { 3475 driver_name, dev) != 0) {
3270 ERROR(dev, "request interrupt %d failed\n", pdev->irq); 3476 dev_err(&dev->pdev->dev, "request interrupt %d failed\n",
3271 return -1; 3477 pdev->irq);
3478 return -EBUSY;
3272 } 3479 }
3273 dev->got_irq = 1; 3480 dev->got_irq = 1;
3274 3481
@@ -3290,7 +3497,7 @@ static int langwell_udc_resume(struct pci_dev *pdev)
3290 dev->ep0_state = WAIT_FOR_SETUP; 3497 dev->ep0_state = WAIT_FOR_SETUP;
3291 dev->ep0_dir = USB_DIR_OUT; 3498 dev->ep0_dir = USB_DIR_OUT;
3292 3499
3293 DBG(dev, "<--- %s()\n", __func__); 3500 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
3294 return 0; 3501 return 0;
3295} 3502}
3296 3503
@@ -3301,15 +3508,15 @@ static void langwell_udc_shutdown(struct pci_dev *pdev)
3301 struct langwell_udc *dev = the_controller; 3508 struct langwell_udc *dev = the_controller;
3302 u32 usbmode; 3509 u32 usbmode;
3303 3510
3304 DBG(dev, "---> %s()\n", __func__); 3511 dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
3305 3512
3306 /* reset controller mode to IDLE */ 3513 /* reset controller mode to IDLE */
3307 usbmode = readl(&dev->op_regs->usbmode); 3514 usbmode = readl(&dev->op_regs->usbmode);
3308 DBG(dev, "usbmode = 0x%08x\n", usbmode); 3515 dev_dbg(&dev->pdev->dev, "usbmode = 0x%08x\n", usbmode);
3309 usbmode &= (~3 | MODE_IDLE); 3516 usbmode &= (~3 | MODE_IDLE);
3310 writel(usbmode, &dev->op_regs->usbmode); 3517 writel(usbmode, &dev->op_regs->usbmode);
3311 3518
3312 DBG(dev, "<--- %s()\n", __func__); 3519 dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
3313} 3520}
3314 3521
3315/*-------------------------------------------------------------------------*/ 3522/*-------------------------------------------------------------------------*/
@@ -3324,7 +3531,6 @@ static const struct pci_device_id pci_ids[] = { {
3324}, { /* end: all zeroes */ } 3531}, { /* end: all zeroes */ }
3325}; 3532};
3326 3533
3327
3328MODULE_DEVICE_TABLE(pci, pci_ids); 3534MODULE_DEVICE_TABLE(pci, pci_ids);
3329 3535
3330 3536
@@ -3343,12 +3549,6 @@ static struct pci_driver langwell_pci_driver = {
3343}; 3549};
3344 3550
3345 3551
3346MODULE_DESCRIPTION(DRIVER_DESC);
3347MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>");
3348MODULE_VERSION(DRIVER_VERSION);
3349MODULE_LICENSE("GPL");
3350
3351
3352static int __init init(void) 3552static int __init init(void)
3353{ 3553{
3354#ifdef OTG_TRANSCEIVER 3554#ifdef OTG_TRANSCEIVER
@@ -3370,3 +3570,9 @@ static void __exit cleanup(void)
3370} 3570}
3371module_exit(cleanup); 3571module_exit(cleanup);
3372 3572
3573
3574MODULE_DESCRIPTION(DRIVER_DESC);
3575MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>");
3576MODULE_VERSION(DRIVER_VERSION);
3577MODULE_LICENSE("GPL");
3578
diff --git a/drivers/usb/gadget/langwell_udc.h b/drivers/usb/gadget/langwell_udc.h
index 9719934e1c08..f1d9c1bb04f3 100644
--- a/drivers/usb/gadget/langwell_udc.h
+++ b/drivers/usb/gadget/langwell_udc.h
@@ -18,11 +18,7 @@
18 */ 18 */
19 19
20#include <linux/usb/langwell_udc.h> 20#include <linux/usb/langwell_udc.h>
21
22#if defined(CONFIG_USB_LANGWELL_OTG)
23#include <linux/usb/langwell_otg.h> 21#include <linux/usb/langwell_otg.h>
24#endif
25
26 22
27/*-------------------------------------------------------------------------*/ 23/*-------------------------------------------------------------------------*/
28 24
@@ -199,7 +195,9 @@ struct langwell_udc {
199 vbus_active:1, 195 vbus_active:1,
200 suspended:1, 196 suspended:1,
201 stopped:1, 197 stopped:1,
202 lpm:1; /* LPM capability */ 198 lpm:1, /* LPM capability */
199 has_sram:1, /* SRAM caching */
200 got_sram:1;
203 201
204 /* pci state used to access those endpoints */ 202 /* pci state used to access those endpoints */
205 struct pci_dev *pdev; 203 struct pci_dev *pdev;
@@ -224,5 +222,12 @@ struct langwell_udc {
224 222
225 /* make sure release() is done */ 223 /* make sure release() is done */
226 struct completion *done; 224 struct completion *done;
225
226 /* for private SRAM caching */
227 unsigned int sram_addr;
228 unsigned int sram_size;
229
230 /* device status data for get_status request */
231 u16 dev_status;
227}; 232};
228 233
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index fded3fca793b..6b58bd8ce623 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -408,7 +408,8 @@ static void udc_enable(struct lh7a40x_udc *dev)
408/* 408/*
409 Register entry point for the peripheral controller driver. 409 Register entry point for the peripheral controller driver.
410*/ 410*/
411int usb_gadget_register_driver(struct usb_gadget_driver *driver) 411int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
412 int (*bind)(struct usb_gadget *))
412{ 413{
413 struct lh7a40x_udc *dev = the_controller; 414 struct lh7a40x_udc *dev = the_controller;
414 int retval; 415 int retval;
@@ -417,7 +418,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
417 418
418 if (!driver 419 if (!driver
419 || driver->speed != USB_SPEED_FULL 420 || driver->speed != USB_SPEED_FULL
420 || !driver->bind 421 || !bind
421 || !driver->disconnect 422 || !driver->disconnect
422 || !driver->setup) 423 || !driver->setup)
423 return -EINVAL; 424 return -EINVAL;
@@ -431,7 +432,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
431 dev->gadget.dev.driver = &driver->driver; 432 dev->gadget.dev.driver = &driver->driver;
432 433
433 device_add(&dev->gadget.dev); 434 device_add(&dev->gadget.dev);
434 retval = driver->bind(&dev->gadget); 435 retval = bind(&dev->gadget);
435 if (retval) { 436 if (retval) {
436 printk(KERN_WARNING "%s: bind to driver %s --> error %d\n", 437 printk(KERN_WARNING "%s: bind to driver %s --> error %d\n",
437 dev->gadget.name, driver->driver.name, retval); 438 dev->gadget.name, driver->driver.name, retval);
@@ -453,8 +454,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
453 454
454 return 0; 455 return 0;
455} 456}
456 457EXPORT_SYMBOL(usb_gadget_probe_driver);
457EXPORT_SYMBOL(usb_gadget_register_driver);
458 458
459/* 459/*
460 Unregister entry point for the peripheral controller driver. 460 Unregister entry point for the peripheral controller driver.
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index e03058fe23cb..51b19f3027e7 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1454,14 +1454,15 @@ static struct usb_ep_ops m66592_ep_ops = {
1454/*-------------------------------------------------------------------------*/ 1454/*-------------------------------------------------------------------------*/
1455static struct m66592 *the_controller; 1455static struct m66592 *the_controller;
1456 1456
1457int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1457int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1458 int (*bind)(struct usb_gadget *))
1458{ 1459{
1459 struct m66592 *m66592 = the_controller; 1460 struct m66592 *m66592 = the_controller;
1460 int retval; 1461 int retval;
1461 1462
1462 if (!driver 1463 if (!driver
1463 || driver->speed != USB_SPEED_HIGH 1464 || driver->speed != USB_SPEED_HIGH
1464 || !driver->bind 1465 || !bind
1465 || !driver->setup) 1466 || !driver->setup)
1466 return -EINVAL; 1467 return -EINVAL;
1467 if (!m66592) 1468 if (!m66592)
@@ -1480,7 +1481,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1480 goto error; 1481 goto error;
1481 } 1482 }
1482 1483
1483 retval = driver->bind (&m66592->gadget); 1484 retval = bind(&m66592->gadget);
1484 if (retval) { 1485 if (retval) {
1485 pr_err("bind to driver error (%d)\n", retval); 1486 pr_err("bind to driver error (%d)\n", retval);
1486 device_del(&m66592->gadget.dev); 1487 device_del(&m66592->gadget.dev);
@@ -1505,7 +1506,7 @@ error:
1505 1506
1506 return retval; 1507 return retval;
1507} 1508}
1508EXPORT_SYMBOL(usb_gadget_register_driver); 1509EXPORT_SYMBOL(usb_gadget_probe_driver);
1509 1510
1510int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 1511int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1511{ 1512{
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c
index 585f2559484d..0769179dbdb0 100644
--- a/drivers/usb/gadget/mass_storage.c
+++ b/drivers/usb/gadget/mass_storage.c
@@ -75,10 +75,6 @@ static struct usb_device_descriptor msg_device_desc = {
75 /* Vendor and product id can be overridden by module parameters. */ 75 /* Vendor and product id can be overridden by module parameters. */
76 .idVendor = cpu_to_le16(FSG_VENDOR_ID), 76 .idVendor = cpu_to_le16(FSG_VENDOR_ID),
77 .idProduct = cpu_to_le16(FSG_PRODUCT_ID), 77 .idProduct = cpu_to_le16(FSG_PRODUCT_ID),
78 /* .bcdDevice = f(hardware) */
79 /* .iManufacturer = DYNAMIC */
80 /* .iProduct = DYNAMIC */
81 /* NO SERIAL NUMBER */
82 .bNumConfigurations = 1, 78 .bNumConfigurations = 1,
83}; 79};
84 80
@@ -86,7 +82,8 @@ static struct usb_otg_descriptor otg_descriptor = {
86 .bLength = sizeof otg_descriptor, 82 .bLength = sizeof otg_descriptor,
87 .bDescriptorType = USB_DT_OTG, 83 .bDescriptorType = USB_DT_OTG,
88 84
89 /* REVISIT SRP-only hardware is possible, although 85 /*
86 * REVISIT SRP-only hardware is possible, although
90 * it would not be called "OTG" ... 87 * it would not be called "OTG" ...
91 */ 88 */
92 .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, 89 .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
@@ -98,33 +95,6 @@ static const struct usb_descriptor_header *otg_desc[] = {
98}; 95};
99 96
100 97
101/* string IDs are assigned dynamically */
102
103#define STRING_MANUFACTURER_IDX 0
104#define STRING_PRODUCT_IDX 1
105#define STRING_CONFIGURATION_IDX 2
106
107static char manufacturer[50];
108
109static struct usb_string strings_dev[] = {
110 [STRING_MANUFACTURER_IDX].s = manufacturer,
111 [STRING_PRODUCT_IDX].s = DRIVER_DESC,
112 [STRING_CONFIGURATION_IDX].s = "Self Powered",
113 { } /* end of list */
114};
115
116static struct usb_gadget_strings stringtab_dev = {
117 .language = 0x0409, /* en-us */
118 .strings = strings_dev,
119};
120
121static struct usb_gadget_strings *dev_strings[] = {
122 &stringtab_dev,
123 NULL,
124};
125
126
127
128/****************************** Configurations ******************************/ 98/****************************** Configurations ******************************/
129 99
130static struct fsg_module_parameters mod_data = { 100static struct fsg_module_parameters mod_data = {
@@ -141,7 +111,7 @@ static int msg_thread_exits(struct fsg_common *common)
141 return 0; 111 return 0;
142} 112}
143 113
144static int __ref msg_do_config(struct usb_configuration *c) 114static int __init msg_do_config(struct usb_configuration *c)
145{ 115{
146 static const struct fsg_operations ops = { 116 static const struct fsg_operations ops = {
147 .thread_exits = msg_thread_exits, 117 .thread_exits = msg_thread_exits,
@@ -171,54 +141,23 @@ static int __ref msg_do_config(struct usb_configuration *c)
171 141
172static struct usb_configuration msg_config_driver = { 142static struct usb_configuration msg_config_driver = {
173 .label = "Linux File-Backed Storage", 143 .label = "Linux File-Backed Storage",
174 .bind = msg_do_config,
175 .bConfigurationValue = 1, 144 .bConfigurationValue = 1,
176 /* .iConfiguration = DYNAMIC */
177 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 145 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
178}; 146};
179 147
180 148
181
182/****************************** Gadget Bind ******************************/ 149/****************************** Gadget Bind ******************************/
183 150
184 151static int __init msg_bind(struct usb_composite_dev *cdev)
185static int __ref msg_bind(struct usb_composite_dev *cdev)
186{ 152{
187 struct usb_gadget *gadget = cdev->gadget;
188 int status; 153 int status;
189 154
190 /* Allocate string descriptor numbers ... note that string 155 status = usb_add_config(cdev, &msg_config_driver, msg_do_config);
191 * contents can be overridden by the composite_dev glue.
192 */
193
194 /* device descriptor strings: manufacturer, product */
195 snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
196 init_utsname()->sysname, init_utsname()->release,
197 gadget->name);
198 status = usb_string_id(cdev);
199 if (status < 0) 156 if (status < 0)
200 return status; 157 return status;
201 strings_dev[STRING_MANUFACTURER_IDX].id = status;
202 msg_device_desc.iManufacturer = status;
203 158
204 status = usb_string_id(cdev); 159 dev_info(&cdev->gadget->dev,
205 if (status < 0) 160 DRIVER_DESC ", version: " DRIVER_VERSION "\n");
206 return status;
207 strings_dev[STRING_PRODUCT_IDX].id = status;
208 msg_device_desc.iProduct = status;
209
210 status = usb_string_id(cdev);
211 if (status < 0)
212 return status;
213 strings_dev[STRING_CONFIGURATION_IDX].id = status;
214 msg_config_driver.iConfiguration = status;
215
216 /* register our second configuration */
217 status = usb_add_config(cdev, &msg_config_driver);
218 if (status < 0)
219 return status;
220
221 dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
222 set_bit(0, &msg_registered); 161 set_bit(0, &msg_registered);
223 return 0; 162 return 0;
224} 163}
@@ -226,12 +165,11 @@ static int __ref msg_bind(struct usb_composite_dev *cdev)
226 165
227/****************************** Some noise ******************************/ 166/****************************** Some noise ******************************/
228 167
229
230static struct usb_composite_driver msg_driver = { 168static struct usb_composite_driver msg_driver = {
231 .name = "g_mass_storage", 169 .name = "g_mass_storage",
232 .dev = &msg_device_desc, 170 .dev = &msg_device_desc,
233 .strings = dev_strings, 171 .iProduct = DRIVER_DESC,
234 .bind = msg_bind, 172 .needs_serial = 1,
235}; 173};
236 174
237MODULE_DESCRIPTION(DRIVER_DESC); 175MODULE_DESCRIPTION(DRIVER_DESC);
@@ -240,7 +178,7 @@ MODULE_LICENSE("GPL");
240 178
241static int __init msg_init(void) 179static int __init msg_init(void)
242{ 180{
243 return usb_composite_register(&msg_driver); 181 return usb_composite_probe(&msg_driver, msg_bind);
244} 182}
245module_init(msg_init); 183module_init(msg_init);
246 184
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 795d76232167..d9feced348e3 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -74,8 +74,8 @@ MODULE_LICENSE("GPL");
74 74
75/***************************** Device Descriptor ****************************/ 75/***************************** Device Descriptor ****************************/
76 76
77#define MULTI_VENDOR_NUM 0x0525 /* XXX NetChip */ 77#define MULTI_VENDOR_NUM 0x1d6b /* Linux Foundation */
78#define MULTI_PRODUCT_NUM 0xa4ab /* XXX */ 78#define MULTI_PRODUCT_NUM 0x0104 /* Multifunction Composite Gadget */
79 79
80 80
81enum { 81enum {
@@ -121,8 +121,6 @@ static const struct usb_descriptor_header *otg_desc[] = {
121 121
122 122
123enum { 123enum {
124 MULTI_STRING_MANUFACTURER_IDX,
125 MULTI_STRING_PRODUCT_IDX,
126#ifdef CONFIG_USB_G_MULTI_RNDIS 124#ifdef CONFIG_USB_G_MULTI_RNDIS
127 MULTI_STRING_RNDIS_CONFIG_IDX, 125 MULTI_STRING_RNDIS_CONFIG_IDX,
128#endif 126#endif
@@ -131,11 +129,7 @@ enum {
131#endif 129#endif
132}; 130};
133 131
134static char manufacturer[50];
135
136static struct usb_string strings_dev[] = { 132static struct usb_string strings_dev[] = {
137 [MULTI_STRING_MANUFACTURER_IDX].s = manufacturer,
138 [MULTI_STRING_PRODUCT_IDX].s = DRIVER_DESC,
139#ifdef CONFIG_USB_G_MULTI_RNDIS 133#ifdef CONFIG_USB_G_MULTI_RNDIS
140 [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS", 134 [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS",
141#endif 135#endif
@@ -170,7 +164,7 @@ static u8 hostaddr[ETH_ALEN];
170 164
171#ifdef USB_ETH_RNDIS 165#ifdef USB_ETH_RNDIS
172 166
173static __ref int rndis_do_config(struct usb_configuration *c) 167static __init int rndis_do_config(struct usb_configuration *c)
174{ 168{
175 int ret; 169 int ret;
176 170
@@ -197,7 +191,6 @@ static __ref int rndis_do_config(struct usb_configuration *c)
197static int rndis_config_register(struct usb_composite_dev *cdev) 191static int rndis_config_register(struct usb_composite_dev *cdev)
198{ 192{
199 static struct usb_configuration config = { 193 static struct usb_configuration config = {
200 .bind = rndis_do_config,
201 .bConfigurationValue = MULTI_RNDIS_CONFIG_NUM, 194 .bConfigurationValue = MULTI_RNDIS_CONFIG_NUM,
202 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 195 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
203 }; 196 };
@@ -205,7 +198,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev)
205 config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s; 198 config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s;
206 config.iConfiguration = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].id; 199 config.iConfiguration = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].id;
207 200
208 return usb_add_config(cdev, &config); 201 return usb_add_config(cdev, &config, rndis_do_config);
209} 202}
210 203
211#else 204#else
@@ -222,7 +215,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev)
222 215
223#ifdef CONFIG_USB_G_MULTI_CDC 216#ifdef CONFIG_USB_G_MULTI_CDC
224 217
225static __ref int cdc_do_config(struct usb_configuration *c) 218static __init int cdc_do_config(struct usb_configuration *c)
226{ 219{
227 int ret; 220 int ret;
228 221
@@ -249,7 +242,6 @@ static __ref int cdc_do_config(struct usb_configuration *c)
249static int cdc_config_register(struct usb_composite_dev *cdev) 242static int cdc_config_register(struct usb_composite_dev *cdev)
250{ 243{
251 static struct usb_configuration config = { 244 static struct usb_configuration config = {
252 .bind = cdc_do_config,
253 .bConfigurationValue = MULTI_CDC_CONFIG_NUM, 245 .bConfigurationValue = MULTI_CDC_CONFIG_NUM,
254 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 246 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
255 }; 247 };
@@ -257,7 +249,7 @@ static int cdc_config_register(struct usb_composite_dev *cdev)
257 config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s; 249 config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s;
258 config.iConfiguration = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].id; 250 config.iConfiguration = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].id;
259 251
260 return usb_add_config(cdev, &config); 252 return usb_add_config(cdev, &config, cdc_do_config);
261} 253}
262 254
263#else 255#else
@@ -314,20 +306,11 @@ static int __ref multi_bind(struct usb_composite_dev *cdev)
314 device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099); 306 device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099);
315 } 307 }
316 308
317 /* allocate string descriptor numbers */ 309 /* allocate string IDs */
318 snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
319 init_utsname()->sysname, init_utsname()->release,
320 gadget->name);
321
322 status = usb_string_ids_tab(cdev, strings_dev); 310 status = usb_string_ids_tab(cdev, strings_dev);
323 if (unlikely(status < 0)) 311 if (unlikely(status < 0))
324 goto fail2; 312 goto fail2;
325 313
326 device_desc.iManufacturer =
327 strings_dev[MULTI_STRING_MANUFACTURER_IDX].id;
328 device_desc.iProduct =
329 strings_dev[MULTI_STRING_PRODUCT_IDX].id;
330
331 /* register configurations */ 314 /* register configurations */
332 status = rndis_config_register(cdev); 315 status = rndis_config_register(cdev);
333 if (unlikely(status < 0)) 316 if (unlikely(status < 0))
@@ -368,14 +351,15 @@ static struct usb_composite_driver multi_driver = {
368 .name = "g_multi", 351 .name = "g_multi",
369 .dev = &device_desc, 352 .dev = &device_desc,
370 .strings = dev_strings, 353 .strings = dev_strings,
371 .bind = multi_bind,
372 .unbind = __exit_p(multi_unbind), 354 .unbind = __exit_p(multi_unbind),
355 .iProduct = DRIVER_DESC,
356 .needs_serial = 1,
373}; 357};
374 358
375 359
376static int __init multi_init(void) 360static int __init multi_init(void)
377{ 361{
378 return usb_composite_register(&multi_driver); 362 return usb_composite_probe(&multi_driver, multi_bind);
379} 363}
380module_init(multi_init); 364module_init(multi_init);
381 365
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 9498be87a724..d09155b25d73 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1929,7 +1929,8 @@ static void ep0_start (struct net2280 *dev)
1929 * disconnect is reported. then a host may connect again, or 1929 * disconnect is reported. then a host may connect again, or
1930 * the driver might get unbound. 1930 * the driver might get unbound.
1931 */ 1931 */
1932int usb_gadget_register_driver (struct usb_gadget_driver *driver) 1932int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1933 int (*bind)(struct usb_gadget *))
1933{ 1934{
1934 struct net2280 *dev = the_controller; 1935 struct net2280 *dev = the_controller;
1935 int retval; 1936 int retval;
@@ -1941,8 +1942,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1941 */ 1942 */
1942 if (!driver 1943 if (!driver
1943 || driver->speed != USB_SPEED_HIGH 1944 || driver->speed != USB_SPEED_HIGH
1944 || !driver->bind 1945 || !bind || !driver->setup)
1945 || !driver->setup)
1946 return -EINVAL; 1946 return -EINVAL;
1947 if (!dev) 1947 if (!dev)
1948 return -ENODEV; 1948 return -ENODEV;
@@ -1957,7 +1957,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1957 driver->driver.bus = NULL; 1957 driver->driver.bus = NULL;
1958 dev->driver = driver; 1958 dev->driver = driver;
1959 dev->gadget.dev.driver = &driver->driver; 1959 dev->gadget.dev.driver = &driver->driver;
1960 retval = driver->bind (&dev->gadget); 1960 retval = bind(&dev->gadget);
1961 if (retval) { 1961 if (retval) {
1962 DEBUG (dev, "bind to driver %s --> %d\n", 1962 DEBUG (dev, "bind to driver %s --> %d\n",
1963 driver->driver.name, retval); 1963 driver->driver.name, retval);
@@ -1993,7 +1993,7 @@ err_unbind:
1993 dev->driver = NULL; 1993 dev->driver = NULL;
1994 return retval; 1994 return retval;
1995} 1995}
1996EXPORT_SYMBOL (usb_gadget_register_driver); 1996EXPORT_SYMBOL(usb_gadget_probe_driver);
1997 1997
1998static void 1998static void
1999stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver) 1999stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 7d6b66a85724..b5364f9d7cd2 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -135,7 +135,6 @@ static int __init nokia_bind_config(struct usb_configuration *c)
135 135
136static struct usb_configuration nokia_config_500ma_driver = { 136static struct usb_configuration nokia_config_500ma_driver = {
137 .label = "Bus Powered", 137 .label = "Bus Powered",
138 .bind = nokia_bind_config,
139 .bConfigurationValue = 1, 138 .bConfigurationValue = 1,
140 /* .iConfiguration = DYNAMIC */ 139 /* .iConfiguration = DYNAMIC */
141 .bmAttributes = USB_CONFIG_ATT_ONE, 140 .bmAttributes = USB_CONFIG_ATT_ONE,
@@ -144,7 +143,6 @@ static struct usb_configuration nokia_config_500ma_driver = {
144 143
145static struct usb_configuration nokia_config_100ma_driver = { 144static struct usb_configuration nokia_config_100ma_driver = {
146 .label = "Self Powered", 145 .label = "Self Powered",
147 .bind = nokia_bind_config,
148 .bConfigurationValue = 2, 146 .bConfigurationValue = 2,
149 /* .iConfiguration = DYNAMIC */ 147 /* .iConfiguration = DYNAMIC */
150 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, 148 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
@@ -206,11 +204,13 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
206 } 204 }
207 205
208 /* finaly register the configuration */ 206 /* finaly register the configuration */
209 status = usb_add_config(cdev, &nokia_config_500ma_driver); 207 status = usb_add_config(cdev, &nokia_config_500ma_driver,
208 nokia_bind_config);
210 if (status < 0) 209 if (status < 0)
211 goto err_usb; 210 goto err_usb;
212 211
213 status = usb_add_config(cdev, &nokia_config_100ma_driver); 212 status = usb_add_config(cdev, &nokia_config_100ma_driver,
213 nokia_bind_config);
214 if (status < 0) 214 if (status < 0)
215 goto err_usb; 215 goto err_usb;
216 216
@@ -241,13 +241,12 @@ static struct usb_composite_driver nokia_driver = {
241 .name = "g_nokia", 241 .name = "g_nokia",
242 .dev = &device_desc, 242 .dev = &device_desc,
243 .strings = dev_strings, 243 .strings = dev_strings,
244 .bind = nokia_bind,
245 .unbind = __exit_p(nokia_unbind), 244 .unbind = __exit_p(nokia_unbind),
246}; 245};
247 246
248static int __init nokia_init(void) 247static int __init nokia_init(void)
249{ 248{
250 return usb_composite_register(&nokia_driver); 249 return usb_composite_probe(&nokia_driver, nokia_bind);
251} 250}
252module_init(nokia_init); 251module_init(nokia_init);
253 252
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index f81e4f025f23..61d3ca6619bb 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2102,7 +2102,8 @@ static inline int machine_without_vbus_sense(void)
2102 ); 2102 );
2103} 2103}
2104 2104
2105int usb_gadget_register_driver (struct usb_gadget_driver *driver) 2105int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2106 int (*bind)(struct usb_gadget *))
2106{ 2107{
2107 int status = -ENODEV; 2108 int status = -ENODEV;
2108 struct omap_ep *ep; 2109 struct omap_ep *ep;
@@ -2114,8 +2115,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2114 if (!driver 2115 if (!driver
2115 // FIXME if otg, check: driver->is_otg 2116 // FIXME if otg, check: driver->is_otg
2116 || driver->speed < USB_SPEED_FULL 2117 || driver->speed < USB_SPEED_FULL
2117 || !driver->bind 2118 || !bind || !driver->setup)
2118 || !driver->setup)
2119 return -EINVAL; 2119 return -EINVAL;
2120 2120
2121 spin_lock_irqsave(&udc->lock, flags); 2121 spin_lock_irqsave(&udc->lock, flags);
@@ -2145,7 +2145,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2145 if (udc->dc_clk != NULL) 2145 if (udc->dc_clk != NULL)
2146 omap_udc_enable_clock(1); 2146 omap_udc_enable_clock(1);
2147 2147
2148 status = driver->bind (&udc->gadget); 2148 status = bind(&udc->gadget);
2149 if (status) { 2149 if (status) {
2150 DBG("bind to %s --> %d\n", driver->driver.name, status); 2150 DBG("bind to %s --> %d\n", driver->driver.name, status);
2151 udc->gadget.dev.driver = NULL; 2151 udc->gadget.dev.driver = NULL;
@@ -2186,7 +2186,7 @@ done:
2186 omap_udc_enable_clock(0); 2186 omap_udc_enable_clock(0);
2187 return status; 2187 return status;
2188} 2188}
2189EXPORT_SYMBOL(usb_gadget_register_driver); 2189EXPORT_SYMBOL(usb_gadget_probe_driver);
2190 2190
2191int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) 2191int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
2192{ 2192{
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 327a92a137b4..2fc8636316c5 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -1348,7 +1348,7 @@ printer_unbind(struct usb_gadget *gadget)
1348 set_gadget_data(gadget, NULL); 1348 set_gadget_data(gadget, NULL);
1349} 1349}
1350 1350
1351static int __ref 1351static int __init
1352printer_bind(struct usb_gadget *gadget) 1352printer_bind(struct usb_gadget *gadget)
1353{ 1353{
1354 struct printer_dev *dev; 1354 struct printer_dev *dev;
@@ -1544,7 +1544,6 @@ static struct usb_gadget_driver printer_driver = {
1544 .speed = DEVSPEED, 1544 .speed = DEVSPEED,
1545 1545
1546 .function = (char *) driver_desc, 1546 .function = (char *) driver_desc,
1547 .bind = printer_bind,
1548 .unbind = printer_unbind, 1547 .unbind = printer_unbind,
1549 1548
1550 .setup = printer_setup, 1549 .setup = printer_setup,
@@ -1580,11 +1579,11 @@ init(void)
1580 return status; 1579 return status;
1581 } 1580 }
1582 1581
1583 status = usb_gadget_register_driver(&printer_driver); 1582 status = usb_gadget_probe_driver(&printer_driver, printer_bind);
1584 if (status) { 1583 if (status) {
1585 class_destroy(usb_gadget_class); 1584 class_destroy(usb_gadget_class);
1586 unregister_chrdev_region(g_printer_devno, 1); 1585 unregister_chrdev_region(g_printer_devno, 1);
1587 DBG(dev, "usb_gadget_register_driver %x\n", status); 1586 DBG(dev, "usb_gadget_probe_driver %x\n", status);
1588 } 1587 }
1589 1588
1590 return status; 1589 return status;
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index be5fb34d9602..b37f92cb71bc 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -1280,14 +1280,15 @@ static void udc_enable (struct pxa25x_udc *dev)
1280 * disconnect is reported. then a host may connect again, or 1280 * disconnect is reported. then a host may connect again, or
1281 * the driver might get unbound. 1281 * the driver might get unbound.
1282 */ 1282 */
1283int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1283int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1284 int (*bind)(struct usb_gadget *))
1284{ 1285{
1285 struct pxa25x_udc *dev = the_controller; 1286 struct pxa25x_udc *dev = the_controller;
1286 int retval; 1287 int retval;
1287 1288
1288 if (!driver 1289 if (!driver
1289 || driver->speed < USB_SPEED_FULL 1290 || driver->speed < USB_SPEED_FULL
1290 || !driver->bind 1291 || !bind
1291 || !driver->disconnect 1292 || !driver->disconnect
1292 || !driver->setup) 1293 || !driver->setup)
1293 return -EINVAL; 1294 return -EINVAL;
@@ -1308,7 +1309,7 @@ fail:
1308 dev->gadget.dev.driver = NULL; 1309 dev->gadget.dev.driver = NULL;
1309 return retval; 1310 return retval;
1310 } 1311 }
1311 retval = driver->bind(&dev->gadget); 1312 retval = bind(&dev->gadget);
1312 if (retval) { 1313 if (retval) {
1313 DMSG("bind to driver %s --> error %d\n", 1314 DMSG("bind to driver %s --> error %d\n",
1314 driver->driver.name, retval); 1315 driver->driver.name, retval);
@@ -1338,7 +1339,7 @@ fail:
1338bind_fail: 1339bind_fail:
1339 return retval; 1340 return retval;
1340} 1341}
1341EXPORT_SYMBOL(usb_gadget_register_driver); 1342EXPORT_SYMBOL(usb_gadget_probe_driver);
1342 1343
1343static void 1344static void
1344stop_activity(struct pxa25x_udc *dev, struct usb_gadget_driver *driver) 1345stop_activity(struct pxa25x_udc *dev, struct usb_gadget_driver *driver)
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 980762453a9c..027d66f81620 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1792,8 +1792,9 @@ static void udc_enable(struct pxa_udc *udc)
1792} 1792}
1793 1793
1794/** 1794/**
1795 * usb_gadget_register_driver - Register gadget driver 1795 * usb_gadget_probe_driver - Register gadget driver
1796 * @driver: gadget driver 1796 * @driver: gadget driver
1797 * @bind: bind function
1797 * 1798 *
1798 * When a driver is successfully registered, it will receive control requests 1799 * When a driver is successfully registered, it will receive control requests
1799 * including set_configuration(), which enables non-control requests. Then 1800 * including set_configuration(), which enables non-control requests. Then
@@ -1805,12 +1806,13 @@ static void udc_enable(struct pxa_udc *udc)
1805 * 1806 *
1806 * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise 1807 * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise
1807 */ 1808 */
1808int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1809int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1810 int (*bind)(struct usb_gadget *))
1809{ 1811{
1810 struct pxa_udc *udc = the_controller; 1812 struct pxa_udc *udc = the_controller;
1811 int retval; 1813 int retval;
1812 1814
1813 if (!driver || driver->speed < USB_SPEED_FULL || !driver->bind 1815 if (!driver || driver->speed < USB_SPEED_FULL || !bind
1814 || !driver->disconnect || !driver->setup) 1816 || !driver->disconnect || !driver->setup)
1815 return -EINVAL; 1817 return -EINVAL;
1816 if (!udc) 1818 if (!udc)
@@ -1828,7 +1830,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1828 dev_err(udc->dev, "device_add error %d\n", retval); 1830 dev_err(udc->dev, "device_add error %d\n", retval);
1829 goto add_fail; 1831 goto add_fail;
1830 } 1832 }
1831 retval = driver->bind(&udc->gadget); 1833 retval = bind(&udc->gadget);
1832 if (retval) { 1834 if (retval) {
1833 dev_err(udc->dev, "bind to driver %s --> error %d\n", 1835 dev_err(udc->dev, "bind to driver %s --> error %d\n",
1834 driver->driver.name, retval); 1836 driver->driver.name, retval);
@@ -1859,7 +1861,7 @@ add_fail:
1859 udc->gadget.dev.driver = NULL; 1861 udc->gadget.dev.driver = NULL;
1860 return retval; 1862 return retval;
1861} 1863}
1862EXPORT_SYMBOL(usb_gadget_register_driver); 1864EXPORT_SYMBOL(usb_gadget_probe_driver);
1863 1865
1864 1866
1865/** 1867/**
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index 2456ccd9965e..20d43da319ae 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -42,6 +42,7 @@ static const char *r8a66597_ep_name[] = {
42 "ep8", "ep9", 42 "ep8", "ep9",
43}; 43};
44 44
45static void init_controller(struct r8a66597 *r8a66597);
45static void disable_controller(struct r8a66597 *r8a66597); 46static void disable_controller(struct r8a66597 *r8a66597);
46static void irq_ep0_write(struct r8a66597_ep *ep, struct r8a66597_request *req); 47static void irq_ep0_write(struct r8a66597_ep *ep, struct r8a66597_request *req);
47static void irq_packet_write(struct r8a66597_ep *ep, 48static void irq_packet_write(struct r8a66597_ep *ep,
@@ -104,6 +105,8 @@ __acquires(r8a66597->lock)
104 spin_lock(&r8a66597->lock); 105 spin_lock(&r8a66597->lock);
105 106
106 disable_controller(r8a66597); 107 disable_controller(r8a66597);
108 init_controller(r8a66597);
109 r8a66597_bset(r8a66597, VBSE, INTENB0);
107 INIT_LIST_HEAD(&r8a66597->ep[0].queue); 110 INIT_LIST_HEAD(&r8a66597->ep[0].queue);
108} 111}
109 112
@@ -274,7 +277,7 @@ static int pipe_buffer_setting(struct r8a66597 *r8a66597,
274 } 277 }
275 278
276 if (buf_bsize && ((bufnum + 16) >= R8A66597_MAX_BUFNUM)) { 279 if (buf_bsize && ((bufnum + 16) >= R8A66597_MAX_BUFNUM)) {
277 pr_err(KERN_ERR "r8a66597 pipe memory is insufficient\n"); 280 pr_err("r8a66597 pipe memory is insufficient\n");
278 return -ENOMEM; 281 return -ENOMEM;
279 } 282 }
280 283
@@ -1405,14 +1408,15 @@ static struct usb_ep_ops r8a66597_ep_ops = {
1405/*-------------------------------------------------------------------------*/ 1408/*-------------------------------------------------------------------------*/
1406static struct r8a66597 *the_controller; 1409static struct r8a66597 *the_controller;
1407 1410
1408int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1411int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1412 int (*bind)(struct usb_gadget *))
1409{ 1413{
1410 struct r8a66597 *r8a66597 = the_controller; 1414 struct r8a66597 *r8a66597 = the_controller;
1411 int retval; 1415 int retval;
1412 1416
1413 if (!driver 1417 if (!driver
1414 || driver->speed != USB_SPEED_HIGH 1418 || driver->speed != USB_SPEED_HIGH
1415 || !driver->bind 1419 || !bind
1416 || !driver->setup) 1420 || !driver->setup)
1417 return -EINVAL; 1421 return -EINVAL;
1418 if (!r8a66597) 1422 if (!r8a66597)
@@ -1431,7 +1435,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1431 goto error; 1435 goto error;
1432 } 1436 }
1433 1437
1434 retval = driver->bind(&r8a66597->gadget); 1438 retval = bind(&r8a66597->gadget);
1435 if (retval) { 1439 if (retval) {
1436 printk(KERN_ERR "bind to driver error (%d)\n", retval); 1440 printk(KERN_ERR "bind to driver error (%d)\n", retval);
1437 device_del(&r8a66597->gadget.dev); 1441 device_del(&r8a66597->gadget.dev);
@@ -1456,7 +1460,7 @@ error:
1456 1460
1457 return retval; 1461 return retval;
1458} 1462}
1459EXPORT_SYMBOL(usb_gadget_register_driver); 1463EXPORT_SYMBOL(usb_gadget_probe_driver);
1460 1464
1461int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 1465int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1462{ 1466{
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h
index f763b5190afa..5fc22e09a0f1 100644
--- a/drivers/usb/gadget/r8a66597-udc.h
+++ b/drivers/usb/gadget/r8a66597-udc.h
@@ -136,7 +136,7 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,
136 int len) 136 int len)
137{ 137{
138 void __iomem *fifoaddr = r8a66597->reg + offset; 138 void __iomem *fifoaddr = r8a66597->reg + offset;
139 unsigned int data; 139 unsigned int data = 0;
140 int i; 140 int i;
141 141
142 if (r8a66597->pdata->on_chip) { 142 if (r8a66597->pdata->on_chip) {
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 972d5ddd1e18..5b314041dfa9 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -61,17 +61,17 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging");
61#define RNDIS_MAX_CONFIGS 1 61#define RNDIS_MAX_CONFIGS 1
62 62
63 63
64static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS]; 64static rndis_params rndis_per_dev_params[RNDIS_MAX_CONFIGS];
65 65
66/* Driver Version */ 66/* Driver Version */
67static const __le32 rndis_driver_version = cpu_to_le32 (1); 67static const __le32 rndis_driver_version = cpu_to_le32(1);
68 68
69/* Function Prototypes */ 69/* Function Prototypes */
70static rndis_resp_t *rndis_add_response (int configNr, u32 length); 70static rndis_resp_t *rndis_add_response(int configNr, u32 length);
71 71
72 72
73/* supported OIDs */ 73/* supported OIDs */
74static const u32 oid_supported_list [] = 74static const u32 oid_supported_list[] =
75{ 75{
76 /* the general stuff */ 76 /* the general stuff */
77 OID_GEN_SUPPORTED_LIST, 77 OID_GEN_SUPPORTED_LIST,
@@ -161,21 +161,20 @@ static const u32 oid_supported_list [] =
161 161
162 162
163/* NDIS Functions */ 163/* NDIS Functions */
164static int 164static int gen_ndis_query_resp(int configNr, u32 OID, u8 *buf,
165gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, 165 unsigned buf_len, rndis_resp_t *r)
166 rndis_resp_t *r)
167{ 166{
168 int retval = -ENOTSUPP; 167 int retval = -ENOTSUPP;
169 u32 length = 4; /* usually */ 168 u32 length = 4; /* usually */
170 __le32 *outbuf; 169 __le32 *outbuf;
171 int i, count; 170 int i, count;
172 rndis_query_cmplt_type *resp; 171 rndis_query_cmplt_type *resp;
173 struct net_device *net; 172 struct net_device *net;
174 struct rtnl_link_stats64 temp; 173 struct rtnl_link_stats64 temp;
175 const struct rtnl_link_stats64 *stats; 174 const struct rtnl_link_stats64 *stats;
176 175
177 if (!r) return -ENOMEM; 176 if (!r) return -ENOMEM;
178 resp = (rndis_query_cmplt_type *) r->buf; 177 resp = (rndis_query_cmplt_type *)r->buf;
179 178
180 if (!resp) return -ENOMEM; 179 if (!resp) return -ENOMEM;
181 180
@@ -191,8 +190,8 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
191 } 190 }
192 191
193 /* response goes here, right after the header */ 192 /* response goes here, right after the header */
194 outbuf = (__le32 *) &resp[1]; 193 outbuf = (__le32 *)&resp[1];
195 resp->InformationBufferOffset = cpu_to_le32 (16); 194 resp->InformationBufferOffset = cpu_to_le32(16);
196 195
197 net = rndis_per_dev_params[configNr].dev; 196 net = rndis_per_dev_params[configNr].dev;
198 stats = dev_get_stats(net, &temp); 197 stats = dev_get_stats(net, &temp);
@@ -204,10 +203,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
204 /* mandatory */ 203 /* mandatory */
205 case OID_GEN_SUPPORTED_LIST: 204 case OID_GEN_SUPPORTED_LIST:
206 pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__); 205 pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__);
207 length = sizeof (oid_supported_list); 206 length = sizeof(oid_supported_list);
208 count = length / sizeof (u32); 207 count = length / sizeof(u32);
209 for (i = 0; i < count; i++) 208 for (i = 0; i < count; i++)
210 outbuf[i] = cpu_to_le32 (oid_supported_list[i]); 209 outbuf[i] = cpu_to_le32(oid_supported_list[i]);
211 retval = 0; 210 retval = 0;
212 break; 211 break;
213 212
@@ -220,14 +219,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
220 * reddite ergo quae sunt Caesaris Caesari 219 * reddite ergo quae sunt Caesaris Caesari
221 * et quae sunt Dei Deo! 220 * et quae sunt Dei Deo!
222 */ 221 */
223 *outbuf = cpu_to_le32 (0); 222 *outbuf = cpu_to_le32(0);
224 retval = 0; 223 retval = 0;
225 break; 224 break;
226 225
227 /* mandatory */ 226 /* mandatory */
228 case OID_GEN_MEDIA_SUPPORTED: 227 case OID_GEN_MEDIA_SUPPORTED:
229 pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); 228 pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__);
230 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 229 *outbuf = cpu_to_le32(rndis_per_dev_params[configNr].medium);
231 retval = 0; 230 retval = 0;
232 break; 231 break;
233 232
@@ -235,16 +234,16 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
235 case OID_GEN_MEDIA_IN_USE: 234 case OID_GEN_MEDIA_IN_USE:
236 pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__); 235 pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__);
237 /* one medium, one transport... (maybe you do it better) */ 236 /* one medium, one transport... (maybe you do it better) */
238 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 237 *outbuf = cpu_to_le32(rndis_per_dev_params[configNr].medium);
239 retval = 0; 238 retval = 0;
240 break; 239 break;
241 240
242 /* mandatory */ 241 /* mandatory */
243 case OID_GEN_MAXIMUM_FRAME_SIZE: 242 case OID_GEN_MAXIMUM_FRAME_SIZE:
244 pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); 243 pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__);
245 if (rndis_per_dev_params [configNr].dev) { 244 if (rndis_per_dev_params[configNr].dev) {
246 *outbuf = cpu_to_le32 ( 245 *outbuf = cpu_to_le32(
247 rndis_per_dev_params [configNr].dev->mtu); 246 rndis_per_dev_params[configNr].dev->mtu);
248 retval = 0; 247 retval = 0;
249 } 248 }
250 break; 249 break;
@@ -253,21 +252,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
253 case OID_GEN_LINK_SPEED: 252 case OID_GEN_LINK_SPEED:
254 if (rndis_debug > 1) 253 if (rndis_debug > 1)
255 pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); 254 pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__);
256 if (rndis_per_dev_params [configNr].media_state 255 if (rndis_per_dev_params[configNr].media_state
257 == NDIS_MEDIA_STATE_DISCONNECTED) 256 == NDIS_MEDIA_STATE_DISCONNECTED)
258 *outbuf = cpu_to_le32 (0); 257 *outbuf = cpu_to_le32(0);
259 else 258 else
260 *outbuf = cpu_to_le32 ( 259 *outbuf = cpu_to_le32(
261 rndis_per_dev_params [configNr].speed); 260 rndis_per_dev_params[configNr].speed);
262 retval = 0; 261 retval = 0;
263 break; 262 break;
264 263
265 /* mandatory */ 264 /* mandatory */
266 case OID_GEN_TRANSMIT_BLOCK_SIZE: 265 case OID_GEN_TRANSMIT_BLOCK_SIZE:
267 pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); 266 pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__);
268 if (rndis_per_dev_params [configNr].dev) { 267 if (rndis_per_dev_params[configNr].dev) {
269 *outbuf = cpu_to_le32 ( 268 *outbuf = cpu_to_le32(
270 rndis_per_dev_params [configNr].dev->mtu); 269 rndis_per_dev_params[configNr].dev->mtu);
271 retval = 0; 270 retval = 0;
272 } 271 }
273 break; 272 break;
@@ -275,9 +274,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
275 /* mandatory */ 274 /* mandatory */
276 case OID_GEN_RECEIVE_BLOCK_SIZE: 275 case OID_GEN_RECEIVE_BLOCK_SIZE:
277 pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); 276 pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__);
278 if (rndis_per_dev_params [configNr].dev) { 277 if (rndis_per_dev_params[configNr].dev) {
279 *outbuf = cpu_to_le32 ( 278 *outbuf = cpu_to_le32(
280 rndis_per_dev_params [configNr].dev->mtu); 279 rndis_per_dev_params[configNr].dev->mtu);
281 retval = 0; 280 retval = 0;
282 } 281 }
283 break; 282 break;
@@ -285,18 +284,20 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
285 /* mandatory */ 284 /* mandatory */
286 case OID_GEN_VENDOR_ID: 285 case OID_GEN_VENDOR_ID:
287 pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__); 286 pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__);
288 *outbuf = cpu_to_le32 ( 287 *outbuf = cpu_to_le32(
289 rndis_per_dev_params [configNr].vendorID); 288 rndis_per_dev_params[configNr].vendorID);
290 retval = 0; 289 retval = 0;
291 break; 290 break;
292 291
293 /* mandatory */ 292 /* mandatory */
294 case OID_GEN_VENDOR_DESCRIPTION: 293 case OID_GEN_VENDOR_DESCRIPTION:
295 pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); 294 pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
296 if ( rndis_per_dev_params [configNr].vendorDescr ) { 295 if (rndis_per_dev_params[configNr].vendorDescr) {
297 length = strlen (rndis_per_dev_params [configNr].vendorDescr); 296 length = strlen(rndis_per_dev_params[configNr].
298 memcpy (outbuf, 297 vendorDescr);
299 rndis_per_dev_params [configNr].vendorDescr, length); 298 memcpy(outbuf,
299 rndis_per_dev_params[configNr].vendorDescr,
300 length);
300 } else { 301 } else {
301 outbuf[0] = 0; 302 outbuf[0] = 0;
302 } 303 }
@@ -313,7 +314,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
313 /* mandatory */ 314 /* mandatory */
314 case OID_GEN_CURRENT_PACKET_FILTER: 315 case OID_GEN_CURRENT_PACKET_FILTER:
315 pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); 316 pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__);
316 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); 317 *outbuf = cpu_to_le32(*rndis_per_dev_params[configNr].filter);
317 retval = 0; 318 retval = 0;
318 break; 319 break;
319 320
@@ -328,14 +329,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
328 case OID_GEN_MEDIA_CONNECT_STATUS: 329 case OID_GEN_MEDIA_CONNECT_STATUS:
329 if (rndis_debug > 1) 330 if (rndis_debug > 1)
330 pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); 331 pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__);
331 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 332 *outbuf = cpu_to_le32(rndis_per_dev_params[configNr]
332 .media_state); 333 .media_state);
333 retval = 0; 334 retval = 0;
334 break; 335 break;
335 336
336 case OID_GEN_PHYSICAL_MEDIUM: 337 case OID_GEN_PHYSICAL_MEDIUM:
337 pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); 338 pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
338 *outbuf = cpu_to_le32 (0); 339 *outbuf = cpu_to_le32(0);
339 retval = 0; 340 retval = 0;
340 break; 341 break;
341 342
@@ -409,10 +410,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
409 /* mandatory */ 410 /* mandatory */
410 case OID_802_3_PERMANENT_ADDRESS: 411 case OID_802_3_PERMANENT_ADDRESS:
411 pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); 412 pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__);
412 if (rndis_per_dev_params [configNr].dev) { 413 if (rndis_per_dev_params[configNr].dev) {
413 length = ETH_ALEN; 414 length = ETH_ALEN;
414 memcpy (outbuf, 415 memcpy(outbuf,
415 rndis_per_dev_params [configNr].host_mac, 416 rndis_per_dev_params[configNr].host_mac,
416 length); 417 length);
417 retval = 0; 418 retval = 0;
418 } 419 }
@@ -421,9 +422,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
421 /* mandatory */ 422 /* mandatory */
422 case OID_802_3_CURRENT_ADDRESS: 423 case OID_802_3_CURRENT_ADDRESS:
423 pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); 424 pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__);
424 if (rndis_per_dev_params [configNr].dev) { 425 if (rndis_per_dev_params[configNr].dev) {
425 length = ETH_ALEN; 426 length = ETH_ALEN;
426 memcpy (outbuf, 427 memcpy(outbuf,
427 rndis_per_dev_params [configNr].host_mac, 428 rndis_per_dev_params [configNr].host_mac,
428 length); 429 length);
429 retval = 0; 430 retval = 0;
@@ -434,7 +435,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
434 case OID_802_3_MULTICAST_LIST: 435 case OID_802_3_MULTICAST_LIST:
435 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); 436 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__);
436 /* Multicast base address only */ 437 /* Multicast base address only */
437 *outbuf = cpu_to_le32 (0xE0000000); 438 *outbuf = cpu_to_le32(0xE0000000);
438 retval = 0; 439 retval = 0;
439 break; 440 break;
440 441
@@ -442,7 +443,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
442 case OID_802_3_MAXIMUM_LIST_SIZE: 443 case OID_802_3_MAXIMUM_LIST_SIZE:
443 pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); 444 pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__);
444 /* Multicast base address only */ 445 /* Multicast base address only */
445 *outbuf = cpu_to_le32 (1); 446 *outbuf = cpu_to_le32(1);
446 retval = 0; 447 retval = 0;
447 break; 448 break;
448 449
@@ -466,14 +467,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
466 /* mandatory */ 467 /* mandatory */
467 case OID_802_3_XMIT_ONE_COLLISION: 468 case OID_802_3_XMIT_ONE_COLLISION:
468 pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); 469 pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__);
469 *outbuf = cpu_to_le32 (0); 470 *outbuf = cpu_to_le32(0);
470 retval = 0; 471 retval = 0;
471 break; 472 break;
472 473
473 /* mandatory */ 474 /* mandatory */
474 case OID_802_3_XMIT_MORE_COLLISIONS: 475 case OID_802_3_XMIT_MORE_COLLISIONS:
475 pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); 476 pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__);
476 *outbuf = cpu_to_le32 (0); 477 *outbuf = cpu_to_le32(0);
477 retval = 0; 478 retval = 0;
478 break; 479 break;
479 480
@@ -484,22 +485,22 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
484 if (retval < 0) 485 if (retval < 0)
485 length = 0; 486 length = 0;
486 487
487 resp->InformationBufferLength = cpu_to_le32 (length); 488 resp->InformationBufferLength = cpu_to_le32(length);
488 r->length = length + sizeof *resp; 489 r->length = length + sizeof(*resp);
489 resp->MessageLength = cpu_to_le32 (r->length); 490 resp->MessageLength = cpu_to_le32(r->length);
490 return retval; 491 return retval;
491} 492}
492 493
493static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, 494static int gen_ndis_set_resp(u8 configNr, u32 OID, u8 *buf, u32 buf_len,
494 rndis_resp_t *r) 495 rndis_resp_t *r)
495{ 496{
496 rndis_set_cmplt_type *resp; 497 rndis_set_cmplt_type *resp;
497 int i, retval = -ENOTSUPP; 498 int i, retval = -ENOTSUPP;
498 struct rndis_params *params; 499 struct rndis_params *params;
499 500
500 if (!r) 501 if (!r)
501 return -ENOMEM; 502 return -ENOMEM;
502 resp = (rndis_set_cmplt_type *) r->buf; 503 resp = (rndis_set_cmplt_type *)r->buf;
503 if (!resp) 504 if (!resp)
504 return -ENOMEM; 505 return -ENOMEM;
505 506
@@ -514,7 +515,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
514 } 515 }
515 } 516 }
516 517
517 params = &rndis_per_dev_params [configNr]; 518 params = &rndis_per_dev_params[configNr];
518 switch (OID) { 519 switch (OID) {
519 case OID_GEN_CURRENT_PACKET_FILTER: 520 case OID_GEN_CURRENT_PACKET_FILTER:
520 521
@@ -537,11 +538,11 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
537 params->state = RNDIS_DATA_INITIALIZED; 538 params->state = RNDIS_DATA_INITIALIZED;
538 netif_carrier_on(params->dev); 539 netif_carrier_on(params->dev);
539 if (netif_running(params->dev)) 540 if (netif_running(params->dev))
540 netif_wake_queue (params->dev); 541 netif_wake_queue(params->dev);
541 } else { 542 } else {
542 params->state = RNDIS_INITIALIZED; 543 params->state = RNDIS_INITIALIZED;
543 netif_carrier_off (params->dev); 544 netif_carrier_off(params->dev);
544 netif_stop_queue (params->dev); 545 netif_stop_queue(params->dev);
545 } 546 }
546 break; 547 break;
547 548
@@ -563,48 +564,47 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
563 * Response Functions 564 * Response Functions
564 */ 565 */
565 566
566static int rndis_init_response (int configNr, rndis_init_msg_type *buf) 567static int rndis_init_response(int configNr, rndis_init_msg_type *buf)
567{ 568{
568 rndis_init_cmplt_type *resp; 569 rndis_init_cmplt_type *resp;
569 rndis_resp_t *r; 570 rndis_resp_t *r;
570 struct rndis_params *params = rndis_per_dev_params + configNr; 571 struct rndis_params *params = rndis_per_dev_params + configNr;
571 572
572 if (!params->dev) 573 if (!params->dev)
573 return -ENOTSUPP; 574 return -ENOTSUPP;
574 575
575 r = rndis_add_response (configNr, sizeof (rndis_init_cmplt_type)); 576 r = rndis_add_response(configNr, sizeof(rndis_init_cmplt_type));
576 if (!r) 577 if (!r)
577 return -ENOMEM; 578 return -ENOMEM;
578 resp = (rndis_init_cmplt_type *) r->buf; 579 resp = (rndis_init_cmplt_type *)r->buf;
579 580
580 resp->MessageType = cpu_to_le32 ( 581 resp->MessageType = cpu_to_le32(REMOTE_NDIS_INITIALIZE_CMPLT);
581 REMOTE_NDIS_INITIALIZE_CMPLT); 582 resp->MessageLength = cpu_to_le32(52);
582 resp->MessageLength = cpu_to_le32 (52);
583 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 583 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
584 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); 584 resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
585 resp->MajorVersion = cpu_to_le32 (RNDIS_MAJOR_VERSION); 585 resp->MajorVersion = cpu_to_le32(RNDIS_MAJOR_VERSION);
586 resp->MinorVersion = cpu_to_le32 (RNDIS_MINOR_VERSION); 586 resp->MinorVersion = cpu_to_le32(RNDIS_MINOR_VERSION);
587 resp->DeviceFlags = cpu_to_le32 (RNDIS_DF_CONNECTIONLESS); 587 resp->DeviceFlags = cpu_to_le32(RNDIS_DF_CONNECTIONLESS);
588 resp->Medium = cpu_to_le32 (RNDIS_MEDIUM_802_3); 588 resp->Medium = cpu_to_le32(RNDIS_MEDIUM_802_3);
589 resp->MaxPacketsPerTransfer = cpu_to_le32 (1); 589 resp->MaxPacketsPerTransfer = cpu_to_le32(1);
590 resp->MaxTransferSize = cpu_to_le32 ( 590 resp->MaxTransferSize = cpu_to_le32(
591 params->dev->mtu 591 params->dev->mtu
592 + sizeof (struct ethhdr) 592 + sizeof(struct ethhdr)
593 + sizeof (struct rndis_packet_msg_type) 593 + sizeof(struct rndis_packet_msg_type)
594 + 22); 594 + 22);
595 resp->PacketAlignmentFactor = cpu_to_le32 (0); 595 resp->PacketAlignmentFactor = cpu_to_le32(0);
596 resp->AFListOffset = cpu_to_le32 (0); 596 resp->AFListOffset = cpu_to_le32(0);
597 resp->AFListSize = cpu_to_le32 (0); 597 resp->AFListSize = cpu_to_le32(0);
598 598
599 params->resp_avail(params->v); 599 params->resp_avail(params->v);
600 return 0; 600 return 0;
601} 601}
602 602
603static int rndis_query_response (int configNr, rndis_query_msg_type *buf) 603static int rndis_query_response(int configNr, rndis_query_msg_type *buf)
604{ 604{
605 rndis_query_cmplt_type *resp; 605 rndis_query_cmplt_type *resp;
606 rndis_resp_t *r; 606 rndis_resp_t *r;
607 struct rndis_params *params = rndis_per_dev_params + configNr; 607 struct rndis_params *params = rndis_per_dev_params + configNr;
608 608
609 /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */ 609 /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */
610 if (!params->dev) 610 if (!params->dev)
@@ -616,47 +616,46 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
616 * rndis_query_cmplt_type followed by data. 616 * rndis_query_cmplt_type followed by data.
617 * oid_supported_list is the largest data reply 617 * oid_supported_list is the largest data reply
618 */ 618 */
619 r = rndis_add_response (configNr, 619 r = rndis_add_response(configNr,
620 sizeof (oid_supported_list) + sizeof(rndis_query_cmplt_type)); 620 sizeof(oid_supported_list) + sizeof(rndis_query_cmplt_type));
621 if (!r) 621 if (!r)
622 return -ENOMEM; 622 return -ENOMEM;
623 resp = (rndis_query_cmplt_type *) r->buf; 623 resp = (rndis_query_cmplt_type *)r->buf;
624 624
625 resp->MessageType = cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT); 625 resp->MessageType = cpu_to_le32(REMOTE_NDIS_QUERY_CMPLT);
626 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 626 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
627 627
628 if (gen_ndis_query_resp (configNr, le32_to_cpu (buf->OID), 628 if (gen_ndis_query_resp(configNr, le32_to_cpu(buf->OID),
629 le32_to_cpu(buf->InformationBufferOffset) 629 le32_to_cpu(buf->InformationBufferOffset)
630 + 8 + (u8 *) buf, 630 + 8 + (u8 *)buf,
631 le32_to_cpu(buf->InformationBufferLength), 631 le32_to_cpu(buf->InformationBufferLength),
632 r)) { 632 r)) {
633 /* OID not supported */ 633 /* OID not supported */
634 resp->Status = cpu_to_le32 ( 634 resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
635 RNDIS_STATUS_NOT_SUPPORTED); 635 resp->MessageLength = cpu_to_le32(sizeof *resp);
636 resp->MessageLength = cpu_to_le32 (sizeof *resp); 636 resp->InformationBufferLength = cpu_to_le32(0);
637 resp->InformationBufferLength = cpu_to_le32 (0); 637 resp->InformationBufferOffset = cpu_to_le32(0);
638 resp->InformationBufferOffset = cpu_to_le32 (0);
639 } else 638 } else
640 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); 639 resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
641 640
642 params->resp_avail(params->v); 641 params->resp_avail(params->v);
643 return 0; 642 return 0;
644} 643}
645 644
646static int rndis_set_response (int configNr, rndis_set_msg_type *buf) 645static int rndis_set_response(int configNr, rndis_set_msg_type *buf)
647{ 646{
648 u32 BufLength, BufOffset; 647 u32 BufLength, BufOffset;
649 rndis_set_cmplt_type *resp; 648 rndis_set_cmplt_type *resp;
650 rndis_resp_t *r; 649 rndis_resp_t *r;
651 struct rndis_params *params = rndis_per_dev_params + configNr; 650 struct rndis_params *params = rndis_per_dev_params + configNr;
652 651
653 r = rndis_add_response (configNr, sizeof (rndis_set_cmplt_type)); 652 r = rndis_add_response(configNr, sizeof(rndis_set_cmplt_type));
654 if (!r) 653 if (!r)
655 return -ENOMEM; 654 return -ENOMEM;
656 resp = (rndis_set_cmplt_type *) r->buf; 655 resp = (rndis_set_cmplt_type *)r->buf;
657 656
658 BufLength = le32_to_cpu (buf->InformationBufferLength); 657 BufLength = le32_to_cpu(buf->InformationBufferLength);
659 BufOffset = le32_to_cpu (buf->InformationBufferOffset); 658 BufOffset = le32_to_cpu(buf->InformationBufferOffset);
660 659
661#ifdef VERBOSE_DEBUG 660#ifdef VERBOSE_DEBUG
662 pr_debug("%s: Length: %d\n", __func__, BufLength); 661 pr_debug("%s: Length: %d\n", __func__, BufLength);
@@ -670,59 +669,59 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf)
670 pr_debug("\n"); 669 pr_debug("\n");
671#endif 670#endif
672 671
673 resp->MessageType = cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); 672 resp->MessageType = cpu_to_le32(REMOTE_NDIS_SET_CMPLT);
674 resp->MessageLength = cpu_to_le32 (16); 673 resp->MessageLength = cpu_to_le32(16);
675 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 674 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
676 if (gen_ndis_set_resp (configNr, le32_to_cpu (buf->OID), 675 if (gen_ndis_set_resp(configNr, le32_to_cpu(buf->OID),
677 ((u8 *) buf) + 8 + BufOffset, BufLength, r)) 676 ((u8 *)buf) + 8 + BufOffset, BufLength, r))
678 resp->Status = cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED); 677 resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
679 else 678 else
680 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); 679 resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
681 680
682 params->resp_avail(params->v); 681 params->resp_avail(params->v);
683 return 0; 682 return 0;
684} 683}
685 684
686static int rndis_reset_response (int configNr, rndis_reset_msg_type *buf) 685static int rndis_reset_response(int configNr, rndis_reset_msg_type *buf)
687{ 686{
688 rndis_reset_cmplt_type *resp; 687 rndis_reset_cmplt_type *resp;
689 rndis_resp_t *r; 688 rndis_resp_t *r;
690 struct rndis_params *params = rndis_per_dev_params + configNr; 689 struct rndis_params *params = rndis_per_dev_params + configNr;
691 690
692 r = rndis_add_response (configNr, sizeof (rndis_reset_cmplt_type)); 691 r = rndis_add_response(configNr, sizeof(rndis_reset_cmplt_type));
693 if (!r) 692 if (!r)
694 return -ENOMEM; 693 return -ENOMEM;
695 resp = (rndis_reset_cmplt_type *) r->buf; 694 resp = (rndis_reset_cmplt_type *)r->buf;
696 695
697 resp->MessageType = cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT); 696 resp->MessageType = cpu_to_le32(REMOTE_NDIS_RESET_CMPLT);
698 resp->MessageLength = cpu_to_le32 (16); 697 resp->MessageLength = cpu_to_le32(16);
699 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); 698 resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
700 /* resent information */ 699 /* resent information */
701 resp->AddressingReset = cpu_to_le32 (1); 700 resp->AddressingReset = cpu_to_le32(1);
702 701
703 params->resp_avail(params->v); 702 params->resp_avail(params->v);
704 return 0; 703 return 0;
705} 704}
706 705
707static int rndis_keepalive_response (int configNr, 706static int rndis_keepalive_response(int configNr,
708 rndis_keepalive_msg_type *buf) 707 rndis_keepalive_msg_type *buf)
709{ 708{
710 rndis_keepalive_cmplt_type *resp; 709 rndis_keepalive_cmplt_type *resp;
711 rndis_resp_t *r; 710 rndis_resp_t *r;
712 struct rndis_params *params = rndis_per_dev_params + configNr; 711 struct rndis_params *params = rndis_per_dev_params + configNr;
713 712
714 /* host "should" check only in RNDIS_DATA_INITIALIZED state */ 713 /* host "should" check only in RNDIS_DATA_INITIALIZED state */
715 714
716 r = rndis_add_response (configNr, sizeof (rndis_keepalive_cmplt_type)); 715 r = rndis_add_response(configNr, sizeof(rndis_keepalive_cmplt_type));
717 if (!r) 716 if (!r)
718 return -ENOMEM; 717 return -ENOMEM;
719 resp = (rndis_keepalive_cmplt_type *) r->buf; 718 resp = (rndis_keepalive_cmplt_type *)r->buf;
720 719
721 resp->MessageType = cpu_to_le32 ( 720 resp->MessageType = cpu_to_le32(
722 REMOTE_NDIS_KEEPALIVE_CMPLT); 721 REMOTE_NDIS_KEEPALIVE_CMPLT);
723 resp->MessageLength = cpu_to_le32 (16); 722 resp->MessageLength = cpu_to_le32(16);
724 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 723 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
725 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); 724 resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
726 725
727 params->resp_avail(params->v); 726 params->resp_avail(params->v);
728 return 0; 727 return 0;
@@ -732,86 +731,85 @@ static int rndis_keepalive_response (int configNr,
732/* 731/*
733 * Device to Host Comunication 732 * Device to Host Comunication
734 */ 733 */
735static int rndis_indicate_status_msg (int configNr, u32 status) 734static int rndis_indicate_status_msg(int configNr, u32 status)
736{ 735{
737 rndis_indicate_status_msg_type *resp; 736 rndis_indicate_status_msg_type *resp;
738 rndis_resp_t *r; 737 rndis_resp_t *r;
739 struct rndis_params *params = rndis_per_dev_params + configNr; 738 struct rndis_params *params = rndis_per_dev_params + configNr;
740 739
741 if (params->state == RNDIS_UNINITIALIZED) 740 if (params->state == RNDIS_UNINITIALIZED)
742 return -ENOTSUPP; 741 return -ENOTSUPP;
743 742
744 r = rndis_add_response (configNr, 743 r = rndis_add_response(configNr,
745 sizeof (rndis_indicate_status_msg_type)); 744 sizeof(rndis_indicate_status_msg_type));
746 if (!r) 745 if (!r)
747 return -ENOMEM; 746 return -ENOMEM;
748 resp = (rndis_indicate_status_msg_type *) r->buf; 747 resp = (rndis_indicate_status_msg_type *)r->buf;
749 748
750 resp->MessageType = cpu_to_le32 ( 749 resp->MessageType = cpu_to_le32(REMOTE_NDIS_INDICATE_STATUS_MSG);
751 REMOTE_NDIS_INDICATE_STATUS_MSG); 750 resp->MessageLength = cpu_to_le32(20);
752 resp->MessageLength = cpu_to_le32 (20); 751 resp->Status = cpu_to_le32(status);
753 resp->Status = cpu_to_le32 (status); 752 resp->StatusBufferLength = cpu_to_le32(0);
754 resp->StatusBufferLength = cpu_to_le32 (0); 753 resp->StatusBufferOffset = cpu_to_le32(0);
755 resp->StatusBufferOffset = cpu_to_le32 (0);
756 754
757 params->resp_avail(params->v); 755 params->resp_avail(params->v);
758 return 0; 756 return 0;
759} 757}
760 758
761int rndis_signal_connect (int configNr) 759int rndis_signal_connect(int configNr)
762{ 760{
763 rndis_per_dev_params [configNr].media_state 761 rndis_per_dev_params[configNr].media_state
764 = NDIS_MEDIA_STATE_CONNECTED; 762 = NDIS_MEDIA_STATE_CONNECTED;
765 return rndis_indicate_status_msg (configNr, 763 return rndis_indicate_status_msg(configNr,
766 RNDIS_STATUS_MEDIA_CONNECT); 764 RNDIS_STATUS_MEDIA_CONNECT);
767} 765}
768 766
769int rndis_signal_disconnect (int configNr) 767int rndis_signal_disconnect(int configNr)
770{ 768{
771 rndis_per_dev_params [configNr].media_state 769 rndis_per_dev_params[configNr].media_state
772 = NDIS_MEDIA_STATE_DISCONNECTED; 770 = NDIS_MEDIA_STATE_DISCONNECTED;
773 return rndis_indicate_status_msg (configNr, 771 return rndis_indicate_status_msg(configNr,
774 RNDIS_STATUS_MEDIA_DISCONNECT); 772 RNDIS_STATUS_MEDIA_DISCONNECT);
775} 773}
776 774
777void rndis_uninit (int configNr) 775void rndis_uninit(int configNr)
778{ 776{
779 u8 *buf; 777 u8 *buf;
780 u32 length; 778 u32 length;
781 779
782 if (configNr >= RNDIS_MAX_CONFIGS) 780 if (configNr >= RNDIS_MAX_CONFIGS)
783 return; 781 return;
784 rndis_per_dev_params [configNr].state = RNDIS_UNINITIALIZED; 782 rndis_per_dev_params[configNr].state = RNDIS_UNINITIALIZED;
785 783
786 /* drain the response queue */ 784 /* drain the response queue */
787 while ((buf = rndis_get_next_response(configNr, &length))) 785 while ((buf = rndis_get_next_response(configNr, &length)))
788 rndis_free_response(configNr, buf); 786 rndis_free_response(configNr, buf);
789} 787}
790 788
791void rndis_set_host_mac (int configNr, const u8 *addr) 789void rndis_set_host_mac(int configNr, const u8 *addr)
792{ 790{
793 rndis_per_dev_params [configNr].host_mac = addr; 791 rndis_per_dev_params[configNr].host_mac = addr;
794} 792}
795 793
796/* 794/*
797 * Message Parser 795 * Message Parser
798 */ 796 */
799int rndis_msg_parser (u8 configNr, u8 *buf) 797int rndis_msg_parser(u8 configNr, u8 *buf)
800{ 798{
801 u32 MsgType, MsgLength; 799 u32 MsgType, MsgLength;
802 __le32 *tmp; 800 __le32 *tmp;
803 struct rndis_params *params; 801 struct rndis_params *params;
804 802
805 if (!buf) 803 if (!buf)
806 return -ENOMEM; 804 return -ENOMEM;
807 805
808 tmp = (__le32 *) buf; 806 tmp = (__le32 *)buf;
809 MsgType = get_unaligned_le32(tmp++); 807 MsgType = get_unaligned_le32(tmp++);
810 MsgLength = get_unaligned_le32(tmp++); 808 MsgLength = get_unaligned_le32(tmp++);
811 809
812 if (configNr >= RNDIS_MAX_CONFIGS) 810 if (configNr >= RNDIS_MAX_CONFIGS)
813 return -ENOTSUPP; 811 return -ENOTSUPP;
814 params = &rndis_per_dev_params [configNr]; 812 params = &rndis_per_dev_params[configNr];
815 813
816 /* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for 814 /* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for
817 * rx/tx statistics and link status, in addition to KEEPALIVE traffic 815 * rx/tx statistics and link status, in addition to KEEPALIVE traffic
@@ -822,41 +820,41 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
822 switch (MsgType) { 820 switch (MsgType) {
823 case REMOTE_NDIS_INITIALIZE_MSG: 821 case REMOTE_NDIS_INITIALIZE_MSG:
824 pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n", 822 pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n",
825 __func__ ); 823 __func__);
826 params->state = RNDIS_INITIALIZED; 824 params->state = RNDIS_INITIALIZED;
827 return rndis_init_response (configNr, 825 return rndis_init_response(configNr,
828 (rndis_init_msg_type *) buf); 826 (rndis_init_msg_type *)buf);
829 827
830 case REMOTE_NDIS_HALT_MSG: 828 case REMOTE_NDIS_HALT_MSG:
831 pr_debug("%s: REMOTE_NDIS_HALT_MSG\n", 829 pr_debug("%s: REMOTE_NDIS_HALT_MSG\n",
832 __func__ ); 830 __func__);
833 params->state = RNDIS_UNINITIALIZED; 831 params->state = RNDIS_UNINITIALIZED;
834 if (params->dev) { 832 if (params->dev) {
835 netif_carrier_off (params->dev); 833 netif_carrier_off(params->dev);
836 netif_stop_queue (params->dev); 834 netif_stop_queue(params->dev);
837 } 835 }
838 return 0; 836 return 0;
839 837
840 case REMOTE_NDIS_QUERY_MSG: 838 case REMOTE_NDIS_QUERY_MSG:
841 return rndis_query_response (configNr, 839 return rndis_query_response(configNr,
842 (rndis_query_msg_type *) buf); 840 (rndis_query_msg_type *)buf);
843 841
844 case REMOTE_NDIS_SET_MSG: 842 case REMOTE_NDIS_SET_MSG:
845 return rndis_set_response (configNr, 843 return rndis_set_response(configNr,
846 (rndis_set_msg_type *) buf); 844 (rndis_set_msg_type *)buf);
847 845
848 case REMOTE_NDIS_RESET_MSG: 846 case REMOTE_NDIS_RESET_MSG:
849 pr_debug("%s: REMOTE_NDIS_RESET_MSG\n", 847 pr_debug("%s: REMOTE_NDIS_RESET_MSG\n",
850 __func__ ); 848 __func__);
851 return rndis_reset_response (configNr, 849 return rndis_reset_response(configNr,
852 (rndis_reset_msg_type *) buf); 850 (rndis_reset_msg_type *)buf);
853 851
854 case REMOTE_NDIS_KEEPALIVE_MSG: 852 case REMOTE_NDIS_KEEPALIVE_MSG:
855 /* For USB: host does this every 5 seconds */ 853 /* For USB: host does this every 5 seconds */
856 if (rndis_debug > 1) 854 if (rndis_debug > 1)
857 pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", 855 pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n",
858 __func__ ); 856 __func__);
859 return rndis_keepalive_response (configNr, 857 return rndis_keepalive_response(configNr,
860 (rndis_keepalive_msg_type *) 858 (rndis_keepalive_msg_type *)
861 buf); 859 buf);
862 860
@@ -866,7 +864,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
866 * suspending itself. 864 * suspending itself.
867 */ 865 */
868 pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", 866 pr_warning("%s: unknown RNDIS message 0x%08X len %d\n",
869 __func__ , MsgType, MsgLength); 867 __func__, MsgType, MsgLength);
870 { 868 {
871 unsigned i; 869 unsigned i;
872 for (i = 0; i < MsgLength; i += 16) { 870 for (i = 0; i < MsgLength; i += 16) {
@@ -901,10 +899,10 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
901 return -EINVAL; 899 return -EINVAL;
902 900
903 for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { 901 for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
904 if (!rndis_per_dev_params [i].used) { 902 if (!rndis_per_dev_params[i].used) {
905 rndis_per_dev_params [i].used = 1; 903 rndis_per_dev_params[i].used = 1;
906 rndis_per_dev_params [i].resp_avail = resp_avail; 904 rndis_per_dev_params[i].resp_avail = resp_avail;
907 rndis_per_dev_params [i].v = v; 905 rndis_per_dev_params[i].v = v;
908 pr_debug("%s: configNr = %d\n", __func__, i); 906 pr_debug("%s: configNr = %d\n", __func__, i);
909 return i; 907 return i;
910 } 908 }
@@ -914,12 +912,12 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
914 return -ENODEV; 912 return -ENODEV;
915} 913}
916 914
917void rndis_deregister (int configNr) 915void rndis_deregister(int configNr)
918{ 916{
919 pr_debug("%s: \n", __func__); 917 pr_debug("%s:\n", __func__);
920 918
921 if (configNr >= RNDIS_MAX_CONFIGS) return; 919 if (configNr >= RNDIS_MAX_CONFIGS) return;
922 rndis_per_dev_params [configNr].used = 0; 920 rndis_per_dev_params[configNr].used = 0;
923 921
924 return; 922 return;
925} 923}
@@ -931,76 +929,76 @@ int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter)
931 return -EINVAL; 929 return -EINVAL;
932 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 930 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
933 931
934 rndis_per_dev_params [configNr].dev = dev; 932 rndis_per_dev_params[configNr].dev = dev;
935 rndis_per_dev_params [configNr].filter = cdc_filter; 933 rndis_per_dev_params[configNr].filter = cdc_filter;
936 934
937 return 0; 935 return 0;
938} 936}
939 937
940int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) 938int rndis_set_param_vendor(u8 configNr, u32 vendorID, const char *vendorDescr)
941{ 939{
942 pr_debug("%s:\n", __func__); 940 pr_debug("%s:\n", __func__);
943 if (!vendorDescr) return -1; 941 if (!vendorDescr) return -1;
944 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 942 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
945 943
946 rndis_per_dev_params [configNr].vendorID = vendorID; 944 rndis_per_dev_params[configNr].vendorID = vendorID;
947 rndis_per_dev_params [configNr].vendorDescr = vendorDescr; 945 rndis_per_dev_params[configNr].vendorDescr = vendorDescr;
948 946
949 return 0; 947 return 0;
950} 948}
951 949
952int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) 950int rndis_set_param_medium(u8 configNr, u32 medium, u32 speed)
953{ 951{
954 pr_debug("%s: %u %u\n", __func__, medium, speed); 952 pr_debug("%s: %u %u\n", __func__, medium, speed);
955 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 953 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
956 954
957 rndis_per_dev_params [configNr].medium = medium; 955 rndis_per_dev_params[configNr].medium = medium;
958 rndis_per_dev_params [configNr].speed = speed; 956 rndis_per_dev_params[configNr].speed = speed;
959 957
960 return 0; 958 return 0;
961} 959}
962 960
963void rndis_add_hdr (struct sk_buff *skb) 961void rndis_add_hdr(struct sk_buff *skb)
964{ 962{
965 struct rndis_packet_msg_type *header; 963 struct rndis_packet_msg_type *header;
966 964
967 if (!skb) 965 if (!skb)
968 return; 966 return;
969 header = (void *) skb_push (skb, sizeof *header); 967 header = (void *)skb_push(skb, sizeof(*header));
970 memset (header, 0, sizeof *header); 968 memset(header, 0, sizeof *header);
971 header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG); 969 header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG);
972 header->MessageLength = cpu_to_le32(skb->len); 970 header->MessageLength = cpu_to_le32(skb->len);
973 header->DataOffset = cpu_to_le32 (36); 971 header->DataOffset = cpu_to_le32(36);
974 header->DataLength = cpu_to_le32(skb->len - sizeof *header); 972 header->DataLength = cpu_to_le32(skb->len - sizeof(*header));
975} 973}
976 974
977void rndis_free_response (int configNr, u8 *buf) 975void rndis_free_response(int configNr, u8 *buf)
978{ 976{
979 rndis_resp_t *r; 977 rndis_resp_t *r;
980 struct list_head *act, *tmp; 978 struct list_head *act, *tmp;
981 979
982 list_for_each_safe (act, tmp, 980 list_for_each_safe(act, tmp,
983 &(rndis_per_dev_params [configNr].resp_queue)) 981 &(rndis_per_dev_params[configNr].resp_queue))
984 { 982 {
985 r = list_entry (act, rndis_resp_t, list); 983 r = list_entry(act, rndis_resp_t, list);
986 if (r && r->buf == buf) { 984 if (r && r->buf == buf) {
987 list_del (&r->list); 985 list_del(&r->list);
988 kfree (r); 986 kfree(r);
989 } 987 }
990 } 988 }
991} 989}
992 990
993u8 *rndis_get_next_response (int configNr, u32 *length) 991u8 *rndis_get_next_response(int configNr, u32 *length)
994{ 992{
995 rndis_resp_t *r; 993 rndis_resp_t *r;
996 struct list_head *act, *tmp; 994 struct list_head *act, *tmp;
997 995
998 if (!length) return NULL; 996 if (!length) return NULL;
999 997
1000 list_for_each_safe (act, tmp, 998 list_for_each_safe(act, tmp,
1001 &(rndis_per_dev_params [configNr].resp_queue)) 999 &(rndis_per_dev_params[configNr].resp_queue))
1002 { 1000 {
1003 r = list_entry (act, rndis_resp_t, list); 1001 r = list_entry(act, rndis_resp_t, list);
1004 if (!r->send) { 1002 if (!r->send) {
1005 r->send = 1; 1003 r->send = 1;
1006 *length = r->length; 1004 *length = r->length;
@@ -1011,20 +1009,20 @@ u8 *rndis_get_next_response (int configNr, u32 *length)
1011 return NULL; 1009 return NULL;
1012} 1010}
1013 1011
1014static rndis_resp_t *rndis_add_response (int configNr, u32 length) 1012static rndis_resp_t *rndis_add_response(int configNr, u32 length)
1015{ 1013{
1016 rndis_resp_t *r; 1014 rndis_resp_t *r;
1017 1015
1018 /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */ 1016 /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */
1019 r = kmalloc (sizeof (rndis_resp_t) + length, GFP_ATOMIC); 1017 r = kmalloc(sizeof(rndis_resp_t) + length, GFP_ATOMIC);
1020 if (!r) return NULL; 1018 if (!r) return NULL;
1021 1019
1022 r->buf = (u8 *) (r + 1); 1020 r->buf = (u8 *)(r + 1);
1023 r->length = length; 1021 r->length = length;
1024 r->send = 0; 1022 r->send = 0;
1025 1023
1026 list_add_tail (&r->list, 1024 list_add_tail(&r->list,
1027 &(rndis_per_dev_params [configNr].resp_queue)); 1025 &(rndis_per_dev_params[configNr].resp_queue));
1028 return r; 1026 return r;
1029} 1027}
1030 1028
@@ -1033,7 +1031,7 @@ int rndis_rm_hdr(struct gether *port,
1033 struct sk_buff_head *list) 1031 struct sk_buff_head *list)
1034{ 1032{
1035 /* tmp points to a struct rndis_packet_msg_type */ 1033 /* tmp points to a struct rndis_packet_msg_type */
1036 __le32 *tmp = (void *) skb->data; 1034 __le32 *tmp = (void *)skb->data;
1037 1035
1038 /* MessageType, MessageLength */ 1036 /* MessageType, MessageLength */
1039 if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG) 1037 if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG)
@@ -1054,7 +1052,7 @@ int rndis_rm_hdr(struct gether *port,
1054 return 0; 1052 return 0;
1055} 1053}
1056 1054
1057#ifdef CONFIG_USB_GADGET_DEBUG_FILES 1055#ifdef CONFIG_USB_GADGET_DEBUG_FILES
1058 1056
1059static int rndis_proc_show(struct seq_file *m, void *v) 1057static int rndis_proc_show(struct seq_file *m, void *v)
1060{ 1058{
@@ -1087,7 +1085,7 @@ static int rndis_proc_show(struct seq_file *m, void *v)
1087} 1085}
1088 1086
1089static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, 1087static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
1090 size_t count, loff_t *ppos) 1088 size_t count, loff_t *ppos)
1091{ 1089{
1092 rndis_params *p = PDE(file->f_path.dentry->d_inode)->data; 1090 rndis_params *p = PDE(file->f_path.dentry->d_inode)->data;
1093 u32 speed = 0; 1091 u32 speed = 0;
@@ -1109,11 +1107,11 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
1109 case '8': 1107 case '8':
1110 case '9': 1108 case '9':
1111 fl_speed = 1; 1109 fl_speed = 1;
1112 speed = speed*10 + c - '0'; 1110 speed = speed * 10 + c - '0';
1113 break; 1111 break;
1114 case 'C': 1112 case 'C':
1115 case 'c': 1113 case 'c':
1116 rndis_signal_connect (p->confignr); 1114 rndis_signal_connect(p->confignr);
1117 break; 1115 break;
1118 case 'D': 1116 case 'D':
1119 case 'd': 1117 case 'd':
@@ -1145,11 +1143,11 @@ static const struct file_operations rndis_proc_fops = {
1145 .write = rndis_proc_write, 1143 .write = rndis_proc_write,
1146}; 1144};
1147 1145
1148#define NAME_TEMPLATE "driver/rndis-%03d" 1146#define NAME_TEMPLATE "driver/rndis-%03d"
1149 1147
1150static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; 1148static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
1151 1149
1152#endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1150#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
1153 1151
1154 1152
1155int rndis_init(void) 1153int rndis_init(void)
@@ -1160,42 +1158,40 @@ int rndis_init(void)
1160#ifdef CONFIG_USB_GADGET_DEBUG_FILES 1158#ifdef CONFIG_USB_GADGET_DEBUG_FILES
1161 char name [20]; 1159 char name [20];
1162 1160
1163 sprintf (name, NAME_TEMPLATE, i); 1161 sprintf(name, NAME_TEMPLATE, i);
1164 if (!(rndis_connect_state [i] 1162 rndis_connect_state[i] = proc_create_data(name, 0660, NULL,
1165 = proc_create_data(name, 0660, NULL,
1166 &rndis_proc_fops, 1163 &rndis_proc_fops,
1167 (void *)(rndis_per_dev_params + i)))) 1164 (void *)(rndis_per_dev_params + i));
1168 { 1165 if (!rndis_connect_state[i]) {
1169 pr_debug("%s :remove entries", __func__); 1166 pr_debug("%s: remove entries", __func__);
1170 while (i) { 1167 while (i) {
1171 sprintf (name, NAME_TEMPLATE, --i); 1168 sprintf(name, NAME_TEMPLATE, --i);
1172 remove_proc_entry (name, NULL); 1169 remove_proc_entry(name, NULL);
1173 } 1170 }
1174 pr_debug("\n"); 1171 pr_debug("\n");
1175 return -EIO; 1172 return -EIO;
1176 } 1173 }
1177#endif 1174#endif
1178 rndis_per_dev_params [i].confignr = i; 1175 rndis_per_dev_params[i].confignr = i;
1179 rndis_per_dev_params [i].used = 0; 1176 rndis_per_dev_params[i].used = 0;
1180 rndis_per_dev_params [i].state = RNDIS_UNINITIALIZED; 1177 rndis_per_dev_params[i].state = RNDIS_UNINITIALIZED;
1181 rndis_per_dev_params [i].media_state 1178 rndis_per_dev_params[i].media_state
1182 = NDIS_MEDIA_STATE_DISCONNECTED; 1179 = NDIS_MEDIA_STATE_DISCONNECTED;
1183 INIT_LIST_HEAD (&(rndis_per_dev_params [i].resp_queue)); 1180 INIT_LIST_HEAD(&(rndis_per_dev_params[i].resp_queue));
1184 } 1181 }
1185 1182
1186 return 0; 1183 return 0;
1187} 1184}
1188 1185
1189void rndis_exit (void) 1186void rndis_exit(void)
1190{ 1187{
1191#ifdef CONFIG_USB_GADGET_DEBUG_FILES 1188#ifdef CONFIG_USB_GADGET_DEBUG_FILES
1192 u8 i; 1189 u8 i;
1193 char name [20]; 1190 char name[20];
1194 1191
1195 for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { 1192 for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
1196 sprintf (name, NAME_TEMPLATE, i); 1193 sprintf(name, NAME_TEMPLATE, i);
1197 remove_proc_entry (name, NULL); 1194 remove_proc_entry(name, NULL);
1198 } 1195 }
1199#endif 1196#endif
1200} 1197}
1201
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index a229744a8c7d..ef825c3baed9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -2523,7 +2523,8 @@ static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg)
2523 return 0; 2523 return 0;
2524} 2524}
2525 2525
2526int usb_gadget_register_driver(struct usb_gadget_driver *driver) 2526int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2527 int (*bind)(struct usb_gadget *))
2527{ 2528{
2528 struct s3c_hsotg *hsotg = our_hsotg; 2529 struct s3c_hsotg *hsotg = our_hsotg;
2529 int ret; 2530 int ret;
@@ -2543,7 +2544,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2543 dev_err(hsotg->dev, "%s: bad speed\n", __func__); 2544 dev_err(hsotg->dev, "%s: bad speed\n", __func__);
2544 } 2545 }
2545 2546
2546 if (!driver->bind || !driver->setup) { 2547 if (!bind || !driver->setup) {
2547 dev_err(hsotg->dev, "%s: missing entry points\n", __func__); 2548 dev_err(hsotg->dev, "%s: missing entry points\n", __func__);
2548 return -EINVAL; 2549 return -EINVAL;
2549 } 2550 }
@@ -2562,7 +2563,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2562 goto err; 2563 goto err;
2563 } 2564 }
2564 2565
2565 ret = driver->bind(&hsotg->gadget); 2566 ret = bind(&hsotg->gadget);
2566 if (ret) { 2567 if (ret) {
2567 dev_err(hsotg->dev, "failed bind %s\n", driver->driver.name); 2568 dev_err(hsotg->dev, "failed bind %s\n", driver->driver.name);
2568 2569
@@ -2687,7 +2688,7 @@ err:
2687 hsotg->gadget.dev.driver = NULL; 2688 hsotg->gadget.dev.driver = NULL;
2688 return ret; 2689 return ret;
2689} 2690}
2690EXPORT_SYMBOL(usb_gadget_register_driver); 2691EXPORT_SYMBOL(usb_gadget_probe_driver);
2691 2692
2692int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 2693int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2693{ 2694{
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index ea2b3c7ebee5..c2448950a8d8 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -1632,15 +1632,15 @@ static void s3c2410_udc_enable(struct s3c2410_udc *dev)
1632} 1632}
1633 1633
1634/* 1634/*
1635 * usb_gadget_register_driver 1635 * usb_gadget_probe_driver
1636 */ 1636 */
1637int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1637int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1638 int (*bind)(struct usb_gadget *))
1638{ 1639{
1639 struct s3c2410_udc *udc = the_controller; 1640 struct s3c2410_udc *udc = the_controller;
1640 int retval; 1641 int retval;
1641 1642
1642 dprintk(DEBUG_NORMAL, "usb_gadget_register_driver() '%s'\n", 1643 dprintk(DEBUG_NORMAL, "%s() '%s'\n", __func__, driver->driver.name);
1643 driver->driver.name);
1644 1644
1645 /* Sanity checks */ 1645 /* Sanity checks */
1646 if (!udc) 1646 if (!udc)
@@ -1649,10 +1649,9 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1649 if (udc->driver) 1649 if (udc->driver)
1650 return -EBUSY; 1650 return -EBUSY;
1651 1651
1652 if (!driver->bind || !driver->setup 1652 if (!bind || !driver->setup || driver->speed < USB_SPEED_FULL) {
1653 || driver->speed < USB_SPEED_FULL) {
1654 printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", 1653 printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n",
1655 driver->bind, driver->setup, driver->speed); 1654 bind, driver->setup, driver->speed);
1656 return -EINVAL; 1655 return -EINVAL;
1657 } 1656 }
1658#if defined(MODULE) 1657#if defined(MODULE)
@@ -1675,7 +1674,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1675 dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n", 1674 dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n",
1676 driver->driver.name); 1675 driver->driver.name);
1677 1676
1678 if ((retval = driver->bind (&udc->gadget)) != 0) { 1677 if ((retval = bind(&udc->gadget)) != 0) {
1679 device_del(&udc->gadget.dev); 1678 device_del(&udc->gadget.dev);
1680 goto register_error; 1679 goto register_error;
1681 } 1680 }
@@ -1690,6 +1689,7 @@ register_error:
1690 udc->gadget.dev.driver = NULL; 1689 udc->gadget.dev.driver = NULL;
1691 return retval; 1690 return retval;
1692} 1691}
1692EXPORT_SYMBOL(usb_gadget_probe_driver);
1693 1693
1694/* 1694/*
1695 * usb_gadget_unregister_driver 1695 * usb_gadget_unregister_driver
@@ -2049,7 +2049,6 @@ static void __exit udc_exit(void)
2049} 2049}
2050 2050
2051EXPORT_SYMBOL(usb_gadget_unregister_driver); 2051EXPORT_SYMBOL(usb_gadget_unregister_driver);
2052EXPORT_SYMBOL(usb_gadget_register_driver);
2053 2052
2054module_init(udc_init); 2053module_init(udc_init);
2055module_exit(udc_exit); 2054module_exit(udc_exit);
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index b22eedbc7dc5..1ac57a973aa9 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -137,7 +137,7 @@ MODULE_PARM_DESC(n_ports, "number of ports to create, default=1");
137 137
138/*-------------------------------------------------------------------------*/ 138/*-------------------------------------------------------------------------*/
139 139
140static int __ref serial_bind_config(struct usb_configuration *c) 140static int __init serial_bind_config(struct usb_configuration *c)
141{ 141{
142 unsigned i; 142 unsigned i;
143 int status = 0; 143 int status = 0;
@@ -155,13 +155,12 @@ static int __ref serial_bind_config(struct usb_configuration *c)
155 155
156static struct usb_configuration serial_config_driver = { 156static struct usb_configuration serial_config_driver = {
157 /* .label = f(use_acm) */ 157 /* .label = f(use_acm) */
158 .bind = serial_bind_config,
159 /* .bConfigurationValue = f(use_acm) */ 158 /* .bConfigurationValue = f(use_acm) */
160 /* .iConfiguration = DYNAMIC */ 159 /* .iConfiguration = DYNAMIC */
161 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 160 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
162}; 161};
163 162
164static int __ref gs_bind(struct usb_composite_dev *cdev) 163static int __init gs_bind(struct usb_composite_dev *cdev)
165{ 164{
166 int gcnum; 165 int gcnum;
167 struct usb_gadget *gadget = cdev->gadget; 166 struct usb_gadget *gadget = cdev->gadget;
@@ -225,7 +224,8 @@ static int __ref gs_bind(struct usb_composite_dev *cdev)
225 } 224 }
226 225
227 /* register our configuration */ 226 /* register our configuration */
228 status = usb_add_config(cdev, &serial_config_driver); 227 status = usb_add_config(cdev, &serial_config_driver,
228 serial_bind_config);
229 if (status < 0) 229 if (status < 0)
230 goto fail; 230 goto fail;
231 231
@@ -242,7 +242,6 @@ static struct usb_composite_driver gserial_driver = {
242 .name = "g_serial", 242 .name = "g_serial",
243 .dev = &device_desc, 243 .dev = &device_desc,
244 .strings = dev_strings, 244 .strings = dev_strings,
245 .bind = gs_bind,
246}; 245};
247 246
248static int __init init(void) 247static int __init init(void)
@@ -271,7 +270,7 @@ static int __init init(void)
271 } 270 }
272 strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; 271 strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label;
273 272
274 return usb_composite_register(&gserial_driver); 273 return usb_composite_probe(&gserial_driver, gs_bind);
275} 274}
276module_init(init); 275module_init(init);
277 276
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 484acfb1a7c5..3b513bafaf2a 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -26,7 +26,6 @@
26 * be defined (each of type pointer to char): 26 * be defined (each of type pointer to char):
27 * - fsg_string_manufacturer -- name of the manufacturer 27 * - fsg_string_manufacturer -- name of the manufacturer
28 * - fsg_string_product -- name of the product 28 * - fsg_string_product -- name of the product
29 * - fsg_string_serial -- product's serial
30 * - fsg_string_config -- name of the configuration 29 * - fsg_string_config -- name of the configuration
31 * - fsg_string_interface -- name of the interface 30 * - fsg_string_interface -- name of the interface
32 * The first four are only needed when FSG_DESCRIPTORS_DEVICE_STRINGS 31 * The first four are only needed when FSG_DESCRIPTORS_DEVICE_STRINGS
@@ -54,6 +53,8 @@
54 */ 53 */
55 54
56 55
56#include <linux/usb/storage.h>
57#include <scsi/scsi.h>
57#include <asm/unaligned.h> 58#include <asm/unaligned.h>
58 59
59 60
@@ -153,23 +154,6 @@
153 154
154/*-------------------------------------------------------------------------*/ 155/*-------------------------------------------------------------------------*/
155 156
156/* SCSI device types */
157#define TYPE_DISK 0x00
158#define TYPE_CDROM 0x05
159
160/* USB protocol value = the transport method */
161#define USB_PR_CBI 0x00 /* Control/Bulk/Interrupt */
162#define USB_PR_CB 0x01 /* Control/Bulk w/o interrupt */
163#define USB_PR_BULK 0x50 /* Bulk-only */
164
165/* USB subclass value = the protocol encapsulation */
166#define USB_SC_RBC 0x01 /* Reduced Block Commands (flash) */
167#define USB_SC_8020 0x02 /* SFF-8020i, MMC-2, ATAPI (CD-ROM) */
168#define USB_SC_QIC 0x03 /* QIC-157 (tape) */
169#define USB_SC_UFI 0x04 /* UFI (floppy) */
170#define USB_SC_8070 0x05 /* SFF-8070i (removable) */
171#define USB_SC_SCSI 0x06 /* Transparent SCSI */
172
173/* Bulk-only data structures */ 157/* Bulk-only data structures */
174 158
175/* Command Block Wrapper */ 159/* Command Block Wrapper */
@@ -221,33 +205,6 @@ struct interrupt_data {
221/* Length of a SCSI Command Data Block */ 205/* Length of a SCSI Command Data Block */
222#define MAX_COMMAND_SIZE 16 206#define MAX_COMMAND_SIZE 16
223 207
224/* SCSI commands that we recognize */
225#define SC_FORMAT_UNIT 0x04
226#define SC_INQUIRY 0x12
227#define SC_MODE_SELECT_6 0x15
228#define SC_MODE_SELECT_10 0x55
229#define SC_MODE_SENSE_6 0x1a
230#define SC_MODE_SENSE_10 0x5a
231#define SC_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
232#define SC_READ_6 0x08
233#define SC_READ_10 0x28
234#define SC_READ_12 0xa8
235#define SC_READ_CAPACITY 0x25
236#define SC_READ_FORMAT_CAPACITIES 0x23
237#define SC_READ_HEADER 0x44
238#define SC_READ_TOC 0x43
239#define SC_RELEASE 0x17
240#define SC_REQUEST_SENSE 0x03
241#define SC_RESERVE 0x16
242#define SC_SEND_DIAGNOSTIC 0x1d
243#define SC_START_STOP_UNIT 0x1b
244#define SC_SYNCHRONIZE_CACHE 0x35
245#define SC_TEST_UNIT_READY 0x00
246#define SC_VERIFY 0x2f
247#define SC_WRITE_6 0x0a
248#define SC_WRITE_10 0x2a
249#define SC_WRITE_12 0xaa
250
251/* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */ 208/* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */
252#define SS_NO_SENSE 0 209#define SS_NO_SENSE 0
253#define SS_COMMUNICATION_FAILURE 0x040800 210#define SS_COMMUNICATION_FAILURE 0x040800
@@ -552,7 +509,7 @@ static struct usb_string fsg_strings[] = {
552#ifndef FSG_NO_DEVICE_STRINGS 509#ifndef FSG_NO_DEVICE_STRINGS
553 {FSG_STRING_MANUFACTURER, fsg_string_manufacturer}, 510 {FSG_STRING_MANUFACTURER, fsg_string_manufacturer},
554 {FSG_STRING_PRODUCT, fsg_string_product}, 511 {FSG_STRING_PRODUCT, fsg_string_product},
555 {FSG_STRING_SERIAL, fsg_string_serial}, 512 {FSG_STRING_SERIAL, ""},
556 {FSG_STRING_CONFIG, fsg_string_config}, 513 {FSG_STRING_CONFIG, fsg_string_config},
557#endif 514#endif
558 {FSG_STRING_INTERFACE, fsg_string_interface}, 515 {FSG_STRING_INTERFACE, fsg_string_interface},
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c
index de1deb7a3c63..a5a0fdb808c7 100644
--- a/drivers/usb/gadget/webcam.c
+++ b/drivers/usb/gadget/webcam.c
@@ -308,7 +308,7 @@ static const struct uvc_descriptor_header * const uvc_hs_streaming_cls[] = {
308 * USB configuration 308 * USB configuration
309 */ 309 */
310 310
311static int __ref 311static int __init
312webcam_config_bind(struct usb_configuration *c) 312webcam_config_bind(struct usb_configuration *c)
313{ 313{
314 return uvc_bind_config(c, uvc_control_cls, uvc_fs_streaming_cls, 314 return uvc_bind_config(c, uvc_control_cls, uvc_fs_streaming_cls,
@@ -317,7 +317,6 @@ webcam_config_bind(struct usb_configuration *c)
317 317
318static struct usb_configuration webcam_config_driver = { 318static struct usb_configuration webcam_config_driver = {
319 .label = webcam_config_label, 319 .label = webcam_config_label,
320 .bind = webcam_config_bind,
321 .bConfigurationValue = 1, 320 .bConfigurationValue = 1,
322 .iConfiguration = 0, /* dynamic */ 321 .iConfiguration = 0, /* dynamic */
323 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 322 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -330,7 +329,7 @@ webcam_unbind(struct usb_composite_dev *cdev)
330 return 0; 329 return 0;
331} 330}
332 331
333static int __ref 332static int __init
334webcam_bind(struct usb_composite_dev *cdev) 333webcam_bind(struct usb_composite_dev *cdev)
335{ 334{
336 int ret; 335 int ret;
@@ -354,7 +353,8 @@ webcam_bind(struct usb_composite_dev *cdev)
354 webcam_config_driver.iConfiguration = ret; 353 webcam_config_driver.iConfiguration = ret;
355 354
356 /* Register our configuration. */ 355 /* Register our configuration. */
357 if ((ret = usb_add_config(cdev, &webcam_config_driver)) < 0) 356 if ((ret = usb_add_config(cdev, &webcam_config_driver,
357 webcam_config_bind)) < 0)
358 goto error; 358 goto error;
359 359
360 INFO(cdev, "Webcam Video Gadget\n"); 360 INFO(cdev, "Webcam Video Gadget\n");
@@ -373,14 +373,13 @@ static struct usb_composite_driver webcam_driver = {
373 .name = "g_webcam", 373 .name = "g_webcam",
374 .dev = &webcam_device_descriptor, 374 .dev = &webcam_device_descriptor,
375 .strings = webcam_device_strings, 375 .strings = webcam_device_strings,
376 .bind = webcam_bind,
377 .unbind = webcam_unbind, 376 .unbind = webcam_unbind,
378}; 377};
379 378
380static int __init 379static int __init
381webcam_init(void) 380webcam_init(void)
382{ 381{
383 return usb_composite_register(&webcam_driver); 382 return usb_composite_probe(&webcam_driver, webcam_bind);
384} 383}
385 384
386static void __exit 385static void __exit
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index cf353920bb1c..6d16db9d9d2d 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -264,7 +264,7 @@ static void zero_resume(struct usb_composite_dev *cdev)
264 264
265/*-------------------------------------------------------------------------*/ 265/*-------------------------------------------------------------------------*/
266 266
267static int __ref zero_bind(struct usb_composite_dev *cdev) 267static int __init zero_bind(struct usb_composite_dev *cdev)
268{ 268{
269 int gcnum; 269 int gcnum;
270 struct usb_gadget *gadget = cdev->gadget; 270 struct usb_gadget *gadget = cdev->gadget;
@@ -340,7 +340,6 @@ static struct usb_composite_driver zero_driver = {
340 .name = "zero", 340 .name = "zero",
341 .dev = &device_desc, 341 .dev = &device_desc,
342 .strings = dev_strings, 342 .strings = dev_strings,
343 .bind = zero_bind,
344 .unbind = zero_unbind, 343 .unbind = zero_unbind,
345 .suspend = zero_suspend, 344 .suspend = zero_suspend,
346 .resume = zero_resume, 345 .resume = zero_resume,
@@ -351,7 +350,7 @@ MODULE_LICENSE("GPL");
351 350
352static int __init init(void) 351static int __init init(void)
353{ 352{
354 return usb_composite_register(&zero_driver); 353 return usb_composite_probe(&zero_driver, zero_bind);
355} 354}
356module_init(init); 355module_init(init);
357 356
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2d926cec0725..bf2e7d234533 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -93,12 +93,14 @@ config USB_EHCI_TT_NEWSCHED
93 93
94config USB_EHCI_BIG_ENDIAN_MMIO 94config USB_EHCI_BIG_ENDIAN_MMIO
95 bool 95 bool
96 depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX) 96 depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || \
97 XPS_USB_HCD_XILINX || PPC_MPC512x)
97 default y 98 default y
98 99
99config USB_EHCI_BIG_ENDIAN_DESC 100config USB_EHCI_BIG_ENDIAN_DESC
100 bool 101 bool
101 depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX) 102 depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX || \
103 PPC_MPC512x)
102 default y 104 default y
103 105
104config XPS_USB_HCD_XILINX 106config XPS_USB_HCD_XILINX
@@ -112,10 +114,14 @@ config XPS_USB_HCD_XILINX
112 support both high speed and full speed devices, or high speed 114 support both high speed and full speed devices, or high speed
113 devices only. 115 devices only.
114 116
117config USB_FSL_MPH_DR_OF
118 tristate
119
115config USB_EHCI_FSL 120config USB_EHCI_FSL
116 bool "Support for Freescale on-chip EHCI USB controller" 121 bool "Support for Freescale on-chip EHCI USB controller"
117 depends on USB_EHCI_HCD && FSL_SOC 122 depends on USB_EHCI_HCD && FSL_SOC
118 select USB_EHCI_ROOT_HUB_TT 123 select USB_EHCI_ROOT_HUB_TT
124 select USB_FSL_MPH_DR_OF
119 ---help--- 125 ---help---
120 Variation of ARC USB block used in some Freescale chips. 126 Variation of ARC USB block used in some Freescale chips.
121 127
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index b6315aa47f7a..91c5a1bd1026 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -2,17 +2,17 @@
2# Makefile for USB Host Controller Drivers 2# Makefile for USB Host Controller Drivers
3# 3#
4 4
5ifeq ($(CONFIG_USB_DEBUG),y) 5ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
6 EXTRA_CFLAGS += -DDEBUG 6
7endif 7isp1760-y := isp1760-hcd.o isp1760-if.o
8 8
9isp1760-objs := isp1760-hcd.o isp1760-if.o 9fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
10fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \ 10fhci-y += fhci-mem.o fhci-tds.o fhci-sched.o
11 fhci-tds.o fhci-sched.o 11
12ifeq ($(CONFIG_FHCI_DEBUG),y) 12fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o
13fhci-objs += fhci-dbg.o 13
14endif 14xhci-hcd-y := xhci.o xhci-mem.o xhci-pci.o
15xhci-hcd-objs := xhci.o xhci-mem.o xhci-pci.o xhci-ring.o xhci-hub.o xhci-dbg.o 15xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
16 16
17obj-$(CONFIG_USB_WHCI_HCD) += whci/ 17obj-$(CONFIG_USB_WHCI_HCD) += whci/
18 18
@@ -33,4 +33,4 @@ obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
33obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o 33obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o
34obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o 34obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o
35obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o 35obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o
36 36obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index a416421abfa2..86e42892016d 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -116,13 +116,33 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
116 goto err3; 116 goto err3;
117 } 117 }
118 118
119 /* Enable USB controller */ 119 pdata->regs = hcd->regs;
120 temp = in_be32(hcd->regs + 0x500);
121 out_be32(hcd->regs + 0x500, temp | 0x4);
122 120
123 /* Set to Host mode */ 121 /*
124 temp = in_le32(hcd->regs + 0x1a8); 122 * do platform specific init: check the clock, grab/config pins, etc.
125 out_le32(hcd->regs + 0x1a8, temp | 0x3); 123 */
124 if (pdata->init && pdata->init(pdev)) {
125 retval = -ENODEV;
126 goto err3;
127 }
128
129 /*
130 * Check if it is MPC5121 SoC, otherwise set pdata->have_sysif_regs
131 * flag for 83xx or 8536 system interface registers.
132 */
133 if (pdata->big_endian_mmio)
134 temp = in_be32(hcd->regs + FSL_SOC_USB_ID);
135 else
136 temp = in_le32(hcd->regs + FSL_SOC_USB_ID);
137
138 if ((temp & ID_MSK) != (~((temp & NID_MSK) >> 8) & ID_MSK))
139 pdata->have_sysif_regs = 1;
140
141 /* Enable USB controller, 83xx or 8536 */
142 if (pdata->have_sysif_regs)
143 setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4);
144
145 /* Don't need to set host mode here. It will be done by tdi_reset() */
126 146
127 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); 147 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
128 if (retval != 0) 148 if (retval != 0)
@@ -137,6 +157,8 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
137 usb_put_hcd(hcd); 157 usb_put_hcd(hcd);
138 err1: 158 err1:
139 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval); 159 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval);
160 if (pdata->exit)
161 pdata->exit(pdev);
140 return retval; 162 return retval;
141} 163}
142 164
@@ -154,17 +176,30 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
154static void usb_hcd_fsl_remove(struct usb_hcd *hcd, 176static void usb_hcd_fsl_remove(struct usb_hcd *hcd,
155 struct platform_device *pdev) 177 struct platform_device *pdev)
156{ 178{
179 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
180
157 usb_remove_hcd(hcd); 181 usb_remove_hcd(hcd);
182
183 /*
184 * do platform specific un-initialization:
185 * release iomux pins, disable clock, etc.
186 */
187 if (pdata->exit)
188 pdata->exit(pdev);
158 iounmap(hcd->regs); 189 iounmap(hcd->regs);
159 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 190 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
160 usb_put_hcd(hcd); 191 usb_put_hcd(hcd);
161} 192}
162 193
163static void mpc83xx_setup_phy(struct ehci_hcd *ehci, 194static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
164 enum fsl_usb2_phy_modes phy_mode, 195 enum fsl_usb2_phy_modes phy_mode,
165 unsigned int port_offset) 196 unsigned int port_offset)
166{ 197{
167 u32 portsc = 0; 198 u32 portsc;
199
200 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]);
201 portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW);
202
168 switch (phy_mode) { 203 switch (phy_mode) {
169 case FSL_USB2_PHY_ULPI: 204 case FSL_USB2_PHY_ULPI:
170 portsc |= PORT_PTS_ULPI; 205 portsc |= PORT_PTS_ULPI;
@@ -184,20 +219,21 @@ static void mpc83xx_setup_phy(struct ehci_hcd *ehci,
184 ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); 219 ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
185} 220}
186 221
187static void mpc83xx_usb_setup(struct usb_hcd *hcd) 222static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
188{ 223{
189 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 224 struct usb_hcd *hcd = ehci_to_hcd(ehci);
190 struct fsl_usb2_platform_data *pdata; 225 struct fsl_usb2_platform_data *pdata;
191 void __iomem *non_ehci = hcd->regs; 226 void __iomem *non_ehci = hcd->regs;
192 u32 temp; 227 u32 temp;
193 228
194 pdata = 229 pdata = hcd->self.controller->platform_data;
195 (struct fsl_usb2_platform_data *)hcd->self.controller-> 230
196 platform_data;
197 /* Enable PHY interface in the control reg. */ 231 /* Enable PHY interface in the control reg. */
198 temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); 232 if (pdata->have_sysif_regs) {
199 out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004); 233 temp = in_be32(non_ehci + FSL_SOC_USB_CTRL);
200 out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b); 234 out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004);
235 out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b);
236 }
201 237
202#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 238#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
203 /* 239 /*
@@ -214,7 +250,7 @@ static void mpc83xx_usb_setup(struct usb_hcd *hcd)
214 250
215 if ((pdata->operating_mode == FSL_USB2_DR_HOST) || 251 if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
216 (pdata->operating_mode == FSL_USB2_DR_OTG)) 252 (pdata->operating_mode == FSL_USB2_DR_OTG))
217 mpc83xx_setup_phy(ehci, pdata->phy_mode, 0); 253 ehci_fsl_setup_phy(ehci, pdata->phy_mode, 0);
218 254
219 if (pdata->operating_mode == FSL_USB2_MPH_HOST) { 255 if (pdata->operating_mode == FSL_USB2_MPH_HOST) {
220 unsigned int chip, rev, svr; 256 unsigned int chip, rev, svr;
@@ -228,27 +264,27 @@ static void mpc83xx_usb_setup(struct usb_hcd *hcd)
228 ehci->has_fsl_port_bug = 1; 264 ehci->has_fsl_port_bug = 1;
229 265
230 if (pdata->port_enables & FSL_USB2_PORT0_ENABLED) 266 if (pdata->port_enables & FSL_USB2_PORT0_ENABLED)
231 mpc83xx_setup_phy(ehci, pdata->phy_mode, 0); 267 ehci_fsl_setup_phy(ehci, pdata->phy_mode, 0);
232 if (pdata->port_enables & FSL_USB2_PORT1_ENABLED) 268 if (pdata->port_enables & FSL_USB2_PORT1_ENABLED)
233 mpc83xx_setup_phy(ehci, pdata->phy_mode, 1); 269 ehci_fsl_setup_phy(ehci, pdata->phy_mode, 1);
234 } 270 }
235 271
236 /* put controller in host mode. */ 272 if (pdata->have_sysif_regs) {
237 ehci_writel(ehci, 0x00000003, non_ehci + FSL_SOC_USB_USBMODE);
238#ifdef CONFIG_PPC_85xx 273#ifdef CONFIG_PPC_85xx
239 out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x00000008); 274 out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x00000008);
240 out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000080); 275 out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000080);
241#else 276#else
242 out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x0000000c); 277 out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x0000000c);
243 out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000040); 278 out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000040);
244#endif 279#endif
245 out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001); 280 out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001);
281 }
246} 282}
247 283
248/* called after powerup, by probe or system-pm "wakeup" */ 284/* called after powerup, by probe or system-pm "wakeup" */
249static int ehci_fsl_reinit(struct ehci_hcd *ehci) 285static int ehci_fsl_reinit(struct ehci_hcd *ehci)
250{ 286{
251 mpc83xx_usb_setup(ehci_to_hcd(ehci)); 287 ehci_fsl_usb_setup(ehci);
252 ehci_port_power(ehci, 0); 288 ehci_port_power(ehci, 0);
253 289
254 return 0; 290 return 0;
@@ -259,6 +295,11 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
259{ 295{
260 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 296 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
261 int retval; 297 int retval;
298 struct fsl_usb2_platform_data *pdata;
299
300 pdata = hcd->self.controller->platform_data;
301 ehci->big_endian_desc = pdata->big_endian_desc;
302 ehci->big_endian_mmio = pdata->big_endian_mmio;
262 303
263 /* EHCI registers start at offset 0x100 */ 304 /* EHCI registers start at offset 0x100 */
264 ehci->caps = hcd->regs + 0x100; 305 ehci->caps = hcd->regs + 0x100;
@@ -270,6 +311,8 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
270 /* cache this readonly data; minimize chip reads */ 311 /* cache this readonly data; minimize chip reads */
271 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 312 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
272 313
314 hcd->has_tt = 1;
315
273 retval = ehci_halt(ehci); 316 retval = ehci_halt(ehci);
274 if (retval) 317 if (retval)
275 return retval; 318 return retval;
@@ -279,8 +322,6 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
279 if (retval) 322 if (retval)
280 return retval; 323 return retval;
281 324
282 hcd->has_tt = 1;
283
284 ehci->sbrn = 0x20; 325 ehci->sbrn = 0x20;
285 326
286 ehci_reset(ehci); 327 ehci_reset(ehci);
@@ -372,7 +413,7 @@ static const struct hc_driver ehci_fsl_hc_driver = {
372 * generic hardware linkage 413 * generic hardware linkage
373 */ 414 */
374 .irq = ehci_irq, 415 .irq = ehci_irq,
375 .flags = HCD_USB2, 416 .flags = HCD_USB2 | HCD_MEMORY,
376 417
377 /* 418 /*
378 * basic lifecycle operations 419 * basic lifecycle operations
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index b5e59db53347..2c8353795226 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -1,4 +1,4 @@
1/* Copyright (c) 2005 freescale semiconductor 1/* Copyright (C) 2005-2010 Freescale Semiconductor, Inc.
2 * Copyright (c) 2005 MontaVista Software 2 * Copyright (c) 2005 MontaVista Software
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
@@ -19,6 +19,9 @@
19#define _EHCI_FSL_H 19#define _EHCI_FSL_H
20 20
21/* offsets for the non-ehci registers in the FSL SOC USB controller */ 21/* offsets for the non-ehci registers in the FSL SOC USB controller */
22#define FSL_SOC_USB_ID 0x0
23#define ID_MSK 0x3f
24#define NID_MSK 0x3f00
22#define FSL_SOC_USB_ULPIVP 0x170 25#define FSL_SOC_USB_ULPIVP 0x170
23#define FSL_SOC_USB_PORTSC1 0x184 26#define FSL_SOC_USB_PORTSC1 0x184
24#define PORT_PTS_MSK (3<<30) 27#define PORT_PTS_MSK (3<<30)
@@ -27,7 +30,14 @@
27#define PORT_PTS_SERIAL (3<<30) 30#define PORT_PTS_SERIAL (3<<30)
28#define PORT_PTS_PTW (1<<28) 31#define PORT_PTS_PTW (1<<28)
29#define FSL_SOC_USB_PORTSC2 0x188 32#define FSL_SOC_USB_PORTSC2 0x188
30#define FSL_SOC_USB_USBMODE 0x1a8 33
34#define FSL_SOC_USB_USBGENCTRL 0x200
35#define USBGENCTRL_PPP (1 << 3)
36#define USBGENCTRL_PFP (1 << 2)
37#define FSL_SOC_USB_ISIPHYCTRL 0x204
38#define ISIPHYCTRL_PXE (1)
39#define ISIPHYCTRL_PHYE (1 << 4)
40
31#define FSL_SOC_USB_SNOOP1 0x400 /* NOTE: big-endian */ 41#define FSL_SOC_USB_SNOOP1 0x400 /* NOTE: big-endian */
32#define FSL_SOC_USB_SNOOP2 0x404 /* NOTE: big-endian */ 42#define FSL_SOC_USB_SNOOP2 0x404 /* NOTE: big-endian */
33#define FSL_SOC_USB_AGECNTTHRSH 0x408 /* NOTE: big-endian */ 43#define FSL_SOC_USB_AGECNTTHRSH 0x408 /* NOTE: big-endian */
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 34a928d3b7d2..15fe3ecd203b 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -194,6 +194,17 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
194 return -ETIMEDOUT; 194 return -ETIMEDOUT;
195} 195}
196 196
197/* check TDI/ARC silicon is in host mode */
198static int tdi_in_host_mode (struct ehci_hcd *ehci)
199{
200 u32 __iomem *reg_ptr;
201 u32 tmp;
202
203 reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE);
204 tmp = ehci_readl(ehci, reg_ptr);
205 return (tmp & 3) == USBMODE_CM_HC;
206}
207
197/* force HC to halt state from unknown (EHCI spec section 2.3) */ 208/* force HC to halt state from unknown (EHCI spec section 2.3) */
198static int ehci_halt (struct ehci_hcd *ehci) 209static int ehci_halt (struct ehci_hcd *ehci)
199{ 210{
@@ -202,6 +213,10 @@ static int ehci_halt (struct ehci_hcd *ehci)
202 /* disable any irqs left enabled by previous code */ 213 /* disable any irqs left enabled by previous code */
203 ehci_writel(ehci, 0, &ehci->regs->intr_enable); 214 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
204 215
216 if (ehci_is_TDI(ehci) && tdi_in_host_mode(ehci) == 0) {
217 return 0;
218 }
219
205 if ((temp & STS_HALT) != 0) 220 if ((temp & STS_HALT) != 0)
206 return 0; 221 return 0;
207 222
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index 1f3f01eacaf0..d36e4e75e08d 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -40,7 +40,7 @@ static inline void ehci_qtd_init(struct ehci_hcd *ehci, struct ehci_qtd *qtd,
40{ 40{
41 memset (qtd, 0, sizeof *qtd); 41 memset (qtd, 0, sizeof *qtd);
42 qtd->qtd_dma = dma; 42 qtd->qtd_dma = dma;
43 qtd->hw_token = cpu_to_le32 (QTD_STS_HALT); 43 qtd->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT);
44 qtd->hw_next = EHCI_LIST_END(ehci); 44 qtd->hw_next = EHCI_LIST_END(ehci);
45 qtd->hw_alt_next = EHCI_LIST_END(ehci); 45 qtd->hw_alt_next = EHCI_LIST_END(ehci);
46 INIT_LIST_HEAD (&qtd->qtd_list); 46 INIT_LIST_HEAD (&qtd->qtd_list);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a8ad8ac120a2..ac9c4d7c44af 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -26,9 +26,6 @@
26#include <mach/mxc_ehci.h> 26#include <mach/mxc_ehci.h>
27 27
28#define ULPI_VIEWPORT_OFFSET 0x170 28#define ULPI_VIEWPORT_OFFSET 0x170
29#define PORTSC_OFFSET 0x184
30#define USBMODE_OFFSET 0x1a8
31#define USBMODE_CM_HOST 3
32 29
33struct ehci_mxc_priv { 30struct ehci_mxc_priv {
34 struct clk *usbclk, *ahbclk; 31 struct clk *usbclk, *ahbclk;
@@ -51,6 +48,8 @@ static int ehci_mxc_setup(struct usb_hcd *hcd)
51 /* cache this readonly data; minimize chip reads */ 48 /* cache this readonly data; minimize chip reads */
52 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 49 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
53 50
51 hcd->has_tt = 1;
52
54 retval = ehci_halt(ehci); 53 retval = ehci_halt(ehci);
55 if (retval) 54 if (retval)
56 return retval; 55 return retval;
@@ -60,8 +59,6 @@ static int ehci_mxc_setup(struct usb_hcd *hcd)
60 if (retval) 59 if (retval)
61 return retval; 60 return retval;
62 61
63 hcd->has_tt = 1;
64
65 ehci->sbrn = 0x20; 62 ehci->sbrn = 0x20;
66 63
67 ehci_reset(ehci); 64 ehci_reset(ehci);
@@ -191,12 +188,8 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
191 clk_enable(priv->ahbclk); 188 clk_enable(priv->ahbclk);
192 } 189 }
193 190
194 /* set USBMODE to host mode */
195 temp = readl(hcd->regs + USBMODE_OFFSET);
196 writel(temp | USBMODE_CM_HOST, hcd->regs + USBMODE_OFFSET);
197
198 /* set up the PORTSCx register */ 191 /* set up the PORTSCx register */
199 writel(pdata->portsc, hcd->regs + PORTSC_OFFSET); 192 ehci_writel(ehci, pdata->portsc, &ehci->regs->port_status[0]);
200 mdelay(10); 193 mdelay(10);
201 194
202 /* setup specific usb hw */ 195 /* setup specific usb hw */
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
new file mode 100644
index 000000000000..574b99ea0700
--- /dev/null
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -0,0 +1,308 @@
1/*
2 * Setup platform devices needed by the Freescale multi-port host
3 * and/or dual-role USB controller modules based on the description
4 * in flat device tree.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/platform_device.h>
14#include <linux/fsl_devices.h>
15#include <linux/err.h>
16#include <linux/io.h>
17#include <linux/of_platform.h>
18#include <linux/clk.h>
19
20struct fsl_usb2_dev_data {
21 char *dr_mode; /* controller mode */
22 char *drivers[3]; /* drivers to instantiate for this mode */
23 enum fsl_usb2_operating_modes op_mode; /* operating mode */
24};
25
26struct fsl_usb2_dev_data dr_mode_data[] __devinitdata = {
27 {
28 .dr_mode = "host",
29 .drivers = { "fsl-ehci", NULL, NULL, },
30 .op_mode = FSL_USB2_DR_HOST,
31 },
32 {
33 .dr_mode = "otg",
34 .drivers = { "fsl-usb2-otg", "fsl-ehci", "fsl-usb2-udc", },
35 .op_mode = FSL_USB2_DR_OTG,
36 },
37 {
38 .dr_mode = "peripheral",
39 .drivers = { "fsl-usb2-udc", NULL, NULL, },
40 .op_mode = FSL_USB2_DR_DEVICE,
41 },
42};
43
44struct fsl_usb2_dev_data * __devinit get_dr_mode_data(struct device_node *np)
45{
46 const unsigned char *prop;
47 int i;
48
49 prop = of_get_property(np, "dr_mode", NULL);
50 if (prop) {
51 for (i = 0; i < ARRAY_SIZE(dr_mode_data); i++) {
52 if (!strcmp(prop, dr_mode_data[i].dr_mode))
53 return &dr_mode_data[i];
54 }
55 }
56 pr_warn("%s: Invalid 'dr_mode' property, fallback to host mode\n",
57 np->full_name);
58 return &dr_mode_data[0]; /* mode not specified, use host */
59}
60
61static enum fsl_usb2_phy_modes __devinit determine_usb_phy(const char *phy_type)
62{
63 if (!phy_type)
64 return FSL_USB2_PHY_NONE;
65 if (!strcasecmp(phy_type, "ulpi"))
66 return FSL_USB2_PHY_ULPI;
67 if (!strcasecmp(phy_type, "utmi"))
68 return FSL_USB2_PHY_UTMI;
69 if (!strcasecmp(phy_type, "utmi_wide"))
70 return FSL_USB2_PHY_UTMI_WIDE;
71 if (!strcasecmp(phy_type, "serial"))
72 return FSL_USB2_PHY_SERIAL;
73
74 return FSL_USB2_PHY_NONE;
75}
76
77struct platform_device * __devinit fsl_usb2_device_register(
78 struct platform_device *ofdev,
79 struct fsl_usb2_platform_data *pdata,
80 const char *name, int id)
81{
82 struct platform_device *pdev;
83 const struct resource *res = ofdev->resource;
84 unsigned int num = ofdev->num_resources;
85 int retval;
86
87 pdev = platform_device_alloc(name, id);
88 if (!pdev) {
89 retval = -ENOMEM;
90 goto error;
91 }
92
93 pdev->dev.parent = &ofdev->dev;
94
95 pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
96 pdev->dev.dma_mask = &pdev->archdata.dma_mask;
97 *pdev->dev.dma_mask = *ofdev->dev.dma_mask;
98
99 retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
100 if (retval)
101 goto error;
102
103 if (num) {
104 retval = platform_device_add_resources(pdev, res, num);
105 if (retval)
106 goto error;
107 }
108
109 retval = platform_device_add(pdev);
110 if (retval)
111 goto error;
112
113 return pdev;
114
115error:
116 platform_device_put(pdev);
117 return ERR_PTR(retval);
118}
119
120static const struct of_device_id fsl_usb2_mph_dr_of_match[];
121
122static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
123{
124 struct device_node *np = ofdev->dev.of_node;
125 struct platform_device *usb_dev;
126 struct fsl_usb2_platform_data data, *pdata;
127 struct fsl_usb2_dev_data *dev_data;
128 const struct of_device_id *match;
129 const unsigned char *prop;
130 static unsigned int idx;
131 int i;
132
133 if (!of_device_is_available(np))
134 return -ENODEV;
135
136 match = of_match_device(fsl_usb2_mph_dr_of_match, &ofdev->dev);
137 if (!match)
138 return -ENODEV;
139
140 pdata = &data;
141 if (match->data)
142 memcpy(pdata, match->data, sizeof(data));
143 else
144 memset(pdata, 0, sizeof(data));
145
146 dev_data = get_dr_mode_data(np);
147
148 if (of_device_is_compatible(np, "fsl-usb2-mph")) {
149 if (of_get_property(np, "port0", NULL))
150 pdata->port_enables |= FSL_USB2_PORT0_ENABLED;
151
152 if (of_get_property(np, "port1", NULL))
153 pdata->port_enables |= FSL_USB2_PORT1_ENABLED;
154
155 pdata->operating_mode = FSL_USB2_MPH_HOST;
156 } else {
157 if (of_get_property(np, "fsl,invert-drvvbus", NULL))
158 pdata->invert_drvvbus = 1;
159
160 if (of_get_property(np, "fsl,invert-pwr-fault", NULL))
161 pdata->invert_pwr_fault = 1;
162
163 /* setup mode selected in the device tree */
164 pdata->operating_mode = dev_data->op_mode;
165 }
166
167 prop = of_get_property(np, "phy_type", NULL);
168 pdata->phy_mode = determine_usb_phy(prop);
169
170 for (i = 0; i < ARRAY_SIZE(dev_data->drivers); i++) {
171 if (!dev_data->drivers[i])
172 continue;
173 usb_dev = fsl_usb2_device_register(ofdev, pdata,
174 dev_data->drivers[i], idx);
175 if (IS_ERR(usb_dev)) {
176 dev_err(&ofdev->dev, "Can't register usb device\n");
177 return PTR_ERR(usb_dev);
178 }
179 }
180 idx++;
181 return 0;
182}
183
184static int __devexit __unregister_subdev(struct device *dev, void *d)
185{
186 platform_device_unregister(to_platform_device(dev));
187 return 0;
188}
189
190static int __devexit fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev)
191{
192 device_for_each_child(&ofdev->dev, NULL, __unregister_subdev);
193 return 0;
194}
195
196#ifdef CONFIG_PPC_MPC512x
197
198#define USBGENCTRL 0x200 /* NOTE: big endian */
199#define GC_WU_INT_CLR (1 << 5) /* Wakeup int clear */
200#define GC_ULPI_SEL (1 << 4) /* ULPI i/f select (usb0 only)*/
201#define GC_PPP (1 << 3) /* Inv. Port Power Polarity */
202#define GC_PFP (1 << 2) /* Inv. Power Fault Polarity */
203#define GC_WU_ULPI_EN (1 << 1) /* Wakeup on ULPI event */
204#define GC_WU_IE (1 << 1) /* Wakeup interrupt enable */
205
206#define ISIPHYCTRL 0x204 /* NOTE: big endian */
207#define PHYCTRL_PHYE (1 << 4) /* On-chip UTMI PHY enable */
208#define PHYCTRL_BSENH (1 << 3) /* Bit Stuff Enable High */
209#define PHYCTRL_BSEN (1 << 2) /* Bit Stuff Enable */
210#define PHYCTRL_LSFE (1 << 1) /* Line State Filter Enable */
211#define PHYCTRL_PXE (1 << 0) /* PHY oscillator enable */
212
213int fsl_usb2_mpc5121_init(struct platform_device *pdev)
214{
215 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
216 struct clk *clk;
217 char clk_name[10];
218 int base, clk_num;
219
220 base = pdev->resource->start & 0xf000;
221 if (base == 0x3000)
222 clk_num = 1;
223 else if (base == 0x4000)
224 clk_num = 2;
225 else
226 return -ENODEV;
227
228 snprintf(clk_name, sizeof(clk_name), "usb%d_clk", clk_num);
229 clk = clk_get(&pdev->dev, clk_name);
230 if (IS_ERR(clk)) {
231 dev_err(&pdev->dev, "failed to get clk\n");
232 return PTR_ERR(clk);
233 }
234
235 clk_enable(clk);
236 pdata->clk = clk;
237
238 if (pdata->phy_mode == FSL_USB2_PHY_UTMI_WIDE) {
239 u32 reg = 0;
240
241 if (pdata->invert_drvvbus)
242 reg |= GC_PPP;
243
244 if (pdata->invert_pwr_fault)
245 reg |= GC_PFP;
246
247 out_be32(pdata->regs + ISIPHYCTRL, PHYCTRL_PHYE | PHYCTRL_PXE);
248 out_be32(pdata->regs + USBGENCTRL, reg);
249 }
250 return 0;
251}
252
253static void fsl_usb2_mpc5121_exit(struct platform_device *pdev)
254{
255 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
256
257 pdata->regs = NULL;
258
259 if (pdata->clk) {
260 clk_disable(pdata->clk);
261 clk_put(pdata->clk);
262 }
263}
264
265struct fsl_usb2_platform_data fsl_usb2_mpc5121_pd = {
266 .big_endian_desc = 1,
267 .big_endian_mmio = 1,
268 .es = 1,
269 .le_setup_buf = 1,
270 .init = fsl_usb2_mpc5121_init,
271 .exit = fsl_usb2_mpc5121_exit,
272};
273#endif /* CONFIG_PPC_MPC512x */
274
275static const struct of_device_id fsl_usb2_mph_dr_of_match[] = {
276 { .compatible = "fsl-usb2-mph", },
277 { .compatible = "fsl-usb2-dr", },
278#ifdef CONFIG_PPC_MPC512x
279 { .compatible = "fsl,mpc5121-usb2-dr", .data = &fsl_usb2_mpc5121_pd, },
280#endif
281 {},
282};
283
284static struct platform_driver fsl_usb2_mph_dr_driver = {
285 .driver = {
286 .name = "fsl-usb2-mph-dr",
287 .owner = THIS_MODULE,
288 .of_match_table = fsl_usb2_mph_dr_of_match,
289 },
290 .probe = fsl_usb2_mph_dr_of_probe,
291 .remove = __devexit_p(fsl_usb2_mph_dr_of_remove),
292};
293
294static int __init fsl_usb2_mph_dr_init(void)
295{
296 return platform_driver_register(&fsl_usb2_mph_dr_driver);
297}
298module_init(fsl_usb2_mph_dr_init);
299
300static void __exit fsl_usb2_mph_dr_exit(void)
301{
302 platform_driver_unregister(&fsl_usb2_mph_dr_driver);
303}
304module_exit(fsl_usb2_mph_dr_exit);
305
306MODULE_DESCRIPTION("FSL MPH DR OF devices driver");
307MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>");
308MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index 3e5630369c31..1dfb2c8f7707 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -57,6 +57,7 @@
57#include <linux/slab.h> 57#include <linux/slab.h>
58#include <linux/usb.h> 58#include <linux/usb.h>
59#include <linux/usb/hcd.h> 59#include <linux/usb/hcd.h>
60#include <linux/dma-mapping.h>
60 61
61#include "imx21-hcd.h" 62#include "imx21-hcd.h"
62 63
@@ -136,9 +137,18 @@ static int imx21_hc_get_frame(struct usb_hcd *hcd)
136 return wrap_frame(readl(imx21->regs + USBH_FRMNUB)); 137 return wrap_frame(readl(imx21->regs + USBH_FRMNUB));
137} 138}
138 139
140static inline bool unsuitable_for_dma(dma_addr_t addr)
141{
142 return (addr & 3) != 0;
143}
139 144
140#include "imx21-dbg.c" 145#include "imx21-dbg.c"
141 146
147static void nonisoc_urb_completed_for_etd(
148 struct imx21 *imx21, struct etd_priv *etd, int status);
149static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb);
150static void free_dmem(struct imx21 *imx21, struct etd_priv *etd);
151
142/* =========================================== */ 152/* =========================================== */
143/* ETD management */ 153/* ETD management */
144/* =========================================== */ 154/* =========================================== */
@@ -185,7 +195,8 @@ static void reset_etd(struct imx21 *imx21, int num)
185 etd_writel(imx21, num, i, 0); 195 etd_writel(imx21, num, i, 0);
186 etd->urb = NULL; 196 etd->urb = NULL;
187 etd->ep = NULL; 197 etd->ep = NULL;
188 etd->td = NULL;; 198 etd->td = NULL;
199 etd->bounce_buffer = NULL;
189} 200}
190 201
191static void free_etd(struct imx21 *imx21, int num) 202static void free_etd(struct imx21 *imx21, int num)
@@ -221,26 +232,94 @@ static void setup_etd_dword0(struct imx21 *imx21,
221 ((u32) maxpacket << DW0_MAXPKTSIZ)); 232 ((u32) maxpacket << DW0_MAXPKTSIZ));
222} 233}
223 234
224static void activate_etd(struct imx21 *imx21, 235/**
225 int etd_num, dma_addr_t dma, u8 dir) 236 * Copy buffer to data controller data memory.
237 * We cannot use memcpy_toio() because the hardware requires 32bit writes
238 */
239static void copy_to_dmem(
240 struct imx21 *imx21, int dmem_offset, void *src, int count)
241{
242 void __iomem *dmem = imx21->regs + USBOTG_DMEM + dmem_offset;
243 u32 word = 0;
244 u8 *p = src;
245 int byte = 0;
246 int i;
247
248 for (i = 0; i < count; i++) {
249 byte = i % 4;
250 word += (*p++ << (byte * 8));
251 if (byte == 3) {
252 writel(word, dmem);
253 dmem += 4;
254 word = 0;
255 }
256 }
257
258 if (count && byte != 3)
259 writel(word, dmem);
260}
261
262static void activate_etd(struct imx21 *imx21, int etd_num, u8 dir)
226{ 263{
227 u32 etd_mask = 1 << etd_num; 264 u32 etd_mask = 1 << etd_num;
228 struct etd_priv *etd = &imx21->etd[etd_num]; 265 struct etd_priv *etd = &imx21->etd[etd_num];
229 266
267 if (etd->dma_handle && unsuitable_for_dma(etd->dma_handle)) {
268 /* For non aligned isoc the condition below is always true */
269 if (etd->len <= etd->dmem_size) {
270 /* Fits into data memory, use PIO */
271 if (dir != TD_DIR_IN) {
272 copy_to_dmem(imx21,
273 etd->dmem_offset,
274 etd->cpu_buffer, etd->len);
275 }
276 etd->dma_handle = 0;
277
278 } else {
279 /* Too big for data memory, use bounce buffer */
280 enum dma_data_direction dmadir;
281
282 if (dir == TD_DIR_IN) {
283 dmadir = DMA_FROM_DEVICE;
284 etd->bounce_buffer = kmalloc(etd->len,
285 GFP_ATOMIC);
286 } else {
287 dmadir = DMA_TO_DEVICE;
288 etd->bounce_buffer = kmemdup(etd->cpu_buffer,
289 etd->len,
290 GFP_ATOMIC);
291 }
292 if (!etd->bounce_buffer) {
293 dev_err(imx21->dev, "failed bounce alloc\n");
294 goto err_bounce_alloc;
295 }
296
297 etd->dma_handle =
298 dma_map_single(imx21->dev,
299 etd->bounce_buffer,
300 etd->len,
301 dmadir);
302 if (dma_mapping_error(imx21->dev, etd->dma_handle)) {
303 dev_err(imx21->dev, "failed bounce map\n");
304 goto err_bounce_map;
305 }
306 }
307 }
308
230 clear_toggle_bit(imx21, USBH_ETDDONESTAT, etd_mask); 309 clear_toggle_bit(imx21, USBH_ETDDONESTAT, etd_mask);
231 set_register_bits(imx21, USBH_ETDDONEEN, etd_mask); 310 set_register_bits(imx21, USBH_ETDDONEEN, etd_mask);
232 clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 311 clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
233 clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask); 312 clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask);
234 313
235 if (dma) { 314 if (etd->dma_handle) {
236 set_register_bits(imx21, USB_ETDDMACHANLCLR, etd_mask); 315 set_register_bits(imx21, USB_ETDDMACHANLCLR, etd_mask);
237 clear_toggle_bit(imx21, USBH_XBUFSTAT, etd_mask); 316 clear_toggle_bit(imx21, USBH_XBUFSTAT, etd_mask);
238 clear_toggle_bit(imx21, USBH_YBUFSTAT, etd_mask); 317 clear_toggle_bit(imx21, USBH_YBUFSTAT, etd_mask);
239 writel(dma, imx21->regs + USB_ETDSMSA(etd_num)); 318 writel(etd->dma_handle, imx21->regs + USB_ETDSMSA(etd_num));
240 set_register_bits(imx21, USB_ETDDMAEN, etd_mask); 319 set_register_bits(imx21, USB_ETDDMAEN, etd_mask);
241 } else { 320 } else {
242 if (dir != TD_DIR_IN) { 321 if (dir != TD_DIR_IN) {
243 /* need to set for ZLP */ 322 /* need to set for ZLP and PIO */
244 set_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 323 set_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
245 set_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask); 324 set_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask);
246 } 325 }
@@ -263,6 +342,14 @@ static void activate_etd(struct imx21 *imx21,
263 342
264 etd->active_count = 1; 343 etd->active_count = 1;
265 writel(etd_mask, imx21->regs + USBH_ETDENSET); 344 writel(etd_mask, imx21->regs + USBH_ETDENSET);
345 return;
346
347err_bounce_map:
348 kfree(etd->bounce_buffer);
349
350err_bounce_alloc:
351 free_dmem(imx21, etd);
352 nonisoc_urb_completed_for_etd(imx21, etd, -ENOMEM);
266} 353}
267 354
268/* =========================================== */ 355/* =========================================== */
@@ -323,16 +410,23 @@ static void activate_queued_etd(struct imx21 *imx21,
323 etd_writel(imx21, etd_num, 1, 410 etd_writel(imx21, etd_num, 1,
324 ((dmem_offset + maxpacket) << DW1_YBUFSRTAD) | dmem_offset); 411 ((dmem_offset + maxpacket) << DW1_YBUFSRTAD) | dmem_offset);
325 412
413 etd->dmem_offset = dmem_offset;
326 urb_priv->active = 1; 414 urb_priv->active = 1;
327 activate_etd(imx21, etd_num, etd->dma_handle, dir); 415 activate_etd(imx21, etd_num, dir);
328} 416}
329 417
330static void free_dmem(struct imx21 *imx21, int offset) 418static void free_dmem(struct imx21 *imx21, struct etd_priv *etd)
331{ 419{
332 struct imx21_dmem_area *area; 420 struct imx21_dmem_area *area;
333 struct etd_priv *etd, *tmp; 421 struct etd_priv *tmp;
334 int found = 0; 422 int found = 0;
423 int offset;
335 424
425 if (!etd->dmem_size)
426 return;
427 etd->dmem_size = 0;
428
429 offset = etd->dmem_offset;
336 list_for_each_entry(area, &imx21->dmem_list, list) { 430 list_for_each_entry(area, &imx21->dmem_list, list) {
337 if (area->offset == offset) { 431 if (area->offset == offset) {
338 debug_dmem_freed(imx21, area->size); 432 debug_dmem_freed(imx21, area->size);
@@ -378,20 +472,23 @@ static void free_epdmem(struct imx21 *imx21, struct usb_host_endpoint *ep)
378/* =========================================== */ 472/* =========================================== */
379/* End handling */ 473/* End handling */
380/* =========================================== */ 474/* =========================================== */
381static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb);
382 475
383/* Endpoint now idle - release it's ETD(s) or asssign to queued request */ 476/* Endpoint now idle - release it's ETD(s) or asssign to queued request */
384static void ep_idle(struct imx21 *imx21, struct ep_priv *ep_priv) 477static void ep_idle(struct imx21 *imx21, struct ep_priv *ep_priv)
385{ 478{
386 int etd_num;
387 int i; 479 int i;
388 480
389 for (i = 0; i < NUM_ISO_ETDS; i++) { 481 for (i = 0; i < NUM_ISO_ETDS; i++) {
390 etd_num = ep_priv->etd[i]; 482 int etd_num = ep_priv->etd[i];
483 struct etd_priv *etd;
391 if (etd_num < 0) 484 if (etd_num < 0)
392 continue; 485 continue;
393 486
487 etd = &imx21->etd[etd_num];
394 ep_priv->etd[i] = -1; 488 ep_priv->etd[i] = -1;
489
490 free_dmem(imx21, etd); /* for isoc */
491
395 if (list_empty(&imx21->queue_for_etd)) { 492 if (list_empty(&imx21->queue_for_etd)) {
396 free_etd(imx21, etd_num); 493 free_etd(imx21, etd_num);
397 continue; 494 continue;
@@ -437,6 +534,24 @@ __acquires(imx21->lock)
437 ep_idle(imx21, ep_priv); 534 ep_idle(imx21, ep_priv);
438} 535}
439 536
537static void nonisoc_urb_completed_for_etd(
538 struct imx21 *imx21, struct etd_priv *etd, int status)
539{
540 struct usb_host_endpoint *ep = etd->ep;
541
542 urb_done(imx21->hcd, etd->urb, status);
543 etd->urb = NULL;
544
545 if (!list_empty(&ep->urb_list)) {
546 struct urb *urb = list_first_entry(
547 &ep->urb_list, struct urb, urb_list);
548
549 dev_vdbg(imx21->dev, "next URB %p\n", urb);
550 schedule_nonisoc_etd(imx21, urb);
551 }
552}
553
554
440/* =========================================== */ 555/* =========================================== */
441/* ISOC Handling ... */ 556/* ISOC Handling ... */
442/* =========================================== */ 557/* =========================================== */
@@ -489,6 +604,8 @@ too_late:
489 etd->ep = td->ep; 604 etd->ep = td->ep;
490 etd->urb = td->urb; 605 etd->urb = td->urb;
491 etd->len = td->len; 606 etd->len = td->len;
607 etd->dma_handle = td->dma_handle;
608 etd->cpu_buffer = td->cpu_buffer;
492 609
493 debug_isoc_submitted(imx21, cur_frame, td); 610 debug_isoc_submitted(imx21, cur_frame, td);
494 611
@@ -502,16 +619,17 @@ too_late:
502 (TD_NOTACCESSED << DW3_COMPCODE0) | 619 (TD_NOTACCESSED << DW3_COMPCODE0) |
503 (td->len << DW3_PKTLEN0)); 620 (td->len << DW3_PKTLEN0));
504 621
505 activate_etd(imx21, etd_num, td->data, dir); 622 activate_etd(imx21, etd_num, dir);
506 } 623 }
507} 624}
508 625
509static void isoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num) 626static void isoc_etd_done(struct usb_hcd *hcd, int etd_num)
510{ 627{
511 struct imx21 *imx21 = hcd_to_imx21(hcd); 628 struct imx21 *imx21 = hcd_to_imx21(hcd);
512 int etd_mask = 1 << etd_num; 629 int etd_mask = 1 << etd_num;
513 struct urb_priv *urb_priv = urb->hcpriv;
514 struct etd_priv *etd = imx21->etd + etd_num; 630 struct etd_priv *etd = imx21->etd + etd_num;
631 struct urb *urb = etd->urb;
632 struct urb_priv *urb_priv = urb->hcpriv;
515 struct td *td = etd->td; 633 struct td *td = etd->td;
516 struct usb_host_endpoint *ep = etd->ep; 634 struct usb_host_endpoint *ep = etd->ep;
517 int isoc_index = td->isoc_index; 635 int isoc_index = td->isoc_index;
@@ -545,8 +663,13 @@ static void isoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
545 bytes_xfrd, td->len, urb, etd_num, isoc_index); 663 bytes_xfrd, td->len, urb, etd_num, isoc_index);
546 } 664 }
547 665
548 if (dir_in) 666 if (dir_in) {
549 clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 667 clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
668 if (!etd->dma_handle)
669 memcpy_fromio(etd->cpu_buffer,
670 imx21->regs + USBOTG_DMEM + etd->dmem_offset,
671 bytes_xfrd);
672 }
550 673
551 urb->actual_length += bytes_xfrd; 674 urb->actual_length += bytes_xfrd;
552 urb->iso_frame_desc[isoc_index].actual_length = bytes_xfrd; 675 urb->iso_frame_desc[isoc_index].actual_length = bytes_xfrd;
@@ -569,30 +692,43 @@ static struct ep_priv *alloc_isoc_ep(
569 int i; 692 int i;
570 693
571 ep_priv = kzalloc(sizeof(struct ep_priv), GFP_ATOMIC); 694 ep_priv = kzalloc(sizeof(struct ep_priv), GFP_ATOMIC);
572 if (ep_priv == NULL) 695 if (!ep_priv)
573 return NULL; 696 return NULL;
574 697
575 /* Allocate the ETDs */ 698 for (i = 0; i < NUM_ISO_ETDS; i++)
576 for (i = 0; i < NUM_ISO_ETDS; i++) { 699 ep_priv->etd[i] = -1;
577 ep_priv->etd[i] = alloc_etd(imx21);
578 if (ep_priv->etd[i] < 0) {
579 int j;
580 dev_err(imx21->dev, "isoc: Couldn't allocate etd\n");
581 for (j = 0; j < i; j++)
582 free_etd(imx21, ep_priv->etd[j]);
583 goto alloc_etd_failed;
584 }
585 imx21->etd[ep_priv->etd[i]].ep = ep;
586 }
587 700
588 INIT_LIST_HEAD(&ep_priv->td_list); 701 INIT_LIST_HEAD(&ep_priv->td_list);
589 ep_priv->ep = ep; 702 ep_priv->ep = ep;
590 ep->hcpriv = ep_priv; 703 ep->hcpriv = ep_priv;
591 return ep_priv; 704 return ep_priv;
705}
706
707static int alloc_isoc_etds(struct imx21 *imx21, struct ep_priv *ep_priv)
708{
709 int i, j;
710 int etd_num;
711
712 /* Allocate the ETDs if required */
713 for (i = 0; i < NUM_ISO_ETDS; i++) {
714 if (ep_priv->etd[i] < 0) {
715 etd_num = alloc_etd(imx21);
716 if (etd_num < 0)
717 goto alloc_etd_failed;
718
719 ep_priv->etd[i] = etd_num;
720 imx21->etd[etd_num].ep = ep_priv->ep;
721 }
722 }
723 return 0;
592 724
593alloc_etd_failed: 725alloc_etd_failed:
594 kfree(ep_priv); 726 dev_err(imx21->dev, "isoc: Couldn't allocate etd\n");
595 return NULL; 727 for (j = 0; j < i; j++) {
728 free_etd(imx21, ep_priv->etd[j]);
729 ep_priv->etd[j] = -1;
730 }
731 return -ENOMEM;
596} 732}
597 733
598static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd, 734static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd,
@@ -632,6 +768,10 @@ static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd,
632 ep_priv = ep->hcpriv; 768 ep_priv = ep->hcpriv;
633 } 769 }
634 770
771 ret = alloc_isoc_etds(imx21, ep_priv);
772 if (ret)
773 goto alloc_etd_failed;
774
635 ret = usb_hcd_link_urb_to_ep(hcd, urb); 775 ret = usb_hcd_link_urb_to_ep(hcd, urb);
636 if (ret) 776 if (ret)
637 goto link_failed; 777 goto link_failed;
@@ -688,12 +828,14 @@ static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd,
688 /* set up transfers */ 828 /* set up transfers */
689 td = urb_priv->isoc_td; 829 td = urb_priv->isoc_td;
690 for (i = 0; i < urb->number_of_packets; i++, td++) { 830 for (i = 0; i < urb->number_of_packets; i++, td++) {
831 unsigned int offset = urb->iso_frame_desc[i].offset;
691 td->ep = ep; 832 td->ep = ep;
692 td->urb = urb; 833 td->urb = urb;
693 td->len = urb->iso_frame_desc[i].length; 834 td->len = urb->iso_frame_desc[i].length;
694 td->isoc_index = i; 835 td->isoc_index = i;
695 td->frame = wrap_frame(urb->start_frame + urb->interval * i); 836 td->frame = wrap_frame(urb->start_frame + urb->interval * i);
696 td->data = urb->transfer_dma + urb->iso_frame_desc[i].offset; 837 td->dma_handle = urb->transfer_dma + offset;
838 td->cpu_buffer = urb->transfer_buffer + offset;
697 list_add_tail(&td->list, &ep_priv->td_list); 839 list_add_tail(&td->list, &ep_priv->td_list);
698 } 840 }
699 841
@@ -711,6 +853,7 @@ alloc_dmem_failed:
711 usb_hcd_unlink_urb_from_ep(hcd, urb); 853 usb_hcd_unlink_urb_from_ep(hcd, urb);
712 854
713link_failed: 855link_failed:
856alloc_etd_failed:
714alloc_ep_failed: 857alloc_ep_failed:
715 spin_unlock_irqrestore(&imx21->lock, flags); 858 spin_unlock_irqrestore(&imx21->lock, flags);
716 kfree(urb_priv->isoc_td); 859 kfree(urb_priv->isoc_td);
@@ -734,9 +877,7 @@ static void dequeue_isoc_urb(struct imx21 *imx21,
734 struct etd_priv *etd = imx21->etd + etd_num; 877 struct etd_priv *etd = imx21->etd + etd_num;
735 878
736 reset_etd(imx21, etd_num); 879 reset_etd(imx21, etd_num);
737 if (etd->dmem_size) 880 free_dmem(imx21, etd);
738 free_dmem(imx21, etd->dmem_offset);
739 etd->dmem_size = 0;
740 } 881 }
741 } 882 }
742 } 883 }
@@ -761,7 +902,6 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
761 int state = urb_priv->state; 902 int state = urb_priv->state;
762 int etd_num = ep_priv->etd[0]; 903 int etd_num = ep_priv->etd[0];
763 struct etd_priv *etd; 904 struct etd_priv *etd;
764 int dmem_offset;
765 u32 count; 905 u32 count;
766 u16 etd_buf_size; 906 u16 etd_buf_size;
767 u16 maxpacket; 907 u16 maxpacket;
@@ -786,13 +926,15 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
786 if (usb_pipecontrol(pipe) && (state != US_CTRL_DATA)) { 926 if (usb_pipecontrol(pipe) && (state != US_CTRL_DATA)) {
787 if (state == US_CTRL_SETUP) { 927 if (state == US_CTRL_SETUP) {
788 dir = TD_DIR_SETUP; 928 dir = TD_DIR_SETUP;
929 if (unsuitable_for_dma(urb->setup_dma))
930 unmap_urb_setup_for_dma(imx21->hcd, urb);
789 etd->dma_handle = urb->setup_dma; 931 etd->dma_handle = urb->setup_dma;
932 etd->cpu_buffer = urb->setup_packet;
790 bufround = 0; 933 bufround = 0;
791 count = 8; 934 count = 8;
792 datatoggle = TD_TOGGLE_DATA0; 935 datatoggle = TD_TOGGLE_DATA0;
793 } else { /* US_CTRL_ACK */ 936 } else { /* US_CTRL_ACK */
794 dir = usb_pipeout(pipe) ? TD_DIR_IN : TD_DIR_OUT; 937 dir = usb_pipeout(pipe) ? TD_DIR_IN : TD_DIR_OUT;
795 etd->dma_handle = urb->transfer_dma;
796 bufround = 0; 938 bufround = 0;
797 count = 0; 939 count = 0;
798 datatoggle = TD_TOGGLE_DATA1; 940 datatoggle = TD_TOGGLE_DATA1;
@@ -800,7 +942,11 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
800 } else { 942 } else {
801 dir = usb_pipeout(pipe) ? TD_DIR_OUT : TD_DIR_IN; 943 dir = usb_pipeout(pipe) ? TD_DIR_OUT : TD_DIR_IN;
802 bufround = (dir == TD_DIR_IN) ? 1 : 0; 944 bufround = (dir == TD_DIR_IN) ? 1 : 0;
945 if (unsuitable_for_dma(urb->transfer_dma))
946 unmap_urb_for_dma(imx21->hcd, urb);
947
803 etd->dma_handle = urb->transfer_dma; 948 etd->dma_handle = urb->transfer_dma;
949 etd->cpu_buffer = urb->transfer_buffer;
804 if (usb_pipebulk(pipe) && (state == US_BULK0)) 950 if (usb_pipebulk(pipe) && (state == US_BULK0))
805 count = 0; 951 count = 0;
806 else 952 else
@@ -855,8 +1001,8 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
855 1001
856 /* allocate x and y buffer space at once */ 1002 /* allocate x and y buffer space at once */
857 etd->dmem_size = (count > maxpacket) ? maxpacket * 2 : maxpacket; 1003 etd->dmem_size = (count > maxpacket) ? maxpacket * 2 : maxpacket;
858 dmem_offset = alloc_dmem(imx21, etd->dmem_size, urb_priv->ep); 1004 etd->dmem_offset = alloc_dmem(imx21, etd->dmem_size, urb_priv->ep);
859 if (dmem_offset < 0) { 1005 if (etd->dmem_offset < 0) {
860 /* Setup everything we can in HW and update when we get DMEM */ 1006 /* Setup everything we can in HW and update when we get DMEM */
861 etd_writel(imx21, etd_num, 1, (u32)maxpacket << 16); 1007 etd_writel(imx21, etd_num, 1, (u32)maxpacket << 16);
862 1008
@@ -867,26 +1013,26 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
867 } 1013 }
868 1014
869 etd_writel(imx21, etd_num, 1, 1015 etd_writel(imx21, etd_num, 1,
870 (((u32) dmem_offset + (u32) maxpacket) << DW1_YBUFSRTAD) | 1016 (((u32) etd->dmem_offset + (u32) maxpacket) << DW1_YBUFSRTAD) |
871 (u32) dmem_offset); 1017 (u32) etd->dmem_offset);
872 1018
873 urb_priv->active = 1; 1019 urb_priv->active = 1;
874 1020
875 /* enable the ETD to kick off transfer */ 1021 /* enable the ETD to kick off transfer */
876 dev_vdbg(imx21->dev, "Activating etd %d for %d bytes %s\n", 1022 dev_vdbg(imx21->dev, "Activating etd %d for %d bytes %s\n",
877 etd_num, count, dir != TD_DIR_IN ? "out" : "in"); 1023 etd_num, count, dir != TD_DIR_IN ? "out" : "in");
878 activate_etd(imx21, etd_num, etd->dma_handle, dir); 1024 activate_etd(imx21, etd_num, dir);
879 1025
880} 1026}
881 1027
882static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num) 1028static void nonisoc_etd_done(struct usb_hcd *hcd, int etd_num)
883{ 1029{
884 struct imx21 *imx21 = hcd_to_imx21(hcd); 1030 struct imx21 *imx21 = hcd_to_imx21(hcd);
885 struct etd_priv *etd = &imx21->etd[etd_num]; 1031 struct etd_priv *etd = &imx21->etd[etd_num];
1032 struct urb *urb = etd->urb;
886 u32 etd_mask = 1 << etd_num; 1033 u32 etd_mask = 1 << etd_num;
887 struct urb_priv *urb_priv = urb->hcpriv; 1034 struct urb_priv *urb_priv = urb->hcpriv;
888 int dir; 1035 int dir;
889 u16 xbufaddr;
890 int cc; 1036 int cc;
891 u32 bytes_xfrd; 1037 u32 bytes_xfrd;
892 int etd_done; 1038 int etd_done;
@@ -894,7 +1040,6 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
894 disactivate_etd(imx21, etd_num); 1040 disactivate_etd(imx21, etd_num);
895 1041
896 dir = (etd_readl(imx21, etd_num, 0) >> DW0_DIRECT) & 0x3; 1042 dir = (etd_readl(imx21, etd_num, 0) >> DW0_DIRECT) & 0x3;
897 xbufaddr = etd_readl(imx21, etd_num, 1) & 0xffff;
898 cc = (etd_readl(imx21, etd_num, 2) >> DW2_COMPCODE) & 0xf; 1043 cc = (etd_readl(imx21, etd_num, 2) >> DW2_COMPCODE) & 0xf;
899 bytes_xfrd = etd->len - (etd_readl(imx21, etd_num, 3) & 0x1fffff); 1044 bytes_xfrd = etd->len - (etd_readl(imx21, etd_num, 3) & 0x1fffff);
900 1045
@@ -906,8 +1051,21 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
906 if (dir == TD_DIR_IN) { 1051 if (dir == TD_DIR_IN) {
907 clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask); 1052 clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
908 clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask); 1053 clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask);
1054
1055 if (etd->bounce_buffer) {
1056 memcpy(etd->cpu_buffer, etd->bounce_buffer, bytes_xfrd);
1057 dma_unmap_single(imx21->dev,
1058 etd->dma_handle, etd->len, DMA_FROM_DEVICE);
1059 } else if (!etd->dma_handle && bytes_xfrd) {/* PIO */
1060 memcpy_fromio(etd->cpu_buffer,
1061 imx21->regs + USBOTG_DMEM + etd->dmem_offset,
1062 bytes_xfrd);
1063 }
909 } 1064 }
910 free_dmem(imx21, xbufaddr); 1065
1066 kfree(etd->bounce_buffer);
1067 etd->bounce_buffer = NULL;
1068 free_dmem(imx21, etd);
911 1069
912 urb->error_count = 0; 1070 urb->error_count = 0;
913 if (!(urb->transfer_flags & URB_SHORT_NOT_OK) 1071 if (!(urb->transfer_flags & URB_SHORT_NOT_OK)
@@ -964,24 +1122,15 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
964 break; 1122 break;
965 } 1123 }
966 1124
967 if (!etd_done) { 1125 if (etd_done)
1126 nonisoc_urb_completed_for_etd(imx21, etd, cc_to_error[cc]);
1127 else {
968 dev_vdbg(imx21->dev, "next state=%d\n", urb_priv->state); 1128 dev_vdbg(imx21->dev, "next state=%d\n", urb_priv->state);
969 schedule_nonisoc_etd(imx21, urb); 1129 schedule_nonisoc_etd(imx21, urb);
970 } else {
971 struct usb_host_endpoint *ep = urb->ep;
972
973 urb_done(hcd, urb, cc_to_error[cc]);
974 etd->urb = NULL;
975
976 if (!list_empty(&ep->urb_list)) {
977 urb = list_first_entry(&ep->urb_list,
978 struct urb, urb_list);
979 dev_vdbg(imx21->dev, "next URB %p\n", urb);
980 schedule_nonisoc_etd(imx21, urb);
981 }
982 } 1130 }
983} 1131}
984 1132
1133
985static struct ep_priv *alloc_ep(void) 1134static struct ep_priv *alloc_ep(void)
986{ 1135{
987 int i; 1136 int i;
@@ -1007,7 +1156,6 @@ static int imx21_hc_urb_enqueue(struct usb_hcd *hcd,
1007 struct etd_priv *etd; 1156 struct etd_priv *etd;
1008 int ret; 1157 int ret;
1009 unsigned long flags; 1158 unsigned long flags;
1010 int new_ep = 0;
1011 1159
1012 dev_vdbg(imx21->dev, 1160 dev_vdbg(imx21->dev,
1013 "enqueue urb=%p ep=%p len=%d " 1161 "enqueue urb=%p ep=%p len=%d "
@@ -1035,7 +1183,6 @@ static int imx21_hc_urb_enqueue(struct usb_hcd *hcd,
1035 } 1183 }
1036 ep->hcpriv = ep_priv; 1184 ep->hcpriv = ep_priv;
1037 ep_priv->ep = ep; 1185 ep_priv->ep = ep;
1038 new_ep = 1;
1039 } 1186 }
1040 1187
1041 ret = usb_hcd_link_urb_to_ep(hcd, urb); 1188 ret = usb_hcd_link_urb_to_ep(hcd, urb);
@@ -1124,9 +1271,13 @@ static int imx21_hc_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
1124 } else if (urb_priv->active) { 1271 } else if (urb_priv->active) {
1125 int etd_num = ep_priv->etd[0]; 1272 int etd_num = ep_priv->etd[0];
1126 if (etd_num != -1) { 1273 if (etd_num != -1) {
1274 struct etd_priv *etd = &imx21->etd[etd_num];
1275
1127 disactivate_etd(imx21, etd_num); 1276 disactivate_etd(imx21, etd_num);
1128 free_dmem(imx21, etd_readl(imx21, etd_num, 1) & 0xffff); 1277 free_dmem(imx21, etd);
1129 imx21->etd[etd_num].urb = NULL; 1278 etd->urb = NULL;
1279 kfree(etd->bounce_buffer);
1280 etd->bounce_buffer = NULL;
1130 } 1281 }
1131 } 1282 }
1132 1283
@@ -1226,9 +1377,9 @@ static void process_etds(struct usb_hcd *hcd, struct imx21 *imx21, int sof)
1226 } 1377 }
1227 1378
1228 if (usb_pipeisoc(etd->urb->pipe)) 1379 if (usb_pipeisoc(etd->urb->pipe))
1229 isoc_etd_done(hcd, etd->urb, etd_num); 1380 isoc_etd_done(hcd, etd_num);
1230 else 1381 else
1231 nonisoc_etd_done(hcd, etd->urb, etd_num); 1382 nonisoc_etd_done(hcd, etd_num);
1232 } 1383 }
1233 1384
1234 /* only enable SOF interrupt if it may be needed for the kludge */ 1385 /* only enable SOF interrupt if it may be needed for the kludge */
@@ -1696,6 +1847,7 @@ static int imx21_probe(struct platform_device *pdev)
1696 } 1847 }
1697 1848
1698 imx21 = hcd_to_imx21(hcd); 1849 imx21 = hcd_to_imx21(hcd);
1850 imx21->hcd = hcd;
1699 imx21->dev = &pdev->dev; 1851 imx21->dev = &pdev->dev;
1700 imx21->pdata = pdev->dev.platform_data; 1852 imx21->pdata = pdev->dev.platform_data;
1701 if (!imx21->pdata) 1853 if (!imx21->pdata)
@@ -1754,7 +1906,7 @@ failed_clock_set:
1754failed_clock_get: 1906failed_clock_get:
1755 iounmap(imx21->regs); 1907 iounmap(imx21->regs);
1756failed_ioremap: 1908failed_ioremap:
1757 release_mem_region(res->start, res->end - res->start); 1909 release_mem_region(res->start, resource_size(res));
1758failed_request_mem: 1910failed_request_mem:
1759 remove_debug_files(imx21); 1911 remove_debug_files(imx21);
1760 usb_put_hcd(hcd); 1912 usb_put_hcd(hcd);
diff --git a/drivers/usb/host/imx21-hcd.h b/drivers/usb/host/imx21-hcd.h
index 1b0d913780a5..87b29fd971b4 100644
--- a/drivers/usb/host/imx21-hcd.h
+++ b/drivers/usb/host/imx21-hcd.h
@@ -250,6 +250,7 @@
250#define USBCTRL_USB_BYP (1 << 2) 250#define USBCTRL_USB_BYP (1 << 2)
251#define USBCTRL_HOST1_TXEN_OE (1 << 1) 251#define USBCTRL_HOST1_TXEN_OE (1 << 1)
252 252
253#define USBOTG_DMEM 0x1000
253 254
254/* Values in TD blocks */ 255/* Values in TD blocks */
255#define TD_DIR_SETUP 0 256#define TD_DIR_SETUP 0
@@ -346,8 +347,8 @@ struct td {
346 struct list_head list; 347 struct list_head list;
347 struct urb *urb; 348 struct urb *urb;
348 struct usb_host_endpoint *ep; 349 struct usb_host_endpoint *ep;
349 dma_addr_t data; 350 dma_addr_t dma_handle;
350 unsigned long buf_addr; 351 void *cpu_buffer;
351 int len; 352 int len;
352 int frame; 353 int frame;
353 int isoc_index; 354 int isoc_index;
@@ -360,6 +361,8 @@ struct etd_priv {
360 struct td *td; 361 struct td *td;
361 struct list_head queue; 362 struct list_head queue;
362 dma_addr_t dma_handle; 363 dma_addr_t dma_handle;
364 void *cpu_buffer;
365 void *bounce_buffer;
363 int alloc; 366 int alloc;
364 int len; 367 int len;
365 int dmem_size; 368 int dmem_size;
@@ -412,6 +415,7 @@ struct debug_isoc_trace {
412struct imx21 { 415struct imx21 {
413 spinlock_t lock; 416 spinlock_t lock;
414 struct device *dev; 417 struct device *dev;
418 struct usb_hcd *hcd;
415 struct mx21_usbh_platform_data *pdata; 419 struct mx21_usbh_platform_data *pdata;
416 struct list_head dmem_list; 420 struct list_head dmem_list;
417 struct list_head queue_for_etd; /* eps queued due to etd shortage */ 421 struct list_head queue_for_etd; /* eps queued due to etd shortage */
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index d9e82123de2a..0da7fc05f453 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1557,8 +1557,6 @@ static int isp116x_remove(struct platform_device *pdev)
1557 return 0; 1557 return 0;
1558} 1558}
1559 1559
1560#define resource_len(r) (((r)->end - (r)->start) + 1)
1561
1562static int __devinit isp116x_probe(struct platform_device *pdev) 1560static int __devinit isp116x_probe(struct platform_device *pdev)
1563{ 1561{
1564 struct usb_hcd *hcd; 1562 struct usb_hcd *hcd;
@@ -1597,7 +1595,7 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
1597 ret = -EBUSY; 1595 ret = -EBUSY;
1598 goto err1; 1596 goto err1;
1599 } 1597 }
1600 addr_reg = ioremap(addr->start, resource_len(addr)); 1598 addr_reg = ioremap(addr->start, resource_size(addr));
1601 if (addr_reg == NULL) { 1599 if (addr_reg == NULL) {
1602 ret = -ENOMEM; 1600 ret = -ENOMEM;
1603 goto err2; 1601 goto err2;
@@ -1606,7 +1604,7 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
1606 ret = -EBUSY; 1604 ret = -EBUSY;
1607 goto err3; 1605 goto err3;
1608 } 1606 }
1609 data_reg = ioremap(data->start, resource_len(data)); 1607 data_reg = ioremap(data->start, resource_size(data));
1610 if (data_reg == NULL) { 1608 if (data_reg == NULL) {
1611 ret = -ENOMEM; 1609 ret = -ENOMEM;
1612 goto err4; 1610 goto err4;
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 0587ad4ce5c2..8196fa11fec4 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -1676,13 +1676,6 @@ static int isp1362_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1676 switch (wValue) { 1676 switch (wValue) {
1677 case USB_PORT_FEAT_SUSPEND: 1677 case USB_PORT_FEAT_SUSPEND:
1678 _DBG(0, "USB_PORT_FEAT_SUSPEND\n"); 1678 _DBG(0, "USB_PORT_FEAT_SUSPEND\n");
1679#ifdef CONFIG_USB_OTG
1680 if (ohci->hcd.self.otg_port == (wIndex + 1) &&
1681 ohci->hcd.self.b_hnp_enable) {
1682 start_hnp(ohci);
1683 break;
1684 }
1685#endif
1686 spin_lock_irqsave(&isp1362_hcd->lock, flags); 1679 spin_lock_irqsave(&isp1362_hcd->lock, flags);
1687 isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + wIndex, RH_PS_PSS); 1680 isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + wIndex, RH_PS_PSS);
1688 isp1362_hcd->rhport[wIndex] = 1681 isp1362_hcd->rhport[wIndex] =
@@ -2656,8 +2649,6 @@ static struct hc_driver isp1362_hc_driver = {
2656 2649
2657/*-------------------------------------------------------------------------*/ 2650/*-------------------------------------------------------------------------*/
2658 2651
2659#define resource_len(r) (((r)->end - (r)->start) + 1)
2660
2661static int __devexit isp1362_remove(struct platform_device *pdev) 2652static int __devexit isp1362_remove(struct platform_device *pdev)
2662{ 2653{
2663 struct usb_hcd *hcd = platform_get_drvdata(pdev); 2654 struct usb_hcd *hcd = platform_get_drvdata(pdev);
@@ -2679,12 +2670,12 @@ static int __devexit isp1362_remove(struct platform_device *pdev)
2679 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2670 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
2680 DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start); 2671 DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start);
2681 if (res) 2672 if (res)
2682 release_mem_region(res->start, resource_len(res)); 2673 release_mem_region(res->start, resource_size(res));
2683 2674
2684 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2675 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2685 DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start); 2676 DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start);
2686 if (res) 2677 if (res)
2687 release_mem_region(res->start, resource_len(res)); 2678 release_mem_region(res->start, resource_size(res));
2688 2679
2689 DBG(0, "%s: put_hcd\n", __func__); 2680 DBG(0, "%s: put_hcd\n", __func__);
2690 usb_put_hcd(hcd); 2681 usb_put_hcd(hcd);
@@ -2730,21 +2721,21 @@ static int __init isp1362_probe(struct platform_device *pdev)
2730 goto err1; 2721 goto err1;
2731 } 2722 }
2732 2723
2733 if (!request_mem_region(addr->start, resource_len(addr), hcd_name)) { 2724 if (!request_mem_region(addr->start, resource_size(addr), hcd_name)) {
2734 retval = -EBUSY; 2725 retval = -EBUSY;
2735 goto err1; 2726 goto err1;
2736 } 2727 }
2737 addr_reg = ioremap(addr->start, resource_len(addr)); 2728 addr_reg = ioremap(addr->start, resource_size(addr));
2738 if (addr_reg == NULL) { 2729 if (addr_reg == NULL) {
2739 retval = -ENOMEM; 2730 retval = -ENOMEM;
2740 goto err2; 2731 goto err2;
2741 } 2732 }
2742 2733
2743 if (!request_mem_region(data->start, resource_len(data), hcd_name)) { 2734 if (!request_mem_region(data->start, resource_size(data), hcd_name)) {
2744 retval = -EBUSY; 2735 retval = -EBUSY;
2745 goto err3; 2736 goto err3;
2746 } 2737 }
2747 data_reg = ioremap(data->start, resource_len(data)); 2738 data_reg = ioremap(data->start, resource_size(data));
2748 if (data_reg == NULL) { 2739 if (data_reg == NULL) {
2749 retval = -ENOMEM; 2740 retval = -ENOMEM;
2750 goto err4; 2741 goto err4;
@@ -2802,13 +2793,13 @@ static int __init isp1362_probe(struct platform_device *pdev)
2802 iounmap(data_reg); 2793 iounmap(data_reg);
2803 err4: 2794 err4:
2804 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)data->start); 2795 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)data->start);
2805 release_mem_region(data->start, resource_len(data)); 2796 release_mem_region(data->start, resource_size(data));
2806 err3: 2797 err3:
2807 DBG(0, "%s: Unmapping addr_reg @ %p\n", __func__, addr_reg); 2798 DBG(0, "%s: Unmapping addr_reg @ %p\n", __func__, addr_reg);
2808 iounmap(addr_reg); 2799 iounmap(addr_reg);
2809 err2: 2800 err2:
2810 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)addr->start); 2801 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)addr->start);
2811 release_mem_region(addr->start, resource_len(addr)); 2802 release_mem_region(addr->start, resource_size(addr));
2812 err1: 2803 err1:
2813 pr_err("%s: init error, %d\n", __func__, retval); 2804 pr_err("%s: init error, %d\n", __func__, retval);
2814 2805
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index c3b4ccc7337b..3b5785032a10 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -398,7 +398,14 @@ ohci_shutdown (struct usb_hcd *hcd)
398 398
399 ohci = hcd_to_ohci (hcd); 399 ohci = hcd_to_ohci (hcd);
400 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); 400 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
401 ohci_usb_reset (ohci); 401 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
402
403 /* If the SHUTDOWN quirk is set, don't put the controller in RESET */
404 ohci->hc_control &= (ohci->flags & OHCI_QUIRK_SHUTDOWN ?
405 OHCI_CTRL_RWC | OHCI_CTRL_HCFS :
406 OHCI_CTRL_RWC);
407 ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
408
402 /* flush the writes */ 409 /* flush the writes */
403 (void) ohci_readl (ohci, &ohci->regs->control); 410 (void) ohci_readl (ohci, &ohci->regs->control);
404} 411}
@@ -1270,6 +1277,9 @@ static void __exit ohci_hcd_mod_exit(void)
1270#ifdef PLATFORM_DRIVER 1277#ifdef PLATFORM_DRIVER
1271 platform_driver_unregister(&PLATFORM_DRIVER); 1278 platform_driver_unregister(&PLATFORM_DRIVER);
1272#endif 1279#endif
1280#ifdef OMAP3_PLATFORM_DRIVER
1281 platform_driver_unregister(&OMAP3_PLATFORM_DRIVER);
1282#endif
1273#ifdef PS3_SYSTEM_BUS_DRIVER 1283#ifdef PS3_SYSTEM_BUS_DRIVER
1274 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1284 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1275#endif 1285#endif
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 6bdc8b25a6a1..36ee9a666e93 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -201,6 +201,20 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
201 return 0; 201 return 0;
202} 202}
203 203
204/* nVidia controllers continue to drive Reset signalling on the bus
205 * even after system shutdown, wasting power. This flag tells the
206 * shutdown routine to leave the controller OPERATIONAL instead of RESET.
207 */
208static int ohci_quirk_nvidia_shutdown(struct usb_hcd *hcd)
209{
210 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
211
212 ohci->flags |= OHCI_QUIRK_SHUTDOWN;
213 ohci_dbg(ohci, "enabled nVidia shutdown quirk\n");
214
215 return 0;
216}
217
204/* 218/*
205 * The hardware normally enables the A-link power management feature, which 219 * The hardware normally enables the A-link power management feature, which
206 * lets the system lower the power consumption in idle states. 220 * lets the system lower the power consumption in idle states.
@@ -332,6 +346,10 @@ static const struct pci_device_id ohci_pci_quirks[] = {
332 PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399), 346 PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399),
333 .driver_data = (unsigned long)ohci_quirk_amd700, 347 .driver_data = (unsigned long)ohci_quirk_amd700,
334 }, 348 },
349 {
350 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
351 .driver_data = (unsigned long) ohci_quirk_nvidia_shutdown,
352 },
335 353
336 /* FIXME for some of the early AMD 760 southbridges, OHCI 354 /* FIXME for some of the early AMD 760 southbridges, OHCI
337 * won't work at all. blacklist them. 355 * won't work at all. blacklist them.
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c
index 60f03cc7ec4f..0b35d22cc70e 100644
--- a/drivers/usb/host/ohci-sh.c
+++ b/drivers/usb/host/ohci-sh.c
@@ -77,7 +77,6 @@ static const struct hc_driver ohci_sh_hc_driver = {
77 77
78/*-------------------------------------------------------------------------*/ 78/*-------------------------------------------------------------------------*/
79 79
80#define resource_len(r) (((r)->end - (r)->start) + 1)
81static int ohci_hcd_sh_probe(struct platform_device *pdev) 80static int ohci_hcd_sh_probe(struct platform_device *pdev)
82{ 81{
83 struct resource *res = NULL; 82 struct resource *res = NULL;
@@ -109,7 +108,7 @@ static int ohci_hcd_sh_probe(struct platform_device *pdev)
109 108
110 hcd->regs = (void __iomem *)res->start; 109 hcd->regs = (void __iomem *)res->start;
111 hcd->rsrc_start = res->start; 110 hcd->rsrc_start = res->start;
112 hcd->rsrc_len = resource_len(res); 111 hcd->rsrc_len = resource_size(res);
113 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); 112 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
114 if (ret != 0) { 113 if (ret != 0) {
115 err("Failed to add hcd"); 114 err("Failed to add hcd");
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index cff23637cfcc..041d30f30c10 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -168,7 +168,7 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
168 168
169 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); 169 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
170 if (retval) 170 if (retval)
171 goto err4; 171 goto err5;
172 172
173 /* enable power and unmask interrupts */ 173 /* enable power and unmask interrupts */
174 174
@@ -176,6 +176,8 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
176 sm501_modify_reg(dev->parent, SM501_IRQ_MASK, 1 << 6, 0); 176 sm501_modify_reg(dev->parent, SM501_IRQ_MASK, 1 << 6, 0);
177 177
178 return 0; 178 return 0;
179err5:
180 iounmap(hcd->regs);
179err4: 181err4:
180 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 182 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
181err3: 183err3:
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index 5bf15fed0d9f..51facb985c84 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -403,6 +403,7 @@ struct ohci_hcd {
403#define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */ 403#define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */
404#define OHCI_QUIRK_AMD_ISO 0x200 /* ISO transfers*/ 404#define OHCI_QUIRK_AMD_ISO 0x200 /* ISO transfers*/
405#define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */ 405#define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */
406#define OHCI_QUIRK_SHUTDOWN 0x800 /* nVidia power bug */
406 // there are also chip quirks/bugs in init logic 407 // there are also chip quirks/bugs in init logic
407 408
408 struct work_struct nec_work; /* Worker for NEC quirk */ 409 struct work_struct nec_work; /* Worker for NEC quirk */
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index d9c85a292737..d32c3eae99cb 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -3696,7 +3696,7 @@ static void oxu_configuration(struct platform_device *pdev, void *base)
3696static int oxu_verify_id(struct platform_device *pdev, void *base) 3696static int oxu_verify_id(struct platform_device *pdev, void *base)
3697{ 3697{
3698 u32 id; 3698 u32 id;
3699 char *bo[] = { 3699 static const char * const bo[] = {
3700 "reserved", 3700 "reserved",
3701 "128-pin LQFP", 3701 "128-pin LQFP",
3702 "84-pin TFBGA", 3702 "84-pin TFBGA",
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 83b5f9cea85a..464ed977b45d 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -169,6 +169,7 @@ static int __devinit mmio_resource_enabled(struct pci_dev *pdev, int idx)
169static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) 169static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
170{ 170{
171 void __iomem *base; 171 void __iomem *base;
172 u32 control;
172 173
173 if (!mmio_resource_enabled(pdev, 0)) 174 if (!mmio_resource_enabled(pdev, 0))
174 return; 175 return;
@@ -177,10 +178,14 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
177 if (base == NULL) 178 if (base == NULL)
178 return; 179 return;
179 180
181 control = readl(base + OHCI_CONTROL);
182
180/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ 183/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
181#ifndef __hppa__ 184#ifdef __hppa__
182{ 185#define OHCI_CTRL_MASK (OHCI_CTRL_RWC | OHCI_CTRL_IR)
183 u32 control = readl(base + OHCI_CONTROL); 186#else
187#define OHCI_CTRL_MASK OHCI_CTRL_RWC
188
184 if (control & OHCI_CTRL_IR) { 189 if (control & OHCI_CTRL_IR) {
185 int wait_time = 500; /* arbitrary; 5 seconds */ 190 int wait_time = 500; /* arbitrary; 5 seconds */
186 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE); 191 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
@@ -194,13 +199,12 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
194 dev_warn(&pdev->dev, "OHCI: BIOS handoff failed" 199 dev_warn(&pdev->dev, "OHCI: BIOS handoff failed"
195 " (BIOS bug?) %08x\n", 200 " (BIOS bug?) %08x\n",
196 readl(base + OHCI_CONTROL)); 201 readl(base + OHCI_CONTROL));
197
198 /* reset controller, preserving RWC */
199 writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL);
200 } 202 }
201}
202#endif 203#endif
203 204
205 /* reset controller, preserving RWC (and possibly IR) */
206 writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);
207
204 /* 208 /*
205 * disable interrupts 209 * disable interrupts
206 */ 210 */
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index 95d0f5adfdcf..25563e9a90bc 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -227,7 +227,7 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
227 int odd = len & 0x0001; 227 int odd = len & 0x0001;
228 228
229 len = len / 2; 229 len = len / 2;
230 ioread16_rep(fifoaddr, buf, len); 230 iowrite16_rep(fifoaddr, buf, len);
231 if (unlikely(odd)) { 231 if (unlikely(odd)) {
232 buf = &buf[len]; 232 buf = &buf[len];
233 iowrite8((unsigned char)*buf, fifoaddr); 233 iowrite8((unsigned char)*buf, fifoaddr);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index d3ade4018487..2090b45eb606 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -917,10 +917,13 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
917 unsigned long destination, status; 917 unsigned long destination, status;
918 int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize); 918 int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize);
919 int len = urb->transfer_buffer_length; 919 int len = urb->transfer_buffer_length;
920 dma_addr_t data = urb->transfer_dma; 920 int this_sg_len;
921 dma_addr_t data;
921 __le32 *plink; 922 __le32 *plink;
922 struct urb_priv *urbp = urb->hcpriv; 923 struct urb_priv *urbp = urb->hcpriv;
923 unsigned int toggle; 924 unsigned int toggle;
925 struct scatterlist *sg;
926 int i;
924 927
925 if (len < 0) 928 if (len < 0)
926 return -EINVAL; 929 return -EINVAL;
@@ -937,12 +940,26 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
937 if (usb_pipein(urb->pipe)) 940 if (usb_pipein(urb->pipe))
938 status |= TD_CTRL_SPD; 941 status |= TD_CTRL_SPD;
939 942
943 i = urb->num_sgs;
944 if (len > 0 && i > 0) {
945 sg = urb->sg;
946 data = sg_dma_address(sg);
947
948 /* urb->transfer_buffer_length may be smaller than the
949 * size of the scatterlist (or vice versa)
950 */
951 this_sg_len = min_t(int, sg_dma_len(sg), len);
952 } else {
953 sg = NULL;
954 data = urb->transfer_dma;
955 this_sg_len = len;
956 }
940 /* 957 /*
941 * Build the DATA TDs 958 * Build the DATA TDs
942 */ 959 */
943 plink = NULL; 960 plink = NULL;
944 td = qh->dummy_td; 961 td = qh->dummy_td;
945 do { /* Allow zero length packets */ 962 for (;;) { /* Allow zero length packets */
946 int pktsze = maxsze; 963 int pktsze = maxsze;
947 964
948 if (len <= pktsze) { /* The last packet */ 965 if (len <= pktsze) { /* The last packet */
@@ -965,10 +982,18 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
965 plink = &td->link; 982 plink = &td->link;
966 status |= TD_CTRL_ACTIVE; 983 status |= TD_CTRL_ACTIVE;
967 984
985 toggle ^= 1;
968 data += pktsze; 986 data += pktsze;
987 this_sg_len -= pktsze;
969 len -= maxsze; 988 len -= maxsze;
970 toggle ^= 1; 989 if (this_sg_len <= 0) {
971 } while (len > 0); 990 if (--i <= 0 || len <= 0)
991 break;
992 sg = sg_next(sg);
993 data = sg_dma_address(sg);
994 this_sg_len = min_t(int, sg_dma_len(sg), len);
995 }
996 }
972 997
973 /* 998 /*
974 * URB_ZERO_PACKET means adding a 0-length packet, if direction 999 * URB_ZERO_PACKET means adding a 0-length packet, if direction
diff --git a/drivers/usb/host/whci/Kbuild b/drivers/usb/host/whci/Kbuild
index 11e5040b8337..26df0138079e 100644
--- a/drivers/usb/host/whci/Kbuild
+++ b/drivers/usb/host/whci/Kbuild
@@ -3,7 +3,7 @@ obj-$(CONFIG_USB_WHCI_HCD) += whci-hcd.o
3whci-hcd-y := \ 3whci-hcd-y := \
4 asl.o \ 4 asl.o \
5 debug.o \ 5 debug.o \
6 hcd.o \ 6 hcd.o \
7 hw.o \ 7 hw.o \
8 init.o \ 8 init.o \
9 int.o \ 9 int.o \
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a1a7a9795536..fef5a1f9d483 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -24,6 +24,10 @@
24 24
25#include "xhci.h" 25#include "xhci.h"
26 26
27#define PORT_WAKE_BITS (PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E)
28#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \
29 PORT_RC | PORT_PLC | PORT_PE)
30
27static void xhci_hub_descriptor(struct xhci_hcd *xhci, 31static void xhci_hub_descriptor(struct xhci_hcd *xhci,
28 struct usb_hub_descriptor *desc) 32 struct usb_hub_descriptor *desc)
29{ 33{
@@ -123,12 +127,105 @@ static unsigned int xhci_port_speed(unsigned int port_status)
123 * writing a 0 clears the bit and writing a 1 sets the bit (RWS). 127 * writing a 0 clears the bit and writing a 1 sets the bit (RWS).
124 * For all other types (RW1S, RW1CS, RW, and RZ), writing a '0' has no effect. 128 * For all other types (RW1S, RW1CS, RW, and RZ), writing a '0' has no effect.
125 */ 129 */
126static u32 xhci_port_state_to_neutral(u32 state) 130u32 xhci_port_state_to_neutral(u32 state)
127{ 131{
128 /* Save read-only status and port state */ 132 /* Save read-only status and port state */
129 return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS); 133 return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS);
130} 134}
131 135
136/*
137 * find slot id based on port number.
138 */
139int xhci_find_slot_id_by_port(struct xhci_hcd *xhci, u16 port)
140{
141 int slot_id;
142 int i;
143
144 slot_id = 0;
145 for (i = 0; i < MAX_HC_SLOTS; i++) {
146 if (!xhci->devs[i])
147 continue;
148 if (xhci->devs[i]->port == port) {
149 slot_id = i;
150 break;
151 }
152 }
153
154 return slot_id;
155}
156
157/*
158 * Stop device
159 * It issues stop endpoint command for EP 0 to 30. And wait the last command
160 * to complete.
161 * suspend will set to 1, if suspend bit need to set in command.
162 */
163static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
164{
165 struct xhci_virt_device *virt_dev;
166 struct xhci_command *cmd;
167 unsigned long flags;
168 int timeleft;
169 int ret;
170 int i;
171
172 ret = 0;
173 virt_dev = xhci->devs[slot_id];
174 cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO);
175 if (!cmd) {
176 xhci_dbg(xhci, "Couldn't allocate command structure.\n");
177 return -ENOMEM;
178 }
179
180 spin_lock_irqsave(&xhci->lock, flags);
181 for (i = LAST_EP_INDEX; i > 0; i--) {
182 if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue)
183 xhci_queue_stop_endpoint(xhci, slot_id, i, suspend);
184 }
185 cmd->command_trb = xhci->cmd_ring->enqueue;
186 list_add_tail(&cmd->cmd_list, &virt_dev->cmd_list);
187 xhci_queue_stop_endpoint(xhci, slot_id, 0, suspend);
188 xhci_ring_cmd_db(xhci);
189 spin_unlock_irqrestore(&xhci->lock, flags);
190
191 /* Wait for last stop endpoint command to finish */
192 timeleft = wait_for_completion_interruptible_timeout(
193 cmd->completion,
194 USB_CTRL_SET_TIMEOUT);
195 if (timeleft <= 0) {
196 xhci_warn(xhci, "%s while waiting for stop endpoint command\n",
197 timeleft == 0 ? "Timeout" : "Signal");
198 spin_lock_irqsave(&xhci->lock, flags);
199 /* The timeout might have raced with the event ring handler, so
200 * only delete from the list if the item isn't poisoned.
201 */
202 if (cmd->cmd_list.next != LIST_POISON1)
203 list_del(&cmd->cmd_list);
204 spin_unlock_irqrestore(&xhci->lock, flags);
205 ret = -ETIME;
206 goto command_cleanup;
207 }
208
209command_cleanup:
210 xhci_free_command(xhci, cmd);
211 return ret;
212}
213
214/*
215 * Ring device, it rings the all doorbells unconditionally.
216 */
217void xhci_ring_device(struct xhci_hcd *xhci, int slot_id)
218{
219 int i;
220
221 for (i = 0; i < LAST_EP_INDEX + 1; i++)
222 if (xhci->devs[slot_id]->eps[i].ring &&
223 xhci->devs[slot_id]->eps[i].ring->dequeue)
224 xhci_ring_ep_doorbell(xhci, slot_id, i, 0);
225
226 return;
227}
228
132static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex, 229static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex,
133 u32 __iomem *addr, u32 port_status) 230 u32 __iomem *addr, u32 port_status)
134{ 231{
@@ -162,6 +259,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue,
162 status = PORT_PEC; 259 status = PORT_PEC;
163 port_change_bit = "enable/disable"; 260 port_change_bit = "enable/disable";
164 break; 261 break;
262 case USB_PORT_FEAT_C_SUSPEND:
263 status = PORT_PLC;
264 port_change_bit = "suspend/resume";
265 break;
165 default: 266 default:
166 /* Should never happen */ 267 /* Should never happen */
167 return; 268 return;
@@ -179,9 +280,10 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
179 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 280 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
180 int ports; 281 int ports;
181 unsigned long flags; 282 unsigned long flags;
182 u32 temp, status; 283 u32 temp, temp1, status;
183 int retval = 0; 284 int retval = 0;
184 u32 __iomem *addr; 285 u32 __iomem *addr;
286 int slot_id;
185 287
186 ports = HCS_MAX_PORTS(xhci->hcs_params1); 288 ports = HCS_MAX_PORTS(xhci->hcs_params1);
187 289
@@ -211,9 +313,49 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
211 if ((temp & PORT_OCC)) 313 if ((temp & PORT_OCC))
212 status |= USB_PORT_STAT_C_OVERCURRENT << 16; 314 status |= USB_PORT_STAT_C_OVERCURRENT << 16;
213 /* 315 /*
214 * FIXME ignoring suspend, reset, and USB 2.1/3.0 specific 316 * FIXME ignoring reset and USB 2.1/3.0 specific
215 * changes 317 * changes
216 */ 318 */
319 if ((temp & PORT_PLS_MASK) == XDEV_U3
320 && (temp & PORT_POWER))
321 status |= 1 << USB_PORT_FEAT_SUSPEND;
322 if ((temp & PORT_PLS_MASK) == XDEV_RESUME) {
323 if ((temp & PORT_RESET) || !(temp & PORT_PE))
324 goto error;
325 if (!DEV_SUPERSPEED(temp) && time_after_eq(jiffies,
326 xhci->resume_done[wIndex])) {
327 xhci_dbg(xhci, "Resume USB2 port %d\n",
328 wIndex + 1);
329 xhci->resume_done[wIndex] = 0;
330 temp1 = xhci_port_state_to_neutral(temp);
331 temp1 &= ~PORT_PLS_MASK;
332 temp1 |= PORT_LINK_STROBE | XDEV_U0;
333 xhci_writel(xhci, temp1, addr);
334
335 xhci_dbg(xhci, "set port %d resume\n",
336 wIndex + 1);
337 slot_id = xhci_find_slot_id_by_port(xhci,
338 wIndex + 1);
339 if (!slot_id) {
340 xhci_dbg(xhci, "slot_id is zero\n");
341 goto error;
342 }
343 xhci_ring_device(xhci, slot_id);
344 xhci->port_c_suspend[wIndex >> 5] |=
345 1 << (wIndex & 31);
346 xhci->suspended_ports[wIndex >> 5] &=
347 ~(1 << (wIndex & 31));
348 }
349 }
350 if ((temp & PORT_PLS_MASK) == XDEV_U0
351 && (temp & PORT_POWER)
352 && (xhci->suspended_ports[wIndex >> 5] &
353 (1 << (wIndex & 31)))) {
354 xhci->suspended_ports[wIndex >> 5] &=
355 ~(1 << (wIndex & 31));
356 xhci->port_c_suspend[wIndex >> 5] |=
357 1 << (wIndex & 31);
358 }
217 if (temp & PORT_CONNECT) { 359 if (temp & PORT_CONNECT) {
218 status |= USB_PORT_STAT_CONNECTION; 360 status |= USB_PORT_STAT_CONNECTION;
219 status |= xhci_port_speed(temp); 361 status |= xhci_port_speed(temp);
@@ -226,6 +368,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
226 status |= USB_PORT_STAT_RESET; 368 status |= USB_PORT_STAT_RESET;
227 if (temp & PORT_POWER) 369 if (temp & PORT_POWER)
228 status |= USB_PORT_STAT_POWER; 370 status |= USB_PORT_STAT_POWER;
371 if (xhci->port_c_suspend[wIndex >> 5] & (1 << (wIndex & 31)))
372 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
229 xhci_dbg(xhci, "Get port status returned 0x%x\n", status); 373 xhci_dbg(xhci, "Get port status returned 0x%x\n", status);
230 put_unaligned(cpu_to_le32(status), (__le32 *) buf); 374 put_unaligned(cpu_to_le32(status), (__le32 *) buf);
231 break; 375 break;
@@ -238,6 +382,42 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
238 temp = xhci_readl(xhci, addr); 382 temp = xhci_readl(xhci, addr);
239 temp = xhci_port_state_to_neutral(temp); 383 temp = xhci_port_state_to_neutral(temp);
240 switch (wValue) { 384 switch (wValue) {
385 case USB_PORT_FEAT_SUSPEND:
386 temp = xhci_readl(xhci, addr);
387 /* In spec software should not attempt to suspend
388 * a port unless the port reports that it is in the
389 * enabled (PED = ‘1’,PLS < ‘3’) state.
390 */
391 if ((temp & PORT_PE) == 0 || (temp & PORT_RESET)
392 || (temp & PORT_PLS_MASK) >= XDEV_U3) {
393 xhci_warn(xhci, "USB core suspending device "
394 "not in U0/U1/U2.\n");
395 goto error;
396 }
397
398 slot_id = xhci_find_slot_id_by_port(xhci, wIndex + 1);
399 if (!slot_id) {
400 xhci_warn(xhci, "slot_id is zero\n");
401 goto error;
402 }
403 /* unlock to execute stop endpoint commands */
404 spin_unlock_irqrestore(&xhci->lock, flags);
405 xhci_stop_device(xhci, slot_id, 1);
406 spin_lock_irqsave(&xhci->lock, flags);
407
408 temp = xhci_port_state_to_neutral(temp);
409 temp &= ~PORT_PLS_MASK;
410 temp |= PORT_LINK_STROBE | XDEV_U3;
411 xhci_writel(xhci, temp, addr);
412
413 spin_unlock_irqrestore(&xhci->lock, flags);
414 msleep(10); /* wait device to enter */
415 spin_lock_irqsave(&xhci->lock, flags);
416
417 temp = xhci_readl(xhci, addr);
418 xhci->suspended_ports[wIndex >> 5] |=
419 1 << (wIndex & (31));
420 break;
241 case USB_PORT_FEAT_POWER: 421 case USB_PORT_FEAT_POWER:
242 /* 422 /*
243 * Turn on ports, even if there isn't per-port switching. 423 * Turn on ports, even if there isn't per-port switching.
@@ -271,6 +451,52 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
271 temp = xhci_readl(xhci, addr); 451 temp = xhci_readl(xhci, addr);
272 temp = xhci_port_state_to_neutral(temp); 452 temp = xhci_port_state_to_neutral(temp);
273 switch (wValue) { 453 switch (wValue) {
454 case USB_PORT_FEAT_SUSPEND:
455 temp = xhci_readl(xhci, addr);
456 xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n");
457 xhci_dbg(xhci, "PORTSC %04x\n", temp);
458 if (temp & PORT_RESET)
459 goto error;
460 if (temp & XDEV_U3) {
461 if ((temp & PORT_PE) == 0)
462 goto error;
463 if (DEV_SUPERSPEED(temp)) {
464 temp = xhci_port_state_to_neutral(temp);
465 temp &= ~PORT_PLS_MASK;
466 temp |= PORT_LINK_STROBE | XDEV_U0;
467 xhci_writel(xhci, temp, addr);
468 xhci_readl(xhci, addr);
469 } else {
470 temp = xhci_port_state_to_neutral(temp);
471 temp &= ~PORT_PLS_MASK;
472 temp |= PORT_LINK_STROBE | XDEV_RESUME;
473 xhci_writel(xhci, temp, addr);
474
475 spin_unlock_irqrestore(&xhci->lock,
476 flags);
477 msleep(20);
478 spin_lock_irqsave(&xhci->lock, flags);
479
480 temp = xhci_readl(xhci, addr);
481 temp = xhci_port_state_to_neutral(temp);
482 temp &= ~PORT_PLS_MASK;
483 temp |= PORT_LINK_STROBE | XDEV_U0;
484 xhci_writel(xhci, temp, addr);
485 }
486 xhci->port_c_suspend[wIndex >> 5] |=
487 1 << (wIndex & 31);
488 }
489
490 slot_id = xhci_find_slot_id_by_port(xhci, wIndex + 1);
491 if (!slot_id) {
492 xhci_dbg(xhci, "slot_id is zero\n");
493 goto error;
494 }
495 xhci_ring_device(xhci, slot_id);
496 break;
497 case USB_PORT_FEAT_C_SUSPEND:
498 xhci->port_c_suspend[wIndex >> 5] &=
499 ~(1 << (wIndex & 31));
274 case USB_PORT_FEAT_C_RESET: 500 case USB_PORT_FEAT_C_RESET:
275 case USB_PORT_FEAT_C_CONNECTION: 501 case USB_PORT_FEAT_C_CONNECTION:
276 case USB_PORT_FEAT_C_OVER_CURRENT: 502 case USB_PORT_FEAT_C_OVER_CURRENT:
@@ -306,6 +532,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
306{ 532{
307 unsigned long flags; 533 unsigned long flags;
308 u32 temp, status; 534 u32 temp, status;
535 u32 mask;
309 int i, retval; 536 int i, retval;
310 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 537 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
311 int ports; 538 int ports;
@@ -318,13 +545,18 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
318 memset(buf, 0, retval); 545 memset(buf, 0, retval);
319 status = 0; 546 status = 0;
320 547
548 mask = PORT_CSC | PORT_PEC | PORT_OCC;
549
321 spin_lock_irqsave(&xhci->lock, flags); 550 spin_lock_irqsave(&xhci->lock, flags);
322 /* For each port, did anything change? If so, set that bit in buf. */ 551 /* For each port, did anything change? If so, set that bit in buf. */
323 for (i = 0; i < ports; i++) { 552 for (i = 0; i < ports; i++) {
324 addr = &xhci->op_regs->port_status_base + 553 addr = &xhci->op_regs->port_status_base +
325 NUM_PORT_REGS*i; 554 NUM_PORT_REGS*i;
326 temp = xhci_readl(xhci, addr); 555 temp = xhci_readl(xhci, addr);
327 if (temp & (PORT_CSC | PORT_PEC | PORT_OCC)) { 556 if ((temp & mask) != 0 ||
557 (xhci->port_c_suspend[i >> 5] & 1 << (i & 31)) ||
558 (xhci->resume_done[i] && time_after_eq(
559 jiffies, xhci->resume_done[i]))) {
328 buf[(i + 1) / 8] |= 1 << (i + 1) % 8; 560 buf[(i + 1) / 8] |= 1 << (i + 1) % 8;
329 status = 1; 561 status = 1;
330 } 562 }
@@ -332,3 +564,182 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
332 spin_unlock_irqrestore(&xhci->lock, flags); 564 spin_unlock_irqrestore(&xhci->lock, flags);
333 return status ? retval : 0; 565 return status ? retval : 0;
334} 566}
567
568#ifdef CONFIG_PM
569
570int xhci_bus_suspend(struct usb_hcd *hcd)
571{
572 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
573 int port;
574 unsigned long flags;
575
576 xhci_dbg(xhci, "suspend root hub\n");
577
578 spin_lock_irqsave(&xhci->lock, flags);
579
580 if (hcd->self.root_hub->do_remote_wakeup) {
581 port = HCS_MAX_PORTS(xhci->hcs_params1);
582 while (port--) {
583 if (xhci->resume_done[port] != 0) {
584 spin_unlock_irqrestore(&xhci->lock, flags);
585 xhci_dbg(xhci, "suspend failed because "
586 "port %d is resuming\n",
587 port + 1);
588 return -EBUSY;
589 }
590 }
591 }
592
593 port = HCS_MAX_PORTS(xhci->hcs_params1);
594 xhci->bus_suspended = 0;
595 while (port--) {
596 /* suspend the port if the port is not suspended */
597 u32 __iomem *addr;
598 u32 t1, t2;
599 int slot_id;
600
601 addr = &xhci->op_regs->port_status_base +
602 NUM_PORT_REGS * (port & 0xff);
603 t1 = xhci_readl(xhci, addr);
604 t2 = xhci_port_state_to_neutral(t1);
605
606 if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) {
607 xhci_dbg(xhci, "port %d not suspended\n", port);
608 slot_id = xhci_find_slot_id_by_port(xhci, port + 1);
609 if (slot_id) {
610 spin_unlock_irqrestore(&xhci->lock, flags);
611 xhci_stop_device(xhci, slot_id, 1);
612 spin_lock_irqsave(&xhci->lock, flags);
613 }
614 t2 &= ~PORT_PLS_MASK;
615 t2 |= PORT_LINK_STROBE | XDEV_U3;
616 set_bit(port, &xhci->bus_suspended);
617 }
618 if (hcd->self.root_hub->do_remote_wakeup) {
619 if (t1 & PORT_CONNECT) {
620 t2 |= PORT_WKOC_E | PORT_WKDISC_E;
621 t2 &= ~PORT_WKCONN_E;
622 } else {
623 t2 |= PORT_WKOC_E | PORT_WKCONN_E;
624 t2 &= ~PORT_WKDISC_E;
625 }
626 } else
627 t2 &= ~PORT_WAKE_BITS;
628
629 t1 = xhci_port_state_to_neutral(t1);
630 if (t1 != t2)
631 xhci_writel(xhci, t2, addr);
632
633 if (DEV_HIGHSPEED(t1)) {
634 /* enable remote wake up for USB 2.0 */
635 u32 __iomem *addr;
636 u32 tmp;
637
638 addr = &xhci->op_regs->port_power_base +
639 NUM_PORT_REGS * (port & 0xff);
640 tmp = xhci_readl(xhci, addr);
641 tmp |= PORT_RWE;
642 xhci_writel(xhci, tmp, addr);
643 }
644 }
645 hcd->state = HC_STATE_SUSPENDED;
646 xhci->next_statechange = jiffies + msecs_to_jiffies(10);
647 spin_unlock_irqrestore(&xhci->lock, flags);
648 return 0;
649}
650
651int xhci_bus_resume(struct usb_hcd *hcd)
652{
653 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
654 int port;
655 u32 temp;
656 unsigned long flags;
657
658 xhci_dbg(xhci, "resume root hub\n");
659
660 if (time_before(jiffies, xhci->next_statechange))
661 msleep(5);
662
663 spin_lock_irqsave(&xhci->lock, flags);
664 if (!HCD_HW_ACCESSIBLE(hcd)) {
665 spin_unlock_irqrestore(&xhci->lock, flags);
666 return -ESHUTDOWN;
667 }
668
669 /* delay the irqs */
670 temp = xhci_readl(xhci, &xhci->op_regs->command);
671 temp &= ~CMD_EIE;
672 xhci_writel(xhci, temp, &xhci->op_regs->command);
673
674 port = HCS_MAX_PORTS(xhci->hcs_params1);
675 while (port--) {
676 /* Check whether need resume ports. If needed
677 resume port and disable remote wakeup */
678 u32 __iomem *addr;
679 u32 temp;
680 int slot_id;
681
682 addr = &xhci->op_regs->port_status_base +
683 NUM_PORT_REGS * (port & 0xff);
684 temp = xhci_readl(xhci, addr);
685 if (DEV_SUPERSPEED(temp))
686 temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
687 else
688 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
689 if (test_bit(port, &xhci->bus_suspended) &&
690 (temp & PORT_PLS_MASK)) {
691 if (DEV_SUPERSPEED(temp)) {
692 temp = xhci_port_state_to_neutral(temp);
693 temp &= ~PORT_PLS_MASK;
694 temp |= PORT_LINK_STROBE | XDEV_U0;
695 xhci_writel(xhci, temp, addr);
696 } else {
697 temp = xhci_port_state_to_neutral(temp);
698 temp &= ~PORT_PLS_MASK;
699 temp |= PORT_LINK_STROBE | XDEV_RESUME;
700 xhci_writel(xhci, temp, addr);
701
702 spin_unlock_irqrestore(&xhci->lock, flags);
703 msleep(20);
704 spin_lock_irqsave(&xhci->lock, flags);
705
706 temp = xhci_readl(xhci, addr);
707 temp = xhci_port_state_to_neutral(temp);
708 temp &= ~PORT_PLS_MASK;
709 temp |= PORT_LINK_STROBE | XDEV_U0;
710 xhci_writel(xhci, temp, addr);
711 }
712 slot_id = xhci_find_slot_id_by_port(xhci, port + 1);
713 if (slot_id)
714 xhci_ring_device(xhci, slot_id);
715 } else
716 xhci_writel(xhci, temp, addr);
717
718 if (DEV_HIGHSPEED(temp)) {
719 /* disable remote wake up for USB 2.0 */
720 u32 __iomem *addr;
721 u32 tmp;
722
723 addr = &xhci->op_regs->port_power_base +
724 NUM_PORT_REGS * (port & 0xff);
725 tmp = xhci_readl(xhci, addr);
726 tmp &= ~PORT_RWE;
727 xhci_writel(xhci, tmp, addr);
728 }
729 }
730
731 (void) xhci_readl(xhci, &xhci->op_regs->command);
732
733 xhci->next_statechange = jiffies + msecs_to_jiffies(5);
734 hcd->state = HC_STATE_RUNNING;
735 /* re-enable irqs */
736 temp = xhci_readl(xhci, &xhci->op_regs->command);
737 temp |= CMD_EIE;
738 xhci_writel(xhci, temp, &xhci->op_regs->command);
739 temp = xhci_readl(xhci, &xhci->op_regs->command);
740
741 spin_unlock_irqrestore(&xhci->lock, flags);
742 return 0;
743}
744
745#endif /* CONFIG_PM */
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 4e51343ddffc..202770676da3 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -778,6 +778,7 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
778 778
779 init_completion(&dev->cmd_completion); 779 init_completion(&dev->cmd_completion);
780 INIT_LIST_HEAD(&dev->cmd_list); 780 INIT_LIST_HEAD(&dev->cmd_list);
781 dev->udev = udev;
781 782
782 /* Point to output device context in dcbaa. */ 783 /* Point to output device context in dcbaa. */
783 xhci->dcbaa->dev_context_ptrs[slot_id] = dev->out_ctx->dma; 784 xhci->dcbaa->dev_context_ptrs[slot_id] = dev->out_ctx->dma;
@@ -866,6 +867,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
866 top_dev = top_dev->parent) 867 top_dev = top_dev->parent)
867 /* Found device below root hub */; 868 /* Found device below root hub */;
868 slot_ctx->dev_info2 |= (u32) ROOT_HUB_PORT(top_dev->portnum); 869 slot_ctx->dev_info2 |= (u32) ROOT_HUB_PORT(top_dev->portnum);
870 dev->port = top_dev->portnum;
869 xhci_dbg(xhci, "Set root hub portnum to %d\n", top_dev->portnum); 871 xhci_dbg(xhci, "Set root hub portnum to %d\n", top_dev->portnum);
870 872
871 /* Is this a LS/FS device under a HS hub? */ 873 /* Is this a LS/FS device under a HS hub? */
@@ -1443,6 +1445,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1443 scratchpad_free(xhci); 1445 scratchpad_free(xhci);
1444 xhci->page_size = 0; 1446 xhci->page_size = 0;
1445 xhci->page_shift = 0; 1447 xhci->page_shift = 0;
1448 xhci->bus_suspended = 0;
1446} 1449}
1447 1450
1448static int xhci_test_trb_in_td(struct xhci_hcd *xhci, 1451static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
@@ -1801,6 +1804,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
1801 init_completion(&xhci->addr_dev); 1804 init_completion(&xhci->addr_dev);
1802 for (i = 0; i < MAX_HC_SLOTS; ++i) 1805 for (i = 0; i < MAX_HC_SLOTS; ++i)
1803 xhci->devs[i] = NULL; 1806 xhci->devs[i] = NULL;
1807 for (i = 0; i < MAX_HC_PORTS; ++i)
1808 xhci->resume_done[i] = 0;
1804 1809
1805 if (scratchpad_alloc(xhci, flags)) 1810 if (scratchpad_alloc(xhci, flags))
1806 goto fail; 1811 goto fail;
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index f7efe025beda..bb668a894ab9 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -116,6 +116,30 @@ static int xhci_pci_setup(struct usb_hcd *hcd)
116 return xhci_pci_reinit(xhci, pdev); 116 return xhci_pci_reinit(xhci, pdev);
117} 117}
118 118
119#ifdef CONFIG_PM
120static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
121{
122 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
123 int retval = 0;
124
125 if (hcd->state != HC_STATE_SUSPENDED)
126 return -EINVAL;
127
128 retval = xhci_suspend(xhci);
129
130 return retval;
131}
132
133static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
134{
135 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
136 int retval = 0;
137
138 retval = xhci_resume(xhci, hibernated);
139 return retval;
140}
141#endif /* CONFIG_PM */
142
119static const struct hc_driver xhci_pci_hc_driver = { 143static const struct hc_driver xhci_pci_hc_driver = {
120 .description = hcd_name, 144 .description = hcd_name,
121 .product_desc = "xHCI Host Controller", 145 .product_desc = "xHCI Host Controller",
@@ -132,7 +156,10 @@ static const struct hc_driver xhci_pci_hc_driver = {
132 */ 156 */
133 .reset = xhci_pci_setup, 157 .reset = xhci_pci_setup,
134 .start = xhci_run, 158 .start = xhci_run,
135 /* suspend and resume implemented later */ 159#ifdef CONFIG_PM
160 .pci_suspend = xhci_pci_suspend,
161 .pci_resume = xhci_pci_resume,
162#endif
136 .stop = xhci_stop, 163 .stop = xhci_stop,
137 .shutdown = xhci_shutdown, 164 .shutdown = xhci_shutdown,
138 165
@@ -152,7 +179,7 @@ static const struct hc_driver xhci_pci_hc_driver = {
152 .reset_bandwidth = xhci_reset_bandwidth, 179 .reset_bandwidth = xhci_reset_bandwidth,
153 .address_device = xhci_address_device, 180 .address_device = xhci_address_device,
154 .update_hub_device = xhci_update_hub_device, 181 .update_hub_device = xhci_update_hub_device,
155 .reset_device = xhci_reset_device, 182 .reset_device = xhci_discover_or_reset_device,
156 183
157 /* 184 /*
158 * scheduling support 185 * scheduling support
@@ -162,6 +189,8 @@ static const struct hc_driver xhci_pci_hc_driver = {
162 /* Root hub support */ 189 /* Root hub support */
163 .hub_control = xhci_hub_control, 190 .hub_control = xhci_hub_control,
164 .hub_status_data = xhci_hub_status_data, 191 .hub_status_data = xhci_hub_status_data,
192 .bus_suspend = xhci_bus_suspend,
193 .bus_resume = xhci_bus_resume,
165}; 194};
166 195
167/*-------------------------------------------------------------------------*/ 196/*-------------------------------------------------------------------------*/
@@ -186,6 +215,11 @@ static struct pci_driver xhci_pci_driver = {
186 /* suspend and resume implemented later */ 215 /* suspend and resume implemented later */
187 216
188 .shutdown = usb_hcd_pci_shutdown, 217 .shutdown = usb_hcd_pci_shutdown,
218#ifdef CONFIG_PM_SLEEP
219 .driver = {
220 .pm = &usb_hcd_pci_pm_ops
221 },
222#endif
189}; 223};
190 224
191int xhci_register_pci(void) 225int xhci_register_pci(void)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 48e60d166ff0..9f3115e729b1 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -68,6 +68,10 @@
68#include <linux/slab.h> 68#include <linux/slab.h>
69#include "xhci.h" 69#include "xhci.h"
70 70
71static int handle_cmd_in_cmd_wait_list(struct xhci_hcd *xhci,
72 struct xhci_virt_device *virt_dev,
73 struct xhci_event_cmd *event);
74
71/* 75/*
72 * Returns zero if the TRB isn't in this segment, otherwise it returns the DMA 76 * Returns zero if the TRB isn't in this segment, otherwise it returns the DMA
73 * address of the TRB. 77 * address of the TRB.
@@ -313,7 +317,7 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci)
313 xhci_readl(xhci, &xhci->dba->doorbell[0]); 317 xhci_readl(xhci, &xhci->dba->doorbell[0]);
314} 318}
315 319
316static void ring_ep_doorbell(struct xhci_hcd *xhci, 320void xhci_ring_ep_doorbell(struct xhci_hcd *xhci,
317 unsigned int slot_id, 321 unsigned int slot_id,
318 unsigned int ep_index, 322 unsigned int ep_index,
319 unsigned int stream_id) 323 unsigned int stream_id)
@@ -353,7 +357,7 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
353 /* A ring has pending URBs if its TD list is not empty */ 357 /* A ring has pending URBs if its TD list is not empty */
354 if (!(ep->ep_state & EP_HAS_STREAMS)) { 358 if (!(ep->ep_state & EP_HAS_STREAMS)) {
355 if (!(list_empty(&ep->ring->td_list))) 359 if (!(list_empty(&ep->ring->td_list)))
356 ring_ep_doorbell(xhci, slot_id, ep_index, 0); 360 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, 0);
357 return; 361 return;
358 } 362 }
359 363
@@ -361,7 +365,8 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
361 stream_id++) { 365 stream_id++) {
362 struct xhci_stream_info *stream_info = ep->stream_info; 366 struct xhci_stream_info *stream_info = ep->stream_info;
363 if (!list_empty(&stream_info->stream_rings[stream_id]->td_list)) 367 if (!list_empty(&stream_info->stream_rings[stream_id]->td_list))
364 ring_ep_doorbell(xhci, slot_id, ep_index, stream_id); 368 xhci_ring_ep_doorbell(xhci, slot_id, ep_index,
369 stream_id);
365 } 370 }
366} 371}
367 372
@@ -626,10 +631,11 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
626 * bit cleared) so that the HW will skip over them. 631 * bit cleared) so that the HW will skip over them.
627 */ 632 */
628static void handle_stopped_endpoint(struct xhci_hcd *xhci, 633static void handle_stopped_endpoint(struct xhci_hcd *xhci,
629 union xhci_trb *trb) 634 union xhci_trb *trb, struct xhci_event_cmd *event)
630{ 635{
631 unsigned int slot_id; 636 unsigned int slot_id;
632 unsigned int ep_index; 637 unsigned int ep_index;
638 struct xhci_virt_device *virt_dev;
633 struct xhci_ring *ep_ring; 639 struct xhci_ring *ep_ring;
634 struct xhci_virt_ep *ep; 640 struct xhci_virt_ep *ep;
635 struct list_head *entry; 641 struct list_head *entry;
@@ -638,6 +644,21 @@ static void handle_stopped_endpoint(struct xhci_hcd *xhci,
638 644
639 struct xhci_dequeue_state deq_state; 645 struct xhci_dequeue_state deq_state;
640 646
647 if (unlikely(TRB_TO_SUSPEND_PORT(
648 xhci->cmd_ring->dequeue->generic.field[3]))) {
649 slot_id = TRB_TO_SLOT_ID(
650 xhci->cmd_ring->dequeue->generic.field[3]);
651 virt_dev = xhci->devs[slot_id];
652 if (virt_dev)
653 handle_cmd_in_cmd_wait_list(xhci, virt_dev,
654 event);
655 else
656 xhci_warn(xhci, "Stop endpoint command "
657 "completion for disabled slot %u\n",
658 slot_id);
659 return;
660 }
661
641 memset(&deq_state, 0, sizeof(deq_state)); 662 memset(&deq_state, 0, sizeof(deq_state));
642 slot_id = TRB_TO_SLOT_ID(trb->generic.field[3]); 663 slot_id = TRB_TO_SLOT_ID(trb->generic.field[3]);
643 ep_index = TRB_TO_EP_INDEX(trb->generic.field[3]); 664 ep_index = TRB_TO_EP_INDEX(trb->generic.field[3]);
@@ -1091,7 +1112,7 @@ bandwidth_change:
1091 complete(&xhci->addr_dev); 1112 complete(&xhci->addr_dev);
1092 break; 1113 break;
1093 case TRB_TYPE(TRB_STOP_RING): 1114 case TRB_TYPE(TRB_STOP_RING):
1094 handle_stopped_endpoint(xhci, xhci->cmd_ring->dequeue); 1115 handle_stopped_endpoint(xhci, xhci->cmd_ring->dequeue, event);
1095 break; 1116 break;
1096 case TRB_TYPE(TRB_SET_DEQ): 1117 case TRB_TYPE(TRB_SET_DEQ):
1097 handle_set_deq_completion(xhci, event, xhci->cmd_ring->dequeue); 1118 handle_set_deq_completion(xhci, event, xhci->cmd_ring->dequeue);
@@ -1144,17 +1165,72 @@ static void handle_vendor_event(struct xhci_hcd *xhci,
1144static void handle_port_status(struct xhci_hcd *xhci, 1165static void handle_port_status(struct xhci_hcd *xhci,
1145 union xhci_trb *event) 1166 union xhci_trb *event)
1146{ 1167{
1168 struct usb_hcd *hcd = xhci_to_hcd(xhci);
1147 u32 port_id; 1169 u32 port_id;
1170 u32 temp, temp1;
1171 u32 __iomem *addr;
1172 int ports;
1173 int slot_id;
1148 1174
1149 /* Port status change events always have a successful completion code */ 1175 /* Port status change events always have a successful completion code */
1150 if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) { 1176 if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) {
1151 xhci_warn(xhci, "WARN: xHC returned failed port status event\n"); 1177 xhci_warn(xhci, "WARN: xHC returned failed port status event\n");
1152 xhci->error_bitmask |= 1 << 8; 1178 xhci->error_bitmask |= 1 << 8;
1153 } 1179 }
1154 /* FIXME: core doesn't care about all port link state changes yet */
1155 port_id = GET_PORT_ID(event->generic.field[0]); 1180 port_id = GET_PORT_ID(event->generic.field[0]);
1156 xhci_dbg(xhci, "Port Status Change Event for port %d\n", port_id); 1181 xhci_dbg(xhci, "Port Status Change Event for port %d\n", port_id);
1157 1182
1183 ports = HCS_MAX_PORTS(xhci->hcs_params1);
1184 if ((port_id <= 0) || (port_id > ports)) {
1185 xhci_warn(xhci, "Invalid port id %d\n", port_id);
1186 goto cleanup;
1187 }
1188
1189 addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS * (port_id - 1);
1190 temp = xhci_readl(xhci, addr);
1191 if ((temp & PORT_CONNECT) && (hcd->state == HC_STATE_SUSPENDED)) {
1192 xhci_dbg(xhci, "resume root hub\n");
1193 usb_hcd_resume_root_hub(hcd);
1194 }
1195
1196 if ((temp & PORT_PLC) && (temp & PORT_PLS_MASK) == XDEV_RESUME) {
1197 xhci_dbg(xhci, "port resume event for port %d\n", port_id);
1198
1199 temp1 = xhci_readl(xhci, &xhci->op_regs->command);
1200 if (!(temp1 & CMD_RUN)) {
1201 xhci_warn(xhci, "xHC is not running.\n");
1202 goto cleanup;
1203 }
1204
1205 if (DEV_SUPERSPEED(temp)) {
1206 xhci_dbg(xhci, "resume SS port %d\n", port_id);
1207 temp = xhci_port_state_to_neutral(temp);
1208 temp &= ~PORT_PLS_MASK;
1209 temp |= PORT_LINK_STROBE | XDEV_U0;
1210 xhci_writel(xhci, temp, addr);
1211 slot_id = xhci_find_slot_id_by_port(xhci, port_id);
1212 if (!slot_id) {
1213 xhci_dbg(xhci, "slot_id is zero\n");
1214 goto cleanup;
1215 }
1216 xhci_ring_device(xhci, slot_id);
1217 xhci_dbg(xhci, "resume SS port %d finished\n", port_id);
1218 /* Clear PORT_PLC */
1219 temp = xhci_readl(xhci, addr);
1220 temp = xhci_port_state_to_neutral(temp);
1221 temp |= PORT_PLC;
1222 xhci_writel(xhci, temp, addr);
1223 } else {
1224 xhci_dbg(xhci, "resume HS port %d\n", port_id);
1225 xhci->resume_done[port_id - 1] = jiffies +
1226 msecs_to_jiffies(20);
1227 mod_timer(&hcd->rh_timer,
1228 xhci->resume_done[port_id - 1]);
1229 /* Do the rest in GetPortStatus */
1230 }
1231 }
1232
1233cleanup:
1158 /* Update event ring dequeue pointer before dropping the lock */ 1234 /* Update event ring dequeue pointer before dropping the lock */
1159 inc_deq(xhci, xhci->event_ring, true); 1235 inc_deq(xhci, xhci->event_ring, true);
1160 1236
@@ -2347,7 +2423,7 @@ static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id,
2347 */ 2423 */
2348 wmb(); 2424 wmb();
2349 start_trb->field[3] |= start_cycle; 2425 start_trb->field[3] |= start_cycle;
2350 ring_ep_doorbell(xhci, slot_id, ep_index, stream_id); 2426 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);
2351} 2427}
2352 2428
2353/* 2429/*
@@ -2931,7 +3007,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2931 wmb(); 3007 wmb();
2932 start_trb->field[3] |= start_cycle; 3008 start_trb->field[3] |= start_cycle;
2933 3009
2934 ring_ep_doorbell(xhci, slot_id, ep_index, urb->stream_id); 3010 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, urb->stream_id);
2935 return 0; 3011 return 0;
2936} 3012}
2937 3013
@@ -3108,15 +3184,20 @@ int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
3108 false); 3184 false);
3109} 3185}
3110 3186
3187/*
3188 * Suspend is set to indicate "Stop Endpoint Command" is being issued to stop
3189 * activity on an endpoint that is about to be suspended.
3190 */
3111int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id, 3191int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
3112 unsigned int ep_index) 3192 unsigned int ep_index, int suspend)
3113{ 3193{
3114 u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id); 3194 u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id);
3115 u32 trb_ep_index = EP_ID_FOR_TRB(ep_index); 3195 u32 trb_ep_index = EP_ID_FOR_TRB(ep_index);
3116 u32 type = TRB_TYPE(TRB_STOP_RING); 3196 u32 type = TRB_TYPE(TRB_STOP_RING);
3197 u32 trb_suspend = SUSPEND_PORT_FOR_TRB(suspend);
3117 3198
3118 return queue_command(xhci, 0, 0, 0, 3199 return queue_command(xhci, 0, 0, 0,
3119 trb_slot_id | trb_ep_index | type, false); 3200 trb_slot_id | trb_ep_index | type | trb_suspend, false);
3120} 3201}
3121 3202
3122/* Set Transfer Ring Dequeue Pointer command. 3203/* Set Transfer Ring Dequeue Pointer command.
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d5c550ea3e68..5d7d4e951ea4 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -551,6 +551,218 @@ void xhci_shutdown(struct usb_hcd *hcd)
551 xhci_readl(xhci, &xhci->op_regs->status)); 551 xhci_readl(xhci, &xhci->op_regs->status));
552} 552}
553 553
554#ifdef CONFIG_PM
555static void xhci_save_registers(struct xhci_hcd *xhci)
556{
557 xhci->s3.command = xhci_readl(xhci, &xhci->op_regs->command);
558 xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification);
559 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
560 xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg);
561 xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
562 xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control);
563 xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size);
564 xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base);
565 xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
566}
567
568static void xhci_restore_registers(struct xhci_hcd *xhci)
569{
570 xhci_writel(xhci, xhci->s3.command, &xhci->op_regs->command);
571 xhci_writel(xhci, xhci->s3.dev_nt, &xhci->op_regs->dev_notification);
572 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr);
573 xhci_writel(xhci, xhci->s3.config_reg, &xhci->op_regs->config_reg);
574 xhci_writel(xhci, xhci->s3.irq_pending, &xhci->ir_set->irq_pending);
575 xhci_writel(xhci, xhci->s3.irq_control, &xhci->ir_set->irq_control);
576 xhci_writel(xhci, xhci->s3.erst_size, &xhci->ir_set->erst_size);
577 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base);
578}
579
580/*
581 * Stop HC (not bus-specific)
582 *
583 * This is called when the machine transition into S3/S4 mode.
584 *
585 */
586int xhci_suspend(struct xhci_hcd *xhci)
587{
588 int rc = 0;
589 struct usb_hcd *hcd = xhci_to_hcd(xhci);
590 u32 command;
591
592 spin_lock_irq(&xhci->lock);
593 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
594 /* step 1: stop endpoint */
595 /* skipped assuming that port suspend has done */
596
597 /* step 2: clear Run/Stop bit */
598 command = xhci_readl(xhci, &xhci->op_regs->command);
599 command &= ~CMD_RUN;
600 xhci_writel(xhci, command, &xhci->op_regs->command);
601 if (handshake(xhci, &xhci->op_regs->status,
602 STS_HALT, STS_HALT, 100*100)) {
603 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n");
604 spin_unlock_irq(&xhci->lock);
605 return -ETIMEDOUT;
606 }
607
608 /* step 3: save registers */
609 xhci_save_registers(xhci);
610
611 /* step 4: set CSS flag */
612 command = xhci_readl(xhci, &xhci->op_regs->command);
613 command |= CMD_CSS;
614 xhci_writel(xhci, command, &xhci->op_regs->command);
615 if (handshake(xhci, &xhci->op_regs->status, STS_SAVE, 0, 10*100)) {
616 xhci_warn(xhci, "WARN: xHC CMD_CSS timeout\n");
617 spin_unlock_irq(&xhci->lock);
618 return -ETIMEDOUT;
619 }
620 /* step 5: remove core well power */
621 xhci_cleanup_msix(xhci);
622 spin_unlock_irq(&xhci->lock);
623
624 return rc;
625}
626
627/*
628 * start xHC (not bus-specific)
629 *
630 * This is called when the machine transition from S3/S4 mode.
631 *
632 */
633int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
634{
635 u32 command, temp = 0;
636 struct usb_hcd *hcd = xhci_to_hcd(xhci);
637 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
638 u64 val_64;
639 int old_state, retval;
640
641 old_state = hcd->state;
642 if (time_before(jiffies, xhci->next_statechange))
643 msleep(100);
644
645 spin_lock_irq(&xhci->lock);
646
647 if (!hibernated) {
648 /* step 1: restore register */
649 xhci_restore_registers(xhci);
650 /* step 2: initialize command ring buffer */
651 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
652 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) |
653 (xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
654 xhci->cmd_ring->dequeue) &
655 (u64) ~CMD_RING_RSVD_BITS) |
656 xhci->cmd_ring->cycle_state;
657 xhci_dbg(xhci, "// Setting command ring address to 0x%llx\n",
658 (long unsigned long) val_64);
659 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring);
660 /* step 3: restore state and start state*/
661 /* step 3: set CRS flag */
662 command = xhci_readl(xhci, &xhci->op_regs->command);
663 command |= CMD_CRS;
664 xhci_writel(xhci, command, &xhci->op_regs->command);
665 if (handshake(xhci, &xhci->op_regs->status,
666 STS_RESTORE, 0, 10*100)) {
667 xhci_dbg(xhci, "WARN: xHC CMD_CSS timeout\n");
668 spin_unlock_irq(&xhci->lock);
669 return -ETIMEDOUT;
670 }
671 temp = xhci_readl(xhci, &xhci->op_regs->status);
672 }
673
674 /* If restore operation fails, re-initialize the HC during resume */
675 if ((temp & STS_SRE) || hibernated) {
676 usb_root_hub_lost_power(hcd->self.root_hub);
677
678 xhci_dbg(xhci, "Stop HCD\n");
679 xhci_halt(xhci);
680 xhci_reset(xhci);
681 if (hibernated)
682 xhci_cleanup_msix(xhci);
683 spin_unlock_irq(&xhci->lock);
684
685#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
686 /* Tell the event ring poll function not to reschedule */
687 xhci->zombie = 1;
688 del_timer_sync(&xhci->event_ring_timer);
689#endif
690
691 xhci_dbg(xhci, "// Disabling event ring interrupts\n");
692 temp = xhci_readl(xhci, &xhci->op_regs->status);
693 xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
694 temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
695 xhci_writel(xhci, ER_IRQ_DISABLE(temp),
696 &xhci->ir_set->irq_pending);
697 xhci_print_ir_set(xhci, xhci->ir_set, 0);
698
699 xhci_dbg(xhci, "cleaning up memory\n");
700 xhci_mem_cleanup(xhci);
701 xhci_dbg(xhci, "xhci_stop completed - status = %x\n",
702 xhci_readl(xhci, &xhci->op_regs->status));
703
704 xhci_dbg(xhci, "Initialize the HCD\n");
705 retval = xhci_init(hcd);
706 if (retval)
707 return retval;
708
709 xhci_dbg(xhci, "Start the HCD\n");
710 retval = xhci_run(hcd);
711 if (!retval)
712 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
713 hcd->state = HC_STATE_SUSPENDED;
714 return retval;
715 }
716
717 /* Re-setup MSI-X */
718 if (hcd->irq)
719 free_irq(hcd->irq, hcd);
720 hcd->irq = -1;
721
722 retval = xhci_setup_msix(xhci);
723 if (retval)
724 /* fall back to msi*/
725 retval = xhci_setup_msi(xhci);
726
727 if (retval) {
728 /* fall back to legacy interrupt*/
729 retval = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED,
730 hcd->irq_descr, hcd);
731 if (retval) {
732 xhci_err(xhci, "request interrupt %d failed\n",
733 pdev->irq);
734 return retval;
735 }
736 hcd->irq = pdev->irq;
737 }
738
739 /* step 4: set Run/Stop bit */
740 command = xhci_readl(xhci, &xhci->op_regs->command);
741 command |= CMD_RUN;
742 xhci_writel(xhci, command, &xhci->op_regs->command);
743 handshake(xhci, &xhci->op_regs->status, STS_HALT,
744 0, 250 * 1000);
745
746 /* step 5: walk topology and initialize portsc,
747 * portpmsc and portli
748 */
749 /* this is done in bus_resume */
750
751 /* step 6: restart each of the previously
752 * Running endpoints by ringing their doorbells
753 */
754
755 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
756 if (!hibernated)
757 hcd->state = old_state;
758 else
759 hcd->state = HC_STATE_SUSPENDED;
760
761 spin_unlock_irq(&xhci->lock);
762 return 0;
763}
764#endif /* CONFIG_PM */
765
554/*-------------------------------------------------------------------------*/ 766/*-------------------------------------------------------------------------*/
555 767
556/** 768/**
@@ -607,7 +819,11 @@ unsigned int xhci_last_valid_endpoint(u32 added_ctxs)
607 * returns 0 this is a root hub; returns -EINVAL for NULL pointers. 819 * returns 0 this is a root hub; returns -EINVAL for NULL pointers.
608 */ 820 */
609int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev, 821int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
610 struct usb_host_endpoint *ep, int check_ep, const char *func) { 822 struct usb_host_endpoint *ep, int check_ep, bool check_virt_dev,
823 const char *func) {
824 struct xhci_hcd *xhci;
825 struct xhci_virt_device *virt_dev;
826
611 if (!hcd || (check_ep && !ep) || !udev) { 827 if (!hcd || (check_ep && !ep) || !udev) {
612 printk(KERN_DEBUG "xHCI %s called with invalid args\n", 828 printk(KERN_DEBUG "xHCI %s called with invalid args\n",
613 func); 829 func);
@@ -618,11 +834,24 @@ int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
618 func); 834 func);
619 return 0; 835 return 0;
620 } 836 }
621 if (!udev->slot_id) { 837
622 printk(KERN_DEBUG "xHCI %s called with unaddressed device\n", 838 if (check_virt_dev) {
623 func); 839 xhci = hcd_to_xhci(hcd);
624 return -EINVAL; 840 if (!udev->slot_id || !xhci->devs
841 || !xhci->devs[udev->slot_id]) {
842 printk(KERN_DEBUG "xHCI %s called with unaddressed "
843 "device\n", func);
844 return -EINVAL;
845 }
846
847 virt_dev = xhci->devs[udev->slot_id];
848 if (virt_dev->udev != udev) {
849 printk(KERN_DEBUG "xHCI %s called with udev and "
850 "virt_dev does not match\n", func);
851 return -EINVAL;
852 }
625 } 853 }
854
626 return 1; 855 return 1;
627} 856}
628 857
@@ -704,18 +933,13 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
704 struct urb_priv *urb_priv; 933 struct urb_priv *urb_priv;
705 int size, i; 934 int size, i;
706 935
707 if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0) 936 if (!urb || xhci_check_args(hcd, urb->dev, urb->ep,
937 true, true, __func__) <= 0)
708 return -EINVAL; 938 return -EINVAL;
709 939
710 slot_id = urb->dev->slot_id; 940 slot_id = urb->dev->slot_id;
711 ep_index = xhci_get_endpoint_index(&urb->ep->desc); 941 ep_index = xhci_get_endpoint_index(&urb->ep->desc);
712 942
713 if (!xhci->devs || !xhci->devs[slot_id]) {
714 if (!in_interrupt())
715 dev_warn(&urb->dev->dev, "WARN: urb submitted for dev with no Slot ID\n");
716 ret = -EINVAL;
717 goto exit;
718 }
719 if (!HCD_HW_ACCESSIBLE(hcd)) { 943 if (!HCD_HW_ACCESSIBLE(hcd)) {
720 if (!in_interrupt()) 944 if (!in_interrupt())
721 xhci_dbg(xhci, "urb submitted during PCI suspend\n"); 945 xhci_dbg(xhci, "urb submitted during PCI suspend\n");
@@ -956,7 +1180,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
956 ep->stop_cmd_timer.expires = jiffies + 1180 ep->stop_cmd_timer.expires = jiffies +
957 XHCI_STOP_EP_CMD_TIMEOUT * HZ; 1181 XHCI_STOP_EP_CMD_TIMEOUT * HZ;
958 add_timer(&ep->stop_cmd_timer); 1182 add_timer(&ep->stop_cmd_timer);
959 xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index); 1183 xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index, 0);
960 xhci_ring_cmd_db(xhci); 1184 xhci_ring_cmd_db(xhci);
961 } 1185 }
962done: 1186done:
@@ -991,7 +1215,7 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
991 u32 new_add_flags, new_drop_flags, new_slot_info; 1215 u32 new_add_flags, new_drop_flags, new_slot_info;
992 int ret; 1216 int ret;
993 1217
994 ret = xhci_check_args(hcd, udev, ep, 1, __func__); 1218 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
995 if (ret <= 0) 1219 if (ret <= 0)
996 return ret; 1220 return ret;
997 xhci = hcd_to_xhci(hcd); 1221 xhci = hcd_to_xhci(hcd);
@@ -1004,12 +1228,6 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1004 return 0; 1228 return 0;
1005 } 1229 }
1006 1230
1007 if (!xhci->devs || !xhci->devs[udev->slot_id]) {
1008 xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
1009 __func__);
1010 return -EINVAL;
1011 }
1012
1013 in_ctx = xhci->devs[udev->slot_id]->in_ctx; 1231 in_ctx = xhci->devs[udev->slot_id]->in_ctx;
1014 out_ctx = xhci->devs[udev->slot_id]->out_ctx; 1232 out_ctx = xhci->devs[udev->slot_id]->out_ctx;
1015 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 1233 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
@@ -1078,7 +1296,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1078 u32 new_add_flags, new_drop_flags, new_slot_info; 1296 u32 new_add_flags, new_drop_flags, new_slot_info;
1079 int ret = 0; 1297 int ret = 0;
1080 1298
1081 ret = xhci_check_args(hcd, udev, ep, 1, __func__); 1299 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
1082 if (ret <= 0) { 1300 if (ret <= 0) {
1083 /* So we won't queue a reset ep command for a root hub */ 1301 /* So we won't queue a reset ep command for a root hub */
1084 ep->hcpriv = NULL; 1302 ep->hcpriv = NULL;
@@ -1098,12 +1316,6 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1098 return 0; 1316 return 0;
1099 } 1317 }
1100 1318
1101 if (!xhci->devs || !xhci->devs[udev->slot_id]) {
1102 xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
1103 __func__);
1104 return -EINVAL;
1105 }
1106
1107 in_ctx = xhci->devs[udev->slot_id]->in_ctx; 1319 in_ctx = xhci->devs[udev->slot_id]->in_ctx;
1108 out_ctx = xhci->devs[udev->slot_id]->out_ctx; 1320 out_ctx = xhci->devs[udev->slot_id]->out_ctx;
1109 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 1321 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
@@ -1346,16 +1558,11 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
1346 struct xhci_input_control_ctx *ctrl_ctx; 1558 struct xhci_input_control_ctx *ctrl_ctx;
1347 struct xhci_slot_ctx *slot_ctx; 1559 struct xhci_slot_ctx *slot_ctx;
1348 1560
1349 ret = xhci_check_args(hcd, udev, NULL, 0, __func__); 1561 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
1350 if (ret <= 0) 1562 if (ret <= 0)
1351 return ret; 1563 return ret;
1352 xhci = hcd_to_xhci(hcd); 1564 xhci = hcd_to_xhci(hcd);
1353 1565
1354 if (!udev->slot_id || !xhci->devs || !xhci->devs[udev->slot_id]) {
1355 xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
1356 __func__);
1357 return -EINVAL;
1358 }
1359 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); 1566 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
1360 virt_dev = xhci->devs[udev->slot_id]; 1567 virt_dev = xhci->devs[udev->slot_id];
1361 1568
@@ -1405,16 +1612,11 @@ void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
1405 struct xhci_virt_device *virt_dev; 1612 struct xhci_virt_device *virt_dev;
1406 int i, ret; 1613 int i, ret;
1407 1614
1408 ret = xhci_check_args(hcd, udev, NULL, 0, __func__); 1615 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
1409 if (ret <= 0) 1616 if (ret <= 0)
1410 return; 1617 return;
1411 xhci = hcd_to_xhci(hcd); 1618 xhci = hcd_to_xhci(hcd);
1412 1619
1413 if (!xhci->devs || !xhci->devs[udev->slot_id]) {
1414 xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
1415 __func__);
1416 return;
1417 }
1418 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); 1620 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
1419 virt_dev = xhci->devs[udev->slot_id]; 1621 virt_dev = xhci->devs[udev->slot_id];
1420 /* Free any rings allocated for added endpoints */ 1622 /* Free any rings allocated for added endpoints */
@@ -1575,7 +1777,7 @@ static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
1575 1777
1576 if (!ep) 1778 if (!ep)
1577 return -EINVAL; 1779 return -EINVAL;
1578 ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, __func__); 1780 ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__);
1579 if (ret <= 0) 1781 if (ret <= 0)
1580 return -EINVAL; 1782 return -EINVAL;
1581 if (ep->ss_ep_comp.bmAttributes == 0) { 1783 if (ep->ss_ep_comp.bmAttributes == 0) {
@@ -1953,8 +2155,13 @@ int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
1953 * Wait for the Reset Device command to finish. Remove all structures 2155 * Wait for the Reset Device command to finish. Remove all structures
1954 * associated with the endpoints that were disabled. Clear the input device 2156 * associated with the endpoints that were disabled. Clear the input device
1955 * structure? Cache the rings? Reset the control endpoint 0 max packet size? 2157 * structure? Cache the rings? Reset the control endpoint 0 max packet size?
2158 *
2159 * If the virt_dev to be reset does not exist or does not match the udev,
2160 * it means the device is lost, possibly due to the xHC restore error and
2161 * re-initialization during S3/S4. In this case, call xhci_alloc_dev() to
2162 * re-allocate the device.
1956 */ 2163 */
1957int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev) 2164int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
1958{ 2165{
1959 int ret, i; 2166 int ret, i;
1960 unsigned long flags; 2167 unsigned long flags;
@@ -1965,16 +2172,35 @@ int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
1965 int timeleft; 2172 int timeleft;
1966 int last_freed_endpoint; 2173 int last_freed_endpoint;
1967 2174
1968 ret = xhci_check_args(hcd, udev, NULL, 0, __func__); 2175 ret = xhci_check_args(hcd, udev, NULL, 0, false, __func__);
1969 if (ret <= 0) 2176 if (ret <= 0)
1970 return ret; 2177 return ret;
1971 xhci = hcd_to_xhci(hcd); 2178 xhci = hcd_to_xhci(hcd);
1972 slot_id = udev->slot_id; 2179 slot_id = udev->slot_id;
1973 virt_dev = xhci->devs[slot_id]; 2180 virt_dev = xhci->devs[slot_id];
1974 if (!virt_dev) { 2181 if (!virt_dev) {
1975 xhci_dbg(xhci, "%s called with invalid slot ID %u\n", 2182 xhci_dbg(xhci, "The device to be reset with slot ID %u does "
1976 __func__, slot_id); 2183 "not exist. Re-allocate the device\n", slot_id);
1977 return -EINVAL; 2184 ret = xhci_alloc_dev(hcd, udev);
2185 if (ret == 1)
2186 return 0;
2187 else
2188 return -EINVAL;
2189 }
2190
2191 if (virt_dev->udev != udev) {
2192 /* If the virt_dev and the udev does not match, this virt_dev
2193 * may belong to another udev.
2194 * Re-allocate the device.
2195 */
2196 xhci_dbg(xhci, "The device to be reset with slot ID %u does "
2197 "not match the udev. Re-allocate the device\n",
2198 slot_id);
2199 ret = xhci_alloc_dev(hcd, udev);
2200 if (ret == 1)
2201 return 0;
2202 else
2203 return -EINVAL;
1978 } 2204 }
1979 2205
1980 xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id); 2206 xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id);
@@ -2077,13 +2303,13 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
2077 struct xhci_virt_device *virt_dev; 2303 struct xhci_virt_device *virt_dev;
2078 unsigned long flags; 2304 unsigned long flags;
2079 u32 state; 2305 u32 state;
2080 int i; 2306 int i, ret;
2081 2307
2082 if (udev->slot_id == 0) 2308 ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
2309 if (ret <= 0)
2083 return; 2310 return;
2311
2084 virt_dev = xhci->devs[udev->slot_id]; 2312 virt_dev = xhci->devs[udev->slot_id];
2085 if (!virt_dev)
2086 return;
2087 2313
2088 /* Stop any wayward timer functions (which may grab the lock) */ 2314 /* Stop any wayward timer functions (which may grab the lock) */
2089 for (i = 0; i < 31; ++i) { 2315 for (i = 0; i < 31; ++i) {
@@ -2191,12 +2417,17 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
2191 2417
2192 virt_dev = xhci->devs[udev->slot_id]; 2418 virt_dev = xhci->devs[udev->slot_id];
2193 2419
2194 /* If this is a Set Address to an unconfigured device, setup ep 0 */ 2420 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
2195 if (!udev->config) 2421 /*
2422 * If this is the first Set Address since device plug-in or
2423 * virt_device realloaction after a resume with an xHCI power loss,
2424 * then set up the slot context.
2425 */
2426 if (!slot_ctx->dev_info)
2196 xhci_setup_addressable_virt_dev(xhci, udev); 2427 xhci_setup_addressable_virt_dev(xhci, udev);
2428 /* Otherwise, update the control endpoint ring enqueue pointer. */
2197 else 2429 else
2198 xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev); 2430 xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev);
2199 /* Otherwise, assume the core has the device configured how it wants */
2200 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); 2431 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
2201 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); 2432 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
2202 2433
@@ -2268,15 +2499,15 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
2268 * address given back to us by the HC. 2499 * address given back to us by the HC.
2269 */ 2500 */
2270 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); 2501 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
2271 udev->devnum = (slot_ctx->dev_state & DEV_ADDR_MASK) + 1; 2502 /* Use kernel assigned address for devices; store xHC assigned
2503 * address locally. */
2504 virt_dev->address = (slot_ctx->dev_state & DEV_ADDR_MASK) + 1;
2272 /* Zero the input context control for later use */ 2505 /* Zero the input context control for later use */
2273 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); 2506 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
2274 ctrl_ctx->add_flags = 0; 2507 ctrl_ctx->add_flags = 0;
2275 ctrl_ctx->drop_flags = 0; 2508 ctrl_ctx->drop_flags = 0;
2276 2509
2277 xhci_dbg(xhci, "Device address = %d\n", udev->devnum); 2510 xhci_dbg(xhci, "Internal device address = %d\n", virt_dev->address);
2278 /* XXX Meh, not sure if anyone else but choose_address uses this. */
2279 set_bit(udev->devnum, udev->bus->devmap.devicemap);
2280 2511
2281 return 0; 2512 return 0;
2282} 2513}
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 34a60d9f056a..93d3bf4d213c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -191,7 +191,7 @@ struct xhci_op_regs {
191/* bits 4:6 are reserved (and should be preserved on writes). */ 191/* bits 4:6 are reserved (and should be preserved on writes). */
192/* light reset (port status stays unchanged) - reset completed when this is 0 */ 192/* light reset (port status stays unchanged) - reset completed when this is 0 */
193#define CMD_LRESET (1 << 7) 193#define CMD_LRESET (1 << 7)
194/* FIXME: ignoring host controller save/restore state for now. */ 194/* host controller save/restore state. */
195#define CMD_CSS (1 << 8) 195#define CMD_CSS (1 << 8)
196#define CMD_CRS (1 << 9) 196#define CMD_CRS (1 << 9)
197/* Enable Wrap Event - '1' means xHC generates an event when MFINDEX wraps. */ 197/* Enable Wrap Event - '1' means xHC generates an event when MFINDEX wraps. */
@@ -269,6 +269,10 @@ struct xhci_op_regs {
269 * A read gives the current link PM state of the port, 269 * A read gives the current link PM state of the port,
270 * a write with Link State Write Strobe set sets the link state. 270 * a write with Link State Write Strobe set sets the link state.
271 */ 271 */
272#define PORT_PLS_MASK (0xf << 5)
273#define XDEV_U0 (0x0 << 5)
274#define XDEV_U3 (0x3 << 5)
275#define XDEV_RESUME (0xf << 5)
272/* true: port has power (see HCC_PPC) */ 276/* true: port has power (see HCC_PPC) */
273#define PORT_POWER (1 << 9) 277#define PORT_POWER (1 << 9)
274/* bits 10:13 indicate device speed: 278/* bits 10:13 indicate device speed:
@@ -353,6 +357,8 @@ struct xhci_op_regs {
353#define PORT_U2_TIMEOUT(p) (((p) & 0xff) << 8) 357#define PORT_U2_TIMEOUT(p) (((p) & 0xff) << 8)
354/* Bits 24:31 for port testing */ 358/* Bits 24:31 for port testing */
355 359
360/* USB2 Protocol PORTSPMSC */
361#define PORT_RWE (1 << 0x3)
356 362
357/** 363/**
358 * struct xhci_intr_reg - Interrupt Register Set 364 * struct xhci_intr_reg - Interrupt Register Set
@@ -510,6 +516,7 @@ struct xhci_slot_ctx {
510#define MAX_EXIT (0xffff) 516#define MAX_EXIT (0xffff)
511/* Root hub port number that is needed to access the USB device */ 517/* Root hub port number that is needed to access the USB device */
512#define ROOT_HUB_PORT(p) (((p) & 0xff) << 16) 518#define ROOT_HUB_PORT(p) (((p) & 0xff) << 16)
519#define DEVINFO_TO_ROOT_HUB_PORT(p) (((p) >> 16) & 0xff)
513/* Maximum number of ports under a hub device */ 520/* Maximum number of ports under a hub device */
514#define XHCI_MAX_PORTS(p) (((p) & 0xff) << 24) 521#define XHCI_MAX_PORTS(p) (((p) & 0xff) << 24)
515 522
@@ -731,6 +738,7 @@ struct xhci_virt_ep {
731}; 738};
732 739
733struct xhci_virt_device { 740struct xhci_virt_device {
741 struct usb_device *udev;
734 /* 742 /*
735 * Commands to the hardware are passed an "input context" that 743 * Commands to the hardware are passed an "input context" that
736 * tells the hardware what to change in its data structures. 744 * tells the hardware what to change in its data structures.
@@ -745,12 +753,15 @@ struct xhci_virt_device {
745 /* Rings saved to ensure old alt settings can be re-instated */ 753 /* Rings saved to ensure old alt settings can be re-instated */
746 struct xhci_ring **ring_cache; 754 struct xhci_ring **ring_cache;
747 int num_rings_cached; 755 int num_rings_cached;
756 /* Store xHC assigned device address */
757 int address;
748#define XHCI_MAX_RINGS_CACHED 31 758#define XHCI_MAX_RINGS_CACHED 31
749 struct xhci_virt_ep eps[31]; 759 struct xhci_virt_ep eps[31];
750 struct completion cmd_completion; 760 struct completion cmd_completion;
751 /* Status of the last command issued for this device */ 761 /* Status of the last command issued for this device */
752 u32 cmd_status; 762 u32 cmd_status;
753 struct list_head cmd_list; 763 struct list_head cmd_list;
764 u8 port;
754}; 765};
755 766
756 767
@@ -881,6 +892,10 @@ struct xhci_event_cmd {
881#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1) 892#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1)
882#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16) 893#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16)
883 894
895#define SUSPEND_PORT_FOR_TRB(p) (((p) & 1) << 23)
896#define TRB_TO_SUSPEND_PORT(p) (((p) & (1 << 23)) >> 23)
897#define LAST_EP_INDEX 30
898
884/* Set TR Dequeue Pointer command TRB fields */ 899/* Set TR Dequeue Pointer command TRB fields */
885#define TRB_TO_STREAM_ID(p) ((((p) & (0xffff << 16)) >> 16)) 900#define TRB_TO_STREAM_ID(p) ((((p) & (0xffff << 16)) >> 16))
886#define STREAM_ID_FOR_TRB(p) ((((p)) & 0xffff) << 16) 901#define STREAM_ID_FOR_TRB(p) ((((p)) & 0xffff) << 16)
@@ -1115,6 +1130,17 @@ struct urb_priv {
1115#define XHCI_STOP_EP_CMD_TIMEOUT 5 1130#define XHCI_STOP_EP_CMD_TIMEOUT 5
1116/* XXX: Make these module parameters */ 1131/* XXX: Make these module parameters */
1117 1132
1133struct s3_save {
1134 u32 command;
1135 u32 dev_nt;
1136 u64 dcbaa_ptr;
1137 u32 config_reg;
1138 u32 irq_pending;
1139 u32 irq_control;
1140 u32 erst_size;
1141 u64 erst_base;
1142 u64 erst_dequeue;
1143};
1118 1144
1119/* There is one ehci_hci structure per controller */ 1145/* There is one ehci_hci structure per controller */
1120struct xhci_hcd { 1146struct xhci_hcd {
@@ -1178,6 +1204,12 @@ struct xhci_hcd {
1178#endif 1204#endif
1179 /* Host controller watchdog timer structures */ 1205 /* Host controller watchdog timer structures */
1180 unsigned int xhc_state; 1206 unsigned int xhc_state;
1207
1208 unsigned long bus_suspended;
1209 unsigned long next_statechange;
1210
1211 u32 command;
1212 struct s3_save s3;
1181/* Host controller is dying - not responding to commands. "I'm not dead yet!" 1213/* Host controller is dying - not responding to commands. "I'm not dead yet!"
1182 * 1214 *
1183 * xHC interrupts have been disabled and a watchdog timer will (or has already) 1215 * xHC interrupts have been disabled and a watchdog timer will (or has already)
@@ -1199,6 +1231,10 @@ struct xhci_hcd {
1199#define XHCI_LINK_TRB_QUIRK (1 << 0) 1231#define XHCI_LINK_TRB_QUIRK (1 << 0)
1200#define XHCI_RESET_EP_QUIRK (1 << 1) 1232#define XHCI_RESET_EP_QUIRK (1 << 1)
1201#define XHCI_NEC_HOST (1 << 2) 1233#define XHCI_NEC_HOST (1 << 2)
1234 u32 port_c_suspend[8]; /* port suspend change*/
1235 u32 suspended_ports[8]; /* which ports are
1236 suspended */
1237 unsigned long resume_done[MAX_HC_PORTS];
1202}; 1238};
1203 1239
1204/* For testing purposes */ 1240/* For testing purposes */
@@ -1369,6 +1405,15 @@ int xhci_init(struct usb_hcd *hcd);
1369int xhci_run(struct usb_hcd *hcd); 1405int xhci_run(struct usb_hcd *hcd);
1370void xhci_stop(struct usb_hcd *hcd); 1406void xhci_stop(struct usb_hcd *hcd);
1371void xhci_shutdown(struct usb_hcd *hcd); 1407void xhci_shutdown(struct usb_hcd *hcd);
1408
1409#ifdef CONFIG_PM
1410int xhci_suspend(struct xhci_hcd *xhci);
1411int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
1412#else
1413#define xhci_suspend NULL
1414#define xhci_resume NULL
1415#endif
1416
1372int xhci_get_frame(struct usb_hcd *hcd); 1417int xhci_get_frame(struct usb_hcd *hcd);
1373irqreturn_t xhci_irq(struct usb_hcd *hcd); 1418irqreturn_t xhci_irq(struct usb_hcd *hcd);
1374irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd); 1419irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd);
@@ -1388,7 +1433,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
1388int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); 1433int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep);
1389int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); 1434int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep);
1390void xhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep); 1435void xhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep);
1391int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev); 1436int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev);
1392int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); 1437int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
1393void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); 1438void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
1394 1439
@@ -1406,7 +1451,7 @@ int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
1406int xhci_queue_vendor_command(struct xhci_hcd *xhci, 1451int xhci_queue_vendor_command(struct xhci_hcd *xhci,
1407 u32 field1, u32 field2, u32 field3, u32 field4); 1452 u32 field1, u32 field2, u32 field3, u32 field4);
1408int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id, 1453int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
1409 unsigned int ep_index); 1454 unsigned int ep_index, int suspend);
1410int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, 1455int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
1411 int slot_id, unsigned int ep_index); 1456 int slot_id, unsigned int ep_index);
1412int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, 1457int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
@@ -1436,12 +1481,26 @@ void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci,
1436 unsigned int slot_id, unsigned int ep_index, 1481 unsigned int slot_id, unsigned int ep_index,
1437 struct xhci_dequeue_state *deq_state); 1482 struct xhci_dequeue_state *deq_state);
1438void xhci_stop_endpoint_command_watchdog(unsigned long arg); 1483void xhci_stop_endpoint_command_watchdog(unsigned long arg);
1484void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
1485 unsigned int ep_index, unsigned int stream_id);
1439 1486
1440/* xHCI roothub code */ 1487/* xHCI roothub code */
1441int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, 1488int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
1442 char *buf, u16 wLength); 1489 char *buf, u16 wLength);
1443int xhci_hub_status_data(struct usb_hcd *hcd, char *buf); 1490int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);
1444 1491
1492#ifdef CONFIG_PM
1493int xhci_bus_suspend(struct usb_hcd *hcd);
1494int xhci_bus_resume(struct usb_hcd *hcd);
1495#else
1496#define xhci_bus_suspend NULL
1497#define xhci_bus_resume NULL
1498#endif /* CONFIG_PM */
1499
1500u32 xhci_port_state_to_neutral(u32 state);
1501int xhci_find_slot_id_by_port(struct xhci_hcd *xhci, u16 port);
1502void xhci_ring_device(struct xhci_hcd *xhci, int slot_id);
1503
1445/* xHCI contexts */ 1504/* xHCI contexts */
1446struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); 1505struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx);
1447struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); 1506struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx);
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 55660eaf947c..1bfcd02ebeb5 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -231,3 +231,16 @@ config USB_ISIGHTFW
231 driver beforehand. Tools for doing so are available at 231 driver beforehand. Tools for doing so are available at
232 http://bersace03.free.fr 232 http://bersace03.free.fr
233 233
234config USB_YUREX
235 tristate "USB YUREX driver support"
236 depends on USB
237 help
238 Say Y here if you want to connect a YUREX to your computer's
239 USB port. The YUREX is a leg-shakes sensor. See
240 <http://bbu.kayac.com/en/> for further information.
241 This driver supports read/write of leg-shakes counter and
242 fasync for the counter update via a device file /dev/yurex*.
243
244 To compile this driver as a module, choose M here: the
245 module will be called yurex.
246
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 717703e81425..796ce7ebccc8 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -3,28 +3,27 @@
3# (the ones that don't fit into any other categories) 3# (the ones that don't fit into any other categories)
4# 4#
5 5
6obj-$(CONFIG_USB_ADUTUX) += adutux.o 6ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
7obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
8obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
9obj-$(CONFIG_USB_CYTHERM) += cytherm.o
10obj-$(CONFIG_USB_EMI26) += emi26.o
11obj-$(CONFIG_USB_EMI62) += emi62.o
12obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
13obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
14obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o
15obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
16obj-$(CONFIG_USB_LCD) += usblcd.o
17obj-$(CONFIG_USB_LD) += ldusb.o
18obj-$(CONFIG_USB_LED) += usbled.o
19obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
20obj-$(CONFIG_USB_RIO500) += rio500.o
21obj-$(CONFIG_USB_TEST) += usbtest.o
22obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
23obj-$(CONFIG_USB_USS720) += uss720.o
24obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o
25 7
26obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 8obj-$(CONFIG_USB_ADUTUX) += adutux.o
9obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
10obj-$(CONFIG_USB_CYPRESS_CY7C63) += cypress_cy7c63.o
11obj-$(CONFIG_USB_CYTHERM) += cytherm.o
12obj-$(CONFIG_USB_EMI26) += emi26.o
13obj-$(CONFIG_USB_EMI62) += emi62.o
14obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
15obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
16obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o
17obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
18obj-$(CONFIG_USB_LCD) += usblcd.o
19obj-$(CONFIG_USB_LD) += ldusb.o
20obj-$(CONFIG_USB_LED) += usbled.o
21obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
22obj-$(CONFIG_USB_RIO500) += rio500.o
23obj-$(CONFIG_USB_TEST) += usbtest.o
24obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
25obj-$(CONFIG_USB_USS720) += uss720.o
26obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o
27obj-$(CONFIG_USB_YUREX) += yurex.o
27 28
28ifeq ($(CONFIG_USB_DEBUG),y) 29obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
29EXTRA_CFLAGS += -DDEBUG
30endif
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index aecf380f6ecc..c8eec9c2d89e 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -2769,7 +2769,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2769 ftdi->sequence_num = ++ftdi_instances; 2769 ftdi->sequence_num = ++ftdi_instances;
2770 mutex_unlock(&ftdi_module_lock); 2770 mutex_unlock(&ftdi_module_lock);
2771 ftdi_elan_init_kref(ftdi); 2771 ftdi_elan_init_kref(ftdi);
2772 init_MUTEX(&ftdi->sw_lock); 2772 sema_init(&ftdi->sw_lock, 1);
2773 ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); 2773 ftdi->udev = usb_get_dev(interface_to_usbdev(interface));
2774 ftdi->interface = interface; 2774 ftdi->interface = interface;
2775 mutex_init(&ftdi->u132_lock); 2775 mutex_init(&ftdi->u132_lock);
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 9b50db257019..375664198776 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -374,7 +374,7 @@ static ssize_t iowarrior_write(struct file *file,
374 case USB_DEVICE_ID_CODEMERCS_IOWPV2: 374 case USB_DEVICE_ID_CODEMERCS_IOWPV2:
375 case USB_DEVICE_ID_CODEMERCS_IOW40: 375 case USB_DEVICE_ID_CODEMERCS_IOW40:
376 /* IOW24 and IOW40 use a synchronous call */ 376 /* IOW24 and IOW40 use a synchronous call */
377 buf = kmalloc(8, GFP_KERNEL); /* 8 bytes are enough for both products */ 377 buf = kmalloc(count, GFP_KERNEL);
378 if (!buf) { 378 if (!buf) {
379 retval = -ENOMEM; 379 retval = -ENOMEM;
380 goto exit; 380 goto exit;
diff --git a/drivers/usb/misc/sisusbvga/Makefile b/drivers/usb/misc/sisusbvga/Makefile
index 7f934cfc906c..3142476ccc8e 100644
--- a/drivers/usb/misc/sisusbvga/Makefile
+++ b/drivers/usb/misc/sisusbvga/Makefile
@@ -4,5 +4,4 @@
4 4
5obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o 5obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o
6 6
7sisusbvga-objs := sisusb.o sisusb_init.o sisusb_con.o 7sisusbvga-y := sisusb.o sisusb_init.o sisusb_con.o
8
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index eef370eb7a54..a35b427c0bac 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -13,17 +13,16 @@
13 13
14/*-------------------------------------------------------------------------*/ 14/*-------------------------------------------------------------------------*/
15 15
16// FIXME make these public somewhere; usbdevfs.h? 16/* FIXME make these public somewhere; usbdevfs.h? */
17//
18struct usbtest_param { 17struct usbtest_param {
19 // inputs 18 /* inputs */
20 unsigned test_num; /* 0..(TEST_CASES-1) */ 19 unsigned test_num; /* 0..(TEST_CASES-1) */
21 unsigned iterations; 20 unsigned iterations;
22 unsigned length; 21 unsigned length;
23 unsigned vary; 22 unsigned vary;
24 unsigned sglen; 23 unsigned sglen;
25 24
26 // outputs 25 /* outputs */
27 struct timeval duration; 26 struct timeval duration;
28}; 27};
29#define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) 28#define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param)
@@ -45,9 +44,9 @@ struct usbtest_info {
45 const char *name; 44 const char *name;
46 u8 ep_in; /* bulk/intr source */ 45 u8 ep_in; /* bulk/intr source */
47 u8 ep_out; /* bulk/intr sink */ 46 u8 ep_out; /* bulk/intr sink */
48 unsigned autoconf : 1; 47 unsigned autoconf:1;
49 unsigned ctrl_out : 1; 48 unsigned ctrl_out:1;
50 unsigned iso : 1; /* try iso in/out */ 49 unsigned iso:1; /* try iso in/out */
51 int alt; 50 int alt;
52}; 51};
53 52
@@ -71,9 +70,9 @@ struct usbtest_dev {
71 u8 *buf; 70 u8 *buf;
72}; 71};
73 72
74static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) 73static struct usb_device *testdev_to_usbdev(struct usbtest_dev *test)
75{ 74{
76 return interface_to_usbdev (test->intf); 75 return interface_to_usbdev(test->intf);
77} 76}
78 77
79/* set up all urbs so they can be used with either bulk or interrupt */ 78/* set up all urbs so they can be used with either bulk or interrupt */
@@ -87,7 +86,7 @@ static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test)
87/*-------------------------------------------------------------------------*/ 86/*-------------------------------------------------------------------------*/
88 87
89static int 88static int
90get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) 89get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf)
91{ 90{
92 int tmp; 91 int tmp;
93 struct usb_host_interface *alt; 92 struct usb_host_interface *alt;
@@ -115,7 +114,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
115 case USB_ENDPOINT_XFER_ISOC: 114 case USB_ENDPOINT_XFER_ISOC:
116 if (dev->info->iso) 115 if (dev->info->iso)
117 goto try_iso; 116 goto try_iso;
118 // FALLTHROUGH 117 /* FALLTHROUGH */
119 default: 118 default:
120 continue; 119 continue;
121 } 120 }
@@ -142,9 +141,9 @@ try_iso:
142 return -EINVAL; 141 return -EINVAL;
143 142
144found: 143found:
145 udev = testdev_to_usbdev (dev); 144 udev = testdev_to_usbdev(dev);
146 if (alt->desc.bAlternateSetting != 0) { 145 if (alt->desc.bAlternateSetting != 0) {
147 tmp = usb_set_interface (udev, 146 tmp = usb_set_interface(udev,
148 alt->desc.bInterfaceNumber, 147 alt->desc.bInterfaceNumber,
149 alt->desc.bAlternateSetting); 148 alt->desc.bAlternateSetting);
150 if (tmp < 0) 149 if (tmp < 0)
@@ -152,21 +151,21 @@ found:
152 } 151 }
153 152
154 if (in) { 153 if (in) {
155 dev->in_pipe = usb_rcvbulkpipe (udev, 154 dev->in_pipe = usb_rcvbulkpipe(udev,
156 in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 155 in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
157 dev->out_pipe = usb_sndbulkpipe (udev, 156 dev->out_pipe = usb_sndbulkpipe(udev,
158 out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 157 out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
159 } 158 }
160 if (iso_in) { 159 if (iso_in) {
161 dev->iso_in = &iso_in->desc; 160 dev->iso_in = &iso_in->desc;
162 dev->in_iso_pipe = usb_rcvisocpipe (udev, 161 dev->in_iso_pipe = usb_rcvisocpipe(udev,
163 iso_in->desc.bEndpointAddress 162 iso_in->desc.bEndpointAddress
164 & USB_ENDPOINT_NUMBER_MASK); 163 & USB_ENDPOINT_NUMBER_MASK);
165 } 164 }
166 165
167 if (iso_out) { 166 if (iso_out) {
168 dev->iso_out = &iso_out->desc; 167 dev->iso_out = &iso_out->desc;
169 dev->out_iso_pipe = usb_sndisocpipe (udev, 168 dev->out_iso_pipe = usb_sndisocpipe(udev,
170 iso_out->desc.bEndpointAddress 169 iso_out->desc.bEndpointAddress
171 & USB_ENDPOINT_NUMBER_MASK); 170 & USB_ENDPOINT_NUMBER_MASK);
172 } 171 }
@@ -182,12 +181,12 @@ found:
182 * them with non-zero test data (or test for it) when appropriate. 181 * them with non-zero test data (or test for it) when appropriate.
183 */ 182 */
184 183
185static void simple_callback (struct urb *urb) 184static void simple_callback(struct urb *urb)
186{ 185{
187 complete(urb->context); 186 complete(urb->context);
188} 187}
189 188
190static struct urb *simple_alloc_urb ( 189static struct urb *simple_alloc_urb(
191 struct usb_device *udev, 190 struct usb_device *udev,
192 int pipe, 191 int pipe,
193 unsigned long bytes 192 unsigned long bytes
@@ -195,32 +194,32 @@ static struct urb *simple_alloc_urb (
195{ 194{
196 struct urb *urb; 195 struct urb *urb;
197 196
198 urb = usb_alloc_urb (0, GFP_KERNEL); 197 urb = usb_alloc_urb(0, GFP_KERNEL);
199 if (!urb) 198 if (!urb)
200 return urb; 199 return urb;
201 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); 200 usb_fill_bulk_urb(urb, udev, pipe, NULL, bytes, simple_callback, NULL);
202 urb->interval = (udev->speed == USB_SPEED_HIGH) 201 urb->interval = (udev->speed == USB_SPEED_HIGH)
203 ? (INTERRUPT_RATE << 3) 202 ? (INTERRUPT_RATE << 3)
204 : INTERRUPT_RATE; 203 : INTERRUPT_RATE;
205 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 204 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
206 if (usb_pipein (pipe)) 205 if (usb_pipein(pipe))
207 urb->transfer_flags |= URB_SHORT_NOT_OK; 206 urb->transfer_flags |= URB_SHORT_NOT_OK;
208 urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, 207 urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL,
209 &urb->transfer_dma); 208 &urb->transfer_dma);
210 if (!urb->transfer_buffer) { 209 if (!urb->transfer_buffer) {
211 usb_free_urb (urb); 210 usb_free_urb(urb);
212 urb = NULL; 211 urb = NULL;
213 } else 212 } else
214 memset (urb->transfer_buffer, 0, bytes); 213 memset(urb->transfer_buffer, 0, bytes);
215 return urb; 214 return urb;
216} 215}
217 216
218static unsigned pattern = 0; 217static unsigned pattern;
219static unsigned mod_pattern; 218static unsigned mod_pattern;
220module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); 219module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR);
221MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); 220MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)");
222 221
223static inline void simple_fill_buf (struct urb *urb) 222static inline void simple_fill_buf(struct urb *urb)
224{ 223{
225 unsigned i; 224 unsigned i;
226 u8 *buf = urb->transfer_buffer; 225 u8 *buf = urb->transfer_buffer;
@@ -228,9 +227,9 @@ static inline void simple_fill_buf (struct urb *urb)
228 227
229 switch (pattern) { 228 switch (pattern) {
230 default: 229 default:
231 // FALLTHROUGH 230 /* FALLTHROUGH */
232 case 0: 231 case 0:
233 memset (buf, 0, len); 232 memset(buf, 0, len);
234 break; 233 break;
235 case 1: /* mod63 */ 234 case 1: /* mod63 */
236 for (i = 0; i < len; i++) 235 for (i = 0; i < len; i++)
@@ -273,14 +272,14 @@ static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb)
273 return 0; 272 return 0;
274} 273}
275 274
276static void simple_free_urb (struct urb *urb) 275static void simple_free_urb(struct urb *urb)
277{ 276{
278 usb_free_coherent(urb->dev, urb->transfer_buffer_length, 277 usb_free_coherent(urb->dev, urb->transfer_buffer_length,
279 urb->transfer_buffer, urb->transfer_dma); 278 urb->transfer_buffer, urb->transfer_dma);
280 usb_free_urb (urb); 279 usb_free_urb(urb);
281} 280}
282 281
283static int simple_io ( 282static int simple_io(
284 struct usbtest_dev *tdev, 283 struct usbtest_dev *tdev,
285 struct urb *urb, 284 struct urb *urb,
286 int iterations, 285 int iterations,
@@ -296,17 +295,18 @@ static int simple_io (
296 295
297 urb->context = &completion; 296 urb->context = &completion;
298 while (retval == 0 && iterations-- > 0) { 297 while (retval == 0 && iterations-- > 0) {
299 init_completion (&completion); 298 init_completion(&completion);
300 if (usb_pipeout (urb->pipe)) 299 if (usb_pipeout(urb->pipe))
301 simple_fill_buf (urb); 300 simple_fill_buf(urb);
302 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) 301 retval = usb_submit_urb(urb, GFP_KERNEL);
302 if (retval != 0)
303 break; 303 break;
304 304
305 /* NOTE: no timeouts; can't be broken out of by interrupt */ 305 /* NOTE: no timeouts; can't be broken out of by interrupt */
306 wait_for_completion (&completion); 306 wait_for_completion(&completion);
307 retval = urb->status; 307 retval = urb->status;
308 urb->dev = udev; 308 urb->dev = udev;
309 if (retval == 0 && usb_pipein (urb->pipe)) 309 if (retval == 0 && usb_pipein(urb->pipe))
310 retval = simple_check_buf(tdev, urb); 310 retval = simple_check_buf(tdev, urb);
311 311
312 if (vary) { 312 if (vary) {
@@ -337,7 +337,7 @@ static int simple_io (
337 * Yes, this also tests the scatterlist primitives. 337 * Yes, this also tests the scatterlist primitives.
338 */ 338 */
339 339
340static void free_sglist (struct scatterlist *sg, int nents) 340static void free_sglist(struct scatterlist *sg, int nents)
341{ 341{
342 unsigned i; 342 unsigned i;
343 343
@@ -346,19 +346,19 @@ static void free_sglist (struct scatterlist *sg, int nents)
346 for (i = 0; i < nents; i++) { 346 for (i = 0; i < nents; i++) {
347 if (!sg_page(&sg[i])) 347 if (!sg_page(&sg[i]))
348 continue; 348 continue;
349 kfree (sg_virt(&sg[i])); 349 kfree(sg_virt(&sg[i]));
350 } 350 }
351 kfree (sg); 351 kfree(sg);
352} 352}
353 353
354static struct scatterlist * 354static struct scatterlist *
355alloc_sglist (int nents, int max, int vary) 355alloc_sglist(int nents, int max, int vary)
356{ 356{
357 struct scatterlist *sg; 357 struct scatterlist *sg;
358 unsigned i; 358 unsigned i;
359 unsigned size = max; 359 unsigned size = max;
360 360
361 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL); 361 sg = kmalloc(nents * sizeof *sg, GFP_KERNEL);
362 if (!sg) 362 if (!sg)
363 return NULL; 363 return NULL;
364 sg_init_table(sg, nents); 364 sg_init_table(sg, nents);
@@ -367,9 +367,9 @@ alloc_sglist (int nents, int max, int vary)
367 char *buf; 367 char *buf;
368 unsigned j; 368 unsigned j;
369 369
370 buf = kzalloc (size, GFP_KERNEL); 370 buf = kzalloc(size, GFP_KERNEL);
371 if (!buf) { 371 if (!buf) {
372 free_sglist (sg, i); 372 free_sglist(sg, i);
373 return NULL; 373 return NULL;
374 } 374 }
375 375
@@ -397,7 +397,7 @@ alloc_sglist (int nents, int max, int vary)
397 return sg; 397 return sg;
398} 398}
399 399
400static int perform_sglist ( 400static int perform_sglist(
401 struct usbtest_dev *tdev, 401 struct usbtest_dev *tdev,
402 unsigned iterations, 402 unsigned iterations,
403 int pipe, 403 int pipe,
@@ -410,7 +410,7 @@ static int perform_sglist (
410 int retval = 0; 410 int retval = 0;
411 411
412 while (retval == 0 && iterations-- > 0) { 412 while (retval == 0 && iterations-- > 0) {
413 retval = usb_sg_init (req, udev, pipe, 413 retval = usb_sg_init(req, udev, pipe,
414 (udev->speed == USB_SPEED_HIGH) 414 (udev->speed == USB_SPEED_HIGH)
415 ? (INTERRUPT_RATE << 3) 415 ? (INTERRUPT_RATE << 3)
416 : INTERRUPT_RATE, 416 : INTERRUPT_RATE,
@@ -418,7 +418,7 @@ static int perform_sglist (
418 418
419 if (retval) 419 if (retval)
420 break; 420 break;
421 usb_sg_wait (req); 421 usb_sg_wait(req);
422 retval = req->status; 422 retval = req->status;
423 423
424 /* FIXME check resulting data pattern */ 424 /* FIXME check resulting data pattern */
@@ -426,9 +426,9 @@ static int perform_sglist (
426 /* FIXME if endpoint halted, clear halt (and log) */ 426 /* FIXME if endpoint halted, clear halt (and log) */
427 } 427 }
428 428
429 // FIXME for unlink or fault handling tests, don't report 429 /* FIXME for unlink or fault handling tests, don't report
430 // failure if retval is as we expected ... 430 * failure if retval is as we expected ...
431 431 */
432 if (retval) 432 if (retval)
433 ERROR(tdev, "perform_sglist failed, " 433 ERROR(tdev, "perform_sglist failed, "
434 "iterations left %d, status %d\n", 434 "iterations left %d, status %d\n",
@@ -452,31 +452,31 @@ static int perform_sglist (
452 */ 452 */
453 453
454static unsigned realworld = 1; 454static unsigned realworld = 1;
455module_param (realworld, uint, 0); 455module_param(realworld, uint, 0);
456MODULE_PARM_DESC (realworld, "clear to demand stricter spec compliance"); 456MODULE_PARM_DESC(realworld, "clear to demand stricter spec compliance");
457 457
458static int get_altsetting (struct usbtest_dev *dev) 458static int get_altsetting(struct usbtest_dev *dev)
459{ 459{
460 struct usb_interface *iface = dev->intf; 460 struct usb_interface *iface = dev->intf;
461 struct usb_device *udev = interface_to_usbdev (iface); 461 struct usb_device *udev = interface_to_usbdev(iface);
462 int retval; 462 int retval;
463 463
464 retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), 464 retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
465 USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, 465 USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE,
466 0, iface->altsetting [0].desc.bInterfaceNumber, 466 0, iface->altsetting[0].desc.bInterfaceNumber,
467 dev->buf, 1, USB_CTRL_GET_TIMEOUT); 467 dev->buf, 1, USB_CTRL_GET_TIMEOUT);
468 switch (retval) { 468 switch (retval) {
469 case 1: 469 case 1:
470 return dev->buf [0]; 470 return dev->buf[0];
471 case 0: 471 case 0:
472 retval = -ERANGE; 472 retval = -ERANGE;
473 // FALLTHROUGH 473 /* FALLTHROUGH */
474 default: 474 default:
475 return retval; 475 return retval;
476 } 476 }
477} 477}
478 478
479static int set_altsetting (struct usbtest_dev *dev, int alternate) 479static int set_altsetting(struct usbtest_dev *dev, int alternate)
480{ 480{
481 struct usb_interface *iface = dev->intf; 481 struct usb_interface *iface = dev->intf;
482 struct usb_device *udev; 482 struct usb_device *udev;
@@ -484,9 +484,9 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate)
484 if (alternate < 0 || alternate >= 256) 484 if (alternate < 0 || alternate >= 256)
485 return -EINVAL; 485 return -EINVAL;
486 486
487 udev = interface_to_usbdev (iface); 487 udev = interface_to_usbdev(iface);
488 return usb_set_interface (udev, 488 return usb_set_interface(udev,
489 iface->altsetting [0].desc.bInterfaceNumber, 489 iface->altsetting[0].desc.bInterfaceNumber,
490 alternate); 490 alternate);
491} 491}
492 492
@@ -519,9 +519,9 @@ static int is_good_config(struct usbtest_dev *tdev, int len)
519 return 0; 519 return 0;
520 } 520 }
521 521
522 if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ 522 if (le16_to_cpu(config->wTotalLength) == len) /* read it all */
523 return 1; 523 return 1;
524 if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ 524 if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */
525 return 1; 525 return 1;
526 ERROR(tdev, "bogus config descriptor read size\n"); 526 ERROR(tdev, "bogus config descriptor read size\n");
527 return 0; 527 return 0;
@@ -542,10 +542,10 @@ static int is_good_config(struct usbtest_dev *tdev, int len)
542 * to see if usbcore, hcd, and device all behave right. such testing would 542 * to see if usbcore, hcd, and device all behave right. such testing would
543 * involve varied read sizes and other operation sequences. 543 * involve varied read sizes and other operation sequences.
544 */ 544 */
545static int ch9_postconfig (struct usbtest_dev *dev) 545static int ch9_postconfig(struct usbtest_dev *dev)
546{ 546{
547 struct usb_interface *iface = dev->intf; 547 struct usb_interface *iface = dev->intf;
548 struct usb_device *udev = interface_to_usbdev (iface); 548 struct usb_device *udev = interface_to_usbdev(iface);
549 int i, alt, retval; 549 int i, alt, retval;
550 550
551 /* [9.2.3] if there's more than one altsetting, we need to be able to 551 /* [9.2.3] if there's more than one altsetting, we need to be able to
@@ -554,7 +554,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
554 for (i = 0; i < iface->num_altsetting; i++) { 554 for (i = 0; i < iface->num_altsetting; i++) {
555 555
556 /* 9.2.3 constrains the range here */ 556 /* 9.2.3 constrains the range here */
557 alt = iface->altsetting [i].desc.bAlternateSetting; 557 alt = iface->altsetting[i].desc.bAlternateSetting;
558 if (alt < 0 || alt >= iface->num_altsetting) { 558 if (alt < 0 || alt >= iface->num_altsetting) {
559 dev_err(&iface->dev, 559 dev_err(&iface->dev,
560 "invalid alt [%d].bAltSetting = %d\n", 560 "invalid alt [%d].bAltSetting = %d\n",
@@ -566,7 +566,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
566 continue; 566 continue;
567 567
568 /* [9.4.10] set_interface */ 568 /* [9.4.10] set_interface */
569 retval = set_altsetting (dev, alt); 569 retval = set_altsetting(dev, alt);
570 if (retval) { 570 if (retval) {
571 dev_err(&iface->dev, "can't set_interface = %d, %d\n", 571 dev_err(&iface->dev, "can't set_interface = %d, %d\n",
572 alt, retval); 572 alt, retval);
@@ -574,7 +574,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
574 } 574 }
575 575
576 /* [9.4.4] get_interface always works */ 576 /* [9.4.4] get_interface always works */
577 retval = get_altsetting (dev); 577 retval = get_altsetting(dev);
578 if (retval != alt) { 578 if (retval != alt) {
579 dev_err(&iface->dev, "get alt should be %d, was %d\n", 579 dev_err(&iface->dev, "get alt should be %d, was %d\n",
580 alt, retval); 580 alt, retval);
@@ -591,11 +591,11 @@ static int ch9_postconfig (struct usbtest_dev *dev)
591 * ... although some cheap devices (like one TI Hub I've got) 591 * ... although some cheap devices (like one TI Hub I've got)
592 * won't return config descriptors except before set_config. 592 * won't return config descriptors except before set_config.
593 */ 593 */
594 retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), 594 retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
595 USB_REQ_GET_CONFIGURATION, 595 USB_REQ_GET_CONFIGURATION,
596 USB_DIR_IN | USB_RECIP_DEVICE, 596 USB_DIR_IN | USB_RECIP_DEVICE,
597 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); 597 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT);
598 if (retval != 1 || dev->buf [0] != expected) { 598 if (retval != 1 || dev->buf[0] != expected) {
599 dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", 599 dev_err(&iface->dev, "get config --> %d %d (1 %d)\n",
600 retval, dev->buf[0], expected); 600 retval, dev->buf[0], expected);
601 return (retval < 0) ? retval : -EDOM; 601 return (retval < 0) ? retval : -EDOM;
@@ -603,7 +603,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
603 } 603 }
604 604
605 /* there's always [9.4.3] a device descriptor [9.6.1] */ 605 /* there's always [9.4.3] a device descriptor [9.6.1] */
606 retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0, 606 retval = usb_get_descriptor(udev, USB_DT_DEVICE, 0,
607 dev->buf, sizeof udev->descriptor); 607 dev->buf, sizeof udev->descriptor);
608 if (retval != sizeof udev->descriptor) { 608 if (retval != sizeof udev->descriptor) {
609 dev_err(&iface->dev, "dev descriptor --> %d\n", retval); 609 dev_err(&iface->dev, "dev descriptor --> %d\n", retval);
@@ -612,7 +612,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
612 612
613 /* there's always [9.4.3] at least one config descriptor [9.6.3] */ 613 /* there's always [9.4.3] at least one config descriptor [9.6.3] */
614 for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { 614 for (i = 0; i < udev->descriptor.bNumConfigurations; i++) {
615 retval = usb_get_descriptor (udev, USB_DT_CONFIG, i, 615 retval = usb_get_descriptor(udev, USB_DT_CONFIG, i,
616 dev->buf, TBUF_SIZE); 616 dev->buf, TBUF_SIZE);
617 if (!is_good_config(dev, retval)) { 617 if (!is_good_config(dev, retval)) {
618 dev_err(&iface->dev, 618 dev_err(&iface->dev,
@@ -621,18 +621,19 @@ static int ch9_postconfig (struct usbtest_dev *dev)
621 return (retval < 0) ? retval : -EDOM; 621 return (retval < 0) ? retval : -EDOM;
622 } 622 }
623 623
624 // FIXME cross-checking udev->config[i] to make sure usbcore 624 /* FIXME cross-checking udev->config[i] to make sure usbcore
625 // parsed it right (etc) would be good testing paranoia 625 * parsed it right (etc) would be good testing paranoia
626 */
626 } 627 }
627 628
628 /* and sometimes [9.2.6.6] speed dependent descriptors */ 629 /* and sometimes [9.2.6.6] speed dependent descriptors */
629 if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { 630 if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) {
630 struct usb_qualifier_descriptor *d = NULL; 631 struct usb_qualifier_descriptor *d = NULL;
631 632
632 /* device qualifier [9.6.2] */ 633 /* device qualifier [9.6.2] */
633 retval = usb_get_descriptor (udev, 634 retval = usb_get_descriptor(udev,
634 USB_DT_DEVICE_QUALIFIER, 0, dev->buf, 635 USB_DT_DEVICE_QUALIFIER, 0, dev->buf,
635 sizeof (struct usb_qualifier_descriptor)); 636 sizeof(struct usb_qualifier_descriptor));
636 if (retval == -EPIPE) { 637 if (retval == -EPIPE) {
637 if (udev->speed == USB_SPEED_HIGH) { 638 if (udev->speed == USB_SPEED_HIGH) {
638 dev_err(&iface->dev, 639 dev_err(&iface->dev,
@@ -641,7 +642,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
641 return (retval < 0) ? retval : -EDOM; 642 return (retval < 0) ? retval : -EDOM;
642 } 643 }
643 /* usb2.0 but not high-speed capable; fine */ 644 /* usb2.0 but not high-speed capable; fine */
644 } else if (retval != sizeof (struct usb_qualifier_descriptor)) { 645 } else if (retval != sizeof(struct usb_qualifier_descriptor)) {
645 dev_err(&iface->dev, "dev qualifier --> %d\n", retval); 646 dev_err(&iface->dev, "dev qualifier --> %d\n", retval);
646 return (retval < 0) ? retval : -EDOM; 647 return (retval < 0) ? retval : -EDOM;
647 } else 648 } else
@@ -651,7 +652,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
651 if (d) { 652 if (d) {
652 unsigned max = d->bNumConfigurations; 653 unsigned max = d->bNumConfigurations;
653 for (i = 0; i < max; i++) { 654 for (i = 0; i < max; i++) {
654 retval = usb_get_descriptor (udev, 655 retval = usb_get_descriptor(udev,
655 USB_DT_OTHER_SPEED_CONFIG, i, 656 USB_DT_OTHER_SPEED_CONFIG, i,
656 dev->buf, TBUF_SIZE); 657 dev->buf, TBUF_SIZE);
657 if (!is_good_config(dev, retval)) { 658 if (!is_good_config(dev, retval)) {
@@ -663,25 +664,26 @@ static int ch9_postconfig (struct usbtest_dev *dev)
663 } 664 }
664 } 665 }
665 } 666 }
666 // FIXME fetch strings from at least the device descriptor 667 /* FIXME fetch strings from at least the device descriptor */
667 668
668 /* [9.4.5] get_status always works */ 669 /* [9.4.5] get_status always works */
669 retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf); 670 retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf);
670 if (retval != 2) { 671 if (retval != 2) {
671 dev_err(&iface->dev, "get dev status --> %d\n", retval); 672 dev_err(&iface->dev, "get dev status --> %d\n", retval);
672 return (retval < 0) ? retval : -EDOM; 673 return (retval < 0) ? retval : -EDOM;
673 } 674 }
674 675
675 // FIXME configuration.bmAttributes says if we could try to set/clear 676 /* FIXME configuration.bmAttributes says if we could try to set/clear
676 // the device's remote wakeup feature ... if we can, test that here 677 * the device's remote wakeup feature ... if we can, test that here
678 */
677 679
678 retval = usb_get_status (udev, USB_RECIP_INTERFACE, 680 retval = usb_get_status(udev, USB_RECIP_INTERFACE,
679 iface->altsetting [0].desc.bInterfaceNumber, dev->buf); 681 iface->altsetting[0].desc.bInterfaceNumber, dev->buf);
680 if (retval != 2) { 682 if (retval != 2) {
681 dev_err(&iface->dev, "get interface status --> %d\n", retval); 683 dev_err(&iface->dev, "get interface status --> %d\n", retval);
682 return (retval < 0) ? retval : -EDOM; 684 return (retval < 0) ? retval : -EDOM;
683 } 685 }
684 // FIXME get status for each endpoint in the interface 686 /* FIXME get status for each endpoint in the interface */
685 687
686 return 0; 688 return 0;
687} 689}
@@ -717,7 +719,7 @@ struct subcase {
717 int expected; 719 int expected;
718}; 720};
719 721
720static void ctrl_complete (struct urb *urb) 722static void ctrl_complete(struct urb *urb)
721{ 723{
722 struct ctrl_ctx *ctx = urb->context; 724 struct ctrl_ctx *ctx = urb->context;
723 struct usb_ctrlrequest *reqp; 725 struct usb_ctrlrequest *reqp;
@@ -725,9 +727,9 @@ static void ctrl_complete (struct urb *urb)
725 int status = urb->status; 727 int status = urb->status;
726 728
727 reqp = (struct usb_ctrlrequest *)urb->setup_packet; 729 reqp = (struct usb_ctrlrequest *)urb->setup_packet;
728 subcase = container_of (reqp, struct subcase, setup); 730 subcase = container_of(reqp, struct subcase, setup);
729 731
730 spin_lock (&ctx->lock); 732 spin_lock(&ctx->lock);
731 ctx->count--; 733 ctx->count--;
732 ctx->pending--; 734 ctx->pending--;
733 735
@@ -787,14 +789,14 @@ error:
787 789
788 /* unlink whatever's still pending */ 790 /* unlink whatever's still pending */
789 for (i = 1; i < ctx->param->sglen; i++) { 791 for (i = 1; i < ctx->param->sglen; i++) {
790 struct urb *u = ctx->urb [ 792 struct urb *u = ctx->urb[
791 (i + subcase->number) 793 (i + subcase->number)
792 % ctx->param->sglen]; 794 % ctx->param->sglen];
793 795
794 if (u == urb || !u->dev) 796 if (u == urb || !u->dev)
795 continue; 797 continue;
796 spin_unlock(&ctx->lock); 798 spin_unlock(&ctx->lock);
797 status = usb_unlink_urb (u); 799 status = usb_unlink_urb(u);
798 spin_lock(&ctx->lock); 800 spin_lock(&ctx->lock);
799 switch (status) { 801 switch (status) {
800 case -EINPROGRESS: 802 case -EINPROGRESS:
@@ -812,7 +814,8 @@ error:
812 814
813 /* resubmit if we need to, else mark this as done */ 815 /* resubmit if we need to, else mark this as done */
814 if ((status == 0) && (ctx->pending < ctx->count)) { 816 if ((status == 0) && (ctx->pending < ctx->count)) {
815 if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { 817 status = usb_submit_urb(urb, GFP_ATOMIC);
818 if (status != 0) {
816 ERROR(ctx->dev, 819 ERROR(ctx->dev,
817 "can't resubmit ctrl %02x.%02x, err %d\n", 820 "can't resubmit ctrl %02x.%02x, err %d\n",
818 reqp->bRequestType, reqp->bRequest, status); 821 reqp->bRequestType, reqp->bRequest, status);
@@ -824,21 +827,21 @@ error:
824 827
825 /* signal completion when nothing's queued */ 828 /* signal completion when nothing's queued */
826 if (ctx->pending == 0) 829 if (ctx->pending == 0)
827 complete (&ctx->complete); 830 complete(&ctx->complete);
828 spin_unlock (&ctx->lock); 831 spin_unlock(&ctx->lock);
829} 832}
830 833
831static int 834static int
832test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) 835test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
833{ 836{
834 struct usb_device *udev = testdev_to_usbdev (dev); 837 struct usb_device *udev = testdev_to_usbdev(dev);
835 struct urb **urb; 838 struct urb **urb;
836 struct ctrl_ctx context; 839 struct ctrl_ctx context;
837 int i; 840 int i;
838 841
839 spin_lock_init (&context.lock); 842 spin_lock_init(&context.lock);
840 context.dev = dev; 843 context.dev = dev;
841 init_completion (&context.complete); 844 init_completion(&context.complete);
842 context.count = param->sglen * param->iterations; 845 context.count = param->sglen * param->iterations;
843 context.pending = 0; 846 context.pending = 0;
844 context.status = -ENOMEM; 847 context.status = -ENOMEM;
@@ -853,7 +856,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
853 if (!urb) 856 if (!urb)
854 return -ENOMEM; 857 return -ENOMEM;
855 for (i = 0; i < param->sglen; i++) { 858 for (i = 0; i < param->sglen; i++) {
856 int pipe = usb_rcvctrlpipe (udev, 0); 859 int pipe = usb_rcvctrlpipe(udev, 0);
857 unsigned len; 860 unsigned len;
858 struct urb *u; 861 struct urb *u;
859 struct usb_ctrlrequest req; 862 struct usb_ctrlrequest req;
@@ -869,104 +872,108 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
869 * device, but some are chosen to trigger protocol stalls 872 * device, but some are chosen to trigger protocol stalls
870 * or short reads. 873 * or short reads.
871 */ 874 */
872 memset (&req, 0, sizeof req); 875 memset(&req, 0, sizeof req);
873 req.bRequest = USB_REQ_GET_DESCRIPTOR; 876 req.bRequest = USB_REQ_GET_DESCRIPTOR;
874 req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; 877 req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;
875 878
876 switch (i % NUM_SUBCASES) { 879 switch (i % NUM_SUBCASES) {
877 case 0: // get device descriptor 880 case 0: /* get device descriptor */
878 req.wValue = cpu_to_le16 (USB_DT_DEVICE << 8); 881 req.wValue = cpu_to_le16(USB_DT_DEVICE << 8);
879 len = sizeof (struct usb_device_descriptor); 882 len = sizeof(struct usb_device_descriptor);
880 break; 883 break;
881 case 1: // get first config descriptor (only) 884 case 1: /* get first config descriptor (only) */
882 req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); 885 req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
883 len = sizeof (struct usb_config_descriptor); 886 len = sizeof(struct usb_config_descriptor);
884 break; 887 break;
885 case 2: // get altsetting (OFTEN STALLS) 888 case 2: /* get altsetting (OFTEN STALLS) */
886 req.bRequest = USB_REQ_GET_INTERFACE; 889 req.bRequest = USB_REQ_GET_INTERFACE;
887 req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; 890 req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;
888 // index = 0 means first interface 891 /* index = 0 means first interface */
889 len = 1; 892 len = 1;
890 expected = EPIPE; 893 expected = EPIPE;
891 break; 894 break;
892 case 3: // get interface status 895 case 3: /* get interface status */
893 req.bRequest = USB_REQ_GET_STATUS; 896 req.bRequest = USB_REQ_GET_STATUS;
894 req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; 897 req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;
895 // interface 0 898 /* interface 0 */
896 len = 2; 899 len = 2;
897 break; 900 break;
898 case 4: // get device status 901 case 4: /* get device status */
899 req.bRequest = USB_REQ_GET_STATUS; 902 req.bRequest = USB_REQ_GET_STATUS;
900 req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; 903 req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;
901 len = 2; 904 len = 2;
902 break; 905 break;
903 case 5: // get device qualifier (MAY STALL) 906 case 5: /* get device qualifier (MAY STALL) */
904 req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); 907 req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8);
905 len = sizeof (struct usb_qualifier_descriptor); 908 len = sizeof(struct usb_qualifier_descriptor);
906 if (udev->speed != USB_SPEED_HIGH) 909 if (udev->speed != USB_SPEED_HIGH)
907 expected = EPIPE; 910 expected = EPIPE;
908 break; 911 break;
909 case 6: // get first config descriptor, plus interface 912 case 6: /* get first config descriptor, plus interface */
910 req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); 913 req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
911 len = sizeof (struct usb_config_descriptor); 914 len = sizeof(struct usb_config_descriptor);
912 len += sizeof (struct usb_interface_descriptor); 915 len += sizeof(struct usb_interface_descriptor);
913 break; 916 break;
914 case 7: // get interface descriptor (ALWAYS STALLS) 917 case 7: /* get interface descriptor (ALWAYS STALLS) */
915 req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); 918 req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8);
916 // interface == 0 919 /* interface == 0 */
917 len = sizeof (struct usb_interface_descriptor); 920 len = sizeof(struct usb_interface_descriptor);
918 expected = -EPIPE; 921 expected = -EPIPE;
919 break; 922 break;
920 // NOTE: two consecutive stalls in the queue here. 923 /* NOTE: two consecutive stalls in the queue here.
921 // that tests fault recovery a bit more aggressively. 924 * that tests fault recovery a bit more aggressively. */
922 case 8: // clear endpoint halt (MAY STALL) 925 case 8: /* clear endpoint halt (MAY STALL) */
923 req.bRequest = USB_REQ_CLEAR_FEATURE; 926 req.bRequest = USB_REQ_CLEAR_FEATURE;
924 req.bRequestType = USB_RECIP_ENDPOINT; 927 req.bRequestType = USB_RECIP_ENDPOINT;
925 // wValue 0 == ep halt 928 /* wValue 0 == ep halt */
926 // wIndex 0 == ep0 (shouldn't halt!) 929 /* wIndex 0 == ep0 (shouldn't halt!) */
927 len = 0; 930 len = 0;
928 pipe = usb_sndctrlpipe (udev, 0); 931 pipe = usb_sndctrlpipe(udev, 0);
929 expected = EPIPE; 932 expected = EPIPE;
930 break; 933 break;
931 case 9: // get endpoint status 934 case 9: /* get endpoint status */
932 req.bRequest = USB_REQ_GET_STATUS; 935 req.bRequest = USB_REQ_GET_STATUS;
933 req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; 936 req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT;
934 // endpoint 0 937 /* endpoint 0 */
935 len = 2; 938 len = 2;
936 break; 939 break;
937 case 10: // trigger short read (EREMOTEIO) 940 case 10: /* trigger short read (EREMOTEIO) */
938 req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); 941 req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
939 len = 1024; 942 len = 1024;
940 expected = -EREMOTEIO; 943 expected = -EREMOTEIO;
941 break; 944 break;
942 // NOTE: two consecutive _different_ faults in the queue. 945 /* NOTE: two consecutive _different_ faults in the queue. */
943 case 11: // get endpoint descriptor (ALWAYS STALLS) 946 case 11: /* get endpoint descriptor (ALWAYS STALLS) */
944 req.wValue = cpu_to_le16 (USB_DT_ENDPOINT << 8); 947 req.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8);
945 // endpoint == 0 948 /* endpoint == 0 */
946 len = sizeof (struct usb_interface_descriptor); 949 len = sizeof(struct usb_interface_descriptor);
947 expected = EPIPE; 950 expected = EPIPE;
948 break; 951 break;
949 // NOTE: sometimes even a third fault in the queue! 952 /* NOTE: sometimes even a third fault in the queue! */
950 case 12: // get string 0 descriptor (MAY STALL) 953 case 12: /* get string 0 descriptor (MAY STALL) */
951 req.wValue = cpu_to_le16 (USB_DT_STRING << 8); 954 req.wValue = cpu_to_le16(USB_DT_STRING << 8);
952 // string == 0, for language IDs 955 /* string == 0, for language IDs */
953 len = sizeof (struct usb_interface_descriptor); 956 len = sizeof(struct usb_interface_descriptor);
954 // may succeed when > 4 languages 957 /* may succeed when > 4 languages */
955 expected = EREMOTEIO; // or EPIPE, if no strings 958 expected = EREMOTEIO; /* or EPIPE, if no strings */
956 break; 959 break;
957 case 13: // short read, resembling case 10 960 case 13: /* short read, resembling case 10 */
958 req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); 961 req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
959 // last data packet "should" be DATA1, not DATA0 962 /* last data packet "should" be DATA1, not DATA0 */
960 len = 1024 - udev->descriptor.bMaxPacketSize0; 963 len = 1024 - udev->descriptor.bMaxPacketSize0;
961 expected = -EREMOTEIO; 964 expected = -EREMOTEIO;
962 break; 965 break;
963 case 14: // short read; try to fill the last packet 966 case 14: /* short read; try to fill the last packet */
964 req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0); 967 req.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0);
965 /* device descriptor size == 18 bytes */ 968 /* device descriptor size == 18 bytes */
966 len = udev->descriptor.bMaxPacketSize0; 969 len = udev->descriptor.bMaxPacketSize0;
967 switch (len) { 970 switch (len) {
968 case 8: len = 24; break; 971 case 8:
969 case 16: len = 32; break; 972 len = 24;
973 break;
974 case 16:
975 len = 32;
976 break;
970 } 977 }
971 expected = -EREMOTEIO; 978 expected = -EREMOTEIO;
972 break; 979 break;
@@ -975,8 +982,8 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
975 context.status = -EINVAL; 982 context.status = -EINVAL;
976 goto cleanup; 983 goto cleanup;
977 } 984 }
978 req.wLength = cpu_to_le16 (len); 985 req.wLength = cpu_to_le16(len);
979 urb [i] = u = simple_alloc_urb (udev, pipe, len); 986 urb[i] = u = simple_alloc_urb(udev, pipe, len);
980 if (!u) 987 if (!u)
981 goto cleanup; 988 goto cleanup;
982 989
@@ -994,9 +1001,9 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
994 1001
995 /* queue the urbs */ 1002 /* queue the urbs */
996 context.urb = urb; 1003 context.urb = urb;
997 spin_lock_irq (&context.lock); 1004 spin_lock_irq(&context.lock);
998 for (i = 0; i < param->sglen; i++) { 1005 for (i = 0; i < param->sglen; i++) {
999 context.status = usb_submit_urb (urb [i], GFP_ATOMIC); 1006 context.status = usb_submit_urb(urb[i], GFP_ATOMIC);
1000 if (context.status != 0) { 1007 if (context.status != 0) {
1001 ERROR(dev, "can't submit urb[%d], status %d\n", 1008 ERROR(dev, "can't submit urb[%d], status %d\n",
1002 i, context.status); 1009 i, context.status);
@@ -1005,23 +1012,23 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
1005 } 1012 }
1006 context.pending++; 1013 context.pending++;
1007 } 1014 }
1008 spin_unlock_irq (&context.lock); 1015 spin_unlock_irq(&context.lock);
1009 1016
1010 /* FIXME set timer and time out; provide a disconnect hook */ 1017 /* FIXME set timer and time out; provide a disconnect hook */
1011 1018
1012 /* wait for the last one to complete */ 1019 /* wait for the last one to complete */
1013 if (context.pending > 0) 1020 if (context.pending > 0)
1014 wait_for_completion (&context.complete); 1021 wait_for_completion(&context.complete);
1015 1022
1016cleanup: 1023cleanup:
1017 for (i = 0; i < param->sglen; i++) { 1024 for (i = 0; i < param->sglen; i++) {
1018 if (!urb [i]) 1025 if (!urb[i])
1019 continue; 1026 continue;
1020 urb [i]->dev = udev; 1027 urb[i]->dev = udev;
1021 kfree(urb[i]->setup_packet); 1028 kfree(urb[i]->setup_packet);
1022 simple_free_urb (urb [i]); 1029 simple_free_urb(urb[i]);
1023 } 1030 }
1024 kfree (urb); 1031 kfree(urb);
1025 return context.status; 1032 return context.status;
1026} 1033}
1027#undef NUM_SUBCASES 1034#undef NUM_SUBCASES
@@ -1029,27 +1036,27 @@ cleanup:
1029 1036
1030/*-------------------------------------------------------------------------*/ 1037/*-------------------------------------------------------------------------*/
1031 1038
1032static void unlink1_callback (struct urb *urb) 1039static void unlink1_callback(struct urb *urb)
1033{ 1040{
1034 int status = urb->status; 1041 int status = urb->status;
1035 1042
1036 // we "know" -EPIPE (stall) never happens 1043 /* we "know" -EPIPE (stall) never happens */
1037 if (!status) 1044 if (!status)
1038 status = usb_submit_urb (urb, GFP_ATOMIC); 1045 status = usb_submit_urb(urb, GFP_ATOMIC);
1039 if (status) { 1046 if (status) {
1040 urb->status = status; 1047 urb->status = status;
1041 complete(urb->context); 1048 complete(urb->context);
1042 } 1049 }
1043} 1050}
1044 1051
1045static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) 1052static int unlink1(struct usbtest_dev *dev, int pipe, int size, int async)
1046{ 1053{
1047 struct urb *urb; 1054 struct urb *urb;
1048 struct completion completion; 1055 struct completion completion;
1049 int retval = 0; 1056 int retval = 0;
1050 1057
1051 init_completion (&completion); 1058 init_completion(&completion);
1052 urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size); 1059 urb = simple_alloc_urb(testdev_to_usbdev(dev), pipe, size);
1053 if (!urb) 1060 if (!urb)
1054 return -ENOMEM; 1061 return -ENOMEM;
1055 urb->context = &completion; 1062 urb->context = &completion;
@@ -1061,7 +1068,8 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1061 * FIXME want additional tests for when endpoint is STALLing 1068 * FIXME want additional tests for when endpoint is STALLing
1062 * due to errors, or is just NAKing requests. 1069 * due to errors, or is just NAKing requests.
1063 */ 1070 */
1064 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { 1071 retval = usb_submit_urb(urb, GFP_KERNEL);
1072 if (retval != 0) {
1065 dev_err(&dev->intf->dev, "submit fail %d\n", retval); 1073 dev_err(&dev->intf->dev, "submit fail %d\n", retval);
1066 return retval; 1074 return retval;
1067 } 1075 }
@@ -1069,7 +1077,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1069 /* unlinking that should always work. variable delay tests more 1077 /* unlinking that should always work. variable delay tests more
1070 * hcd states and code paths, even with little other system load. 1078 * hcd states and code paths, even with little other system load.
1071 */ 1079 */
1072 msleep (jiffies % (2 * INTERRUPT_RATE)); 1080 msleep(jiffies % (2 * INTERRUPT_RATE));
1073 if (async) { 1081 if (async) {
1074 while (!completion_done(&completion)) { 1082 while (!completion_done(&completion)) {
1075 retval = usb_unlink_urb(urb); 1083 retval = usb_unlink_urb(urb);
@@ -1098,11 +1106,11 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1098 break; 1106 break;
1099 } 1107 }
1100 } else 1108 } else
1101 usb_kill_urb (urb); 1109 usb_kill_urb(urb);
1102 1110
1103 wait_for_completion (&completion); 1111 wait_for_completion(&completion);
1104 retval = urb->status; 1112 retval = urb->status;
1105 simple_free_urb (urb); 1113 simple_free_urb(urb);
1106 1114
1107 if (async) 1115 if (async)
1108 return (retval == -ECONNRESET) ? 0 : retval - 1000; 1116 return (retval == -ECONNRESET) ? 0 : retval - 1000;
@@ -1111,14 +1119,14 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1111 0 : retval - 2000; 1119 0 : retval - 2000;
1112} 1120}
1113 1121
1114static int unlink_simple (struct usbtest_dev *dev, int pipe, int len) 1122static int unlink_simple(struct usbtest_dev *dev, int pipe, int len)
1115{ 1123{
1116 int retval = 0; 1124 int retval = 0;
1117 1125
1118 /* test sync and async paths */ 1126 /* test sync and async paths */
1119 retval = unlink1 (dev, pipe, len, 1); 1127 retval = unlink1(dev, pipe, len, 1);
1120 if (!retval) 1128 if (!retval)
1121 retval = unlink1 (dev, pipe, len, 0); 1129 retval = unlink1(dev, pipe, len, 0);
1122 return retval; 1130 return retval;
1123} 1131}
1124 1132
@@ -1130,7 +1138,7 @@ static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1130 u16 status; 1138 u16 status;
1131 1139
1132 /* shouldn't look or act halted */ 1140 /* shouldn't look or act halted */
1133 retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); 1141 retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1134 if (retval < 0) { 1142 if (retval < 0) {
1135 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", 1143 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n",
1136 ep, retval); 1144 ep, retval);
@@ -1152,7 +1160,7 @@ static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1152 u16 status; 1160 u16 status;
1153 1161
1154 /* should look and act halted */ 1162 /* should look and act halted */
1155 retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); 1163 retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1156 if (retval < 0) { 1164 if (retval < 0) {
1157 ERROR(tdev, "ep %02x couldn't get halt status, %d\n", 1165 ERROR(tdev, "ep %02x couldn't get halt status, %d\n",
1158 ep, retval); 1166 ep, retval);
@@ -1182,7 +1190,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
1182 return retval; 1190 return retval;
1183 1191
1184 /* set halt (protocol test only), verify it worked */ 1192 /* set halt (protocol test only), verify it worked */
1185 retval = usb_control_msg (urb->dev, usb_sndctrlpipe (urb->dev, 0), 1193 retval = usb_control_msg(urb->dev, usb_sndctrlpipe(urb->dev, 0),
1186 USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, 1194 USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
1187 USB_ENDPOINT_HALT, ep, 1195 USB_ENDPOINT_HALT, ep,
1188 NULL, 0, USB_CTRL_SET_TIMEOUT); 1196 NULL, 0, USB_CTRL_SET_TIMEOUT);
@@ -1195,7 +1203,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
1195 return retval; 1203 return retval;
1196 1204
1197 /* clear halt (tests API + protocol), verify it worked */ 1205 /* clear halt (tests API + protocol), verify it worked */
1198 retval = usb_clear_halt (urb->dev, urb->pipe); 1206 retval = usb_clear_halt(urb->dev, urb->pipe);
1199 if (retval < 0) { 1207 if (retval < 0) {
1200 ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval); 1208 ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval);
1201 return retval; 1209 return retval;
@@ -1209,18 +1217,18 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
1209 return 0; 1217 return 0;
1210} 1218}
1211 1219
1212static int halt_simple (struct usbtest_dev *dev) 1220static int halt_simple(struct usbtest_dev *dev)
1213{ 1221{
1214 int ep; 1222 int ep;
1215 int retval = 0; 1223 int retval = 0;
1216 struct urb *urb; 1224 struct urb *urb;
1217 1225
1218 urb = simple_alloc_urb (testdev_to_usbdev (dev), 0, 512); 1226 urb = simple_alloc_urb(testdev_to_usbdev(dev), 0, 512);
1219 if (urb == NULL) 1227 if (urb == NULL)
1220 return -ENOMEM; 1228 return -ENOMEM;
1221 1229
1222 if (dev->in_pipe) { 1230 if (dev->in_pipe) {
1223 ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN; 1231 ep = usb_pipeendpoint(dev->in_pipe) | USB_DIR_IN;
1224 urb->pipe = dev->in_pipe; 1232 urb->pipe = dev->in_pipe;
1225 retval = test_halt(dev, ep, urb); 1233 retval = test_halt(dev, ep, urb);
1226 if (retval < 0) 1234 if (retval < 0)
@@ -1228,12 +1236,12 @@ static int halt_simple (struct usbtest_dev *dev)
1228 } 1236 }
1229 1237
1230 if (dev->out_pipe) { 1238 if (dev->out_pipe) {
1231 ep = usb_pipeendpoint (dev->out_pipe); 1239 ep = usb_pipeendpoint(dev->out_pipe);
1232 urb->pipe = dev->out_pipe; 1240 urb->pipe = dev->out_pipe;
1233 retval = test_halt(dev, ep, urb); 1241 retval = test_halt(dev, ep, urb);
1234 } 1242 }
1235done: 1243done:
1236 simple_free_urb (urb); 1244 simple_free_urb(urb);
1237 return retval; 1245 return retval;
1238} 1246}
1239 1247
@@ -1247,7 +1255,7 @@ done:
1247 * need to be able to handle more than one OUT data packet. We'll 1255 * need to be able to handle more than one OUT data packet. We'll
1248 * try whatever we're told to try. 1256 * try whatever we're told to try.
1249 */ 1257 */
1250static int ctrl_out (struct usbtest_dev *dev, 1258static int ctrl_out(struct usbtest_dev *dev,
1251 unsigned count, unsigned length, unsigned vary) 1259 unsigned count, unsigned length, unsigned vary)
1252{ 1260{
1253 unsigned i, j, len; 1261 unsigned i, j, len;
@@ -1263,7 +1271,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1263 if (!buf) 1271 if (!buf)
1264 return -ENOMEM; 1272 return -ENOMEM;
1265 1273
1266 udev = testdev_to_usbdev (dev); 1274 udev = testdev_to_usbdev(dev);
1267 len = length; 1275 len = length;
1268 retval = 0; 1276 retval = 0;
1269 1277
@@ -1273,8 +1281,8 @@ static int ctrl_out (struct usbtest_dev *dev,
1273 for (i = 0; i < count; i++) { 1281 for (i = 0; i < count; i++) {
1274 /* write patterned data */ 1282 /* write patterned data */
1275 for (j = 0; j < len; j++) 1283 for (j = 0; j < len; j++)
1276 buf [j] = i + j; 1284 buf[j] = i + j;
1277 retval = usb_control_msg (udev, usb_sndctrlpipe (udev,0), 1285 retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1278 0x5b, USB_DIR_OUT|USB_TYPE_VENDOR, 1286 0x5b, USB_DIR_OUT|USB_TYPE_VENDOR,
1279 0, 0, buf, len, USB_CTRL_SET_TIMEOUT); 1287 0, 0, buf, len, USB_CTRL_SET_TIMEOUT);
1280 if (retval != len) { 1288 if (retval != len) {
@@ -1288,7 +1296,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1288 } 1296 }
1289 1297
1290 /* read it back -- assuming nothing intervened!! */ 1298 /* read it back -- assuming nothing intervened!! */
1291 retval = usb_control_msg (udev, usb_rcvctrlpipe (udev,0), 1299 retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
1292 0x5c, USB_DIR_IN|USB_TYPE_VENDOR, 1300 0x5c, USB_DIR_IN|USB_TYPE_VENDOR,
1293 0, 0, buf, len, USB_CTRL_GET_TIMEOUT); 1301 0, 0, buf, len, USB_CTRL_GET_TIMEOUT);
1294 if (retval != len) { 1302 if (retval != len) {
@@ -1303,9 +1311,9 @@ static int ctrl_out (struct usbtest_dev *dev,
1303 1311
1304 /* fail if we can't verify */ 1312 /* fail if we can't verify */
1305 for (j = 0; j < len; j++) { 1313 for (j = 0; j < len; j++) {
1306 if (buf [j] != (u8) (i + j)) { 1314 if (buf[j] != (u8) (i + j)) {
1307 ERROR(dev, "ctrl_out, byte %d is %d not %d\n", 1315 ERROR(dev, "ctrl_out, byte %d is %d not %d\n",
1308 j, buf [j], (u8) i + j); 1316 j, buf[j], (u8) i + j);
1309 retval = -EBADMSG; 1317 retval = -EBADMSG;
1310 break; 1318 break;
1311 } 1319 }
@@ -1326,10 +1334,10 @@ static int ctrl_out (struct usbtest_dev *dev,
1326 } 1334 }
1327 1335
1328 if (retval < 0) 1336 if (retval < 0)
1329 ERROR (dev, "ctrl_out %s failed, code %d, count %d\n", 1337 ERROR(dev, "ctrl_out %s failed, code %d, count %d\n",
1330 what, retval, i); 1338 what, retval, i);
1331 1339
1332 kfree (buf); 1340 kfree(buf);
1333 return retval; 1341 return retval;
1334} 1342}
1335 1343
@@ -1351,7 +1359,7 @@ struct iso_context {
1351 struct usbtest_dev *dev; 1359 struct usbtest_dev *dev;
1352}; 1360};
1353 1361
1354static void iso_callback (struct urb *urb) 1362static void iso_callback(struct urb *urb)
1355{ 1363{
1356 struct iso_context *ctx = urb->context; 1364 struct iso_context *ctx = urb->context;
1357 1365
@@ -1363,10 +1371,12 @@ static void iso_callback (struct urb *urb)
1363 ctx->errors += urb->error_count; 1371 ctx->errors += urb->error_count;
1364 else if (urb->status != 0) 1372 else if (urb->status != 0)
1365 ctx->errors += urb->number_of_packets; 1373 ctx->errors += urb->number_of_packets;
1374 else if (urb->actual_length != urb->transfer_buffer_length)
1375 ctx->errors++;
1366 1376
1367 if (urb->status == 0 && ctx->count > (ctx->pending - 1) 1377 if (urb->status == 0 && ctx->count > (ctx->pending - 1)
1368 && !ctx->submit_error) { 1378 && !ctx->submit_error) {
1369 int status = usb_submit_urb (urb, GFP_ATOMIC); 1379 int status = usb_submit_urb(urb, GFP_ATOMIC);
1370 switch (status) { 1380 switch (status) {
1371 case 0: 1381 case 0:
1372 goto done; 1382 goto done;
@@ -1388,13 +1398,13 @@ static void iso_callback (struct urb *urb)
1388 dev_err(&ctx->dev->intf->dev, 1398 dev_err(&ctx->dev->intf->dev,
1389 "iso test, %lu errors out of %lu\n", 1399 "iso test, %lu errors out of %lu\n",
1390 ctx->errors, ctx->packet_count); 1400 ctx->errors, ctx->packet_count);
1391 complete (&ctx->done); 1401 complete(&ctx->done);
1392 } 1402 }
1393done: 1403done:
1394 spin_unlock(&ctx->lock); 1404 spin_unlock(&ctx->lock);
1395} 1405}
1396 1406
1397static struct urb *iso_alloc_urb ( 1407static struct urb *iso_alloc_urb(
1398 struct usb_device *udev, 1408 struct usb_device *udev,
1399 int pipe, 1409 int pipe,
1400 struct usb_endpoint_descriptor *desc, 1410 struct usb_endpoint_descriptor *desc,
@@ -1410,7 +1420,7 @@ static struct urb *iso_alloc_urb (
1410 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); 1420 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
1411 packets = DIV_ROUND_UP(bytes, maxp); 1421 packets = DIV_ROUND_UP(bytes, maxp);
1412 1422
1413 urb = usb_alloc_urb (packets, GFP_KERNEL); 1423 urb = usb_alloc_urb(packets, GFP_KERNEL);
1414 if (!urb) 1424 if (!urb)
1415 return urb; 1425 return urb;
1416 urb->dev = udev; 1426 urb->dev = udev;
@@ -1418,30 +1428,30 @@ static struct urb *iso_alloc_urb (
1418 1428
1419 urb->number_of_packets = packets; 1429 urb->number_of_packets = packets;
1420 urb->transfer_buffer_length = bytes; 1430 urb->transfer_buffer_length = bytes;
1421 urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, 1431 urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL,
1422 &urb->transfer_dma); 1432 &urb->transfer_dma);
1423 if (!urb->transfer_buffer) { 1433 if (!urb->transfer_buffer) {
1424 usb_free_urb (urb); 1434 usb_free_urb(urb);
1425 return NULL; 1435 return NULL;
1426 } 1436 }
1427 memset (urb->transfer_buffer, 0, bytes); 1437 memset(urb->transfer_buffer, 0, bytes);
1428 for (i = 0; i < packets; i++) { 1438 for (i = 0; i < packets; i++) {
1429 /* here, only the last packet will be short */ 1439 /* here, only the last packet will be short */
1430 urb->iso_frame_desc[i].length = min ((unsigned) bytes, maxp); 1440 urb->iso_frame_desc[i].length = min((unsigned) bytes, maxp);
1431 bytes -= urb->iso_frame_desc[i].length; 1441 bytes -= urb->iso_frame_desc[i].length;
1432 1442
1433 urb->iso_frame_desc[i].offset = maxp * i; 1443 urb->iso_frame_desc[i].offset = maxp * i;
1434 } 1444 }
1435 1445
1436 urb->complete = iso_callback; 1446 urb->complete = iso_callback;
1437 // urb->context = SET BY CALLER 1447 /* urb->context = SET BY CALLER */
1438 urb->interval = 1 << (desc->bInterval - 1); 1448 urb->interval = 1 << (desc->bInterval - 1);
1439 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; 1449 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
1440 return urb; 1450 return urb;
1441} 1451}
1442 1452
1443static int 1453static int
1444test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, 1454test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param,
1445 int pipe, struct usb_endpoint_descriptor *desc) 1455 int pipe, struct usb_endpoint_descriptor *desc)
1446{ 1456{
1447 struct iso_context context; 1457 struct iso_context context;
@@ -1457,11 +1467,11 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1457 memset(&context, 0, sizeof context); 1467 memset(&context, 0, sizeof context);
1458 context.count = param->iterations * param->sglen; 1468 context.count = param->iterations * param->sglen;
1459 context.dev = dev; 1469 context.dev = dev;
1460 init_completion (&context.done); 1470 init_completion(&context.done);
1461 spin_lock_init (&context.lock); 1471 spin_lock_init(&context.lock);
1462 1472
1463 memset (urbs, 0, sizeof urbs); 1473 memset(urbs, 0, sizeof urbs);
1464 udev = testdev_to_usbdev (dev); 1474 udev = testdev_to_usbdev(dev);
1465 dev_info(&dev->intf->dev, 1475 dev_info(&dev->intf->dev,
1466 "... iso period %d %sframes, wMaxPacket %04x\n", 1476 "... iso period %d %sframes, wMaxPacket %04x\n",
1467 1 << (desc->bInterval - 1), 1477 1 << (desc->bInterval - 1),
@@ -1469,14 +1479,14 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1469 le16_to_cpu(desc->wMaxPacketSize)); 1479 le16_to_cpu(desc->wMaxPacketSize));
1470 1480
1471 for (i = 0; i < param->sglen; i++) { 1481 for (i = 0; i < param->sglen; i++) {
1472 urbs [i] = iso_alloc_urb (udev, pipe, desc, 1482 urbs[i] = iso_alloc_urb(udev, pipe, desc,
1473 param->length); 1483 param->length);
1474 if (!urbs [i]) { 1484 if (!urbs[i]) {
1475 status = -ENOMEM; 1485 status = -ENOMEM;
1476 goto fail; 1486 goto fail;
1477 } 1487 }
1478 packets += urbs[i]->number_of_packets; 1488 packets += urbs[i]->number_of_packets;
1479 urbs [i]->context = &context; 1489 urbs[i]->context = &context;
1480 } 1490 }
1481 packets *= param->iterations; 1491 packets *= param->iterations;
1482 dev_info(&dev->intf->dev, 1492 dev_info(&dev->intf->dev,
@@ -1485,27 +1495,27 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1485 / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), 1495 / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1),
1486 packets); 1496 packets);
1487 1497
1488 spin_lock_irq (&context.lock); 1498 spin_lock_irq(&context.lock);
1489 for (i = 0; i < param->sglen; i++) { 1499 for (i = 0; i < param->sglen; i++) {
1490 ++context.pending; 1500 ++context.pending;
1491 status = usb_submit_urb (urbs [i], GFP_ATOMIC); 1501 status = usb_submit_urb(urbs[i], GFP_ATOMIC);
1492 if (status < 0) { 1502 if (status < 0) {
1493 ERROR (dev, "submit iso[%d], error %d\n", i, status); 1503 ERROR(dev, "submit iso[%d], error %d\n", i, status);
1494 if (i == 0) { 1504 if (i == 0) {
1495 spin_unlock_irq (&context.lock); 1505 spin_unlock_irq(&context.lock);
1496 goto fail; 1506 goto fail;
1497 } 1507 }
1498 1508
1499 simple_free_urb (urbs [i]); 1509 simple_free_urb(urbs[i]);
1500 urbs[i] = NULL; 1510 urbs[i] = NULL;
1501 context.pending--; 1511 context.pending--;
1502 context.submit_error = 1; 1512 context.submit_error = 1;
1503 break; 1513 break;
1504 } 1514 }
1505 } 1515 }
1506 spin_unlock_irq (&context.lock); 1516 spin_unlock_irq(&context.lock);
1507 1517
1508 wait_for_completion (&context.done); 1518 wait_for_completion(&context.done);
1509 1519
1510 for (i = 0; i < param->sglen; i++) { 1520 for (i = 0; i < param->sglen; i++) {
1511 if (urbs[i]) 1521 if (urbs[i])
@@ -1526,8 +1536,8 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1526 1536
1527fail: 1537fail:
1528 for (i = 0; i < param->sglen; i++) { 1538 for (i = 0; i < param->sglen; i++) {
1529 if (urbs [i]) 1539 if (urbs[i])
1530 simple_free_urb (urbs [i]); 1540 simple_free_urb(urbs[i]);
1531 } 1541 }
1532 return status; 1542 return status;
1533} 1543}
@@ -1557,10 +1567,10 @@ fail:
1557 1567
1558/* No BKL needed */ 1568/* No BKL needed */
1559static int 1569static int
1560usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) 1570usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
1561{ 1571{
1562 struct usbtest_dev *dev = usb_get_intfdata (intf); 1572 struct usbtest_dev *dev = usb_get_intfdata(intf);
1563 struct usb_device *udev = testdev_to_usbdev (dev); 1573 struct usb_device *udev = testdev_to_usbdev(dev);
1564 struct usbtest_param *param = buf; 1574 struct usbtest_param *param = buf;
1565 int retval = -EOPNOTSUPP; 1575 int retval = -EOPNOTSUPP;
1566 struct urb *urb; 1576 struct urb *urb;
@@ -1569,7 +1579,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1569 struct timeval start; 1579 struct timeval start;
1570 unsigned i; 1580 unsigned i;
1571 1581
1572 // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. 1582 /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
1573 1583
1574 pattern = mod_pattern; 1584 pattern = mod_pattern;
1575 1585
@@ -1595,9 +1605,9 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1595 mutex_unlock(&dev->lock); 1605 mutex_unlock(&dev->lock);
1596 return -ENODEV; 1606 return -ENODEV;
1597 } 1607 }
1598 res = set_altsetting (dev, dev->info->alt); 1608 res = set_altsetting(dev, dev->info->alt);
1599 if (res) { 1609 if (res) {
1600 dev_err (&intf->dev, 1610 dev_err(&intf->dev,
1601 "set altsetting to %d failed, %d\n", 1611 "set altsetting to %d failed, %d\n",
1602 dev->info->alt, res); 1612 dev->info->alt, res);
1603 mutex_unlock(&dev->lock); 1613 mutex_unlock(&dev->lock);
@@ -1614,7 +1624,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1614 * FIXME add more tests! cancel requests, verify the data, control 1624 * FIXME add more tests! cancel requests, verify the data, control
1615 * queueing, concurrent read+write threads, and so on. 1625 * queueing, concurrent read+write threads, and so on.
1616 */ 1626 */
1617 do_gettimeofday (&start); 1627 do_gettimeofday(&start);
1618 switch (param->test_num) { 1628 switch (param->test_num) {
1619 1629
1620 case 0: 1630 case 0:
@@ -1629,14 +1639,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1629 dev_info(&intf->dev, 1639 dev_info(&intf->dev,
1630 "TEST 1: write %d bytes %u times\n", 1640 "TEST 1: write %d bytes %u times\n",
1631 param->length, param->iterations); 1641 param->length, param->iterations);
1632 urb = simple_alloc_urb (udev, dev->out_pipe, param->length); 1642 urb = simple_alloc_urb(udev, dev->out_pipe, param->length);
1633 if (!urb) { 1643 if (!urb) {
1634 retval = -ENOMEM; 1644 retval = -ENOMEM;
1635 break; 1645 break;
1636 } 1646 }
1637 // FIRMWARE: bulk sink (maybe accepts short writes) 1647 /* FIRMWARE: bulk sink (maybe accepts short writes) */
1638 retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); 1648 retval = simple_io(dev, urb, param->iterations, 0, 0, "test1");
1639 simple_free_urb (urb); 1649 simple_free_urb(urb);
1640 break; 1650 break;
1641 case 2: 1651 case 2:
1642 if (dev->in_pipe == 0) 1652 if (dev->in_pipe == 0)
@@ -1644,14 +1654,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1644 dev_info(&intf->dev, 1654 dev_info(&intf->dev,
1645 "TEST 2: read %d bytes %u times\n", 1655 "TEST 2: read %d bytes %u times\n",
1646 param->length, param->iterations); 1656 param->length, param->iterations);
1647 urb = simple_alloc_urb (udev, dev->in_pipe, param->length); 1657 urb = simple_alloc_urb(udev, dev->in_pipe, param->length);
1648 if (!urb) { 1658 if (!urb) {
1649 retval = -ENOMEM; 1659 retval = -ENOMEM;
1650 break; 1660 break;
1651 } 1661 }
1652 // FIRMWARE: bulk source (maybe generates short writes) 1662 /* FIRMWARE: bulk source (maybe generates short writes) */
1653 retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); 1663 retval = simple_io(dev, urb, param->iterations, 0, 0, "test2");
1654 simple_free_urb (urb); 1664 simple_free_urb(urb);
1655 break; 1665 break;
1656 case 3: 1666 case 3:
1657 if (dev->out_pipe == 0 || param->vary == 0) 1667 if (dev->out_pipe == 0 || param->vary == 0)
@@ -1659,15 +1669,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1659 dev_info(&intf->dev, 1669 dev_info(&intf->dev,
1660 "TEST 3: write/%d 0..%d bytes %u times\n", 1670 "TEST 3: write/%d 0..%d bytes %u times\n",
1661 param->vary, param->length, param->iterations); 1671 param->vary, param->length, param->iterations);
1662 urb = simple_alloc_urb (udev, dev->out_pipe, param->length); 1672 urb = simple_alloc_urb(udev, dev->out_pipe, param->length);
1663 if (!urb) { 1673 if (!urb) {
1664 retval = -ENOMEM; 1674 retval = -ENOMEM;
1665 break; 1675 break;
1666 } 1676 }
1667 // FIRMWARE: bulk sink (maybe accepts short writes) 1677 /* FIRMWARE: bulk sink (maybe accepts short writes) */
1668 retval = simple_io(dev, urb, param->iterations, param->vary, 1678 retval = simple_io(dev, urb, param->iterations, param->vary,
1669 0, "test3"); 1679 0, "test3");
1670 simple_free_urb (urb); 1680 simple_free_urb(urb);
1671 break; 1681 break;
1672 case 4: 1682 case 4:
1673 if (dev->in_pipe == 0 || param->vary == 0) 1683 if (dev->in_pipe == 0 || param->vary == 0)
@@ -1675,15 +1685,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1675 dev_info(&intf->dev, 1685 dev_info(&intf->dev,
1676 "TEST 4: read/%d 0..%d bytes %u times\n", 1686 "TEST 4: read/%d 0..%d bytes %u times\n",
1677 param->vary, param->length, param->iterations); 1687 param->vary, param->length, param->iterations);
1678 urb = simple_alloc_urb (udev, dev->in_pipe, param->length); 1688 urb = simple_alloc_urb(udev, dev->in_pipe, param->length);
1679 if (!urb) { 1689 if (!urb) {
1680 retval = -ENOMEM; 1690 retval = -ENOMEM;
1681 break; 1691 break;
1682 } 1692 }
1683 // FIRMWARE: bulk source (maybe generates short writes) 1693 /* FIRMWARE: bulk source (maybe generates short writes) */
1684 retval = simple_io(dev, urb, param->iterations, param->vary, 1694 retval = simple_io(dev, urb, param->iterations, param->vary,
1685 0, "test4"); 1695 0, "test4");
1686 simple_free_urb (urb); 1696 simple_free_urb(urb);
1687 break; 1697 break;
1688 1698
1689 /* Queued bulk I/O tests */ 1699 /* Queued bulk I/O tests */
@@ -1694,15 +1704,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1694 "TEST 5: write %d sglists %d entries of %d bytes\n", 1704 "TEST 5: write %d sglists %d entries of %d bytes\n",
1695 param->iterations, 1705 param->iterations,
1696 param->sglen, param->length); 1706 param->sglen, param->length);
1697 sg = alloc_sglist (param->sglen, param->length, 0); 1707 sg = alloc_sglist(param->sglen, param->length, 0);
1698 if (!sg) { 1708 if (!sg) {
1699 retval = -ENOMEM; 1709 retval = -ENOMEM;
1700 break; 1710 break;
1701 } 1711 }
1702 // FIRMWARE: bulk sink (maybe accepts short writes) 1712 /* FIRMWARE: bulk sink (maybe accepts short writes) */
1703 retval = perform_sglist(dev, param->iterations, dev->out_pipe, 1713 retval = perform_sglist(dev, param->iterations, dev->out_pipe,
1704 &req, sg, param->sglen); 1714 &req, sg, param->sglen);
1705 free_sglist (sg, param->sglen); 1715 free_sglist(sg, param->sglen);
1706 break; 1716 break;
1707 1717
1708 case 6: 1718 case 6:
@@ -1712,15 +1722,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1712 "TEST 6: read %d sglists %d entries of %d bytes\n", 1722 "TEST 6: read %d sglists %d entries of %d bytes\n",
1713 param->iterations, 1723 param->iterations,
1714 param->sglen, param->length); 1724 param->sglen, param->length);
1715 sg = alloc_sglist (param->sglen, param->length, 0); 1725 sg = alloc_sglist(param->sglen, param->length, 0);
1716 if (!sg) { 1726 if (!sg) {
1717 retval = -ENOMEM; 1727 retval = -ENOMEM;
1718 break; 1728 break;
1719 } 1729 }
1720 // FIRMWARE: bulk source (maybe generates short writes) 1730 /* FIRMWARE: bulk source (maybe generates short writes) */
1721 retval = perform_sglist(dev, param->iterations, dev->in_pipe, 1731 retval = perform_sglist(dev, param->iterations, dev->in_pipe,
1722 &req, sg, param->sglen); 1732 &req, sg, param->sglen);
1723 free_sglist (sg, param->sglen); 1733 free_sglist(sg, param->sglen);
1724 break; 1734 break;
1725 case 7: 1735 case 7:
1726 if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) 1736 if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0)
@@ -1729,15 +1739,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1729 "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", 1739 "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n",
1730 param->vary, param->iterations, 1740 param->vary, param->iterations,
1731 param->sglen, param->length); 1741 param->sglen, param->length);
1732 sg = alloc_sglist (param->sglen, param->length, param->vary); 1742 sg = alloc_sglist(param->sglen, param->length, param->vary);
1733 if (!sg) { 1743 if (!sg) {
1734 retval = -ENOMEM; 1744 retval = -ENOMEM;
1735 break; 1745 break;
1736 } 1746 }
1737 // FIRMWARE: bulk sink (maybe accepts short writes) 1747 /* FIRMWARE: bulk sink (maybe accepts short writes) */
1738 retval = perform_sglist(dev, param->iterations, dev->out_pipe, 1748 retval = perform_sglist(dev, param->iterations, dev->out_pipe,
1739 &req, sg, param->sglen); 1749 &req, sg, param->sglen);
1740 free_sglist (sg, param->sglen); 1750 free_sglist(sg, param->sglen);
1741 break; 1751 break;
1742 case 8: 1752 case 8:
1743 if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) 1753 if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0)
@@ -1746,15 +1756,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1746 "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", 1756 "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n",
1747 param->vary, param->iterations, 1757 param->vary, param->iterations,
1748 param->sglen, param->length); 1758 param->sglen, param->length);
1749 sg = alloc_sglist (param->sglen, param->length, param->vary); 1759 sg = alloc_sglist(param->sglen, param->length, param->vary);
1750 if (!sg) { 1760 if (!sg) {
1751 retval = -ENOMEM; 1761 retval = -ENOMEM;
1752 break; 1762 break;
1753 } 1763 }
1754 // FIRMWARE: bulk source (maybe generates short writes) 1764 /* FIRMWARE: bulk source (maybe generates short writes) */
1755 retval = perform_sglist(dev, param->iterations, dev->in_pipe, 1765 retval = perform_sglist(dev, param->iterations, dev->in_pipe,
1756 &req, sg, param->sglen); 1766 &req, sg, param->sglen);
1757 free_sglist (sg, param->sglen); 1767 free_sglist(sg, param->sglen);
1758 break; 1768 break;
1759 1769
1760 /* non-queued sanity tests for control (chapter 9 subset) */ 1770 /* non-queued sanity tests for control (chapter 9 subset) */
@@ -1764,7 +1774,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1764 "TEST 9: ch9 (subset) control tests, %d times\n", 1774 "TEST 9: ch9 (subset) control tests, %d times\n",
1765 param->iterations); 1775 param->iterations);
1766 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1776 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1767 retval = ch9_postconfig (dev); 1777 retval = ch9_postconfig(dev);
1768 if (retval) 1778 if (retval)
1769 dev_err(&intf->dev, "ch9 subset failed, " 1779 dev_err(&intf->dev, "ch9 subset failed, "
1770 "iterations left %d\n", i); 1780 "iterations left %d\n", i);
@@ -1779,7 +1789,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1779 "TEST 10: queue %d control calls, %d times\n", 1789 "TEST 10: queue %d control calls, %d times\n",
1780 param->sglen, 1790 param->sglen,
1781 param->iterations); 1791 param->iterations);
1782 retval = test_ctrl_queue (dev, param); 1792 retval = test_ctrl_queue(dev, param);
1783 break; 1793 break;
1784 1794
1785 /* simple non-queued unlinks (ring with one urb) */ 1795 /* simple non-queued unlinks (ring with one urb) */
@@ -1790,7 +1800,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1790 dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", 1800 dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n",
1791 param->iterations, param->length); 1801 param->iterations, param->length);
1792 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1802 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1793 retval = unlink_simple (dev, dev->in_pipe, 1803 retval = unlink_simple(dev, dev->in_pipe,
1794 param->length); 1804 param->length);
1795 if (retval) 1805 if (retval)
1796 dev_err(&intf->dev, "unlink reads failed %d, " 1806 dev_err(&intf->dev, "unlink reads failed %d, "
@@ -1803,7 +1813,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1803 dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", 1813 dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n",
1804 param->iterations, param->length); 1814 param->iterations, param->length);
1805 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1815 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1806 retval = unlink_simple (dev, dev->out_pipe, 1816 retval = unlink_simple(dev, dev->out_pipe,
1807 param->length); 1817 param->length);
1808 if (retval) 1818 if (retval)
1809 dev_err(&intf->dev, "unlink writes failed %d, " 1819 dev_err(&intf->dev, "unlink writes failed %d, "
@@ -1818,7 +1828,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1818 dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", 1828 dev_info(&intf->dev, "TEST 13: set/clear %d halts\n",
1819 param->iterations); 1829 param->iterations);
1820 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1830 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1821 retval = halt_simple (dev); 1831 retval = halt_simple(dev);
1822 1832
1823 if (retval) 1833 if (retval)
1824 ERROR(dev, "halts failed, iterations left %d\n", i); 1834 ERROR(dev, "halts failed, iterations left %d\n", i);
@@ -1844,8 +1854,8 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1844 "TEST 15: write %d iso, %d entries of %d bytes\n", 1854 "TEST 15: write %d iso, %d entries of %d bytes\n",
1845 param->iterations, 1855 param->iterations,
1846 param->sglen, param->length); 1856 param->sglen, param->length);
1847 // FIRMWARE: iso sink 1857 /* FIRMWARE: iso sink */
1848 retval = test_iso_queue (dev, param, 1858 retval = test_iso_queue(dev, param,
1849 dev->out_iso_pipe, dev->iso_out); 1859 dev->out_iso_pipe, dev->iso_out);
1850 break; 1860 break;
1851 1861
@@ -1857,17 +1867,17 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1857 "TEST 16: read %d iso, %d entries of %d bytes\n", 1867 "TEST 16: read %d iso, %d entries of %d bytes\n",
1858 param->iterations, 1868 param->iterations,
1859 param->sglen, param->length); 1869 param->sglen, param->length);
1860 // FIRMWARE: iso source 1870 /* FIRMWARE: iso source */
1861 retval = test_iso_queue (dev, param, 1871 retval = test_iso_queue(dev, param,
1862 dev->in_iso_pipe, dev->iso_in); 1872 dev->in_iso_pipe, dev->iso_in);
1863 break; 1873 break;
1864 1874
1865 // FIXME unlink from queue (ring with N urbs) 1875 /* FIXME unlink from queue (ring with N urbs) */
1866 1876
1867 // FIXME scatterlist cancel (needs helper thread) 1877 /* FIXME scatterlist cancel (needs helper thread) */
1868 1878
1869 } 1879 }
1870 do_gettimeofday (&param->duration); 1880 do_gettimeofday(&param->duration);
1871 param->duration.tv_sec -= start.tv_sec; 1881 param->duration.tv_sec -= start.tv_sec;
1872 param->duration.tv_usec -= start.tv_usec; 1882 param->duration.tv_usec -= start.tv_usec;
1873 if (param->duration.tv_usec < 0) { 1883 if (param->duration.tv_usec < 0) {
@@ -1880,22 +1890,22 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1880 1890
1881/*-------------------------------------------------------------------------*/ 1891/*-------------------------------------------------------------------------*/
1882 1892
1883static unsigned force_interrupt = 0; 1893static unsigned force_interrupt;
1884module_param (force_interrupt, uint, 0); 1894module_param(force_interrupt, uint, 0);
1885MODULE_PARM_DESC (force_interrupt, "0 = test default; else interrupt"); 1895MODULE_PARM_DESC(force_interrupt, "0 = test default; else interrupt");
1886 1896
1887#ifdef GENERIC 1897#ifdef GENERIC
1888static unsigned short vendor; 1898static unsigned short vendor;
1889module_param(vendor, ushort, 0); 1899module_param(vendor, ushort, 0);
1890MODULE_PARM_DESC (vendor, "vendor code (from usb-if)"); 1900MODULE_PARM_DESC(vendor, "vendor code (from usb-if)");
1891 1901
1892static unsigned short product; 1902static unsigned short product;
1893module_param(product, ushort, 0); 1903module_param(product, ushort, 0);
1894MODULE_PARM_DESC (product, "product code (from vendor)"); 1904MODULE_PARM_DESC(product, "product code (from vendor)");
1895#endif 1905#endif
1896 1906
1897static int 1907static int
1898usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) 1908usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id)
1899{ 1909{
1900 struct usb_device *udev; 1910 struct usb_device *udev;
1901 struct usbtest_dev *dev; 1911 struct usbtest_dev *dev;
@@ -1903,7 +1913,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1903 char *rtest, *wtest; 1913 char *rtest, *wtest;
1904 char *irtest, *iwtest; 1914 char *irtest, *iwtest;
1905 1915
1906 udev = interface_to_usbdev (intf); 1916 udev = interface_to_usbdev(intf);
1907 1917
1908#ifdef GENERIC 1918#ifdef GENERIC
1909 /* specify devices by module parameters? */ 1919 /* specify devices by module parameters? */
@@ -1930,8 +1940,9 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1930 dev->intf = intf; 1940 dev->intf = intf;
1931 1941
1932 /* cacheline-aligned scratch for i/o */ 1942 /* cacheline-aligned scratch for i/o */
1933 if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) { 1943 dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL);
1934 kfree (dev); 1944 if (dev->buf == NULL) {
1945 kfree(dev);
1935 return -ENOMEM; 1946 return -ENOMEM;
1936 } 1947 }
1937 1948
@@ -1943,18 +1954,18 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1943 irtest = iwtest = ""; 1954 irtest = iwtest = "";
1944 if (force_interrupt || udev->speed == USB_SPEED_LOW) { 1955 if (force_interrupt || udev->speed == USB_SPEED_LOW) {
1945 if (info->ep_in) { 1956 if (info->ep_in) {
1946 dev->in_pipe = usb_rcvintpipe (udev, info->ep_in); 1957 dev->in_pipe = usb_rcvintpipe(udev, info->ep_in);
1947 rtest = " intr-in"; 1958 rtest = " intr-in";
1948 } 1959 }
1949 if (info->ep_out) { 1960 if (info->ep_out) {
1950 dev->out_pipe = usb_sndintpipe (udev, info->ep_out); 1961 dev->out_pipe = usb_sndintpipe(udev, info->ep_out);
1951 wtest = " intr-out"; 1962 wtest = " intr-out";
1952 } 1963 }
1953 } else { 1964 } else {
1954 if (info->autoconf) { 1965 if (info->autoconf) {
1955 int status; 1966 int status;
1956 1967
1957 status = get_endpoints (dev, intf); 1968 status = get_endpoints(dev, intf);
1958 if (status < 0) { 1969 if (status < 0) {
1959 WARNING(dev, "couldn't get endpoints, %d\n", 1970 WARNING(dev, "couldn't get endpoints, %d\n",
1960 status); 1971 status);
@@ -1963,10 +1974,10 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1963 /* may find bulk or ISO pipes */ 1974 /* may find bulk or ISO pipes */
1964 } else { 1975 } else {
1965 if (info->ep_in) 1976 if (info->ep_in)
1966 dev->in_pipe = usb_rcvbulkpipe (udev, 1977 dev->in_pipe = usb_rcvbulkpipe(udev,
1967 info->ep_in); 1978 info->ep_in);
1968 if (info->ep_out) 1979 if (info->ep_out)
1969 dev->out_pipe = usb_sndbulkpipe (udev, 1980 dev->out_pipe = usb_sndbulkpipe(udev,
1970 info->ep_out); 1981 info->ep_out);
1971 } 1982 }
1972 if (dev->in_pipe) 1983 if (dev->in_pipe)
@@ -1979,15 +1990,23 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1979 iwtest = " iso-out"; 1990 iwtest = " iso-out";
1980 } 1991 }
1981 1992
1982 usb_set_intfdata (intf, dev); 1993 usb_set_intfdata(intf, dev);
1983 dev_info (&intf->dev, "%s\n", info->name); 1994 dev_info(&intf->dev, "%s\n", info->name);
1984 dev_info (&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", 1995 dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n",
1985 ({ char *tmp; 1996 ({ char *tmp;
1986 switch (udev->speed) { 1997 switch (udev->speed) {
1987 case USB_SPEED_LOW: tmp = "low"; break; 1998 case USB_SPEED_LOW:
1988 case USB_SPEED_FULL: tmp = "full"; break; 1999 tmp = "low";
1989 case USB_SPEED_HIGH: tmp = "high"; break; 2000 break;
1990 default: tmp = "unknown"; break; 2001 case USB_SPEED_FULL:
2002 tmp = "full";
2003 break;
2004 case USB_SPEED_HIGH:
2005 tmp = "high";
2006 break;
2007 default:
2008 tmp = "unknown";
2009 break;
1991 }; tmp; }), 2010 }; tmp; }),
1992 info->ctrl_out ? " in/out" : "", 2011 info->ctrl_out ? " in/out" : "",
1993 rtest, wtest, 2012 rtest, wtest,
@@ -1996,24 +2015,24 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1996 return 0; 2015 return 0;
1997} 2016}
1998 2017
1999static int usbtest_suspend (struct usb_interface *intf, pm_message_t message) 2018static int usbtest_suspend(struct usb_interface *intf, pm_message_t message)
2000{ 2019{
2001 return 0; 2020 return 0;
2002} 2021}
2003 2022
2004static int usbtest_resume (struct usb_interface *intf) 2023static int usbtest_resume(struct usb_interface *intf)
2005{ 2024{
2006 return 0; 2025 return 0;
2007} 2026}
2008 2027
2009 2028
2010static void usbtest_disconnect (struct usb_interface *intf) 2029static void usbtest_disconnect(struct usb_interface *intf)
2011{ 2030{
2012 struct usbtest_dev *dev = usb_get_intfdata (intf); 2031 struct usbtest_dev *dev = usb_get_intfdata(intf);
2013 2032
2014 usb_set_intfdata (intf, NULL); 2033 usb_set_intfdata(intf, NULL);
2015 dev_dbg (&intf->dev, "disconnect\n"); 2034 dev_dbg(&intf->dev, "disconnect\n");
2016 kfree (dev); 2035 kfree(dev);
2017} 2036}
2018 2037
2019/* Basic testing only needs a device that can source or sink bulk traffic. 2038/* Basic testing only needs a device that can source or sink bulk traffic.
@@ -2050,9 +2069,9 @@ static struct usbtest_info fw_info = {
2050 .ep_in = 2, 2069 .ep_in = 2,
2051 .ep_out = 2, 2070 .ep_out = 2,
2052 .alt = 1, 2071 .alt = 1,
2053 .autoconf = 1, // iso and ctrl_out need autoconf 2072 .autoconf = 1, /* iso and ctrl_out need autoconf */
2054 .ctrl_out = 1, 2073 .ctrl_out = 1,
2055 .iso = 1, // iso_ep's are #8 in/out 2074 .iso = 1, /* iso_ep's are #8 in/out */
2056}; 2075};
2057 2076
2058/* peripheral running Linux and 'zero.c' test firmware, or 2077/* peripheral running Linux and 'zero.c' test firmware, or
@@ -2109,56 +2128,56 @@ static const struct usb_device_id id_table[] = {
2109 */ 2128 */
2110 2129
2111 /* generic EZ-USB FX controller */ 2130 /* generic EZ-USB FX controller */
2112 { USB_DEVICE (0x0547, 0x2235), 2131 { USB_DEVICE(0x0547, 0x2235),
2113 .driver_info = (unsigned long) &ez1_info, 2132 .driver_info = (unsigned long) &ez1_info,
2114 }, 2133 },
2115 2134
2116 /* CY3671 development board with EZ-USB FX */ 2135 /* CY3671 development board with EZ-USB FX */
2117 { USB_DEVICE (0x0547, 0x0080), 2136 { USB_DEVICE(0x0547, 0x0080),
2118 .driver_info = (unsigned long) &ez1_info, 2137 .driver_info = (unsigned long) &ez1_info,
2119 }, 2138 },
2120 2139
2121 /* generic EZ-USB FX2 controller (or development board) */ 2140 /* generic EZ-USB FX2 controller (or development board) */
2122 { USB_DEVICE (0x04b4, 0x8613), 2141 { USB_DEVICE(0x04b4, 0x8613),
2123 .driver_info = (unsigned long) &ez2_info, 2142 .driver_info = (unsigned long) &ez2_info,
2124 }, 2143 },
2125 2144
2126 /* re-enumerated usb test device firmware */ 2145 /* re-enumerated usb test device firmware */
2127 { USB_DEVICE (0xfff0, 0xfff0), 2146 { USB_DEVICE(0xfff0, 0xfff0),
2128 .driver_info = (unsigned long) &fw_info, 2147 .driver_info = (unsigned long) &fw_info,
2129 }, 2148 },
2130 2149
2131 /* "Gadget Zero" firmware runs under Linux */ 2150 /* "Gadget Zero" firmware runs under Linux */
2132 { USB_DEVICE (0x0525, 0xa4a0), 2151 { USB_DEVICE(0x0525, 0xa4a0),
2133 .driver_info = (unsigned long) &gz_info, 2152 .driver_info = (unsigned long) &gz_info,
2134 }, 2153 },
2135 2154
2136 /* so does a user-mode variant */ 2155 /* so does a user-mode variant */
2137 { USB_DEVICE (0x0525, 0xa4a4), 2156 { USB_DEVICE(0x0525, 0xa4a4),
2138 .driver_info = (unsigned long) &um_info, 2157 .driver_info = (unsigned long) &um_info,
2139 }, 2158 },
2140 2159
2141 /* ... and a user-mode variant that talks iso */ 2160 /* ... and a user-mode variant that talks iso */
2142 { USB_DEVICE (0x0525, 0xa4a3), 2161 { USB_DEVICE(0x0525, 0xa4a3),
2143 .driver_info = (unsigned long) &um2_info, 2162 .driver_info = (unsigned long) &um2_info,
2144 }, 2163 },
2145 2164
2146#ifdef KEYSPAN_19Qi 2165#ifdef KEYSPAN_19Qi
2147 /* Keyspan 19qi uses an21xx (original EZ-USB) */ 2166 /* Keyspan 19qi uses an21xx (original EZ-USB) */
2148 // this does not coexist with the real Keyspan 19qi driver! 2167 /* this does not coexist with the real Keyspan 19qi driver! */
2149 { USB_DEVICE (0x06cd, 0x010b), 2168 { USB_DEVICE(0x06cd, 0x010b),
2150 .driver_info = (unsigned long) &ez1_info, 2169 .driver_info = (unsigned long) &ez1_info,
2151 }, 2170 },
2152#endif 2171#endif
2153 2172
2154 /*-------------------------------------------------------------*/ 2173 /*-------------------------------------------------------------*/
2155 2174
2156#ifdef IBOT2 2175#ifdef IBOT2
2157 /* iBOT2 makes a nice source of high speed bulk-in data */ 2176 /* iBOT2 makes a nice source of high speed bulk-in data */
2158 // this does not coexist with a real iBOT2 driver! 2177 /* this does not coexist with a real iBOT2 driver! */
2159 { USB_DEVICE (0x0b62, 0x0059), 2178 { USB_DEVICE(0x0b62, 0x0059),
2160 .driver_info = (unsigned long) &ibot2_info, 2179 .driver_info = (unsigned long) &ibot2_info,
2161 }, 2180 },
2162#endif 2181#endif
2163 2182
2164 /*-------------------------------------------------------------*/ 2183 /*-------------------------------------------------------------*/
@@ -2172,7 +2191,7 @@ static const struct usb_device_id id_table[] = {
2172 2191
2173 { } 2192 { }
2174}; 2193};
2175MODULE_DEVICE_TABLE (usb, id_table); 2194MODULE_DEVICE_TABLE(usb, id_table);
2176 2195
2177static struct usb_driver usbtest_driver = { 2196static struct usb_driver usbtest_driver = {
2178 .name = "usbtest", 2197 .name = "usbtest",
@@ -2186,22 +2205,22 @@ static struct usb_driver usbtest_driver = {
2186 2205
2187/*-------------------------------------------------------------------------*/ 2206/*-------------------------------------------------------------------------*/
2188 2207
2189static int __init usbtest_init (void) 2208static int __init usbtest_init(void)
2190{ 2209{
2191#ifdef GENERIC 2210#ifdef GENERIC
2192 if (vendor) 2211 if (vendor)
2193 pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); 2212 pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product);
2194#endif 2213#endif
2195 return usb_register (&usbtest_driver); 2214 return usb_register(&usbtest_driver);
2196} 2215}
2197module_init (usbtest_init); 2216module_init(usbtest_init);
2198 2217
2199static void __exit usbtest_exit (void) 2218static void __exit usbtest_exit(void)
2200{ 2219{
2201 usb_deregister (&usbtest_driver); 2220 usb_deregister(&usbtest_driver);
2202} 2221}
2203module_exit (usbtest_exit); 2222module_exit(usbtest_exit);
2204 2223
2205MODULE_DESCRIPTION ("USB Core/HCD Testing Driver"); 2224MODULE_DESCRIPTION("USB Core/HCD Testing Driver");
2206MODULE_LICENSE ("GPL"); 2225MODULE_LICENSE("GPL");
2207 2226
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
new file mode 100644
index 000000000000..719c6180b31f
--- /dev/null
+++ b/drivers/usb/misc/yurex.c
@@ -0,0 +1,563 @@
1/*
2 * Driver for Meywa-Denki & KAYAC YUREX
3 *
4 * Copyright (C) 2010 Tomoki Sekiyama (tomoki.sekiyama@gmail.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 */
11
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/init.h>
15#include <linux/slab.h>
16#include <linux/module.h>
17#include <linux/kref.h>
18#include <linux/mutex.h>
19#include <linux/uaccess.h>
20#include <linux/usb.h>
21#include <linux/hid.h>
22
23#define DRIVER_AUTHOR "Tomoki Sekiyama"
24#define DRIVER_DESC "Driver for Meywa-Denki & KAYAC YUREX"
25
26#define YUREX_VENDOR_ID 0x0c45
27#define YUREX_PRODUCT_ID 0x1010
28
29#define CMD_ACK '!'
30#define CMD_ANIMATE 'A'
31#define CMD_COUNT 'C'
32#define CMD_LED 'L'
33#define CMD_READ 'R'
34#define CMD_SET 'S'
35#define CMD_VERSION 'V'
36#define CMD_EOF 0x0d
37#define CMD_PADDING 0xff
38
39#define YUREX_BUF_SIZE 8
40#define YUREX_WRITE_TIMEOUT (HZ*2)
41
42/* table of devices that work with this driver */
43static struct usb_device_id yurex_table[] = {
44 { USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) },
45 { } /* Terminating entry */
46};
47MODULE_DEVICE_TABLE(usb, yurex_table);
48
49#ifdef CONFIG_USB_DYNAMIC_MINORS
50#define YUREX_MINOR_BASE 0
51#else
52#define YUREX_MINOR_BASE 192
53#endif
54
55/* Structure to hold all of our device specific stuff */
56struct usb_yurex {
57 struct usb_device *udev;
58 struct usb_interface *interface;
59 __u8 int_in_endpointAddr;
60 struct urb *urb; /* URB for interrupt in */
61 unsigned char *int_buffer; /* buffer for intterupt in */
62 struct urb *cntl_urb; /* URB for control msg */
63 struct usb_ctrlrequest *cntl_req; /* req for control msg */
64 unsigned char *cntl_buffer; /* buffer for control msg */
65
66 struct kref kref;
67 struct mutex io_mutex;
68 struct fasync_struct *async_queue;
69 wait_queue_head_t waitq;
70
71 spinlock_t lock;
72 __s64 bbu; /* BBU from device */
73};
74#define to_yurex_dev(d) container_of(d, struct usb_yurex, kref)
75
76static struct usb_driver yurex_driver;
77static const struct file_operations yurex_fops;
78
79
80static void yurex_control_callback(struct urb *urb)
81{
82 struct usb_yurex *dev = urb->context;
83 int status = urb->status;
84
85 if (status) {
86 err("%s - control failed: %d\n", __func__, status);
87 wake_up_interruptible(&dev->waitq);
88 return;
89 }
90 /* on success, sender woken up by CMD_ACK int in, or timeout */
91}
92
93static void yurex_delete(struct kref *kref)
94{
95 struct usb_yurex *dev = to_yurex_dev(kref);
96
97 dbg("yurex_delete");
98
99 usb_put_dev(dev->udev);
100 if (dev->cntl_urb) {
101 usb_kill_urb(dev->cntl_urb);
102 if (dev->cntl_req)
103 usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
104 dev->cntl_req, dev->cntl_urb->setup_dma);
105 if (dev->cntl_buffer)
106 usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
107 dev->cntl_buffer, dev->cntl_urb->transfer_dma);
108 usb_free_urb(dev->cntl_urb);
109 }
110 if (dev->urb) {
111 usb_kill_urb(dev->urb);
112 if (dev->int_buffer)
113 usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
114 dev->int_buffer, dev->urb->transfer_dma);
115 usb_free_urb(dev->urb);
116 }
117 kfree(dev);
118}
119
120/*
121 * usb class driver info in order to get a minor number from the usb core,
122 * and to have the device registered with the driver core
123 */
124static struct usb_class_driver yurex_class = {
125 .name = "yurex%d",
126 .fops = &yurex_fops,
127 .minor_base = YUREX_MINOR_BASE,
128};
129
130static void yurex_interrupt(struct urb *urb)
131{
132 struct usb_yurex *dev = urb->context;
133 unsigned char *buf = dev->int_buffer;
134 int status = urb->status;
135 unsigned long flags;
136 int retval, i;
137
138 switch (status) {
139 case 0: /*success*/
140 break;
141 case -EOVERFLOW:
142 err("%s - overflow with length %d, actual length is %d",
143 __func__, YUREX_BUF_SIZE, dev->urb->actual_length);
144 case -ECONNRESET:
145 case -ENOENT:
146 case -ESHUTDOWN:
147 case -EILSEQ:
148 /* The device is terminated, clean up */
149 return;
150 default:
151 err("%s - unknown status received: %d", __func__, status);
152 goto exit;
153 }
154
155 /* handle received message */
156 switch (buf[0]) {
157 case CMD_COUNT:
158 case CMD_READ:
159 if (buf[6] == CMD_EOF) {
160 spin_lock_irqsave(&dev->lock, flags);
161 dev->bbu = 0;
162 for (i = 1; i < 6; i++) {
163 dev->bbu += buf[i];
164 if (i != 5)
165 dev->bbu <<= 8;
166 }
167 dbg("%s count: %lld", __func__, dev->bbu);
168 spin_unlock_irqrestore(&dev->lock, flags);
169
170 kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
171 }
172 else
173 dbg("data format error - no EOF");
174 break;
175 case CMD_ACK:
176 dbg("%s ack: %c", __func__, buf[1]);
177 wake_up_interruptible(&dev->waitq);
178 break;
179 }
180
181exit:
182 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
183 if (retval) {
184 err("%s - usb_submit_urb failed: %d",
185 __func__, retval);
186 }
187}
188
189static int yurex_probe(struct usb_interface *interface, const struct usb_device_id *id)
190{
191 struct usb_yurex *dev;
192 struct usb_host_interface *iface_desc;
193 struct usb_endpoint_descriptor *endpoint;
194 int retval = -ENOMEM;
195 int i;
196 DEFINE_WAIT(wait);
197
198 /* allocate memory for our device state and initialize it */
199 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
200 if (!dev) {
201 err("Out of memory");
202 goto error;
203 }
204 kref_init(&dev->kref);
205 mutex_init(&dev->io_mutex);
206 spin_lock_init(&dev->lock);
207 init_waitqueue_head(&dev->waitq);
208
209 dev->udev = usb_get_dev(interface_to_usbdev(interface));
210 dev->interface = interface;
211
212 /* set up the endpoint information */
213 iface_desc = interface->cur_altsetting;
214 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
215 endpoint = &iface_desc->endpoint[i].desc;
216
217 if (usb_endpoint_is_int_in(endpoint)) {
218 dev->int_in_endpointAddr = endpoint->bEndpointAddress;
219 break;
220 }
221 }
222 if (!dev->int_in_endpointAddr) {
223 retval = -ENODEV;
224 err("Could not find endpoints");
225 goto error;
226 }
227
228
229 /* allocate control URB */
230 dev->cntl_urb = usb_alloc_urb(0, GFP_KERNEL);
231 if (!dev->cntl_urb) {
232 err("Could not allocate control URB");
233 goto error;
234 }
235
236 /* allocate buffer for control req */
237 dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
238 GFP_KERNEL,
239 &dev->cntl_urb->setup_dma);
240 if (!dev->cntl_req) {
241 err("Could not allocate cntl_req");
242 goto error;
243 }
244
245 /* allocate buffer for control msg */
246 dev->cntl_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
247 GFP_KERNEL,
248 &dev->cntl_urb->transfer_dma);
249 if (!dev->cntl_buffer) {
250 err("Could not allocate cntl_buffer");
251 goto error;
252 }
253
254 /* configure control URB */
255 dev->cntl_req->bRequestType = USB_DIR_OUT | USB_TYPE_CLASS |
256 USB_RECIP_INTERFACE;
257 dev->cntl_req->bRequest = HID_REQ_SET_REPORT;
258 dev->cntl_req->wValue = cpu_to_le16((HID_OUTPUT_REPORT + 1) << 8);
259 dev->cntl_req->wIndex = cpu_to_le16(iface_desc->desc.bInterfaceNumber);
260 dev->cntl_req->wLength = cpu_to_le16(YUREX_BUF_SIZE);
261
262 usb_fill_control_urb(dev->cntl_urb, dev->udev,
263 usb_sndctrlpipe(dev->udev, 0),
264 (void *)dev->cntl_req, dev->cntl_buffer,
265 YUREX_BUF_SIZE, yurex_control_callback, dev);
266 dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
267
268
269 /* allocate interrupt URB */
270 dev->urb = usb_alloc_urb(0, GFP_KERNEL);
271 if (!dev->urb) {
272 err("Could not allocate URB");
273 goto error;
274 }
275
276 /* allocate buffer for interrupt in */
277 dev->int_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
278 GFP_KERNEL, &dev->urb->transfer_dma);
279 if (!dev->int_buffer) {
280 err("Could not allocate int_buffer");
281 goto error;
282 }
283
284 /* configure interrupt URB */
285 usb_fill_int_urb(dev->urb, dev->udev,
286 usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
287 dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt,
288 dev, 1);
289 dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
290 if (usb_submit_urb(dev->urb, GFP_KERNEL)) {
291 retval = -EIO;
292 err("Could not submitting URB");
293 goto error;
294 }
295
296 /* save our data pointer in this interface device */
297 usb_set_intfdata(interface, dev);
298
299 /* we can register the device now, as it is ready */
300 retval = usb_register_dev(interface, &yurex_class);
301 if (retval) {
302 err("Not able to get a minor for this device.");
303 usb_set_intfdata(interface, NULL);
304 goto error;
305 }
306
307 dev->bbu = -1;
308
309 dev_info(&interface->dev,
310 "USB YUREX device now attached to Yurex #%d\n",
311 interface->minor);
312
313 return 0;
314
315error:
316 if (dev)
317 /* this frees allocated memory */
318 kref_put(&dev->kref, yurex_delete);
319 return retval;
320}
321
322static void yurex_disconnect(struct usb_interface *interface)
323{
324 struct usb_yurex *dev;
325 int minor = interface->minor;
326
327 dev = usb_get_intfdata(interface);
328 usb_set_intfdata(interface, NULL);
329
330 /* give back our minor */
331 usb_deregister_dev(interface, &yurex_class);
332
333 /* prevent more I/O from starting */
334 mutex_lock(&dev->io_mutex);
335 dev->interface = NULL;
336 mutex_unlock(&dev->io_mutex);
337
338 /* wakeup waiters */
339 kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
340 wake_up_interruptible(&dev->waitq);
341
342 /* decrement our usage count */
343 kref_put(&dev->kref, yurex_delete);
344
345 dev_info(&interface->dev, "USB YUREX #%d now disconnected\n", minor);
346}
347
348static struct usb_driver yurex_driver = {
349 .name = "yurex",
350 .probe = yurex_probe,
351 .disconnect = yurex_disconnect,
352 .id_table = yurex_table,
353};
354
355
356static int yurex_fasync(int fd, struct file *file, int on)
357{
358 struct usb_yurex *dev;
359
360 dev = (struct usb_yurex *)file->private_data;
361 return fasync_helper(fd, file, on, &dev->async_queue);
362}
363
364static int yurex_open(struct inode *inode, struct file *file)
365{
366 struct usb_yurex *dev;
367 struct usb_interface *interface;
368 int subminor;
369 int retval = 0;
370
371 subminor = iminor(inode);
372
373 interface = usb_find_interface(&yurex_driver, subminor);
374 if (!interface) {
375 err("%s - error, can't find device for minor %d",
376 __func__, subminor);
377 retval = -ENODEV;
378 goto exit;
379 }
380
381 dev = usb_get_intfdata(interface);
382 if (!dev) {
383 retval = -ENODEV;
384 goto exit;
385 }
386
387 /* increment our usage count for the device */
388 kref_get(&dev->kref);
389
390 /* save our object in the file's private structure */
391 mutex_lock(&dev->io_mutex);
392 file->private_data = dev;
393 mutex_unlock(&dev->io_mutex);
394
395exit:
396 return retval;
397}
398
399static int yurex_release(struct inode *inode, struct file *file)
400{
401 struct usb_yurex *dev;
402
403 dev = (struct usb_yurex *)file->private_data;
404 if (dev == NULL)
405 return -ENODEV;
406
407 yurex_fasync(-1, file, 0);
408
409 /* decrement the count on our device */
410 kref_put(&dev->kref, yurex_delete);
411 return 0;
412}
413
414static ssize_t yurex_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
415{
416 struct usb_yurex *dev;
417 int retval = 0;
418 int bytes_read = 0;
419 char in_buffer[20];
420 unsigned long flags;
421
422 dev = (struct usb_yurex *)file->private_data;
423
424 mutex_lock(&dev->io_mutex);
425 if (!dev->interface) { /* already disconnected */
426 retval = -ENODEV;
427 goto exit;
428 }
429
430 spin_lock_irqsave(&dev->lock, flags);
431 bytes_read = snprintf(in_buffer, 20, "%lld\n", dev->bbu);
432 spin_unlock_irqrestore(&dev->lock, flags);
433
434 if (*ppos < bytes_read) {
435 if (copy_to_user(buffer, in_buffer + *ppos, bytes_read - *ppos))
436 retval = -EFAULT;
437 else {
438 retval = bytes_read - *ppos;
439 *ppos += bytes_read;
440 }
441 }
442
443exit:
444 mutex_unlock(&dev->io_mutex);
445 return retval;
446}
447
448static ssize_t yurex_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos)
449{
450 struct usb_yurex *dev;
451 int i, set = 0, retval = 0;
452 char buffer[16];
453 char *data = buffer;
454 unsigned long long c, c2 = 0;
455 signed long timeout = 0;
456 DEFINE_WAIT(wait);
457
458 count = min(sizeof(buffer), count);
459 dev = (struct usb_yurex *)file->private_data;
460
461 /* verify that we actually have some data to write */
462 if (count == 0)
463 goto error;
464
465 mutex_lock(&dev->io_mutex);
466 if (!dev->interface) { /* alreaday disconnected */
467 mutex_unlock(&dev->io_mutex);
468 retval = -ENODEV;
469 goto error;
470 }
471
472 if (copy_from_user(buffer, user_buffer, count)) {
473 mutex_unlock(&dev->io_mutex);
474 retval = -EFAULT;
475 goto error;
476 }
477 memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE);
478
479 switch (buffer[0]) {
480 case CMD_ANIMATE:
481 case CMD_LED:
482 dev->cntl_buffer[0] = buffer[0];
483 dev->cntl_buffer[1] = buffer[1];
484 dev->cntl_buffer[2] = CMD_EOF;
485 break;
486 case CMD_READ:
487 case CMD_VERSION:
488 dev->cntl_buffer[0] = buffer[0];
489 dev->cntl_buffer[1] = 0x00;
490 dev->cntl_buffer[2] = CMD_EOF;
491 break;
492 case CMD_SET:
493 data++;
494 /* FALL THROUGH */
495 case '0' ... '9':
496 set = 1;
497 c = c2 = simple_strtoull(data, NULL, 0);
498 dev->cntl_buffer[0] = CMD_SET;
499 for (i = 1; i < 6; i++) {
500 dev->cntl_buffer[i] = (c>>32) & 0xff;
501 c <<= 8;
502 }
503 buffer[6] = CMD_EOF;
504 break;
505 default:
506 mutex_unlock(&dev->io_mutex);
507 return -EINVAL;
508 }
509
510 /* send the data as the control msg */
511 prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
512 dbg("%s - submit %c", __func__, dev->cntl_buffer[0]);
513 retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
514 if (retval >= 0)
515 timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
516 finish_wait(&dev->waitq, &wait);
517
518 mutex_unlock(&dev->io_mutex);
519
520 if (retval < 0) {
521 err("%s - failed to send bulk msg, error %d", __func__, retval);
522 goto error;
523 }
524 if (set && timeout)
525 dev->bbu = c2;
526 return timeout ? count : -EIO;
527
528error:
529 return retval;
530}
531
532static const struct file_operations yurex_fops = {
533 .owner = THIS_MODULE,
534 .read = yurex_read,
535 .write = yurex_write,
536 .open = yurex_open,
537 .release = yurex_release,
538 .fasync = yurex_fasync,
539};
540
541
542static int __init usb_yurex_init(void)
543{
544 int result;
545
546 /* register this driver with the USB subsystem */
547 result = usb_register(&yurex_driver);
548 if (result)
549 err("usb_register failed. Error number %d", result);
550
551 return result;
552}
553
554static void __exit usb_yurex_exit(void)
555{
556 /* deregister this driver with the USB subsystem */
557 usb_deregister(&yurex_driver);
558}
559
560module_init(usb_yurex_init);
561module_exit(usb_yurex_exit);
562
563MODULE_LICENSE("GPL");
diff --git a/drivers/usb/mon/Makefile b/drivers/usb/mon/Makefile
index 384b198faa7c..8ed24ab08698 100644
--- a/drivers/usb/mon/Makefile
+++ b/drivers/usb/mon/Makefile
@@ -2,6 +2,6 @@
2# Makefile for USB monitor 2# Makefile for USB monitor
3# 3#
4 4
5usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_bin.o 5usbmon-y := mon_main.o mon_stat.o mon_text.o mon_bin.o
6 6
7obj-$(CONFIG_USB_MON) += usbmon.o 7obj-$(CONFIG_USB_MON) += usbmon.o
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index cfd38edfcf9e..341a37a469bd 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -45,6 +45,9 @@ config USB_MUSB_SOC
45comment "DaVinci 35x and 644x USB support" 45comment "DaVinci 35x and 644x USB support"
46 depends on USB_MUSB_HDRC && ARCH_DAVINCI_DMx 46 depends on USB_MUSB_HDRC && ARCH_DAVINCI_DMx
47 47
48comment "DA8xx/OMAP-L1x USB support"
49 depends on USB_MUSB_HDRC && ARCH_DAVINCI_DA8XX
50
48comment "OMAP 243x high speed USB support" 51comment "OMAP 243x high speed USB support"
49 depends on USB_MUSB_HDRC && ARCH_OMAP2430 52 depends on USB_MUSB_HDRC && ARCH_OMAP2430
50 53
@@ -57,6 +60,17 @@ comment "OMAP 44xx high speed USB support"
57comment "Blackfin high speed USB Support" 60comment "Blackfin high speed USB Support"
58 depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523)) 61 depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523))
59 62
63config USB_MUSB_AM35X
64 bool
65 depends on USB_MUSB_HDRC && !ARCH_OMAP2430 && !ARCH_OMAP4
66 select NOP_USB_XCEIV
67 default MACH_OMAP3517EVM
68 help
69 Select this option if your platform is based on AM35x. As
70 AM35x has an updated MUSB with CPPI4.1 DMA so this config
71 is introduced to differentiate musb ip between OMAP3x and
72 AM35x platforms.
73
60config USB_TUSB6010 74config USB_TUSB6010
61 boolean "TUSB 6010 support" 75 boolean "TUSB 6010 support"
62 depends on USB_MUSB_HDRC && !USB_MUSB_SOC 76 depends on USB_MUSB_HDRC && !USB_MUSB_SOC
@@ -144,7 +158,7 @@ config USB_MUSB_HDRC_HCD
144config MUSB_PIO_ONLY 158config MUSB_PIO_ONLY
145 bool 'Disable DMA (always use PIO)' 159 bool 'Disable DMA (always use PIO)'
146 depends on USB_MUSB_HDRC 160 depends on USB_MUSB_HDRC
147 default y if USB_TUSB6010 161 default USB_TUSB6010 || ARCH_DAVINCI_DA8XX || USB_MUSB_AM35X
148 help 162 help
149 All data is copied between memory and FIFO by the CPU. 163 All data is copied between memory and FIFO by the CPU.
150 DMA controllers are ignored. 164 DMA controllers are ignored.
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 9705f716386e..ce164e8998d8 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -2,49 +2,27 @@
2# for USB OTG silicon based on Mentor Graphics INVENTRA designs 2# for USB OTG silicon based on Mentor Graphics INVENTRA designs
3# 3#
4 4
5musb_hdrc-objs := musb_core.o 5ccflags-$(CONFIG_USB_MUSB_DEBUG) := -DDEBUG
6 6
7obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o 7obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
8 8
9ifeq ($(CONFIG_ARCH_DAVINCI_DMx),y) 9musb_hdrc-y := musb_core.o
10 musb_hdrc-objs += davinci.o
11endif
12
13ifeq ($(CONFIG_USB_TUSB6010),y)
14 musb_hdrc-objs += tusb6010.o
15endif
16
17ifeq ($(CONFIG_ARCH_OMAP2430),y)
18 musb_hdrc-objs += omap2430.o
19endif
20
21ifeq ($(CONFIG_ARCH_OMAP3430),y)
22 musb_hdrc-objs += omap2430.o
23endif
24
25ifeq ($(CONFIG_ARCH_OMAP4),y)
26 musb_hdrc-objs += omap2430.o
27endif
28
29ifeq ($(CONFIG_BF54x),y)
30 musb_hdrc-objs += blackfin.o
31endif
32 10
33ifeq ($(CONFIG_BF52x),y) 11musb_hdrc-$(CONFIG_ARCH_DAVINCI_DMx) += davinci.o
34 musb_hdrc-objs += blackfin.o 12musb_hdrc-$(CONFIG_ARCH_DAVINCI_DA8XX) += da8xx.o
35endif 13musb_hdrc-$(CONFIG_USB_TUSB6010) += tusb6010.o
36 14musb_hdrc-$(CONFIG_ARCH_OMAP2430) += omap2430.o
37ifeq ($(CONFIG_USB_GADGET_MUSB_HDRC),y) 15ifeq ($(CONFIG_USB_MUSB_AM35X),y)
38 musb_hdrc-objs += musb_gadget_ep0.o musb_gadget.o 16 musb_hdrc-$(CONFIG_ARCH_OMAP3430) += am35x.o
39endif 17else
40 18 musb_hdrc-$(CONFIG_ARCH_OMAP3430) += omap2430.o
41ifeq ($(CONFIG_USB_MUSB_HDRC_HCD),y)
42 musb_hdrc-objs += musb_virthub.o musb_host.o
43endif
44
45ifeq ($(CONFIG_DEBUG_FS),y)
46 musb_hdrc-objs += musb_debugfs.o
47endif 19endif
20musb_hdrc-$(CONFIG_ARCH_OMAP4) += omap2430.o
21musb_hdrc-$(CONFIG_BF54x) += blackfin.o
22musb_hdrc-$(CONFIG_BF52x) += blackfin.o
23musb_hdrc-$(CONFIG_USB_GADGET_MUSB_HDRC) += musb_gadget_ep0.o musb_gadget.o
24musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) += musb_virthub.o musb_host.o
25musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o
48 26
49# the kconfig must guarantee that only one of the 27# the kconfig must guarantee that only one of the
50# possible I/O schemes will be enabled at a time ... 28# possible I/O schemes will be enabled at a time ...
@@ -54,26 +32,17 @@ endif
54ifneq ($(CONFIG_MUSB_PIO_ONLY),y) 32ifneq ($(CONFIG_MUSB_PIO_ONLY),y)
55 33
56 ifeq ($(CONFIG_USB_INVENTRA_DMA),y) 34 ifeq ($(CONFIG_USB_INVENTRA_DMA),y)
57 musb_hdrc-objs += musbhsdma.o 35 musb_hdrc-y += musbhsdma.o
58 36
59 else 37 else
60 ifeq ($(CONFIG_USB_TI_CPPI_DMA),y) 38 ifeq ($(CONFIG_USB_TI_CPPI_DMA),y)
61 musb_hdrc-objs += cppi_dma.o 39 musb_hdrc-y += cppi_dma.o
62 40
63 else 41 else
64 ifeq ($(CONFIG_USB_TUSB_OMAP_DMA),y) 42 ifeq ($(CONFIG_USB_TUSB_OMAP_DMA),y)
65 musb_hdrc-objs += tusb6010_omap.o 43 musb_hdrc-y += tusb6010_omap.o
66 44
67 endif 45 endif
68 endif 46 endif
69 endif 47 endif
70endif 48endif
71
72
73################################################################################
74
75# Debugging
76
77ifeq ($(CONFIG_USB_MUSB_DEBUG),y)
78 EXTRA_CFLAGS += -DDEBUG
79endif
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
new file mode 100644
index 000000000000..b0aabf3a606f
--- /dev/null
+++ b/drivers/usb/musb/am35x.c
@@ -0,0 +1,524 @@
1/*
2 * Texas Instruments AM35x "glue layer"
3 *
4 * Copyright (c) 2010, by Texas Instruments
5 *
6 * Based on the DA8xx "glue layer" code.
7 * Copyright (c) 2008-2009, MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This file is part of the Inventra Controller Driver for Linux.
10 *
11 * The Inventra Controller Driver for Linux is free software; you
12 * can redistribute it and/or modify it under the terms of the GNU
13 * General Public License version 2 as published by the Free Software
14 * Foundation.
15 *
16 * The Inventra Controller Driver for Linux is distributed in
17 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
18 * without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
20 * License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with The Inventra Controller Driver for Linux ; if not,
24 * write to the Free Software Foundation, Inc., 59 Temple Place,
25 * Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29#include <linux/init.h>
30#include <linux/clk.h>
31#include <linux/io.h>
32
33#include <plat/control.h>
34#include <plat/usb.h>
35
36#include "musb_core.h"
37
38/*
39 * AM35x specific definitions
40 */
41/* USB 2.0 OTG module registers */
42#define USB_REVISION_REG 0x00
43#define USB_CTRL_REG 0x04
44#define USB_STAT_REG 0x08
45#define USB_EMULATION_REG 0x0c
46/* 0x10 Reserved */
47#define USB_AUTOREQ_REG 0x14
48#define USB_SRP_FIX_TIME_REG 0x18
49#define USB_TEARDOWN_REG 0x1c
50#define EP_INTR_SRC_REG 0x20
51#define EP_INTR_SRC_SET_REG 0x24
52#define EP_INTR_SRC_CLEAR_REG 0x28
53#define EP_INTR_MASK_REG 0x2c
54#define EP_INTR_MASK_SET_REG 0x30
55#define EP_INTR_MASK_CLEAR_REG 0x34
56#define EP_INTR_SRC_MASKED_REG 0x38
57#define CORE_INTR_SRC_REG 0x40
58#define CORE_INTR_SRC_SET_REG 0x44
59#define CORE_INTR_SRC_CLEAR_REG 0x48
60#define CORE_INTR_MASK_REG 0x4c
61#define CORE_INTR_MASK_SET_REG 0x50
62#define CORE_INTR_MASK_CLEAR_REG 0x54
63#define CORE_INTR_SRC_MASKED_REG 0x58
64/* 0x5c Reserved */
65#define USB_END_OF_INTR_REG 0x60
66
67/* Control register bits */
68#define AM35X_SOFT_RESET_MASK 1
69
70/* USB interrupt register bits */
71#define AM35X_INTR_USB_SHIFT 16
72#define AM35X_INTR_USB_MASK (0x1ff << AM35X_INTR_USB_SHIFT)
73#define AM35X_INTR_DRVVBUS 0x100
74#define AM35X_INTR_RX_SHIFT 16
75#define AM35X_INTR_TX_SHIFT 0
76#define AM35X_TX_EP_MASK 0xffff /* EP0 + 15 Tx EPs */
77#define AM35X_RX_EP_MASK 0xfffe /* 15 Rx EPs */
78#define AM35X_TX_INTR_MASK (AM35X_TX_EP_MASK << AM35X_INTR_TX_SHIFT)
79#define AM35X_RX_INTR_MASK (AM35X_RX_EP_MASK << AM35X_INTR_RX_SHIFT)
80
81#define USB_MENTOR_CORE_OFFSET 0x400
82
83static inline void phy_on(void)
84{
85 unsigned long timeout = jiffies + msecs_to_jiffies(100);
86 u32 devconf2;
87
88 /*
89 * Start the on-chip PHY and its PLL.
90 */
91 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
92
93 devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN);
94 devconf2 |= CONF2_PHY_PLLON;
95
96 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
97
98 DBG(1, "Waiting for PHY clock good...\n");
99 while (!(omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2)
100 & CONF2_PHYCLKGD)) {
101 cpu_relax();
102
103 if (time_after(jiffies, timeout)) {
104 DBG(1, "musb PHY clock good timed out\n");
105 break;
106 }
107 }
108}
109
110static inline void phy_off(void)
111{
112 u32 devconf2;
113
114 /*
115 * Power down the on-chip PHY.
116 */
117 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
118
119 devconf2 &= ~CONF2_PHY_PLLON;
120 devconf2 |= CONF2_PHYPWRDN | CONF2_OTGPWRDN;
121 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
122}
123
124/*
125 * musb_platform_enable - enable interrupts
126 */
127void musb_platform_enable(struct musb *musb)
128{
129 void __iomem *reg_base = musb->ctrl_base;
130 u32 epmask;
131
132 /* Workaround: setup IRQs through both register sets. */
133 epmask = ((musb->epmask & AM35X_TX_EP_MASK) << AM35X_INTR_TX_SHIFT) |
134 ((musb->epmask & AM35X_RX_EP_MASK) << AM35X_INTR_RX_SHIFT);
135
136 musb_writel(reg_base, EP_INTR_MASK_SET_REG, epmask);
137 musb_writel(reg_base, CORE_INTR_MASK_SET_REG, AM35X_INTR_USB_MASK);
138
139 /* Force the DRVVBUS IRQ so we can start polling for ID change. */
140 if (is_otg_enabled(musb))
141 musb_writel(reg_base, CORE_INTR_SRC_SET_REG,
142 AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT);
143}
144
145/*
146 * musb_platform_disable - disable HDRC and flush interrupts
147 */
148void musb_platform_disable(struct musb *musb)
149{
150 void __iomem *reg_base = musb->ctrl_base;
151
152 musb_writel(reg_base, CORE_INTR_MASK_CLEAR_REG, AM35X_INTR_USB_MASK);
153 musb_writel(reg_base, EP_INTR_MASK_CLEAR_REG,
154 AM35X_TX_INTR_MASK | AM35X_RX_INTR_MASK);
155 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
156 musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
157}
158
159#ifdef CONFIG_USB_MUSB_HDRC_HCD
160#define portstate(stmt) stmt
161#else
162#define portstate(stmt)
163#endif
164
165static void am35x_set_vbus(struct musb *musb, int is_on)
166{
167 WARN_ON(is_on && is_peripheral_active(musb));
168}
169
170#define POLL_SECONDS 2
171
172static struct timer_list otg_workaround;
173
174static void otg_timer(unsigned long _musb)
175{
176 struct musb *musb = (void *)_musb;
177 void __iomem *mregs = musb->mregs;
178 u8 devctl;
179 unsigned long flags;
180
181 /*
182 * We poll because AM35x's won't expose several OTG-critical
183 * status change events (from the transceiver) otherwise.
184 */
185 devctl = musb_readb(mregs, MUSB_DEVCTL);
186 DBG(7, "Poll devctl %02x (%s)\n", devctl, otg_state_string(musb));
187
188 spin_lock_irqsave(&musb->lock, flags);
189 switch (musb->xceiv->state) {
190 case OTG_STATE_A_WAIT_BCON:
191 devctl &= ~MUSB_DEVCTL_SESSION;
192 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
193
194 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
195 if (devctl & MUSB_DEVCTL_BDEVICE) {
196 musb->xceiv->state = OTG_STATE_B_IDLE;
197 MUSB_DEV_MODE(musb);
198 } else {
199 musb->xceiv->state = OTG_STATE_A_IDLE;
200 MUSB_HST_MODE(musb);
201 }
202 break;
203 case OTG_STATE_A_WAIT_VFALL:
204 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
205 musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
206 MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
207 break;
208 case OTG_STATE_B_IDLE:
209 if (!is_peripheral_enabled(musb))
210 break;
211
212 devctl = musb_readb(mregs, MUSB_DEVCTL);
213 if (devctl & MUSB_DEVCTL_BDEVICE)
214 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
215 else
216 musb->xceiv->state = OTG_STATE_A_IDLE;
217 break;
218 default:
219 break;
220 }
221 spin_unlock_irqrestore(&musb->lock, flags);
222}
223
224void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
225{
226 static unsigned long last_timer;
227
228 if (!is_otg_enabled(musb))
229 return;
230
231 if (timeout == 0)
232 timeout = jiffies + msecs_to_jiffies(3);
233
234 /* Never idle if active, or when VBUS timeout is not set as host */
235 if (musb->is_active || (musb->a_wait_bcon == 0 &&
236 musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
237 DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
238 del_timer(&otg_workaround);
239 last_timer = jiffies;
240 return;
241 }
242
243 if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
244 DBG(4, "Longer idle timer already pending, ignoring...\n");
245 return;
246 }
247 last_timer = timeout;
248
249 DBG(4, "%s inactive, starting idle timer for %u ms\n",
250 otg_state_string(musb), jiffies_to_msecs(timeout - jiffies));
251 mod_timer(&otg_workaround, timeout);
252}
253
254static irqreturn_t am35x_interrupt(int irq, void *hci)
255{
256 struct musb *musb = hci;
257 void __iomem *reg_base = musb->ctrl_base;
258 unsigned long flags;
259 irqreturn_t ret = IRQ_NONE;
260 u32 epintr, usbintr, lvl_intr;
261
262 spin_lock_irqsave(&musb->lock, flags);
263
264 /* Get endpoint interrupts */
265 epintr = musb_readl(reg_base, EP_INTR_SRC_MASKED_REG);
266
267 if (epintr) {
268 musb_writel(reg_base, EP_INTR_SRC_CLEAR_REG, epintr);
269
270 musb->int_rx =
271 (epintr & AM35X_RX_INTR_MASK) >> AM35X_INTR_RX_SHIFT;
272 musb->int_tx =
273 (epintr & AM35X_TX_INTR_MASK) >> AM35X_INTR_TX_SHIFT;
274 }
275
276 /* Get usb core interrupts */
277 usbintr = musb_readl(reg_base, CORE_INTR_SRC_MASKED_REG);
278 if (!usbintr && !epintr)
279 goto eoi;
280
281 if (usbintr) {
282 musb_writel(reg_base, CORE_INTR_SRC_CLEAR_REG, usbintr);
283
284 musb->int_usb =
285 (usbintr & AM35X_INTR_USB_MASK) >> AM35X_INTR_USB_SHIFT;
286 }
287 /*
288 * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
289 * AM35x's missing ID change IRQ. We need an ID change IRQ to
290 * switch appropriately between halves of the OTG state machine.
291 * Managing DEVCTL.SESSION per Mentor docs requires that we know its
292 * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set.
293 * Also, DRVVBUS pulses for SRP (but not at 5V) ...
294 */
295 if (usbintr & (AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT)) {
296 int drvvbus = musb_readl(reg_base, USB_STAT_REG);
297 void __iomem *mregs = musb->mregs;
298 u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
299 int err;
300
301 err = is_host_enabled(musb) && (musb->int_usb &
302 MUSB_INTR_VBUSERROR);
303 if (err) {
304 /*
305 * The Mentor core doesn't debounce VBUS as needed
306 * to cope with device connect current spikes. This
307 * means it's not uncommon for bus-powered devices
308 * to get VBUS errors during enumeration.
309 *
310 * This is a workaround, but newer RTL from Mentor
311 * seems to allow a better one: "re"-starting sessions
312 * without waiting for VBUS to stop registering in
313 * devctl.
314 */
315 musb->int_usb &= ~MUSB_INTR_VBUSERROR;
316 musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
317 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
318 WARNING("VBUS error workaround (delay coming)\n");
319 } else if (is_host_enabled(musb) && drvvbus) {
320 MUSB_HST_MODE(musb);
321 musb->xceiv->default_a = 1;
322 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
323 portstate(musb->port1_status |= USB_PORT_STAT_POWER);
324 del_timer(&otg_workaround);
325 } else {
326 musb->is_active = 0;
327 MUSB_DEV_MODE(musb);
328 musb->xceiv->default_a = 0;
329 musb->xceiv->state = OTG_STATE_B_IDLE;
330 portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
331 }
332
333 /* NOTE: this must complete power-on within 100 ms. */
334 DBG(2, "VBUS %s (%s)%s, devctl %02x\n",
335 drvvbus ? "on" : "off",
336 otg_state_string(musb),
337 err ? " ERROR" : "",
338 devctl);
339 ret = IRQ_HANDLED;
340 }
341
342 if (musb->int_tx || musb->int_rx || musb->int_usb)
343 ret |= musb_interrupt(musb);
344
345eoi:
346 /* EOI needs to be written for the IRQ to be re-asserted. */
347 if (ret == IRQ_HANDLED || epintr || usbintr) {
348 /* clear level interrupt */
349 lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
350 lvl_intr |= AM35XX_USBOTGSS_INT_CLR;
351 omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR);
352 /* write EOI */
353 musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
354 }
355
356 /* Poll for ID change */
357 if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
358 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
359
360 spin_unlock_irqrestore(&musb->lock, flags);
361
362 return ret;
363}
364
365int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
366{
367 u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
368
369 devconf2 &= ~CONF2_OTGMODE;
370 switch (musb_mode) {
371#ifdef CONFIG_USB_MUSB_HDRC_HCD
372 case MUSB_HOST: /* Force VBUS valid, ID = 0 */
373 devconf2 |= CONF2_FORCE_HOST;
374 break;
375#endif
376#ifdef CONFIG_USB_GADGET_MUSB_HDRC
377 case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
378 devconf2 |= CONF2_FORCE_DEVICE;
379 break;
380#endif
381#ifdef CONFIG_USB_MUSB_OTG
382 case MUSB_OTG: /* Don't override the VBUS/ID comparators */
383 devconf2 |= CONF2_NO_OVERRIDE;
384 break;
385#endif
386 default:
387 DBG(2, "Trying to set unsupported mode %u\n", musb_mode);
388 }
389
390 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
391 return 0;
392}
393
394int __init musb_platform_init(struct musb *musb, void *board_data)
395{
396 void __iomem *reg_base = musb->ctrl_base;
397 u32 rev, lvl_intr, sw_reset;
398 int status;
399
400 musb->mregs += USB_MENTOR_CORE_OFFSET;
401
402 clk_enable(musb->clock);
403 DBG(2, "musb->clock=%lud\n", clk_get_rate(musb->clock));
404
405 musb->phy_clock = clk_get(musb->controller, "fck");
406 if (IS_ERR(musb->phy_clock)) {
407 status = PTR_ERR(musb->phy_clock);
408 goto exit0;
409 }
410 clk_enable(musb->phy_clock);
411 DBG(2, "musb->phy_clock=%lud\n", clk_get_rate(musb->phy_clock));
412
413 /* Returns zero if e.g. not clocked */
414 rev = musb_readl(reg_base, USB_REVISION_REG);
415 if (!rev) {
416 status = -ENODEV;
417 goto exit1;
418 }
419
420 usb_nop_xceiv_register();
421 musb->xceiv = otg_get_transceiver();
422 if (!musb->xceiv) {
423 status = -ENODEV;
424 goto exit1;
425 }
426
427 if (is_host_enabled(musb))
428 setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
429
430 musb->board_set_vbus = am35x_set_vbus;
431
432 /* Global reset */
433 sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
434
435 sw_reset |= AM35XX_USBOTGSS_SW_RST;
436 omap_ctrl_writel(sw_reset, AM35XX_CONTROL_IP_SW_RESET);
437
438 sw_reset &= ~AM35XX_USBOTGSS_SW_RST;
439 omap_ctrl_writel(sw_reset, AM35XX_CONTROL_IP_SW_RESET);
440
441 /* Reset the controller */
442 musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK);
443
444 /* Start the on-chip PHY and its PLL. */
445 phy_on();
446
447 msleep(5);
448
449 musb->isr = am35x_interrupt;
450
451 /* clear level interrupt */
452 lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
453 lvl_intr |= AM35XX_USBOTGSS_INT_CLR;
454 omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR);
455 return 0;
456exit1:
457 clk_disable(musb->phy_clock);
458 clk_put(musb->phy_clock);
459exit0:
460 clk_disable(musb->clock);
461 return status;
462}
463
464int musb_platform_exit(struct musb *musb)
465{
466 if (is_host_enabled(musb))
467 del_timer_sync(&otg_workaround);
468
469 phy_off();
470
471 otg_put_transceiver(musb->xceiv);
472 usb_nop_xceiv_unregister();
473
474 clk_disable(musb->clock);
475
476 clk_disable(musb->phy_clock);
477 clk_put(musb->phy_clock);
478
479 return 0;
480}
481
482#ifdef CONFIG_PM
483void musb_platform_save_context(struct musb *musb,
484 struct musb_context_registers *musb_context)
485{
486 phy_off();
487}
488
489void musb_platform_restore_context(struct musb *musb,
490 struct musb_context_registers *musb_context)
491{
492 phy_on();
493}
494#endif
495
496/* AM35x supports only 32bit read operation */
497void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
498{
499 void __iomem *fifo = hw_ep->fifo;
500 u32 val;
501 int i;
502
503 /* Read for 32bit-aligned destination address */
504 if (likely((0x03 & (unsigned long) dst) == 0) && len >= 4) {
505 readsl(fifo, dst, len >> 2);
506 dst += len & ~0x03;
507 len &= 0x03;
508 }
509 /*
510 * Now read the remaining 1 to 3 byte or complete length if
511 * unaligned address.
512 */
513 if (len > 4) {
514 for (i = 0; i < (len >> 2); i++) {
515 *(u32 *) dst = musb_readl(fifo, 0);
516 dst += 4;
517 }
518 len &= 0x03;
519 }
520 if (len > 0) {
521 val = musb_readl(fifo, 0);
522 memcpy(dst, &val, len);
523 }
524}
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index b611420a8050..611a9d274363 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -342,8 +342,10 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
342 342
343 usb_nop_xceiv_register(); 343 usb_nop_xceiv_register();
344 musb->xceiv = otg_get_transceiver(); 344 musb->xceiv = otg_get_transceiver();
345 if (!musb->xceiv) 345 if (!musb->xceiv) {
346 gpio_free(musb->config->gpio_vrsel);
346 return -ENODEV; 347 return -ENODEV;
348 }
347 349
348 if (ANOMALY_05000346) { 350 if (ANOMALY_05000346) {
349 bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); 351 bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value);
@@ -394,8 +396,9 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
394 396
395int musb_platform_exit(struct musb *musb) 397int musb_platform_exit(struct musb *musb)
396{ 398{
397
398 gpio_free(musb->config->gpio_vrsel); 399 gpio_free(musb->config->gpio_vrsel);
399 400
401 otg_put_transceiver(musb->xceiv);
402 usb_nop_xceiv_unregister();
400 return 0; 403 return 0;
401} 404}
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index 5ab5bb89bae3..f5a65ff0ac2b 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -1156,7 +1156,7 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
1156 struct musb_hw_ep *hw_ep = NULL; 1156 struct musb_hw_ep *hw_ep = NULL;
1157 u32 rx, tx; 1157 u32 rx, tx;
1158 int i, index; 1158 int i, index;
1159 unsigned long flags; 1159 unsigned long uninitialized_var(flags);
1160 1160
1161 cppi = container_of(musb->dma_controller, struct cppi, controller); 1161 cppi = container_of(musb->dma_controller, struct cppi, controller);
1162 if (cppi->irq) 1162 if (cppi->irq)
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
new file mode 100644
index 000000000000..84427bebbf62
--- /dev/null
+++ b/drivers/usb/musb/da8xx.c
@@ -0,0 +1,469 @@
1/*
2 * Texas Instruments DA8xx/OMAP-L1x "glue layer"
3 *
4 * Copyright (c) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
5 *
6 * Based on the DaVinci "glue layer" code.
7 * Copyright (C) 2005-2006 by Texas Instruments
8 *
9 * This file is part of the Inventra Controller Driver for Linux.
10 *
11 * The Inventra Controller Driver for Linux is free software; you
12 * can redistribute it and/or modify it under the terms of the GNU
13 * General Public License version 2 as published by the Free Software
14 * Foundation.
15 *
16 * The Inventra Controller Driver for Linux is distributed in
17 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
18 * without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
20 * License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with The Inventra Controller Driver for Linux ; if not,
24 * write to the Free Software Foundation, Inc., 59 Temple Place,
25 * Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29#include <linux/init.h>
30#include <linux/clk.h>
31#include <linux/io.h>
32
33#include <mach/da8xx.h>
34#include <mach/usb.h>
35
36#include "musb_core.h"
37
38/*
39 * DA8XX specific definitions
40 */
41
42/* USB 2.0 OTG module registers */
43#define DA8XX_USB_REVISION_REG 0x00
44#define DA8XX_USB_CTRL_REG 0x04
45#define DA8XX_USB_STAT_REG 0x08
46#define DA8XX_USB_EMULATION_REG 0x0c
47#define DA8XX_USB_MODE_REG 0x10 /* Transparent, CDC, [Generic] RNDIS */
48#define DA8XX_USB_AUTOREQ_REG 0x14
49#define DA8XX_USB_SRP_FIX_TIME_REG 0x18
50#define DA8XX_USB_TEARDOWN_REG 0x1c
51#define DA8XX_USB_INTR_SRC_REG 0x20
52#define DA8XX_USB_INTR_SRC_SET_REG 0x24
53#define DA8XX_USB_INTR_SRC_CLEAR_REG 0x28
54#define DA8XX_USB_INTR_MASK_REG 0x2c
55#define DA8XX_USB_INTR_MASK_SET_REG 0x30
56#define DA8XX_USB_INTR_MASK_CLEAR_REG 0x34
57#define DA8XX_USB_INTR_SRC_MASKED_REG 0x38
58#define DA8XX_USB_END_OF_INTR_REG 0x3c
59#define DA8XX_USB_GENERIC_RNDIS_EP_SIZE_REG(n) (0x50 + (((n) - 1) << 2))
60
61/* Control register bits */
62#define DA8XX_SOFT_RESET_MASK 1
63
64#define DA8XX_USB_TX_EP_MASK 0x1f /* EP0 + 4 Tx EPs */
65#define DA8XX_USB_RX_EP_MASK 0x1e /* 4 Rx EPs */
66
67/* USB interrupt register bits */
68#define DA8XX_INTR_USB_SHIFT 16
69#define DA8XX_INTR_USB_MASK (0x1ff << DA8XX_INTR_USB_SHIFT) /* 8 Mentor */
70 /* interrupts and DRVVBUS interrupt */
71#define DA8XX_INTR_DRVVBUS 0x100
72#define DA8XX_INTR_RX_SHIFT 8
73#define DA8XX_INTR_RX_MASK (DA8XX_USB_RX_EP_MASK << DA8XX_INTR_RX_SHIFT)
74#define DA8XX_INTR_TX_SHIFT 0
75#define DA8XX_INTR_TX_MASK (DA8XX_USB_TX_EP_MASK << DA8XX_INTR_TX_SHIFT)
76
77#define DA8XX_MENTOR_CORE_OFFSET 0x400
78
79#define CFGCHIP2 IO_ADDRESS(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG)
80
81/*
82 * REVISIT (PM): we should be able to keep the PHY in low power mode most
83 * of the time (24 MHz oscillator and PLL off, etc.) by setting POWER.D0
84 * and, when in host mode, autosuspending idle root ports... PHY_PLLON
85 * (overriding SUSPENDM?) then likely needs to stay off.
86 */
87
88static inline void phy_on(void)
89{
90 u32 cfgchip2 = __raw_readl(CFGCHIP2);
91
92 /*
93 * Start the on-chip PHY and its PLL.
94 */
95 cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN);
96 cfgchip2 |= CFGCHIP2_PHY_PLLON;
97 __raw_writel(cfgchip2, CFGCHIP2);
98
99 pr_info("Waiting for USB PHY clock good...\n");
100 while (!(__raw_readl(CFGCHIP2) & CFGCHIP2_PHYCLKGD))
101 cpu_relax();
102}
103
104static inline void phy_off(void)
105{
106 u32 cfgchip2 = __raw_readl(CFGCHIP2);
107
108 /*
109 * Ensure that USB 1.1 reference clock is not being sourced from
110 * USB 2.0 PHY. Otherwise do not power down the PHY.
111 */
112 if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX) &&
113 (cfgchip2 & CFGCHIP2_USB1SUSPENDM)) {
114 pr_warning("USB 1.1 clocked from USB 2.0 PHY -- "
115 "can't power it down\n");
116 return;
117 }
118
119 /*
120 * Power down the on-chip PHY.
121 */
122 cfgchip2 |= CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN;
123 __raw_writel(cfgchip2, CFGCHIP2);
124}
125
126/*
127 * Because we don't set CTRL.UINT, it's "important" to:
128 * - not read/write INTRUSB/INTRUSBE (except during
129 * initial setup, as a workaround);
130 * - use INTSET/INTCLR instead.
131 */
132
133/**
134 * musb_platform_enable - enable interrupts
135 */
136void musb_platform_enable(struct musb *musb)
137{
138 void __iomem *reg_base = musb->ctrl_base;
139 u32 mask;
140
141 /* Workaround: setup IRQs through both register sets. */
142 mask = ((musb->epmask & DA8XX_USB_TX_EP_MASK) << DA8XX_INTR_TX_SHIFT) |
143 ((musb->epmask & DA8XX_USB_RX_EP_MASK) << DA8XX_INTR_RX_SHIFT) |
144 DA8XX_INTR_USB_MASK;
145 musb_writel(reg_base, DA8XX_USB_INTR_MASK_SET_REG, mask);
146
147 /* Force the DRVVBUS IRQ so we can start polling for ID change. */
148 if (is_otg_enabled(musb))
149 musb_writel(reg_base, DA8XX_USB_INTR_SRC_SET_REG,
150 DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT);
151}
152
153/**
154 * musb_platform_disable - disable HDRC and flush interrupts
155 */
156void musb_platform_disable(struct musb *musb)
157{
158 void __iomem *reg_base = musb->ctrl_base;
159
160 musb_writel(reg_base, DA8XX_USB_INTR_MASK_CLEAR_REG,
161 DA8XX_INTR_USB_MASK |
162 DA8XX_INTR_TX_MASK | DA8XX_INTR_RX_MASK);
163 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
164 musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
165}
166
167#ifdef CONFIG_USB_MUSB_HDRC_HCD
168#define portstate(stmt) stmt
169#else
170#define portstate(stmt)
171#endif
172
173static void da8xx_set_vbus(struct musb *musb, int is_on)
174{
175 WARN_ON(is_on && is_peripheral_active(musb));
176}
177
178#define POLL_SECONDS 2
179
180static struct timer_list otg_workaround;
181
182static void otg_timer(unsigned long _musb)
183{
184 struct musb *musb = (void *)_musb;
185 void __iomem *mregs = musb->mregs;
186 u8 devctl;
187 unsigned long flags;
188
189 /*
190 * We poll because DaVinci's won't expose several OTG-critical
191 * status change events (from the transceiver) otherwise.
192 */
193 devctl = musb_readb(mregs, MUSB_DEVCTL);
194 DBG(7, "Poll devctl %02x (%s)\n", devctl, otg_state_string(musb));
195
196 spin_lock_irqsave(&musb->lock, flags);
197 switch (musb->xceiv->state) {
198 case OTG_STATE_A_WAIT_BCON:
199 devctl &= ~MUSB_DEVCTL_SESSION;
200 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
201
202 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
203 if (devctl & MUSB_DEVCTL_BDEVICE) {
204 musb->xceiv->state = OTG_STATE_B_IDLE;
205 MUSB_DEV_MODE(musb);
206 } else {
207 musb->xceiv->state = OTG_STATE_A_IDLE;
208 MUSB_HST_MODE(musb);
209 }
210 break;
211 case OTG_STATE_A_WAIT_VFALL:
212 /*
213 * Wait till VBUS falls below SessionEnd (~0.2 V); the 1.3
214 * RTL seems to mis-handle session "start" otherwise (or in
215 * our case "recover"), in routine "VBUS was valid by the time
216 * VBUSERR got reported during enumeration" cases.
217 */
218 if (devctl & MUSB_DEVCTL_VBUS) {
219 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
220 break;
221 }
222 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
223 musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
224 MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
225 break;
226 case OTG_STATE_B_IDLE:
227 if (!is_peripheral_enabled(musb))
228 break;
229
230 /*
231 * There's no ID-changed IRQ, so we have no good way to tell
232 * when to switch to the A-Default state machine (by setting
233 * the DEVCTL.Session bit).
234 *
235 * Workaround: whenever we're in B_IDLE, try setting the
236 * session flag every few seconds. If it works, ID was
237 * grounded and we're now in the A-Default state machine.
238 *
239 * NOTE: setting the session flag is _supposed_ to trigger
240 * SRP but clearly it doesn't.
241 */
242 musb_writeb(mregs, MUSB_DEVCTL, devctl | MUSB_DEVCTL_SESSION);
243 devctl = musb_readb(mregs, MUSB_DEVCTL);
244 if (devctl & MUSB_DEVCTL_BDEVICE)
245 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
246 else
247 musb->xceiv->state = OTG_STATE_A_IDLE;
248 break;
249 default:
250 break;
251 }
252 spin_unlock_irqrestore(&musb->lock, flags);
253}
254
255void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
256{
257 static unsigned long last_timer;
258
259 if (!is_otg_enabled(musb))
260 return;
261
262 if (timeout == 0)
263 timeout = jiffies + msecs_to_jiffies(3);
264
265 /* Never idle if active, or when VBUS timeout is not set as host */
266 if (musb->is_active || (musb->a_wait_bcon == 0 &&
267 musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
268 DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
269 del_timer(&otg_workaround);
270 last_timer = jiffies;
271 return;
272 }
273
274 if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
275 DBG(4, "Longer idle timer already pending, ignoring...\n");
276 return;
277 }
278 last_timer = timeout;
279
280 DBG(4, "%s inactive, starting idle timer for %u ms\n",
281 otg_state_string(musb), jiffies_to_msecs(timeout - jiffies));
282 mod_timer(&otg_workaround, timeout);
283}
284
285static irqreturn_t da8xx_interrupt(int irq, void *hci)
286{
287 struct musb *musb = hci;
288 void __iomem *reg_base = musb->ctrl_base;
289 unsigned long flags;
290 irqreturn_t ret = IRQ_NONE;
291 u32 status;
292
293 spin_lock_irqsave(&musb->lock, flags);
294
295 /*
296 * NOTE: DA8XX shadows the Mentor IRQs. Don't manage them through
297 * the Mentor registers (except for setup), use the TI ones and EOI.
298 */
299
300 /* Acknowledge and handle non-CPPI interrupts */
301 status = musb_readl(reg_base, DA8XX_USB_INTR_SRC_MASKED_REG);
302 if (!status)
303 goto eoi;
304
305 musb_writel(reg_base, DA8XX_USB_INTR_SRC_CLEAR_REG, status);
306 DBG(4, "USB IRQ %08x\n", status);
307
308 musb->int_rx = (status & DA8XX_INTR_RX_MASK) >> DA8XX_INTR_RX_SHIFT;
309 musb->int_tx = (status & DA8XX_INTR_TX_MASK) >> DA8XX_INTR_TX_SHIFT;
310 musb->int_usb = (status & DA8XX_INTR_USB_MASK) >> DA8XX_INTR_USB_SHIFT;
311
312 /*
313 * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
314 * DA8xx's missing ID change IRQ. We need an ID change IRQ to
315 * switch appropriately between halves of the OTG state machine.
316 * Managing DEVCTL.Session per Mentor docs requires that we know its
317 * value but DEVCTL.BDevice is invalid without DEVCTL.Session set.
318 * Also, DRVVBUS pulses for SRP (but not at 5 V)...
319 */
320 if (status & (DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT)) {
321 int drvvbus = musb_readl(reg_base, DA8XX_USB_STAT_REG);
322 void __iomem *mregs = musb->mregs;
323 u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
324 int err;
325
326 err = is_host_enabled(musb) && (musb->int_usb &
327 MUSB_INTR_VBUSERROR);
328 if (err) {
329 /*
330 * The Mentor core doesn't debounce VBUS as needed
331 * to cope with device connect current spikes. This
332 * means it's not uncommon for bus-powered devices
333 * to get VBUS errors during enumeration.
334 *
335 * This is a workaround, but newer RTL from Mentor
336 * seems to allow a better one: "re"-starting sessions
337 * without waiting for VBUS to stop registering in
338 * devctl.
339 */
340 musb->int_usb &= ~MUSB_INTR_VBUSERROR;
341 musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
342 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
343 WARNING("VBUS error workaround (delay coming)\n");
344 } else if (is_host_enabled(musb) && drvvbus) {
345 MUSB_HST_MODE(musb);
346 musb->xceiv->default_a = 1;
347 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
348 portstate(musb->port1_status |= USB_PORT_STAT_POWER);
349 del_timer(&otg_workaround);
350 } else {
351 musb->is_active = 0;
352 MUSB_DEV_MODE(musb);
353 musb->xceiv->default_a = 0;
354 musb->xceiv->state = OTG_STATE_B_IDLE;
355 portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
356 }
357
358 DBG(2, "VBUS %s (%s)%s, devctl %02x\n",
359 drvvbus ? "on" : "off",
360 otg_state_string(musb),
361 err ? " ERROR" : "",
362 devctl);
363 ret = IRQ_HANDLED;
364 }
365
366 if (musb->int_tx || musb->int_rx || musb->int_usb)
367 ret |= musb_interrupt(musb);
368
369 eoi:
370 /* EOI needs to be written for the IRQ to be re-asserted. */
371 if (ret == IRQ_HANDLED || status)
372 musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
373
374 /* Poll for ID change */
375 if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
376 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
377
378 spin_unlock_irqrestore(&musb->lock, flags);
379
380 return ret;
381}
382
383int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
384{
385 u32 cfgchip2 = __raw_readl(CFGCHIP2);
386
387 cfgchip2 &= ~CFGCHIP2_OTGMODE;
388 switch (musb_mode) {
389#ifdef CONFIG_USB_MUSB_HDRC_HCD
390 case MUSB_HOST: /* Force VBUS valid, ID = 0 */
391 cfgchip2 |= CFGCHIP2_FORCE_HOST;
392 break;
393#endif
394#ifdef CONFIG_USB_GADGET_MUSB_HDRC
395 case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
396 cfgchip2 |= CFGCHIP2_FORCE_DEVICE;
397 break;
398#endif
399#ifdef CONFIG_USB_MUSB_OTG
400 case MUSB_OTG: /* Don't override the VBUS/ID comparators */
401 cfgchip2 |= CFGCHIP2_NO_OVERRIDE;
402 break;
403#endif
404 default:
405 DBG(2, "Trying to set unsupported mode %u\n", musb_mode);
406 }
407
408 __raw_writel(cfgchip2, CFGCHIP2);
409 return 0;
410}
411
412int __init musb_platform_init(struct musb *musb, void *board_data)
413{
414 void __iomem *reg_base = musb->ctrl_base;
415 u32 rev;
416
417 musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
418
419 clk_enable(musb->clock);
420
421 /* Returns zero if e.g. not clocked */
422 rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
423 if (!rev)
424 goto fail;
425
426 usb_nop_xceiv_register();
427 musb->xceiv = otg_get_transceiver();
428 if (!musb->xceiv)
429 goto fail;
430
431 if (is_host_enabled(musb))
432 setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);
433
434 musb->board_set_vbus = da8xx_set_vbus;
435
436 /* Reset the controller */
437 musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
438
439 /* Start the on-chip PHY and its PLL. */
440 phy_on();
441
442 msleep(5);
443
444 /* NOTE: IRQs are in mixed mode, not bypass to pure MUSB */
445 pr_debug("DA8xx OTG revision %08x, PHY %03x, control %02x\n",
446 rev, __raw_readl(CFGCHIP2),
447 musb_readb(reg_base, DA8XX_USB_CTRL_REG));
448
449 musb->isr = da8xx_interrupt;
450 return 0;
451fail:
452 clk_disable(musb->clock);
453 return -ENODEV;
454}
455
456int musb_platform_exit(struct musb *musb)
457{
458 if (is_host_enabled(musb))
459 del_timer_sync(&otg_workaround);
460
461 phy_off();
462
463 otg_put_transceiver(musb->xceiv);
464 usb_nop_xceiv_unregister();
465
466 clk_disable(musb->clock);
467
468 return 0;
469}
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 57624361c1de..6e67629f50cc 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -446,6 +446,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
446fail: 446fail:
447 clk_disable(musb->clock); 447 clk_disable(musb->clock);
448 448
449 otg_put_transceiver(musb->xceiv);
449 usb_nop_xceiv_unregister(); 450 usb_nop_xceiv_unregister();
450 return -ENODEV; 451 return -ENODEV;
451} 452}
@@ -496,6 +497,7 @@ int musb_platform_exit(struct musb *musb)
496 497
497 clk_disable(musb->clock); 498 clk_disable(musb->clock);
498 499
500 otg_put_transceiver(musb->xceiv);
499 usb_nop_xceiv_unregister(); 501 usb_nop_xceiv_unregister();
500 502
501 return 0; 503 return 0;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 540c766c4f86..c9f9024c5515 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -272,6 +272,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
272 } 272 }
273} 273}
274 274
275#if !defined(CONFIG_USB_MUSB_AM35X)
275/* 276/*
276 * Unload an endpoint's FIFO 277 * Unload an endpoint's FIFO
277 */ 278 */
@@ -309,6 +310,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
309 readsb(fifo, dst, len); 310 readsb(fifo, dst, len);
310 } 311 }
311} 312}
313#endif
312 314
313#endif /* normal PIO */ 315#endif /* normal PIO */
314 316
@@ -550,6 +552,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
550 if (int_usb & MUSB_INTR_SESSREQ) { 552 if (int_usb & MUSB_INTR_SESSREQ) {
551 void __iomem *mbase = musb->mregs; 553 void __iomem *mbase = musb->mregs;
552 554
555 if (devctl & MUSB_DEVCTL_BDEVICE) {
556 DBG(3, "SessReq while on B state\n");
557 return IRQ_HANDLED;
558 }
559
553 DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(musb)); 560 DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(musb));
554 561
555 /* IRQ arrives from ID pin sense or (later, if VBUS power 562 /* IRQ arrives from ID pin sense or (later, if VBUS power
@@ -1921,10 +1928,6 @@ static void musb_free(struct musb *musb)
1921 dma_controller_destroy(c); 1928 dma_controller_destroy(c);
1922 } 1929 }
1923 1930
1924#ifdef CONFIG_USB_MUSB_OTG
1925 put_device(musb->xceiv->dev);
1926#endif
1927
1928#ifdef CONFIG_USB_MUSB_HDRC_HCD 1931#ifdef CONFIG_USB_MUSB_HDRC_HCD
1929 usb_put_hcd(musb_to_hcd(musb)); 1932 usb_put_hcd(musb_to_hcd(musb));
1930#else 1933#else
@@ -2266,6 +2269,7 @@ void musb_save_context(struct musb *musb)
2266{ 2269{
2267 int i; 2270 int i;
2268 void __iomem *musb_base = musb->mregs; 2271 void __iomem *musb_base = musb->mregs;
2272 void __iomem *epio;
2269 2273
2270 if (is_host_enabled(musb)) { 2274 if (is_host_enabled(musb)) {
2271 musb_context.frame = musb_readw(musb_base, MUSB_FRAME); 2275 musb_context.frame = musb_readw(musb_base, MUSB_FRAME);
@@ -2279,16 +2283,16 @@ void musb_save_context(struct musb *musb)
2279 musb_context.index = musb_readb(musb_base, MUSB_INDEX); 2283 musb_context.index = musb_readb(musb_base, MUSB_INDEX);
2280 musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL); 2284 musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL);
2281 2285
2282 for (i = 0; i < MUSB_C_NUM_EPS; ++i) { 2286 for (i = 0; i < musb->config->num_eps; ++i) {
2283 musb_writeb(musb_base, MUSB_INDEX, i); 2287 epio = musb->endpoints[i].regs;
2284 musb_context.index_regs[i].txmaxp = 2288 musb_context.index_regs[i].txmaxp =
2285 musb_readw(musb_base, 0x10 + MUSB_TXMAXP); 2289 musb_readw(epio, MUSB_TXMAXP);
2286 musb_context.index_regs[i].txcsr = 2290 musb_context.index_regs[i].txcsr =
2287 musb_readw(musb_base, 0x10 + MUSB_TXCSR); 2291 musb_readw(epio, MUSB_TXCSR);
2288 musb_context.index_regs[i].rxmaxp = 2292 musb_context.index_regs[i].rxmaxp =
2289 musb_readw(musb_base, 0x10 + MUSB_RXMAXP); 2293 musb_readw(epio, MUSB_RXMAXP);
2290 musb_context.index_regs[i].rxcsr = 2294 musb_context.index_regs[i].rxcsr =
2291 musb_readw(musb_base, 0x10 + MUSB_RXCSR); 2295 musb_readw(epio, MUSB_RXCSR);
2292 2296
2293 if (musb->dyn_fifo) { 2297 if (musb->dyn_fifo) {
2294 musb_context.index_regs[i].txfifoadd = 2298 musb_context.index_regs[i].txfifoadd =
@@ -2302,13 +2306,13 @@ void musb_save_context(struct musb *musb)
2302 } 2306 }
2303 if (is_host_enabled(musb)) { 2307 if (is_host_enabled(musb)) {
2304 musb_context.index_regs[i].txtype = 2308 musb_context.index_regs[i].txtype =
2305 musb_readb(musb_base, 0x10 + MUSB_TXTYPE); 2309 musb_readb(epio, MUSB_TXTYPE);
2306 musb_context.index_regs[i].txinterval = 2310 musb_context.index_regs[i].txinterval =
2307 musb_readb(musb_base, 0x10 + MUSB_TXINTERVAL); 2311 musb_readb(epio, MUSB_TXINTERVAL);
2308 musb_context.index_regs[i].rxtype = 2312 musb_context.index_regs[i].rxtype =
2309 musb_readb(musb_base, 0x10 + MUSB_RXTYPE); 2313 musb_readb(epio, MUSB_RXTYPE);
2310 musb_context.index_regs[i].rxinterval = 2314 musb_context.index_regs[i].rxinterval =
2311 musb_readb(musb_base, 0x10 + MUSB_RXINTERVAL); 2315 musb_readb(epio, MUSB_RXINTERVAL);
2312 2316
2313 musb_context.index_regs[i].txfunaddr = 2317 musb_context.index_regs[i].txfunaddr =
2314 musb_read_txfunaddr(musb_base, i); 2318 musb_read_txfunaddr(musb_base, i);
@@ -2326,8 +2330,6 @@ void musb_save_context(struct musb *musb)
2326 } 2330 }
2327 } 2331 }
2328 2332
2329 musb_writeb(musb_base, MUSB_INDEX, musb_context.index);
2330
2331 musb_platform_save_context(musb, &musb_context); 2333 musb_platform_save_context(musb, &musb_context);
2332} 2334}
2333 2335
@@ -2336,6 +2338,7 @@ void musb_restore_context(struct musb *musb)
2336 int i; 2338 int i;
2337 void __iomem *musb_base = musb->mregs; 2339 void __iomem *musb_base = musb->mregs;
2338 void __iomem *ep_target_regs; 2340 void __iomem *ep_target_regs;
2341 void __iomem *epio;
2339 2342
2340 musb_platform_restore_context(musb, &musb_context); 2343 musb_platform_restore_context(musb, &musb_context);
2341 2344
@@ -2350,15 +2353,15 @@ void musb_restore_context(struct musb *musb)
2350 musb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe); 2353 musb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe);
2351 musb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl); 2354 musb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl);
2352 2355
2353 for (i = 0; i < MUSB_C_NUM_EPS; ++i) { 2356 for (i = 0; i < musb->config->num_eps; ++i) {
2354 musb_writeb(musb_base, MUSB_INDEX, i); 2357 epio = musb->endpoints[i].regs;
2355 musb_writew(musb_base, 0x10 + MUSB_TXMAXP, 2358 musb_writew(epio, MUSB_TXMAXP,
2356 musb_context.index_regs[i].txmaxp); 2359 musb_context.index_regs[i].txmaxp);
2357 musb_writew(musb_base, 0x10 + MUSB_TXCSR, 2360 musb_writew(epio, MUSB_TXCSR,
2358 musb_context.index_regs[i].txcsr); 2361 musb_context.index_regs[i].txcsr);
2359 musb_writew(musb_base, 0x10 + MUSB_RXMAXP, 2362 musb_writew(epio, MUSB_RXMAXP,
2360 musb_context.index_regs[i].rxmaxp); 2363 musb_context.index_regs[i].rxmaxp);
2361 musb_writew(musb_base, 0x10 + MUSB_RXCSR, 2364 musb_writew(epio, MUSB_RXCSR,
2362 musb_context.index_regs[i].rxcsr); 2365 musb_context.index_regs[i].rxcsr);
2363 2366
2364 if (musb->dyn_fifo) { 2367 if (musb->dyn_fifo) {
@@ -2373,13 +2376,13 @@ void musb_restore_context(struct musb *musb)
2373 } 2376 }
2374 2377
2375 if (is_host_enabled(musb)) { 2378 if (is_host_enabled(musb)) {
2376 musb_writeb(musb_base, 0x10 + MUSB_TXTYPE, 2379 musb_writeb(epio, MUSB_TXTYPE,
2377 musb_context.index_regs[i].txtype); 2380 musb_context.index_regs[i].txtype);
2378 musb_writeb(musb_base, 0x10 + MUSB_TXINTERVAL, 2381 musb_writeb(epio, MUSB_TXINTERVAL,
2379 musb_context.index_regs[i].txinterval); 2382 musb_context.index_regs[i].txinterval);
2380 musb_writeb(musb_base, 0x10 + MUSB_RXTYPE, 2383 musb_writeb(epio, MUSB_RXTYPE,
2381 musb_context.index_regs[i].rxtype); 2384 musb_context.index_regs[i].rxtype);
2382 musb_writeb(musb_base, 0x10 + MUSB_RXINTERVAL, 2385 musb_writeb(epio, MUSB_RXINTERVAL,
2383 2386
2384 musb_context.index_regs[i].rxinterval); 2387 musb_context.index_regs[i].rxinterval);
2385 musb_write_txfunaddr(musb_base, i, 2388 musb_write_txfunaddr(musb_base, i,
@@ -2400,8 +2403,6 @@ void musb_restore_context(struct musb *musb)
2400 musb_context.index_regs[i].rxhubport); 2403 musb_context.index_regs[i].rxhubport);
2401 } 2404 }
2402 } 2405 }
2403
2404 musb_writeb(musb_base, MUSB_INDEX, musb_context.index);
2405} 2406}
2406 2407
2407static int musb_suspend(struct device *dev) 2408static int musb_suspend(struct device *dev)
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 91d67794e350..69797e5b46a7 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -330,6 +330,7 @@ struct musb {
330 /* device lock */ 330 /* device lock */
331 spinlock_t lock; 331 spinlock_t lock;
332 struct clk *clock; 332 struct clk *clock;
333 struct clk *phy_clock;
333 irqreturn_t (*isr)(int, void *); 334 irqreturn_t (*isr)(int, void *);
334 struct work_struct irq_work; 335 struct work_struct irq_work;
335 u16 hwvers; 336 u16 hwvers;
@@ -599,6 +600,7 @@ extern void musb_hnp_stop(struct musb *musb);
599extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode); 600extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode);
600 601
601#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \ 602#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \
603 defined(CONFIG_ARCH_DAVINCI_DA8XX) || \
602 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ 604 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
603 defined(CONFIG_ARCH_OMAP4) 605 defined(CONFIG_ARCH_OMAP4)
604extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout); 606extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout);
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
index d73afdbde3ee..94f6973cf8f7 100644
--- a/drivers/usb/musb/musb_debug.h
+++ b/drivers/usb/musb/musb_debug.h
@@ -42,11 +42,10 @@
42#define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args) 42#define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
43#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args) 43#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
44 44
45#define xprintk(level, facility, format, args...) do { \ 45#define DBG(level, format, args...) do { \
46 if (_dbg_level(level)) { \ 46 if (_dbg_level(level)) \
47 printk(facility "%s %d: " format , \ 47 pr_debug("%s %d: " format, __func__, __LINE__, ## args); \
48 __func__, __LINE__ , ## args); \ 48 } while (0)
49 } } while (0)
50 49
51extern unsigned musb_debug; 50extern unsigned musb_debug;
52 51
@@ -55,8 +54,6 @@ static inline int _dbg_level(unsigned l)
55 return musb_debug >= l; 54 return musb_debug >= l;
56} 55}
57 56
58#define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args)
59
60extern const char *otg_state_string(struct musb *); 57extern const char *otg_state_string(struct musb *);
61 58
62#ifdef CONFIG_DEBUG_FS 59#ifdef CONFIG_DEBUG_FS
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index d065e23f123e..5d815049cbaa 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -337,13 +337,15 @@ static void txstate(struct musb *musb, struct musb_request *req)
337 csr |= (MUSB_TXCSR_DMAENAB | 337 csr |= (MUSB_TXCSR_DMAENAB |
338 MUSB_TXCSR_MODE); 338 MUSB_TXCSR_MODE);
339 /* against programming guide */ 339 /* against programming guide */
340 } else 340 } else {
341 csr |= (MUSB_TXCSR_AUTOSET 341 csr |= (MUSB_TXCSR_DMAENAB
342 | MUSB_TXCSR_DMAENAB
343 | MUSB_TXCSR_DMAMODE 342 | MUSB_TXCSR_DMAMODE
344 | MUSB_TXCSR_MODE); 343 | MUSB_TXCSR_MODE);
345 344 if (!musb_ep->hb_mult)
345 csr |= MUSB_TXCSR_AUTOSET;
346 }
346 csr &= ~MUSB_TXCSR_P_UNDERRUN; 347 csr &= ~MUSB_TXCSR_P_UNDERRUN;
348
347 musb_writew(epio, MUSB_TXCSR, csr); 349 musb_writew(epio, MUSB_TXCSR, csr);
348 } 350 }
349 } 351 }
@@ -475,40 +477,39 @@ void musb_g_tx(struct musb *musb, u8 epnum)
475 epnum, csr, musb_ep->dma->actual_len, request); 477 epnum, csr, musb_ep->dma->actual_len, request);
476 } 478 }
477 479
478 if (is_dma || request->actual == request->length) { 480 /*
479 /* 481 * First, maybe a terminating short packet. Some DMA
480 * First, maybe a terminating short packet. Some DMA 482 * engines might handle this by themselves.
481 * engines might handle this by themselves. 483 */
482 */ 484 if ((request->zero && request->length
483 if ((request->zero && request->length 485 && (request->length % musb_ep->packet_sz == 0)
484 && request->length % musb_ep->packet_sz == 0) 486 && (request->actual == request->length))
485#ifdef CONFIG_USB_INVENTRA_DMA 487#ifdef CONFIG_USB_INVENTRA_DMA
486 || (is_dma && (!dma->desired_mode || 488 || (is_dma && (!dma->desired_mode ||
487 (request->actual & 489 (request->actual &
488 (musb_ep->packet_sz - 1)))) 490 (musb_ep->packet_sz - 1))))
489#endif 491#endif
490 ) { 492 ) {
491 /* 493 /*
492 * On DMA completion, FIFO may not be 494 * On DMA completion, FIFO may not be
493 * available yet... 495 * available yet...
494 */ 496 */
495 if (csr & MUSB_TXCSR_TXPKTRDY) 497 if (csr & MUSB_TXCSR_TXPKTRDY)
496 return; 498 return;
497 499
498 DBG(4, "sending zero pkt\n"); 500 DBG(4, "sending zero pkt\n");
499 musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_MODE 501 musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_MODE
500 | MUSB_TXCSR_TXPKTRDY); 502 | MUSB_TXCSR_TXPKTRDY);
501 request->zero = 0; 503 request->zero = 0;
502 } 504 }
503 505
504 if (request->actual == request->length) { 506 if (request->actual == request->length) {
505 musb_g_giveback(musb_ep, request, 0); 507 musb_g_giveback(musb_ep, request, 0);
506 request = musb_ep->desc ? next_request(musb_ep) : NULL; 508 request = musb_ep->desc ? next_request(musb_ep) : NULL;
507 if (!request) { 509 if (!request) {
508 DBG(4, "%s idle now\n", 510 DBG(4, "%s idle now\n",
509 musb_ep->end_point.name); 511 musb_ep->end_point.name);
510 return; 512 return;
511 }
512 } 513 }
513 } 514 }
514 515
@@ -643,7 +644,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)
643 */ 644 */
644 645
645 csr |= MUSB_RXCSR_DMAENAB; 646 csr |= MUSB_RXCSR_DMAENAB;
646 csr |= MUSB_RXCSR_AUTOCLEAR; 647 if (!musb_ep->hb_mult &&
648 musb_ep->hw_ep->rx_double_buffered)
649 csr |= MUSB_RXCSR_AUTOCLEAR;
647#ifdef USE_MODE1 650#ifdef USE_MODE1
648 /* csr |= MUSB_RXCSR_DMAMODE; */ 651 /* csr |= MUSB_RXCSR_DMAMODE; */
649 652
@@ -772,7 +775,7 @@ void musb_g_rx(struct musb *musb, u8 epnum)
772 musb_writew(epio, MUSB_RXCSR, csr); 775 musb_writew(epio, MUSB_RXCSR, csr);
773 776
774 DBG(3, "%s iso overrun on %p\n", musb_ep->name, request); 777 DBG(3, "%s iso overrun on %p\n", musb_ep->name, request);
775 if (request && request->status == -EINPROGRESS) 778 if (request->status == -EINPROGRESS)
776 request->status = -EOVERFLOW; 779 request->status = -EOVERFLOW;
777 } 780 }
778 if (csr & MUSB_RXCSR_INCOMPRX) { 781 if (csr & MUSB_RXCSR_INCOMPRX) {
@@ -825,14 +828,8 @@ void musb_g_rx(struct musb *musb, u8 epnum)
825 return; 828 return;
826 } 829 }
827 830
828 /* analyze request if the ep is hot */ 831 /* Analyze request */
829 if (request) 832 rxstate(musb, to_musb_request(request));
830 rxstate(musb, to_musb_request(request));
831 else
832 DBG(3, "packet waiting for %s%s request\n",
833 musb_ep->desc ? "" : "inactive ",
834 musb_ep->end_point.name);
835 return;
836} 833}
837 834
838/* ------------------------------------------------------------ */ 835/* ------------------------------------------------------------ */
@@ -875,9 +872,25 @@ static int musb_gadget_enable(struct usb_ep *ep,
875 872
876 /* REVISIT this rules out high bandwidth periodic transfers */ 873 /* REVISIT this rules out high bandwidth periodic transfers */
877 tmp = le16_to_cpu(desc->wMaxPacketSize); 874 tmp = le16_to_cpu(desc->wMaxPacketSize);
878 if (tmp & ~0x07ff) 875 if (tmp & ~0x07ff) {
879 goto fail; 876 int ok;
880 musb_ep->packet_sz = tmp; 877
878 if (usb_endpoint_dir_in(desc))
879 ok = musb->hb_iso_tx;
880 else
881 ok = musb->hb_iso_rx;
882
883 if (!ok) {
884 DBG(4, "%s: not support ISO high bandwidth\n", __func__);
885 goto fail;
886 }
887 musb_ep->hb_mult = (tmp >> 11) & 3;
888 } else {
889 musb_ep->hb_mult = 0;
890 }
891
892 musb_ep->packet_sz = tmp & 0x7ff;
893 tmp = musb_ep->packet_sz * (musb_ep->hb_mult + 1);
881 894
882 /* enable the interrupts for the endpoint, set the endpoint 895 /* enable the interrupts for the endpoint, set the endpoint
883 * packet size (or fail), set the mode, clear the fifo 896 * packet size (or fail), set the mode, clear the fifo
@@ -890,8 +903,11 @@ static int musb_gadget_enable(struct usb_ep *ep,
890 musb_ep->is_in = 1; 903 musb_ep->is_in = 1;
891 if (!musb_ep->is_in) 904 if (!musb_ep->is_in)
892 goto fail; 905 goto fail;
893 if (tmp > hw_ep->max_packet_sz_tx) 906
907 if (tmp > hw_ep->max_packet_sz_tx) {
908 DBG(4, "%s: packet size beyond hw fifo size\n", __func__);
894 goto fail; 909 goto fail;
910 }
895 911
896 int_txe |= (1 << epnum); 912 int_txe |= (1 << epnum);
897 musb_writew(mbase, MUSB_INTRTXE, int_txe); 913 musb_writew(mbase, MUSB_INTRTXE, int_txe);
@@ -906,7 +922,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
906 if (musb->hwvers < MUSB_HWVERS_2000) 922 if (musb->hwvers < MUSB_HWVERS_2000)
907 musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); 923 musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx);
908 else 924 else
909 musb_writew(regs, MUSB_TXMAXP, tmp); 925 musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
910 926
911 csr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG; 927 csr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG;
912 if (musb_readw(regs, MUSB_TXCSR) 928 if (musb_readw(regs, MUSB_TXCSR)
@@ -927,8 +943,11 @@ static int musb_gadget_enable(struct usb_ep *ep,
927 musb_ep->is_in = 0; 943 musb_ep->is_in = 0;
928 if (musb_ep->is_in) 944 if (musb_ep->is_in)
929 goto fail; 945 goto fail;
930 if (tmp > hw_ep->max_packet_sz_rx) 946
947 if (tmp > hw_ep->max_packet_sz_rx) {
948 DBG(4, "%s: packet size beyond hw fifo size\n", __func__);
931 goto fail; 949 goto fail;
950 }
932 951
933 int_rxe |= (1 << epnum); 952 int_rxe |= (1 << epnum);
934 musb_writew(mbase, MUSB_INTRRXE, int_rxe); 953 musb_writew(mbase, MUSB_INTRRXE, int_rxe);
@@ -942,7 +961,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
942 if (musb->hwvers < MUSB_HWVERS_2000) 961 if (musb->hwvers < MUSB_HWVERS_2000)
943 musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx); 962 musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx);
944 else 963 else
945 musb_writew(regs, MUSB_RXMAXP, tmp); 964 musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
946 965
947 /* force shared fifo to OUT-only mode */ 966 /* force shared fifo to OUT-only mode */
948 if (hw_ep->is_shared_fifo) { 967 if (hw_ep->is_shared_fifo) {
@@ -1699,9 +1718,11 @@ void musb_gadget_cleanup(struct musb *musb)
1699 * -ENOMEM no memeory to perform the operation 1718 * -ENOMEM no memeory to perform the operation
1700 * 1719 *
1701 * @param driver the gadget driver 1720 * @param driver the gadget driver
1721 * @param bind the driver's bind function
1702 * @return <0 if error, 0 if everything is fine 1722 * @return <0 if error, 0 if everything is fine
1703 */ 1723 */
1704int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1724int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1725 int (*bind)(struct usb_gadget *))
1705{ 1726{
1706 int retval; 1727 int retval;
1707 unsigned long flags; 1728 unsigned long flags;
@@ -1709,8 +1730,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1709 1730
1710 if (!driver 1731 if (!driver
1711 || driver->speed != USB_SPEED_HIGH 1732 || driver->speed != USB_SPEED_HIGH
1712 || !driver->bind 1733 || !bind || !driver->setup)
1713 || !driver->setup)
1714 return -EINVAL; 1734 return -EINVAL;
1715 1735
1716 /* driver must be initialized to support peripheral mode */ 1736 /* driver must be initialized to support peripheral mode */
@@ -1738,7 +1758,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1738 spin_unlock_irqrestore(&musb->lock, flags); 1758 spin_unlock_irqrestore(&musb->lock, flags);
1739 1759
1740 if (retval == 0) { 1760 if (retval == 0) {
1741 retval = driver->bind(&musb->g); 1761 retval = bind(&musb->g);
1742 if (retval != 0) { 1762 if (retval != 0) {
1743 DBG(3, "bind to driver %s failed --> %d\n", 1763 DBG(3, "bind to driver %s failed --> %d\n",
1744 driver->driver.name, retval); 1764 driver->driver.name, retval);
@@ -1786,7 +1806,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1786 1806
1787 return retval; 1807 return retval;
1788} 1808}
1789EXPORT_SYMBOL(usb_gadget_register_driver); 1809EXPORT_SYMBOL(usb_gadget_probe_driver);
1790 1810
1791static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver) 1811static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver)
1792{ 1812{
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 572b1da7f2dc..dec8dc008191 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -79,6 +79,8 @@ struct musb_ep {
79 79
80 /* true if lock must be dropped but req_list may not be advanced */ 80 /* true if lock must be dropped but req_list may not be advanced */
81 u8 busy; 81 u8 busy;
82
83 u8 hb_mult;
82}; 84};
83 85
84static inline struct musb_ep *to_musb_ep(struct usb_ep *ep) 86static inline struct musb_ep *to_musb_ep(struct usb_ep *ep)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 9e65c47cc98b..4d5bcb4e14d2 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -41,6 +41,7 @@
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/init.h> 42#include <linux/init.h>
43#include <linux/list.h> 43#include <linux/list.h>
44#include <linux/dma-mapping.h>
44 45
45#include "musb_core.h" 46#include "musb_core.h"
46#include "musb_host.h" 47#include "musb_host.h"
@@ -1119,6 +1120,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
1119 u32 status = 0; 1120 u32 status = 0;
1120 void __iomem *mbase = musb->mregs; 1121 void __iomem *mbase = musb->mregs;
1121 struct dma_channel *dma; 1122 struct dma_channel *dma;
1123 bool transfer_pending = false;
1122 1124
1123 musb_ep_select(mbase, epnum); 1125 musb_ep_select(mbase, epnum);
1124 tx_csr = musb_readw(epio, MUSB_TXCSR); 1126 tx_csr = musb_readw(epio, MUSB_TXCSR);
@@ -1279,7 +1281,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
1279 offset = d->offset; 1281 offset = d->offset;
1280 length = d->length; 1282 length = d->length;
1281 } 1283 }
1282 } else if (dma) { 1284 } else if (dma && urb->transfer_buffer_length == qh->offset) {
1283 done = true; 1285 done = true;
1284 } else { 1286 } else {
1285 /* see if we need to send more data, or ZLP */ 1287 /* see if we need to send more data, or ZLP */
@@ -1292,6 +1294,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
1292 if (!done) { 1294 if (!done) {
1293 offset = qh->offset; 1295 offset = qh->offset;
1294 length = urb->transfer_buffer_length - offset; 1296 length = urb->transfer_buffer_length - offset;
1297 transfer_pending = true;
1295 } 1298 }
1296 } 1299 }
1297 } 1300 }
@@ -1311,7 +1314,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
1311 urb->actual_length = qh->offset; 1314 urb->actual_length = qh->offset;
1312 musb_advance_schedule(musb, urb, hw_ep, USB_DIR_OUT); 1315 musb_advance_schedule(musb, urb, hw_ep, USB_DIR_OUT);
1313 return; 1316 return;
1314 } else if (usb_pipeisoc(pipe) && dma) { 1317 } else if ((usb_pipeisoc(pipe) || transfer_pending) && dma) {
1315 if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb, 1318 if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb,
1316 offset, length)) { 1319 offset, length)) {
1317 if (is_cppi_enabled() || tusb_dma_omap()) 1320 if (is_cppi_enabled() || tusb_dma_omap())
@@ -1332,6 +1335,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
1332 */ 1335 */
1333 if (length > qh->maxpacket) 1336 if (length > qh->maxpacket)
1334 length = qh->maxpacket; 1337 length = qh->maxpacket;
1338 /* Unmap the buffer so that CPU can use it */
1339 unmap_urb_for_dma(musb_to_hcd(musb), urb);
1335 musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset); 1340 musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset);
1336 qh->segsize = length; 1341 qh->segsize = length;
1337 1342
@@ -1752,6 +1757,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1752#endif /* Mentor DMA */ 1757#endif /* Mentor DMA */
1753 1758
1754 if (!dma) { 1759 if (!dma) {
1760 /* Unmap the buffer so that CPU can use it */
1761 unmap_urb_for_dma(musb_to_hcd(musb), urb);
1755 done = musb_host_packet_rx(musb, urb, 1762 done = musb_host_packet_rx(musb, urb,
1756 epnum, iso_err); 1763 epnum, iso_err);
1757 DBG(6, "read %spacket\n", done ? "last " : ""); 1764 DBG(6, "read %spacket\n", done ? "last " : "");
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 6dc107f25245..6f771af5cbdb 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -91,7 +91,7 @@ static struct dma_channel *dma_channel_allocate(struct dma_controller *c,
91 channel = &(musb_channel->channel); 91 channel = &(musb_channel->channel);
92 channel->private_data = musb_channel; 92 channel->private_data = musb_channel;
93 channel->status = MUSB_DMA_STATUS_FREE; 93 channel->status = MUSB_DMA_STATUS_FREE;
94 channel->max_len = 0x10000; 94 channel->max_len = 0x100000;
95 /* Tx => mode 1; Rx => mode 0 */ 95 /* Tx => mode 1; Rx => mode 0 */
96 channel->desired_mode = transmit; 96 channel->desired_mode = transmit;
97 channel->actual_len = 0; 97 channel->actual_len = 0;
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 2111a241dd03..ed618bde1eec 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -320,5 +320,6 @@ int musb_platform_exit(struct musb *musb)
320 320
321 musb_platform_suspend(musb); 321 musb_platform_suspend(musb);
322 322
323 otg_put_transceiver(musb->xceiv);
323 return 0; 324 return 0;
324} 325}
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 3c48e77a0aa2..bde40efc7046 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1152,6 +1152,8 @@ done:
1152 if (ret < 0) { 1152 if (ret < 0) {
1153 if (sync) 1153 if (sync)
1154 iounmap(sync); 1154 iounmap(sync);
1155
1156 otg_put_transceiver(musb->xceiv);
1155 usb_nop_xceiv_unregister(); 1157 usb_nop_xceiv_unregister();
1156 } 1158 }
1157 return ret; 1159 return ret;
@@ -1166,6 +1168,8 @@ int musb_platform_exit(struct musb *musb)
1166 musb->board_set_power(0); 1168 musb->board_set_power(0);
1167 1169
1168 iounmap(musb->sync_va); 1170 iounmap(musb->sync_va);
1171
1172 otg_put_transceiver(musb->xceiv);
1169 usb_nop_xceiv_unregister(); 1173 usb_nop_xceiv_unregister();
1170 return 0; 1174 return 0;
1171} 1175}
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 3b1289572d72..5ce07528cd0c 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -67,4 +67,18 @@ config NOP_USB_XCEIV
67 built-in with usb ip or which are autonomous and doesn't require any 67 built-in with usb ip or which are autonomous and doesn't require any
68 phy programming such as ISP1x04 etc. 68 phy programming such as ISP1x04 etc.
69 69
70config USB_LANGWELL_OTG
71 tristate "Intel Langwell USB OTG dual-role support"
72 depends on USB && PCI && INTEL_SCU_IPC
73 select USB_OTG
74 select USB_OTG_UTILS
75 help
76 Say Y here if you want to build Intel Langwell USB OTG
77 transciever driver in kernel. This driver implements role
78 switch between EHCI host driver and Langwell USB OTG
79 client driver.
80
81 To compile this driver as a module, choose M here: the
82 module will be called langwell_otg.
83
70endif # USB || OTG 84endif # USB || OTG
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index aeb49a8ec412..66f1b83e4fa7 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -2,6 +2,9 @@
2# OTG infrastructure and transceiver drivers 2# OTG infrastructure and transceiver drivers
3# 3#
4 4
5ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
6ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
7
5# infrastructure 8# infrastructure
6obj-$(CONFIG_USB_OTG_UTILS) += otg.o 9obj-$(CONFIG_USB_OTG_UTILS) += otg.o
7 10
@@ -9,9 +12,6 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg.o
9obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o 12obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
10obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 13obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
11obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o 14obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
15obj-$(CONFIG_USB_LANGWELL_OTG) += langwell_otg.o
12obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o 16obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o
13obj-$(CONFIG_USB_ULPI) += ulpi.o 17obj-$(CONFIG_USB_ULPI) += ulpi.o
14
15ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG
16ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
17
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
new file mode 100644
index 000000000000..bdc3ea66be69
--- /dev/null
+++ b/drivers/usb/otg/langwell_otg.c
@@ -0,0 +1,2408 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19/* This driver helps to switch Langwell OTG controller function between host
20 * and peripheral. It works with EHCI driver and Langwell client controller
21 * driver together.
22 */
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/pci.h>
26#include <linux/errno.h>
27#include <linux/interrupt.h>
28#include <linux/kernel.h>
29#include <linux/device.h>
30#include <linux/moduleparam.h>
31#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h>
33#include <linux/usb.h>
34#include <linux/usb/otg.h>
35#include <linux/usb/hcd.h>
36#include <linux/notifier.h>
37#include <linux/delay.h>
38#include <asm/intel_scu_ipc.h>
39
40#include <linux/usb/langwell_otg.h>
41
42#define DRIVER_DESC "Intel Langwell USB OTG transceiver driver"
43#define DRIVER_VERSION "July 10, 2010"
44
45MODULE_DESCRIPTION(DRIVER_DESC);
46MODULE_AUTHOR("Henry Yuan <hang.yuan@intel.com>, Hao Wu <hao.wu@intel.com>");
47MODULE_VERSION(DRIVER_VERSION);
48MODULE_LICENSE("GPL");
49
50static const char driver_name[] = "langwell_otg";
51
52static int langwell_otg_probe(struct pci_dev *pdev,
53 const struct pci_device_id *id);
54static void langwell_otg_remove(struct pci_dev *pdev);
55static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message);
56static int langwell_otg_resume(struct pci_dev *pdev);
57
58static int langwell_otg_set_host(struct otg_transceiver *otg,
59 struct usb_bus *host);
60static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
61 struct usb_gadget *gadget);
62static int langwell_otg_start_srp(struct otg_transceiver *otg);
63
64static const struct pci_device_id pci_ids[] = {{
65 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
66 .class_mask = ~0,
67 .vendor = 0x8086,
68 .device = 0x0811,
69 .subvendor = PCI_ANY_ID,
70 .subdevice = PCI_ANY_ID,
71}, { /* end: all zeroes */ }
72};
73
74static struct pci_driver otg_pci_driver = {
75 .name = (char *) driver_name,
76 .id_table = pci_ids,
77
78 .probe = langwell_otg_probe,
79 .remove = langwell_otg_remove,
80
81 .suspend = langwell_otg_suspend,
82 .resume = langwell_otg_resume,
83};
84
85static const char *state_string(enum usb_otg_state state)
86{
87 switch (state) {
88 case OTG_STATE_A_IDLE:
89 return "a_idle";
90 case OTG_STATE_A_WAIT_VRISE:
91 return "a_wait_vrise";
92 case OTG_STATE_A_WAIT_BCON:
93 return "a_wait_bcon";
94 case OTG_STATE_A_HOST:
95 return "a_host";
96 case OTG_STATE_A_SUSPEND:
97 return "a_suspend";
98 case OTG_STATE_A_PERIPHERAL:
99 return "a_peripheral";
100 case OTG_STATE_A_WAIT_VFALL:
101 return "a_wait_vfall";
102 case OTG_STATE_A_VBUS_ERR:
103 return "a_vbus_err";
104 case OTG_STATE_B_IDLE:
105 return "b_idle";
106 case OTG_STATE_B_SRP_INIT:
107 return "b_srp_init";
108 case OTG_STATE_B_PERIPHERAL:
109 return "b_peripheral";
110 case OTG_STATE_B_WAIT_ACON:
111 return "b_wait_acon";
112 case OTG_STATE_B_HOST:
113 return "b_host";
114 default:
115 return "UNDEFINED";
116 }
117}
118
119/* HSM timers */
120static inline struct langwell_otg_timer *otg_timer_initializer
121(void (*function)(unsigned long), unsigned long expires, unsigned long data)
122{
123 struct langwell_otg_timer *timer;
124 timer = kmalloc(sizeof(struct langwell_otg_timer), GFP_KERNEL);
125 if (timer == NULL)
126 return timer;
127
128 timer->function = function;
129 timer->expires = expires;
130 timer->data = data;
131 return timer;
132}
133
134static struct langwell_otg_timer *a_wait_vrise_tmr, *a_aidl_bdis_tmr,
135 *b_se0_srp_tmr, *b_srp_init_tmr;
136
137static struct list_head active_timers;
138
139static struct langwell_otg *the_transceiver;
140
141/* host/client notify transceiver when event affects HNP state */
142void langwell_update_transceiver(void)
143{
144 struct langwell_otg *lnw = the_transceiver;
145
146 dev_dbg(lnw->dev, "transceiver is updated\n");
147
148 if (!lnw->qwork)
149 return ;
150
151 queue_work(lnw->qwork, &lnw->work);
152}
153EXPORT_SYMBOL(langwell_update_transceiver);
154
155static int langwell_otg_set_host(struct otg_transceiver *otg,
156 struct usb_bus *host)
157{
158 otg->host = host;
159
160 return 0;
161}
162
163static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
164 struct usb_gadget *gadget)
165{
166 otg->gadget = gadget;
167
168 return 0;
169}
170
171static int langwell_otg_set_power(struct otg_transceiver *otg,
172 unsigned mA)
173{
174 return 0;
175}
176
177/* A-device drives vbus, controlled through PMIC CHRGCNTL register*/
178static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled)
179{
180 struct langwell_otg *lnw = the_transceiver;
181 u8 r;
182
183 dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off");
184
185 /* FIXME: surely we should cache this on the first read. If not use
186 readv to avoid two transactions */
187 if (intel_scu_ipc_ioread8(0x00, &r) < 0) {
188 dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2");
189 return -EBUSY;
190 }
191 if ((r & 0x03) != 0x02) {
192 dev_dbg(lnw->dev, "not NEC PMIC attached\n");
193 return -EBUSY;
194 }
195
196 if (intel_scu_ipc_ioread8(0x20, &r) < 0) {
197 dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2");
198 return -EBUSY;
199 }
200
201 if ((r & 0x20) == 0) {
202 dev_dbg(lnw->dev, "no battery attached\n");
203 return -EBUSY;
204 }
205
206 /* Workaround for battery attachment issue */
207 if (r == 0x34) {
208 dev_dbg(lnw->dev, "no battery attached on SH\n");
209 return -EBUSY;
210 }
211
212 dev_dbg(lnw->dev, "battery attached. 2 reg = %x\n", r);
213
214 /* workaround: FW detect writing 0x20/0xc0 to d4 event.
215 * this is only for NEC PMIC.
216 */
217
218 if (intel_scu_ipc_iowrite8(0xD4, enabled ? 0x20 : 0xC0))
219 dev_dbg(lnw->dev, "Failed to write PMIC.\n");
220
221 dev_dbg(lnw->dev, "%s --->\n", __func__);
222
223 return 0;
224}
225
226/* charge vbus or discharge vbus through a resistor to ground */
227static void langwell_otg_chrg_vbus(int on)
228{
229 struct langwell_otg *lnw = the_transceiver;
230 u32 val;
231
232 val = readl(lnw->iotg.base + CI_OTGSC);
233
234 if (on)
235 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VC,
236 lnw->iotg.base + CI_OTGSC);
237 else
238 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VD,
239 lnw->iotg.base + CI_OTGSC);
240}
241
242/* Start SRP */
243static int langwell_otg_start_srp(struct otg_transceiver *otg)
244{
245 struct langwell_otg *lnw = the_transceiver;
246 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
247 u32 val;
248
249 dev_dbg(lnw->dev, "%s --->\n", __func__);
250
251 val = readl(iotg->base + CI_OTGSC);
252
253 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP,
254 iotg->base + CI_OTGSC);
255
256 /* Check if the data plus is finished or not */
257 msleep(8);
258 val = readl(iotg->base + CI_OTGSC);
259 if (val & (OTGSC_HADP | OTGSC_DP))
260 dev_dbg(lnw->dev, "DataLine SRP Error\n");
261
262 /* Disable interrupt - b_sess_vld */
263 val = readl(iotg->base + CI_OTGSC);
264 val &= (~(OTGSC_BSVIE | OTGSC_BSEIE));
265 writel(val, iotg->base + CI_OTGSC);
266
267 /* Start VBus SRP, drive vbus to generate VBus pulse */
268 iotg->otg.set_vbus(&iotg->otg, true);
269 msleep(15);
270 iotg->otg.set_vbus(&iotg->otg, false);
271
272 /* Enable interrupt - b_sess_vld*/
273 val = readl(iotg->base + CI_OTGSC);
274 dev_dbg(lnw->dev, "after VBUS pulse otgsc = %x\n", val);
275
276 val |= (OTGSC_BSVIE | OTGSC_BSEIE);
277 writel(val, iotg->base + CI_OTGSC);
278
279 /* If Vbus is valid, then update the hsm */
280 if (val & OTGSC_BSV) {
281 dev_dbg(lnw->dev, "no b_sess_vld interrupt\n");
282
283 lnw->iotg.hsm.b_sess_vld = 1;
284 langwell_update_transceiver();
285 }
286
287 dev_dbg(lnw->dev, "%s <---\n", __func__);
288 return 0;
289}
290
291/* stop SOF via bus_suspend */
292static void langwell_otg_loc_sof(int on)
293{
294 struct langwell_otg *lnw = the_transceiver;
295 struct usb_hcd *hcd;
296 int err;
297
298 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "suspend" : "resume");
299
300 hcd = bus_to_hcd(lnw->iotg.otg.host);
301 if (on)
302 err = hcd->driver->bus_resume(hcd);
303 else
304 err = hcd->driver->bus_suspend(hcd);
305
306 if (err)
307 dev_dbg(lnw->dev, "Fail to resume/suspend USB bus - %d\n", err);
308
309 dev_dbg(lnw->dev, "%s <---\n", __func__);
310}
311
312static int langwell_otg_check_otgsc(void)
313{
314 struct langwell_otg *lnw = the_transceiver;
315 u32 otgsc, usbcfg;
316
317 dev_dbg(lnw->dev, "check sync OTGSC and USBCFG registers\n");
318
319 otgsc = readl(lnw->iotg.base + CI_OTGSC);
320 usbcfg = readl(lnw->usbcfg);
321
322 dev_dbg(lnw->dev, "OTGSC = %08x, USBCFG = %08x\n",
323 otgsc, usbcfg);
324 dev_dbg(lnw->dev, "OTGSC_AVV = %d\n", !!(otgsc & OTGSC_AVV));
325 dev_dbg(lnw->dev, "USBCFG.VBUSVAL = %d\n",
326 !!(usbcfg & USBCFG_VBUSVAL));
327 dev_dbg(lnw->dev, "OTGSC_ASV = %d\n", !!(otgsc & OTGSC_ASV));
328 dev_dbg(lnw->dev, "USBCFG.AVALID = %d\n",
329 !!(usbcfg & USBCFG_AVALID));
330 dev_dbg(lnw->dev, "OTGSC_BSV = %d\n", !!(otgsc & OTGSC_BSV));
331 dev_dbg(lnw->dev, "USBCFG.BVALID = %d\n",
332 !!(usbcfg & USBCFG_BVALID));
333 dev_dbg(lnw->dev, "OTGSC_BSE = %d\n", !!(otgsc & OTGSC_BSE));
334 dev_dbg(lnw->dev, "USBCFG.SESEND = %d\n",
335 !!(usbcfg & USBCFG_SESEND));
336
337 /* Check USBCFG VBusValid/AValid/BValid/SessEnd */
338 if (!!(otgsc & OTGSC_AVV) ^ !!(usbcfg & USBCFG_VBUSVAL)) {
339 dev_dbg(lnw->dev, "OTGSC.AVV != USBCFG.VBUSVAL\n");
340 goto err;
341 }
342 if (!!(otgsc & OTGSC_ASV) ^ !!(usbcfg & USBCFG_AVALID)) {
343 dev_dbg(lnw->dev, "OTGSC.ASV != USBCFG.AVALID\n");
344 goto err;
345 }
346 if (!!(otgsc & OTGSC_BSV) ^ !!(usbcfg & USBCFG_BVALID)) {
347 dev_dbg(lnw->dev, "OTGSC.BSV != USBCFG.BVALID\n");
348 goto err;
349 }
350 if (!!(otgsc & OTGSC_BSE) ^ !!(usbcfg & USBCFG_SESEND)) {
351 dev_dbg(lnw->dev, "OTGSC.BSE != USBCFG.SESSEN\n");
352 goto err;
353 }
354
355 dev_dbg(lnw->dev, "OTGSC and USBCFG are synced\n");
356
357 return 0;
358
359err:
360 dev_warn(lnw->dev, "OTGSC isn't equal to USBCFG\n");
361 return -EPIPE;
362}
363
364
365static void langwell_otg_phy_low_power(int on)
366{
367 struct langwell_otg *lnw = the_transceiver;
368 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
369 u8 val, phcd;
370 int retval;
371
372 dev_dbg(lnw->dev, "%s ---> %s mode\n",
373 __func__, on ? "Low power" : "Normal");
374
375 phcd = 0x40;
376
377 val = readb(iotg->base + CI_HOSTPC1 + 2);
378
379 if (on) {
380 /* Due to hardware issue, after set PHCD, sync will failed
381 * between USBCFG and OTGSC, so before set PHCD, check if
382 * sync is in process now. If the answer is "yes", then do
383 * not touch PHCD bit */
384 retval = langwell_otg_check_otgsc();
385 if (retval) {
386 dev_dbg(lnw->dev, "Skip PHCD programming..\n");
387 return ;
388 }
389
390 writeb(val | phcd, iotg->base + CI_HOSTPC1 + 2);
391 } else
392 writeb(val & ~phcd, iotg->base + CI_HOSTPC1 + 2);
393
394 dev_dbg(lnw->dev, "%s <--- done\n", __func__);
395}
396
397/* After drv vbus, add 2 ms delay to set PHCD */
398static void langwell_otg_phy_low_power_wait(int on)
399{
400 struct langwell_otg *lnw = the_transceiver;
401
402 dev_dbg(lnw->dev, "add 2ms delay before programing PHCD\n");
403
404 mdelay(2);
405 langwell_otg_phy_low_power(on);
406}
407
408/* Enable/Disable OTG interrupt */
409static void langwell_otg_intr(int on)
410{
411 struct langwell_otg *lnw = the_transceiver;
412 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
413 u32 val;
414
415 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
416
417 val = readl(iotg->base + CI_OTGSC);
418
419 /* OTGSC_INT_MASK doesn't contains 1msInt */
420 if (on) {
421 val = val | (OTGSC_INT_MASK);
422 writel(val, iotg->base + CI_OTGSC);
423 } else {
424 val = val & ~(OTGSC_INT_MASK);
425 writel(val, iotg->base + CI_OTGSC);
426 }
427
428 dev_dbg(lnw->dev, "%s <---\n", __func__);
429}
430
431/* set HAAR: Hardware Assist Auto-Reset */
432static void langwell_otg_HAAR(int on)
433{
434 struct langwell_otg *lnw = the_transceiver;
435 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
436 u32 val;
437
438 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
439
440 val = readl(iotg->base + CI_OTGSC);
441 if (on)
442 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HAAR,
443 iotg->base + CI_OTGSC);
444 else
445 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HAAR,
446 iotg->base + CI_OTGSC);
447
448 dev_dbg(lnw->dev, "%s <---\n", __func__);
449}
450
451/* set HABA: Hardware Assist B-Disconnect to A-Connect */
452static void langwell_otg_HABA(int on)
453{
454 struct langwell_otg *lnw = the_transceiver;
455 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
456 u32 val;
457
458 dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
459
460 val = readl(iotg->base + CI_OTGSC);
461 if (on)
462 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HABA,
463 iotg->base + CI_OTGSC);
464 else
465 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HABA,
466 iotg->base + CI_OTGSC);
467
468 dev_dbg(lnw->dev, "%s <---\n", __func__);
469}
470
471static int langwell_otg_check_se0_srp(int on)
472{
473 struct langwell_otg *lnw = the_transceiver;
474 int delay_time = TB_SE0_SRP * 10;
475 u32 val;
476
477 dev_dbg(lnw->dev, "%s --->\n", __func__);
478
479 do {
480 udelay(100);
481 if (!delay_time--)
482 break;
483 val = readl(lnw->iotg.base + CI_PORTSC1);
484 val &= PORTSC_LS;
485 } while (!val);
486
487 dev_dbg(lnw->dev, "%s <---\n", __func__);
488 return val;
489}
490
491/* The timeout callback function to set time out bit */
492static void set_tmout(unsigned long indicator)
493{
494 *(int *)indicator = 1;
495}
496
497void langwell_otg_nsf_msg(unsigned long indicator)
498{
499 struct langwell_otg *lnw = the_transceiver;
500
501 switch (indicator) {
502 case 2:
503 case 4:
504 case 6:
505 case 7:
506 dev_warn(lnw->dev,
507 "OTG:NSF-%lu - deivce not responding\n", indicator);
508 break;
509 case 3:
510 dev_warn(lnw->dev,
511 "OTG:NSF-%lu - deivce not supported\n", indicator);
512 break;
513 default:
514 dev_warn(lnw->dev, "Do not have this kind of NSF\n");
515 break;
516 }
517}
518
519/* Initialize timers */
520static int langwell_otg_init_timers(struct otg_hsm *hsm)
521{
522 /* HSM used timers */
523 a_wait_vrise_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_VRISE,
524 (unsigned long)&hsm->a_wait_vrise_tmout);
525 if (a_wait_vrise_tmr == NULL)
526 return -ENOMEM;
527 a_aidl_bdis_tmr = otg_timer_initializer(&set_tmout, TA_AIDL_BDIS,
528 (unsigned long)&hsm->a_aidl_bdis_tmout);
529 if (a_aidl_bdis_tmr == NULL)
530 return -ENOMEM;
531 b_se0_srp_tmr = otg_timer_initializer(&set_tmout, TB_SE0_SRP,
532 (unsigned long)&hsm->b_se0_srp);
533 if (b_se0_srp_tmr == NULL)
534 return -ENOMEM;
535 b_srp_init_tmr = otg_timer_initializer(&set_tmout, TB_SRP_INIT,
536 (unsigned long)&hsm->b_srp_init_tmout);
537 if (b_srp_init_tmr == NULL)
538 return -ENOMEM;
539
540 return 0;
541}
542
543/* Free timers */
544static void langwell_otg_free_timers(void)
545{
546 kfree(a_wait_vrise_tmr);
547 kfree(a_aidl_bdis_tmr);
548 kfree(b_se0_srp_tmr);
549 kfree(b_srp_init_tmr);
550}
551
552/* The timeout callback function to set time out bit */
553static void langwell_otg_timer_fn(unsigned long indicator)
554{
555 struct langwell_otg *lnw = the_transceiver;
556
557 *(int *)indicator = 1;
558
559 dev_dbg(lnw->dev, "kernel timer - timeout\n");
560
561 langwell_update_transceiver();
562}
563
564/* kernel timer used instead of HW based interrupt */
565static void langwell_otg_add_ktimer(enum langwell_otg_timer_type timers)
566{
567 struct langwell_otg *lnw = the_transceiver;
568 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
569 unsigned long j = jiffies;
570 unsigned long data, time;
571
572 switch (timers) {
573 case TA_WAIT_VRISE_TMR:
574 iotg->hsm.a_wait_vrise_tmout = 0;
575 data = (unsigned long)&iotg->hsm.a_wait_vrise_tmout;
576 time = TA_WAIT_VRISE;
577 break;
578 case TA_WAIT_BCON_TMR:
579 iotg->hsm.a_wait_bcon_tmout = 0;
580 data = (unsigned long)&iotg->hsm.a_wait_bcon_tmout;
581 time = TA_WAIT_BCON;
582 break;
583 case TA_AIDL_BDIS_TMR:
584 iotg->hsm.a_aidl_bdis_tmout = 0;
585 data = (unsigned long)&iotg->hsm.a_aidl_bdis_tmout;
586 time = TA_AIDL_BDIS;
587 break;
588 case TB_ASE0_BRST_TMR:
589 iotg->hsm.b_ase0_brst_tmout = 0;
590 data = (unsigned long)&iotg->hsm.b_ase0_brst_tmout;
591 time = TB_ASE0_BRST;
592 break;
593 case TB_SRP_INIT_TMR:
594 iotg->hsm.b_srp_init_tmout = 0;
595 data = (unsigned long)&iotg->hsm.b_srp_init_tmout;
596 time = TB_SRP_INIT;
597 break;
598 case TB_SRP_FAIL_TMR:
599 iotg->hsm.b_srp_fail_tmout = 0;
600 data = (unsigned long)&iotg->hsm.b_srp_fail_tmout;
601 time = TB_SRP_FAIL;
602 break;
603 case TB_BUS_SUSPEND_TMR:
604 iotg->hsm.b_bus_suspend_tmout = 0;
605 data = (unsigned long)&iotg->hsm.b_bus_suspend_tmout;
606 time = TB_BUS_SUSPEND;
607 break;
608 default:
609 dev_dbg(lnw->dev, "unkown timer, cannot enable it\n");
610 return;
611 }
612
613 lnw->hsm_timer.data = data;
614 lnw->hsm_timer.function = langwell_otg_timer_fn;
615 lnw->hsm_timer.expires = j + time * HZ / 1000; /* milliseconds */
616
617 add_timer(&lnw->hsm_timer);
618
619 dev_dbg(lnw->dev, "add timer successfully\n");
620}
621
622/* Add timer to timer list */
623static void langwell_otg_add_timer(void *gtimer)
624{
625 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
626 struct langwell_otg_timer *tmp_timer;
627 struct intel_mid_otg_xceiv *iotg = &the_transceiver->iotg;
628 u32 val32;
629
630 /* Check if the timer is already in the active list,
631 * if so update timer count
632 */
633 list_for_each_entry(tmp_timer, &active_timers, list)
634 if (tmp_timer == timer) {
635 timer->count = timer->expires;
636 return;
637 }
638 timer->count = timer->expires;
639
640 if (list_empty(&active_timers)) {
641 val32 = readl(iotg->base + CI_OTGSC);
642 writel(val32 | OTGSC_1MSE, iotg->base + CI_OTGSC);
643 }
644
645 list_add_tail(&timer->list, &active_timers);
646}
647
648/* Remove timer from the timer list; clear timeout status */
649static void langwell_otg_del_timer(void *gtimer)
650{
651 struct langwell_otg *lnw = the_transceiver;
652 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
653 struct langwell_otg_timer *tmp_timer, *del_tmp;
654 u32 val32;
655
656 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list)
657 if (tmp_timer == timer)
658 list_del(&timer->list);
659
660 if (list_empty(&active_timers)) {
661 val32 = readl(lnw->iotg.base + CI_OTGSC);
662 writel(val32 & ~OTGSC_1MSE, lnw->iotg.base + CI_OTGSC);
663 }
664}
665
666/* Reduce timer count by 1, and find timeout conditions.*/
667static int langwell_otg_tick_timer(u32 *int_sts)
668{
669 struct langwell_otg *lnw = the_transceiver;
670 struct langwell_otg_timer *tmp_timer, *del_tmp;
671 int expired = 0;
672
673 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list) {
674 tmp_timer->count--;
675 /* check if timer expires */
676 if (!tmp_timer->count) {
677 list_del(&tmp_timer->list);
678 tmp_timer->function(tmp_timer->data);
679 expired = 1;
680 }
681 }
682
683 if (list_empty(&active_timers)) {
684 dev_dbg(lnw->dev, "tick timer: disable 1ms int\n");
685 *int_sts = *int_sts & ~OTGSC_1MSE;
686 }
687 return expired;
688}
689
690static void reset_otg(void)
691{
692 struct langwell_otg *lnw = the_transceiver;
693 int delay_time = 1000;
694 u32 val;
695
696 dev_dbg(lnw->dev, "reseting OTG controller ...\n");
697 val = readl(lnw->iotg.base + CI_USBCMD);
698 writel(val | USBCMD_RST, lnw->iotg.base + CI_USBCMD);
699 do {
700 udelay(100);
701 if (!delay_time--)
702 dev_dbg(lnw->dev, "reset timeout\n");
703 val = readl(lnw->iotg.base + CI_USBCMD);
704 val &= USBCMD_RST;
705 } while (val != 0);
706 dev_dbg(lnw->dev, "reset done.\n");
707}
708
709static void set_host_mode(void)
710{
711 struct langwell_otg *lnw = the_transceiver;
712 u32 val;
713
714 reset_otg();
715 val = readl(lnw->iotg.base + CI_USBMODE);
716 val = (val & (~USBMODE_CM)) | USBMODE_HOST;
717 writel(val, lnw->iotg.base + CI_USBMODE);
718}
719
720static void set_client_mode(void)
721{
722 struct langwell_otg *lnw = the_transceiver;
723 u32 val;
724
725 reset_otg();
726 val = readl(lnw->iotg.base + CI_USBMODE);
727 val = (val & (~USBMODE_CM)) | USBMODE_DEVICE;
728 writel(val, lnw->iotg.base + CI_USBMODE);
729}
730
731static void init_hsm(void)
732{
733 struct langwell_otg *lnw = the_transceiver;
734 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
735 u32 val32;
736
737 /* read OTGSC after reset */
738 val32 = readl(lnw->iotg.base + CI_OTGSC);
739 dev_dbg(lnw->dev, "%s: OTGSC init value = 0x%x\n", __func__, val32);
740
741 /* set init state */
742 if (val32 & OTGSC_ID) {
743 iotg->hsm.id = 1;
744 iotg->otg.default_a = 0;
745 set_client_mode();
746 iotg->otg.state = OTG_STATE_B_IDLE;
747 } else {
748 iotg->hsm.id = 0;
749 iotg->otg.default_a = 1;
750 set_host_mode();
751 iotg->otg.state = OTG_STATE_A_IDLE;
752 }
753
754 /* set session indicator */
755 if (val32 & OTGSC_BSE)
756 iotg->hsm.b_sess_end = 1;
757 if (val32 & OTGSC_BSV)
758 iotg->hsm.b_sess_vld = 1;
759 if (val32 & OTGSC_ASV)
760 iotg->hsm.a_sess_vld = 1;
761 if (val32 & OTGSC_AVV)
762 iotg->hsm.a_vbus_vld = 1;
763
764 /* defautly power the bus */
765 iotg->hsm.a_bus_req = 1;
766 iotg->hsm.a_bus_drop = 0;
767 /* defautly don't request bus as B device */
768 iotg->hsm.b_bus_req = 0;
769 /* no system error */
770 iotg->hsm.a_clr_err = 0;
771
772 langwell_otg_phy_low_power_wait(1);
773}
774
775static void update_hsm(void)
776{
777 struct langwell_otg *lnw = the_transceiver;
778 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
779 u32 val32;
780
781 /* read OTGSC */
782 val32 = readl(lnw->iotg.base + CI_OTGSC);
783 dev_dbg(lnw->dev, "%s: OTGSC value = 0x%x\n", __func__, val32);
784
785 iotg->hsm.id = !!(val32 & OTGSC_ID);
786 iotg->hsm.b_sess_end = !!(val32 & OTGSC_BSE);
787 iotg->hsm.b_sess_vld = !!(val32 & OTGSC_BSV);
788 iotg->hsm.a_sess_vld = !!(val32 & OTGSC_ASV);
789 iotg->hsm.a_vbus_vld = !!(val32 & OTGSC_AVV);
790}
791
792static irqreturn_t otg_dummy_irq(int irq, void *_dev)
793{
794 struct langwell_otg *lnw = the_transceiver;
795 void __iomem *reg_base = _dev;
796 u32 val;
797 u32 int_mask = 0;
798
799 val = readl(reg_base + CI_USBMODE);
800 if ((val & USBMODE_CM) != USBMODE_DEVICE)
801 return IRQ_NONE;
802
803 val = readl(reg_base + CI_USBSTS);
804 int_mask = val & INTR_DUMMY_MASK;
805
806 if (int_mask == 0)
807 return IRQ_NONE;
808
809 /* clear hsm.b_conn here since host driver can't detect it
810 * otg_dummy_irq called means B-disconnect happened.
811 */
812 if (lnw->iotg.hsm.b_conn) {
813 lnw->iotg.hsm.b_conn = 0;
814 if (spin_trylock(&lnw->wq_lock)) {
815 langwell_update_transceiver();
816 spin_unlock(&lnw->wq_lock);
817 }
818 }
819
820 /* Clear interrupts */
821 writel(int_mask, reg_base + CI_USBSTS);
822 return IRQ_HANDLED;
823}
824
825static irqreturn_t otg_irq(int irq, void *_dev)
826{
827 struct langwell_otg *lnw = _dev;
828 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
829 u32 int_sts, int_en;
830 u32 int_mask = 0;
831 int flag = 0;
832
833 int_sts = readl(lnw->iotg.base + CI_OTGSC);
834 int_en = (int_sts & OTGSC_INTEN_MASK) >> 8;
835 int_mask = int_sts & int_en;
836 if (int_mask == 0)
837 return IRQ_NONE;
838
839 if (int_mask & OTGSC_IDIS) {
840 dev_dbg(lnw->dev, "%s: id change int\n", __func__);
841 iotg->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0;
842 dev_dbg(lnw->dev, "id = %d\n", iotg->hsm.id);
843 flag = 1;
844 }
845 if (int_mask & OTGSC_DPIS) {
846 dev_dbg(lnw->dev, "%s: data pulse int\n", __func__);
847 iotg->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0;
848 dev_dbg(lnw->dev, "data pulse = %d\n", iotg->hsm.a_srp_det);
849 flag = 1;
850 }
851 if (int_mask & OTGSC_BSEIS) {
852 dev_dbg(lnw->dev, "%s: b session end int\n", __func__);
853 iotg->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0;
854 dev_dbg(lnw->dev, "b_sess_end = %d\n", iotg->hsm.b_sess_end);
855 flag = 1;
856 }
857 if (int_mask & OTGSC_BSVIS) {
858 dev_dbg(lnw->dev, "%s: b session valid int\n", __func__);
859 iotg->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0;
860 dev_dbg(lnw->dev, "b_sess_vld = %d\n", iotg->hsm.b_sess_end);
861 flag = 1;
862 }
863 if (int_mask & OTGSC_ASVIS) {
864 dev_dbg(lnw->dev, "%s: a session valid int\n", __func__);
865 iotg->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0;
866 dev_dbg(lnw->dev, "a_sess_vld = %d\n", iotg->hsm.a_sess_vld);
867 flag = 1;
868 }
869 if (int_mask & OTGSC_AVVIS) {
870 dev_dbg(lnw->dev, "%s: a vbus valid int\n", __func__);
871 iotg->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0;
872 dev_dbg(lnw->dev, "a_vbus_vld = %d\n", iotg->hsm.a_vbus_vld);
873 flag = 1;
874 }
875
876 if (int_mask & OTGSC_1MSS) {
877 /* need to schedule otg_work if any timer is expired */
878 if (langwell_otg_tick_timer(&int_sts))
879 flag = 1;
880 }
881
882 writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask,
883 lnw->iotg.base + CI_OTGSC);
884 if (flag)
885 langwell_update_transceiver();
886
887 return IRQ_HANDLED;
888}
889
890static int langwell_otg_iotg_notify(struct notifier_block *nb,
891 unsigned long action, void *data)
892{
893 struct langwell_otg *lnw = the_transceiver;
894 struct intel_mid_otg_xceiv *iotg = data;
895 int flag = 0;
896
897 if (iotg == NULL)
898 return NOTIFY_BAD;
899
900 if (lnw == NULL)
901 return NOTIFY_BAD;
902
903 switch (action) {
904 case MID_OTG_NOTIFY_CONNECT:
905 dev_dbg(lnw->dev, "Lnw OTG Notify Connect Event\n");
906 if (iotg->otg.default_a == 1)
907 iotg->hsm.b_conn = 1;
908 else
909 iotg->hsm.a_conn = 1;
910 flag = 1;
911 break;
912 case MID_OTG_NOTIFY_DISCONN:
913 dev_dbg(lnw->dev, "Lnw OTG Notify Disconnect Event\n");
914 if (iotg->otg.default_a == 1)
915 iotg->hsm.b_conn = 0;
916 else
917 iotg->hsm.a_conn = 0;
918 flag = 1;
919 break;
920 case MID_OTG_NOTIFY_HSUSPEND:
921 dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus suspend Event\n");
922 if (iotg->otg.default_a == 1)
923 iotg->hsm.a_suspend_req = 1;
924 else
925 iotg->hsm.b_bus_req = 0;
926 flag = 1;
927 break;
928 case MID_OTG_NOTIFY_HRESUME:
929 dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus resume Event\n");
930 if (iotg->otg.default_a == 1)
931 iotg->hsm.b_bus_resume = 1;
932 flag = 1;
933 break;
934 case MID_OTG_NOTIFY_CSUSPEND:
935 dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus suspend Event\n");
936 if (iotg->otg.default_a == 1) {
937 if (iotg->hsm.b_bus_suspend_vld == 2) {
938 iotg->hsm.b_bus_suspend = 1;
939 iotg->hsm.b_bus_suspend_vld = 0;
940 flag = 1;
941 } else {
942 iotg->hsm.b_bus_suspend_vld++;
943 flag = 0;
944 }
945 } else {
946 if (iotg->hsm.a_bus_suspend == 0) {
947 iotg->hsm.a_bus_suspend = 1;
948 flag = 1;
949 }
950 }
951 break;
952 case MID_OTG_NOTIFY_CRESUME:
953 dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus resume Event\n");
954 if (iotg->otg.default_a == 0)
955 iotg->hsm.a_bus_suspend = 0;
956 flag = 0;
957 break;
958 case MID_OTG_NOTIFY_HOSTADD:
959 dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver Add\n");
960 flag = 1;
961 break;
962 case MID_OTG_NOTIFY_HOSTREMOVE:
963 dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver remove\n");
964 flag = 1;
965 break;
966 case MID_OTG_NOTIFY_CLIENTADD:
967 dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver Add\n");
968 flag = 1;
969 break;
970 case MID_OTG_NOTIFY_CLIENTREMOVE:
971 dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver remove\n");
972 flag = 1;
973 break;
974 default:
975 dev_dbg(lnw->dev, "Lnw OTG Nofity unknown notify message\n");
976 return NOTIFY_DONE;
977 }
978
979 if (flag)
980 langwell_update_transceiver();
981
982 return NOTIFY_OK;
983}
984
985static void langwell_otg_work(struct work_struct *work)
986{
987 struct langwell_otg *lnw;
988 struct intel_mid_otg_xceiv *iotg;
989 int retval;
990 struct pci_dev *pdev;
991
992 lnw = container_of(work, struct langwell_otg, work);
993 iotg = &lnw->iotg;
994 pdev = to_pci_dev(lnw->dev);
995
996 dev_dbg(lnw->dev, "%s: old state = %s\n", __func__,
997 state_string(iotg->otg.state));
998
999 switch (iotg->otg.state) {
1000 case OTG_STATE_UNDEFINED:
1001 case OTG_STATE_B_IDLE:
1002 if (!iotg->hsm.id) {
1003 langwell_otg_del_timer(b_srp_init_tmr);
1004 del_timer_sync(&lnw->hsm_timer);
1005
1006 iotg->otg.default_a = 1;
1007 iotg->hsm.a_srp_det = 0;
1008
1009 langwell_otg_chrg_vbus(0);
1010 set_host_mode();
1011 langwell_otg_phy_low_power(1);
1012
1013 iotg->otg.state = OTG_STATE_A_IDLE;
1014 langwell_update_transceiver();
1015 } else if (iotg->hsm.b_sess_vld) {
1016 langwell_otg_del_timer(b_srp_init_tmr);
1017 del_timer_sync(&lnw->hsm_timer);
1018 iotg->hsm.b_sess_end = 0;
1019 iotg->hsm.a_bus_suspend = 0;
1020 langwell_otg_chrg_vbus(0);
1021
1022 if (lnw->iotg.start_peripheral) {
1023 lnw->iotg.start_peripheral(&lnw->iotg);
1024 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1025 } else
1026 dev_dbg(lnw->dev, "client driver not loaded\n");
1027
1028 } else if (iotg->hsm.b_srp_init_tmout) {
1029 iotg->hsm.b_srp_init_tmout = 0;
1030 dev_warn(lnw->dev, "SRP init timeout\n");
1031 } else if (iotg->hsm.b_srp_fail_tmout) {
1032 iotg->hsm.b_srp_fail_tmout = 0;
1033 iotg->hsm.b_bus_req = 0;
1034
1035 /* No silence failure */
1036 langwell_otg_nsf_msg(6);
1037 } else if (iotg->hsm.b_bus_req && iotg->hsm.b_sess_end) {
1038 del_timer_sync(&lnw->hsm_timer);
1039 /* workaround for b_se0_srp detection */
1040 retval = langwell_otg_check_se0_srp(0);
1041 if (retval) {
1042 iotg->hsm.b_bus_req = 0;
1043 dev_dbg(lnw->dev, "LS isn't SE0, try later\n");
1044 } else {
1045 /* clear the PHCD before start srp */
1046 langwell_otg_phy_low_power(0);
1047
1048 /* Start SRP */
1049 langwell_otg_add_timer(b_srp_init_tmr);
1050 iotg->otg.start_srp(&iotg->otg);
1051 langwell_otg_del_timer(b_srp_init_tmr);
1052 langwell_otg_add_ktimer(TB_SRP_FAIL_TMR);
1053
1054 /* reset PHY low power mode here */
1055 langwell_otg_phy_low_power_wait(1);
1056 }
1057 }
1058 break;
1059 case OTG_STATE_B_SRP_INIT:
1060 if (!iotg->hsm.id) {
1061 iotg->otg.default_a = 1;
1062 iotg->hsm.a_srp_det = 0;
1063
1064 /* Turn off VBus */
1065 iotg->otg.set_vbus(&iotg->otg, false);
1066 langwell_otg_chrg_vbus(0);
1067 set_host_mode();
1068 langwell_otg_phy_low_power(1);
1069 iotg->otg.state = OTG_STATE_A_IDLE;
1070 langwell_update_transceiver();
1071 } else if (iotg->hsm.b_sess_vld) {
1072 langwell_otg_chrg_vbus(0);
1073 if (lnw->iotg.start_peripheral) {
1074 lnw->iotg.start_peripheral(&lnw->iotg);
1075 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1076 } else
1077 dev_dbg(lnw->dev, "client driver not loaded\n");
1078 }
1079 break;
1080 case OTG_STATE_B_PERIPHERAL:
1081 if (!iotg->hsm.id) {
1082 iotg->otg.default_a = 1;
1083 iotg->hsm.a_srp_det = 0;
1084
1085 langwell_otg_chrg_vbus(0);
1086
1087 if (lnw->iotg.stop_peripheral)
1088 lnw->iotg.stop_peripheral(&lnw->iotg);
1089 else
1090 dev_dbg(lnw->dev,
1091 "client driver has been removed.\n");
1092
1093 set_host_mode();
1094 langwell_otg_phy_low_power(1);
1095 iotg->otg.state = OTG_STATE_A_IDLE;
1096 langwell_update_transceiver();
1097 } else if (!iotg->hsm.b_sess_vld) {
1098 iotg->hsm.b_hnp_enable = 0;
1099
1100 if (lnw->iotg.stop_peripheral)
1101 lnw->iotg.stop_peripheral(&lnw->iotg);
1102 else
1103 dev_dbg(lnw->dev,
1104 "client driver has been removed.\n");
1105
1106 iotg->otg.state = OTG_STATE_B_IDLE;
1107 } else if (iotg->hsm.b_bus_req && iotg->otg.gadget &&
1108 iotg->otg.gadget->b_hnp_enable &&
1109 iotg->hsm.a_bus_suspend) {
1110
1111 if (lnw->iotg.stop_peripheral)
1112 lnw->iotg.stop_peripheral(&lnw->iotg);
1113 else
1114 dev_dbg(lnw->dev,
1115 "client driver has been removed.\n");
1116
1117 langwell_otg_HAAR(1);
1118 iotg->hsm.a_conn = 0;
1119
1120 if (lnw->iotg.start_host) {
1121 lnw->iotg.start_host(&lnw->iotg);
1122 iotg->otg.state = OTG_STATE_B_WAIT_ACON;
1123 } else
1124 dev_dbg(lnw->dev,
1125 "host driver not loaded.\n");
1126
1127 iotg->hsm.a_bus_resume = 0;
1128 langwell_otg_add_ktimer(TB_ASE0_BRST_TMR);
1129 }
1130 break;
1131
1132 case OTG_STATE_B_WAIT_ACON:
1133 if (!iotg->hsm.id) {
1134 /* delete hsm timer for b_ase0_brst_tmr */
1135 del_timer_sync(&lnw->hsm_timer);
1136
1137 iotg->otg.default_a = 1;
1138 iotg->hsm.a_srp_det = 0;
1139
1140 langwell_otg_chrg_vbus(0);
1141
1142 langwell_otg_HAAR(0);
1143 if (lnw->iotg.stop_host)
1144 lnw->iotg.stop_host(&lnw->iotg);
1145 else
1146 dev_dbg(lnw->dev,
1147 "host driver has been removed.\n");
1148
1149 set_host_mode();
1150 langwell_otg_phy_low_power(1);
1151 iotg->otg.state = OTG_STATE_A_IDLE;
1152 langwell_update_transceiver();
1153 } else if (!iotg->hsm.b_sess_vld) {
1154 /* delete hsm timer for b_ase0_brst_tmr */
1155 del_timer_sync(&lnw->hsm_timer);
1156
1157 iotg->hsm.b_hnp_enable = 0;
1158 iotg->hsm.b_bus_req = 0;
1159
1160 langwell_otg_chrg_vbus(0);
1161 langwell_otg_HAAR(0);
1162
1163 if (lnw->iotg.stop_host)
1164 lnw->iotg.stop_host(&lnw->iotg);
1165 else
1166 dev_dbg(lnw->dev,
1167 "host driver has been removed.\n");
1168
1169 set_client_mode();
1170 langwell_otg_phy_low_power(1);
1171 iotg->otg.state = OTG_STATE_B_IDLE;
1172 } else if (iotg->hsm.a_conn) {
1173 /* delete hsm timer for b_ase0_brst_tmr */
1174 del_timer_sync(&lnw->hsm_timer);
1175
1176 langwell_otg_HAAR(0);
1177 iotg->otg.state = OTG_STATE_B_HOST;
1178 langwell_update_transceiver();
1179 } else if (iotg->hsm.a_bus_resume ||
1180 iotg->hsm.b_ase0_brst_tmout) {
1181 /* delete hsm timer for b_ase0_brst_tmr */
1182 del_timer_sync(&lnw->hsm_timer);
1183
1184 langwell_otg_HAAR(0);
1185 langwell_otg_nsf_msg(7);
1186
1187 if (lnw->iotg.stop_host)
1188 lnw->iotg.stop_host(&lnw->iotg);
1189 else
1190 dev_dbg(lnw->dev,
1191 "host driver has been removed.\n");
1192
1193 iotg->hsm.a_bus_suspend = 0;
1194 iotg->hsm.b_bus_req = 0;
1195
1196 if (lnw->iotg.start_peripheral)
1197 lnw->iotg.start_peripheral(&lnw->iotg);
1198 else
1199 dev_dbg(lnw->dev,
1200 "client driver not loaded.\n");
1201
1202 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1203 }
1204 break;
1205
1206 case OTG_STATE_B_HOST:
1207 if (!iotg->hsm.id) {
1208 iotg->otg.default_a = 1;
1209 iotg->hsm.a_srp_det = 0;
1210
1211 langwell_otg_chrg_vbus(0);
1212
1213 if (lnw->iotg.stop_host)
1214 lnw->iotg.stop_host(&lnw->iotg);
1215 else
1216 dev_dbg(lnw->dev,
1217 "host driver has been removed.\n");
1218
1219 set_host_mode();
1220 langwell_otg_phy_low_power(1);
1221 iotg->otg.state = OTG_STATE_A_IDLE;
1222 langwell_update_transceiver();
1223 } else if (!iotg->hsm.b_sess_vld) {
1224 iotg->hsm.b_hnp_enable = 0;
1225 iotg->hsm.b_bus_req = 0;
1226
1227 langwell_otg_chrg_vbus(0);
1228 if (lnw->iotg.stop_host)
1229 lnw->iotg.stop_host(&lnw->iotg);
1230 else
1231 dev_dbg(lnw->dev,
1232 "host driver has been removed.\n");
1233
1234 set_client_mode();
1235 langwell_otg_phy_low_power(1);
1236 iotg->otg.state = OTG_STATE_B_IDLE;
1237 } else if ((!iotg->hsm.b_bus_req) ||
1238 (!iotg->hsm.a_conn)) {
1239 iotg->hsm.b_bus_req = 0;
1240 langwell_otg_loc_sof(0);
1241
1242 if (lnw->iotg.stop_host)
1243 lnw->iotg.stop_host(&lnw->iotg);
1244 else
1245 dev_dbg(lnw->dev,
1246 "host driver has been removed.\n");
1247
1248 iotg->hsm.a_bus_suspend = 0;
1249
1250 if (lnw->iotg.start_peripheral)
1251 lnw->iotg.start_peripheral(&lnw->iotg);
1252 else
1253 dev_dbg(lnw->dev,
1254 "client driver not loaded.\n");
1255
1256 iotg->otg.state = OTG_STATE_B_PERIPHERAL;
1257 }
1258 break;
1259
1260 case OTG_STATE_A_IDLE:
1261 iotg->otg.default_a = 1;
1262 if (iotg->hsm.id) {
1263 iotg->otg.default_a = 0;
1264 iotg->hsm.b_bus_req = 0;
1265 iotg->hsm.vbus_srp_up = 0;
1266
1267 langwell_otg_chrg_vbus(0);
1268 set_client_mode();
1269 langwell_otg_phy_low_power(1);
1270 iotg->otg.state = OTG_STATE_B_IDLE;
1271 langwell_update_transceiver();
1272 } else if (!iotg->hsm.a_bus_drop &&
1273 (iotg->hsm.a_srp_det || iotg->hsm.a_bus_req)) {
1274 langwell_otg_phy_low_power(0);
1275
1276 /* Turn on VBus */
1277 iotg->otg.set_vbus(&iotg->otg, true);
1278
1279 iotg->hsm.vbus_srp_up = 0;
1280 iotg->hsm.a_wait_vrise_tmout = 0;
1281 langwell_otg_add_timer(a_wait_vrise_tmr);
1282 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1283 langwell_update_transceiver();
1284 } else if (!iotg->hsm.a_bus_drop && iotg->hsm.a_sess_vld) {
1285 iotg->hsm.vbus_srp_up = 1;
1286 } else if (!iotg->hsm.a_sess_vld && iotg->hsm.vbus_srp_up) {
1287 msleep(10);
1288 langwell_otg_phy_low_power(0);
1289
1290 /* Turn on VBus */
1291 iotg->otg.set_vbus(&iotg->otg, true);
1292 iotg->hsm.a_srp_det = 1;
1293 iotg->hsm.vbus_srp_up = 0;
1294 iotg->hsm.a_wait_vrise_tmout = 0;
1295 langwell_otg_add_timer(a_wait_vrise_tmr);
1296 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1297 langwell_update_transceiver();
1298 } else if (!iotg->hsm.a_sess_vld &&
1299 !iotg->hsm.vbus_srp_up) {
1300 langwell_otg_phy_low_power(1);
1301 }
1302 break;
1303 case OTG_STATE_A_WAIT_VRISE:
1304 if (iotg->hsm.id) {
1305 langwell_otg_del_timer(a_wait_vrise_tmr);
1306 iotg->hsm.b_bus_req = 0;
1307 iotg->otg.default_a = 0;
1308
1309 /* Turn off VBus */
1310 iotg->otg.set_vbus(&iotg->otg, false);
1311 set_client_mode();
1312 langwell_otg_phy_low_power_wait(1);
1313 iotg->otg.state = OTG_STATE_B_IDLE;
1314 } else if (iotg->hsm.a_vbus_vld) {
1315 langwell_otg_del_timer(a_wait_vrise_tmr);
1316 iotg->hsm.b_conn = 0;
1317 if (lnw->iotg.start_host)
1318 lnw->iotg.start_host(&lnw->iotg);
1319 else {
1320 dev_dbg(lnw->dev, "host driver not loaded.\n");
1321 break;
1322 }
1323
1324 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1325 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1326 } else if (iotg->hsm.a_wait_vrise_tmout) {
1327 iotg->hsm.b_conn = 0;
1328 if (iotg->hsm.a_vbus_vld) {
1329 if (lnw->iotg.start_host)
1330 lnw->iotg.start_host(&lnw->iotg);
1331 else {
1332 dev_dbg(lnw->dev,
1333 "host driver not loaded.\n");
1334 break;
1335 }
1336 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1337 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1338 } else {
1339
1340 /* Turn off VBus */
1341 iotg->otg.set_vbus(&iotg->otg, false);
1342 langwell_otg_phy_low_power_wait(1);
1343 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1344 }
1345 }
1346 break;
1347 case OTG_STATE_A_WAIT_BCON:
1348 if (iotg->hsm.id) {
1349 /* delete hsm timer for a_wait_bcon_tmr */
1350 del_timer_sync(&lnw->hsm_timer);
1351
1352 iotg->otg.default_a = 0;
1353 iotg->hsm.b_bus_req = 0;
1354
1355 if (lnw->iotg.stop_host)
1356 lnw->iotg.stop_host(&lnw->iotg);
1357 else
1358 dev_dbg(lnw->dev,
1359 "host driver has been removed.\n");
1360
1361 /* Turn off VBus */
1362 iotg->otg.set_vbus(&iotg->otg, false);
1363 set_client_mode();
1364 langwell_otg_phy_low_power_wait(1);
1365 iotg->otg.state = OTG_STATE_B_IDLE;
1366 langwell_update_transceiver();
1367 } else if (!iotg->hsm.a_vbus_vld) {
1368 /* delete hsm timer for a_wait_bcon_tmr */
1369 del_timer_sync(&lnw->hsm_timer);
1370
1371 if (lnw->iotg.stop_host)
1372 lnw->iotg.stop_host(&lnw->iotg);
1373 else
1374 dev_dbg(lnw->dev,
1375 "host driver has been removed.\n");
1376
1377 /* Turn off VBus */
1378 iotg->otg.set_vbus(&iotg->otg, false);
1379 langwell_otg_phy_low_power_wait(1);
1380 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1381 } else if (iotg->hsm.a_bus_drop ||
1382 (iotg->hsm.a_wait_bcon_tmout &&
1383 !iotg->hsm.a_bus_req)) {
1384 /* delete hsm timer for a_wait_bcon_tmr */
1385 del_timer_sync(&lnw->hsm_timer);
1386
1387 if (lnw->iotg.stop_host)
1388 lnw->iotg.stop_host(&lnw->iotg);
1389 else
1390 dev_dbg(lnw->dev,
1391 "host driver has been removed.\n");
1392
1393 /* Turn off VBus */
1394 iotg->otg.set_vbus(&iotg->otg, false);
1395 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1396 } else if (iotg->hsm.b_conn) {
1397 /* delete hsm timer for a_wait_bcon_tmr */
1398 del_timer_sync(&lnw->hsm_timer);
1399
1400 iotg->hsm.a_suspend_req = 0;
1401 iotg->otg.state = OTG_STATE_A_HOST;
1402 if (iotg->hsm.a_srp_det && iotg->otg.host &&
1403 !iotg->otg.host->b_hnp_enable) {
1404 /* SRP capable peripheral-only device */
1405 iotg->hsm.a_bus_req = 1;
1406 iotg->hsm.a_srp_det = 0;
1407 } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
1408 iotg->otg.host->b_hnp_enable) {
1409 /* It is not safe enough to do a fast
1410 * transistion from A_WAIT_BCON to
1411 * A_SUSPEND */
1412 msleep(10000);
1413 if (iotg->hsm.a_bus_req)
1414 break;
1415
1416 if (request_irq(pdev->irq,
1417 otg_dummy_irq, IRQF_SHARED,
1418 driver_name, iotg->base) != 0) {
1419 dev_dbg(lnw->dev,
1420 "request interrupt %d fail\n",
1421 pdev->irq);
1422 }
1423
1424 langwell_otg_HABA(1);
1425 iotg->hsm.b_bus_resume = 0;
1426 iotg->hsm.a_aidl_bdis_tmout = 0;
1427
1428 langwell_otg_loc_sof(0);
1429 /* clear PHCD to enable HW timer */
1430 langwell_otg_phy_low_power(0);
1431 langwell_otg_add_timer(a_aidl_bdis_tmr);
1432 iotg->otg.state = OTG_STATE_A_SUSPEND;
1433 } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
1434 !iotg->otg.host->b_hnp_enable) {
1435 if (lnw->iotg.stop_host)
1436 lnw->iotg.stop_host(&lnw->iotg);
1437 else
1438 dev_dbg(lnw->dev,
1439 "host driver removed.\n");
1440
1441 /* Turn off VBus */
1442 iotg->otg.set_vbus(&iotg->otg, false);
1443 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1444 }
1445 }
1446 break;
1447 case OTG_STATE_A_HOST:
1448 if (iotg->hsm.id) {
1449 iotg->otg.default_a = 0;
1450 iotg->hsm.b_bus_req = 0;
1451
1452 if (lnw->iotg.stop_host)
1453 lnw->iotg.stop_host(&lnw->iotg);
1454 else
1455 dev_dbg(lnw->dev,
1456 "host driver has been removed.\n");
1457
1458 /* Turn off VBus */
1459 iotg->otg.set_vbus(&iotg->otg, false);
1460 set_client_mode();
1461 langwell_otg_phy_low_power_wait(1);
1462 iotg->otg.state = OTG_STATE_B_IDLE;
1463 langwell_update_transceiver();
1464 } else if (iotg->hsm.a_bus_drop ||
1465 (iotg->otg.host &&
1466 !iotg->otg.host->b_hnp_enable &&
1467 !iotg->hsm.a_bus_req)) {
1468 if (lnw->iotg.stop_host)
1469 lnw->iotg.stop_host(&lnw->iotg);
1470 else
1471 dev_dbg(lnw->dev,
1472 "host driver has been removed.\n");
1473
1474 /* Turn off VBus */
1475 iotg->otg.set_vbus(&iotg->otg, false);
1476 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1477 } else if (!iotg->hsm.a_vbus_vld) {
1478 if (lnw->iotg.stop_host)
1479 lnw->iotg.stop_host(&lnw->iotg);
1480 else
1481 dev_dbg(lnw->dev,
1482 "host driver has been removed.\n");
1483
1484 /* Turn off VBus */
1485 iotg->otg.set_vbus(&iotg->otg, false);
1486 langwell_otg_phy_low_power_wait(1);
1487 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1488 } else if (iotg->otg.host &&
1489 iotg->otg.host->b_hnp_enable &&
1490 !iotg->hsm.a_bus_req) {
1491 /* Set HABA to enable hardware assistance to signal
1492 * A-connect after receiver B-disconnect. Hardware
1493 * will then set client mode and enable URE, SLE and
1494 * PCE after the assistance. otg_dummy_irq is used to
1495 * clean these ints when client driver is not resumed.
1496 */
1497 if (request_irq(pdev->irq, otg_dummy_irq, IRQF_SHARED,
1498 driver_name, iotg->base) != 0) {
1499 dev_dbg(lnw->dev,
1500 "request interrupt %d failed\n",
1501 pdev->irq);
1502 }
1503
1504 /* set HABA */
1505 langwell_otg_HABA(1);
1506 iotg->hsm.b_bus_resume = 0;
1507 iotg->hsm.a_aidl_bdis_tmout = 0;
1508 langwell_otg_loc_sof(0);
1509 /* clear PHCD to enable HW timer */
1510 langwell_otg_phy_low_power(0);
1511 langwell_otg_add_timer(a_aidl_bdis_tmr);
1512 iotg->otg.state = OTG_STATE_A_SUSPEND;
1513 } else if (!iotg->hsm.b_conn || !iotg->hsm.a_bus_req) {
1514 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1515 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1516 }
1517 break;
1518 case OTG_STATE_A_SUSPEND:
1519 if (iotg->hsm.id) {
1520 langwell_otg_del_timer(a_aidl_bdis_tmr);
1521 langwell_otg_HABA(0);
1522 free_irq(pdev->irq, iotg->base);
1523 iotg->otg.default_a = 0;
1524 iotg->hsm.b_bus_req = 0;
1525
1526 if (lnw->iotg.stop_host)
1527 lnw->iotg.stop_host(&lnw->iotg);
1528 else
1529 dev_dbg(lnw->dev,
1530 "host driver has been removed.\n");
1531
1532 /* Turn off VBus */
1533 iotg->otg.set_vbus(&iotg->otg, false);
1534 set_client_mode();
1535 langwell_otg_phy_low_power(1);
1536 iotg->otg.state = OTG_STATE_B_IDLE;
1537 langwell_update_transceiver();
1538 } else if (iotg->hsm.a_bus_req ||
1539 iotg->hsm.b_bus_resume) {
1540 langwell_otg_del_timer(a_aidl_bdis_tmr);
1541 langwell_otg_HABA(0);
1542 free_irq(pdev->irq, iotg->base);
1543 iotg->hsm.a_suspend_req = 0;
1544 langwell_otg_loc_sof(1);
1545 iotg->otg.state = OTG_STATE_A_HOST;
1546 } else if (iotg->hsm.a_aidl_bdis_tmout ||
1547 iotg->hsm.a_bus_drop) {
1548 langwell_otg_del_timer(a_aidl_bdis_tmr);
1549 langwell_otg_HABA(0);
1550 free_irq(pdev->irq, iotg->base);
1551 if (lnw->iotg.stop_host)
1552 lnw->iotg.stop_host(&lnw->iotg);
1553 else
1554 dev_dbg(lnw->dev,
1555 "host driver has been removed.\n");
1556
1557 /* Turn off VBus */
1558 iotg->otg.set_vbus(&iotg->otg, false);
1559 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1560 } else if (!iotg->hsm.b_conn && iotg->otg.host &&
1561 iotg->otg.host->b_hnp_enable) {
1562 langwell_otg_del_timer(a_aidl_bdis_tmr);
1563 langwell_otg_HABA(0);
1564 free_irq(pdev->irq, iotg->base);
1565
1566 if (lnw->iotg.stop_host)
1567 lnw->iotg.stop_host(&lnw->iotg);
1568 else
1569 dev_dbg(lnw->dev,
1570 "host driver has been removed.\n");
1571
1572 iotg->hsm.b_bus_suspend = 0;
1573 iotg->hsm.b_bus_suspend_vld = 0;
1574
1575 /* msleep(200); */
1576 if (lnw->iotg.start_peripheral)
1577 lnw->iotg.start_peripheral(&lnw->iotg);
1578 else
1579 dev_dbg(lnw->dev,
1580 "client driver not loaded.\n");
1581
1582 langwell_otg_add_ktimer(TB_BUS_SUSPEND_TMR);
1583 iotg->otg.state = OTG_STATE_A_PERIPHERAL;
1584 break;
1585 } else if (!iotg->hsm.a_vbus_vld) {
1586 langwell_otg_del_timer(a_aidl_bdis_tmr);
1587 langwell_otg_HABA(0);
1588 free_irq(pdev->irq, iotg->base);
1589 if (lnw->iotg.stop_host)
1590 lnw->iotg.stop_host(&lnw->iotg);
1591 else
1592 dev_dbg(lnw->dev,
1593 "host driver has been removed.\n");
1594
1595 /* Turn off VBus */
1596 iotg->otg.set_vbus(&iotg->otg, false);
1597 langwell_otg_phy_low_power_wait(1);
1598 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1599 }
1600 break;
1601 case OTG_STATE_A_PERIPHERAL:
1602 if (iotg->hsm.id) {
1603 /* delete hsm timer for b_bus_suspend_tmr */
1604 del_timer_sync(&lnw->hsm_timer);
1605 iotg->otg.default_a = 0;
1606 iotg->hsm.b_bus_req = 0;
1607 if (lnw->iotg.stop_peripheral)
1608 lnw->iotg.stop_peripheral(&lnw->iotg);
1609 else
1610 dev_dbg(lnw->dev,
1611 "client driver has been removed.\n");
1612
1613 /* Turn off VBus */
1614 iotg->otg.set_vbus(&iotg->otg, false);
1615 set_client_mode();
1616 langwell_otg_phy_low_power_wait(1);
1617 iotg->otg.state = OTG_STATE_B_IDLE;
1618 langwell_update_transceiver();
1619 } else if (!iotg->hsm.a_vbus_vld) {
1620 /* delete hsm timer for b_bus_suspend_tmr */
1621 del_timer_sync(&lnw->hsm_timer);
1622
1623 if (lnw->iotg.stop_peripheral)
1624 lnw->iotg.stop_peripheral(&lnw->iotg);
1625 else
1626 dev_dbg(lnw->dev,
1627 "client driver has been removed.\n");
1628
1629 /* Turn off VBus */
1630 iotg->otg.set_vbus(&iotg->otg, false);
1631 langwell_otg_phy_low_power_wait(1);
1632 iotg->otg.state = OTG_STATE_A_VBUS_ERR;
1633 } else if (iotg->hsm.a_bus_drop) {
1634 /* delete hsm timer for b_bus_suspend_tmr */
1635 del_timer_sync(&lnw->hsm_timer);
1636
1637 if (lnw->iotg.stop_peripheral)
1638 lnw->iotg.stop_peripheral(&lnw->iotg);
1639 else
1640 dev_dbg(lnw->dev,
1641 "client driver has been removed.\n");
1642
1643 /* Turn off VBus */
1644 iotg->otg.set_vbus(&iotg->otg, false);
1645 iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
1646 } else if (iotg->hsm.b_bus_suspend) {
1647 /* delete hsm timer for b_bus_suspend_tmr */
1648 del_timer_sync(&lnw->hsm_timer);
1649
1650 if (lnw->iotg.stop_peripheral)
1651 lnw->iotg.stop_peripheral(&lnw->iotg);
1652 else
1653 dev_dbg(lnw->dev,
1654 "client driver has been removed.\n");
1655
1656 if (lnw->iotg.start_host)
1657 lnw->iotg.start_host(&lnw->iotg);
1658 else
1659 dev_dbg(lnw->dev,
1660 "host driver not loaded.\n");
1661 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1662 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1663 } else if (iotg->hsm.b_bus_suspend_tmout) {
1664 u32 val;
1665 val = readl(lnw->iotg.base + CI_PORTSC1);
1666 if (!(val & PORTSC_SUSP))
1667 break;
1668
1669 if (lnw->iotg.stop_peripheral)
1670 lnw->iotg.stop_peripheral(&lnw->iotg);
1671 else
1672 dev_dbg(lnw->dev,
1673 "client driver has been removed.\n");
1674
1675 if (lnw->iotg.start_host)
1676 lnw->iotg.start_host(&lnw->iotg);
1677 else
1678 dev_dbg(lnw->dev,
1679 "host driver not loaded.\n");
1680 langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
1681 iotg->otg.state = OTG_STATE_A_WAIT_BCON;
1682 }
1683 break;
1684 case OTG_STATE_A_VBUS_ERR:
1685 if (iotg->hsm.id) {
1686 iotg->otg.default_a = 0;
1687 iotg->hsm.a_clr_err = 0;
1688 iotg->hsm.a_srp_det = 0;
1689 set_client_mode();
1690 langwell_otg_phy_low_power(1);
1691 iotg->otg.state = OTG_STATE_B_IDLE;
1692 langwell_update_transceiver();
1693 } else if (iotg->hsm.a_clr_err) {
1694 iotg->hsm.a_clr_err = 0;
1695 iotg->hsm.a_srp_det = 0;
1696 reset_otg();
1697 init_hsm();
1698 if (iotg->otg.state == OTG_STATE_A_IDLE)
1699 langwell_update_transceiver();
1700 } else {
1701 /* FW will clear PHCD bit when any VBus
1702 * event detected. Reset PHCD to 1 again */
1703 langwell_otg_phy_low_power(1);
1704 }
1705 break;
1706 case OTG_STATE_A_WAIT_VFALL:
1707 if (iotg->hsm.id) {
1708 iotg->otg.default_a = 0;
1709 set_client_mode();
1710 langwell_otg_phy_low_power(1);
1711 iotg->otg.state = OTG_STATE_B_IDLE;
1712 langwell_update_transceiver();
1713 } else if (iotg->hsm.a_bus_req) {
1714
1715 /* Turn on VBus */
1716 iotg->otg.set_vbus(&iotg->otg, true);
1717 iotg->hsm.a_wait_vrise_tmout = 0;
1718 langwell_otg_add_timer(a_wait_vrise_tmr);
1719 iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
1720 } else if (!iotg->hsm.a_sess_vld) {
1721 iotg->hsm.a_srp_det = 0;
1722 set_host_mode();
1723 langwell_otg_phy_low_power(1);
1724 iotg->otg.state = OTG_STATE_A_IDLE;
1725 }
1726 break;
1727 default:
1728 ;
1729 }
1730
1731 dev_dbg(lnw->dev, "%s: new state = %s\n", __func__,
1732 state_string(iotg->otg.state));
1733}
1734
1735static ssize_t
1736show_registers(struct device *_dev, struct device_attribute *attr, char *buf)
1737{
1738 struct langwell_otg *lnw = the_transceiver;
1739 char *next;
1740 unsigned size, t;
1741
1742 next = buf;
1743 size = PAGE_SIZE;
1744
1745 t = scnprintf(next, size,
1746 "\n"
1747 "USBCMD = 0x%08x\n"
1748 "USBSTS = 0x%08x\n"
1749 "USBINTR = 0x%08x\n"
1750 "ASYNCLISTADDR = 0x%08x\n"
1751 "PORTSC1 = 0x%08x\n"
1752 "HOSTPC1 = 0x%08x\n"
1753 "OTGSC = 0x%08x\n"
1754 "USBMODE = 0x%08x\n",
1755 readl(lnw->iotg.base + 0x30),
1756 readl(lnw->iotg.base + 0x34),
1757 readl(lnw->iotg.base + 0x38),
1758 readl(lnw->iotg.base + 0x48),
1759 readl(lnw->iotg.base + 0x74),
1760 readl(lnw->iotg.base + 0xb4),
1761 readl(lnw->iotg.base + 0xf4),
1762 readl(lnw->iotg.base + 0xf8)
1763 );
1764 size -= t;
1765 next += t;
1766
1767 return PAGE_SIZE - size;
1768}
1769static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
1770
1771static ssize_t
1772show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
1773{
1774 struct langwell_otg *lnw = the_transceiver;
1775 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1776 char *next;
1777 unsigned size, t;
1778
1779 next = buf;
1780 size = PAGE_SIZE;
1781
1782 if (iotg->otg.host)
1783 iotg->hsm.a_set_b_hnp_en = iotg->otg.host->b_hnp_enable;
1784
1785 if (iotg->otg.gadget)
1786 iotg->hsm.b_hnp_enable = iotg->otg.gadget->b_hnp_enable;
1787
1788 t = scnprintf(next, size,
1789 "\n"
1790 "current state = %s\n"
1791 "a_bus_resume = \t%d\n"
1792 "a_bus_suspend = \t%d\n"
1793 "a_conn = \t%d\n"
1794 "a_sess_vld = \t%d\n"
1795 "a_srp_det = \t%d\n"
1796 "a_vbus_vld = \t%d\n"
1797 "b_bus_resume = \t%d\n"
1798 "b_bus_suspend = \t%d\n"
1799 "b_conn = \t%d\n"
1800 "b_se0_srp = \t%d\n"
1801 "b_sess_end = \t%d\n"
1802 "b_sess_vld = \t%d\n"
1803 "id = \t%d\n"
1804 "a_set_b_hnp_en = \t%d\n"
1805 "b_srp_done = \t%d\n"
1806 "b_hnp_enable = \t%d\n"
1807 "a_wait_vrise_tmout = \t%d\n"
1808 "a_wait_bcon_tmout = \t%d\n"
1809 "a_aidl_bdis_tmout = \t%d\n"
1810 "b_ase0_brst_tmout = \t%d\n"
1811 "a_bus_drop = \t%d\n"
1812 "a_bus_req = \t%d\n"
1813 "a_clr_err = \t%d\n"
1814 "a_suspend_req = \t%d\n"
1815 "b_bus_req = \t%d\n"
1816 "b_bus_suspend_tmout = \t%d\n"
1817 "b_bus_suspend_vld = \t%d\n",
1818 state_string(iotg->otg.state),
1819 iotg->hsm.a_bus_resume,
1820 iotg->hsm.a_bus_suspend,
1821 iotg->hsm.a_conn,
1822 iotg->hsm.a_sess_vld,
1823 iotg->hsm.a_srp_det,
1824 iotg->hsm.a_vbus_vld,
1825 iotg->hsm.b_bus_resume,
1826 iotg->hsm.b_bus_suspend,
1827 iotg->hsm.b_conn,
1828 iotg->hsm.b_se0_srp,
1829 iotg->hsm.b_sess_end,
1830 iotg->hsm.b_sess_vld,
1831 iotg->hsm.id,
1832 iotg->hsm.a_set_b_hnp_en,
1833 iotg->hsm.b_srp_done,
1834 iotg->hsm.b_hnp_enable,
1835 iotg->hsm.a_wait_vrise_tmout,
1836 iotg->hsm.a_wait_bcon_tmout,
1837 iotg->hsm.a_aidl_bdis_tmout,
1838 iotg->hsm.b_ase0_brst_tmout,
1839 iotg->hsm.a_bus_drop,
1840 iotg->hsm.a_bus_req,
1841 iotg->hsm.a_clr_err,
1842 iotg->hsm.a_suspend_req,
1843 iotg->hsm.b_bus_req,
1844 iotg->hsm.b_bus_suspend_tmout,
1845 iotg->hsm.b_bus_suspend_vld
1846 );
1847 size -= t;
1848 next += t;
1849
1850 return PAGE_SIZE - size;
1851}
1852static DEVICE_ATTR(hsm, S_IRUGO, show_hsm, NULL);
1853
1854static ssize_t
1855get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1856{
1857 struct langwell_otg *lnw = the_transceiver;
1858 char *next;
1859 unsigned size, t;
1860
1861 next = buf;
1862 size = PAGE_SIZE;
1863
1864 t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_req);
1865 size -= t;
1866 next += t;
1867
1868 return PAGE_SIZE - size;
1869}
1870
1871static ssize_t
1872set_a_bus_req(struct device *dev, struct device_attribute *attr,
1873 const char *buf, size_t count)
1874{
1875 struct langwell_otg *lnw = the_transceiver;
1876 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1877
1878 if (!iotg->otg.default_a)
1879 return -1;
1880 if (count > 2)
1881 return -1;
1882
1883 if (buf[0] == '0') {
1884 iotg->hsm.a_bus_req = 0;
1885 dev_dbg(lnw->dev, "User request: a_bus_req = 0\n");
1886 } else if (buf[0] == '1') {
1887 /* If a_bus_drop is TRUE, a_bus_req can't be set */
1888 if (iotg->hsm.a_bus_drop)
1889 return -1;
1890 iotg->hsm.a_bus_req = 1;
1891 dev_dbg(lnw->dev, "User request: a_bus_req = 1\n");
1892 }
1893 if (spin_trylock(&lnw->wq_lock)) {
1894 langwell_update_transceiver();
1895 spin_unlock(&lnw->wq_lock);
1896 }
1897 return count;
1898}
1899static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUGO, get_a_bus_req, set_a_bus_req);
1900
1901static ssize_t
1902get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
1903{
1904 struct langwell_otg *lnw = the_transceiver;
1905 char *next;
1906 unsigned size, t;
1907
1908 next = buf;
1909 size = PAGE_SIZE;
1910
1911 t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_drop);
1912 size -= t;
1913 next += t;
1914
1915 return PAGE_SIZE - size;
1916}
1917
1918static ssize_t
1919set_a_bus_drop(struct device *dev, struct device_attribute *attr,
1920 const char *buf, size_t count)
1921{
1922 struct langwell_otg *lnw = the_transceiver;
1923 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1924
1925 if (!iotg->otg.default_a)
1926 return -1;
1927 if (count > 2)
1928 return -1;
1929
1930 if (buf[0] == '0') {
1931 iotg->hsm.a_bus_drop = 0;
1932 dev_dbg(lnw->dev, "User request: a_bus_drop = 0\n");
1933 } else if (buf[0] == '1') {
1934 iotg->hsm.a_bus_drop = 1;
1935 iotg->hsm.a_bus_req = 0;
1936 dev_dbg(lnw->dev, "User request: a_bus_drop = 1\n");
1937 dev_dbg(lnw->dev, "User request: and a_bus_req = 0\n");
1938 }
1939 if (spin_trylock(&lnw->wq_lock)) {
1940 langwell_update_transceiver();
1941 spin_unlock(&lnw->wq_lock);
1942 }
1943 return count;
1944}
1945static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUGO,
1946 get_a_bus_drop, set_a_bus_drop);
1947
1948static ssize_t
1949get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1950{
1951 struct langwell_otg *lnw = the_transceiver;
1952 char *next;
1953 unsigned size, t;
1954
1955 next = buf;
1956 size = PAGE_SIZE;
1957
1958 t = scnprintf(next, size, "%d", lnw->iotg.hsm.b_bus_req);
1959 size -= t;
1960 next += t;
1961
1962 return PAGE_SIZE - size;
1963}
1964
1965static ssize_t
1966set_b_bus_req(struct device *dev, struct device_attribute *attr,
1967 const char *buf, size_t count)
1968{
1969 struct langwell_otg *lnw = the_transceiver;
1970 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1971
1972 if (iotg->otg.default_a)
1973 return -1;
1974
1975 if (count > 2)
1976 return -1;
1977
1978 if (buf[0] == '0') {
1979 iotg->hsm.b_bus_req = 0;
1980 dev_dbg(lnw->dev, "User request: b_bus_req = 0\n");
1981 } else if (buf[0] == '1') {
1982 iotg->hsm.b_bus_req = 1;
1983 dev_dbg(lnw->dev, "User request: b_bus_req = 1\n");
1984 }
1985 if (spin_trylock(&lnw->wq_lock)) {
1986 langwell_update_transceiver();
1987 spin_unlock(&lnw->wq_lock);
1988 }
1989 return count;
1990}
1991static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUGO, get_b_bus_req, set_b_bus_req);
1992
1993static ssize_t
1994set_a_clr_err(struct device *dev, struct device_attribute *attr,
1995 const char *buf, size_t count)
1996{
1997 struct langwell_otg *lnw = the_transceiver;
1998 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
1999
2000 if (!iotg->otg.default_a)
2001 return -1;
2002 if (count > 2)
2003 return -1;
2004
2005 if (buf[0] == '1') {
2006 iotg->hsm.a_clr_err = 1;
2007 dev_dbg(lnw->dev, "User request: a_clr_err = 1\n");
2008 }
2009 if (spin_trylock(&lnw->wq_lock)) {
2010 langwell_update_transceiver();
2011 spin_unlock(&lnw->wq_lock);
2012 }
2013 return count;
2014}
2015static DEVICE_ATTR(a_clr_err, S_IWUGO, NULL, set_a_clr_err);
2016
2017static struct attribute *inputs_attrs[] = {
2018 &dev_attr_a_bus_req.attr,
2019 &dev_attr_a_bus_drop.attr,
2020 &dev_attr_b_bus_req.attr,
2021 &dev_attr_a_clr_err.attr,
2022 NULL,
2023};
2024
2025static struct attribute_group debug_dev_attr_group = {
2026 .name = "inputs",
2027 .attrs = inputs_attrs,
2028};
2029
2030static int langwell_otg_probe(struct pci_dev *pdev,
2031 const struct pci_device_id *id)
2032{
2033 unsigned long resource, len;
2034 void __iomem *base = NULL;
2035 int retval;
2036 u32 val32;
2037 struct langwell_otg *lnw;
2038 char qname[] = "langwell_otg_queue";
2039
2040 retval = 0;
2041 dev_dbg(&pdev->dev, "\notg controller is detected.\n");
2042 if (pci_enable_device(pdev) < 0) {
2043 retval = -ENODEV;
2044 goto done;
2045 }
2046
2047 lnw = kzalloc(sizeof *lnw, GFP_KERNEL);
2048 if (lnw == NULL) {
2049 retval = -ENOMEM;
2050 goto done;
2051 }
2052 the_transceiver = lnw;
2053
2054 /* control register: BAR 0 */
2055 resource = pci_resource_start(pdev, 0);
2056 len = pci_resource_len(pdev, 0);
2057 if (!request_mem_region(resource, len, driver_name)) {
2058 retval = -EBUSY;
2059 goto err;
2060 }
2061 lnw->region = 1;
2062
2063 base = ioremap_nocache(resource, len);
2064 if (base == NULL) {
2065 retval = -EFAULT;
2066 goto err;
2067 }
2068 lnw->iotg.base = base;
2069
2070 if (!request_mem_region(USBCFG_ADDR, USBCFG_LEN, driver_name)) {
2071 retval = -EBUSY;
2072 goto err;
2073 }
2074 lnw->cfg_region = 1;
2075
2076 /* For the SCCB.USBCFG register */
2077 base = ioremap_nocache(USBCFG_ADDR, USBCFG_LEN);
2078 if (base == NULL) {
2079 retval = -EFAULT;
2080 goto err;
2081 }
2082 lnw->usbcfg = base;
2083
2084 if (!pdev->irq) {
2085 dev_dbg(&pdev->dev, "No IRQ.\n");
2086 retval = -ENODEV;
2087 goto err;
2088 }
2089
2090 lnw->qwork = create_singlethread_workqueue(qname);
2091 if (!lnw->qwork) {
2092 dev_dbg(&pdev->dev, "cannot create workqueue %s\n", qname);
2093 retval = -ENOMEM;
2094 goto err;
2095 }
2096 INIT_WORK(&lnw->work, langwell_otg_work);
2097
2098 /* OTG common part */
2099 lnw->dev = &pdev->dev;
2100 lnw->iotg.otg.dev = lnw->dev;
2101 lnw->iotg.otg.label = driver_name;
2102 lnw->iotg.otg.set_host = langwell_otg_set_host;
2103 lnw->iotg.otg.set_peripheral = langwell_otg_set_peripheral;
2104 lnw->iotg.otg.set_power = langwell_otg_set_power;
2105 lnw->iotg.otg.set_vbus = langwell_otg_set_vbus;
2106 lnw->iotg.otg.start_srp = langwell_otg_start_srp;
2107 lnw->iotg.otg.state = OTG_STATE_UNDEFINED;
2108
2109 if (otg_set_transceiver(&lnw->iotg.otg)) {
2110 dev_dbg(lnw->dev, "can't set transceiver\n");
2111 retval = -EBUSY;
2112 goto err;
2113 }
2114
2115 reset_otg();
2116 init_hsm();
2117
2118 spin_lock_init(&lnw->lock);
2119 spin_lock_init(&lnw->wq_lock);
2120 INIT_LIST_HEAD(&active_timers);
2121 retval = langwell_otg_init_timers(&lnw->iotg.hsm);
2122 if (retval) {
2123 dev_dbg(&pdev->dev, "Failed to init timers\n");
2124 goto err;
2125 }
2126
2127 init_timer(&lnw->hsm_timer);
2128 ATOMIC_INIT_NOTIFIER_HEAD(&lnw->iotg.iotg_notifier);
2129
2130 lnw->iotg_notifier.notifier_call = langwell_otg_iotg_notify;
2131
2132 retval = intel_mid_otg_register_notifier(&lnw->iotg,
2133 &lnw->iotg_notifier);
2134 if (retval) {
2135 dev_dbg(lnw->dev, "Failed to register notifier\n");
2136 goto err;
2137 }
2138
2139 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
2140 driver_name, lnw) != 0) {
2141 dev_dbg(lnw->dev, "request interrupt %d failed\n", pdev->irq);
2142 retval = -EBUSY;
2143 goto err;
2144 }
2145
2146 /* enable OTGSC int */
2147 val32 = OTGSC_DPIE | OTGSC_BSEIE | OTGSC_BSVIE |
2148 OTGSC_ASVIE | OTGSC_AVVIE | OTGSC_IDIE | OTGSC_IDPU;
2149 writel(val32, lnw->iotg.base + CI_OTGSC);
2150
2151 retval = device_create_file(&pdev->dev, &dev_attr_registers);
2152 if (retval < 0) {
2153 dev_dbg(lnw->dev,
2154 "Can't register sysfs attribute: %d\n", retval);
2155 goto err;
2156 }
2157
2158 retval = device_create_file(&pdev->dev, &dev_attr_hsm);
2159 if (retval < 0) {
2160 dev_dbg(lnw->dev, "Can't hsm sysfs attribute: %d\n", retval);
2161 goto err;
2162 }
2163
2164 retval = sysfs_create_group(&pdev->dev.kobj, &debug_dev_attr_group);
2165 if (retval < 0) {
2166 dev_dbg(lnw->dev,
2167 "Can't register sysfs attr group: %d\n", retval);
2168 goto err;
2169 }
2170
2171 if (lnw->iotg.otg.state == OTG_STATE_A_IDLE)
2172 langwell_update_transceiver();
2173
2174 return 0;
2175
2176err:
2177 if (the_transceiver)
2178 langwell_otg_remove(pdev);
2179done:
2180 return retval;
2181}
2182
2183static void langwell_otg_remove(struct pci_dev *pdev)
2184{
2185 struct langwell_otg *lnw = the_transceiver;
2186
2187 if (lnw->qwork) {
2188 flush_workqueue(lnw->qwork);
2189 destroy_workqueue(lnw->qwork);
2190 }
2191 intel_mid_otg_unregister_notifier(&lnw->iotg, &lnw->iotg_notifier);
2192 langwell_otg_free_timers();
2193
2194 /* disable OTGSC interrupt as OTGSC doesn't change in reset */
2195 writel(0, lnw->iotg.base + CI_OTGSC);
2196
2197 if (pdev->irq)
2198 free_irq(pdev->irq, lnw);
2199 if (lnw->usbcfg)
2200 iounmap(lnw->usbcfg);
2201 if (lnw->cfg_region)
2202 release_mem_region(USBCFG_ADDR, USBCFG_LEN);
2203 if (lnw->iotg.base)
2204 iounmap(lnw->iotg.base);
2205 if (lnw->region)
2206 release_mem_region(pci_resource_start(pdev, 0),
2207 pci_resource_len(pdev, 0));
2208
2209 otg_set_transceiver(NULL);
2210 pci_disable_device(pdev);
2211 sysfs_remove_group(&pdev->dev.kobj, &debug_dev_attr_group);
2212 device_remove_file(&pdev->dev, &dev_attr_hsm);
2213 device_remove_file(&pdev->dev, &dev_attr_registers);
2214 kfree(lnw);
2215 lnw = NULL;
2216}
2217
2218static void transceiver_suspend(struct pci_dev *pdev)
2219{
2220 pci_save_state(pdev);
2221 pci_set_power_state(pdev, PCI_D3hot);
2222 langwell_otg_phy_low_power(1);
2223}
2224
2225static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
2226{
2227 struct langwell_otg *lnw = the_transceiver;
2228 struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
2229 int ret = 0;
2230
2231 /* Disbale OTG interrupts */
2232 langwell_otg_intr(0);
2233
2234 if (pdev->irq)
2235 free_irq(pdev->irq, lnw);
2236
2237 /* Prevent more otg_work */
2238 flush_workqueue(lnw->qwork);
2239 destroy_workqueue(lnw->qwork);
2240 lnw->qwork = NULL;
2241
2242 /* start actions */
2243 switch (iotg->otg.state) {
2244 case OTG_STATE_A_WAIT_VFALL:
2245 iotg->otg.state = OTG_STATE_A_IDLE;
2246 case OTG_STATE_A_IDLE:
2247 case OTG_STATE_B_IDLE:
2248 case OTG_STATE_A_VBUS_ERR:
2249 transceiver_suspend(pdev);
2250 break;
2251 case OTG_STATE_A_WAIT_VRISE:
2252 langwell_otg_del_timer(a_wait_vrise_tmr);
2253 iotg->hsm.a_srp_det = 0;
2254
2255 /* Turn off VBus */
2256 iotg->otg.set_vbus(&iotg->otg, false);
2257 iotg->otg.state = OTG_STATE_A_IDLE;
2258 transceiver_suspend(pdev);
2259 break;
2260 case OTG_STATE_A_WAIT_BCON:
2261 del_timer_sync(&lnw->hsm_timer);
2262 if (lnw->iotg.stop_host)
2263 lnw->iotg.stop_host(&lnw->iotg);
2264 else
2265 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2266
2267 iotg->hsm.a_srp_det = 0;
2268
2269 /* Turn off VBus */
2270 iotg->otg.set_vbus(&iotg->otg, false);
2271 iotg->otg.state = OTG_STATE_A_IDLE;
2272 transceiver_suspend(pdev);
2273 break;
2274 case OTG_STATE_A_HOST:
2275 if (lnw->iotg.stop_host)
2276 lnw->iotg.stop_host(&lnw->iotg);
2277 else
2278 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2279
2280 iotg->hsm.a_srp_det = 0;
2281
2282 /* Turn off VBus */
2283 iotg->otg.set_vbus(&iotg->otg, false);
2284
2285 iotg->otg.state = OTG_STATE_A_IDLE;
2286 transceiver_suspend(pdev);
2287 break;
2288 case OTG_STATE_A_SUSPEND:
2289 langwell_otg_del_timer(a_aidl_bdis_tmr);
2290 langwell_otg_HABA(0);
2291 if (lnw->iotg.stop_host)
2292 lnw->iotg.stop_host(&lnw->iotg);
2293 else
2294 dev_dbg(lnw->dev, "host driver has been removed.\n");
2295 iotg->hsm.a_srp_det = 0;
2296
2297 /* Turn off VBus */
2298 iotg->otg.set_vbus(&iotg->otg, false);
2299 iotg->otg.state = OTG_STATE_A_IDLE;
2300 transceiver_suspend(pdev);
2301 break;
2302 case OTG_STATE_A_PERIPHERAL:
2303 del_timer_sync(&lnw->hsm_timer);
2304
2305 if (lnw->iotg.stop_peripheral)
2306 lnw->iotg.stop_peripheral(&lnw->iotg);
2307 else
2308 dev_dbg(&pdev->dev,
2309 "client driver has been removed.\n");
2310 iotg->hsm.a_srp_det = 0;
2311
2312 /* Turn off VBus */
2313 iotg->otg.set_vbus(&iotg->otg, false);
2314 iotg->otg.state = OTG_STATE_A_IDLE;
2315 transceiver_suspend(pdev);
2316 break;
2317 case OTG_STATE_B_HOST:
2318 if (lnw->iotg.stop_host)
2319 lnw->iotg.stop_host(&lnw->iotg);
2320 else
2321 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2322 iotg->hsm.b_bus_req = 0;
2323 iotg->otg.state = OTG_STATE_B_IDLE;
2324 transceiver_suspend(pdev);
2325 break;
2326 case OTG_STATE_B_PERIPHERAL:
2327 if (lnw->iotg.stop_peripheral)
2328 lnw->iotg.stop_peripheral(&lnw->iotg);
2329 else
2330 dev_dbg(&pdev->dev,
2331 "client driver has been removed.\n");
2332 iotg->otg.state = OTG_STATE_B_IDLE;
2333 transceiver_suspend(pdev);
2334 break;
2335 case OTG_STATE_B_WAIT_ACON:
2336 /* delete hsm timer for b_ase0_brst_tmr */
2337 del_timer_sync(&lnw->hsm_timer);
2338
2339 langwell_otg_HAAR(0);
2340
2341 if (lnw->iotg.stop_host)
2342 lnw->iotg.stop_host(&lnw->iotg);
2343 else
2344 dev_dbg(&pdev->dev, "host driver has been removed.\n");
2345 iotg->hsm.b_bus_req = 0;
2346 iotg->otg.state = OTG_STATE_B_IDLE;
2347 transceiver_suspend(pdev);
2348 break;
2349 default:
2350 dev_dbg(lnw->dev, "error state before suspend\n");
2351 break;
2352 }
2353
2354 return ret;
2355}
2356
2357static void transceiver_resume(struct pci_dev *pdev)
2358{
2359 pci_restore_state(pdev);
2360 pci_set_power_state(pdev, PCI_D0);
2361}
2362
2363static int langwell_otg_resume(struct pci_dev *pdev)
2364{
2365 struct langwell_otg *lnw = the_transceiver;
2366 int ret = 0;
2367
2368 transceiver_resume(pdev);
2369
2370 lnw->qwork = create_singlethread_workqueue("langwell_otg_queue");
2371 if (!lnw->qwork) {
2372 dev_dbg(&pdev->dev, "cannot create langwell otg workqueuen");
2373 ret = -ENOMEM;
2374 goto error;
2375 }
2376
2377 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
2378 driver_name, lnw) != 0) {
2379 dev_dbg(&pdev->dev, "request interrupt %d failed\n", pdev->irq);
2380 ret = -EBUSY;
2381 goto error;
2382 }
2383
2384 /* enable OTG interrupts */
2385 langwell_otg_intr(1);
2386
2387 update_hsm();
2388
2389 langwell_update_transceiver();
2390
2391 return ret;
2392error:
2393 langwell_otg_intr(0);
2394 transceiver_suspend(pdev);
2395 return ret;
2396}
2397
2398static int __init langwell_otg_init(void)
2399{
2400 return pci_register_driver(&otg_pci_driver);
2401}
2402module_init(langwell_otg_init);
2403
2404static void __exit langwell_otg_cleanup(void)
2405{
2406 pci_unregister_driver(&otg_pci_driver);
2407}
2408module_exit(langwell_otg_cleanup);
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index ccc81950822b..059d9ac0ab5b 100644
--- a/drivers/usb/otg/ulpi.c
+++ b/drivers/usb/otg/ulpi.c
@@ -29,12 +29,23 @@
29#include <linux/usb/otg.h> 29#include <linux/usb/otg.h>
30#include <linux/usb/ulpi.h> 30#include <linux/usb/ulpi.h>
31 31
32
33struct ulpi_info {
34 unsigned int id;
35 char *name;
36};
37
32#define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) 38#define ULPI_ID(vendor, product) (((vendor) << 16) | (product))
39#define ULPI_INFO(_id, _name) \
40 { \
41 .id = (_id), \
42 .name = (_name), \
43 }
33 44
34/* ULPI hardcoded IDs, used for probing */ 45/* ULPI hardcoded IDs, used for probing */
35static unsigned int ulpi_ids[] = { 46static struct ulpi_info ulpi_ids[] = {
36 ULPI_ID(0x04cc, 0x1504), /* NXP ISP1504 */ 47 ULPI_INFO(ULPI_ID(0x04cc, 0x1504), "NXP ISP1504"),
37 ULPI_ID(0x0424, 0x0006), /* SMSC USB3319 */ 48 ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB3319"),
38}; 49};
39 50
40static int ulpi_set_otg_flags(struct otg_transceiver *otg) 51static int ulpi_set_otg_flags(struct otg_transceiver *otg)
@@ -137,6 +148,32 @@ static int ulpi_set_flags(struct otg_transceiver *otg)
137 return ulpi_set_fc_flags(otg); 148 return ulpi_set_fc_flags(otg);
138} 149}
139 150
151static int ulpi_check_integrity(struct otg_transceiver *otg)
152{
153 int ret, i;
154 unsigned int val = 0x55;
155
156 for (i = 0; i < 2; i++) {
157 ret = otg_io_write(otg, val, ULPI_SCRATCH);
158 if (ret < 0)
159 return ret;
160
161 ret = otg_io_read(otg, ULPI_SCRATCH);
162 if (ret < 0)
163 return ret;
164
165 if (ret != val) {
166 pr_err("ULPI integrity check: failed!");
167 return -ENODEV;
168 }
169 val = val << 1;
170 }
171
172 pr_info("ULPI integrity check: passed.\n");
173
174 return 0;
175}
176
140static int ulpi_init(struct otg_transceiver *otg) 177static int ulpi_init(struct otg_transceiver *otg)
141{ 178{
142 int i, vid, pid, ret; 179 int i, vid, pid, ret;
@@ -153,12 +190,19 @@ static int ulpi_init(struct otg_transceiver *otg)
153 190
154 pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); 191 pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid);
155 192
156 for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++) 193 for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++) {
157 if (ulpi_ids[i] == ULPI_ID(vid, pid)) 194 if (ulpi_ids[i].id == ULPI_ID(vid, pid)) {
158 return ulpi_set_flags(otg); 195 pr_info("Found %s ULPI transceiver.\n",
196 ulpi_ids[i].name);
197 break;
198 }
199 }
200
201 ret = ulpi_check_integrity(otg);
202 if (ret)
203 return ret;
159 204
160 pr_err("ULPI ID does not match any known transceiver.\n"); 205 return ulpi_set_flags(otg);
161 return -ENODEV;
162} 206}
163 207
164static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host) 208static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host)
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 916b2b6d765f..95058109f9fa 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -527,6 +527,15 @@ config USB_SERIAL_SAFE_PADDED
527 bool "USB Secure Encapsulated Driver - Padded" 527 bool "USB Secure Encapsulated Driver - Padded"
528 depends on USB_SERIAL_SAFE 528 depends on USB_SERIAL_SAFE
529 529
530config USB_SERIAL_SAMBA
531 tristate "USB Atmel SAM Boot Assistant (SAM-BA) driver"
532 help
533 Say Y here if you want to access the SAM-BA boot application of an
534 Atmel AT91SAM device.
535
536 To compile this driver as a module, choose M here: the
537 module will be called sam-ba.
538
530config USB_SERIAL_SIEMENS_MPI 539config USB_SERIAL_SIEMENS_MPI
531 tristate "USB Siemens MPI driver" 540 tristate "USB Siemens MPI driver"
532 help 541 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 40ebe17b6ea8..9a2117f2b06e 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -6,10 +6,10 @@
6 6
7obj-$(CONFIG_USB_SERIAL) += usbserial.o 7obj-$(CONFIG_USB_SERIAL) += usbserial.o
8 8
9usbserial-obj-$(CONFIG_USB_SERIAL_CONSOLE) += console.o 9usbserial-y := usb-serial.o generic.o bus.o
10usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
11 10
12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) 11usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o
12usbserial-$(CONFIG_USB_EZUSB) += ezusb.o
13 13
14obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o 14obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o
15obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o 15obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o
@@ -48,6 +48,7 @@ obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
48obj-$(CONFIG_USB_SERIAL_QCAUX) += qcaux.o 48obj-$(CONFIG_USB_SERIAL_QCAUX) += qcaux.o
49obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o 49obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o
50obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 50obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
51obj-$(CONFIG_USB_SERIAL_SAMBA) += sam-ba.o
51obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o 52obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o
52obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o 53obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
53obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o 54obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o
@@ -58,6 +59,5 @@ obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
58obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 59obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
59obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 60obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
60obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o 61obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o
61obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o 62obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o
62obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o 63obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o
63
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 4f1744c5871f..8d7731dbf478 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -54,6 +54,7 @@ static int cp210x_carrier_raised(struct usb_serial_port *p);
54static int debug; 54static int debug;
55 55
56static const struct usb_device_id id_table[] = { 56static const struct usb_device_id id_table[] = {
57 { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */
57 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */ 58 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
58 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 59 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
59 { USB_DEVICE(0x0489, 0xE003) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 60 { USB_DEVICE(0x0489, 0xE003) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
@@ -132,6 +133,7 @@ static const struct usb_device_id id_table[] = {
132 { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */ 133 { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
133 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ 134 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
134 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 135 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
136 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
135 { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ 137 { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
136 { } /* Terminating Entry */ 138 { } /* Terminating Entry */
137}; 139};
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 891c20e3bb38..37b57c785cc7 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -177,6 +177,7 @@ static struct usb_device_id id_table_combined [] = {
177 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_SNIFFER_PID) }, 177 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_SNIFFER_PID) },
178 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) }, 178 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
179 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) }, 179 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
180 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
180 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 181 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
181 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 182 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
182 { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) }, 183 { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) },
@@ -674,7 +675,6 @@ static struct usb_device_id id_table_combined [] = {
674 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) }, 675 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) },
675 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) }, 676 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) },
676 { USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) }, 677 { USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) },
677 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
678 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, 678 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
679 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) }, 679 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
680 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) }, 680 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
@@ -715,8 +715,37 @@ static struct usb_device_id id_table_combined [] = {
715 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 715 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
716 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, 716 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
717 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, 717 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
718
719 /* Papouch devices based on FTDI chip */
720 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_PID) },
721 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_PID) },
722 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_PID) },
723 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_2_PID) },
724 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_2_PID) },
725 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_2_PID) },
726 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485S_PID) },
727 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485C_PID) },
728 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_LEC_PID) },
729 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB232_PID) },
730 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
731 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_IRAMP_PID) },
732 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK5_PID) },
733 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO8x8_PID) },
718 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, 734 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
735 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x2_PID) },
736 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO10x1_PID) },
737 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO30x3_PID) },
738 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO60x3_PID) },
739 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x16_PID) },
740 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO3x32_PID) },
741 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK6_PID) },
742 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_UPSUSB_PID) },
743 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_MU_PID) },
744 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SIMUKEY_PID) },
719 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AD4USB_PID) }, 745 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AD4USB_PID) },
746 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMUX_PID) },
747 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMSR_PID) },
748
720 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) }, 749 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
721 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, 750 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
722 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) }, 751 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
@@ -751,6 +780,7 @@ static struct usb_device_id id_table_combined [] = {
751 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID), 780 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID),
752 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 781 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
753 { USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) }, 782 { USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) },
783 { USB_DEVICE(FTDI_VID, ACCESIO_COM4SM_PID) },
754 { USB_DEVICE(IONICS_VID, IONICS_PLUGCOMPUTER_PID), 784 { USB_DEVICE(IONICS_VID, IONICS_PLUGCOMPUTER_PID),
755 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 785 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
756 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_24_MASTER_WING_PID) }, 786 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_24_MASTER_WING_PID) },
@@ -761,6 +791,9 @@ static struct usb_device_id id_table_combined [] = {
761 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MAXI_WING_PID) }, 791 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MAXI_WING_PID) },
762 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MEDIA_WING_PID) }, 792 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MEDIA_WING_PID) },
763 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_WING_PID) }, 793 { USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_WING_PID) },
794 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LOGBOOKML_PID) },
795 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LS_LOGBOOK_PID) },
796 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_HS_LOGBOOK_PID) },
764 { }, /* Optional parameter entry */ 797 { }, /* Optional parameter entry */
765 { } /* Terminating entry */ 798 { } /* Terminating entry */
766}; 799};
@@ -1559,6 +1592,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1559 ftdi_set_max_packet_size(port); 1592 ftdi_set_max_packet_size(port);
1560 if (read_latency_timer(port) < 0) 1593 if (read_latency_timer(port) < 0)
1561 priv->latency = 16; 1594 priv->latency = 16;
1595 write_latency_timer(port);
1562 create_sysfs_attrs(port); 1596 create_sysfs_attrs(port);
1563 return 0; 1597 return 0;
1564} 1598}
@@ -1687,8 +1721,6 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1687 1721
1688 dbg("%s", __func__); 1722 dbg("%s", __func__);
1689 1723
1690 write_latency_timer(port);
1691
1692 /* No error checking for this (will get errors later anyway) */ 1724 /* No error checking for this (will get errors later anyway) */
1693 /* See ftdi_sio.h for description of what is reset */ 1725 /* See ftdi_sio.h for description of what is reset */
1694 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1726 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
@@ -2028,8 +2060,6 @@ static void ftdi_set_termios(struct tty_struct *tty,
2028 "urb failed to set to rts/cts flow control\n"); 2060 "urb failed to set to rts/cts flow control\n");
2029 } 2061 }
2030 2062
2031 /* raise DTR/RTS */
2032 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2033 } else { 2063 } else {
2034 /* 2064 /*
2035 * Xon/Xoff code 2065 * Xon/Xoff code
@@ -2077,8 +2107,6 @@ static void ftdi_set_termios(struct tty_struct *tty,
2077 } 2107 }
2078 } 2108 }
2079 2109
2080 /* lower DTR/RTS */
2081 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2082 } 2110 }
2083 return; 2111 return;
2084} 2112}
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 15a4583775ad..cf1aea1b9ee7 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -61,6 +61,7 @@
61#define FTDI_OPENDCC_SNIFFER_PID 0xBFD9 61#define FTDI_OPENDCC_SNIFFER_PID 0xBFD9
62#define FTDI_OPENDCC_THROTTLE_PID 0xBFDA 62#define FTDI_OPENDCC_THROTTLE_PID 0xBFDA
63#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB 63#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
64#define FTDI_OPENDCC_GBM_PID 0xBFDC
64 65
65/* 66/*
66 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com) 67 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
@@ -1022,9 +1023,34 @@
1022 */ 1023 */
1023 1024
1024#define PAPOUCH_VID 0x5050 /* Vendor ID */ 1025#define PAPOUCH_VID 0x5050 /* Vendor ID */
1026#define PAPOUCH_SB485_PID 0x0100 /* Papouch SB485 USB-485/422 Converter */
1027#define PAPOUCH_AP485_PID 0x0101 /* AP485 USB-RS485 Converter */
1028#define PAPOUCH_SB422_PID 0x0102 /* Papouch SB422 USB-RS422 Converter */
1029#define PAPOUCH_SB485_2_PID 0x0103 /* Papouch SB485 USB-485/422 Converter */
1030#define PAPOUCH_AP485_2_PID 0x0104 /* AP485 USB-RS485 Converter */
1031#define PAPOUCH_SB422_2_PID 0x0105 /* Papouch SB422 USB-RS422 Converter */
1032#define PAPOUCH_SB485S_PID 0x0106 /* Papouch SB485S USB-485/422 Converter */
1033#define PAPOUCH_SB485C_PID 0x0107 /* Papouch SB485C USB-485/422 Converter */
1034#define PAPOUCH_LEC_PID 0x0300 /* LEC USB Converter */
1035#define PAPOUCH_SB232_PID 0x0301 /* Papouch SB232 USB-RS232 Converter */
1025#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ 1036#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */
1026#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */ 1037#define PAPOUCH_IRAMP_PID 0x0500 /* Papouch IRAmp Duplex */
1038#define PAPOUCH_DRAK5_PID 0x0700 /* Papouch DRAK5 */
1039#define PAPOUCH_QUIDO8x8_PID 0x0800 /* Papouch Quido 8/8 Module */
1040#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Papouch Quido 4/4 Module */
1041#define PAPOUCH_QUIDO2x2_PID 0x0a00 /* Papouch Quido 2/2 Module */
1042#define PAPOUCH_QUIDO10x1_PID 0x0b00 /* Papouch Quido 10/1 Module */
1043#define PAPOUCH_QUIDO30x3_PID 0x0c00 /* Papouch Quido 30/3 Module */
1044#define PAPOUCH_QUIDO60x3_PID 0x0d00 /* Papouch Quido 60(100)/3 Module */
1045#define PAPOUCH_QUIDO2x16_PID 0x0e00 /* Papouch Quido 2/16 Module */
1046#define PAPOUCH_QUIDO3x32_PID 0x0f00 /* Papouch Quido 3/32 Module */
1047#define PAPOUCH_DRAK6_PID 0x1000 /* Papouch DRAK6 */
1048#define PAPOUCH_UPSUSB_PID 0x8000 /* Papouch UPS-USB adapter */
1049#define PAPOUCH_MU_PID 0x8001 /* MU controller */
1050#define PAPOUCH_SIMUKEY_PID 0x8002 /* Papouch SimuKey */
1027#define PAPOUCH_AD4USB_PID 0x8003 /* AD4USB Measurement Module */ 1051#define PAPOUCH_AD4USB_PID 0x8003 /* AD4USB Measurement Module */
1052#define PAPOUCH_GMUX_PID 0x8004 /* Papouch GOLIATH MUX */
1053#define PAPOUCH_GMSR_PID 0x8005 /* Papouch GOLIATH MSR */
1028 1054
1029/* 1055/*
1030 * Marvell SheevaPlug 1056 * Marvell SheevaPlug
@@ -1063,3 +1089,14 @@
1063 * Submitted by John G. Rogers 1089 * Submitted by John G. Rogers
1064 */ 1090 */
1065#define SEGWAY_RMP200_PID 0xe729 1091#define SEGWAY_RMP200_PID 0xe729
1092
1093
1094/*
1095 * Accesio USB Data Acquisition products (http://www.accesio.com/)
1096 */
1097#define ACCESIO_COM4SM_PID 0xD578
1098
1099/* www.sciencescope.co.uk educational dataloggers */
1100#define FTDI_SCIENCESCOPE_LOGBOOKML_PID 0xFF18
1101#define FTDI_SCIENCESCOPE_LS_LOGBOOK_PID 0xFF1C
1102#define FTDI_SCIENCESCOPE_HS_LOGBOOK_PID 0xFF1D
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 7aa01b95b1d4..2849f8c32015 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -549,9 +549,12 @@ static void mct_u232_close(struct usb_serial_port *port)
549{ 549{
550 dbg("%s port %d", __func__, port->number); 550 dbg("%s port %d", __func__, port->number);
551 551
552 usb_serial_generic_close(port); 552 if (port->serial->dev) {
553 if (port->serial->dev) 553 /* shutdown our urbs */
554 usb_kill_urb(port->write_urb);
555 usb_kill_urb(port->read_urb);
554 usb_kill_urb(port->interrupt_in_urb); 556 usb_kill_urb(port->interrupt_in_urb);
557 }
555} /* mct_u232_close */ 558} /* mct_u232_close */
556 559
557 560
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index ed01f3b2de8c..eda1f9266c4e 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -96,8 +96,8 @@ static void opticon_bulk_callback(struct urb *urb)
96 /* real data, send it to the tty layer */ 96 /* real data, send it to the tty layer */
97 tty = tty_port_tty_get(&port->port); 97 tty = tty_port_tty_get(&port->port);
98 if (tty) { 98 if (tty) {
99 tty_insert_flip_string(tty, data, 99 tty_insert_flip_string(tty, data + 2,
100 data_length); 100 data_length);
101 tty_flip_buffer_push(tty); 101 tty_flip_buffer_push(tty);
102 tty_kref_put(tty); 102 tty_kref_put(tty);
103 } 103 }
@@ -108,10 +108,10 @@ static void opticon_bulk_callback(struct urb *urb)
108 else 108 else
109 priv->rts = true; 109 priv->rts = true;
110 } else { 110 } else {
111 dev_dbg(&priv->udev->dev, 111 dev_dbg(&priv->udev->dev,
112 "Unknown data packet received from the device:" 112 "Unknown data packet received from the device:"
113 " %2x %2x\n", 113 " %2x %2x\n",
114 data[0], data[1]); 114 data[0], data[1]);
115 } 115 }
116 } 116 }
117 } else { 117 } else {
@@ -130,7 +130,7 @@ exit:
130 priv->bulk_address), 130 priv->bulk_address),
131 priv->bulk_in_buffer, priv->buffer_size, 131 priv->bulk_in_buffer, priv->buffer_size,
132 opticon_bulk_callback, priv); 132 opticon_bulk_callback, priv);
133 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 133 result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC);
134 if (result) 134 if (result)
135 dev_err(&port->dev, 135 dev_err(&port->dev,
136 "%s - failed resubmitting read urb, error %d\n", 136 "%s - failed resubmitting read urb, error %d\n",
@@ -187,6 +187,9 @@ static void opticon_write_bulk_callback(struct urb *urb)
187 /* free up the transfer buffer, as usb_free_urb() does not do this */ 187 /* free up the transfer buffer, as usb_free_urb() does not do this */
188 kfree(urb->transfer_buffer); 188 kfree(urb->transfer_buffer);
189 189
190 /* setup packet may be set if we're using it for writing */
191 kfree(urb->setup_packet);
192
190 if (status) 193 if (status)
191 dbg("%s - nonzero write bulk status received: %d", 194 dbg("%s - nonzero write bulk status received: %d",
192 __func__, status); 195 __func__, status);
@@ -237,10 +240,29 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
237 240
238 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); 241 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
239 242
240 usb_fill_bulk_urb(urb, serial->dev, 243 if (port->bulk_out_endpointAddress) {
241 usb_sndbulkpipe(serial->dev, 244 usb_fill_bulk_urb(urb, serial->dev,
242 port->bulk_out_endpointAddress), 245 usb_sndbulkpipe(serial->dev,
243 buffer, count, opticon_write_bulk_callback, priv); 246 port->bulk_out_endpointAddress),
247 buffer, count, opticon_write_bulk_callback, priv);
248 } else {
249 struct usb_ctrlrequest *dr;
250
251 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
252 if (!dr)
253 return -ENOMEM;
254
255 dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT;
256 dr->bRequest = 0x01;
257 dr->wValue = 0;
258 dr->wIndex = 0;
259 dr->wLength = cpu_to_le16(count);
260
261 usb_fill_control_urb(urb, serial->dev,
262 usb_sndctrlpipe(serial->dev, 0),
263 (unsigned char *)dr, buffer, count,
264 opticon_write_bulk_callback, priv);
265 }
244 266
245 /* send it down the pipe */ 267 /* send it down the pipe */
246 status = usb_submit_urb(urb, GFP_ATOMIC); 268 status = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index c46911af282f..2297fb1bcf65 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -392,6 +392,12 @@ static void option_instat_callback(struct urb *urb);
392#define CELOT_VENDOR_ID 0x211f 392#define CELOT_VENDOR_ID 0x211f
393#define CELOT_PRODUCT_CT680M 0x6801 393#define CELOT_PRODUCT_CT680M 0x6801
394 394
395/* ONDA Communication vendor id */
396#define ONDA_VENDOR_ID 0x1ee8
397
398/* ONDA MT825UP HSDPA 14.2 modem */
399#define ONDA_MT825UP 0x000b
400
395/* some devices interfaces need special handling due to a number of reasons */ 401/* some devices interfaces need special handling due to a number of reasons */
396enum option_blacklist_reason { 402enum option_blacklist_reason {
397 OPTION_BLACKLIST_NONE = 0, 403 OPTION_BLACKLIST_NONE = 0,
@@ -622,6 +628,7 @@ static const struct usb_device_id option_ids[] = {
622 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0011, 0xff, 0xff, 0xff) }, 628 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0011, 0xff, 0xff, 0xff) },
623 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0012, 0xff, 0xff, 0xff) }, 629 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0012, 0xff, 0xff, 0xff) },
624 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0013, 0xff, 0xff, 0xff) }, 630 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0013, 0xff, 0xff, 0xff) },
631 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) },
625 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628, 0xff, 0xff, 0xff) }, 632 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628, 0xff, 0xff, 0xff) },
626 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0016, 0xff, 0xff, 0xff) }, 633 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0016, 0xff, 0xff, 0xff) },
627 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff) }, 634 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff) },
@@ -633,38 +640,52 @@ static const struct usb_device_id option_ids[] = {
633 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0023, 0xff, 0xff, 0xff) }, 640 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0023, 0xff, 0xff, 0xff) },
634 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0024, 0xff, 0xff, 0xff) }, 641 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0024, 0xff, 0xff, 0xff) },
635 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0025, 0xff, 0xff, 0xff) }, 642 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0025, 0xff, 0xff, 0xff) },
636 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0026, 0xff, 0xff, 0xff) }, 643 /* { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0026, 0xff, 0xff, 0xff) }, */
637 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0028, 0xff, 0xff, 0xff) }, 644 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0028, 0xff, 0xff, 0xff) },
638 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0029, 0xff, 0xff, 0xff) }, 645 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0029, 0xff, 0xff, 0xff) },
639 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0030, 0xff, 0xff, 0xff) }, 646 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0030, 0xff, 0xff, 0xff) },
640 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626, 0xff, 0xff, 0xff) }, 647 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626, 0xff, 0xff, 0xff) },
641 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0032, 0xff, 0xff, 0xff) }, 648 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0032, 0xff, 0xff, 0xff) },
642 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0033, 0xff, 0xff, 0xff) }, 649 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0033, 0xff, 0xff, 0xff) },
650 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0034, 0xff, 0xff, 0xff) },
643 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0037, 0xff, 0xff, 0xff) }, 651 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0037, 0xff, 0xff, 0xff) },
652 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0038, 0xff, 0xff, 0xff) },
644 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0039, 0xff, 0xff, 0xff) }, 653 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0039, 0xff, 0xff, 0xff) },
654 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0040, 0xff, 0xff, 0xff) },
645 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0042, 0xff, 0xff, 0xff) }, 655 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0042, 0xff, 0xff, 0xff) },
646 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0043, 0xff, 0xff, 0xff) }, 656 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0043, 0xff, 0xff, 0xff) },
657 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0044, 0xff, 0xff, 0xff) },
647 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0048, 0xff, 0xff, 0xff) }, 658 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0048, 0xff, 0xff, 0xff) },
648 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0049, 0xff, 0xff, 0xff) }, 659 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0049, 0xff, 0xff, 0xff) },
660 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0050, 0xff, 0xff, 0xff) },
649 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0051, 0xff, 0xff, 0xff) }, 661 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0051, 0xff, 0xff, 0xff) },
650 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0052, 0xff, 0xff, 0xff) }, 662 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0052, 0xff, 0xff, 0xff) },
663 /* { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0053, 0xff, 0xff, 0xff) }, */
651 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0054, 0xff, 0xff, 0xff) }, 664 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0054, 0xff, 0xff, 0xff) },
652 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0055, 0xff, 0xff, 0xff) }, 665 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0055, 0xff, 0xff, 0xff) },
666 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0056, 0xff, 0xff, 0xff) },
653 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0057, 0xff, 0xff, 0xff) }, 667 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0057, 0xff, 0xff, 0xff) },
654 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0058, 0xff, 0xff, 0xff) }, 668 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0058, 0xff, 0xff, 0xff) },
669 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) },
655 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0061, 0xff, 0xff, 0xff) }, 670 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0061, 0xff, 0xff, 0xff) },
656 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0062, 0xff, 0xff, 0xff) }, 671 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0062, 0xff, 0xff, 0xff) },
657 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0063, 0xff, 0xff, 0xff) }, 672 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0063, 0xff, 0xff, 0xff) },
658 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0064, 0xff, 0xff, 0xff) }, 673 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0064, 0xff, 0xff, 0xff) },
674 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0065, 0xff, 0xff, 0xff) },
659 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0066, 0xff, 0xff, 0xff) }, 675 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0066, 0xff, 0xff, 0xff) },
676 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0067, 0xff, 0xff, 0xff) },
660 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0069, 0xff, 0xff, 0xff) }, 677 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0069, 0xff, 0xff, 0xff) },
678 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
661 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0076, 0xff, 0xff, 0xff) }, 679 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0076, 0xff, 0xff, 0xff) },
680 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0077, 0xff, 0xff, 0xff) },
662 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0078, 0xff, 0xff, 0xff) }, 681 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0078, 0xff, 0xff, 0xff) },
682 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0079, 0xff, 0xff, 0xff) },
663 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0082, 0xff, 0xff, 0xff) }, 683 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0082, 0xff, 0xff, 0xff) },
684 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0083, 0xff, 0xff, 0xff) },
664 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0086, 0xff, 0xff, 0xff) }, 685 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0086, 0xff, 0xff, 0xff) },
665 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 0xff, 0xff) }, 686 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0087, 0xff, 0xff, 0xff) },
666 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
667 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff) }, 687 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff) },
688 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0105, 0xff, 0xff, 0xff) },
668 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0106, 0xff, 0xff, 0xff) }, 689 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0106, 0xff, 0xff, 0xff) },
669 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0108, 0xff, 0xff, 0xff) }, 690 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0108, 0xff, 0xff, 0xff) },
670 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff) }, 691 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff) },
@@ -880,6 +901,8 @@ static const struct usb_device_id option_ids[] = {
880 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, 901 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
881 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) }, 902 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) },
882 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) }, 903 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) },
904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 0xff, 0xff) },
905 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
883 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, 906 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
884 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, 907 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
885 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 908 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
@@ -925,6 +948,7 @@ static const struct usb_device_id option_ids[] = {
925 { USB_DEVICE(CINTERION_VENDOR_ID, 0x0047) }, 948 { USB_DEVICE(CINTERION_VENDOR_ID, 0x0047) },
926 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, 949 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
927 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ 950 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
951 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
928 { } /* Terminating entry */ 952 { } /* Terminating entry */
929}; 953};
930MODULE_DEVICE_TABLE(usb, option_ids); 954MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index cde67cacb2c3..8858201eb1d3 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -118,6 +118,8 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
118 118
119 spin_lock_init(&data->susp_lock); 119 spin_lock_init(&data->susp_lock);
120 120
121 usb_enable_autosuspend(serial->dev);
122
121 switch (nintf) { 123 switch (nintf) {
122 case 1: 124 case 1:
123 /* QDL mode */ 125 /* QDL mode */
@@ -150,7 +152,22 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
150 case 3: 152 case 3:
151 case 4: 153 case 4:
152 /* Composite mode */ 154 /* Composite mode */
153 if (ifnum == 2) { 155 /* ifnum == 0 is a broadband network adapter */
156 if (ifnum == 1) {
157 /*
158 * Diagnostics Monitor (serial line 9600 8N1)
159 * Qualcomm DM protocol
160 * use "libqcdm" (ModemManager) for communication
161 */
162 dbg("Diagnostics Monitor found");
163 retval = usb_set_interface(serial->dev, ifnum, 0);
164 if (retval < 0) {
165 dev_err(&serial->dev->dev,
166 "Could not set interface, error %d\n",
167 retval);
168 retval = -ENODEV;
169 }
170 } else if (ifnum == 2) {
154 dbg("Modem port found"); 171 dbg("Modem port found");
155 retval = usb_set_interface(serial->dev, ifnum, 0); 172 retval = usb_set_interface(serial->dev, ifnum, 0);
156 if (retval < 0) { 173 if (retval < 0) {
@@ -161,6 +178,20 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
161 kfree(data); 178 kfree(data);
162 } 179 }
163 return retval; 180 return retval;
181 } else if (ifnum==3) {
182 /*
183 * NMEA (serial line 9600 8N1)
184 * # echo "\$GPS_START" > /dev/ttyUSBx
185 * # echo "\$GPS_STOP" > /dev/ttyUSBx
186 */
187 dbg("NMEA GPS interface found");
188 retval = usb_set_interface(serial->dev, ifnum, 0);
189 if (retval < 0) {
190 dev_err(&serial->dev->dev,
191 "Could not set interface, error %d\n",
192 retval);
193 retval = -ENODEV;
194 }
164 } 195 }
165 break; 196 break;
166 197
diff --git a/drivers/usb/serial/sam-ba.c b/drivers/usb/serial/sam-ba.c
new file mode 100644
index 000000000000..e3bba64afc57
--- /dev/null
+++ b/drivers/usb/serial/sam-ba.c
@@ -0,0 +1,206 @@
1/*
2 * Atmel SAM Boot Assistant (SAM-BA) driver
3 *
4 * Copyright (C) 2010 Johan Hovold <jhovold@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/tty.h>
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/usb.h>
16#include <linux/usb/serial.h>
17
18
19#define DRIVER_VERSION "v1.0"
20#define DRIVER_AUTHOR "Johan Hovold <jhovold@gmail.com>"
21#define DRIVER_DESC "Atmel SAM Boot Assistant (SAM-BA) driver"
22
23#define SAMBA_VENDOR_ID 0x3eb
24#define SAMBA_PRODUCT_ID 0x6124
25
26
27static int debug;
28
29static const struct usb_device_id id_table[] = {
30 /*
31 * NOTE: Only match the CDC Data interface.
32 */
33 { USB_DEVICE_AND_INTERFACE_INFO(SAMBA_VENDOR_ID, SAMBA_PRODUCT_ID,
34 USB_CLASS_CDC_DATA, 0, 0) },
35 { }
36};
37MODULE_DEVICE_TABLE(usb, id_table);
38
39static struct usb_driver samba_driver = {
40 .name = "sam-ba",
41 .probe = usb_serial_probe,
42 .disconnect = usb_serial_disconnect,
43 .id_table = id_table,
44 .no_dynamic_id = 1,
45};
46
47
48/*
49 * NOTE: The SAM-BA firmware cannot handle merged write requests so we cannot
50 * use the generic write implementation (which uses the port write fifo).
51 */
52static int samba_write(struct tty_struct *tty, struct usb_serial_port *port,
53 const unsigned char *buf, int count)
54{
55 struct urb *urb;
56 unsigned long flags;
57 int result;
58 int i;
59
60 if (!count)
61 return 0;
62
63 count = min_t(int, count, port->bulk_out_size);
64
65 spin_lock_irqsave(&port->lock, flags);
66 if (!port->write_urbs_free) {
67 spin_unlock_irqrestore(&port->lock, flags);
68 return 0;
69 }
70 i = find_first_bit(&port->write_urbs_free,
71 ARRAY_SIZE(port->write_urbs));
72 __clear_bit(i, &port->write_urbs_free);
73 port->tx_bytes += count;
74 spin_unlock_irqrestore(&port->lock, flags);
75
76 urb = port->write_urbs[i];
77 memcpy(urb->transfer_buffer, buf, count);
78 urb->transfer_buffer_length = count;
79 usb_serial_debug_data(debug, &port->dev, __func__, count,
80 urb->transfer_buffer);
81 result = usb_submit_urb(urb, GFP_ATOMIC);
82 if (result) {
83 dev_err(&port->dev, "%s - error submitting urb: %d\n",
84 __func__, result);
85 spin_lock_irqsave(&port->lock, flags);
86 __set_bit(i, &port->write_urbs_free);
87 port->tx_bytes -= count;
88 spin_unlock_irqrestore(&port->lock, flags);
89
90 return result;
91 }
92
93 return count;
94}
95
96static int samba_write_room(struct tty_struct *tty)
97{
98 struct usb_serial_port *port = tty->driver_data;
99 unsigned long flags;
100 unsigned long free;
101 int count;
102 int room;
103
104 spin_lock_irqsave(&port->lock, flags);
105 free = port->write_urbs_free;
106 spin_unlock_irqrestore(&port->lock, flags);
107
108 count = hweight_long(free);
109 room = count * port->bulk_out_size;
110
111 dbg("%s - returns %d", __func__, room);
112
113 return room;
114}
115
116static int samba_chars_in_buffer(struct tty_struct *tty)
117{
118 struct usb_serial_port *port = tty->driver_data;
119 unsigned long flags;
120 int chars;
121
122 spin_lock_irqsave(&port->lock, flags);
123 chars = port->tx_bytes;
124 spin_unlock_irqrestore(&port->lock, flags);
125
126 dbg("%s - returns %d", __func__, chars);
127
128 return chars;
129}
130
131static void samba_write_bulk_callback(struct urb *urb)
132{
133 struct usb_serial_port *port = urb->context;
134 unsigned long flags;
135 int i;
136
137 dbg("%s - port %d", __func__, port->number);
138
139 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) {
140 if (port->write_urbs[i] == urb)
141 break;
142 }
143 spin_lock_irqsave(&port->lock, flags);
144 __set_bit(i, &port->write_urbs_free);
145 port->tx_bytes -= urb->transfer_buffer_length;
146 spin_unlock_irqrestore(&port->lock, flags);
147
148 if (urb->status)
149 dbg("%s - non-zero urb status: %d", __func__, urb->status);
150
151 usb_serial_port_softint(port);
152}
153
154static struct usb_serial_driver samba_device = {
155 .driver = {
156 .owner = THIS_MODULE,
157 .name = "sam-ba",
158 },
159 .usb_driver = &samba_driver,
160 .id_table = id_table,
161 .num_ports = 1,
162 .bulk_in_size = 512,
163 .bulk_out_size = 2048,
164 .write = samba_write,
165 .write_room = samba_write_room,
166 .chars_in_buffer = samba_chars_in_buffer,
167 .write_bulk_callback = samba_write_bulk_callback,
168 .throttle = usb_serial_generic_throttle,
169 .unthrottle = usb_serial_generic_unthrottle,
170};
171
172static int __init samba_init(void)
173{
174 int retval;
175
176 retval = usb_serial_register(&samba_device);
177 if (retval)
178 return retval;
179
180 retval = usb_register(&samba_driver);
181 if (retval) {
182 usb_serial_deregister(&samba_device);
183 return retval;
184 }
185
186 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ": "
187 DRIVER_DESC "\n");
188 return 0;
189}
190
191static void __exit samba_exit(void)
192{
193 usb_deregister(&samba_driver);
194 usb_serial_deregister(&samba_device);
195}
196
197module_init(samba_init);
198module_exit(samba_exit);
199
200MODULE_AUTHOR(DRIVER_AUTHOR);
201MODULE_DESCRIPTION(DRIVER_DESC);
202MODULE_VERSION(DRIVER_VERSION);
203MODULE_LICENSE("GPL");
204
205module_param(debug, bool, S_IRUGO | S_IWUSR);
206MODULE_PARM_DESC(debug, "Enable verbose debugging messages");
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index eb76aaef4268..15a5d89b7f39 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -606,6 +606,10 @@ static int treo_attach(struct usb_serial *serial)
606 606
607static int clie_5_attach(struct usb_serial *serial) 607static int clie_5_attach(struct usb_serial *serial)
608{ 608{
609 struct usb_serial_port *port;
610 unsigned int pipe;
611 int j;
612
609 dbg("%s", __func__); 613 dbg("%s", __func__);
610 614
611 /* TH55 registers 2 ports. 615 /* TH55 registers 2 ports.
@@ -621,9 +625,14 @@ static int clie_5_attach(struct usb_serial *serial)
621 return -1; 625 return -1;
622 626
623 /* port 0 now uses the modified endpoint Address */ 627 /* port 0 now uses the modified endpoint Address */
624 serial->port[0]->bulk_out_endpointAddress = 628 port = serial->port[0];
629 port->bulk_out_endpointAddress =
625 serial->port[1]->bulk_out_endpointAddress; 630 serial->port[1]->bulk_out_endpointAddress;
626 631
632 pipe = usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress);
633 for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j)
634 port->write_urbs[j]->pipe = pipe;
635
627 return 0; 636 return 0;
628} 637}
629 638
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 8a372bac0e43..f2767cf2e229 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -172,6 +172,19 @@ config USB_STORAGE_CYPRESS_ATACB
172 172
173 If this driver is compiled as a module, it will be named ums-cypress. 173 If this driver is compiled as a module, it will be named ums-cypress.
174 174
175config USB_UAS
176 tristate "USB Attached SCSI"
177 depends on USB && SCSI
178 help
179 The USB Attached SCSI protocol is supported by some USB
180 storage devices. It permits higher performance by supporting
181 multiple outstanding commands.
182
183 If you don't know whether you have a UAS device, it is safe to
184 say 'Y' or 'M' here and the kernel will use the right driver.
185
186 If you compile this driver as a module, it will be named uas.
187
175config USB_LIBUSUAL 188config USB_LIBUSUAL
176 bool "The shared table of common (or usual) storage devices" 189 bool "The shared table of common (or usual) storage devices"
177 depends on USB 190 depends on USB
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index ef7e5a8ceab5..fcf14cdc4a04 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -5,20 +5,21 @@
5# Rewritten to use lists instead of if-statements. 5# Rewritten to use lists instead of if-statements.
6# 6#
7 7
8EXTRA_CFLAGS := -Idrivers/scsi 8ccflags-y := -Idrivers/scsi
9 9
10obj-$(CONFIG_USB_UAS) += uas.o
10obj-$(CONFIG_USB_STORAGE) += usb-storage.o 11obj-$(CONFIG_USB_STORAGE) += usb-storage.o
11 12
12usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG) += debug.o 13usb-storage-y := scsiglue.o protocol.o transport.o usb.o
14usb-storage-y += initializers.o sierra_ms.o option_ms.o
13 15
14usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 16usb-storage-$(CONFIG_USB_STORAGE_DEBUG) += debug.o
15 initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y)
16 17
17ifeq ($(CONFIG_USB_LIBUSUAL),) 18ifeq ($(CONFIG_USB_LIBUSUAL),)
18 usb-storage-objs += usual-tables.o 19 usb-storage-y += usual-tables.o
19else 20else
20 obj-$(CONFIG_USB) += usb-libusual.o 21 obj-$(CONFIG_USB) += usb-libusual.o
21 usb-libusual-objs := libusual.o usual-tables.o 22 usb-libusual-y := libusual.o usual-tables.o
22endif 23endif
23 24
24obj-$(CONFIG_USB_STORAGE_ALAUDA) += ums-alauda.o 25obj-$(CONFIG_USB_STORAGE_ALAUDA) += ums-alauda.o
@@ -33,14 +34,14 @@ obj-$(CONFIG_USB_STORAGE_SDDR09) += ums-sddr09.o
33obj-$(CONFIG_USB_STORAGE_SDDR55) += ums-sddr55.o 34obj-$(CONFIG_USB_STORAGE_SDDR55) += ums-sddr55.o
34obj-$(CONFIG_USB_STORAGE_USBAT) += ums-usbat.o 35obj-$(CONFIG_USB_STORAGE_USBAT) += ums-usbat.o
35 36
36ums-alauda-objs := alauda.o 37ums-alauda-y := alauda.o
37ums-cypress-objs := cypress_atacb.o 38ums-cypress-y := cypress_atacb.o
38ums-datafab-objs := datafab.o 39ums-datafab-y := datafab.o
39ums-freecom-objs := freecom.o 40ums-freecom-y := freecom.o
40ums-isd200-objs := isd200.o 41ums-isd200-y := isd200.o
41ums-jumpshot-objs := jumpshot.o 42ums-jumpshot-y := jumpshot.o
42ums-karma-objs := karma.o 43ums-karma-y := karma.o
43ums-onetouch-objs := onetouch.o 44ums-onetouch-y := onetouch.o
44ums-sddr09-objs := sddr09.o 45ums-sddr09-y := sddr09.o
45ums-sddr55-objs := sddr55.o 46ums-sddr55-y := sddr55.o
46ums-usbat-objs := shuttle_usbat.o 47ums-usbat-y := shuttle_usbat.o
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index d8d98cfecada..a688b1e686ea 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -113,7 +113,7 @@ static int slave_alloc (struct scsi_device *sdev)
113 * Let the scanning code know if this target merely sets 113 * Let the scanning code know if this target merely sets
114 * Peripheral Device Type to 0x1f to indicate no LUN. 114 * Peripheral Device Type to 0x1f to indicate no LUN.
115 */ 115 */
116 if (us->subclass == US_SC_UFI) 116 if (us->subclass == USB_SC_UFI)
117 sdev->sdev_target->pdt_1f_for_no_lun = 1; 117 sdev->sdev_target->pdt_1f_for_no_lun = 1;
118 118
119 return 0; 119 return 0;
@@ -176,7 +176,7 @@ static int slave_configure(struct scsi_device *sdev)
176 /* Disk-type devices use MODE SENSE(6) if the protocol 176 /* Disk-type devices use MODE SENSE(6) if the protocol
177 * (SubClass) is Transparent SCSI, otherwise they use 177 * (SubClass) is Transparent SCSI, otherwise they use
178 * MODE SENSE(10). */ 178 * MODE SENSE(10). */
179 if (us->subclass != US_SC_SCSI && us->subclass != US_SC_CYP_ATACB) 179 if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB)
180 sdev->use_10_for_ms = 1; 180 sdev->use_10_for_ms = 1;
181 181
182 /* Many disks only accept MODE SENSE transfer lengths of 182 /* Many disks only accept MODE SENSE transfer lengths of
@@ -209,6 +209,10 @@ static int slave_configure(struct scsi_device *sdev)
209 if (us->fflags & US_FL_CAPACITY_HEURISTICS) 209 if (us->fflags & US_FL_CAPACITY_HEURISTICS)
210 sdev->guess_capacity = 1; 210 sdev->guess_capacity = 1;
211 211
212 /* Some devices cannot handle READ_CAPACITY_16 */
213 if (us->fflags & US_FL_NO_READ_CAPACITY_16)
214 sdev->no_read_capacity_16 = 1;
215
212 /* assume SPC3 or latter devices support sense size > 18 */ 216 /* assume SPC3 or latter devices support sense size > 18 */
213 if (sdev->scsi_level > SCSI_SPC_2) 217 if (sdev->scsi_level > SCSI_SPC_2)
214 us->fflags |= US_FL_SANE_SENSE; 218 us->fflags |= US_FL_SANE_SENSE;
@@ -245,7 +249,7 @@ static int slave_configure(struct scsi_device *sdev)
245 * capacity will be decremented or is correct. */ 249 * capacity will be decremented or is correct. */
246 if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK | 250 if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK |
247 US_FL_SCM_MULT_TARG)) && 251 US_FL_SCM_MULT_TARG)) &&
248 us->protocol == US_PR_BULK) 252 us->protocol == USB_PR_BULK)
249 us->use_last_sector_hacks = 1; 253 us->use_last_sector_hacks = 1;
250 } else { 254 } else {
251 255
@@ -253,6 +257,10 @@ static int slave_configure(struct scsi_device *sdev)
253 * or to force 192-byte transfer lengths for MODE SENSE. 257 * or to force 192-byte transfer lengths for MODE SENSE.
254 * But they do need to use MODE SENSE(10). */ 258 * But they do need to use MODE SENSE(10). */
255 sdev->use_10_for_ms = 1; 259 sdev->use_10_for_ms = 1;
260
261 /* Some (fake) usb cdrom devices don't like READ_DISC_INFO */
262 if (us->fflags & US_FL_NO_READ_DISC_INFO)
263 sdev->no_read_disc_info = 1;
256 } 264 }
257 265
258 /* The CB and CBI transports have no way to pass LUN values 266 /* The CB and CBI transports have no way to pass LUN values
@@ -261,7 +269,7 @@ static int slave_configure(struct scsi_device *sdev)
261 * scsi_level == 0 (UNKNOWN). Hence such devices must necessarily 269 * scsi_level == 0 (UNKNOWN). Hence such devices must necessarily
262 * be single-LUN. 270 * be single-LUN.
263 */ 271 */
264 if ((us->protocol == US_PR_CB || us->protocol == US_PR_CBI) && 272 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_CBI) &&
265 sdev->scsi_level == SCSI_UNKNOWN) 273 sdev->scsi_level == SCSI_UNKNOWN)
266 us->max_lun = 0; 274 us->max_lun = 0;
267 275
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index ab5f9f37575a..bcb9a709d349 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -1760,7 +1760,7 @@ static int sddr09_probe(struct usb_interface *intf,
1760 if (result) 1760 if (result)
1761 return result; 1761 return result;
1762 1762
1763 if (us->protocol == US_PR_DPCM_USB) { 1763 if (us->protocol == USB_PR_DPCM_USB) {
1764 us->transport_name = "Control/Bulk-EUSB/SDDR09"; 1764 us->transport_name = "Control/Bulk-EUSB/SDDR09";
1765 us->transport = dpcm_transport; 1765 us->transport = dpcm_transport;
1766 us->transport_reset = usb_stor_CB_reset; 1766 us->transport_reset = usb_stor_CB_reset;
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 64ec073e89de..00418995d8e9 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -642,7 +642,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
642 * unless the operation involved a data-in transfer. Devices 642 * unless the operation involved a data-in transfer. Devices
643 * can signal most data-in errors by stalling the bulk-in pipe. 643 * can signal most data-in errors by stalling the bulk-in pipe.
644 */ 644 */
645 if ((us->protocol == US_PR_CB || us->protocol == US_PR_DPCM_USB) && 645 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) &&
646 srb->sc_data_direction != DMA_FROM_DEVICE) { 646 srb->sc_data_direction != DMA_FROM_DEVICE) {
647 US_DEBUGP("-- CB transport device requiring auto-sense\n"); 647 US_DEBUGP("-- CB transport device requiring auto-sense\n");
648 need_auto_sense = 1; 648 need_auto_sense = 1;
@@ -701,8 +701,8 @@ Retry_Sense:
701 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size); 701 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
702 702
703 /* FIXME: we must do the protocol translation here */ 703 /* FIXME: we must do the protocol translation here */
704 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI || 704 if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
705 us->subclass == US_SC_CYP_ATACB) 705 us->subclass == USB_SC_CYP_ATACB)
706 srb->cmd_len = 6; 706 srb->cmd_len = 6;
707 else 707 else
708 srb->cmd_len = 12; 708 srb->cmd_len = 12;
@@ -926,7 +926,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
926 /* NOTE: CB does not have a status stage. Silly, I know. So 926 /* NOTE: CB does not have a status stage. Silly, I know. So
927 * we have to catch this at a higher level. 927 * we have to catch this at a higher level.
928 */ 928 */
929 if (us->protocol != US_PR_CBI) 929 if (us->protocol != USB_PR_CBI)
930 return USB_STOR_TRANSPORT_GOOD; 930 return USB_STOR_TRANSPORT_GOOD;
931 931
932 result = usb_stor_intr_transfer(us, us->iobuf, 2); 932 result = usb_stor_intr_transfer(us, us->iobuf, 2);
@@ -942,7 +942,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
942 * that this means we could be ignoring a real error on these 942 * that this means we could be ignoring a real error on these
943 * commands, but that can't be helped. 943 * commands, but that can't be helped.
944 */ 944 */
945 if (us->subclass == US_SC_UFI) { 945 if (us->subclass == USB_SC_UFI) {
946 if (srb->cmnd[0] == REQUEST_SENSE || 946 if (srb->cmnd[0] == REQUEST_SENSE ||
947 srb->cmnd[0] == INQUIRY) 947 srb->cmnd[0] == INQUIRY)
948 return USB_STOR_TRANSPORT_GOOD; 948 return USB_STOR_TRANSPORT_GOOD;
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
new file mode 100644
index 000000000000..2054b1e25a65
--- /dev/null
+++ b/drivers/usb/storage/uas.c
@@ -0,0 +1,751 @@
1/*
2 * USB Attached SCSI
3 * Note that this is not the same as the USB Mass Storage driver
4 *
5 * Copyright Matthew Wilcox for Intel Corp, 2010
6 * Copyright Sarah Sharp for Intel Corp, 2010
7 *
8 * Distributed under the terms of the GNU GPL, version two.
9 */
10
11#include <linux/blkdev.h>
12#include <linux/slab.h>
13#include <linux/types.h>
14#include <linux/usb.h>
15#include <linux/usb/storage.h>
16
17#include <scsi/scsi.h>
18#include <scsi/scsi_dbg.h>
19#include <scsi/scsi_cmnd.h>
20#include <scsi/scsi_device.h>
21#include <scsi/scsi_host.h>
22#include <scsi/scsi_tcq.h>
23
24/* Common header for all IUs */
25struct iu {
26 __u8 iu_id;
27 __u8 rsvd1;
28 __be16 tag;
29};
30
31enum {
32 IU_ID_COMMAND = 0x01,
33 IU_ID_STATUS = 0x03,
34 IU_ID_RESPONSE = 0x04,
35 IU_ID_TASK_MGMT = 0x05,
36 IU_ID_READ_READY = 0x06,
37 IU_ID_WRITE_READY = 0x07,
38};
39
40struct command_iu {
41 __u8 iu_id;
42 __u8 rsvd1;
43 __be16 tag;
44 __u8 prio_attr;
45 __u8 rsvd5;
46 __u8 len;
47 __u8 rsvd7;
48 struct scsi_lun lun;
49 __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */
50};
51
52struct sense_iu {
53 __u8 iu_id;
54 __u8 rsvd1;
55 __be16 tag;
56 __be16 status_qual;
57 __u8 status;
58 __u8 service_response;
59 __u8 rsvd8[6];
60 __be16 len;
61 __u8 sense[SCSI_SENSE_BUFFERSIZE];
62};
63
64/*
65 * The r00-r01c specs define this version of the SENSE IU data structure.
66 * It's still in use by several different firmware releases.
67 */
68struct sense_iu_old {
69 __u8 iu_id;
70 __u8 rsvd1;
71 __be16 tag;
72 __be16 len;
73 __u8 status;
74 __u8 service_response;
75 __u8 sense[SCSI_SENSE_BUFFERSIZE];
76};
77
78enum {
79 CMD_PIPE_ID = 1,
80 STATUS_PIPE_ID = 2,
81 DATA_IN_PIPE_ID = 3,
82 DATA_OUT_PIPE_ID = 4,
83
84 UAS_SIMPLE_TAG = 0,
85 UAS_HEAD_TAG = 1,
86 UAS_ORDERED_TAG = 2,
87 UAS_ACA = 4,
88};
89
90struct uas_dev_info {
91 struct usb_interface *intf;
92 struct usb_device *udev;
93 int qdepth;
94 unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe;
95 unsigned use_streams:1;
96 unsigned uas_sense_old:1;
97};
98
99enum {
100 ALLOC_SENSE_URB = (1 << 0),
101 SUBMIT_SENSE_URB = (1 << 1),
102 ALLOC_DATA_IN_URB = (1 << 2),
103 SUBMIT_DATA_IN_URB = (1 << 3),
104 ALLOC_DATA_OUT_URB = (1 << 4),
105 SUBMIT_DATA_OUT_URB = (1 << 5),
106 ALLOC_CMD_URB = (1 << 6),
107 SUBMIT_CMD_URB = (1 << 7),
108};
109
110/* Overrides scsi_pointer */
111struct uas_cmd_info {
112 unsigned int state;
113 unsigned int stream;
114 struct urb *cmd_urb;
115 struct urb *sense_urb;
116 struct urb *data_in_urb;
117 struct urb *data_out_urb;
118 struct list_head list;
119};
120
121/* I hate forward declarations, but I actually have a loop */
122static int uas_submit_urbs(struct scsi_cmnd *cmnd,
123 struct uas_dev_info *devinfo, gfp_t gfp);
124
125static DEFINE_SPINLOCK(uas_work_lock);
126static LIST_HEAD(uas_work_list);
127
128static void uas_do_work(struct work_struct *work)
129{
130 struct uas_cmd_info *cmdinfo;
131 struct list_head list;
132
133 spin_lock_irq(&uas_work_lock);
134 list_replace_init(&uas_work_list, &list);
135 spin_unlock_irq(&uas_work_lock);
136
137 list_for_each_entry(cmdinfo, &list, list) {
138 struct scsi_pointer *scp = (void *)cmdinfo;
139 struct scsi_cmnd *cmnd = container_of(scp,
140 struct scsi_cmnd, SCp);
141 uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_KERNEL);
142 }
143}
144
145static DECLARE_WORK(uas_work, uas_do_work);
146
147static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
148{
149 struct sense_iu *sense_iu = urb->transfer_buffer;
150 struct scsi_device *sdev = cmnd->device;
151
152 if (urb->actual_length > 16) {
153 unsigned len = be16_to_cpup(&sense_iu->len);
154 if (len + 16 != urb->actual_length) {
155 int newlen = min(len + 16, urb->actual_length) - 16;
156 if (newlen < 0)
157 newlen = 0;
158 sdev_printk(KERN_INFO, sdev, "%s: urb length %d "
159 "disagrees with IU sense data length %d, "
160 "using %d bytes of sense data\n", __func__,
161 urb->actual_length, len, newlen);
162 len = newlen;
163 }
164 memcpy(cmnd->sense_buffer, sense_iu->sense, len);
165 }
166
167 cmnd->result = sense_iu->status;
168 if (sdev->current_cmnd)
169 sdev->current_cmnd = NULL;
170 cmnd->scsi_done(cmnd);
171 usb_free_urb(urb);
172}
173
174static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd)
175{
176 struct sense_iu_old *sense_iu = urb->transfer_buffer;
177 struct scsi_device *sdev = cmnd->device;
178
179 if (urb->actual_length > 8) {
180 unsigned len = be16_to_cpup(&sense_iu->len) - 2;
181 if (len + 8 != urb->actual_length) {
182 int newlen = min(len + 8, urb->actual_length) - 8;
183 if (newlen < 0)
184 newlen = 0;
185 sdev_printk(KERN_INFO, sdev, "%s: urb length %d "
186 "disagrees with IU sense data length %d, "
187 "using %d bytes of sense data\n", __func__,
188 urb->actual_length, len, newlen);
189 len = newlen;
190 }
191 memcpy(cmnd->sense_buffer, sense_iu->sense, len);
192 }
193
194 cmnd->result = sense_iu->status;
195 if (sdev->current_cmnd)
196 sdev->current_cmnd = NULL;
197 cmnd->scsi_done(cmnd);
198 usb_free_urb(urb);
199}
200
201static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd,
202 unsigned direction)
203{
204 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
205 int err;
206
207 cmdinfo->state = direction | SUBMIT_SENSE_URB;
208 err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC);
209 if (err) {
210 spin_lock(&uas_work_lock);
211 list_add_tail(&cmdinfo->list, &uas_work_list);
212 spin_unlock(&uas_work_lock);
213 schedule_work(&uas_work);
214 }
215}
216
217static void uas_stat_cmplt(struct urb *urb)
218{
219 struct iu *iu = urb->transfer_buffer;
220 struct scsi_device *sdev = urb->context;
221 struct uas_dev_info *devinfo = sdev->hostdata;
222 struct scsi_cmnd *cmnd;
223 u16 tag;
224
225 if (urb->status) {
226 dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status);
227 usb_free_urb(urb);
228 return;
229 }
230
231 tag = be16_to_cpup(&iu->tag) - 1;
232 if (sdev->current_cmnd)
233 cmnd = sdev->current_cmnd;
234 else
235 cmnd = scsi_find_tag(sdev, tag);
236 if (!cmnd)
237 return;
238
239 switch (iu->iu_id) {
240 case IU_ID_STATUS:
241 if (urb->actual_length < 16)
242 devinfo->uas_sense_old = 1;
243 if (devinfo->uas_sense_old)
244 uas_sense_old(urb, cmnd);
245 else
246 uas_sense(urb, cmnd);
247 break;
248 case IU_ID_READ_READY:
249 uas_xfer_data(urb, cmnd, SUBMIT_DATA_IN_URB);
250 break;
251 case IU_ID_WRITE_READY:
252 uas_xfer_data(urb, cmnd, SUBMIT_DATA_OUT_URB);
253 break;
254 default:
255 scmd_printk(KERN_ERR, cmnd,
256 "Bogus IU (%d) received on status pipe\n", iu->iu_id);
257 }
258}
259
260static void uas_data_cmplt(struct urb *urb)
261{
262 struct scsi_data_buffer *sdb = urb->context;
263 sdb->resid = sdb->length - urb->actual_length;
264 usb_free_urb(urb);
265}
266
267static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
268 unsigned int pipe, u16 stream_id,
269 struct scsi_data_buffer *sdb,
270 enum dma_data_direction dir)
271{
272 struct usb_device *udev = devinfo->udev;
273 struct urb *urb = usb_alloc_urb(0, gfp);
274
275 if (!urb)
276 goto out;
277 usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, uas_data_cmplt,
278 sdb);
279 if (devinfo->use_streams)
280 urb->stream_id = stream_id;
281 urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
282 urb->sg = sdb->table.sgl;
283 out:
284 return urb;
285}
286
287static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
288 struct scsi_cmnd *cmnd, u16 stream_id)
289{
290 struct usb_device *udev = devinfo->udev;
291 struct urb *urb = usb_alloc_urb(0, gfp);
292 struct sense_iu *iu;
293
294 if (!urb)
295 goto out;
296
297 iu = kmalloc(sizeof(*iu), gfp);
298 if (!iu)
299 goto free;
300
301 usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
302 uas_stat_cmplt, cmnd->device);
303 urb->stream_id = stream_id;
304 urb->transfer_flags |= URB_FREE_BUFFER;
305 out:
306 return urb;
307 free:
308 usb_free_urb(urb);
309 return NULL;
310}
311
312static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp,
313 struct scsi_cmnd *cmnd, u16 stream_id)
314{
315 struct usb_device *udev = devinfo->udev;
316 struct scsi_device *sdev = cmnd->device;
317 struct urb *urb = usb_alloc_urb(0, gfp);
318 struct command_iu *iu;
319 int len;
320
321 if (!urb)
322 goto out;
323
324 len = cmnd->cmd_len - 16;
325 if (len < 0)
326 len = 0;
327 len = ALIGN(len, 4);
328 iu = kmalloc(sizeof(*iu) + len, gfp);
329 if (!iu)
330 goto free;
331
332 iu->iu_id = IU_ID_COMMAND;
333 iu->tag = cpu_to_be16(stream_id);
334 if (sdev->ordered_tags && (cmnd->request->cmd_flags & REQ_HARDBARRIER))
335 iu->prio_attr = UAS_ORDERED_TAG;
336 else
337 iu->prio_attr = UAS_SIMPLE_TAG;
338 iu->len = len;
339 int_to_scsilun(sdev->lun, &iu->lun);
340 memcpy(iu->cdb, cmnd->cmnd, cmnd->cmd_len);
341
342 usb_fill_bulk_urb(urb, udev, devinfo->cmd_pipe, iu, sizeof(*iu) + len,
343 usb_free_urb, NULL);
344 urb->transfer_flags |= URB_FREE_BUFFER;
345 out:
346 return urb;
347 free:
348 usb_free_urb(urb);
349 return NULL;
350}
351
352/*
353 * Why should I request the Status IU before sending the Command IU? Spec
354 * says to, but also says the device may receive them in any order. Seems
355 * daft to me.
356 */
357
358static int uas_submit_urbs(struct scsi_cmnd *cmnd,
359 struct uas_dev_info *devinfo, gfp_t gfp)
360{
361 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
362
363 if (cmdinfo->state & ALLOC_SENSE_URB) {
364 cmdinfo->sense_urb = uas_alloc_sense_urb(devinfo, gfp, cmnd,
365 cmdinfo->stream);
366 if (!cmdinfo->sense_urb)
367 return SCSI_MLQUEUE_DEVICE_BUSY;
368 cmdinfo->state &= ~ALLOC_SENSE_URB;
369 }
370
371 if (cmdinfo->state & SUBMIT_SENSE_URB) {
372 if (usb_submit_urb(cmdinfo->sense_urb, gfp)) {
373 scmd_printk(KERN_INFO, cmnd,
374 "sense urb submission failure\n");
375 return SCSI_MLQUEUE_DEVICE_BUSY;
376 }
377 cmdinfo->state &= ~SUBMIT_SENSE_URB;
378 }
379
380 if (cmdinfo->state & ALLOC_DATA_IN_URB) {
381 cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp,
382 devinfo->data_in_pipe, cmdinfo->stream,
383 scsi_in(cmnd), DMA_FROM_DEVICE);
384 if (!cmdinfo->data_in_urb)
385 return SCSI_MLQUEUE_DEVICE_BUSY;
386 cmdinfo->state &= ~ALLOC_DATA_IN_URB;
387 }
388
389 if (cmdinfo->state & SUBMIT_DATA_IN_URB) {
390 if (usb_submit_urb(cmdinfo->data_in_urb, gfp)) {
391 scmd_printk(KERN_INFO, cmnd,
392 "data in urb submission failure\n");
393 return SCSI_MLQUEUE_DEVICE_BUSY;
394 }
395 cmdinfo->state &= ~SUBMIT_DATA_IN_URB;
396 }
397
398 if (cmdinfo->state & ALLOC_DATA_OUT_URB) {
399 cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp,
400 devinfo->data_out_pipe, cmdinfo->stream,
401 scsi_out(cmnd), DMA_TO_DEVICE);
402 if (!cmdinfo->data_out_urb)
403 return SCSI_MLQUEUE_DEVICE_BUSY;
404 cmdinfo->state &= ~ALLOC_DATA_OUT_URB;
405 }
406
407 if (cmdinfo->state & SUBMIT_DATA_OUT_URB) {
408 if (usb_submit_urb(cmdinfo->data_out_urb, gfp)) {
409 scmd_printk(KERN_INFO, cmnd,
410 "data out urb submission failure\n");
411 return SCSI_MLQUEUE_DEVICE_BUSY;
412 }
413 cmdinfo->state &= ~SUBMIT_DATA_OUT_URB;
414 }
415
416 if (cmdinfo->state & ALLOC_CMD_URB) {
417 cmdinfo->cmd_urb = uas_alloc_cmd_urb(devinfo, gfp, cmnd,
418 cmdinfo->stream);
419 if (!cmdinfo->cmd_urb)
420 return SCSI_MLQUEUE_DEVICE_BUSY;
421 cmdinfo->state &= ~ALLOC_CMD_URB;
422 }
423
424 if (cmdinfo->state & SUBMIT_CMD_URB) {
425 if (usb_submit_urb(cmdinfo->cmd_urb, gfp)) {
426 scmd_printk(KERN_INFO, cmnd,
427 "cmd urb submission failure\n");
428 return SCSI_MLQUEUE_DEVICE_BUSY;
429 }
430 cmdinfo->state &= ~SUBMIT_CMD_URB;
431 }
432
433 return 0;
434}
435
436static int uas_queuecommand(struct scsi_cmnd *cmnd,
437 void (*done)(struct scsi_cmnd *))
438{
439 struct scsi_device *sdev = cmnd->device;
440 struct uas_dev_info *devinfo = sdev->hostdata;
441 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
442 int err;
443
444 BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer));
445
446 if (!cmdinfo->sense_urb && sdev->current_cmnd)
447 return SCSI_MLQUEUE_DEVICE_BUSY;
448
449 if (blk_rq_tagged(cmnd->request)) {
450 cmdinfo->stream = cmnd->request->tag + 1;
451 } else {
452 sdev->current_cmnd = cmnd;
453 cmdinfo->stream = 1;
454 }
455
456 cmnd->scsi_done = done;
457
458 cmdinfo->state = ALLOC_SENSE_URB | SUBMIT_SENSE_URB |
459 ALLOC_CMD_URB | SUBMIT_CMD_URB;
460
461 switch (cmnd->sc_data_direction) {
462 case DMA_FROM_DEVICE:
463 cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB;
464 break;
465 case DMA_BIDIRECTIONAL:
466 cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB;
467 case DMA_TO_DEVICE:
468 cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB;
469 case DMA_NONE:
470 break;
471 }
472
473 if (!devinfo->use_streams) {
474 cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB);
475 cmdinfo->stream = 0;
476 }
477
478 err = uas_submit_urbs(cmnd, devinfo, GFP_ATOMIC);
479 if (err) {
480 /* If we did nothing, give up now */
481 if (cmdinfo->state & SUBMIT_SENSE_URB) {
482 usb_free_urb(cmdinfo->sense_urb);
483 return SCSI_MLQUEUE_DEVICE_BUSY;
484 }
485 spin_lock(&uas_work_lock);
486 list_add_tail(&cmdinfo->list, &uas_work_list);
487 spin_unlock(&uas_work_lock);
488 schedule_work(&uas_work);
489 }
490
491 return 0;
492}
493
494static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
495{
496 struct scsi_device *sdev = cmnd->device;
497 sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
498 cmnd->request->tag);
499
500/* XXX: Send ABORT TASK Task Management command */
501 return FAILED;
502}
503
504static int uas_eh_device_reset_handler(struct scsi_cmnd *cmnd)
505{
506 struct scsi_device *sdev = cmnd->device;
507 sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
508 cmnd->request->tag);
509
510/* XXX: Send LOGICAL UNIT RESET Task Management command */
511 return FAILED;
512}
513
514static int uas_eh_target_reset_handler(struct scsi_cmnd *cmnd)
515{
516 struct scsi_device *sdev = cmnd->device;
517 sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
518 cmnd->request->tag);
519
520/* XXX: Can we reset just the one USB interface?
521 * Would calling usb_set_interface() have the right effect?
522 */
523 return FAILED;
524}
525
526static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
527{
528 struct scsi_device *sdev = cmnd->device;
529 struct uas_dev_info *devinfo = sdev->hostdata;
530 struct usb_device *udev = devinfo->udev;
531
532 sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
533 cmnd->request->tag);
534
535 if (usb_reset_device(udev))
536 return SUCCESS;
537
538 return FAILED;
539}
540
541static int uas_slave_alloc(struct scsi_device *sdev)
542{
543 sdev->hostdata = (void *)sdev->host->hostdata[0];
544 return 0;
545}
546
547static int uas_slave_configure(struct scsi_device *sdev)
548{
549 struct uas_dev_info *devinfo = sdev->hostdata;
550 scsi_set_tag_type(sdev, MSG_ORDERED_TAG);
551 scsi_activate_tcq(sdev, devinfo->qdepth - 1);
552 return 0;
553}
554
555static struct scsi_host_template uas_host_template = {
556 .module = THIS_MODULE,
557 .name = "uas",
558 .queuecommand = uas_queuecommand,
559 .slave_alloc = uas_slave_alloc,
560 .slave_configure = uas_slave_configure,
561 .eh_abort_handler = uas_eh_abort_handler,
562 .eh_device_reset_handler = uas_eh_device_reset_handler,
563 .eh_target_reset_handler = uas_eh_target_reset_handler,
564 .eh_bus_reset_handler = uas_eh_bus_reset_handler,
565 .can_queue = 65536, /* Is there a limit on the _host_ ? */
566 .this_id = -1,
567 .sg_tablesize = SG_NONE,
568 .cmd_per_lun = 1, /* until we override it */
569 .skip_settle_delay = 1,
570 .ordered_tag = 1,
571};
572
573static struct usb_device_id uas_usb_ids[] = {
574 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_BULK) },
575 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_UAS) },
576 /* 0xaa is a prototype device I happen to have access to */
577 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, 0xaa) },
578 { }
579};
580MODULE_DEVICE_TABLE(usb, uas_usb_ids);
581
582static void uas_configure_endpoints(struct uas_dev_info *devinfo)
583{
584 struct usb_host_endpoint *eps[4] = { };
585 struct usb_interface *intf = devinfo->intf;
586 struct usb_device *udev = devinfo->udev;
587 struct usb_host_endpoint *endpoint = intf->cur_altsetting->endpoint;
588 unsigned i, n_endpoints = intf->cur_altsetting->desc.bNumEndpoints;
589
590 devinfo->uas_sense_old = 0;
591
592 for (i = 0; i < n_endpoints; i++) {
593 unsigned char *extra = endpoint[i].extra;
594 int len = endpoint[i].extralen;
595 while (len > 1) {
596 if (extra[1] == USB_DT_PIPE_USAGE) {
597 unsigned pipe_id = extra[2];
598 if (pipe_id > 0 && pipe_id < 5)
599 eps[pipe_id - 1] = &endpoint[i];
600 break;
601 }
602 len -= extra[0];
603 extra += extra[0];
604 }
605 }
606
607 /*
608 * Assume that if we didn't find a control pipe descriptor, we're
609 * using a device with old firmware that happens to be set up like
610 * this.
611 */
612 if (!eps[0]) {
613 devinfo->cmd_pipe = usb_sndbulkpipe(udev, 1);
614 devinfo->status_pipe = usb_rcvbulkpipe(udev, 1);
615 devinfo->data_in_pipe = usb_rcvbulkpipe(udev, 2);
616 devinfo->data_out_pipe = usb_sndbulkpipe(udev, 2);
617
618 eps[1] = usb_pipe_endpoint(udev, devinfo->status_pipe);
619 eps[2] = usb_pipe_endpoint(udev, devinfo->data_in_pipe);
620 eps[3] = usb_pipe_endpoint(udev, devinfo->data_out_pipe);
621 } else {
622 devinfo->cmd_pipe = usb_sndbulkpipe(udev,
623 eps[0]->desc.bEndpointAddress);
624 devinfo->status_pipe = usb_rcvbulkpipe(udev,
625 eps[1]->desc.bEndpointAddress);
626 devinfo->data_in_pipe = usb_rcvbulkpipe(udev,
627 eps[2]->desc.bEndpointAddress);
628 devinfo->data_out_pipe = usb_sndbulkpipe(udev,
629 eps[3]->desc.bEndpointAddress);
630 }
631
632 devinfo->qdepth = usb_alloc_streams(devinfo->intf, eps + 1, 3, 256,
633 GFP_KERNEL);
634 if (devinfo->qdepth < 0) {
635 devinfo->qdepth = 256;
636 devinfo->use_streams = 0;
637 } else {
638 devinfo->use_streams = 1;
639 }
640}
641
642/*
643 * XXX: What I'd like to do here is register a SCSI host for each USB host in
644 * the system. Follow usb-storage's design of registering a SCSI host for
645 * each USB device for the moment. Can implement this by walking up the
646 * USB hierarchy until we find a USB host.
647 */
648static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
649{
650 int result;
651 struct Scsi_Host *shost;
652 struct uas_dev_info *devinfo;
653 struct usb_device *udev = interface_to_usbdev(intf);
654
655 if (id->bInterfaceProtocol == 0x50) {
656 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
657/* XXX: Shouldn't assume that 1 is the alternative we want */
658 int ret = usb_set_interface(udev, ifnum, 1);
659 if (ret)
660 return -ENODEV;
661 }
662
663 devinfo = kmalloc(sizeof(struct uas_dev_info), GFP_KERNEL);
664 if (!devinfo)
665 return -ENOMEM;
666
667 result = -ENOMEM;
668 shost = scsi_host_alloc(&uas_host_template, sizeof(void *));
669 if (!shost)
670 goto free;
671
672 shost->max_cmd_len = 16 + 252;
673 shost->max_id = 1;
674 shost->sg_tablesize = udev->bus->sg_tablesize;
675
676 result = scsi_add_host(shost, &intf->dev);
677 if (result)
678 goto free;
679 shost->hostdata[0] = (unsigned long)devinfo;
680
681 devinfo->intf = intf;
682 devinfo->udev = udev;
683 uas_configure_endpoints(devinfo);
684
685 scsi_scan_host(shost);
686 usb_set_intfdata(intf, shost);
687 return result;
688 free:
689 kfree(devinfo);
690 if (shost)
691 scsi_host_put(shost);
692 return result;
693}
694
695static int uas_pre_reset(struct usb_interface *intf)
696{
697/* XXX: Need to return 1 if it's not our device in error handling */
698 return 0;
699}
700
701static int uas_post_reset(struct usb_interface *intf)
702{
703/* XXX: Need to return 1 if it's not our device in error handling */
704 return 0;
705}
706
707static void uas_disconnect(struct usb_interface *intf)
708{
709 struct usb_device *udev = interface_to_usbdev(intf);
710 struct usb_host_endpoint *eps[3];
711 struct Scsi_Host *shost = usb_get_intfdata(intf);
712 struct uas_dev_info *devinfo = (void *)shost->hostdata[0];
713
714 scsi_remove_host(shost);
715
716 eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe);
717 eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe);
718 eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe);
719 usb_free_streams(intf, eps, 3, GFP_KERNEL);
720
721 kfree(devinfo);
722}
723
724/*
725 * XXX: Should this plug into libusual so we can auto-upgrade devices from
726 * Bulk-Only to UAS?
727 */
728static struct usb_driver uas_driver = {
729 .name = "uas",
730 .probe = uas_probe,
731 .disconnect = uas_disconnect,
732 .pre_reset = uas_pre_reset,
733 .post_reset = uas_post_reset,
734 .id_table = uas_usb_ids,
735};
736
737static int uas_init(void)
738{
739 return usb_register(&uas_driver);
740}
741
742static void uas_exit(void)
743{
744 usb_deregister(&uas_driver);
745}
746
747module_init(uas_init);
748module_exit(uas_exit);
749
750MODULE_LICENSE("GPL");
751MODULE_AUTHOR("Matthew Wilcox and Sarah Sharp");
diff --git a/drivers/usb/storage/unusual_alauda.h b/drivers/usb/storage/unusual_alauda.h
index 8c412f885dd2..fa3e9edaa2cf 100644
--- a/drivers/usb/storage/unusual_alauda.h
+++ b/drivers/usb/storage/unusual_alauda.h
@@ -21,11 +21,11 @@
21UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102, 21UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102,
22 "Fujifilm", 22 "Fujifilm",
23 "DPC-R1 (Alauda)", 23 "DPC-R1 (Alauda)",
24 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0), 24 USB_SC_SCSI, USB_PR_ALAUDA, init_alauda, 0),
25 25
26UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102, 26UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102,
27 "Olympus", 27 "Olympus",
28 "MAUSB-10 (Alauda)", 28 "MAUSB-10 (Alauda)",
29 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0), 29 USB_SC_SCSI, USB_PR_ALAUDA, init_alauda, 0),
30 30
31#endif /* defined(CONFIG_USB_STORAGE_ALAUDA) || ... */ 31#endif /* defined(CONFIG_USB_STORAGE_ALAUDA) || ... */
diff --git a/drivers/usb/storage/unusual_cypress.h b/drivers/usb/storage/unusual_cypress.h
index 44be6d75dab6..c854fdebe0ae 100644
--- a/drivers/usb/storage/unusual_cypress.h
+++ b/drivers/usb/storage/unusual_cypress.h
@@ -23,12 +23,12 @@
23UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, 23UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
24 "Cypress", 24 "Cypress",
25 "Cypress AT2LP", 25 "Cypress AT2LP",
26 US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0), 26 USB_SC_CYP_ATACB, USB_PR_DEVICE, NULL, 0),
27 27
28/* CY7C68310 : support atacb and atacb2 */ 28/* CY7C68310 : support atacb and atacb2 */
29UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999, 29UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999,
30 "Cypress", 30 "Cypress",
31 "Cypress ISD-300LP", 31 "Cypress ISD-300LP",
32 US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0), 32 USB_SC_CYP_ATACB, USB_PR_DEVICE, NULL, 0),
33 33
34#endif /* defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || ... */ 34#endif /* defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || ... */
diff --git a/drivers/usb/storage/unusual_datafab.h b/drivers/usb/storage/unusual_datafab.h
index c9298ce9f223..582a603c78be 100644
--- a/drivers/usb/storage/unusual_datafab.h
+++ b/drivers/usb/storage/unusual_datafab.h
@@ -21,7 +21,7 @@
21UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015, 21UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
22 "Datafab", 22 "Datafab",
23 "MDCFE-B USB CF Reader", 23 "MDCFE-B USB CF Reader",
24 US_SC_SCSI, US_PR_DATAFAB, NULL, 24 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
25 0), 25 0),
26 26
27/* 27/*
@@ -38,45 +38,45 @@ UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
38UNUSUAL_DEV( 0x07c4, 0xa001, 0x0000, 0xffff, 38UNUSUAL_DEV( 0x07c4, 0xa001, 0x0000, 0xffff,
39 "SIIG/Datafab", 39 "SIIG/Datafab",
40 "SIIG/Datafab Memory Stick+CF Reader/Writer", 40 "SIIG/Datafab Memory Stick+CF Reader/Writer",
41 US_SC_SCSI, US_PR_DATAFAB, NULL, 41 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
42 0), 42 0),
43 43
44/* Reported by Josef Reisinger <josef.reisinger@netcologne.de> */ 44/* Reported by Josef Reisinger <josef.reisinger@netcologne.de> */
45UNUSUAL_DEV( 0x07c4, 0xa002, 0x0000, 0xffff, 45UNUSUAL_DEV( 0x07c4, 0xa002, 0x0000, 0xffff,
46 "Datafab/Unknown", 46 "Datafab/Unknown",
47 "MD2/MD3 Disk enclosure", 47 "MD2/MD3 Disk enclosure",
48 US_SC_SCSI, US_PR_DATAFAB, NULL, 48 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
49 US_FL_SINGLE_LUN), 49 US_FL_SINGLE_LUN),
50 50
51UNUSUAL_DEV( 0x07c4, 0xa003, 0x0000, 0xffff, 51UNUSUAL_DEV( 0x07c4, 0xa003, 0x0000, 0xffff,
52 "Datafab/Unknown", 52 "Datafab/Unknown",
53 "Datafab-based Reader", 53 "Datafab-based Reader",
54 US_SC_SCSI, US_PR_DATAFAB, NULL, 54 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
55 0), 55 0),
56 56
57UNUSUAL_DEV( 0x07c4, 0xa004, 0x0000, 0xffff, 57UNUSUAL_DEV( 0x07c4, 0xa004, 0x0000, 0xffff,
58 "Datafab/Unknown", 58 "Datafab/Unknown",
59 "Datafab-based Reader", 59 "Datafab-based Reader",
60 US_SC_SCSI, US_PR_DATAFAB, NULL, 60 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
61 0), 61 0),
62 62
63UNUSUAL_DEV( 0x07c4, 0xa005, 0x0000, 0xffff, 63UNUSUAL_DEV( 0x07c4, 0xa005, 0x0000, 0xffff,
64 "PNY/Datafab", 64 "PNY/Datafab",
65 "PNY/Datafab CF+SM Reader", 65 "PNY/Datafab CF+SM Reader",
66 US_SC_SCSI, US_PR_DATAFAB, NULL, 66 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
67 0), 67 0),
68 68
69UNUSUAL_DEV( 0x07c4, 0xa006, 0x0000, 0xffff, 69UNUSUAL_DEV( 0x07c4, 0xa006, 0x0000, 0xffff,
70 "Simple Tech/Datafab", 70 "Simple Tech/Datafab",
71 "Simple Tech/Datafab CF+SM Reader", 71 "Simple Tech/Datafab CF+SM Reader",
72 US_SC_SCSI, US_PR_DATAFAB, NULL, 72 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
73 0), 73 0),
74 74
75/* Submitted by Olaf Hering <olh@suse.de> */ 75/* Submitted by Olaf Hering <olh@suse.de> */
76UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff, 76UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
77 "Datafab Systems, Inc.", 77 "Datafab Systems, Inc.",
78 "USB to CF + SM Combo (LC1)", 78 "USB to CF + SM Combo (LC1)",
79 US_SC_SCSI, US_PR_DATAFAB, NULL, 79 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
80 0), 80 0),
81 81
82/* Reported by Felix Moeller <felix@derklecks.de> 82/* Reported by Felix Moeller <felix@derklecks.de>
@@ -86,13 +86,13 @@ UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
86UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff, 86UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff,
87 "DataFab Systems Inc.", 87 "DataFab Systems Inc.",
88 "USB CF+MS", 88 "USB CF+MS",
89 US_SC_SCSI, US_PR_DATAFAB, NULL, 89 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
90 0), 90 0),
91 91
92UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff, 92UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
93 "Acomdata", 93 "Acomdata",
94 "CF", 94 "CF",
95 US_SC_SCSI, US_PR_DATAFAB, NULL, 95 USB_SC_SCSI, USB_PR_DATAFAB, NULL,
96 US_FL_SINGLE_LUN), 96 US_FL_SINGLE_LUN),
97 97
98#endif /* defined(CONFIG_USB_STORAGE_DATAFAB) || ... */ 98#endif /* defined(CONFIG_USB_STORAGE_DATAFAB) || ... */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 2c897eefadde..6ccdd3dd5259 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -63,26 +63,26 @@
63UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100, 63UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
64 "ATMEL", 64 "ATMEL",
65 "SND1 Storage", 65 "SND1 Storage",
66 US_SC_DEVICE, US_PR_DEVICE, NULL, 66 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
67 US_FL_IGNORE_RESIDUE), 67 US_FL_IGNORE_RESIDUE),
68 68
69/* Reported by Rodolfo Quesada <rquesada@roqz.net> */ 69/* Reported by Rodolfo Quesada <rquesada@roqz.net> */
70UNUSUAL_DEV( 0x03ee, 0x6906, 0x0003, 0x0003, 70UNUSUAL_DEV( 0x03ee, 0x6906, 0x0003, 0x0003,
71 "VIA Technologies Inc.", 71 "VIA Technologies Inc.",
72 "Mitsumi multi cardreader", 72 "Mitsumi multi cardreader",
73 US_SC_DEVICE, US_PR_DEVICE, NULL, 73 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
74 US_FL_IGNORE_RESIDUE ), 74 US_FL_IGNORE_RESIDUE ),
75 75
76UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200, 76UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200,
77 "HP", 77 "HP",
78 "CD-Writer+", 78 "CD-Writer+",
79 US_SC_8070, US_PR_CB, NULL, 0), 79 USB_SC_8070, USB_PR_CB, NULL, 0),
80 80
81/* Reported by Ben Efros <ben@pc-doctor.com> */ 81/* Reported by Ben Efros <ben@pc-doctor.com> */
82UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000, 82UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000,
83 "HP", 83 "HP",
84 "Personal Media Drive", 84 "Personal Media Drive",
85 US_SC_DEVICE, US_PR_DEVICE, NULL, 85 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
86 US_FL_SANE_SENSE ), 86 US_FL_SANE_SENSE ),
87 87
88/* Reported by Grant Grundler <grundler@parisc-linux.org> 88/* Reported by Grant Grundler <grundler@parisc-linux.org>
@@ -91,7 +91,7 @@ UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000,
91UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001, 91UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001,
92 "HP", 92 "HP",
93 "PhotoSmart R707", 93 "PhotoSmart R707",
94 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY), 94 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_CAPACITY),
95 95
96/* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> 96/* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net>
97 * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) 97 * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product)
@@ -100,14 +100,14 @@ UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001,
100UNUSUAL_DEV( 0x0409, 0x0040, 0x0000, 0x9999, 100UNUSUAL_DEV( 0x0409, 0x0040, 0x0000, 0x9999,
101 "NEC", 101 "NEC",
102 "NEC USB UF000x", 102 "NEC USB UF000x",
103 US_SC_DEVICE, US_PR_DEVICE, NULL, 103 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
104 US_FL_SINGLE_LUN ), 104 US_FL_SINGLE_LUN ),
105 105
106/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */ 106/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */
107UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003, 107UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003,
108 "VIA Technologies Inc.", 108 "VIA Technologies Inc.",
109 "USB 2.0 Card Reader", 109 "USB 2.0 Card Reader",
110 US_SC_DEVICE, US_PR_DEVICE, NULL, 110 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
111 US_FL_IGNORE_RESIDUE ), 111 US_FL_IGNORE_RESIDUE ),
112 112
113/* Deduced by Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 113/* Deduced by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
@@ -117,40 +117,40 @@ UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003,
117UNUSUAL_DEV( 0x0411, 0x001c, 0x0113, 0x0113, 117UNUSUAL_DEV( 0x0411, 0x001c, 0x0113, 0x0113,
118 "Buffalo", 118 "Buffalo",
119 "DUB-P40G HDD", 119 "DUB-P40G HDD",
120 US_SC_DEVICE, US_PR_DEVICE, NULL, 120 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
121 US_FL_FIX_INQUIRY ), 121 US_FL_FIX_INQUIRY ),
122 122
123/* Submitted by Ernestas Vaiciukevicius <ernisv@gmail.com> */ 123/* Submitted by Ernestas Vaiciukevicius <ernisv@gmail.com> */
124UNUSUAL_DEV( 0x0419, 0x0100, 0x0100, 0x0100, 124UNUSUAL_DEV( 0x0419, 0x0100, 0x0100, 0x0100,
125 "Samsung Info. Systems America, Inc.", 125 "Samsung Info. Systems America, Inc.",
126 "MP3 Player", 126 "MP3 Player",
127 US_SC_DEVICE, US_PR_DEVICE, NULL, 127 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
128 US_FL_IGNORE_RESIDUE ), 128 US_FL_IGNORE_RESIDUE ),
129 129
130/* Reported by Orgad Shaneh <orgads@gmail.com> */ 130/* Reported by Orgad Shaneh <orgads@gmail.com> */
131UNUSUAL_DEV( 0x0419, 0xaace, 0x0100, 0x0100, 131UNUSUAL_DEV( 0x0419, 0xaace, 0x0100, 0x0100,
132 "Samsung", "MP3 Player", 132 "Samsung", "MP3 Player",
133 US_SC_DEVICE, US_PR_DEVICE, NULL, 133 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
134 US_FL_IGNORE_RESIDUE ), 134 US_FL_IGNORE_RESIDUE ),
135 135
136/* Reported by Christian Leber <christian@leber.de> */ 136/* Reported by Christian Leber <christian@leber.de> */
137UNUSUAL_DEV( 0x0419, 0xaaf5, 0x0100, 0x0100, 137UNUSUAL_DEV( 0x0419, 0xaaf5, 0x0100, 0x0100,
138 "TrekStor", 138 "TrekStor",
139 "i.Beat 115 2.0", 139 "i.Beat 115 2.0",
140 US_SC_DEVICE, US_PR_DEVICE, NULL, 140 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
141 US_FL_IGNORE_RESIDUE | US_FL_NOT_LOCKABLE ), 141 US_FL_IGNORE_RESIDUE | US_FL_NOT_LOCKABLE ),
142 142
143/* Reported by Stefan Werner <dustbln@gmx.de> */ 143/* Reported by Stefan Werner <dustbln@gmx.de> */
144UNUSUAL_DEV( 0x0419, 0xaaf6, 0x0100, 0x0100, 144UNUSUAL_DEV( 0x0419, 0xaaf6, 0x0100, 0x0100,
145 "TrekStor", 145 "TrekStor",
146 "i.Beat Joy 2.0", 146 "i.Beat Joy 2.0",
147 US_SC_DEVICE, US_PR_DEVICE, NULL, 147 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
148 US_FL_IGNORE_RESIDUE ), 148 US_FL_IGNORE_RESIDUE ),
149 149
150/* Reported by Pete Zaitcev <zaitcev@redhat.com>, bz#176584 */ 150/* Reported by Pete Zaitcev <zaitcev@redhat.com>, bz#176584 */
151UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100, 151UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100,
152 "GENERIC", "MP3 PLAYER", /* MyMusix PD-205 on the outside. */ 152 "GENERIC", "MP3 PLAYER", /* MyMusix PD-205 on the outside. */
153 US_SC_DEVICE, US_PR_DEVICE, NULL, 153 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
154 US_FL_IGNORE_RESIDUE ), 154 US_FL_IGNORE_RESIDUE ),
155 155
156/* Reported by Andrew Nayenko <relan@bk.ru> 156/* Reported by Andrew Nayenko <relan@bk.ru>
@@ -158,28 +158,28 @@ UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100,
158UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0610, 158UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0610,
159 "Nokia", 159 "Nokia",
160 "Nokia 6288", 160 "Nokia 6288",
161 US_SC_DEVICE, US_PR_DEVICE, NULL, 161 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
162 US_FL_MAX_SECTORS_64 ), 162 US_FL_MAX_SECTORS_64 ),
163 163
164/* Reported by Mario Rettig <mariorettig@web.de> */ 164/* Reported by Mario Rettig <mariorettig@web.de> */
165UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, 165UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
166 "Nokia", 166 "Nokia",
167 "Nokia 3250", 167 "Nokia 3250",
168 US_SC_DEVICE, US_PR_DEVICE, NULL, 168 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
169 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 169 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
170 170
171/* Reported by <honkkis@gmail.com> */ 171/* Reported by <honkkis@gmail.com> */
172UNUSUAL_DEV( 0x0421, 0x0433, 0x0100, 0x0100, 172UNUSUAL_DEV( 0x0421, 0x0433, 0x0100, 0x0100,
173 "Nokia", 173 "Nokia",
174 "E70", 174 "E70",
175 US_SC_DEVICE, US_PR_DEVICE, NULL, 175 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
176 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 176 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
177 177
178/* Reported by Jon Hart <Jon.Hart@web.de> */ 178/* Reported by Jon Hart <Jon.Hart@web.de> */
179UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100, 179UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100,
180 "Nokia", 180 "Nokia",
181 "E60", 181 "E60",
182 US_SC_DEVICE, US_PR_DEVICE, NULL, 182 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
183 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), 183 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
184 184
185/* Reported by Sumedha Swamy <sumedhaswamy@gmail.com> and 185/* Reported by Sumedha Swamy <sumedhaswamy@gmail.com> and
@@ -187,7 +187,7 @@ UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100,
187UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100, 187UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100,
188 "Nokia", 188 "Nokia",
189 "N91", 189 "N91",
190 US_SC_DEVICE, US_PR_DEVICE, NULL, 190 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
191 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 191 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
192 192
193/* Reported by Jiri Slaby <jirislaby@gmail.com> and 193/* Reported by Jiri Slaby <jirislaby@gmail.com> and
@@ -195,42 +195,42 @@ UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100,
195UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100, 195UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100,
196 "Nokia", 196 "Nokia",
197 "N80", 197 "N80",
198 US_SC_DEVICE, US_PR_DEVICE, NULL, 198 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
199 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 199 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
200 200
201/* Reported by Matthew Bloch <matthew@bytemark.co.uk> */ 201/* Reported by Matthew Bloch <matthew@bytemark.co.uk> */
202UNUSUAL_DEV( 0x0421, 0x044e, 0x0100, 0x0100, 202UNUSUAL_DEV( 0x0421, 0x044e, 0x0100, 0x0100,
203 "Nokia", 203 "Nokia",
204 "E61", 204 "E61",
205 US_SC_DEVICE, US_PR_DEVICE, NULL, 205 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
206 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 206 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
207 207
208/* Reported by Bardur Arantsson <bardur@scientician.net> */ 208/* Reported by Bardur Arantsson <bardur@scientician.net> */
209UNUSUAL_DEV( 0x0421, 0x047c, 0x0370, 0x0610, 209UNUSUAL_DEV( 0x0421, 0x047c, 0x0370, 0x0610,
210 "Nokia", 210 "Nokia",
211 "6131", 211 "6131",
212 US_SC_DEVICE, US_PR_DEVICE, NULL, 212 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
213 US_FL_MAX_SECTORS_64 ), 213 US_FL_MAX_SECTORS_64 ),
214 214
215/* Reported by Manuel Osdoba <manuel.osdoba@tu-ilmenau.de> */ 215/* Reported by Manuel Osdoba <manuel.osdoba@tu-ilmenau.de> */
216UNUSUAL_DEV( 0x0421, 0x0492, 0x0452, 0x9999, 216UNUSUAL_DEV( 0x0421, 0x0492, 0x0452, 0x9999,
217 "Nokia", 217 "Nokia",
218 "Nokia 6233", 218 "Nokia 6233",
219 US_SC_DEVICE, US_PR_DEVICE, NULL, 219 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
220 US_FL_MAX_SECTORS_64 ), 220 US_FL_MAX_SECTORS_64 ),
221 221
222/* Reported by Alex Corcoles <alex@corcoles.net> */ 222/* Reported by Alex Corcoles <alex@corcoles.net> */
223UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370, 223UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
224 "Nokia", 224 "Nokia",
225 "6234", 225 "6234",
226 US_SC_DEVICE, US_PR_DEVICE, NULL, 226 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
227 US_FL_MAX_SECTORS_64 ), 227 US_FL_MAX_SECTORS_64 ),
228 228
229#ifdef NO_SDDR09 229#ifdef NO_SDDR09
230UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100, 230UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
231 "Microtech", 231 "Microtech",
232 "CameraMate", 232 "CameraMate",
233 US_SC_SCSI, US_PR_CB, NULL, 233 USB_SC_SCSI, USB_PR_CB, NULL,
234 US_FL_SINGLE_LUN ), 234 US_FL_SINGLE_LUN ),
235#endif 235#endif
236 236
@@ -239,7 +239,7 @@ UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
239UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100, 239UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100,
240 "Neuros Audio", 240 "Neuros Audio",
241 "USB 2.0 HD 2.5", 241 "USB 2.0 HD 2.5",
242 US_SC_DEVICE, US_PR_BULK, NULL, 242 USB_SC_DEVICE, USB_PR_BULK, NULL,
243 US_FL_NEED_OVERRIDE ), 243 US_FL_NEED_OVERRIDE ),
244 244
245/* 245/*
@@ -250,7 +250,7 @@ UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100,
250UNUSUAL_DEV( 0x0457, 0x0150, 0x0100, 0x0100, 250UNUSUAL_DEV( 0x0457, 0x0150, 0x0100, 0x0100,
251 "USBest Technology", /* sold by Transcend */ 251 "USBest Technology", /* sold by Transcend */
252 "USB Mass Storage Device", 252 "USB Mass Storage Device",
253 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), 253 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
254 254
255/* 255/*
256* Bohdan Linda <bohdan.linda@gmail.com> 256* Bohdan Linda <bohdan.linda@gmail.com>
@@ -260,7 +260,7 @@ UNUSUAL_DEV( 0x0457, 0x0150, 0x0100, 0x0100,
260UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100, 260UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100,
261 "USB 2.0", 261 "USB 2.0",
262 "Flash Disk", 262 "Flash Disk",
263 US_SC_DEVICE, US_PR_DEVICE, NULL, 263 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
264 US_FL_NOT_LOCKABLE ), 264 US_FL_NOT_LOCKABLE ),
265 265
266/* Reported by Tamas Kerecsen <kerecsen@bigfoot.com> 266/* Reported by Tamas Kerecsen <kerecsen@bigfoot.com>
@@ -272,7 +272,7 @@ UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100,
272UNUSUAL_DEV( 0x045e, 0xffff, 0x0000, 0x0000, 272UNUSUAL_DEV( 0x045e, 0xffff, 0x0000, 0x0000,
273 "Mitac", 273 "Mitac",
274 "GPS", 274 "GPS",
275 US_SC_DEVICE, US_PR_DEVICE, NULL, 275 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
276 US_FL_MAX_SECTORS_64 ), 276 US_FL_MAX_SECTORS_64 ),
277 277
278/* 278/*
@@ -284,32 +284,32 @@ UNUSUAL_DEV( 0x045e, 0xffff, 0x0000, 0x0000,
284UNUSUAL_DEV( 0x046b, 0xff40, 0x0100, 0x0100, 284UNUSUAL_DEV( 0x046b, 0xff40, 0x0100, 0x0100,
285 "AMI", 285 "AMI",
286 "Virtual Floppy", 286 "Virtual Floppy",
287 US_SC_DEVICE, US_PR_DEVICE, NULL, 287 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
288 US_FL_NO_WP_DETECT), 288 US_FL_NO_WP_DETECT),
289 289
290/* Patch submitted by Philipp Friedrich <philipp@void.at> */ 290/* Patch submitted by Philipp Friedrich <philipp@void.at> */
291UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100, 291UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100,
292 "Kyocera", 292 "Kyocera",
293 "Finecam S3x", 293 "Finecam S3x",
294 US_SC_8070, US_PR_CB, NULL, US_FL_FIX_INQUIRY), 294 USB_SC_8070, USB_PR_CB, NULL, US_FL_FIX_INQUIRY),
295 295
296/* Patch submitted by Philipp Friedrich <philipp@void.at> */ 296/* Patch submitted by Philipp Friedrich <philipp@void.at> */
297UNUSUAL_DEV( 0x0482, 0x0101, 0x0100, 0x0100, 297UNUSUAL_DEV( 0x0482, 0x0101, 0x0100, 0x0100,
298 "Kyocera", 298 "Kyocera",
299 "Finecam S4", 299 "Finecam S4",
300 US_SC_8070, US_PR_CB, NULL, US_FL_FIX_INQUIRY), 300 USB_SC_8070, USB_PR_CB, NULL, US_FL_FIX_INQUIRY),
301 301
302/* Patch submitted by Stephane Galles <stephane.galles@free.fr> */ 302/* Patch submitted by Stephane Galles <stephane.galles@free.fr> */
303UNUSUAL_DEV( 0x0482, 0x0103, 0x0100, 0x0100, 303UNUSUAL_DEV( 0x0482, 0x0103, 0x0100, 0x0100,
304 "Kyocera", 304 "Kyocera",
305 "Finecam S5", 305 "Finecam S5",
306 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY), 306 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
307 307
308/* Patch submitted by Jens Taprogge <jens.taprogge@taprogge.org> */ 308/* Patch submitted by Jens Taprogge <jens.taprogge@taprogge.org> */
309UNUSUAL_DEV( 0x0482, 0x0107, 0x0100, 0x0100, 309UNUSUAL_DEV( 0x0482, 0x0107, 0x0100, 0x0100,
310 "Kyocera", 310 "Kyocera",
311 "CONTAX SL300R T*", 311 "CONTAX SL300R T*",
312 US_SC_DEVICE, US_PR_DEVICE, NULL, 312 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
313 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE), 313 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE),
314 314
315/* Reported by Paul Stewart <stewart@wetlogic.net> 315/* Reported by Paul Stewart <stewart@wetlogic.net>
@@ -317,7 +317,7 @@ UNUSUAL_DEV( 0x0482, 0x0107, 0x0100, 0x0100,
317UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001, 317UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001,
318 "Hitachi", 318 "Hitachi",
319 "DVD-CAM DZ-MV100A Camcorder", 319 "DVD-CAM DZ-MV100A Camcorder",
320 US_SC_SCSI, US_PR_CB, NULL, US_FL_SINGLE_LUN), 320 USB_SC_SCSI, USB_PR_CB, NULL, US_FL_SINGLE_LUN),
321 321
322/* BENQ DC5330 322/* BENQ DC5330
323 * Reported by Manuel Fombuena <mfombuena@ya.com> and 323 * Reported by Manuel Fombuena <mfombuena@ya.com> and
@@ -325,7 +325,7 @@ UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001,
325UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100, 325UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
326 "Tekom Technologies, Inc", 326 "Tekom Technologies, Inc",
327 "300_CAMERA", 327 "300_CAMERA",
328 US_SC_DEVICE, US_PR_DEVICE, NULL, 328 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
329 US_FL_IGNORE_RESIDUE ), 329 US_FL_IGNORE_RESIDUE ),
330 330
331/* Patch for Nikon coolpix 2000 331/* Patch for Nikon coolpix 2000
@@ -333,14 +333,14 @@ UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
333UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010, 333UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010,
334 "NIKON", 334 "NIKON",
335 "NIKON DSC E2000", 335 "NIKON DSC E2000",
336 US_SC_DEVICE, US_PR_DEVICE,NULL, 336 USB_SC_DEVICE, USB_PR_DEVICE,NULL,
337 US_FL_NOT_LOCKABLE ), 337 US_FL_NOT_LOCKABLE ),
338 338
339/* Reported by Doug Maxey (dwm@austin.ibm.com) */ 339/* Reported by Doug Maxey (dwm@austin.ibm.com) */
340UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, 340UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
341 "IBM", 341 "IBM",
342 "IBM RSA2", 342 "IBM RSA2",
343 US_SC_DEVICE, US_PR_CB, NULL, 343 USB_SC_DEVICE, USB_PR_CB, NULL,
344 US_FL_MAX_SECTORS_MIN), 344 US_FL_MAX_SECTORS_MIN),
345 345
346/* Reported by Simon Levitt <simon@whattf.com> 346/* Reported by Simon Levitt <simon@whattf.com>
@@ -348,14 +348,14 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
348UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, 348UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100,
349 "Epson", 349 "Epson",
350 "875DC Storage", 350 "875DC Storage",
351 US_SC_SCSI, US_PR_CB, NULL, US_FL_FIX_INQUIRY), 351 USB_SC_SCSI, USB_PR_CB, NULL, US_FL_FIX_INQUIRY),
352 352
353/* Reported by Khalid Aziz <khalid@gonehiking.org> 353/* Reported by Khalid Aziz <khalid@gonehiking.org>
354 * This entry is needed because the device reports Sub=ff */ 354 * This entry is needed because the device reports Sub=ff */
355UNUSUAL_DEV( 0x04b8, 0x0602, 0x0110, 0x0110, 355UNUSUAL_DEV( 0x04b8, 0x0602, 0x0110, 0x0110,
356 "Epson", 356 "Epson",
357 "785EPX Storage", 357 "785EPX Storage",
358 US_SC_SCSI, US_PR_BULK, NULL, US_FL_SINGLE_LUN), 358 USB_SC_SCSI, USB_PR_BULK, NULL, US_FL_SINGLE_LUN),
359 359
360/* Not sure who reported this originally but 360/* Not sure who reported this originally but
361 * Pavel Machek <pavel@ucw.cz> reported that the extra US_FL_SINGLE_LUN 361 * Pavel Machek <pavel@ucw.cz> reported that the extra US_FL_SINGLE_LUN
@@ -363,7 +363,7 @@ UNUSUAL_DEV( 0x04b8, 0x0602, 0x0110, 0x0110,
363UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210, 363UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210,
364 "Fujifilm", 364 "Fujifilm",
365 "FinePix 1400Zoom", 365 "FinePix 1400Zoom",
366 US_SC_UFI, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN), 366 USB_SC_UFI, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN),
367 367
368/* Reported by Ondrej Zary <linux@rainbow-software.org> 368/* Reported by Ondrej Zary <linux@rainbow-software.org>
369 * The device reports one sector more and breaks when that sector is accessed 369 * The device reports one sector more and breaks when that sector is accessed
@@ -371,7 +371,7 @@ UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210,
371UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c, 371UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c,
372 "ScanLogic", 372 "ScanLogic",
373 "SL11R-IDE", 373 "SL11R-IDE",
374 US_SC_DEVICE, US_PR_DEVICE, NULL, 374 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
375 US_FL_FIX_CAPACITY), 375 US_FL_FIX_CAPACITY),
376 376
377/* Reported by Kriston Fincher <kriston@airmail.net> 377/* Reported by Kriston Fincher <kriston@airmail.net>
@@ -382,27 +382,27 @@ UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c,
382UNUSUAL_DEV( 0x04da, 0x0901, 0x0100, 0x0200, 382UNUSUAL_DEV( 0x04da, 0x0901, 0x0100, 0x0200,
383 "Panasonic", 383 "Panasonic",
384 "LS-120 Camera", 384 "LS-120 Camera",
385 US_SC_UFI, US_PR_DEVICE, NULL, 0), 385 USB_SC_UFI, USB_PR_DEVICE, NULL, 0),
386 386
387/* From Yukihiro Nakai, via zaitcev@yahoo.com. 387/* From Yukihiro Nakai, via zaitcev@yahoo.com.
388 * This is needed for CB instead of CBI */ 388 * This is needed for CB instead of CBI */
389UNUSUAL_DEV( 0x04da, 0x0d05, 0x0000, 0x0000, 389UNUSUAL_DEV( 0x04da, 0x0d05, 0x0000, 0x0000,
390 "Sharp CE-CW05", 390 "Sharp CE-CW05",
391 "CD-R/RW Drive", 391 "CD-R/RW Drive",
392 US_SC_8070, US_PR_CB, NULL, 0), 392 USB_SC_8070, USB_PR_CB, NULL, 0),
393 393
394/* Reported by Adriaan Penning <a.penning@luon.net> */ 394/* Reported by Adriaan Penning <a.penning@luon.net> */
395UNUSUAL_DEV( 0x04da, 0x2372, 0x0000, 0x9999, 395UNUSUAL_DEV( 0x04da, 0x2372, 0x0000, 0x9999,
396 "Panasonic", 396 "Panasonic",
397 "DMC-LCx Camera", 397 "DMC-LCx Camera",
398 US_SC_DEVICE, US_PR_DEVICE, NULL, 398 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
399 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), 399 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
400 400
401/* Reported by Simeon Simeonov <simeonov_2000@yahoo.com> */ 401/* Reported by Simeon Simeonov <simeonov_2000@yahoo.com> */
402UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999, 402UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999,
403 "LEICA", 403 "LEICA",
404 "D-LUX Camera", 404 "D-LUX Camera",
405 US_SC_DEVICE, US_PR_DEVICE, NULL, 405 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
406 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), 406 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
407 407
408/* Most of the following entries were developed with the help of 408/* Most of the following entries were developed with the help of
@@ -411,19 +411,19 @@ UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999,
411UNUSUAL_DEV( 0x04e6, 0x0001, 0x0200, 0x0200, 411UNUSUAL_DEV( 0x04e6, 0x0001, 0x0200, 0x0200,
412 "Matshita", 412 "Matshita",
413 "LS-120", 413 "LS-120",
414 US_SC_8020, US_PR_CB, NULL, 0), 414 USB_SC_8020, USB_PR_CB, NULL, 0),
415 415
416UNUSUAL_DEV( 0x04e6, 0x0002, 0x0100, 0x0100, 416UNUSUAL_DEV( 0x04e6, 0x0002, 0x0100, 0x0100,
417 "Shuttle", 417 "Shuttle",
418 "eUSCSI Bridge", 418 "eUSCSI Bridge",
419 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init, 419 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
420 US_FL_SCM_MULT_TARG ), 420 US_FL_SCM_MULT_TARG ),
421 421
422#ifdef NO_SDDR09 422#ifdef NO_SDDR09
423UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208, 423UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
424 "SCM Microsystems", 424 "SCM Microsystems",
425 "eUSB CompactFlash Adapter", 425 "eUSB CompactFlash Adapter",
426 US_SC_SCSI, US_PR_CB, NULL, 426 USB_SC_SCSI, USB_PR_CB, NULL,
427 US_FL_SINGLE_LUN), 427 US_FL_SINGLE_LUN),
428#endif 428#endif
429 429
@@ -431,54 +431,54 @@ UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
431UNUSUAL_DEV( 0x04e6, 0x0006, 0x0100, 0x0100, 431UNUSUAL_DEV( 0x04e6, 0x0006, 0x0100, 0x0100,
432 "SCM Microsystems Inc.", 432 "SCM Microsystems Inc.",
433 "eUSB MMC Adapter", 433 "eUSB MMC Adapter",
434 US_SC_SCSI, US_PR_CB, NULL, 434 USB_SC_SCSI, USB_PR_CB, NULL,
435 US_FL_SINGLE_LUN), 435 US_FL_SINGLE_LUN),
436 436
437/* Reported by Daniel Nouri <dpunktnpunkt@web.de> */ 437/* Reported by Daniel Nouri <dpunktnpunkt@web.de> */
438UNUSUAL_DEV( 0x04e6, 0x0006, 0x0205, 0x0205, 438UNUSUAL_DEV( 0x04e6, 0x0006, 0x0205, 0x0205,
439 "Shuttle", 439 "Shuttle",
440 "eUSB MMC Adapter", 440 "eUSB MMC Adapter",
441 US_SC_SCSI, US_PR_DEVICE, NULL, 441 USB_SC_SCSI, USB_PR_DEVICE, NULL,
442 US_FL_SINGLE_LUN), 442 US_FL_SINGLE_LUN),
443 443
444UNUSUAL_DEV( 0x04e6, 0x0007, 0x0100, 0x0200, 444UNUSUAL_DEV( 0x04e6, 0x0007, 0x0100, 0x0200,
445 "Sony", 445 "Sony",
446 "Hifd", 446 "Hifd",
447 US_SC_SCSI, US_PR_CB, NULL, 447 USB_SC_SCSI, USB_PR_CB, NULL,
448 US_FL_SINGLE_LUN), 448 US_FL_SINGLE_LUN),
449 449
450UNUSUAL_DEV( 0x04e6, 0x0009, 0x0200, 0x0200, 450UNUSUAL_DEV( 0x04e6, 0x0009, 0x0200, 0x0200,
451 "Shuttle", 451 "Shuttle",
452 "eUSB ATA/ATAPI Adapter", 452 "eUSB ATA/ATAPI Adapter",
453 US_SC_8020, US_PR_CB, NULL, 0), 453 USB_SC_8020, USB_PR_CB, NULL, 0),
454 454
455UNUSUAL_DEV( 0x04e6, 0x000a, 0x0200, 0x0200, 455UNUSUAL_DEV( 0x04e6, 0x000a, 0x0200, 0x0200,
456 "Shuttle", 456 "Shuttle",
457 "eUSB CompactFlash Adapter", 457 "eUSB CompactFlash Adapter",
458 US_SC_8020, US_PR_CB, NULL, 0), 458 USB_SC_8020, USB_PR_CB, NULL, 0),
459 459
460UNUSUAL_DEV( 0x04e6, 0x000B, 0x0100, 0x0100, 460UNUSUAL_DEV( 0x04e6, 0x000B, 0x0100, 0x0100,
461 "Shuttle", 461 "Shuttle",
462 "eUSCSI Bridge", 462 "eUSCSI Bridge",
463 US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 463 USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init,
464 US_FL_SCM_MULT_TARG ), 464 US_FL_SCM_MULT_TARG ),
465 465
466UNUSUAL_DEV( 0x04e6, 0x000C, 0x0100, 0x0100, 466UNUSUAL_DEV( 0x04e6, 0x000C, 0x0100, 0x0100,
467 "Shuttle", 467 "Shuttle",
468 "eUSCSI Bridge", 468 "eUSCSI Bridge",
469 US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 469 USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init,
470 US_FL_SCM_MULT_TARG ), 470 US_FL_SCM_MULT_TARG ),
471 471
472UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200, 472UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
473 "Shuttle", 473 "Shuttle",
474 "CD-RW Device", 474 "CD-RW Device",
475 US_SC_8020, US_PR_CB, NULL, 0), 475 USB_SC_8020, USB_PR_CB, NULL, 0),
476 476
477/* Reported by Dmitry Khlystov <adminimus@gmail.com> */ 477/* Reported by Dmitry Khlystov <adminimus@gmail.com> */
478UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220, 478UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
479 "Samsung", 479 "Samsung",
480 "YP-U3", 480 "YP-U3",
481 US_SC_DEVICE, US_PR_DEVICE, NULL, 481 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
482 US_FL_MAX_SECTORS_64), 482 US_FL_MAX_SECTORS_64),
483 483
484/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 484/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
@@ -488,14 +488,14 @@ UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
488UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100, 488UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
489 "Kobian Mercury", 489 "Kobian Mercury",
490 "Binocam DCB-132", 490 "Binocam DCB-132",
491 US_SC_DEVICE, US_PR_DEVICE, NULL, 491 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
492 US_FL_BULK32), 492 US_FL_BULK32),
493 493
494/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ 494/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */
495UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, 495UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133,
496 "Belkin", 496 "Belkin",
497 "USB SCSI Adaptor", 497 "USB SCSI Adaptor",
498 US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 498 USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init,
499 US_FL_SCM_MULT_TARG ), 499 US_FL_SCM_MULT_TARG ),
500 500
501/* Iomega Clik! Drive 501/* Iomega Clik! Drive
@@ -505,14 +505,14 @@ UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133,
505UNUSUAL_DEV( 0x0525, 0xa140, 0x0100, 0x0100, 505UNUSUAL_DEV( 0x0525, 0xa140, 0x0100, 0x0100,
506 "Iomega", 506 "Iomega",
507 "USB Clik! 40", 507 "USB Clik! 40",
508 US_SC_8070, US_PR_DEVICE, NULL, 508 USB_SC_8070, USB_PR_DEVICE, NULL,
509 US_FL_FIX_INQUIRY ), 509 US_FL_FIX_INQUIRY ),
510 510
511/* Added by Alan Stern <stern@rowland.harvard.edu> */ 511/* Added by Alan Stern <stern@rowland.harvard.edu> */
512COMPLIANT_DEV(0x0525, 0xa4a5, 0x0000, 0x9999, 512COMPLIANT_DEV(0x0525, 0xa4a5, 0x0000, 0x9999,
513 "Linux", 513 "Linux",
514 "File-backed Storage Gadget", 514 "File-backed Storage Gadget",
515 US_SC_DEVICE, US_PR_DEVICE, NULL, 515 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
516 US_FL_CAPACITY_OK ), 516 US_FL_CAPACITY_OK ),
517 517
518/* Yakumo Mega Image 37 518/* Yakumo Mega Image 37
@@ -520,7 +520,7 @@ COMPLIANT_DEV(0x0525, 0xa4a5, 0x0000, 0x9999,
520UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100, 520UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100,
521 "Tekom Technologies, Inc", 521 "Tekom Technologies, Inc",
522 "300_CAMERA", 522 "300_CAMERA",
523 US_SC_DEVICE, US_PR_DEVICE, NULL, 523 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
524 US_FL_IGNORE_RESIDUE ), 524 US_FL_IGNORE_RESIDUE ),
525 525
526/* Another Yakumo camera. 526/* Another Yakumo camera.
@@ -528,14 +528,14 @@ UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100,
528UNUSUAL_DEV( 0x052b, 0x1804, 0x0100, 0x0100, 528UNUSUAL_DEV( 0x052b, 0x1804, 0x0100, 0x0100,
529 "Tekom Technologies, Inc", 529 "Tekom Technologies, Inc",
530 "300_CAMERA", 530 "300_CAMERA",
531 US_SC_DEVICE, US_PR_DEVICE, NULL, 531 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
532 US_FL_IGNORE_RESIDUE ), 532 US_FL_IGNORE_RESIDUE ),
533 533
534/* Reported by Iacopo Spalletti <avvisi@spalletti.it> */ 534/* Reported by Iacopo Spalletti <avvisi@spalletti.it> */
535UNUSUAL_DEV( 0x052b, 0x1807, 0x0100, 0x0100, 535UNUSUAL_DEV( 0x052b, 0x1807, 0x0100, 0x0100,
536 "Tekom Technologies, Inc", 536 "Tekom Technologies, Inc",
537 "300_CAMERA", 537 "300_CAMERA",
538 US_SC_DEVICE, US_PR_DEVICE, NULL, 538 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
539 US_FL_IGNORE_RESIDUE ), 539 US_FL_IGNORE_RESIDUE ),
540 540
541/* Yakumo Mega Image 47 541/* Yakumo Mega Image 47
@@ -543,7 +543,7 @@ UNUSUAL_DEV( 0x052b, 0x1807, 0x0100, 0x0100,
543UNUSUAL_DEV( 0x052b, 0x1905, 0x0100, 0x0100, 543UNUSUAL_DEV( 0x052b, 0x1905, 0x0100, 0x0100,
544 "Tekom Technologies, Inc", 544 "Tekom Technologies, Inc",
545 "400_CAMERA", 545 "400_CAMERA",
546 US_SC_DEVICE, US_PR_DEVICE, NULL, 546 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
547 US_FL_IGNORE_RESIDUE ), 547 US_FL_IGNORE_RESIDUE ),
548 548
549/* Reported by Paul Ortyl <ortylp@3miasto.net> 549/* Reported by Paul Ortyl <ortylp@3miasto.net>
@@ -551,13 +551,13 @@ UNUSUAL_DEV( 0x052b, 0x1905, 0x0100, 0x0100,
551UNUSUAL_DEV( 0x052b, 0x1911, 0x0100, 0x0100, 551UNUSUAL_DEV( 0x052b, 0x1911, 0x0100, 0x0100,
552 "Tekom Technologies, Inc", 552 "Tekom Technologies, Inc",
553 "400_CAMERA", 553 "400_CAMERA",
554 US_SC_DEVICE, US_PR_DEVICE, NULL, 554 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
555 US_FL_IGNORE_RESIDUE ), 555 US_FL_IGNORE_RESIDUE ),
556 556
557UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450, 557UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450,
558 "Sony", 558 "Sony",
559 "DSC-S30/S70/S75/505V/F505/F707/F717/P8", 559 "DSC-S30/S70/S75/505V/F505/F707/F717/P8",
560 US_SC_SCSI, US_PR_DEVICE, NULL, 560 USB_SC_SCSI, USB_PR_DEVICE, NULL,
561 US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ), 561 US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ),
562 562
563/* Submitted by Lars Jacob <jacob.lars@googlemail.com> 563/* Submitted by Lars Jacob <jacob.lars@googlemail.com>
@@ -565,7 +565,7 @@ UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450,
565UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610, 565UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610,
566 "Sony", 566 "Sony",
567 "DSC-T1/T5/H5", 567 "DSC-T1/T5/H5",
568 US_SC_8070, US_PR_DEVICE, NULL, 568 USB_SC_8070, USB_PR_DEVICE, NULL,
569 US_FL_SINGLE_LUN ), 569 US_FL_SINGLE_LUN ),
570 570
571 571
@@ -573,88 +573,88 @@ UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610,
573UNUSUAL_DEV( 0x054c, 0x0025, 0x0100, 0x0100, 573UNUSUAL_DEV( 0x054c, 0x0025, 0x0100, 0x0100,
574 "Sony", 574 "Sony",
575 "Memorystick NW-MS7", 575 "Memorystick NW-MS7",
576 US_SC_DEVICE, US_PR_DEVICE, NULL, 576 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
577 US_FL_SINGLE_LUN ), 577 US_FL_SINGLE_LUN ),
578 578
579/* Submitted by Olaf Hering, <olh@suse.de> SuSE Bugzilla #49049 */ 579/* Submitted by Olaf Hering, <olh@suse.de> SuSE Bugzilla #49049 */
580UNUSUAL_DEV( 0x054c, 0x002c, 0x0501, 0x2000, 580UNUSUAL_DEV( 0x054c, 0x002c, 0x0501, 0x2000,
581 "Sony", 581 "Sony",
582 "USB Floppy Drive", 582 "USB Floppy Drive",
583 US_SC_DEVICE, US_PR_DEVICE, NULL, 583 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
584 US_FL_SINGLE_LUN ), 584 US_FL_SINGLE_LUN ),
585 585
586UNUSUAL_DEV( 0x054c, 0x002d, 0x0100, 0x0100, 586UNUSUAL_DEV( 0x054c, 0x002d, 0x0100, 0x0100,
587 "Sony", 587 "Sony",
588 "Memorystick MSAC-US1", 588 "Memorystick MSAC-US1",
589 US_SC_DEVICE, US_PR_DEVICE, NULL, 589 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
590 US_FL_SINGLE_LUN ), 590 US_FL_SINGLE_LUN ),
591 591
592/* Submitted by Klaus Mueller <k.mueller@intershop.de> */ 592/* Submitted by Klaus Mueller <k.mueller@intershop.de> */
593UNUSUAL_DEV( 0x054c, 0x002e, 0x0106, 0x0310, 593UNUSUAL_DEV( 0x054c, 0x002e, 0x0106, 0x0310,
594 "Sony", 594 "Sony",
595 "Handycam", 595 "Handycam",
596 US_SC_SCSI, US_PR_DEVICE, NULL, 596 USB_SC_SCSI, USB_PR_DEVICE, NULL,
597 US_FL_SINGLE_LUN ), 597 US_FL_SINGLE_LUN ),
598 598
599/* Submitted by Rajesh Kumble Nayak <nayak@obs-nice.fr> */ 599/* Submitted by Rajesh Kumble Nayak <nayak@obs-nice.fr> */
600UNUSUAL_DEV( 0x054c, 0x002e, 0x0500, 0x0500, 600UNUSUAL_DEV( 0x054c, 0x002e, 0x0500, 0x0500,
601 "Sony", 601 "Sony",
602 "Handycam HC-85", 602 "Handycam HC-85",
603 US_SC_UFI, US_PR_DEVICE, NULL, 603 USB_SC_UFI, USB_PR_DEVICE, NULL,
604 US_FL_SINGLE_LUN ), 604 US_FL_SINGLE_LUN ),
605 605
606UNUSUAL_DEV( 0x054c, 0x0032, 0x0000, 0x9999, 606UNUSUAL_DEV( 0x054c, 0x0032, 0x0000, 0x9999,
607 "Sony", 607 "Sony",
608 "Memorystick MSC-U01N", 608 "Memorystick MSC-U01N",
609 US_SC_DEVICE, US_PR_DEVICE, NULL, 609 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
610 US_FL_SINGLE_LUN ), 610 US_FL_SINGLE_LUN ),
611 611
612/* Submitted by Michal Mlotek <mlotek@foobar.pl> */ 612/* Submitted by Michal Mlotek <mlotek@foobar.pl> */
613UNUSUAL_DEV( 0x054c, 0x0058, 0x0000, 0x9999, 613UNUSUAL_DEV( 0x054c, 0x0058, 0x0000, 0x9999,
614 "Sony", 614 "Sony",
615 "PEG N760c Memorystick", 615 "PEG N760c Memorystick",
616 US_SC_DEVICE, US_PR_DEVICE, NULL, 616 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
617 US_FL_FIX_INQUIRY ), 617 US_FL_FIX_INQUIRY ),
618 618
619UNUSUAL_DEV( 0x054c, 0x0069, 0x0000, 0x9999, 619UNUSUAL_DEV( 0x054c, 0x0069, 0x0000, 0x9999,
620 "Sony", 620 "Sony",
621 "Memorystick MSC-U03", 621 "Memorystick MSC-U03",
622 US_SC_UFI, US_PR_CB, NULL, 622 USB_SC_UFI, USB_PR_CB, NULL,
623 US_FL_SINGLE_LUN ), 623 US_FL_SINGLE_LUN ),
624 624
625/* Submitted by Nathan Babb <nathan@lexi.com> */ 625/* Submitted by Nathan Babb <nathan@lexi.com> */
626UNUSUAL_DEV( 0x054c, 0x006d, 0x0000, 0x9999, 626UNUSUAL_DEV( 0x054c, 0x006d, 0x0000, 0x9999,
627 "Sony", 627 "Sony",
628 "PEG Mass Storage", 628 "PEG Mass Storage",
629 US_SC_DEVICE, US_PR_DEVICE, NULL, 629 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
630 US_FL_FIX_INQUIRY ), 630 US_FL_FIX_INQUIRY ),
631 631
632/* Submitted by Frank Engel <frankie@cse.unsw.edu.au> */ 632/* Submitted by Frank Engel <frankie@cse.unsw.edu.au> */
633UNUSUAL_DEV( 0x054c, 0x0099, 0x0000, 0x9999, 633UNUSUAL_DEV( 0x054c, 0x0099, 0x0000, 0x9999,
634 "Sony", 634 "Sony",
635 "PEG Mass Storage", 635 "PEG Mass Storage",
636 US_SC_DEVICE, US_PR_DEVICE, NULL, 636 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
637 US_FL_FIX_INQUIRY ), 637 US_FL_FIX_INQUIRY ),
638 638
639/* Submitted by Mike Alborn <malborn@deandra.homeip.net> */ 639/* Submitted by Mike Alborn <malborn@deandra.homeip.net> */
640UNUSUAL_DEV( 0x054c, 0x016a, 0x0000, 0x9999, 640UNUSUAL_DEV( 0x054c, 0x016a, 0x0000, 0x9999,
641 "Sony", 641 "Sony",
642 "PEG Mass Storage", 642 "PEG Mass Storage",
643 US_SC_DEVICE, US_PR_DEVICE, NULL, 643 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
644 US_FL_FIX_INQUIRY ), 644 US_FL_FIX_INQUIRY ),
645 645
646/* floppy reports multiple luns */ 646/* floppy reports multiple luns */
647UNUSUAL_DEV( 0x055d, 0x2020, 0x0000, 0x0210, 647UNUSUAL_DEV( 0x055d, 0x2020, 0x0000, 0x0210,
648 "SAMSUNG", 648 "SAMSUNG",
649 "SFD-321U [FW 0C]", 649 "SFD-321U [FW 0C]",
650 US_SC_DEVICE, US_PR_DEVICE, NULL, 650 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
651 US_FL_SINGLE_LUN ), 651 US_FL_SINGLE_LUN ),
652 652
653/* We keep this entry to force the transport; firmware 3.00 and later is ok. */ 653/* We keep this entry to force the transport; firmware 3.00 and later is ok. */
654UNUSUAL_DEV( 0x057b, 0x0000, 0x0000, 0x0299, 654UNUSUAL_DEV( 0x057b, 0x0000, 0x0000, 0x0299,
655 "Y-E Data", 655 "Y-E Data",
656 "Flashbuster-U", 656 "Flashbuster-U",
657 US_SC_DEVICE, US_PR_CB, NULL, 657 USB_SC_DEVICE, USB_PR_CB, NULL,
658 US_FL_SINGLE_LUN), 658 US_FL_SINGLE_LUN),
659 659
660/* Reported by Johann Cardon <johann.cardon@free.fr> 660/* Reported by Johann Cardon <johann.cardon@free.fr>
@@ -664,20 +664,20 @@ UNUSUAL_DEV( 0x057b, 0x0000, 0x0000, 0x0299,
664UNUSUAL_DEV( 0x057b, 0x0022, 0x0000, 0x9999, 664UNUSUAL_DEV( 0x057b, 0x0022, 0x0000, 0x9999,
665 "Y-E Data", 665 "Y-E Data",
666 "Silicon Media R/W", 666 "Silicon Media R/W",
667 US_SC_DEVICE, US_PR_DEVICE, NULL, 0), 667 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 0),
668 668
669/* Reported by RTE <raszilki@yandex.ru> */ 669/* Reported by RTE <raszilki@yandex.ru> */
670UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141, 670UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141,
671 "JetFlash", 671 "JetFlash",
672 "TS1GJF2A/120", 672 "TS1GJF2A/120",
673 US_SC_DEVICE, US_PR_DEVICE, NULL, 673 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
674 US_FL_MAX_SECTORS_64 ), 674 US_FL_MAX_SECTORS_64 ),
675 675
676/* Fabrizio Fellini <fello@libero.it> */ 676/* Fabrizio Fellini <fello@libero.it> */
677UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, 677UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
678 "Fujifilm", 678 "Fujifilm",
679 "Digital Camera EX-20 DSC", 679 "Digital Camera EX-20 DSC",
680 US_SC_8070, US_PR_DEVICE, NULL, 0 ), 680 USB_SC_8070, USB_PR_DEVICE, NULL, 0 ),
681 681
682/* Reported by Andre Welter <a.r.welter@gmx.de> 682/* Reported by Andre Welter <a.r.welter@gmx.de>
683 * This antique device predates the release of the Bulk-only Transport 683 * This antique device predates the release of the Bulk-only Transport
@@ -688,14 +688,14 @@ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
688UNUSUAL_DEV( 0x059b, 0x0001, 0x0100, 0x0100, 688UNUSUAL_DEV( 0x059b, 0x0001, 0x0100, 0x0100,
689 "Iomega", 689 "Iomega",
690 "ZIP 100", 690 "ZIP 100",
691 US_SC_DEVICE, US_PR_DEVICE, NULL, 691 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
692 US_FL_SINGLE_LUN ), 692 US_FL_SINGLE_LUN ),
693 693
694/* Reported by <Hendryk.Pfeiffer@gmx.de> */ 694/* Reported by <Hendryk.Pfeiffer@gmx.de> */
695UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000, 695UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000,
696 "LaCie", 696 "LaCie",
697 "DVD+-RW", 697 "DVD+-RW",
698 US_SC_DEVICE, US_PR_DEVICE, NULL, 698 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
699 US_FL_GO_SLOW ), 699 US_FL_GO_SLOW ),
700 700
701/* Submitted by Joel Bourquard <numlock@freesurf.ch> 701/* Submitted by Joel Bourquard <numlock@freesurf.ch>
@@ -705,7 +705,7 @@ UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000,
705UNUSUAL_DEV( 0x05ab, 0x0060, 0x1104, 0x1110, 705UNUSUAL_DEV( 0x05ab, 0x0060, 0x1104, 0x1110,
706 "In-System", 706 "In-System",
707 "PyroGate External CD-ROM Enclosure (FCD-523)", 707 "PyroGate External CD-ROM Enclosure (FCD-523)",
708 US_SC_SCSI, US_PR_BULK, NULL, 708 USB_SC_SCSI, USB_PR_BULK, NULL,
709 US_FL_NEED_OVERRIDE ), 709 US_FL_NEED_OVERRIDE ),
710 710
711/* Submitted by Sven Anderson <sven-linux@anderson.de> 711/* Submitted by Sven Anderson <sven-linux@anderson.de>
@@ -717,26 +717,26 @@ UNUSUAL_DEV( 0x05ab, 0x0060, 0x1104, 0x1110,
717UNUSUAL_DEV( 0x05ac, 0x1202, 0x0000, 0x9999, 717UNUSUAL_DEV( 0x05ac, 0x1202, 0x0000, 0x9999,
718 "Apple", 718 "Apple",
719 "iPod", 719 "iPod",
720 US_SC_DEVICE, US_PR_DEVICE, NULL, 720 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
721 US_FL_FIX_CAPACITY ), 721 US_FL_FIX_CAPACITY ),
722 722
723/* Reported by Avi Kivity <avi@argo.co.il> */ 723/* Reported by Avi Kivity <avi@argo.co.il> */
724UNUSUAL_DEV( 0x05ac, 0x1203, 0x0000, 0x9999, 724UNUSUAL_DEV( 0x05ac, 0x1203, 0x0000, 0x9999,
725 "Apple", 725 "Apple",
726 "iPod", 726 "iPod",
727 US_SC_DEVICE, US_PR_DEVICE, NULL, 727 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
728 US_FL_FIX_CAPACITY ), 728 US_FL_FIX_CAPACITY ),
729 729
730UNUSUAL_DEV( 0x05ac, 0x1204, 0x0000, 0x9999, 730UNUSUAL_DEV( 0x05ac, 0x1204, 0x0000, 0x9999,
731 "Apple", 731 "Apple",
732 "iPod", 732 "iPod",
733 US_SC_DEVICE, US_PR_DEVICE, NULL, 733 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
734 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), 734 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
735 735
736UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999, 736UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
737 "Apple", 737 "Apple",
738 "iPod", 738 "iPod",
739 US_SC_DEVICE, US_PR_DEVICE, NULL, 739 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
740 US_FL_FIX_CAPACITY ), 740 US_FL_FIX_CAPACITY ),
741 741
742/* 742/*
@@ -746,7 +746,7 @@ UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
746UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999, 746UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
747 "Apple", 747 "Apple",
748 "iPod", 748 "iPod",
749 US_SC_DEVICE, US_PR_DEVICE, NULL, 749 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
750 US_FL_FIX_CAPACITY ), 750 US_FL_FIX_CAPACITY ),
751 751
752/* Reported by Dan Williams <dcbw@redhat.com> 752/* Reported by Dan Williams <dcbw@redhat.com>
@@ -758,14 +758,14 @@ UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
758UNUSUAL_DEV( 0x05c6, 0x1000, 0x0000, 0x9999, 758UNUSUAL_DEV( 0x05c6, 0x1000, 0x0000, 0x9999,
759 "Option N.V.", 759 "Option N.V.",
760 "Mass Storage", 760 "Mass Storage",
761 US_SC_DEVICE, US_PR_DEVICE, option_ms_init, 761 USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init,
762 0), 762 0),
763 763
764/* Reported by Blake Matheny <bmatheny@purdue.edu> */ 764/* Reported by Blake Matheny <bmatheny@purdue.edu> */
765UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113, 765UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113,
766 "Lexar", 766 "Lexar",
767 "USB CF Reader", 767 "USB CF Reader",
768 US_SC_DEVICE, US_PR_DEVICE, NULL, 768 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
769 US_FL_FIX_INQUIRY ), 769 US_FL_FIX_INQUIRY ),
770 770
771/* The following two entries are for a Genesys USB to IDE 771/* The following two entries are for a Genesys USB to IDE
@@ -782,20 +782,20 @@ UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113,
782UNUSUAL_DEV( 0x05e3, 0x0701, 0x0000, 0xffff, 782UNUSUAL_DEV( 0x05e3, 0x0701, 0x0000, 0xffff,
783 "Genesys Logic", 783 "Genesys Logic",
784 "USB to IDE Optical", 784 "USB to IDE Optical",
785 US_SC_DEVICE, US_PR_DEVICE, NULL, 785 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
786 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ), 786 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ),
787 787
788UNUSUAL_DEV( 0x05e3, 0x0702, 0x0000, 0xffff, 788UNUSUAL_DEV( 0x05e3, 0x0702, 0x0000, 0xffff,
789 "Genesys Logic", 789 "Genesys Logic",
790 "USB to IDE Disk", 790 "USB to IDE Disk",
791 US_SC_DEVICE, US_PR_DEVICE, NULL, 791 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
792 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ), 792 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ),
793 793
794/* Reported by Ben Efros <ben@pc-doctor.com> */ 794/* Reported by Ben Efros <ben@pc-doctor.com> */
795UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451, 795UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451,
796 "Genesys Logic", 796 "Genesys Logic",
797 "USB to SATA", 797 "USB to SATA",
798 US_SC_DEVICE, US_PR_DEVICE, NULL, 798 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
799 US_FL_SANE_SENSE ), 799 US_FL_SANE_SENSE ),
800 800
801/* Reported by Hanno Boeck <hanno@gmx.de> 801/* Reported by Hanno Boeck <hanno@gmx.de>
@@ -803,33 +803,33 @@ UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451,
803UNUSUAL_DEV( 0x0636, 0x0003, 0x0000, 0x9999, 803UNUSUAL_DEV( 0x0636, 0x0003, 0x0000, 0x9999,
804 "Vivitar", 804 "Vivitar",
805 "Vivicam 35Xx", 805 "Vivicam 35Xx",
806 US_SC_SCSI, US_PR_BULK, NULL, 806 USB_SC_SCSI, USB_PR_BULK, NULL,
807 US_FL_FIX_INQUIRY ), 807 US_FL_FIX_INQUIRY ),
808 808
809UNUSUAL_DEV( 0x0644, 0x0000, 0x0100, 0x0100, 809UNUSUAL_DEV( 0x0644, 0x0000, 0x0100, 0x0100,
810 "TEAC", 810 "TEAC",
811 "Floppy Drive", 811 "Floppy Drive",
812 US_SC_UFI, US_PR_CB, NULL, 0 ), 812 USB_SC_UFI, USB_PR_CB, NULL, 0 ),
813 813
814/* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */ 814/* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */
815UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001, 815UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001,
816 "SigmaTel", 816 "SigmaTel",
817 "USBMSC Audio Player", 817 "USBMSC Audio Player",
818 US_SC_DEVICE, US_PR_DEVICE, NULL, 818 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
819 US_FL_FIX_CAPACITY ), 819 US_FL_FIX_CAPACITY ),
820 820
821/* Reported by Daniel Kukula <daniel.kuku@gmail.com> */ 821/* Reported by Daniel Kukula <daniel.kuku@gmail.com> */
822UNUSUAL_DEV( 0x067b, 0x1063, 0x0100, 0x0100, 822UNUSUAL_DEV( 0x067b, 0x1063, 0x0100, 0x0100,
823 "Prolific Technology, Inc.", 823 "Prolific Technology, Inc.",
824 "Prolific Storage Gadget", 824 "Prolific Storage Gadget",
825 US_SC_DEVICE, US_PR_DEVICE, NULL, 825 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
826 US_FL_BAD_SENSE ), 826 US_FL_BAD_SENSE ),
827 827
828/* Reported by Rogerio Brito <rbrito@ime.usp.br> */ 828/* Reported by Rogerio Brito <rbrito@ime.usp.br> */
829UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001, 829UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001,
830 "Prolific Technology, Inc.", 830 "Prolific Technology, Inc.",
831 "Mass Storage Device", 831 "Mass Storage Device",
832 US_SC_DEVICE, US_PR_DEVICE, NULL, 832 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
833 US_FL_NOT_LOCKABLE ), 833 US_FL_NOT_LOCKABLE ),
834 834
835/* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */ 835/* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */
@@ -838,46 +838,47 @@ UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001,
838UNUSUAL_DEV( 0x067b, 0x2507, 0x0001, 0x0100, 838UNUSUAL_DEV( 0x067b, 0x2507, 0x0001, 0x0100,
839 "Prolific Technology Inc.", 839 "Prolific Technology Inc.",
840 "Mass Storage Device", 840 "Mass Storage Device",
841 US_SC_DEVICE, US_PR_DEVICE, NULL, 841 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
842 US_FL_FIX_CAPACITY | US_FL_GO_SLOW ), 842 US_FL_FIX_CAPACITY | US_FL_GO_SLOW ),
843 843
844/* Reported by Alex Butcher <alex.butcher@assursys.co.uk> */ 844/* Reported by Alex Butcher <alex.butcher@assursys.co.uk> */
845UNUSUAL_DEV( 0x067b, 0x3507, 0x0001, 0x0101, 845UNUSUAL_DEV( 0x067b, 0x3507, 0x0001, 0x0101,
846 "Prolific Technology Inc.", 846 "Prolific Technology Inc.",
847 "ATAPI-6 Bridge Controller", 847 "ATAPI-6 Bridge Controller",
848 US_SC_DEVICE, US_PR_DEVICE, NULL, 848 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
849 US_FL_FIX_CAPACITY | US_FL_GO_SLOW ), 849 US_FL_FIX_CAPACITY | US_FL_GO_SLOW ),
850 850
851/* Submitted by Benny Sjostrand <benny@hostmobility.com> */ 851/* Submitted by Benny Sjostrand <benny@hostmobility.com> */
852UNUSUAL_DEV( 0x0686, 0x4011, 0x0001, 0x0001, 852UNUSUAL_DEV( 0x0686, 0x4011, 0x0001, 0x0001,
853 "Minolta", 853 "Minolta",
854 "Dimage F300", 854 "Dimage F300",
855 US_SC_SCSI, US_PR_BULK, NULL, 0 ), 855 USB_SC_SCSI, USB_PR_BULK, NULL, 0 ),
856 856
857/* Reported by Miguel A. Fosas <amn3s1a@ono.com> */ 857/* Reported by Miguel A. Fosas <amn3s1a@ono.com> */
858UNUSUAL_DEV( 0x0686, 0x4017, 0x0001, 0x0001, 858UNUSUAL_DEV( 0x0686, 0x4017, 0x0001, 0x0001,
859 "Minolta", 859 "Minolta",
860 "DIMAGE E223", 860 "DIMAGE E223",
861 US_SC_SCSI, US_PR_DEVICE, NULL, 0 ), 861 USB_SC_SCSI, USB_PR_DEVICE, NULL, 0 ),
862 862
863UNUSUAL_DEV( 0x0693, 0x0005, 0x0100, 0x0100, 863UNUSUAL_DEV( 0x0693, 0x0005, 0x0100, 0x0100,
864 "Hagiwara", 864 "Hagiwara",
865 "Flashgate", 865 "Flashgate",
866 US_SC_SCSI, US_PR_BULK, NULL, 0 ), 866 USB_SC_SCSI, USB_PR_BULK, NULL, 0 ),
867 867
868/* Reported by David Hamilton <niftimusmaximus@lycos.com> */ 868/* Reported by David Hamilton <niftimusmaximus@lycos.com> */
869UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001, 869UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001,
870 "Thomson Multimedia Inc.", 870 "Thomson Multimedia Inc.",
871 "RCA RD1080 MP3 Player", 871 "RCA RD1080 MP3 Player",
872 US_SC_DEVICE, US_PR_DEVICE, NULL, 872 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
873 US_FL_FIX_CAPACITY ), 873 US_FL_FIX_CAPACITY ),
874 874
875/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */ 875/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */
876UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000, 876UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
877 "RockChip", 877 "RockChip",
878 "MP3", 878 "MP3",
879 US_SC_DEVICE, US_PR_DEVICE, NULL, 879 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
880 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64), 880 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64 |
881 US_FL_NO_READ_CAPACITY_16),
881 882
882/* Reported by Jean-Baptiste Onofre <jb@nanthrax.net> 883/* Reported by Jean-Baptiste Onofre <jb@nanthrax.net>
883 * Support the following product : 884 * Support the following product :
@@ -886,7 +887,7 @@ UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
886UNUSUAL_DEV( 0x071b, 0x32bb, 0x0000, 0x0000, 887UNUSUAL_DEV( 0x071b, 0x32bb, 0x0000, 0x0000,
887 "RockChip", 888 "RockChip",
888 "MTP", 889 "MTP",
889 US_SC_DEVICE, US_PR_DEVICE, NULL, 890 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
890 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64), 891 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64),
891 892
892/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> 893/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com>
@@ -902,59 +903,59 @@ UNUSUAL_DEV( 0x071b, 0x32bb, 0x0000, 0x0000,
902UNUSUAL_DEV( 0x071b, 0x3203, 0x0100, 0x0100, 903UNUSUAL_DEV( 0x071b, 0x3203, 0x0100, 0x0100,
903 "RockChip", 904 "RockChip",
904 "ROCK MP3", 905 "ROCK MP3",
905 US_SC_DEVICE, US_PR_DEVICE, NULL, 906 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
906 US_FL_MAX_SECTORS_64), 907 US_FL_MAX_SECTORS_64),
907 908
908/* Reported by Olivier Blondeau <zeitoun@gmail.com> */ 909/* Reported by Olivier Blondeau <zeitoun@gmail.com> */
909UNUSUAL_DEV( 0x0727, 0x0306, 0x0100, 0x0100, 910UNUSUAL_DEV( 0x0727, 0x0306, 0x0100, 0x0100,
910 "ATMEL", 911 "ATMEL",
911 "SND1 Storage", 912 "SND1 Storage",
912 US_SC_DEVICE, US_PR_DEVICE, NULL, 913 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
913 US_FL_IGNORE_RESIDUE), 914 US_FL_IGNORE_RESIDUE),
914 915
915/* Submitted by Roman Hodek <roman@hodek.net> */ 916/* Submitted by Roman Hodek <roman@hodek.net> */
916UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200, 917UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200,
917 "Sandisk", 918 "Sandisk",
918 "ImageMate SDDR-05a", 919 "ImageMate SDDR-05a",
919 US_SC_SCSI, US_PR_CB, NULL, 920 USB_SC_SCSI, USB_PR_CB, NULL,
920 US_FL_SINGLE_LUN ), 921 US_FL_SINGLE_LUN ),
921 922
922UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009, 923UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009,
923 "SanDisk Corporation", 924 "SanDisk Corporation",
924 "ImageMate CompactFlash USB", 925 "ImageMate CompactFlash USB",
925 US_SC_DEVICE, US_PR_DEVICE, NULL, 926 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
926 US_FL_FIX_CAPACITY ), 927 US_FL_FIX_CAPACITY ),
927 928
928UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100, 929UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100,
929 "Sandisk", 930 "Sandisk",
930 "ImageMate SDDR-12", 931 "ImageMate SDDR-12",
931 US_SC_SCSI, US_PR_CB, NULL, 932 USB_SC_SCSI, USB_PR_CB, NULL,
932 US_FL_SINGLE_LUN ), 933 US_FL_SINGLE_LUN ),
933 934
934/* Reported by Eero Volotinen <eero@ping-viini.org> */ 935/* Reported by Eero Volotinen <eero@ping-viini.org> */
935UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999, 936UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999,
936 "Freecom Technologies", 937 "Freecom Technologies",
937 "FHD-Classic", 938 "FHD-Classic",
938 US_SC_DEVICE, US_PR_DEVICE, NULL, 939 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
939 US_FL_FIX_CAPACITY), 940 US_FL_FIX_CAPACITY),
940 941
941UNUSUAL_DEV( 0x07af, 0x0004, 0x0100, 0x0133, 942UNUSUAL_DEV( 0x07af, 0x0004, 0x0100, 0x0133,
942 "Microtech", 943 "Microtech",
943 "USB-SCSI-DB25", 944 "USB-SCSI-DB25",
944 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init, 945 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
945 US_FL_SCM_MULT_TARG ), 946 US_FL_SCM_MULT_TARG ),
946 947
947UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100, 948UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100,
948 "Microtech", 949 "Microtech",
949 "USB-SCSI-HD50", 950 "USB-SCSI-HD50",
950 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init, 951 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
951 US_FL_SCM_MULT_TARG ), 952 US_FL_SCM_MULT_TARG ),
952 953
953#ifdef NO_SDDR09 954#ifdef NO_SDDR09
954UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100, 955UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
955 "Microtech", 956 "Microtech",
956 "CameraMate", 957 "CameraMate",
957 US_SC_SCSI, US_PR_CB, NULL, 958 USB_SC_SCSI, USB_PR_CB, NULL,
958 US_FL_SINGLE_LUN ), 959 US_FL_SINGLE_LUN ),
959#endif 960#endif
960 961
@@ -967,7 +968,7 @@ UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
967UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff, 968UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff,
968 "Datafab", 969 "Datafab",
969 "KECF-USB", 970 "KECF-USB",
970 US_SC_DEVICE, US_PR_DEVICE, NULL, 971 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
971 US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY ), 972 US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY ),
972 973
973/* Reported by Rauch Wolke <rauchwolke@gmx.net> 974/* Reported by Rauch Wolke <rauchwolke@gmx.net>
@@ -976,7 +977,7 @@ UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff,
976UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff, 977UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff,
977 "Simple Tech/Datafab", 978 "Simple Tech/Datafab",
978 "CF+SM Reader", 979 "CF+SM Reader",
979 US_SC_DEVICE, US_PR_DEVICE, NULL, 980 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
980 US_FL_IGNORE_RESIDUE | US_FL_MAX_SECTORS_64 ), 981 US_FL_IGNORE_RESIDUE | US_FL_MAX_SECTORS_64 ),
981 982
982/* Casio QV 2x00/3x00/4000/8000 digital still cameras are not conformant 983/* Casio QV 2x00/3x00/4000/8000 digital still cameras are not conformant
@@ -986,42 +987,42 @@ UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff,
986 * - They don't like the INQUIRY command. So we must handle this command 987 * - They don't like the INQUIRY command. So we must handle this command
987 * of the SCSI layer ourselves. 988 * of the SCSI layer ourselves.
988 * - Some cameras with idProduct=0x1001 and bcdDevice=0x1000 have 989 * - Some cameras with idProduct=0x1001 and bcdDevice=0x1000 have
989 * bInterfaceProtocol=0x00 (US_PR_CBI) while others have 0x01 (US_PR_CB). 990 * bInterfaceProtocol=0x00 (USB_PR_CBI) while others have 0x01 (USB_PR_CB).
990 * So don't remove the US_PR_CB override! 991 * So don't remove the USB_PR_CB override!
991 * - Cameras with bcdDevice=0x9009 require the US_SC_8070 override. 992 * - Cameras with bcdDevice=0x9009 require the USB_SC_8070 override.
992 */ 993 */
993UNUSUAL_DEV( 0x07cf, 0x1001, 0x1000, 0x9999, 994UNUSUAL_DEV( 0x07cf, 0x1001, 0x1000, 0x9999,
994 "Casio", 995 "Casio",
995 "QV DigitalCamera", 996 "QV DigitalCamera",
996 US_SC_8070, US_PR_CB, NULL, 997 USB_SC_8070, USB_PR_CB, NULL,
997 US_FL_NEED_OVERRIDE | US_FL_FIX_INQUIRY ), 998 US_FL_NEED_OVERRIDE | US_FL_FIX_INQUIRY ),
998 999
999/* Submitted by Hartmut Wahl <hwahl@hwahl.de>*/ 1000/* Submitted by Hartmut Wahl <hwahl@hwahl.de>*/
1000UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001, 1001UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001,
1001 "Samsung", 1002 "Samsung",
1002 "Digimax 410", 1003 "Digimax 410",
1003 US_SC_DEVICE, US_PR_DEVICE, NULL, 1004 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1004 US_FL_FIX_INQUIRY), 1005 US_FL_FIX_INQUIRY),
1005 1006
1006/* Reported by Luciano Rocha <luciano@eurotux.com> */ 1007/* Reported by Luciano Rocha <luciano@eurotux.com> */
1007UNUSUAL_DEV( 0x0840, 0x0082, 0x0001, 0x0001, 1008UNUSUAL_DEV( 0x0840, 0x0082, 0x0001, 0x0001,
1008 "Argosy", 1009 "Argosy",
1009 "Storage", 1010 "Storage",
1010 US_SC_DEVICE, US_PR_DEVICE, NULL, 1011 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1011 US_FL_FIX_CAPACITY), 1012 US_FL_FIX_CAPACITY),
1012 1013
1013/* Reported and patched by Nguyen Anh Quynh <aquynh@gmail.com> */ 1014/* Reported and patched by Nguyen Anh Quynh <aquynh@gmail.com> */
1014UNUSUAL_DEV( 0x0840, 0x0084, 0x0001, 0x0001, 1015UNUSUAL_DEV( 0x0840, 0x0084, 0x0001, 0x0001,
1015 "Argosy", 1016 "Argosy",
1016 "Storage", 1017 "Storage",
1017 US_SC_DEVICE, US_PR_DEVICE, NULL, 1018 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1018 US_FL_FIX_CAPACITY), 1019 US_FL_FIX_CAPACITY),
1019 1020
1020/* Reported by Martijn Hijdra <martijn.hijdra@gmail.com> */ 1021/* Reported by Martijn Hijdra <martijn.hijdra@gmail.com> */
1021UNUSUAL_DEV( 0x0840, 0x0085, 0x0001, 0x0001, 1022UNUSUAL_DEV( 0x0840, 0x0085, 0x0001, 0x0001,
1022 "Argosy", 1023 "Argosy",
1023 "Storage", 1024 "Storage",
1024 US_SC_DEVICE, US_PR_DEVICE, NULL, 1025 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1025 US_FL_FIX_CAPACITY), 1026 US_FL_FIX_CAPACITY),
1026 1027
1027/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 1028/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
@@ -1033,7 +1034,7 @@ UNUSUAL_DEV( 0x0840, 0x0085, 0x0001, 0x0001,
1033UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110, 1034UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110,
1034 "Grandtech", 1035 "Grandtech",
1035 "DC2MEGA", 1036 "DC2MEGA",
1036 US_SC_DEVICE, US_PR_DEVICE, NULL, 1037 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1037 US_FL_BULK32), 1038 US_FL_BULK32),
1038 1039
1039/* Andrew Lunn <andrew@lunn.ch> 1040/* Andrew Lunn <andrew@lunn.ch>
@@ -1044,14 +1045,14 @@ UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110,
1044UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200, 1045UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200,
1045 "PanDigital", 1046 "PanDigital",
1046 "Photo Frame", 1047 "Photo Frame",
1047 US_SC_DEVICE, US_PR_DEVICE, NULL, 1048 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1048 US_FL_NOT_LOCKABLE), 1049 US_FL_NOT_LOCKABLE),
1049 1050
1050/* Submitted by Jan De Luyck <lkml@kcore.org> */ 1051/* Submitted by Jan De Luyck <lkml@kcore.org> */
1051UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000, 1052UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000,
1052 "CITIZEN", 1053 "CITIZEN",
1053 "X1DE-USB", 1054 "X1DE-USB",
1054 US_SC_DEVICE, US_PR_DEVICE, NULL, 1055 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1055 US_FL_SINGLE_LUN), 1056 US_FL_SINGLE_LUN),
1056 1057
1057/* Submitted by Dylan Taft <d13f00l@gmail.com> 1058/* Submitted by Dylan Taft <d13f00l@gmail.com>
@@ -1060,7 +1061,7 @@ UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000,
1060UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100, 1061UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100,
1061 "AIPTEK", 1062 "AIPTEK",
1062 "Aiptek USB Keychain MP3 Player", 1063 "Aiptek USB Keychain MP3 Player",
1063 US_SC_DEVICE, US_PR_DEVICE, NULL, 1064 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1064 US_FL_IGNORE_RESIDUE), 1065 US_FL_IGNORE_RESIDUE),
1065 1066
1066/* Entry needed for flags. Moreover, all devices with this ID use 1067/* Entry needed for flags. Moreover, all devices with this ID use
@@ -1071,7 +1072,7 @@ UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100,
1071UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100, 1072UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100,
1072 "Trumpion", 1073 "Trumpion",
1073 "t33520 USB Flash Card Controller", 1074 "t33520 USB Flash Card Controller",
1074 US_SC_DEVICE, US_PR_BULK, NULL, 1075 USB_SC_DEVICE, USB_PR_BULK, NULL,
1075 US_FL_NEED_OVERRIDE ), 1076 US_FL_NEED_OVERRIDE ),
1076 1077
1077/* Reported by Filippo Bardelli <filibard@libero.it> 1078/* Reported by Filippo Bardelli <filibard@libero.it>
@@ -1080,21 +1081,21 @@ UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100,
1080UNUSUAL_DEV( 0x090a, 0x1050, 0x0100, 0x0100, 1081UNUSUAL_DEV( 0x090a, 0x1050, 0x0100, 0x0100,
1081 "Trumpion Microelectronics, Inc.", 1082 "Trumpion Microelectronics, Inc.",
1082 "33520 USB Digital Voice Recorder", 1083 "33520 USB Digital Voice Recorder",
1083 US_SC_UFI, US_PR_DEVICE, NULL, 1084 USB_SC_UFI, USB_PR_DEVICE, NULL,
1084 0), 1085 0),
1085 1086
1086/* Trumpion Microelectronics MP3 player (felipe_alfaro@linuxmail.org) */ 1087/* Trumpion Microelectronics MP3 player (felipe_alfaro@linuxmail.org) */
1087UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999, 1088UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999,
1088 "Trumpion", 1089 "Trumpion",
1089 "MP3 player", 1090 "MP3 player",
1090 US_SC_RBC, US_PR_BULK, NULL, 1091 USB_SC_RBC, USB_PR_BULK, NULL,
1091 0 ), 1092 0 ),
1092 1093
1093/* aeb */ 1094/* aeb */
1094UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xffff, 1095UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xffff,
1095 "Feiya", 1096 "Feiya",
1096 "5-in-1 Card Reader", 1097 "5-in-1 Card Reader",
1097 US_SC_DEVICE, US_PR_DEVICE, NULL, 1098 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1098 US_FL_FIX_CAPACITY ), 1099 US_FL_FIX_CAPACITY ),
1099 1100
1100/* This Pentax still camera is not conformant 1101/* This Pentax still camera is not conformant
@@ -1107,7 +1108,7 @@ UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xffff,
1107UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000, 1108UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
1108 "Pentax", 1109 "Pentax",
1109 "Optio 2/3/400", 1110 "Optio 2/3/400",
1110 US_SC_DEVICE, US_PR_DEVICE, NULL, 1111 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1111 US_FL_FIX_INQUIRY ), 1112 US_FL_FIX_INQUIRY ),
1112 1113
1113/* These are virtual windows driver CDs, which the zd1211rw driver 1114/* These are virtual windows driver CDs, which the zd1211rw driver
@@ -1115,13 +1116,13 @@ UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
1115UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, 1116UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
1116 "ZyXEL", 1117 "ZyXEL",
1117 "G-220F USB-WLAN Install", 1118 "G-220F USB-WLAN Install",
1118 US_SC_DEVICE, US_PR_DEVICE, NULL, 1119 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1119 US_FL_IGNORE_DEVICE ), 1120 US_FL_IGNORE_DEVICE ),
1120 1121
1121UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101, 1122UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1122 "SiteCom", 1123 "SiteCom",
1123 "WL-117 USB-WLAN Install", 1124 "WL-117 USB-WLAN Install",
1124 US_SC_DEVICE, US_PR_DEVICE, NULL, 1125 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1125 US_FL_IGNORE_DEVICE ), 1126 US_FL_IGNORE_DEVICE ),
1126 1127
1127/* Reported by Dan Williams <dcbw@redhat.com> 1128/* Reported by Dan Williams <dcbw@redhat.com>
@@ -1133,7 +1134,7 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1133UNUSUAL_DEV( 0x0af0, 0x6971, 0x0000, 0x9999, 1134UNUSUAL_DEV( 0x0af0, 0x6971, 0x0000, 0x9999,
1134 "Option N.V.", 1135 "Option N.V.",
1135 "Mass Storage", 1136 "Mass Storage",
1136 US_SC_DEVICE, US_PR_DEVICE, option_ms_init, 1137 USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init,
1137 0), 1138 0),
1138 1139
1139/* Reported by F. Aben <f.aben@option.com> 1140/* Reported by F. Aben <f.aben@option.com>
@@ -1143,7 +1144,7 @@ UNUSUAL_DEV( 0x0af0, 0x6971, 0x0000, 0x9999,
1143UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000, 1144UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1144 "Option", 1145 "Option",
1145 "GI 0401 SD-Card", 1146 "GI 0401 SD-Card",
1146 US_SC_DEVICE, US_PR_DEVICE, NULL, 1147 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1147 0 ), 1148 0 ),
1148 1149
1149/* Reported by Jan Dumon <j.dumon@option.com> 1150/* Reported by Jan Dumon <j.dumon@option.com>
@@ -1153,104 +1154,104 @@ UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1153UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000, 1154UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000,
1154 "Option", 1155 "Option",
1155 "GI 0431 SD-Card", 1156 "GI 0431 SD-Card",
1156 US_SC_DEVICE, US_PR_DEVICE, NULL, 1157 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1157 0 ), 1158 0 ),
1158 1159
1159UNUSUAL_DEV( 0x0af0, 0x7701, 0x0000, 0x0000, 1160UNUSUAL_DEV( 0x0af0, 0x7701, 0x0000, 0x0000,
1160 "Option", 1161 "Option",
1161 "GI 0451 SD-Card", 1162 "GI 0451 SD-Card",
1162 US_SC_DEVICE, US_PR_DEVICE, NULL, 1163 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1163 0 ), 1164 0 ),
1164 1165
1165UNUSUAL_DEV( 0x0af0, 0x7706, 0x0000, 0x0000, 1166UNUSUAL_DEV( 0x0af0, 0x7706, 0x0000, 0x0000,
1166 "Option", 1167 "Option",
1167 "GI 0451 SD-Card", 1168 "GI 0451 SD-Card",
1168 US_SC_DEVICE, US_PR_DEVICE, NULL, 1169 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1169 0 ), 1170 0 ),
1170 1171
1171UNUSUAL_DEV( 0x0af0, 0x7901, 0x0000, 0x0000, 1172UNUSUAL_DEV( 0x0af0, 0x7901, 0x0000, 0x0000,
1172 "Option", 1173 "Option",
1173 "GI 0452 SD-Card", 1174 "GI 0452 SD-Card",
1174 US_SC_DEVICE, US_PR_DEVICE, NULL, 1175 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1175 0 ), 1176 0 ),
1176 1177
1177UNUSUAL_DEV( 0x0af0, 0x7A01, 0x0000, 0x0000, 1178UNUSUAL_DEV( 0x0af0, 0x7A01, 0x0000, 0x0000,
1178 "Option", 1179 "Option",
1179 "GI 0461 SD-Card", 1180 "GI 0461 SD-Card",
1180 US_SC_DEVICE, US_PR_DEVICE, NULL, 1181 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1181 0 ), 1182 0 ),
1182 1183
1183UNUSUAL_DEV( 0x0af0, 0x7A05, 0x0000, 0x0000, 1184UNUSUAL_DEV( 0x0af0, 0x7A05, 0x0000, 0x0000,
1184 "Option", 1185 "Option",
1185 "GI 0461 SD-Card", 1186 "GI 0461 SD-Card",
1186 US_SC_DEVICE, US_PR_DEVICE, NULL, 1187 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1187 0 ), 1188 0 ),
1188 1189
1189UNUSUAL_DEV( 0x0af0, 0x8300, 0x0000, 0x0000, 1190UNUSUAL_DEV( 0x0af0, 0x8300, 0x0000, 0x0000,
1190 "Option", 1191 "Option",
1191 "GI 033x SD-Card", 1192 "GI 033x SD-Card",
1192 US_SC_DEVICE, US_PR_DEVICE, NULL, 1193 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1193 0 ), 1194 0 ),
1194 1195
1195UNUSUAL_DEV( 0x0af0, 0x8302, 0x0000, 0x0000, 1196UNUSUAL_DEV( 0x0af0, 0x8302, 0x0000, 0x0000,
1196 "Option", 1197 "Option",
1197 "GI 033x SD-Card", 1198 "GI 033x SD-Card",
1198 US_SC_DEVICE, US_PR_DEVICE, NULL, 1199 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1199 0 ), 1200 0 ),
1200 1201
1201UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0000, 1202UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0000,
1202 "Option", 1203 "Option",
1203 "GI 033x SD-Card", 1204 "GI 033x SD-Card",
1204 US_SC_DEVICE, US_PR_DEVICE, NULL, 1205 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1205 0 ), 1206 0 ),
1206 1207
1207UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000, 1208UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000,
1208 "Option", 1209 "Option",
1209 "GI 070x SD-Card", 1210 "GI 070x SD-Card",
1210 US_SC_DEVICE, US_PR_DEVICE, NULL, 1211 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1211 0 ), 1212 0 ),
1212 1213
1213UNUSUAL_DEV( 0x0af0, 0xd057, 0x0000, 0x0000, 1214UNUSUAL_DEV( 0x0af0, 0xd057, 0x0000, 0x0000,
1214 "Option", 1215 "Option",
1215 "GI 1505 SD-Card", 1216 "GI 1505 SD-Card",
1216 US_SC_DEVICE, US_PR_DEVICE, NULL, 1217 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1217 0 ), 1218 0 ),
1218 1219
1219UNUSUAL_DEV( 0x0af0, 0xd058, 0x0000, 0x0000, 1220UNUSUAL_DEV( 0x0af0, 0xd058, 0x0000, 0x0000,
1220 "Option", 1221 "Option",
1221 "GI 1509 SD-Card", 1222 "GI 1509 SD-Card",
1222 US_SC_DEVICE, US_PR_DEVICE, NULL, 1223 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1223 0 ), 1224 0 ),
1224 1225
1225UNUSUAL_DEV( 0x0af0, 0xd157, 0x0000, 0x0000, 1226UNUSUAL_DEV( 0x0af0, 0xd157, 0x0000, 0x0000,
1226 "Option", 1227 "Option",
1227 "GI 1515 SD-Card", 1228 "GI 1515 SD-Card",
1228 US_SC_DEVICE, US_PR_DEVICE, NULL, 1229 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1229 0 ), 1230 0 ),
1230 1231
1231UNUSUAL_DEV( 0x0af0, 0xd257, 0x0000, 0x0000, 1232UNUSUAL_DEV( 0x0af0, 0xd257, 0x0000, 0x0000,
1232 "Option", 1233 "Option",
1233 "GI 1215 SD-Card", 1234 "GI 1215 SD-Card",
1234 US_SC_DEVICE, US_PR_DEVICE, NULL, 1235 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1235 0 ), 1236 0 ),
1236 1237
1237UNUSUAL_DEV( 0x0af0, 0xd357, 0x0000, 0x0000, 1238UNUSUAL_DEV( 0x0af0, 0xd357, 0x0000, 0x0000,
1238 "Option", 1239 "Option",
1239 "GI 1505 SD-Card", 1240 "GI 1505 SD-Card",
1240 US_SC_DEVICE, US_PR_DEVICE, NULL, 1241 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1241 0 ), 1242 0 ),
1242 1243
1243/* Reported by Ben Efros <ben@pc-doctor.com> */ 1244/* Reported by Ben Efros <ben@pc-doctor.com> */
1244UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000, 1245UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000,
1245 "Seagate", 1246 "Seagate",
1246 "FreeAgent Pro", 1247 "FreeAgent Pro",
1247 US_SC_DEVICE, US_PR_DEVICE, NULL, 1248 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1248 US_FL_SANE_SENSE ), 1249 US_FL_SANE_SENSE ),
1249 1250
1250UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999, 1251UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999,
1251 "Maxtor", 1252 "Maxtor",
1252 "USB to SATA", 1253 "USB to SATA",
1253 US_SC_DEVICE, US_PR_DEVICE, NULL, 1254 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1254 US_FL_SANE_SENSE), 1255 US_FL_SANE_SENSE),
1255 1256
1256/* 1257/*
@@ -1260,14 +1261,14 @@ UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999,
1260UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100, 1261UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100,
1261 "Unknown", 1262 "Unknown",
1262 "Unknown", 1263 "Unknown",
1263 US_SC_DEVICE, US_PR_DEVICE, NULL, 1264 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1264 US_FL_SINGLE_LUN ), 1265 US_FL_SINGLE_LUN ),
1265 1266
1266/* Submitted by Joris Struyve <joris@struyve.be> */ 1267/* Submitted by Joris Struyve <joris@struyve.be> */
1267UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, 1268UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1268 "Medion", 1269 "Medion",
1269 "MD 7425", 1270 "MD 7425",
1270 US_SC_DEVICE, US_PR_DEVICE, NULL, 1271 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1271 US_FL_FIX_INQUIRY), 1272 US_FL_FIX_INQUIRY),
1272 1273
1273/* 1274/*
@@ -1278,13 +1279,13 @@ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1278UNUSUAL_DEV( 0x0d96, 0x5200, 0x0001, 0x0200, 1279UNUSUAL_DEV( 0x0d96, 0x5200, 0x0001, 0x0200,
1279 "Jenoptik", 1280 "Jenoptik",
1280 "JD 5200 z3", 1281 "JD 5200 z3",
1281 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY), 1282 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
1282 1283
1283/* Reported by Jason Johnston <killean@shaw.ca> */ 1284/* Reported by Jason Johnston <killean@shaw.ca> */
1284UNUSUAL_DEV( 0x0dc4, 0x0073, 0x0000, 0x0000, 1285UNUSUAL_DEV( 0x0dc4, 0x0073, 0x0000, 0x0000,
1285 "Macpower Technology Co.LTD.", 1286 "Macpower Technology Co.LTD.",
1286 "USB 2.0 3.5\" DEVICE", 1287 "USB 2.0 3.5\" DEVICE",
1287 US_SC_DEVICE, US_PR_DEVICE, NULL, 1288 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1288 US_FL_FIX_CAPACITY), 1289 US_FL_FIX_CAPACITY),
1289 1290
1290/* Reported by Lubomir Blaha <tritol@trilogic.cz> 1291/* Reported by Lubomir Blaha <tritol@trilogic.cz>
@@ -1295,7 +1296,7 @@ UNUSUAL_DEV( 0x0dc4, 0x0073, 0x0000, 0x0000,
1295UNUSUAL_DEV( 0x0dd8, 0x1060, 0x0000, 0xffff, 1296UNUSUAL_DEV( 0x0dd8, 0x1060, 0x0000, 0xffff,
1296 "Netac", 1297 "Netac",
1297 "USB-CF-Card", 1298 "USB-CF-Card",
1298 US_SC_DEVICE, US_PR_DEVICE, NULL, 1299 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1299 US_FL_FIX_INQUIRY ), 1300 US_FL_FIX_INQUIRY ),
1300 1301
1301/* Reported by Edward Chapman (taken from linux-usb mailing list) 1302/* Reported by Edward Chapman (taken from linux-usb mailing list)
@@ -1303,7 +1304,7 @@ UNUSUAL_DEV( 0x0dd8, 0x1060, 0x0000, 0xffff,
1303UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999, 1304UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999,
1304 "Netac", 1305 "Netac",
1305 "USB Flash Disk", 1306 "USB Flash Disk",
1306 US_SC_DEVICE, US_PR_DEVICE, NULL, 1307 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1307 US_FL_IGNORE_RESIDUE ), 1308 US_FL_IGNORE_RESIDUE ),
1308 1309
1309 1310
@@ -1312,28 +1313,28 @@ UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999,
1312UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012, 1313UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012,
1313 "WINWARD", 1314 "WINWARD",
1314 "Music Disk", 1315 "Music Disk",
1315 US_SC_DEVICE, US_PR_DEVICE, NULL, 1316 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1316 US_FL_IGNORE_RESIDUE ), 1317 US_FL_IGNORE_RESIDUE ),
1317 1318
1318/* Reported by Ian McConnell <ian at emit.demon.co.uk> */ 1319/* Reported by Ian McConnell <ian at emit.demon.co.uk> */
1319UNUSUAL_DEV( 0x0dda, 0x0301, 0x0012, 0x0012, 1320UNUSUAL_DEV( 0x0dda, 0x0301, 0x0012, 0x0012,
1320 "PNP_MP3", 1321 "PNP_MP3",
1321 "PNP_MP3 PLAYER", 1322 "PNP_MP3 PLAYER",
1322 US_SC_DEVICE, US_PR_DEVICE, NULL, 1323 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1323 US_FL_IGNORE_RESIDUE ), 1324 US_FL_IGNORE_RESIDUE ),
1324 1325
1325/* Reported by Jim McCloskey <mcclosk@ucsc.edu> */ 1326/* Reported by Jim McCloskey <mcclosk@ucsc.edu> */
1326UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100, 1327UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100,
1327 "Cowon Systems", 1328 "Cowon Systems",
1328 "iAUDIO M5", 1329 "iAUDIO M5",
1329 US_SC_DEVICE, US_PR_BULK, NULL, 1330 USB_SC_DEVICE, USB_PR_BULK, NULL,
1330 US_FL_NEED_OVERRIDE ), 1331 US_FL_NEED_OVERRIDE ),
1331 1332
1332/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */ 1333/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
1333UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300, 1334UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
1334 "USB", 1335 "USB",
1335 "Solid state disk", 1336 "Solid state disk",
1336 US_SC_DEVICE, US_PR_DEVICE, NULL, 1337 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1337 US_FL_FIX_INQUIRY ), 1338 US_FL_FIX_INQUIRY ),
1338 1339
1339/* Submitted by Daniel Drake <dsd@gentoo.org> 1340/* Submitted by Daniel Drake <dsd@gentoo.org>
@@ -1341,14 +1342,14 @@ UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
1341UNUSUAL_DEV( 0x0ea0, 0x2168, 0x0110, 0x0110, 1342UNUSUAL_DEV( 0x0ea0, 0x2168, 0x0110, 0x0110,
1342 "Ours Technology", 1343 "Ours Technology",
1343 "Flash Disk", 1344 "Flash Disk",
1344 US_SC_DEVICE, US_PR_DEVICE, NULL, 1345 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1345 US_FL_IGNORE_RESIDUE ), 1346 US_FL_IGNORE_RESIDUE ),
1346 1347
1347/* Reported by Rastislav Stanik <rs_kernel@yahoo.com> */ 1348/* Reported by Rastislav Stanik <rs_kernel@yahoo.com> */
1348UNUSUAL_DEV( 0x0ea0, 0x6828, 0x0110, 0x0110, 1349UNUSUAL_DEV( 0x0ea0, 0x6828, 0x0110, 0x0110,
1349 "USB", 1350 "USB",
1350 "Flash Disk", 1351 "Flash Disk",
1351 US_SC_DEVICE, US_PR_DEVICE, NULL, 1352 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1352 US_FL_IGNORE_RESIDUE ), 1353 US_FL_IGNORE_RESIDUE ),
1353 1354
1354/* Reported by Benjamin Schiller <sbenni@gmx.de> 1355/* Reported by Benjamin Schiller <sbenni@gmx.de>
@@ -1356,7 +1357,7 @@ UNUSUAL_DEV( 0x0ea0, 0x6828, 0x0110, 0x0110,
1356UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103, 1357UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103,
1357 "Typhoon", 1358 "Typhoon",
1358 "My DJ 1820", 1359 "My DJ 1820",
1359 US_SC_DEVICE, US_PR_DEVICE, NULL, 1360 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1360 US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64), 1361 US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64),
1361 1362
1362/* Patch by Leonid Petrov mail at lpetrov.net 1363/* Patch by Leonid Petrov mail at lpetrov.net
@@ -1367,7 +1368,7 @@ UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103,
1367UNUSUAL_DEV( 0x0f19, 0x0103, 0x0100, 0x0100, 1368UNUSUAL_DEV( 0x0f19, 0x0103, 0x0100, 0x0100,
1368 "Oracom Co., Ltd", 1369 "Oracom Co., Ltd",
1369 "ORC-200M", 1370 "ORC-200M",
1370 US_SC_DEVICE, US_PR_DEVICE, NULL, 1371 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1371 US_FL_IGNORE_RESIDUE ), 1372 US_FL_IGNORE_RESIDUE ),
1372 1373
1373/* David Kuehling <dvdkhlng@gmx.de>: 1374/* David Kuehling <dvdkhlng@gmx.de>:
@@ -1377,21 +1378,21 @@ UNUSUAL_DEV( 0x0f19, 0x0103, 0x0100, 0x0100,
1377UNUSUAL_DEV( 0x0f19, 0x0105, 0x0100, 0x0100, 1378UNUSUAL_DEV( 0x0f19, 0x0105, 0x0100, 0x0100,
1378 "C-MEX", 1379 "C-MEX",
1379 "A-VOX", 1380 "A-VOX",
1380 US_SC_DEVICE, US_PR_DEVICE, NULL, 1381 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1381 US_FL_IGNORE_RESIDUE ), 1382 US_FL_IGNORE_RESIDUE ),
1382 1383
1383/* Reported by Michael Stattmann <michael@stattmann.com> */ 1384/* Reported by Michael Stattmann <michael@stattmann.com> */
1384UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000, 1385UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
1385 "Sony Ericsson", 1386 "Sony Ericsson",
1386 "V800-Vodafone 802", 1387 "V800-Vodafone 802",
1387 US_SC_DEVICE, US_PR_DEVICE, NULL, 1388 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1388 US_FL_NO_WP_DETECT ), 1389 US_FL_NO_WP_DETECT ),
1389 1390
1390/* Reported by The Solutor <thesolutor@gmail.com> */ 1391/* Reported by The Solutor <thesolutor@gmail.com> */
1391UNUSUAL_DEV( 0x0fce, 0xd0e1, 0x0000, 0x0000, 1392UNUSUAL_DEV( 0x0fce, 0xd0e1, 0x0000, 0x0000,
1392 "Sony Ericsson", 1393 "Sony Ericsson",
1393 "MD400", 1394 "MD400",
1394 US_SC_DEVICE, US_PR_DEVICE, NULL, 1395 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1395 US_FL_IGNORE_DEVICE), 1396 US_FL_IGNORE_DEVICE),
1396 1397
1397/* Reported by Jan Mate <mate@fiit.stuba.sk> 1398/* Reported by Jan Mate <mate@fiit.stuba.sk>
@@ -1399,21 +1400,21 @@ UNUSUAL_DEV( 0x0fce, 0xd0e1, 0x0000, 0x0000,
1399UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000, 1400UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1400 "Sony Ericsson", 1401 "Sony Ericsson",
1401 "P990i", 1402 "P990i",
1402 US_SC_DEVICE, US_PR_DEVICE, NULL, 1403 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1403 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), 1404 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
1404 1405
1405/* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */ 1406/* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */
1406UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000, 1407UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000,
1407 "Sony Ericsson", 1408 "Sony Ericsson",
1408 "M600i", 1409 "M600i",
1409 US_SC_DEVICE, US_PR_DEVICE, NULL, 1410 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1410 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 1411 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
1411 1412
1412/* Reported by Ricardo Barberis <ricardo@dattatec.com> */ 1413/* Reported by Ricardo Barberis <ricardo@dattatec.com> */
1413UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000, 1414UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000,
1414 "Sony Ericsson", 1415 "Sony Ericsson",
1415 "P1i", 1416 "P1i",
1416 US_SC_DEVICE, US_PR_DEVICE, NULL, 1417 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1417 US_FL_IGNORE_RESIDUE ), 1418 US_FL_IGNORE_RESIDUE ),
1418 1419
1419/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1420/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
@@ -1425,13 +1426,13 @@ UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000,
1425UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110, 1426UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1426 "Desknote", 1427 "Desknote",
1427 "UCR-61S2B", 1428 "UCR-61S2B",
1428 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1429 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_ucr61s2b_init,
1429 0 ), 1430 0 ),
1430 1431
1431UNUSUAL_DEV( 0x1058, 0x0704, 0x0000, 0x9999, 1432UNUSUAL_DEV( 0x1058, 0x0704, 0x0000, 0x9999,
1432 "Western Digital", 1433 "Western Digital",
1433 "External HDD", 1434 "External HDD",
1434 US_SC_DEVICE, US_PR_DEVICE, NULL, 1435 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1435 US_FL_SANE_SENSE), 1436 US_FL_SANE_SENSE),
1436 1437
1437/* Reported by Fabio Venturi <f.venturi@tdnet.it> 1438/* Reported by Fabio Venturi <f.venturi@tdnet.it>
@@ -1440,7 +1441,7 @@ UNUSUAL_DEV( 0x1058, 0x0704, 0x0000, 0x9999,
1440UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100, 1441UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100,
1441 "Actions Semiconductor", 1442 "Actions Semiconductor",
1442 "Mtp device", 1443 "Mtp device",
1443 US_SC_DEVICE, US_PR_DEVICE, NULL, 1444 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1444 0), 1445 0),
1445 1446
1446/* Reported by Pascal Terjan <pterjan@mandriva.com> 1447/* Reported by Pascal Terjan <pterjan@mandriva.com>
@@ -1449,7 +1450,7 @@ UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100,
1449UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000, 1450UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000,
1450 "D-Link", 1451 "D-Link",
1451 "USB Mass Storage", 1452 "USB Mass Storage",
1452 US_SC_DEVICE, US_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE), 1453 USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE),
1453 1454
1454/* Reported by Kevin Lloyd <linux@sierrawireless.com> 1455/* Reported by Kevin Lloyd <linux@sierrawireless.com>
1455 * Entry is needed for the initializer function override, 1456 * Entry is needed for the initializer function override,
@@ -1459,7 +1460,7 @@ UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000,
1459UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999, 1460UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999,
1460 "Sierra Wireless", 1461 "Sierra Wireless",
1461 "USB MMC Storage", 1462 "USB MMC Storage",
1462 US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init, 1463 USB_SC_DEVICE, USB_PR_DEVICE, sierra_ms_init,
1463 0), 1464 0),
1464 1465
1465/* Reported by Jaco Kroon <jaco@kroon.co.za> 1466/* Reported by Jaco Kroon <jaco@kroon.co.za>
@@ -1469,7 +1470,7 @@ UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999,
1469UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100, 1470UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
1470 "Digitech HMG", 1471 "Digitech HMG",
1471 "DigiTech Mass Storage", 1472 "DigiTech Mass Storage",
1472 US_SC_DEVICE, US_PR_DEVICE, NULL, 1473 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1473 US_FL_IGNORE_RESIDUE ), 1474 US_FL_IGNORE_RESIDUE ),
1474 1475
1475/* Reported by fangxiaozhi <huananhu@huawei.com> 1476/* Reported by fangxiaozhi <huananhu@huawei.com>
@@ -1478,353 +1479,353 @@ UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
1478UNUSUAL_DEV( 0x12d1, 0x1001, 0x0000, 0x0000, 1479UNUSUAL_DEV( 0x12d1, 0x1001, 0x0000, 0x0000,
1479 "HUAWEI MOBILE", 1480 "HUAWEI MOBILE",
1480 "Mass Storage", 1481 "Mass Storage",
1481 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1482 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1482 0), 1483 0),
1483UNUSUAL_DEV( 0x12d1, 0x1003, 0x0000, 0x0000, 1484UNUSUAL_DEV( 0x12d1, 0x1003, 0x0000, 0x0000,
1484 "HUAWEI MOBILE", 1485 "HUAWEI MOBILE",
1485 "Mass Storage", 1486 "Mass Storage",
1486 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1487 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1487 0), 1488 0),
1488UNUSUAL_DEV( 0x12d1, 0x1004, 0x0000, 0x0000, 1489UNUSUAL_DEV( 0x12d1, 0x1004, 0x0000, 0x0000,
1489 "HUAWEI MOBILE", 1490 "HUAWEI MOBILE",
1490 "Mass Storage", 1491 "Mass Storage",
1491 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1492 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1492 0), 1493 0),
1493UNUSUAL_DEV( 0x12d1, 0x1401, 0x0000, 0x0000, 1494UNUSUAL_DEV( 0x12d1, 0x1401, 0x0000, 0x0000,
1494 "HUAWEI MOBILE", 1495 "HUAWEI MOBILE",
1495 "Mass Storage", 1496 "Mass Storage",
1496 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1497 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1497 0), 1498 0),
1498UNUSUAL_DEV( 0x12d1, 0x1402, 0x0000, 0x0000, 1499UNUSUAL_DEV( 0x12d1, 0x1402, 0x0000, 0x0000,
1499 "HUAWEI MOBILE", 1500 "HUAWEI MOBILE",
1500 "Mass Storage", 1501 "Mass Storage",
1501 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1502 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1502 0), 1503 0),
1503UNUSUAL_DEV( 0x12d1, 0x1403, 0x0000, 0x0000, 1504UNUSUAL_DEV( 0x12d1, 0x1403, 0x0000, 0x0000,
1504 "HUAWEI MOBILE", 1505 "HUAWEI MOBILE",
1505 "Mass Storage", 1506 "Mass Storage",
1506 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1507 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1507 0), 1508 0),
1508UNUSUAL_DEV( 0x12d1, 0x1404, 0x0000, 0x0000, 1509UNUSUAL_DEV( 0x12d1, 0x1404, 0x0000, 0x0000,
1509 "HUAWEI MOBILE", 1510 "HUAWEI MOBILE",
1510 "Mass Storage", 1511 "Mass Storage",
1511 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1512 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1512 0), 1513 0),
1513UNUSUAL_DEV( 0x12d1, 0x1405, 0x0000, 0x0000, 1514UNUSUAL_DEV( 0x12d1, 0x1405, 0x0000, 0x0000,
1514 "HUAWEI MOBILE", 1515 "HUAWEI MOBILE",
1515 "Mass Storage", 1516 "Mass Storage",
1516 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1517 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1517 0), 1518 0),
1518UNUSUAL_DEV( 0x12d1, 0x1406, 0x0000, 0x0000, 1519UNUSUAL_DEV( 0x12d1, 0x1406, 0x0000, 0x0000,
1519 "HUAWEI MOBILE", 1520 "HUAWEI MOBILE",
1520 "Mass Storage", 1521 "Mass Storage",
1521 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1522 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1522 0), 1523 0),
1523UNUSUAL_DEV( 0x12d1, 0x1407, 0x0000, 0x0000, 1524UNUSUAL_DEV( 0x12d1, 0x1407, 0x0000, 0x0000,
1524 "HUAWEI MOBILE", 1525 "HUAWEI MOBILE",
1525 "Mass Storage", 1526 "Mass Storage",
1526 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1527 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1527 0), 1528 0),
1528UNUSUAL_DEV( 0x12d1, 0x1408, 0x0000, 0x0000, 1529UNUSUAL_DEV( 0x12d1, 0x1408, 0x0000, 0x0000,
1529 "HUAWEI MOBILE", 1530 "HUAWEI MOBILE",
1530 "Mass Storage", 1531 "Mass Storage",
1531 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1532 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1532 0), 1533 0),
1533UNUSUAL_DEV( 0x12d1, 0x1409, 0x0000, 0x0000, 1534UNUSUAL_DEV( 0x12d1, 0x1409, 0x0000, 0x0000,
1534 "HUAWEI MOBILE", 1535 "HUAWEI MOBILE",
1535 "Mass Storage", 1536 "Mass Storage",
1536 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1537 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1537 0), 1538 0),
1538UNUSUAL_DEV( 0x12d1, 0x140A, 0x0000, 0x0000, 1539UNUSUAL_DEV( 0x12d1, 0x140A, 0x0000, 0x0000,
1539 "HUAWEI MOBILE", 1540 "HUAWEI MOBILE",
1540 "Mass Storage", 1541 "Mass Storage",
1541 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1542 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1542 0), 1543 0),
1543UNUSUAL_DEV( 0x12d1, 0x140B, 0x0000, 0x0000, 1544UNUSUAL_DEV( 0x12d1, 0x140B, 0x0000, 0x0000,
1544 "HUAWEI MOBILE", 1545 "HUAWEI MOBILE",
1545 "Mass Storage", 1546 "Mass Storage",
1546 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1547 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1547 0), 1548 0),
1548UNUSUAL_DEV( 0x12d1, 0x140C, 0x0000, 0x0000, 1549UNUSUAL_DEV( 0x12d1, 0x140C, 0x0000, 0x0000,
1549 "HUAWEI MOBILE", 1550 "HUAWEI MOBILE",
1550 "Mass Storage", 1551 "Mass Storage",
1551 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1552 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1552 0), 1553 0),
1553UNUSUAL_DEV( 0x12d1, 0x140D, 0x0000, 0x0000, 1554UNUSUAL_DEV( 0x12d1, 0x140D, 0x0000, 0x0000,
1554 "HUAWEI MOBILE", 1555 "HUAWEI MOBILE",
1555 "Mass Storage", 1556 "Mass Storage",
1556 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1557 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1557 0), 1558 0),
1558UNUSUAL_DEV( 0x12d1, 0x140E, 0x0000, 0x0000, 1559UNUSUAL_DEV( 0x12d1, 0x140E, 0x0000, 0x0000,
1559 "HUAWEI MOBILE", 1560 "HUAWEI MOBILE",
1560 "Mass Storage", 1561 "Mass Storage",
1561 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1562 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1562 0), 1563 0),
1563UNUSUAL_DEV( 0x12d1, 0x140F, 0x0000, 0x0000, 1564UNUSUAL_DEV( 0x12d1, 0x140F, 0x0000, 0x0000,
1564 "HUAWEI MOBILE", 1565 "HUAWEI MOBILE",
1565 "Mass Storage", 1566 "Mass Storage",
1566 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1567 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1567 0), 1568 0),
1568UNUSUAL_DEV( 0x12d1, 0x1410, 0x0000, 0x0000, 1569UNUSUAL_DEV( 0x12d1, 0x1410, 0x0000, 0x0000,
1569 "HUAWEI MOBILE", 1570 "HUAWEI MOBILE",
1570 "Mass Storage", 1571 "Mass Storage",
1571 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1572 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1572 0), 1573 0),
1573UNUSUAL_DEV( 0x12d1, 0x1411, 0x0000, 0x0000, 1574UNUSUAL_DEV( 0x12d1, 0x1411, 0x0000, 0x0000,
1574 "HUAWEI MOBILE", 1575 "HUAWEI MOBILE",
1575 "Mass Storage", 1576 "Mass Storage",
1576 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1577 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1577 0), 1578 0),
1578UNUSUAL_DEV( 0x12d1, 0x1412, 0x0000, 0x0000, 1579UNUSUAL_DEV( 0x12d1, 0x1412, 0x0000, 0x0000,
1579 "HUAWEI MOBILE", 1580 "HUAWEI MOBILE",
1580 "Mass Storage", 1581 "Mass Storage",
1581 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1582 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1582 0), 1583 0),
1583UNUSUAL_DEV( 0x12d1, 0x1413, 0x0000, 0x0000, 1584UNUSUAL_DEV( 0x12d1, 0x1413, 0x0000, 0x0000,
1584 "HUAWEI MOBILE", 1585 "HUAWEI MOBILE",
1585 "Mass Storage", 1586 "Mass Storage",
1586 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1587 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1587 0), 1588 0),
1588UNUSUAL_DEV( 0x12d1, 0x1414, 0x0000, 0x0000, 1589UNUSUAL_DEV( 0x12d1, 0x1414, 0x0000, 0x0000,
1589 "HUAWEI MOBILE", 1590 "HUAWEI MOBILE",
1590 "Mass Storage", 1591 "Mass Storage",
1591 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1592 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1592 0), 1593 0),
1593UNUSUAL_DEV( 0x12d1, 0x1415, 0x0000, 0x0000, 1594UNUSUAL_DEV( 0x12d1, 0x1415, 0x0000, 0x0000,
1594 "HUAWEI MOBILE", 1595 "HUAWEI MOBILE",
1595 "Mass Storage", 1596 "Mass Storage",
1596 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1597 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1597 0), 1598 0),
1598UNUSUAL_DEV( 0x12d1, 0x1416, 0x0000, 0x0000, 1599UNUSUAL_DEV( 0x12d1, 0x1416, 0x0000, 0x0000,
1599 "HUAWEI MOBILE", 1600 "HUAWEI MOBILE",
1600 "Mass Storage", 1601 "Mass Storage",
1601 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1602 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1602 0), 1603 0),
1603UNUSUAL_DEV( 0x12d1, 0x1417, 0x0000, 0x0000, 1604UNUSUAL_DEV( 0x12d1, 0x1417, 0x0000, 0x0000,
1604 "HUAWEI MOBILE", 1605 "HUAWEI MOBILE",
1605 "Mass Storage", 1606 "Mass Storage",
1606 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1607 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1607 0), 1608 0),
1608UNUSUAL_DEV( 0x12d1, 0x1418, 0x0000, 0x0000, 1609UNUSUAL_DEV( 0x12d1, 0x1418, 0x0000, 0x0000,
1609 "HUAWEI MOBILE", 1610 "HUAWEI MOBILE",
1610 "Mass Storage", 1611 "Mass Storage",
1611 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1612 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1612 0), 1613 0),
1613UNUSUAL_DEV( 0x12d1, 0x1419, 0x0000, 0x0000, 1614UNUSUAL_DEV( 0x12d1, 0x1419, 0x0000, 0x0000,
1614 "HUAWEI MOBILE", 1615 "HUAWEI MOBILE",
1615 "Mass Storage", 1616 "Mass Storage",
1616 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1617 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1617 0), 1618 0),
1618UNUSUAL_DEV( 0x12d1, 0x141A, 0x0000, 0x0000, 1619UNUSUAL_DEV( 0x12d1, 0x141A, 0x0000, 0x0000,
1619 "HUAWEI MOBILE", 1620 "HUAWEI MOBILE",
1620 "Mass Storage", 1621 "Mass Storage",
1621 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1622 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1622 0), 1623 0),
1623UNUSUAL_DEV( 0x12d1, 0x141B, 0x0000, 0x0000, 1624UNUSUAL_DEV( 0x12d1, 0x141B, 0x0000, 0x0000,
1624 "HUAWEI MOBILE", 1625 "HUAWEI MOBILE",
1625 "Mass Storage", 1626 "Mass Storage",
1626 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1627 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1627 0), 1628 0),
1628UNUSUAL_DEV( 0x12d1, 0x141C, 0x0000, 0x0000, 1629UNUSUAL_DEV( 0x12d1, 0x141C, 0x0000, 0x0000,
1629 "HUAWEI MOBILE", 1630 "HUAWEI MOBILE",
1630 "Mass Storage", 1631 "Mass Storage",
1631 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1632 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1632 0), 1633 0),
1633UNUSUAL_DEV( 0x12d1, 0x141D, 0x0000, 0x0000, 1634UNUSUAL_DEV( 0x12d1, 0x141D, 0x0000, 0x0000,
1634 "HUAWEI MOBILE", 1635 "HUAWEI MOBILE",
1635 "Mass Storage", 1636 "Mass Storage",
1636 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1637 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1637 0), 1638 0),
1638UNUSUAL_DEV( 0x12d1, 0x141E, 0x0000, 0x0000, 1639UNUSUAL_DEV( 0x12d1, 0x141E, 0x0000, 0x0000,
1639 "HUAWEI MOBILE", 1640 "HUAWEI MOBILE",
1640 "Mass Storage", 1641 "Mass Storage",
1641 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1642 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1642 0), 1643 0),
1643UNUSUAL_DEV( 0x12d1, 0x141F, 0x0000, 0x0000, 1644UNUSUAL_DEV( 0x12d1, 0x141F, 0x0000, 0x0000,
1644 "HUAWEI MOBILE", 1645 "HUAWEI MOBILE",
1645 "Mass Storage", 1646 "Mass Storage",
1646 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1647 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1647 0), 1648 0),
1648UNUSUAL_DEV( 0x12d1, 0x1420, 0x0000, 0x0000, 1649UNUSUAL_DEV( 0x12d1, 0x1420, 0x0000, 0x0000,
1649 "HUAWEI MOBILE", 1650 "HUAWEI MOBILE",
1650 "Mass Storage", 1651 "Mass Storage",
1651 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1652 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1652 0), 1653 0),
1653UNUSUAL_DEV( 0x12d1, 0x1421, 0x0000, 0x0000, 1654UNUSUAL_DEV( 0x12d1, 0x1421, 0x0000, 0x0000,
1654 "HUAWEI MOBILE", 1655 "HUAWEI MOBILE",
1655 "Mass Storage", 1656 "Mass Storage",
1656 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1657 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1657 0), 1658 0),
1658UNUSUAL_DEV( 0x12d1, 0x1422, 0x0000, 0x0000, 1659UNUSUAL_DEV( 0x12d1, 0x1422, 0x0000, 0x0000,
1659 "HUAWEI MOBILE", 1660 "HUAWEI MOBILE",
1660 "Mass Storage", 1661 "Mass Storage",
1661 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1662 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1662 0), 1663 0),
1663UNUSUAL_DEV( 0x12d1, 0x1423, 0x0000, 0x0000, 1664UNUSUAL_DEV( 0x12d1, 0x1423, 0x0000, 0x0000,
1664 "HUAWEI MOBILE", 1665 "HUAWEI MOBILE",
1665 "Mass Storage", 1666 "Mass Storage",
1666 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1667 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1667 0), 1668 0),
1668UNUSUAL_DEV( 0x12d1, 0x1424, 0x0000, 0x0000, 1669UNUSUAL_DEV( 0x12d1, 0x1424, 0x0000, 0x0000,
1669 "HUAWEI MOBILE", 1670 "HUAWEI MOBILE",
1670 "Mass Storage", 1671 "Mass Storage",
1671 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1672 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1672 0), 1673 0),
1673UNUSUAL_DEV( 0x12d1, 0x1425, 0x0000, 0x0000, 1674UNUSUAL_DEV( 0x12d1, 0x1425, 0x0000, 0x0000,
1674 "HUAWEI MOBILE", 1675 "HUAWEI MOBILE",
1675 "Mass Storage", 1676 "Mass Storage",
1676 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1677 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1677 0), 1678 0),
1678UNUSUAL_DEV( 0x12d1, 0x1426, 0x0000, 0x0000, 1679UNUSUAL_DEV( 0x12d1, 0x1426, 0x0000, 0x0000,
1679 "HUAWEI MOBILE", 1680 "HUAWEI MOBILE",
1680 "Mass Storage", 1681 "Mass Storage",
1681 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1682 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1682 0), 1683 0),
1683UNUSUAL_DEV( 0x12d1, 0x1427, 0x0000, 0x0000, 1684UNUSUAL_DEV( 0x12d1, 0x1427, 0x0000, 0x0000,
1684 "HUAWEI MOBILE", 1685 "HUAWEI MOBILE",
1685 "Mass Storage", 1686 "Mass Storage",
1686 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1687 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1687 0), 1688 0),
1688UNUSUAL_DEV( 0x12d1, 0x1428, 0x0000, 0x0000, 1689UNUSUAL_DEV( 0x12d1, 0x1428, 0x0000, 0x0000,
1689 "HUAWEI MOBILE", 1690 "HUAWEI MOBILE",
1690 "Mass Storage", 1691 "Mass Storage",
1691 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1692 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1692 0), 1693 0),
1693UNUSUAL_DEV( 0x12d1, 0x1429, 0x0000, 0x0000, 1694UNUSUAL_DEV( 0x12d1, 0x1429, 0x0000, 0x0000,
1694 "HUAWEI MOBILE", 1695 "HUAWEI MOBILE",
1695 "Mass Storage", 1696 "Mass Storage",
1696 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1697 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1697 0), 1698 0),
1698UNUSUAL_DEV( 0x12d1, 0x142A, 0x0000, 0x0000, 1699UNUSUAL_DEV( 0x12d1, 0x142A, 0x0000, 0x0000,
1699 "HUAWEI MOBILE", 1700 "HUAWEI MOBILE",
1700 "Mass Storage", 1701 "Mass Storage",
1701 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1702 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1702 0), 1703 0),
1703UNUSUAL_DEV( 0x12d1, 0x142B, 0x0000, 0x0000, 1704UNUSUAL_DEV( 0x12d1, 0x142B, 0x0000, 0x0000,
1704 "HUAWEI MOBILE", 1705 "HUAWEI MOBILE",
1705 "Mass Storage", 1706 "Mass Storage",
1706 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1707 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1707 0), 1708 0),
1708UNUSUAL_DEV( 0x12d1, 0x142C, 0x0000, 0x0000, 1709UNUSUAL_DEV( 0x12d1, 0x142C, 0x0000, 0x0000,
1709 "HUAWEI MOBILE", 1710 "HUAWEI MOBILE",
1710 "Mass Storage", 1711 "Mass Storage",
1711 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1712 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1712 0), 1713 0),
1713UNUSUAL_DEV( 0x12d1, 0x142D, 0x0000, 0x0000, 1714UNUSUAL_DEV( 0x12d1, 0x142D, 0x0000, 0x0000,
1714 "HUAWEI MOBILE", 1715 "HUAWEI MOBILE",
1715 "Mass Storage", 1716 "Mass Storage",
1716 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1717 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1717 0), 1718 0),
1718UNUSUAL_DEV( 0x12d1, 0x142E, 0x0000, 0x0000, 1719UNUSUAL_DEV( 0x12d1, 0x142E, 0x0000, 0x0000,
1719 "HUAWEI MOBILE", 1720 "HUAWEI MOBILE",
1720 "Mass Storage", 1721 "Mass Storage",
1721 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1722 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1722 0), 1723 0),
1723UNUSUAL_DEV( 0x12d1, 0x142F, 0x0000, 0x0000, 1724UNUSUAL_DEV( 0x12d1, 0x142F, 0x0000, 0x0000,
1724 "HUAWEI MOBILE", 1725 "HUAWEI MOBILE",
1725 "Mass Storage", 1726 "Mass Storage",
1726 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1727 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1727 0), 1728 0),
1728UNUSUAL_DEV( 0x12d1, 0x1430, 0x0000, 0x0000, 1729UNUSUAL_DEV( 0x12d1, 0x1430, 0x0000, 0x0000,
1729 "HUAWEI MOBILE", 1730 "HUAWEI MOBILE",
1730 "Mass Storage", 1731 "Mass Storage",
1731 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1732 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1732 0), 1733 0),
1733UNUSUAL_DEV( 0x12d1, 0x1431, 0x0000, 0x0000, 1734UNUSUAL_DEV( 0x12d1, 0x1431, 0x0000, 0x0000,
1734 "HUAWEI MOBILE", 1735 "HUAWEI MOBILE",
1735 "Mass Storage", 1736 "Mass Storage",
1736 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1737 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1737 0), 1738 0),
1738UNUSUAL_DEV( 0x12d1, 0x1432, 0x0000, 0x0000, 1739UNUSUAL_DEV( 0x12d1, 0x1432, 0x0000, 0x0000,
1739 "HUAWEI MOBILE", 1740 "HUAWEI MOBILE",
1740 "Mass Storage", 1741 "Mass Storage",
1741 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1742 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1742 0), 1743 0),
1743UNUSUAL_DEV( 0x12d1, 0x1433, 0x0000, 0x0000, 1744UNUSUAL_DEV( 0x12d1, 0x1433, 0x0000, 0x0000,
1744 "HUAWEI MOBILE", 1745 "HUAWEI MOBILE",
1745 "Mass Storage", 1746 "Mass Storage",
1746 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1747 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1747 0), 1748 0),
1748UNUSUAL_DEV( 0x12d1, 0x1434, 0x0000, 0x0000, 1749UNUSUAL_DEV( 0x12d1, 0x1434, 0x0000, 0x0000,
1749 "HUAWEI MOBILE", 1750 "HUAWEI MOBILE",
1750 "Mass Storage", 1751 "Mass Storage",
1751 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1752 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1752 0), 1753 0),
1753UNUSUAL_DEV( 0x12d1, 0x1435, 0x0000, 0x0000, 1754UNUSUAL_DEV( 0x12d1, 0x1435, 0x0000, 0x0000,
1754 "HUAWEI MOBILE", 1755 "HUAWEI MOBILE",
1755 "Mass Storage", 1756 "Mass Storage",
1756 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1757 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1757 0), 1758 0),
1758UNUSUAL_DEV( 0x12d1, 0x1436, 0x0000, 0x0000, 1759UNUSUAL_DEV( 0x12d1, 0x1436, 0x0000, 0x0000,
1759 "HUAWEI MOBILE", 1760 "HUAWEI MOBILE",
1760 "Mass Storage", 1761 "Mass Storage",
1761 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1762 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1762 0), 1763 0),
1763UNUSUAL_DEV( 0x12d1, 0x1437, 0x0000, 0x0000, 1764UNUSUAL_DEV( 0x12d1, 0x1437, 0x0000, 0x0000,
1764 "HUAWEI MOBILE", 1765 "HUAWEI MOBILE",
1765 "Mass Storage", 1766 "Mass Storage",
1766 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1767 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1767 0), 1768 0),
1768UNUSUAL_DEV( 0x12d1, 0x1438, 0x0000, 0x0000, 1769UNUSUAL_DEV( 0x12d1, 0x1438, 0x0000, 0x0000,
1769 "HUAWEI MOBILE", 1770 "HUAWEI MOBILE",
1770 "Mass Storage", 1771 "Mass Storage",
1771 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1772 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1772 0), 1773 0),
1773UNUSUAL_DEV( 0x12d1, 0x1439, 0x0000, 0x0000, 1774UNUSUAL_DEV( 0x12d1, 0x1439, 0x0000, 0x0000,
1774 "HUAWEI MOBILE", 1775 "HUAWEI MOBILE",
1775 "Mass Storage", 1776 "Mass Storage",
1776 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1777 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1777 0), 1778 0),
1778UNUSUAL_DEV( 0x12d1, 0x143A, 0x0000, 0x0000, 1779UNUSUAL_DEV( 0x12d1, 0x143A, 0x0000, 0x0000,
1779 "HUAWEI MOBILE", 1780 "HUAWEI MOBILE",
1780 "Mass Storage", 1781 "Mass Storage",
1781 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1782 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1782 0), 1783 0),
1783UNUSUAL_DEV( 0x12d1, 0x143B, 0x0000, 0x0000, 1784UNUSUAL_DEV( 0x12d1, 0x143B, 0x0000, 0x0000,
1784 "HUAWEI MOBILE", 1785 "HUAWEI MOBILE",
1785 "Mass Storage", 1786 "Mass Storage",
1786 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1787 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1787 0), 1788 0),
1788UNUSUAL_DEV( 0x12d1, 0x143C, 0x0000, 0x0000, 1789UNUSUAL_DEV( 0x12d1, 0x143C, 0x0000, 0x0000,
1789 "HUAWEI MOBILE", 1790 "HUAWEI MOBILE",
1790 "Mass Storage", 1791 "Mass Storage",
1791 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1792 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1792 0), 1793 0),
1793UNUSUAL_DEV( 0x12d1, 0x143D, 0x0000, 0x0000, 1794UNUSUAL_DEV( 0x12d1, 0x143D, 0x0000, 0x0000,
1794 "HUAWEI MOBILE", 1795 "HUAWEI MOBILE",
1795 "Mass Storage", 1796 "Mass Storage",
1796 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1797 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1797 0), 1798 0),
1798UNUSUAL_DEV( 0x12d1, 0x143E, 0x0000, 0x0000, 1799UNUSUAL_DEV( 0x12d1, 0x143E, 0x0000, 0x0000,
1799 "HUAWEI MOBILE", 1800 "HUAWEI MOBILE",
1800 "Mass Storage", 1801 "Mass Storage",
1801 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1802 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1802 0), 1803 0),
1803UNUSUAL_DEV( 0x12d1, 0x143F, 0x0000, 0x0000, 1804UNUSUAL_DEV( 0x12d1, 0x143F, 0x0000, 0x0000,
1804 "HUAWEI MOBILE", 1805 "HUAWEI MOBILE",
1805 "Mass Storage", 1806 "Mass Storage",
1806 US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init, 1807 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
1807 0), 1808 0),
1808 1809
1809/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */ 1810/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1810UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001, 1811UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1811 "Minolta", 1812 "Minolta",
1812 "Dimage Z10", 1813 "Dimage Z10",
1813 US_SC_DEVICE, US_PR_DEVICE, NULL, 1814 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1814 0 ), 1815 0 ),
1815 1816
1816/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */ 1817/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */
1817UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110, 1818UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110,
1818 "SWISSBIT", 1819 "SWISSBIT",
1819 "Black Silver", 1820 "Black Silver",
1820 US_SC_DEVICE, US_PR_DEVICE, NULL, 1821 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1821 US_FL_IGNORE_RESIDUE ), 1822 US_FL_IGNORE_RESIDUE ),
1822 1823
1823/* Reported by Francesco Foresti <frafore@tiscali.it> */ 1824/* Reported by Francesco Foresti <frafore@tiscali.it> */
1824UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201, 1825UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201,
1825 "Super Top", 1826 "Super Top",
1826 "IDE DEVICE", 1827 "IDE DEVICE",
1827 US_SC_DEVICE, US_PR_DEVICE, NULL, 1828 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1828 US_FL_IGNORE_RESIDUE ), 1829 US_FL_IGNORE_RESIDUE ),
1829 1830
1830/* Reported by Alexandre Oliva <oliva@lsd.ic.unicamp.br> 1831/* Reported by Alexandre Oliva <oliva@lsd.ic.unicamp.br>
@@ -1833,7 +1834,7 @@ UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201,
1833UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100, 1834UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100,
1834 "JMicron", 1835 "JMicron",
1835 "USB to ATA/ATAPI Bridge", 1836 "USB to ATA/ATAPI Bridge",
1836 US_SC_DEVICE, US_PR_DEVICE, NULL, 1837 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1837 US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ), 1838 US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ),
1838 1839
1839/* Reported by Robert Schedel <r.schedel@yahoo.de> 1840/* Reported by Robert Schedel <r.schedel@yahoo.de>
@@ -1841,7 +1842,7 @@ UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100,
1841UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201, 1842UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
1842 "Teac", 1843 "Teac",
1843 "HD-35PUK-B", 1844 "HD-35PUK-B",
1844 US_SC_DEVICE, US_PR_DEVICE, NULL, 1845 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1845 US_FL_IGNORE_RESIDUE ), 1846 US_FL_IGNORE_RESIDUE ),
1846 1847
1847/* Reported by Hans de Goede <hdegoede@redhat.com> 1848/* Reported by Hans de Goede <hdegoede@redhat.com>
@@ -1851,18 +1852,23 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
1851UNUSUAL_DEV( 0x1908, 0x1315, 0x0000, 0x0000, 1852UNUSUAL_DEV( 0x1908, 0x1315, 0x0000, 0x0000,
1852 "BUILDWIN", 1853 "BUILDWIN",
1853 "Photo Frame", 1854 "Photo Frame",
1854 US_SC_DEVICE, US_PR_DEVICE, NULL, 1855 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1855 US_FL_BAD_SENSE ), 1856 US_FL_BAD_SENSE ),
1856UNUSUAL_DEV( 0x1908, 0x1320, 0x0000, 0x0000, 1857UNUSUAL_DEV( 0x1908, 0x1320, 0x0000, 0x0000,
1857 "BUILDWIN", 1858 "BUILDWIN",
1858 "Photo Frame", 1859 "Photo Frame",
1859 US_SC_DEVICE, US_PR_DEVICE, NULL, 1860 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1860 US_FL_BAD_SENSE ), 1861 US_FL_BAD_SENSE ),
1862UNUSUAL_DEV( 0x1908, 0x3335, 0x0200, 0x0200,
1863 "BUILDWIN",
1864 "Photo Frame",
1865 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1866 US_FL_NO_READ_DISC_INFO ),
1861 1867
1862UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001, 1868UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
1863 "ST", 1869 "ST",
1864 "2A", 1870 "2A",
1865 US_SC_DEVICE, US_PR_DEVICE, NULL, 1871 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1866 US_FL_FIX_CAPACITY), 1872 US_FL_FIX_CAPACITY),
1867 1873
1868/* patch submitted by Davide Perini <perini.davide@dpsoftware.org> 1874/* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
@@ -1871,7 +1877,7 @@ UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
1871UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001, 1877UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
1872 "Motorola", 1878 "Motorola",
1873 "RAZR V3x", 1879 "RAZR V3x",
1874 US_SC_DEVICE, US_PR_DEVICE, NULL, 1880 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1875 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), 1881 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
1876 1882
1877/* 1883/*
@@ -1882,14 +1888,14 @@ UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
1882UNUSUAL_DEV( 0x22b8, 0x6426, 0x0101, 0x0101, 1888UNUSUAL_DEV( 0x22b8, 0x6426, 0x0101, 0x0101,
1883 "Motorola", 1889 "Motorola",
1884 "MSnc.", 1890 "MSnc.",
1885 US_SC_DEVICE, US_PR_DEVICE, NULL, 1891 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1886 US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY | US_FL_BULK_IGNORE_TAG), 1892 US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY | US_FL_BULK_IGNORE_TAG),
1887 1893
1888/* Reported by Radovan Garabik <garabik@kassiopeia.juls.savba.sk> */ 1894/* Reported by Radovan Garabik <garabik@kassiopeia.juls.savba.sk> */
1889UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999, 1895UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1890 "MPIO", 1896 "MPIO",
1891 "HS200", 1897 "HS200",
1892 US_SC_DEVICE, US_PR_DEVICE, NULL, 1898 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1893 US_FL_GO_SLOW ), 1899 US_FL_GO_SLOW ),
1894 1900
1895/* Reported by Frederic Marchal <frederic.marchal@wowcompany.com> 1901/* Reported by Frederic Marchal <frederic.marchal@wowcompany.com>
@@ -1898,21 +1904,21 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1898UNUSUAL_DEV( 0x3340, 0xffff, 0x0000, 0x0000, 1904UNUSUAL_DEV( 0x3340, 0xffff, 0x0000, 0x0000,
1899 "Mitac", 1905 "Mitac",
1900 "Mio DigiWalker USB Sync", 1906 "Mio DigiWalker USB Sync",
1901 US_SC_DEVICE,US_PR_DEVICE,NULL, 1907 USB_SC_DEVICE,USB_PR_DEVICE,NULL,
1902 US_FL_MAX_SECTORS_64 ), 1908 US_FL_MAX_SECTORS_64 ),
1903 1909
1904/* Reported by Andrey Rahmatullin <wrar@altlinux.org> */ 1910/* Reported by Andrey Rahmatullin <wrar@altlinux.org> */
1905UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100, 1911UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
1906 "iRiver", 1912 "iRiver",
1907 "MP3 T10", 1913 "MP3 T10",
1908 US_SC_DEVICE, US_PR_DEVICE, NULL, 1914 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1909 US_FL_IGNORE_RESIDUE ), 1915 US_FL_IGNORE_RESIDUE ),
1910 1916
1911/* Reported by Sergey Pinaev <dfo@antex.ru> */ 1917/* Reported by Sergey Pinaev <dfo@antex.ru> */
1912UNUSUAL_DEV( 0x4102, 0x1059, 0x0000, 0x0000, 1918UNUSUAL_DEV( 0x4102, 0x1059, 0x0000, 0x0000,
1913 "iRiver", 1919 "iRiver",
1914 "P7K", 1920 "P7K",
1915 US_SC_DEVICE, US_PR_DEVICE, NULL, 1921 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1916 US_FL_MAX_SECTORS_64 ), 1922 US_FL_MAX_SECTORS_64 ),
1917 1923
1918/* 1924/*
@@ -1922,41 +1928,41 @@ UNUSUAL_DEV( 0x4102, 0x1059, 0x0000, 0x0000,
1922UNUSUAL_DEV( 0x4146, 0xba01, 0x0100, 0x0100, 1928UNUSUAL_DEV( 0x4146, 0xba01, 0x0100, 0x0100,
1923 "Iomega", 1929 "Iomega",
1924 "Micro Mini 1GB", 1930 "Micro Mini 1GB",
1925 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), 1931 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
1926 1932
1927/* Reported by Andrew Simmons <andrew.simmons@gmail.com> */ 1933/* Reported by Andrew Simmons <andrew.simmons@gmail.com> */
1928UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001, 1934UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
1929 "DataStor", 1935 "DataStor",
1930 "USB4500 FW1.04", 1936 "USB4500 FW1.04",
1931 US_SC_DEVICE, US_PR_DEVICE, NULL, 1937 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1932 US_FL_CAPACITY_HEURISTICS), 1938 US_FL_CAPACITY_HEURISTICS),
1933 1939
1934/* Reported by Alessio Treglia <quadrispro@ubuntu.com> */ 1940/* Reported by Alessio Treglia <quadrispro@ubuntu.com> */
1935UNUSUAL_DEV( 0xed10, 0x7636, 0x0001, 0x0001, 1941UNUSUAL_DEV( 0xed10, 0x7636, 0x0001, 0x0001,
1936 "TGE", 1942 "TGE",
1937 "Digital MP3 Audio Player", 1943 "Digital MP3 Audio Player",
1938 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), 1944 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
1939 1945
1940/* Control/Bulk transport for all SubClass values */ 1946/* Control/Bulk transport for all SubClass values */
1941USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), 1947USUAL_DEV(USB_SC_RBC, USB_PR_CB, USB_US_TYPE_STOR),
1942USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), 1948USUAL_DEV(USB_SC_8020, USB_PR_CB, USB_US_TYPE_STOR),
1943USUAL_DEV(US_SC_QIC, US_PR_CB, USB_US_TYPE_STOR), 1949USUAL_DEV(USB_SC_QIC, USB_PR_CB, USB_US_TYPE_STOR),
1944USUAL_DEV(US_SC_UFI, US_PR_CB, USB_US_TYPE_STOR), 1950USUAL_DEV(USB_SC_UFI, USB_PR_CB, USB_US_TYPE_STOR),
1945USUAL_DEV(US_SC_8070, US_PR_CB, USB_US_TYPE_STOR), 1951USUAL_DEV(USB_SC_8070, USB_PR_CB, USB_US_TYPE_STOR),
1946USUAL_DEV(US_SC_SCSI, US_PR_CB, USB_US_TYPE_STOR), 1952USUAL_DEV(USB_SC_SCSI, USB_PR_CB, USB_US_TYPE_STOR),
1947 1953
1948/* Control/Bulk/Interrupt transport for all SubClass values */ 1954/* Control/Bulk/Interrupt transport for all SubClass values */
1949USUAL_DEV(US_SC_RBC, US_PR_CBI, USB_US_TYPE_STOR), 1955USUAL_DEV(USB_SC_RBC, USB_PR_CBI, USB_US_TYPE_STOR),
1950USUAL_DEV(US_SC_8020, US_PR_CBI, USB_US_TYPE_STOR), 1956USUAL_DEV(USB_SC_8020, USB_PR_CBI, USB_US_TYPE_STOR),
1951USUAL_DEV(US_SC_QIC, US_PR_CBI, USB_US_TYPE_STOR), 1957USUAL_DEV(USB_SC_QIC, USB_PR_CBI, USB_US_TYPE_STOR),
1952USUAL_DEV(US_SC_UFI, US_PR_CBI, USB_US_TYPE_STOR), 1958USUAL_DEV(USB_SC_UFI, USB_PR_CBI, USB_US_TYPE_STOR),
1953USUAL_DEV(US_SC_8070, US_PR_CBI, USB_US_TYPE_STOR), 1959USUAL_DEV(USB_SC_8070, USB_PR_CBI, USB_US_TYPE_STOR),
1954USUAL_DEV(US_SC_SCSI, US_PR_CBI, USB_US_TYPE_STOR), 1960USUAL_DEV(USB_SC_SCSI, USB_PR_CBI, USB_US_TYPE_STOR),
1955 1961
1956/* Bulk-only transport for all SubClass values */ 1962/* Bulk-only transport for all SubClass values */
1957USUAL_DEV(US_SC_RBC, US_PR_BULK, USB_US_TYPE_STOR), 1963USUAL_DEV(USB_SC_RBC, USB_PR_BULK, USB_US_TYPE_STOR),
1958USUAL_DEV(US_SC_8020, US_PR_BULK, USB_US_TYPE_STOR), 1964USUAL_DEV(USB_SC_8020, USB_PR_BULK, USB_US_TYPE_STOR),
1959USUAL_DEV(US_SC_QIC, US_PR_BULK, USB_US_TYPE_STOR), 1965USUAL_DEV(USB_SC_QIC, USB_PR_BULK, USB_US_TYPE_STOR),
1960USUAL_DEV(US_SC_UFI, US_PR_BULK, USB_US_TYPE_STOR), 1966USUAL_DEV(USB_SC_UFI, USB_PR_BULK, USB_US_TYPE_STOR),
1961USUAL_DEV(US_SC_8070, US_PR_BULK, USB_US_TYPE_STOR), 1967USUAL_DEV(USB_SC_8070, USB_PR_BULK, USB_US_TYPE_STOR),
1962USUAL_DEV(US_SC_SCSI, US_PR_BULK, 0), 1968USUAL_DEV(USB_SC_SCSI, USB_PR_BULK, 0),
diff --git a/drivers/usb/storage/unusual_freecom.h b/drivers/usb/storage/unusual_freecom.h
index 375867942391..59a261155b98 100644
--- a/drivers/usb/storage/unusual_freecom.h
+++ b/drivers/usb/storage/unusual_freecom.h
@@ -21,6 +21,6 @@
21UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999, 21UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999,
22 "Freecom", 22 "Freecom",
23 "USB-IDE", 23 "USB-IDE",
24 US_SC_QIC, US_PR_FREECOM, init_freecom, 0), 24 USB_SC_QIC, USB_PR_FREECOM, init_freecom, 0),
25 25
26#endif /* defined(CONFIG_USB_STORAGE_FREECOM) || ... */ 26#endif /* defined(CONFIG_USB_STORAGE_FREECOM) || ... */
diff --git a/drivers/usb/storage/unusual_isd200.h b/drivers/usb/storage/unusual_isd200.h
index 0d99dde3382a..14cca0c48302 100644
--- a/drivers/usb/storage/unusual_isd200.h
+++ b/drivers/usb/storage/unusual_isd200.h
@@ -21,37 +21,37 @@
21UNUSUAL_DEV( 0x054c, 0x002b, 0x0100, 0x0110, 21UNUSUAL_DEV( 0x054c, 0x002b, 0x0100, 0x0110,
22 "Sony", 22 "Sony",
23 "Portable USB Harddrive V2", 23 "Portable USB Harddrive V2",
24 US_SC_ISD200, US_PR_BULK, isd200_Initialization, 24 USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
25 0), 25 0),
26 26
27UNUSUAL_DEV( 0x05ab, 0x0031, 0x0100, 0x0110, 27UNUSUAL_DEV( 0x05ab, 0x0031, 0x0100, 0x0110,
28 "In-System", 28 "In-System",
29 "USB/IDE Bridge (ATA/ATAPI)", 29 "USB/IDE Bridge (ATA/ATAPI)",
30 US_SC_ISD200, US_PR_BULK, isd200_Initialization, 30 USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
31 0), 31 0),
32 32
33UNUSUAL_DEV( 0x05ab, 0x0301, 0x0100, 0x0110, 33UNUSUAL_DEV( 0x05ab, 0x0301, 0x0100, 0x0110,
34 "In-System", 34 "In-System",
35 "Portable USB Harddrive V2", 35 "Portable USB Harddrive V2",
36 US_SC_ISD200, US_PR_BULK, isd200_Initialization, 36 USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
37 0), 37 0),
38 38
39UNUSUAL_DEV( 0x05ab, 0x0351, 0x0100, 0x0110, 39UNUSUAL_DEV( 0x05ab, 0x0351, 0x0100, 0x0110,
40 "In-System", 40 "In-System",
41 "Portable USB Harddrive V2", 41 "Portable USB Harddrive V2",
42 US_SC_ISD200, US_PR_BULK, isd200_Initialization, 42 USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
43 0), 43 0),
44 44
45UNUSUAL_DEV( 0x05ab, 0x5701, 0x0100, 0x0110, 45UNUSUAL_DEV( 0x05ab, 0x5701, 0x0100, 0x0110,
46 "In-System", 46 "In-System",
47 "USB Storage Adapter V2", 47 "USB Storage Adapter V2",
48 US_SC_ISD200, US_PR_BULK, isd200_Initialization, 48 USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
49 0), 49 0),
50 50
51UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 51UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
52 "ATI", 52 "ATI",
53 "USB Cable 205", 53 "USB Cable 205",
54 US_SC_ISD200, US_PR_BULK, isd200_Initialization, 54 USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
55 0), 55 0),
56 56
57#endif /* defined(CONFIG_USB_STORAGE_ISD200) || ... */ 57#endif /* defined(CONFIG_USB_STORAGE_ISD200) || ... */
diff --git a/drivers/usb/storage/unusual_jumpshot.h b/drivers/usb/storage/unusual_jumpshot.h
index 2e549b1c2c62..54be78b5d643 100644
--- a/drivers/usb/storage/unusual_jumpshot.h
+++ b/drivers/usb/storage/unusual_jumpshot.h
@@ -21,7 +21,7 @@
21UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001, 21UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001,
22 "Lexar", 22 "Lexar",
23 "Jumpshot USB CF Reader", 23 "Jumpshot USB CF Reader",
24 US_SC_SCSI, US_PR_JUMPSHOT, NULL, 24 USB_SC_SCSI, USB_PR_JUMPSHOT, NULL,
25 US_FL_NEED_OVERRIDE), 25 US_FL_NEED_OVERRIDE),
26 26
27#endif /* defined(CONFIG_USB_STORAGE_JUMPSHOT) || ... */ 27#endif /* defined(CONFIG_USB_STORAGE_JUMPSHOT) || ... */
diff --git a/drivers/usb/storage/unusual_karma.h b/drivers/usb/storage/unusual_karma.h
index 12ae3a03e802..6df03972a22c 100644
--- a/drivers/usb/storage/unusual_karma.h
+++ b/drivers/usb/storage/unusual_karma.h
@@ -21,6 +21,6 @@
21UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101, 21UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101,
22 "Rio", 22 "Rio",
23 "Rio Karma", 23 "Rio Karma",
24 US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0), 24 USB_SC_SCSI, USB_PR_KARMA, rio_karma_init, 0),
25 25
26#endif /* defined(CONFIG_USB_STORAGE_KARMA) || ... */ 26#endif /* defined(CONFIG_USB_STORAGE_KARMA) || ... */
diff --git a/drivers/usb/storage/unusual_onetouch.h b/drivers/usb/storage/unusual_onetouch.h
index bd9306b637df..0abb819c7405 100644
--- a/drivers/usb/storage/unusual_onetouch.h
+++ b/drivers/usb/storage/unusual_onetouch.h
@@ -24,13 +24,13 @@
24UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999, 24UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999,
25 "Maxtor", 25 "Maxtor",
26 "OneTouch External Harddrive", 26 "OneTouch External Harddrive",
27 US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input, 27 USB_SC_DEVICE, USB_PR_DEVICE, onetouch_connect_input,
28 0), 28 0),
29 29
30UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999, 30UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999,
31 "Maxtor", 31 "Maxtor",
32 "OneTouch External Harddrive", 32 "OneTouch External Harddrive",
33 US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input, 33 USB_SC_DEVICE, USB_PR_DEVICE, onetouch_connect_input,
34 0), 34 0),
35 35
36#endif /* defined(CONFIG_USB_STORAGE_ONETOUCH) || ... */ 36#endif /* defined(CONFIG_USB_STORAGE_ONETOUCH) || ... */
diff --git a/drivers/usb/storage/unusual_sddr09.h b/drivers/usb/storage/unusual_sddr09.h
index 50cab511a4d7..59a7e37b6c11 100644
--- a/drivers/usb/storage/unusual_sddr09.h
+++ b/drivers/usb/storage/unusual_sddr09.h
@@ -21,36 +21,36 @@
21UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100, 21UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
22 "Microtech", 22 "Microtech",
23 "CameraMate (DPCM_USB)", 23 "CameraMate (DPCM_USB)",
24 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0), 24 USB_SC_SCSI, USB_PR_DPCM_USB, NULL, 0),
25 25
26UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999, 26UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999,
27 "Sandisk", 27 "Sandisk",
28 "ImageMate SDDR09", 28 "ImageMate SDDR09",
29 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, 29 USB_SC_SCSI, USB_PR_EUSB_SDDR09, usb_stor_sddr09_init,
30 0), 30 0),
31 31
32/* This entry is from Andries.Brouwer@cwi.nl */ 32/* This entry is from Andries.Brouwer@cwi.nl */
33UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208, 33UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
34 "SCM Microsystems", 34 "SCM Microsystems",
35 "eUSB SmartMedia / CompactFlash Adapter", 35 "eUSB SmartMedia / CompactFlash Adapter",
36 US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init, 36 USB_SC_SCSI, USB_PR_DPCM_USB, usb_stor_sddr09_dpcm_init,
37 0), 37 0),
38 38
39UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100, 39UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100,
40 "Olympus", 40 "Olympus",
41 "Camedia MAUSB-2", 41 "Camedia MAUSB-2",
42 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, 42 USB_SC_SCSI, USB_PR_EUSB_SDDR09, usb_stor_sddr09_init,
43 0), 43 0),
44 44
45UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999, 45UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999,
46 "Sandisk", 46 "Sandisk",
47 "ImageMate SDDR-09", 47 "ImageMate SDDR-09",
48 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, 48 USB_SC_SCSI, USB_PR_EUSB_SDDR09, usb_stor_sddr09_init,
49 0), 49 0),
50 50
51UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100, 51UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
52 "Microtech", 52 "Microtech",
53 "CameraMate (DPCM_USB)", 53 "CameraMate (DPCM_USB)",
54 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0), 54 USB_SC_SCSI, USB_PR_DPCM_USB, NULL, 0),
55 55
56#endif /* defined(CONFIG_USB_STORAGE_SDDR09) || ... */ 56#endif /* defined(CONFIG_USB_STORAGE_SDDR09) || ... */
diff --git a/drivers/usb/storage/unusual_sddr55.h b/drivers/usb/storage/unusual_sddr55.h
index ae81ef7a1cfd..fcb7e12c598f 100644
--- a/drivers/usb/storage/unusual_sddr55.h
+++ b/drivers/usb/storage/unusual_sddr55.h
@@ -22,23 +22,23 @@
22UNUSUAL_DEV( 0x07c4, 0xa103, 0x0000, 0x9999, 22UNUSUAL_DEV( 0x07c4, 0xa103, 0x0000, 0x9999,
23 "Datafab", 23 "Datafab",
24 "MDSM-B reader", 24 "MDSM-B reader",
25 US_SC_SCSI, US_PR_SDDR55, NULL, 25 USB_SC_SCSI, USB_PR_SDDR55, NULL,
26 US_FL_FIX_INQUIRY), 26 US_FL_FIX_INQUIRY),
27 27
28/* SM part - aeb <Andries.Brouwer@cwi.nl> */ 28/* SM part - aeb <Andries.Brouwer@cwi.nl> */
29UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff, 29UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
30 "Datafab Systems, Inc.", 30 "Datafab Systems, Inc.",
31 "USB to CF + SM Combo (LC1)", 31 "USB to CF + SM Combo (LC1)",
32 US_SC_SCSI, US_PR_SDDR55, NULL, 0), 32 USB_SC_SCSI, USB_PR_SDDR55, NULL, 0),
33 33
34UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff, 34UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
35 "Acomdata", 35 "Acomdata",
36 "SM", 36 "SM",
37 US_SC_SCSI, US_PR_SDDR55, NULL, 0), 37 USB_SC_SCSI, USB_PR_SDDR55, NULL, 0),
38 38
39UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999, 39UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999,
40 "Sandisk", 40 "Sandisk",
41 "ImageMate SDDR55", 41 "ImageMate SDDR55",
42 US_SC_SCSI, US_PR_SDDR55, NULL, 0), 42 USB_SC_SCSI, USB_PR_SDDR55, NULL, 0),
43 43
44#endif /* defined(CONFIG_USB_STORAGE_SDDR55) || ... */ 44#endif /* defined(CONFIG_USB_STORAGE_SDDR55) || ... */
diff --git a/drivers/usb/storage/unusual_usbat.h b/drivers/usb/storage/unusual_usbat.h
index 80e869f10180..38e79c4e6d6a 100644
--- a/drivers/usb/storage/unusual_usbat.h
+++ b/drivers/usb/storage/unusual_usbat.h
@@ -21,23 +21,23 @@
21UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001, 21UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001,
22 "HP", 22 "HP",
23 "CD-Writer+ 8200e", 23 "CD-Writer+ 8200e",
24 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), 24 USB_SC_8070, USB_PR_USBAT, init_usbat_cd, 0),
25 25
26UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, 26UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
27 "HP", 27 "HP",
28 "CD-Writer+ CD-4e", 28 "CD-Writer+ CD-4e",
29 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), 29 USB_SC_8070, USB_PR_USBAT, init_usbat_cd, 0),
30 30
31UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, 31UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
32 "Shuttle/SCM", 32 "Shuttle/SCM",
33 "USBAT-02", 33 "USBAT-02",
34 US_SC_SCSI, US_PR_USBAT, init_usbat_flash, 34 USB_SC_SCSI, USB_PR_USBAT, init_usbat_flash,
35 US_FL_SINGLE_LUN), 35 US_FL_SINGLE_LUN),
36 36
37UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005, 37UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
38 "Sandisk", 38 "Sandisk",
39 "ImageMate SDDR-05b", 39 "ImageMate SDDR-05b",
40 US_SC_SCSI, US_PR_USBAT, init_usbat_flash, 40 USB_SC_SCSI, USB_PR_USBAT, init_usbat_flash,
41 US_FL_SINGLE_LUN), 41 US_FL_SINGLE_LUN),
42 42
43#endif /* defined(CONFIG_USB_STORAGE_USBAT) || ... */ 43#endif /* defined(CONFIG_USB_STORAGE_USBAT) || ... */
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 90bb0175a152..4219c197cb08 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -512,10 +512,10 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
512 512
513 /* Store the entries */ 513 /* Store the entries */
514 us->unusual_dev = unusual_dev; 514 us->unusual_dev = unusual_dev;
515 us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ? 515 us->subclass = (unusual_dev->useProtocol == USB_SC_DEVICE) ?
516 idesc->bInterfaceSubClass : 516 idesc->bInterfaceSubClass :
517 unusual_dev->useProtocol; 517 unusual_dev->useProtocol;
518 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? 518 us->protocol = (unusual_dev->useTransport == USB_PR_DEVICE) ?
519 idesc->bInterfaceProtocol : 519 idesc->bInterfaceProtocol :
520 unusual_dev->useTransport; 520 unusual_dev->useTransport;
521 us->fflags = USB_US_ORIG_FLAGS(id->driver_info); 521 us->fflags = USB_US_ORIG_FLAGS(id->driver_info);
@@ -552,10 +552,10 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
552 struct usb_device_descriptor *ddesc = &dev->descriptor; 552 struct usb_device_descriptor *ddesc = &dev->descriptor;
553 int msg = -1; 553 int msg = -1;
554 554
555 if (unusual_dev->useProtocol != US_SC_DEVICE && 555 if (unusual_dev->useProtocol != USB_SC_DEVICE &&
556 us->subclass == idesc->bInterfaceSubClass) 556 us->subclass == idesc->bInterfaceSubClass)
557 msg += 1; 557 msg += 1;
558 if (unusual_dev->useTransport != US_PR_DEVICE && 558 if (unusual_dev->useTransport != USB_PR_DEVICE &&
559 us->protocol == idesc->bInterfaceProtocol) 559 us->protocol == idesc->bInterfaceProtocol)
560 msg += 2; 560 msg += 2;
561 if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE)) 561 if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE))
@@ -582,21 +582,21 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
582static void get_transport(struct us_data *us) 582static void get_transport(struct us_data *us)
583{ 583{
584 switch (us->protocol) { 584 switch (us->protocol) {
585 case US_PR_CB: 585 case USB_PR_CB:
586 us->transport_name = "Control/Bulk"; 586 us->transport_name = "Control/Bulk";
587 us->transport = usb_stor_CB_transport; 587 us->transport = usb_stor_CB_transport;
588 us->transport_reset = usb_stor_CB_reset; 588 us->transport_reset = usb_stor_CB_reset;
589 us->max_lun = 7; 589 us->max_lun = 7;
590 break; 590 break;
591 591
592 case US_PR_CBI: 592 case USB_PR_CBI:
593 us->transport_name = "Control/Bulk/Interrupt"; 593 us->transport_name = "Control/Bulk/Interrupt";
594 us->transport = usb_stor_CB_transport; 594 us->transport = usb_stor_CB_transport;
595 us->transport_reset = usb_stor_CB_reset; 595 us->transport_reset = usb_stor_CB_reset;
596 us->max_lun = 7; 596 us->max_lun = 7;
597 break; 597 break;
598 598
599 case US_PR_BULK: 599 case USB_PR_BULK:
600 us->transport_name = "Bulk"; 600 us->transport_name = "Bulk";
601 us->transport = usb_stor_Bulk_transport; 601 us->transport = usb_stor_Bulk_transport;
602 us->transport_reset = usb_stor_Bulk_reset; 602 us->transport_reset = usb_stor_Bulk_reset;
@@ -608,35 +608,35 @@ static void get_transport(struct us_data *us)
608static void get_protocol(struct us_data *us) 608static void get_protocol(struct us_data *us)
609{ 609{
610 switch (us->subclass) { 610 switch (us->subclass) {
611 case US_SC_RBC: 611 case USB_SC_RBC:
612 us->protocol_name = "Reduced Block Commands (RBC)"; 612 us->protocol_name = "Reduced Block Commands (RBC)";
613 us->proto_handler = usb_stor_transparent_scsi_command; 613 us->proto_handler = usb_stor_transparent_scsi_command;
614 break; 614 break;
615 615
616 case US_SC_8020: 616 case USB_SC_8020:
617 us->protocol_name = "8020i"; 617 us->protocol_name = "8020i";
618 us->proto_handler = usb_stor_pad12_command; 618 us->proto_handler = usb_stor_pad12_command;
619 us->max_lun = 0; 619 us->max_lun = 0;
620 break; 620 break;
621 621
622 case US_SC_QIC: 622 case USB_SC_QIC:
623 us->protocol_name = "QIC-157"; 623 us->protocol_name = "QIC-157";
624 us->proto_handler = usb_stor_pad12_command; 624 us->proto_handler = usb_stor_pad12_command;
625 us->max_lun = 0; 625 us->max_lun = 0;
626 break; 626 break;
627 627
628 case US_SC_8070: 628 case USB_SC_8070:
629 us->protocol_name = "8070i"; 629 us->protocol_name = "8070i";
630 us->proto_handler = usb_stor_pad12_command; 630 us->proto_handler = usb_stor_pad12_command;
631 us->max_lun = 0; 631 us->max_lun = 0;
632 break; 632 break;
633 633
634 case US_SC_SCSI: 634 case USB_SC_SCSI:
635 us->protocol_name = "Transparent SCSI"; 635 us->protocol_name = "Transparent SCSI";
636 us->proto_handler = usb_stor_transparent_scsi_command; 636 us->proto_handler = usb_stor_transparent_scsi_command;
637 break; 637 break;
638 638
639 case US_SC_UFI: 639 case USB_SC_UFI:
640 us->protocol_name = "Uniform Floppy Interface (UFI)"; 640 us->protocol_name = "Uniform Floppy Interface (UFI)";
641 us->proto_handler = usb_stor_ufi_command; 641 us->proto_handler = usb_stor_ufi_command;
642 break; 642 break;
@@ -679,7 +679,7 @@ static int get_pipes(struct us_data *us)
679 } 679 }
680 } 680 }
681 681
682 if (!ep_in || !ep_out || (us->protocol == US_PR_CBI && !ep_int)) { 682 if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) {
683 US_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n"); 683 US_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n");
684 return -EIO; 684 return -EIO;
685 } 685 }
@@ -834,7 +834,7 @@ static int usb_stor_scan_thread(void * __us)
834 if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) { 834 if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) {
835 835
836 /* For bulk-only devices, determine the max LUN value */ 836 /* For bulk-only devices, determine the max LUN value */
837 if (us->protocol == US_PR_BULK && 837 if (us->protocol == USB_PR_BULK &&
838 !(us->fflags & US_FL_SINGLE_LUN)) { 838 !(us->fflags & US_FL_SINGLE_LUN)) {
839 mutex_lock(&us->dev_mutex); 839 mutex_lock(&us->dev_mutex);
840 us->max_lun = usb_stor_Bulk_max_lun(us); 840 us->max_lun = usb_stor_Bulk_max_lun(us);
diff --git a/drivers/usb/wusbcore/Makefile b/drivers/usb/wusbcore/Makefile
index 75f1ade66258..b3bd313032b1 100644
--- a/drivers/usb/wusbcore/Makefile
+++ b/drivers/usb/wusbcore/Makefile
@@ -1,9 +1,11 @@
1ccflags-$(CONFIG_USB_WUSB_CBAF_DEBUG) := -DDEBUG
2
1obj-$(CONFIG_USB_WUSB) += wusbcore.o 3obj-$(CONFIG_USB_WUSB) += wusbcore.o
2obj-$(CONFIG_USB_HWA_HCD) += wusb-wa.o 4obj-$(CONFIG_USB_HWA_HCD) += wusb-wa.o
3obj-$(CONFIG_USB_WUSB_CBAF) += wusb-cbaf.o 5obj-$(CONFIG_USB_WUSB_CBAF) += wusb-cbaf.o
4 6
5 7
6wusbcore-objs := \ 8wusbcore-y := \
7 crypto.o \ 9 crypto.o \
8 devconnect.o \ 10 devconnect.o \
9 dev-sysfs.o \ 11 dev-sysfs.o \
@@ -14,13 +16,10 @@ wusbcore-objs := \
14 security.o \ 16 security.o \
15 wusbhc.o 17 wusbhc.o
16 18
17wusb-cbaf-objs := cbaf.o 19wusb-cbaf-y := cbaf.o
18
19wusb-wa-objs := wa-hc.o \
20 wa-nep.o \
21 wa-rpipe.o \
22 wa-xfer.o
23 20
24ifeq ($(CONFIG_USB_WUSB_CBAF_DEBUG),y) 21wusb-wa-y := \
25EXTRA_CFLAGS += -DDEBUG 22 wa-hc.o \
26endif 23 wa-nep.o \
24 wa-rpipe.o \
25 wa-xfer.o
diff --git a/drivers/uwb/address.c b/drivers/uwb/address.c
index 973321327c44..8739c4f4d015 100644
--- a/drivers/uwb/address.c
+++ b/drivers/uwb/address.c
@@ -363,10 +363,7 @@ size_t __uwb_addr_print(char *buf, size_t buf_size, const unsigned char *addr,
363{ 363{
364 size_t result; 364 size_t result;
365 if (type) 365 if (type)
366 result = scnprintf(buf, buf_size, 366 result = scnprintf(buf, buf_size, "%pM", addr);
367 "%02x:%02x:%02x:%02x:%02x:%02x",
368 addr[0], addr[1], addr[2],
369 addr[3], addr[4], addr[5]);
370 else 367 else
371 result = scnprintf(buf, buf_size, "%02x:%02x", 368 result = scnprintf(buf, buf_size, "%02x:%02x",
372 addr[1], addr[0]); 369 addr[1], addr[0]);
diff --git a/drivers/uwb/wlp/wss-lc.c b/drivers/uwb/wlp/wss-lc.c
index a005d2a03b5d..67872c83b679 100644
--- a/drivers/uwb/wlp/wss-lc.c
+++ b/drivers/uwb/wlp/wss-lc.c
@@ -791,11 +791,8 @@ int wlp_wss_prep_hdr(struct wlp *wlp, struct wlp_eda_node *eda_entry,
791 } else { 791 } else {
792 if (printk_ratelimit()) 792 if (printk_ratelimit())
793 dev_err(dev, "WLP: Destination neighbor (Ethernet: " 793 dev_err(dev, "WLP: Destination neighbor (Ethernet: "
794 "%02x:%02x:%02x:%02x:%02x:%02x, Dev: " 794 "%pM, Dev: %02x:%02x) is not connected.\n",
795 "%02x:%02x) is not connected. \n", eth_addr[0], 795 eth_addr, dev_addr->data[1], dev_addr->data[0]);
796 eth_addr[1], eth_addr[2], eth_addr[3],
797 eth_addr[4], eth_addr[5], dev_addr->data[1],
798 dev_addr->data[0]);
799 result = -EINVAL; 796 result = -EINVAL;
800 } 797 }
801 return result; 798 return result;
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 28e33fea5107..4eb56ed75fbc 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -58,17 +58,35 @@ enum fsl_usb2_phy_modes {
58 FSL_USB2_PHY_SERIAL, 58 FSL_USB2_PHY_SERIAL,
59}; 59};
60 60
61struct clk;
62struct platform_device;
63
61struct fsl_usb2_platform_data { 64struct fsl_usb2_platform_data {
62 /* board specific information */ 65 /* board specific information */
63 enum fsl_usb2_operating_modes operating_mode; 66 enum fsl_usb2_operating_modes operating_mode;
64 enum fsl_usb2_phy_modes phy_mode; 67 enum fsl_usb2_phy_modes phy_mode;
65 unsigned int port_enables; 68 unsigned int port_enables;
69 unsigned int workaround;
70
71 int (*init)(struct platform_device *);
72 void (*exit)(struct platform_device *);
73 void __iomem *regs; /* ioremap'd register base */
74 struct clk *clk;
75 unsigned big_endian_mmio:1;
76 unsigned big_endian_desc:1;
77 unsigned es:1; /* need USBMODE:ES */
78 unsigned le_setup_buf:1;
79 unsigned have_sysif_regs:1;
80 unsigned invert_drvvbus:1;
81 unsigned invert_pwr_fault:1;
66}; 82};
67 83
68/* Flags in fsl_usb2_mph_platform_data */ 84/* Flags in fsl_usb2_mph_platform_data */
69#define FSL_USB2_PORT0_ENABLED 0x00000001 85#define FSL_USB2_PORT0_ENABLED 0x00000001
70#define FSL_USB2_PORT1_ENABLED 0x00000002 86#define FSL_USB2_PORT1_ENABLED 0x00000002
71 87
88#define FLS_USB2_WORKAROUND_ENGCM09152 (1 << 0)
89
72struct spi_device; 90struct spi_device;
73 91
74struct fsl_spi_platform_data { 92struct fsl_spi_platform_data {
diff --git a/include/linux/init.h b/include/linux/init.h
index de994304e0bb..577671c55153 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -46,16 +46,23 @@
46#define __exitdata __section(.exit.data) 46#define __exitdata __section(.exit.data)
47#define __exit_call __used __section(.exitcall.exit) 47#define __exit_call __used __section(.exitcall.exit)
48 48
49/* modpost check for section mismatches during the kernel build. 49/*
50 * modpost check for section mismatches during the kernel build.
50 * A section mismatch happens when there are references from a 51 * A section mismatch happens when there are references from a
51 * code or data section to an init section (both code or data). 52 * code or data section to an init section (both code or data).
52 * The init sections are (for most archs) discarded by the kernel 53 * The init sections are (for most archs) discarded by the kernel
53 * when early init has completed so all such references are potential bugs. 54 * when early init has completed so all such references are potential bugs.
54 * For exit sections the same issue exists. 55 * For exit sections the same issue exists.
56 *
55 * The following markers are used for the cases where the reference to 57 * The following markers are used for the cases where the reference to
56 * the *init / *exit section (code or data) is valid and will teach 58 * the *init / *exit section (code or data) is valid and will teach
57 * modpost not to issue a warning. 59 * modpost not to issue a warning. Intended semantics is that a code or
58 * The markers follow same syntax rules as __init / __initdata. */ 60 * data tagged __ref* can reference code or data from init section without
61 * producing a warning (of course, no warning does not mean code is
62 * correct, so optimally document why the __ref is needed and why it's OK).
63 *
64 * The markers follow same syntax rules as __init / __initdata.
65 */
59#define __ref __section(.ref.text) noinline 66#define __ref __section(.ref.text) noinline
60#define __refdata __section(.ref.data) 67#define __refdata __section(.ref.data)
61#define __refconst __section(.ref.rodata) 68#define __refconst __section(.ref.rodata)
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index c117a68d04a7..5e86dc771da4 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -32,6 +32,8 @@
32 32
33#define USB_CDC_PROTO_EEM 7 33#define USB_CDC_PROTO_EEM 7
34 34
35#define USB_CDC_NCM_PROTO_NTB 1
36
35/*-------------------------------------------------------------------------*/ 37/*-------------------------------------------------------------------------*/
36 38
37/* 39/*
@@ -274,13 +276,13 @@ struct usb_cdc_notification {
274/* 276/*
275 * Class Specific structures and constants 277 * Class Specific structures and constants
276 * 278 *
277 * CDC NCM parameter structure, CDC NCM subclass 6.2.1 279 * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1
278 * 280 *
279 */ 281 */
280 282
281struct usb_cdc_ncm_ntb_parameter { 283struct usb_cdc_ncm_ntb_parameters {
282 __le16 wLength; 284 __le16 wLength;
283 __le16 bmNtbFormatSupported; 285 __le16 bmNtbFormatsSupported;
284 __le32 dwNtbInMaxSize; 286 __le32 dwNtbInMaxSize;
285 __le16 wNdpInDivisor; 287 __le16 wNdpInDivisor;
286 __le16 wNdpInPayloadRemainder; 288 __le16 wNdpInPayloadRemainder;
@@ -297,8 +299,8 @@ struct usb_cdc_ncm_ntb_parameter {
297 * CDC NCM transfer headers, CDC NCM subclass 3.2 299 * CDC NCM transfer headers, CDC NCM subclass 3.2
298 */ 300 */
299 301
300#define NCM_NTH16_SIGN 0x484D434E /* NCMH */ 302#define USB_CDC_NCM_NTH16_SIGN 0x484D434E /* NCMH */
301#define NCM_NTH32_SIGN 0x686D636E /* ncmh */ 303#define USB_CDC_NCM_NTH32_SIGN 0x686D636E /* ncmh */
302 304
303struct usb_cdc_ncm_nth16 { 305struct usb_cdc_ncm_nth16 {
304 __le32 dwSignature; 306 __le32 dwSignature;
@@ -320,25 +322,78 @@ struct usb_cdc_ncm_nth32 {
320 * CDC NCM datagram pointers, CDC NCM subclass 3.3 322 * CDC NCM datagram pointers, CDC NCM subclass 3.3
321 */ 323 */
322 324
323#define NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */ 325#define USB_CDC_NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */
324#define NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */ 326#define USB_CDC_NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */
325#define NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */ 327#define USB_CDC_NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */
326#define NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */ 328#define USB_CDC_NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */
329
330/* 16-bit NCM Datagram Pointer Entry */
331struct usb_cdc_ncm_dpe16 {
332 __le16 wDatagramIndex;
333 __le16 wDatagramLength;
334} __attribute__((__packed__));
327 335
336/* 16-bit NCM Datagram Pointer Table */
328struct usb_cdc_ncm_ndp16 { 337struct usb_cdc_ncm_ndp16 {
329 __le32 dwSignature; 338 __le32 dwSignature;
330 __le16 wLength; 339 __le16 wLength;
331 __le16 wNextFpIndex; 340 __le16 wNextFpIndex;
332 __u8 data[0]; 341 struct usb_cdc_ncm_dpe16 dpe16[0];
333} __attribute__ ((packed)); 342} __attribute__ ((packed));
334 343
344/* 32-bit NCM Datagram Pointer Entry */
345struct usb_cdc_ncm_dpe32 {
346 __le32 dwDatagramIndex;
347 __le32 dwDatagramLength;
348} __attribute__((__packed__));
349
350/* 32-bit NCM Datagram Pointer Table */
335struct usb_cdc_ncm_ndp32 { 351struct usb_cdc_ncm_ndp32 {
336 __le32 dwSignature; 352 __le32 dwSignature;
337 __le16 wLength; 353 __le16 wLength;
338 __le16 wReserved6; 354 __le16 wReserved6;
339 __le32 dwNextFpIndex; 355 __le32 dwNextNdpIndex;
340 __le32 dwReserved12; 356 __le32 dwReserved12;
341 __u8 data[0]; 357 struct usb_cdc_ncm_dpe32 dpe32[0];
342} __attribute__ ((packed)); 358} __attribute__ ((packed));
343 359
360/* CDC NCM subclass 3.2.1 and 3.2.2 */
361#define USB_CDC_NCM_NDP16_INDEX_MIN 0x000C
362#define USB_CDC_NCM_NDP32_INDEX_MIN 0x0010
363
364/* CDC NCM subclass 3.3.3 Datagram Formatting */
365#define USB_CDC_NCM_DATAGRAM_FORMAT_CRC 0x30
366#define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC 0X31
367
368/* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */
369#define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS 0x00
370#define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO 0xFE
371
372/* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */
373#define USB_CDC_NCM_NCAP_ETH_FILTER (1 << 0)
374#define USB_CDC_NCM_NCAP_NET_ADDRESS (1 << 1)
375#define USB_CDC_NCM_NCAP_ENCAP_COMMAND (1 << 2)
376#define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE (1 << 3)
377#define USB_CDC_NCM_NCAP_CRC_MODE (1 << 4)
378
379/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
380#define USB_CDC_NCM_NTB16_SUPPORTED (1 << 0)
381#define USB_CDC_NCM_NTB32_SUPPORTED (1 << 1)
382
383/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
384#define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE 0x04
385#define USB_CDC_NCM_NTB_MAX_LENGTH 0x1C
386
387/* CDC NCM subclass 6.2.5 SetNtbFormat */
388#define USB_CDC_NCM_NTB16_FORMAT 0x00
389#define USB_CDC_NCM_NTB32_FORMAT 0x01
390
391/* CDC NCM subclass 6.2.7 SetNtbInputSize */
392#define USB_CDC_NCM_NTB_MIN_IN_SIZE 2048
393#define USB_CDC_NCM_NTB_MIN_OUT_SIZE 2048
394
395/* CDC NCM subclass 6.2.11 SetCrcMode */
396#define USB_CDC_NCM_CRC_NOT_APPENDED 0x00
397#define USB_CDC_NCM_CRC_APPENDED 0x01
398
344#endif /* __LINUX_USB_CDC_H */ 399#endif /* __LINUX_USB_CDC_H */
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index da2ed77d3e8d..f917bbbc8901 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -123,8 +123,23 @@
123#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ 123#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
124#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ 124#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
125 125
126/*
127 * New Feature Selectors as added by USB 3.0
128 * See USB 3.0 spec Table 9-6
129 */
130#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
131#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
132#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
133#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
134
135#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
136
126#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ 137#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
127 138
139/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
140#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
141#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
142#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
128 143
129/** 144/**
130 * struct usb_ctrlrequest - SETUP data for a USB device control request 145 * struct usb_ctrlrequest - SETUP data for a USB device control request
@@ -675,6 +690,7 @@ struct usb_bos_descriptor {
675 __u8 bNumDeviceCaps; 690 __u8 bNumDeviceCaps;
676} __attribute__((packed)); 691} __attribute__((packed));
677 692
693#define USB_DT_BOS_SIZE 5
678/*-------------------------------------------------------------------------*/ 694/*-------------------------------------------------------------------------*/
679 695
680/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */ 696/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
@@ -712,16 +728,56 @@ struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
712 __u8 bReserved; 728 __u8 bReserved;
713} __attribute__((packed)); 729} __attribute__((packed));
714 730
731/* USB 2.0 Extension descriptor */
715#define USB_CAP_TYPE_EXT 2 732#define USB_CAP_TYPE_EXT 2
716 733
717struct usb_ext_cap_descriptor { /* Link Power Management */ 734struct usb_ext_cap_descriptor { /* Link Power Management */
718 __u8 bLength; 735 __u8 bLength;
719 __u8 bDescriptorType; 736 __u8 bDescriptorType;
720 __u8 bDevCapabilityType; 737 __u8 bDevCapabilityType;
721 __u8 bmAttributes; 738 __le32 bmAttributes;
722#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ 739#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
723} __attribute__((packed)); 740} __attribute__((packed));
724 741
742#define USB_DT_USB_EXT_CAP_SIZE 7
743
744/*
745 * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
746 * specific device level capabilities
747 */
748#define USB_SS_CAP_TYPE 3
749struct usb_ss_cap_descriptor { /* Link Power Management */
750 __u8 bLength;
751 __u8 bDescriptorType;
752 __u8 bDevCapabilityType;
753 __u8 bmAttributes;
754#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
755 __le16 wSpeedSupported;
756#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
757#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
758#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
759#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
760 __u8 bFunctionalitySupport;
761 __u8 bU1devExitLat;
762 __le16 bU2DevExitLat;
763} __attribute__((packed));
764
765#define USB_DT_USB_SS_CAP_SIZE 10
766
767/*
768 * Container ID Capability descriptor: Defines the instance unique ID used to
769 * identify the instance across all operating modes
770 */
771#define CONTAINER_ID_TYPE 4
772struct usb_ss_container_id_descriptor {
773 __u8 bLength;
774 __u8 bDescriptorType;
775 __u8 bDevCapabilityType;
776 __u8 bReserved;
777 __u8 ContainerID[16]; /* 128-bit number */
778} __attribute__((packed));
779
780#define USB_DT_USB_SS_CONTN_ID_SIZE 20
725/*-------------------------------------------------------------------------*/ 781/*-------------------------------------------------------------------------*/
726 782
727/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with 783/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
@@ -808,4 +864,14 @@ enum usb_device_state {
808 */ 864 */
809}; 865};
810 866
867/*-------------------------------------------------------------------------*/
868
869/*
870 * As per USB compliance update, a device that is actively drawing
871 * more than 100mA from USB must report itself as bus-powered in
872 * the GetStatus(DEVICE) call.
873 * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
874 */
875#define USB_SELF_POWER_VBUS_MAX_DRAW 100
876
811#endif /* __LINUX_USB_CH9_H */ 877#endif /* __LINUX_USB_CH9_H */
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 617068134ae8..3d29a7dcac2d 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -161,8 +161,6 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
161 * and by language IDs provided in control requests. 161 * and by language IDs provided in control requests.
162 * @descriptors: Table of descriptors preceding all function descriptors. 162 * @descriptors: Table of descriptors preceding all function descriptors.
163 * Examples include OTG and vendor-specific descriptors. 163 * Examples include OTG and vendor-specific descriptors.
164 * @bind: Called from @usb_add_config() to allocate resources unique to this
165 * configuration and to call @usb_add_function() for each function used.
166 * @unbind: Reverses @bind; called as a side effect of unregistering the 164 * @unbind: Reverses @bind; called as a side effect of unregistering the
167 * driver which added this configuration. 165 * driver which added this configuration.
168 * @setup: Used to delegate control requests that aren't handled by standard 166 * @setup: Used to delegate control requests that aren't handled by standard
@@ -207,8 +205,7 @@ struct usb_configuration {
207 * we can't restructure things to avoid mismatching... 205 * we can't restructure things to avoid mismatching...
208 */ 206 */
209 207
210 /* configuration management: bind/unbind */ 208 /* configuration management: unbind/setup */
211 int (*bind)(struct usb_configuration *);
212 void (*unbind)(struct usb_configuration *); 209 void (*unbind)(struct usb_configuration *);
213 int (*setup)(struct usb_configuration *, 210 int (*setup)(struct usb_configuration *,
214 const struct usb_ctrlrequest *); 211 const struct usb_ctrlrequest *);
@@ -232,20 +229,24 @@ struct usb_configuration {
232}; 229};
233 230
234int usb_add_config(struct usb_composite_dev *, 231int usb_add_config(struct usb_composite_dev *,
235 struct usb_configuration *); 232 struct usb_configuration *,
233 int (*)(struct usb_configuration *));
236 234
237/** 235/**
238 * struct usb_composite_driver - groups configurations into a gadget 236 * struct usb_composite_driver - groups configurations into a gadget
239 * @name: For diagnostics, identifies the driver. 237 * @name: For diagnostics, identifies the driver.
238 * @iProduct: Used as iProduct override if @dev->iProduct is not set.
239 * If NULL value of @name is taken.
240 * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
241 * not set. If NULL a default "<system> <release> with <udc>" value
242 * will be used.
240 * @dev: Template descriptor for the device, including default device 243 * @dev: Template descriptor for the device, including default device
241 * identifiers. 244 * identifiers.
242 * @strings: tables of strings, keyed by identifiers assigned during bind() 245 * @strings: tables of strings, keyed by identifiers assigned during bind()
243 * and language IDs provided in control requests 246 * and language IDs provided in control requests
244 * @bind: (REQUIRED) Used to allocate resources that are shared across the 247 * @needs_serial: set to 1 if the gadget needs userspace to provide
245 * whole device, such as string IDs, and add its configurations using 248 * a serial number. If one is not provided, warning will be printed.
246 * @usb_add_config(). This may fail by returning a negative errno 249 * @unbind: Reverses bind; called as a side effect of unregistering
247 * value; it should return zero on successful initialization.
248 * @unbind: Reverses @bind(); called as a side effect of unregistering
249 * this driver. 250 * this driver.
250 * @disconnect: optional driver disconnect method 251 * @disconnect: optional driver disconnect method
251 * @suspend: Notifies when the host stops sending USB traffic, 252 * @suspend: Notifies when the host stops sending USB traffic,
@@ -256,7 +257,7 @@ int usb_add_config(struct usb_composite_dev *,
256 * Devices default to reporting self powered operation. Devices which rely 257 * Devices default to reporting self powered operation. Devices which rely
257 * on bus powered operation should report this in their @bind() method. 258 * on bus powered operation should report this in their @bind() method.
258 * 259 *
259 * Before returning from @bind, various fields in the template descriptor 260 * Before returning from bind, various fields in the template descriptor
260 * may be overridden. These include the idVendor/idProduct/bcdDevice values 261 * may be overridden. These include the idVendor/idProduct/bcdDevice values
261 * normally to bind the appropriate host side driver, and the three strings 262 * normally to bind the appropriate host side driver, and the three strings
262 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user 263 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
@@ -266,15 +267,12 @@ int usb_add_config(struct usb_composite_dev *,
266 */ 267 */
267struct usb_composite_driver { 268struct usb_composite_driver {
268 const char *name; 269 const char *name;
270 const char *iProduct;
271 const char *iManufacturer;
269 const struct usb_device_descriptor *dev; 272 const struct usb_device_descriptor *dev;
270 struct usb_gadget_strings **strings; 273 struct usb_gadget_strings **strings;
274 unsigned needs_serial:1;
271 275
272 /* REVISIT: bind() functions can be marked __init, which
273 * makes trouble for section mismatch analysis. See if
274 * we can't restructure things to avoid mismatching...
275 */
276
277 int (*bind)(struct usb_composite_dev *);
278 int (*unbind)(struct usb_composite_dev *); 276 int (*unbind)(struct usb_composite_dev *);
279 277
280 void (*disconnect)(struct usb_composite_dev *); 278 void (*disconnect)(struct usb_composite_dev *);
@@ -284,8 +282,9 @@ struct usb_composite_driver {
284 void (*resume)(struct usb_composite_dev *); 282 void (*resume)(struct usb_composite_dev *);
285}; 283};
286 284
287extern int usb_composite_register(struct usb_composite_driver *); 285extern int usb_composite_probe(struct usb_composite_driver *driver,
288extern void usb_composite_unregister(struct usb_composite_driver *); 286 int (*bind)(struct usb_composite_dev *cdev));
287extern void usb_composite_unregister(struct usb_composite_driver *driver);
289 288
290 289
291/** 290/**
@@ -334,6 +333,9 @@ struct usb_composite_dev {
334 struct list_head configs; 333 struct list_head configs;
335 struct usb_composite_driver *driver; 334 struct usb_composite_driver *driver;
336 u8 next_string_id; 335 u8 next_string_id;
336 u8 manufacturer_override;
337 u8 product_override;
338 u8 serial_override;
337 339
338 /* the gadget driver won't enable the data pullup 340 /* the gadget driver won't enable the data pullup
339 * while the deactivation count is nonzero. 341 * while the deactivation count is nonzero.
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index d3ef42d7d2f0..006412ce2303 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -705,11 +705,6 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
705 * struct usb_gadget_driver - driver for usb 'slave' devices 705 * struct usb_gadget_driver - driver for usb 'slave' devices
706 * @function: String describing the gadget's function 706 * @function: String describing the gadget's function
707 * @speed: Highest speed the driver handles. 707 * @speed: Highest speed the driver handles.
708 * @bind: Invoked when the driver is bound to a gadget, usually
709 * after registering the driver.
710 * At that point, ep0 is fully initialized, and ep_list holds
711 * the currently-available endpoints.
712 * Called in a context that permits sleeping.
713 * @setup: Invoked for ep0 control requests that aren't handled by 708 * @setup: Invoked for ep0 control requests that aren't handled by
714 * the hardware level driver. Most calls must be handled by 709 * the hardware level driver. Most calls must be handled by
715 * the gadget driver, including descriptor and configuration 710 * the gadget driver, including descriptor and configuration
@@ -774,7 +769,6 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
774struct usb_gadget_driver { 769struct usb_gadget_driver {
775 char *function; 770 char *function;
776 enum usb_device_speed speed; 771 enum usb_device_speed speed;
777 int (*bind)(struct usb_gadget *);
778 void (*unbind)(struct usb_gadget *); 772 void (*unbind)(struct usb_gadget *);
779 int (*setup)(struct usb_gadget *, 773 int (*setup)(struct usb_gadget *,
780 const struct usb_ctrlrequest *); 774 const struct usb_ctrlrequest *);
@@ -798,17 +792,19 @@ struct usb_gadget_driver {
798 */ 792 */
799 793
800/** 794/**
801 * usb_gadget_register_driver - register a gadget driver 795 * usb_gadget_probe_driver - probe a gadget driver
802 * @driver:the driver being registered 796 * @driver: the driver being registered
797 * @bind: the driver's bind callback
803 * Context: can sleep 798 * Context: can sleep
804 * 799 *
805 * Call this in your gadget driver's module initialization function, 800 * Call this in your gadget driver's module initialization function,
806 * to tell the underlying usb controller driver about your driver. 801 * to tell the underlying usb controller driver about your driver.
807 * The driver's bind() function will be called to bind it to a 802 * The @bind() function will be called to bind it to a gadget before this
808 * gadget before this registration call returns. It's expected that 803 * registration call returns. It's expected that the @bind() function will
809 * the bind() functions will be in init sections. 804 * be in init sections.
810 */ 805 */
811int usb_gadget_register_driver(struct usb_gadget_driver *driver); 806int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
807 int (*bind)(struct usb_gadget *));
812 808
813/** 809/**
814 * usb_gadget_unregister_driver - unregister a gadget driver 810 * usb_gadget_unregister_driver - unregister a gadget driver
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 3b571f1ffbb3..0b6e751ea0b1 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -329,6 +329,8 @@ extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags);
329extern int usb_hcd_unlink_urb(struct urb *urb, int status); 329extern int usb_hcd_unlink_urb(struct urb *urb, int status);
330extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, 330extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb,
331 int status); 331 int status);
332extern void unmap_urb_setup_for_dma(struct usb_hcd *, struct urb *);
333extern void unmap_urb_for_dma(struct usb_hcd *, struct urb *);
332extern void usb_hcd_flush_endpoint(struct usb_device *udev, 334extern void usb_hcd_flush_endpoint(struct usb_device *udev,
333 struct usb_host_endpoint *ep); 335 struct usb_host_endpoint *ep);
334extern void usb_hcd_disable_endpoint(struct usb_device *udev, 336extern void usb_hcd_disable_endpoint(struct usb_device *udev,
diff --git a/include/linux/usb/intel_mid_otg.h b/include/linux/usb/intel_mid_otg.h
new file mode 100644
index 000000000000..a0ccf795f362
--- /dev/null
+++ b/include/linux/usb/intel_mid_otg.h
@@ -0,0 +1,180 @@
1/*
2 * Intel MID (Langwell/Penwell) USB OTG Transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#ifndef __INTEL_MID_OTG_H
21#define __INTEL_MID_OTG_H
22
23#include <linux/pm.h>
24#include <linux/usb/otg.h>
25#include <linux/notifier.h>
26
27struct intel_mid_otg_xceiv;
28
29/* This is a common data structure for Intel MID platform to
30 * save values of the OTG state machine */
31struct otg_hsm {
32 /* Input */
33 int a_bus_resume;
34 int a_bus_suspend;
35 int a_conn;
36 int a_sess_vld;
37 int a_srp_det;
38 int a_vbus_vld;
39 int b_bus_resume;
40 int b_bus_suspend;
41 int b_conn;
42 int b_se0_srp;
43 int b_ssend_srp;
44 int b_sess_end;
45 int b_sess_vld;
46 int id;
47/* id values */
48#define ID_B 0x05
49#define ID_A 0x04
50#define ID_ACA_C 0x03
51#define ID_ACA_B 0x02
52#define ID_ACA_A 0x01
53 int power_up;
54 int adp_change;
55 int test_device;
56
57 /* Internal variables */
58 int a_set_b_hnp_en;
59 int b_srp_done;
60 int b_hnp_enable;
61 int hnp_poll_enable;
62
63 /* Timeout indicator for timers */
64 int a_wait_vrise_tmout;
65 int a_wait_bcon_tmout;
66 int a_aidl_bdis_tmout;
67 int a_bidl_adis_tmout;
68 int a_bidl_adis_tmr;
69 int a_wait_vfall_tmout;
70 int b_ase0_brst_tmout;
71 int b_bus_suspend_tmout;
72 int b_srp_init_tmout;
73 int b_srp_fail_tmout;
74 int b_srp_fail_tmr;
75 int b_adp_sense_tmout;
76
77 /* Informative variables */
78 int a_bus_drop;
79 int a_bus_req;
80 int a_clr_err;
81 int b_bus_req;
82 int a_suspend_req;
83 int b_bus_suspend_vld;
84
85 /* Output */
86 int drv_vbus;
87 int loc_conn;
88 int loc_sof;
89
90 /* Others */
91 int vbus_srp_up;
92};
93
94/* must provide ULPI access function to read/write registers implemented in
95 * ULPI address space */
96struct iotg_ulpi_access_ops {
97 int (*read)(struct intel_mid_otg_xceiv *iotg, u8 reg, u8 *val);
98 int (*write)(struct intel_mid_otg_xceiv *iotg, u8 reg, u8 val);
99};
100
101#define OTG_A_DEVICE 0x0
102#define OTG_B_DEVICE 0x1
103
104/*
105 * the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact
106 * with device and host drivers to implement the USB OTG related feature. More
107 * function members are added based on otg_transceiver data structure for this
108 * purpose.
109 */
110struct intel_mid_otg_xceiv {
111 struct otg_transceiver otg;
112 struct otg_hsm hsm;
113
114 /* base address */
115 void __iomem *base;
116
117 /* ops to access ulpi */
118 struct iotg_ulpi_access_ops ulpi_ops;
119
120 /* atomic notifier for interrupt context */
121 struct atomic_notifier_head iotg_notifier;
122
123 /* start/stop USB Host function */
124 int (*start_host)(struct intel_mid_otg_xceiv *iotg);
125 int (*stop_host)(struct intel_mid_otg_xceiv *iotg);
126
127 /* start/stop USB Peripheral function */
128 int (*start_peripheral)(struct intel_mid_otg_xceiv *iotg);
129 int (*stop_peripheral)(struct intel_mid_otg_xceiv *iotg);
130
131 /* start/stop ADP sense/probe function */
132 int (*set_adp_probe)(struct intel_mid_otg_xceiv *iotg,
133 bool enabled, int dev);
134 int (*set_adp_sense)(struct intel_mid_otg_xceiv *iotg,
135 bool enabled);
136
137#ifdef CONFIG_PM
138 /* suspend/resume USB host function */
139 int (*suspend_host)(struct intel_mid_otg_xceiv *iotg,
140 pm_message_t message);
141 int (*resume_host)(struct intel_mid_otg_xceiv *iotg);
142
143 int (*suspend_peripheral)(struct intel_mid_otg_xceiv *iotg,
144 pm_message_t message);
145 int (*resume_peripheral)(struct intel_mid_otg_xceiv *iotg);
146#endif
147
148};
149static inline
150struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct otg_transceiver *otg)
151{
152 return container_of(otg, struct intel_mid_otg_xceiv, otg);
153}
154
155#define MID_OTG_NOTIFY_CONNECT 0x0001
156#define MID_OTG_NOTIFY_DISCONN 0x0002
157#define MID_OTG_NOTIFY_HSUSPEND 0x0003
158#define MID_OTG_NOTIFY_HRESUME 0x0004
159#define MID_OTG_NOTIFY_CSUSPEND 0x0005
160#define MID_OTG_NOTIFY_CRESUME 0x0006
161#define MID_OTG_NOTIFY_HOSTADD 0x0007
162#define MID_OTG_NOTIFY_HOSTREMOVE 0x0008
163#define MID_OTG_NOTIFY_CLIENTADD 0x0009
164#define MID_OTG_NOTIFY_CLIENTREMOVE 0x000a
165
166static inline int
167intel_mid_otg_register_notifier(struct intel_mid_otg_xceiv *iotg,
168 struct notifier_block *nb)
169{
170 return atomic_notifier_chain_register(&iotg->iotg_notifier, nb);
171}
172
173static inline void
174intel_mid_otg_unregister_notifier(struct intel_mid_otg_xceiv *iotg,
175 struct notifier_block *nb)
176{
177 atomic_notifier_chain_unregister(&iotg->iotg_notifier, nb);
178}
179
180#endif /* __INTEL_MID_OTG_H */
diff --git a/include/linux/usb/langwell_otg.h b/include/linux/usb/langwell_otg.h
new file mode 100644
index 000000000000..51f17b16d312
--- /dev/null
+++ b/include/linux/usb/langwell_otg.h
@@ -0,0 +1,139 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#ifndef __LANGWELL_OTG_H
21#define __LANGWELL_OTG_H
22
23#include <linux/usb/intel_mid_otg.h>
24
25#define CI_USBCMD 0x30
26# define USBCMD_RST BIT(1)
27# define USBCMD_RS BIT(0)
28#define CI_USBSTS 0x34
29# define USBSTS_SLI BIT(8)
30# define USBSTS_URI BIT(6)
31# define USBSTS_PCI BIT(2)
32#define CI_PORTSC1 0x74
33# define PORTSC_PP BIT(12)
34# define PORTSC_LS (BIT(11) | BIT(10))
35# define PORTSC_SUSP BIT(7)
36# define PORTSC_CCS BIT(0)
37#define CI_HOSTPC1 0xb4
38# define HOSTPC1_PHCD BIT(22)
39#define CI_OTGSC 0xf4
40# define OTGSC_DPIE BIT(30)
41# define OTGSC_1MSE BIT(29)
42# define OTGSC_BSEIE BIT(28)
43# define OTGSC_BSVIE BIT(27)
44# define OTGSC_ASVIE BIT(26)
45# define OTGSC_AVVIE BIT(25)
46# define OTGSC_IDIE BIT(24)
47# define OTGSC_DPIS BIT(22)
48# define OTGSC_1MSS BIT(21)
49# define OTGSC_BSEIS BIT(20)
50# define OTGSC_BSVIS BIT(19)
51# define OTGSC_ASVIS BIT(18)
52# define OTGSC_AVVIS BIT(17)
53# define OTGSC_IDIS BIT(16)
54# define OTGSC_DPS BIT(14)
55# define OTGSC_1MST BIT(13)
56# define OTGSC_BSE BIT(12)
57# define OTGSC_BSV BIT(11)
58# define OTGSC_ASV BIT(10)
59# define OTGSC_AVV BIT(9)
60# define OTGSC_ID BIT(8)
61# define OTGSC_HABA BIT(7)
62# define OTGSC_HADP BIT(6)
63# define OTGSC_IDPU BIT(5)
64# define OTGSC_DP BIT(4)
65# define OTGSC_OT BIT(3)
66# define OTGSC_HAAR BIT(2)
67# define OTGSC_VC BIT(1)
68# define OTGSC_VD BIT(0)
69# define OTGSC_INTEN_MASK (0x7f << 24)
70# define OTGSC_INT_MASK (0x5f << 24)
71# define OTGSC_INTSTS_MASK (0x7f << 16)
72#define CI_USBMODE 0xf8
73# define USBMODE_CM (BIT(1) | BIT(0))
74# define USBMODE_IDLE 0
75# define USBMODE_DEVICE 0x2
76# define USBMODE_HOST 0x3
77#define USBCFG_ADDR 0xff10801c
78#define USBCFG_LEN 4
79# define USBCFG_VBUSVAL BIT(14)
80# define USBCFG_AVALID BIT(13)
81# define USBCFG_BVALID BIT(12)
82# define USBCFG_SESEND BIT(11)
83
84#define INTR_DUMMY_MASK (USBSTS_SLI | USBSTS_URI | USBSTS_PCI)
85
86enum langwell_otg_timer_type {
87 TA_WAIT_VRISE_TMR,
88 TA_WAIT_BCON_TMR,
89 TA_AIDL_BDIS_TMR,
90 TB_ASE0_BRST_TMR,
91 TB_SE0_SRP_TMR,
92 TB_SRP_INIT_TMR,
93 TB_SRP_FAIL_TMR,
94 TB_BUS_SUSPEND_TMR
95};
96
97#define TA_WAIT_VRISE 100
98#define TA_WAIT_BCON 30000
99#define TA_AIDL_BDIS 15000
100#define TB_ASE0_BRST 5000
101#define TB_SE0_SRP 2
102#define TB_SRP_INIT 100
103#define TB_SRP_FAIL 5500
104#define TB_BUS_SUSPEND 500
105
106struct langwell_otg_timer {
107 unsigned long expires; /* Number of count increase to timeout */
108 unsigned long count; /* Tick counter */
109 void (*function)(unsigned long); /* Timeout function */
110 unsigned long data; /* Data passed to function */
111 struct list_head list;
112};
113
114struct langwell_otg {
115 struct intel_mid_otg_xceiv iotg;
116 struct device *dev;
117
118 void __iomem *usbcfg; /* SCCBUSB config Reg */
119
120 unsigned region;
121 unsigned cfg_region;
122
123 struct work_struct work;
124 struct workqueue_struct *qwork;
125 struct timer_list hsm_timer;
126
127 spinlock_t lock;
128 spinlock_t wq_lock;
129
130 struct notifier_block iotg_notifier;
131};
132
133static inline
134struct langwell_otg *mid_xceiv_to_lnw(struct intel_mid_otg_xceiv *iotg)
135{
136 return container_of(iotg, struct langwell_otg, iotg);
137}
138
139#endif /* __LANGWELL_OTG_H__ */
diff --git a/include/linux/usb/ncm.h b/include/linux/usb/ncm.h
deleted file mode 100644
index 006d1064c8b2..000000000000
--- a/include/linux/usb/ncm.h
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 * USB CDC NCM auxiliary definitions
3 */
4
5#ifndef __LINUX_USB_NCM_H
6#define __LINUX_USB_NCM_H
7
8#include <linux/types.h>
9#include <linux/usb/cdc.h>
10#include <asm/unaligned.h>
11
12#define NCM_NTB_MIN_IN_SIZE 2048
13#define NCM_NTB_MIN_OUT_SIZE 2048
14
15#define NCM_CONTROL_TIMEOUT (5 * 1000)
16
17/* bmNetworkCapabilities */
18
19#define NCM_NCAP_ETH_FILTER (1 << 0)
20#define NCM_NCAP_NET_ADDRESS (1 << 1)
21#define NCM_NCAP_ENCAP_COMM (1 << 2)
22#define NCM_NCAP_MAX_DGRAM (1 << 3)
23#define NCM_NCAP_CRC_MODE (1 << 4)
24
25/*
26 * Here are options for NCM Datagram Pointer table (NDP) parser.
27 * There are 2 different formats: NDP16 and NDP32 in the spec (ch. 3),
28 * in NDP16 offsets and sizes fields are 1 16bit word wide,
29 * in NDP32 -- 2 16bit words wide. Also signatures are different.
30 * To make the parser code the same, put the differences in the structure,
31 * and switch pointers to the structures when the format is changed.
32 */
33
34struct ndp_parser_opts {
35 u32 nth_sign;
36 u32 ndp_sign;
37 unsigned nth_size;
38 unsigned ndp_size;
39 unsigned ndplen_align;
40 /* sizes in u16 units */
41 unsigned dgram_item_len; /* index or length */
42 unsigned block_length;
43 unsigned fp_index;
44 unsigned reserved1;
45 unsigned reserved2;
46 unsigned next_fp_index;
47};
48
49#define INIT_NDP16_OPTS { \
50 .nth_sign = NCM_NTH16_SIGN, \
51 .ndp_sign = NCM_NDP16_NOCRC_SIGN, \
52 .nth_size = sizeof(struct usb_cdc_ncm_nth16), \
53 .ndp_size = sizeof(struct usb_cdc_ncm_ndp16), \
54 .ndplen_align = 4, \
55 .dgram_item_len = 1, \
56 .block_length = 1, \
57 .fp_index = 1, \
58 .reserved1 = 0, \
59 .reserved2 = 0, \
60 .next_fp_index = 1, \
61 }
62
63
64#define INIT_NDP32_OPTS { \
65 .nth_sign = NCM_NTH32_SIGN, \
66 .ndp_sign = NCM_NDP32_NOCRC_SIGN, \
67 .nth_size = sizeof(struct usb_cdc_ncm_nth32), \
68 .ndp_size = sizeof(struct usb_cdc_ncm_ndp32), \
69 .ndplen_align = 8, \
70 .dgram_item_len = 2, \
71 .block_length = 2, \
72 .fp_index = 2, \
73 .reserved1 = 1, \
74 .reserved2 = 2, \
75 .next_fp_index = 2, \
76 }
77
78static inline void put_ncm(__le16 **p, unsigned size, unsigned val)
79{
80 switch (size) {
81 case 1:
82 put_unaligned_le16((u16)val, *p);
83 break;
84 case 2:
85 put_unaligned_le32((u32)val, *p);
86
87 break;
88 default:
89 BUG();
90 }
91
92 *p += size;
93}
94
95static inline unsigned get_ncm(__le16 **p, unsigned size)
96{
97 unsigned tmp;
98
99 switch (size) {
100 case 1:
101 tmp = get_unaligned_le16(*p);
102 break;
103 case 2:
104 tmp = get_unaligned_le32(*p);
105 break;
106 default:
107 BUG();
108 }
109
110 *p += size;
111 return tmp;
112}
113
114#endif /* __LINUX_USB_NCM_H */
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 545cba73ccaf..0a5b3711e502 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -164,8 +164,19 @@ otg_shutdown(struct otg_transceiver *otg)
164} 164}
165 165
166/* for usb host and peripheral controller drivers */ 166/* for usb host and peripheral controller drivers */
167#ifdef CONFIG_USB_OTG_UTILS
167extern struct otg_transceiver *otg_get_transceiver(void); 168extern struct otg_transceiver *otg_get_transceiver(void);
168extern void otg_put_transceiver(struct otg_transceiver *); 169extern void otg_put_transceiver(struct otg_transceiver *);
170#else
171static inline struct otg_transceiver *otg_get_transceiver(void)
172{
173 return NULL;
174}
175
176static inline void otg_put_transceiver(struct otg_transceiver *x)
177{
178}
179#endif
169 180
170/* Context: can sleep */ 181/* Context: can sleep */
171static inline int 182static inline int
diff --git a/include/linux/usb/storage.h b/include/linux/usb/storage.h
new file mode 100644
index 000000000000..d7fc910f1dc4
--- /dev/null
+++ b/include/linux/usb/storage.h
@@ -0,0 +1,48 @@
1#ifndef __LINUX_USB_STORAGE_H
2#define __LINUX_USB_STORAGE_H
3
4/*
5 * linux/usb/storage.h
6 *
7 * Copyright Matthew Wilcox for Intel Corp, 2010
8 *
9 * This file contains definitions taken from the
10 * USB Mass Storage Class Specification Overview
11 *
12 * Distributed under the terms of the GNU GPL, version two.
13 */
14
15/* Storage subclass codes */
16
17#define USB_SC_RBC 0x01 /* Typically, flash devices */
18#define USB_SC_8020 0x02 /* CD-ROM */
19#define USB_SC_QIC 0x03 /* QIC-157 Tapes */
20#define USB_SC_UFI 0x04 /* Floppy */
21#define USB_SC_8070 0x05 /* Removable media */
22#define USB_SC_SCSI 0x06 /* Transparent */
23#define USB_SC_LOCKABLE 0x07 /* Password-protected */
24
25#define USB_SC_ISD200 0xf0 /* ISD200 ATA */
26#define USB_SC_CYP_ATACB 0xf1 /* Cypress ATACB */
27#define USB_SC_DEVICE 0xff /* Use device's value */
28
29/* Storage protocol codes */
30
31#define USB_PR_CBI 0x00 /* Control/Bulk/Interrupt */
32#define USB_PR_CB 0x01 /* Control/Bulk w/o interrupt */
33#define USB_PR_BULK 0x50 /* bulk only */
34#define USB_PR_UAS 0x62 /* USB Attached SCSI */
35
36#define USB_PR_USBAT 0x80 /* SCM-ATAPI bridge */
37#define USB_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */
38#define USB_PR_SDDR55 0x82 /* SDDR-55 (made up) */
39#define USB_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
40#define USB_PR_FREECOM 0xf1 /* Freecom */
41#define USB_PR_DATAFAB 0xf2 /* Datafab chipsets */
42#define USB_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */
43#define USB_PR_ALAUDA 0xf4 /* Alauda chipsets */
44#define USB_PR_KARMA 0xf5 /* Rio Karma */
45
46#define USB_PR_DEVICE 0xff /* Use device's value */
47
48#endif
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index a4b947e470a5..71693d4a4fe1 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -58,7 +58,11 @@
58 US_FLAG(CAPACITY_OK, 0x00010000) \ 58 US_FLAG(CAPACITY_OK, 0x00010000) \
59 /* READ CAPACITY response is correct */ \ 59 /* READ CAPACITY response is correct */ \
60 US_FLAG(BAD_SENSE, 0x00020000) \ 60 US_FLAG(BAD_SENSE, 0x00020000) \
61 /* Bad Sense (never more than 18 bytes) */ 61 /* Bad Sense (never more than 18 bytes) */ \
62 US_FLAG(NO_READ_DISC_INFO, 0x00040000) \
63 /* cannot handle READ_DISC_INFO */ \
64 US_FLAG(NO_READ_CAPACITY_16, 0x00080000) \
65 /* cannot handle READ_CAPACITY_16 */
62 66
63#define US_FLAG(name, value) US_FL_##name = value , 67#define US_FLAG(name, value) US_FL_##name = value ,
64enum { US_DO_ALL_FLAGS }; 68enum { US_DO_ALL_FLAGS };
@@ -74,42 +78,7 @@ enum { US_DO_ALL_FLAGS };
74#define USB_US_TYPE(flags) (((flags) >> 24) & 0xFF) 78#define USB_US_TYPE(flags) (((flags) >> 24) & 0xFF)
75#define USB_US_ORIG_FLAGS(flags) ((flags) & 0x00FFFFFF) 79#define USB_US_ORIG_FLAGS(flags) ((flags) & 0x00FFFFFF)
76 80
77/* 81#include <linux/usb/storage.h>
78 * This is probably not the best place to keep these constants, conceptually.
79 * But it's the only header included into all places which need them.
80 */
81
82/* Sub Classes */
83
84#define US_SC_RBC 0x01 /* Typically, flash devices */
85#define US_SC_8020 0x02 /* CD-ROM */
86#define US_SC_QIC 0x03 /* QIC-157 Tapes */
87#define US_SC_UFI 0x04 /* Floppy */
88#define US_SC_8070 0x05 /* Removable media */
89#define US_SC_SCSI 0x06 /* Transparent */
90#define US_SC_LOCKABLE 0x07 /* Password-protected */
91
92#define US_SC_ISD200 0xf0 /* ISD200 ATA */
93#define US_SC_CYP_ATACB 0xf1 /* Cypress ATACB */
94#define US_SC_DEVICE 0xff /* Use device's value */
95
96/* Protocols */
97
98#define US_PR_CBI 0x00 /* Control/Bulk/Interrupt */
99#define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */
100#define US_PR_BULK 0x50 /* bulk only */
101
102#define US_PR_USBAT 0x80 /* SCM-ATAPI bridge */
103#define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */
104#define US_PR_SDDR55 0x82 /* SDDR-55 (made up) */
105#define US_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
106#define US_PR_FREECOM 0xf1 /* Freecom */
107#define US_PR_DATAFAB 0xf2 /* Datafab chipsets */
108#define US_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */
109#define US_PR_ALAUDA 0xf4 /* Alauda chipsets */
110#define US_PR_KARMA 0xf5 /* Rio Karma */
111
112#define US_PR_DEVICE 0xff /* Use device's value */
113 82
114/* 83/*
115 */ 84 */
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index d63533a4a59e..216af8538cc9 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -73,6 +73,7 @@ struct scsi_cmnd;
73#define SEND_DIAGNOSTIC 0x1d 73#define SEND_DIAGNOSTIC 0x1d
74#define ALLOW_MEDIUM_REMOVAL 0x1e 74#define ALLOW_MEDIUM_REMOVAL 0x1e
75 75
76#define READ_FORMAT_CAPACITIES 0x23
76#define SET_WINDOW 0x24 77#define SET_WINDOW 0x24
77#define READ_CAPACITY 0x25 78#define READ_CAPACITY 0x25
78#define READ_10 0x28 79#define READ_10 0x28
@@ -102,6 +103,7 @@ struct scsi_cmnd;
102#define WRITE_SAME 0x41 103#define WRITE_SAME 0x41
103#define UNMAP 0x42 104#define UNMAP 0x42
104#define READ_TOC 0x43 105#define READ_TOC 0x43
106#define READ_HEADER 0x44
105#define LOG_SELECT 0x4c 107#define LOG_SELECT 0x4c
106#define LOG_SENSE 0x4d 108#define LOG_SENSE 0x4d
107#define XDWRITEREAD_10 0x53 109#define XDWRITEREAD_10 0x53
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 50cb34ffef11..85867dcde335 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -148,6 +148,8 @@ struct scsi_device {
148 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ 148 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */
149 unsigned last_sector_bug:1; /* do not use multisector accesses on 149 unsigned last_sector_bug:1; /* do not use multisector accesses on
150 SD_LAST_BUGGY_SECTORS */ 150 SD_LAST_BUGGY_SECTORS */
151 unsigned no_read_disc_info:1; /* Avoid READ_DISC_INFO cmds */
152 unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */
151 unsigned is_visible:1; /* is the device visible in sysfs */ 153 unsigned is_visible:1; /* is the device visible in sysfs */
152 154
153 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ 155 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */